Batch Print / Emailing

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Batch Print / Emailing

Postby SBarnes » Tue Feb 05, 2019 2:34 pm

Can you give an example of how to use JiwaFinancials.Jiwa.JiwaSales.BatchPrinting.BatchPrint mainly to batch email invoices given a list of invoiceIDs that I already have to fill the candidates with?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Batch Print / Emailing

Postby DannyC » Wed Feb 06, 2019 9:11 am

To add some clarity, we have a schedule running every n minutes which processes orders. This is running fine.
The client now wants an email sent to the customer with their invoice - as if they'd manually clicked the 'email' ribbon button but done when the orders are processed.

I've spent ages fiddling with the plugin code to try & get it to email but nothing I try is working.
What do you suggest is the best way to do it?

As a last resort I though we could use the batch print/email and pass in the processed orders.

Either way, the client just needs to see an email has been sent to the customer.
v 7.2. C#
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Batch Print / Emailing

Postby Mike.Sheen » Wed Feb 06, 2019 10:50 am

Do you have anything in the Candidates collection? And does each item in the Candidates collection have at least one item in the Actions collection?

Candidates are just the sales orders. Actions are either email or print, and the report type to use and a few other properties.

You can manually add to the candidates and actions collection, or you can add using a range (which is passed to a stored procedure defined in system settings - default is usp_JIWA_SalesOrders_SOBatchPrintGetActions).

Here's some code showing how to do that:

Code: Select all
using System;
using JiwaFinancials.Jiwa.JiwaApplication;
using JiwaFinancials.Jiwa.JiwaODBC;
using JiwaFinancials.Jiwa;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var manager = new Manager();
            manager.Logon("localhost", "JiwaDemo720", database.AuthenticationModes.JiwaAuthentication, "Admin", "password");

            var batchPrint = manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaSales.BatchPrinting.BatchPrint>(null);
            // Add a range of invoices
            string minRunNo = "";
            string maxRunNo = "";
            batchPrint.GetDefaultRunNoRange(ref minRunNo, ref maxRunNo);

            string minDebtorName = "";
            string maxDebtorName = "";
            batchPrint.GetDefaultDebtorNameRange(ref minDebtorName, ref maxDebtorName);

            string minDebtorAccountNo = "";
            string maxDebtorAccountNo = "";
            batchPrint.GetDefaultDebtorAccountNoRange(ref minDebtorAccountNo, ref maxDebtorAccountNo);

            string minDebtorClassification = "";
            string maxDebtorClassification = "";
            batchPrint.GetDefaultDebtorClassificationRange(ref minDebtorClassification, ref maxDebtorClassification);

            string minDebtorGroup = "";
            string maxDebtorGroup = "";
            batchPrint.GetDefaultDebtorGroupRange(ref minDebtorGroup, ref maxDebtorGroup);

            batchPrint.GetActions("100500", "100500",
                                    1, batchPrint.GetMaximumSOHistoryNo(),
                                    minRunNo, maxRunNo,
                                    minDebtorName, maxDebtorName,
                                    minDebtorAccountNo, maxDebtorAccountNo,
                                    minDebtorClassification, maxDebtorClassification,
                                    minDebtorGroup, maxDebtorGroup,
                                    new DateTime(2000, 01, 01),
                                    DateTime.Now,
                                    new DateTime(2000, 01, 01),
                                    DateTime.Now,
                                    JiwaFinancials.Jiwa.JiwaSales.BatchPrinting.BatchPrint.BatchPrintOverrides.EmailOnly);
            batchPrint.Process();
        }
    }   
}


This will populate the candidates and actions collections - and then email.

Note that the email method is defined by a plugin - you need to have an email provider plugin enabled to send anything. Also note you cannot use Outlook as the provider when emailing from services. I provided a plugin in this forum post which adds to the staff member a drop-down field allowing you to specify how emails for that staff member should be sent - that may be of use if you have the requirement to mix email methods.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Batch Print / Emailing

Postby DannyC » Fri Feb 08, 2019 9:30 am

I've managed to send an email when each candidate gets processed but not using the batch.

I get the SalesOrderReport via different means (setting up a System Configuration setting where the invoice CR is saved) and then instead of using candidate which looks like a trimmed down entity of a full sales order, I instantiated the full sales order object and just used
Code: Select all
salesOrder.Email(salesOrderReport,from, to, etc etc etc)


Anyway, took me about a week to nut out around 10 lines of code but seems to be working sweet.
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests