Recurring Orders Processing - how to hook in on processing  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Recurring Orders Processing - how to hook in on processing

Postby neil.interactit » Wed Mar 21, 2018 11:15 am

Hey guys,

I can't quite see under the hood to work out how to correctly hook in with some extra business logic.

The requirement is to influence the quote creation on "Save" on the Recurring Orders Processing form. So in essence, given a sales quote with a line item description "Rent up to [DATE]", after processing the created sales order will have a line item description "Rent up to 21-Mar-2018" the supplied date being based on the "next activated" date of the quote.

Could you point me in the right direction to be able to hook in at the correct step of the processing?

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Recurring Orders Processing - how to hook in on processi

Postby Mike.Sheen » Wed Mar 21, 2018 7:33 pm

Hi Neil,

I think this should be fairly easy - if you could impart which version of Jiwa you're wanting this for, and your preferred language (C# or VB.Net), I can spend a few minutes whipping up a sample plugin for you.

I can't guide you with complete confidence without trying it out myself - so in order to answer your query I will make a plugin myself - but it'd be nice if I knew the Jiwa version and language you prefer so I can just offer you whatever plugin I conjured as part of the answer.

Mike
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Recurring Orders Processing - how to hook in on processi

Postby neil.interactit » Thu Mar 22, 2018 8:04 am

Great! Many thanks Mike. It's for Jiwa 175 in C#.
Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Recurring Orders Processing - how to hook in on processi  Topic is solved

Postby Mike.Sheen » Thu Mar 22, 2018 11:43 am

Plugin attached.

This was a bit trickier than it needed to be - our recurring batch in sales orders doesn't have events in place for when the sales order is being created - so I've added improvement DEV-6540 to address this.



Mike
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Recurring Orders Processing - how to hook in on processi

Postby neil.interactit » Thu Mar 22, 2018 3:31 pm

Thanks Mike. It actually makes me feel better that the events weren't there - as I couldn't find them and my wife would accuse me of a "man look"! I'll have a play with this. Thanks again!
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Recurring Orders Processing - how to hook in on processi

Postby Mike.Sheen » Tue Mar 27, 2018 6:51 pm

Just so this is clear - the plugin I provided works around the missing events and does what you wanted.

I raise this point because I note you've not download the sample plugin I attached to my post yet.
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Recurring Orders Processing - how to hook in on processi

Postby neil.interactit » Wed Mar 28, 2018 10:05 am

All good - I've been swamped with work for other clients - back on this today. Thanks again!
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Recurring Orders Processing - how to hook in on processi

Postby neil.interactit » Wed Mar 28, 2018 2:18 pm

Hi Mike,

Works a treat!

I've tweaked slightly to accommodate offsets, so [DATE-3] and [DATE+6] are now also valid. For interest, here's the updated code ...

Code: Select all
        public void SalesOrder_SaveStart(object sender, System.EventArgs e, JiwaFinancials.Jiwa.JiwaSales.RecurringBatch.RecurringBatch recurringBatch)
        {
            var salesOrder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)sender;

            if (salesOrder.QuoteID == null || salesOrder.QuoteID.Trim().Length <= 0) return;
            // find the matching line in the recurring batch for this sales order using the QuoteID
            var batchLine = recurringBatch.BatchLines.Cast<JiwaFinancials.Jiwa.JiwaSales.RecurringBatch.BatchLine>().FirstOrDefault(x => x.SourceQuoteID == salesOrder.QuoteID);
            if (batchLine == null) return;
            // Replace the [DATE+/-XX] text on each line description to be the batch lines quote activation date
            foreach (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine salesOrderLine in salesOrder.SalesOrderLines)
                foreach (Match match in Regex.Matches(salesOrderLine.Description, @"\[DATE([\+-]*)(\d*)\]"))
                {
                    var realdate = match.Groups[0].Value == "[DATE]" ? batchLine.QuoteNextActivateDate : batchLine.QuoteNextActivateDate.AddDays((match.Groups[1].Value == "-" ? -1 : 1) * int.Parse(match.Groups[2].Value));
                    salesOrderLine.Description = salesOrderLine.Description.Replace(match.Groups[0].Value, realdate.ToString("dd-MMM-yyyy"));
                }
        }
    }

Thanks,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6


Return to Technical and or Programming

Who is online

Users browsing this forum: Google [Bot] and 23 guests

cron