Scheduler to automate sales order processing  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Scheduler to automate sales order processing  Topic is solved

Postby DannyC » Wed Mar 02, 2022 4:14 pm

Just wanted opinion on the best angle to attack setting up a schedule running every nn minutes to process sales orders.

I can either instantiate the Batch Processing object and simulate firing that. Sort of like
Code: Select all
JiwaFinancials.Jiwa.JiwaSales.BatchProcessing.BatchProcess batch = Plugin.Manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaSales.BatchProcessing.BatchProcess>(null);
batch.ProcessCandidates.Read();
batch.Process();


Or, I can knock up a SQL SELECT to get my candidate orders, basically like this forum topic viewtopic.php?f=26&t=1649
Populate a list as the attached plugin demonstrates (in that forum post, not this one).
Then just loop through the list and process one by one, like this:
Code: Select all
if (InvoiceIds.Count > 0)
{
   JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesOrder = Plugin.Manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder>(null);
   
   foreach (string invoiceID in InvoiceIds)
   {
      Plugin.Manager.LogEvent(String.Format("Processing invoice '{0}'", invoiceID), System.Diagnostics.EventLogEntryType.Information, 0, 0, true);   
      salesOrder.Read(invoiceID);

      salesOrder.Process() 
   }
}


I think my preference is the latter but would like to hear other thoughts.
And I can see the Process method has parameters for sales order report. Is that essential or can I leave the brackets blank?

EDIT: Re my last question about the brackets, I can see in the POS plugin that I can leave the .Process() brackets blank. :)
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Scheduler to automate sales order processing

Postby SBarnes » Tue Mar 08, 2022 5:32 pm

The problem with the latter is that it produces a batch number for every invoice.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Scheduler to automate sales order processing

Postby DannyC » Wed Mar 09, 2022 10:40 pm

I think my preference is the latter but would like to hear other thoughts.


That works. Was easier than I thought.
Not instantiating a batch object at all, so it's not creating a new batch for each sales order. It's just grabbing candidate orders via my SQL SELECT.
Then populating the list.
Then processing each one using salesOrder.Process().
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Scheduler to automate sales order processing

Postby SBarnes » Thu Mar 10, 2022 11:06 am

So long as you understand you are creating a line in SO_Run for every order you process individually i.e. the sales order process code does it.

With the batch object you could add to the ProcessCandidates collection by filling in a JiwaFinancials.Jiwa.JiwaSales.BatchProcessing.ProcessCandidate which is a Jiwa collection item object and then just adding it to process candidates and then just call process on the batch to get them all in one run.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 6 guests

cron