Sales Quote Line Update Optimization  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Sales Quote Line Update Optimization

Postby nsbandara » Tue Jan 09, 2018 7:02 pm

Jiwa version : 7.0.129

I'm working on a plugin that updates open sales quote entries when an inventory item is updated.

Code: Select all
        List<OpenQuotesLines> openQuoteLines = ReadOpenQuoteLines(inventory.InventoryID); //read quote ids, line keys
        if (openQuoteLines.Any())
        {
            string[] openQuotes = openQuoteLines.Select(ql => ql.InvoiceID).Distinct().ToArray();
            JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote quoteBo = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote>(null);

            foreach (string openQuote in openQuotes)
            {
                quoteBo.Read(openQuote);

                string[] quoteLines = openQuoteLines.Where(ql => ql.InvoiceID == openQuote).Select(ql => ql.InvoiceLineID).ToArray();
                foreach (var quoteLineKey in quoteLines)
                {
                    JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuoteLine quoteLine = quoteBo.SalesQuoteLines[quoteLineKey];
                       
                    quoteLine.Description = inventory.Description;
                    quoteLine.ClassificationDescription = inventory.Classification.Description;
                    quoteLine.Units = inventory.UnitMeasure;
                    quoteLine.Cat1Description = inventory.Category1.Description;
                    quoteLine.Cat2Description = inventory.Category2.Description;
                    quoteLine.Cat3Description = inventory.Category3.Description;
                    quoteLine.CostIn = inventory.LCost;
                   quoteLine.SellPriceExGST = inventory.LCost; //price update, use jiwa library to update GST calc
                }

                quoteBo.Save();
            }

        }


If there was no price update I could run a SQL command to update other fields. But since we need to update prices I had to use Jiwa library functions. Issue I'm experiencing is it gets really slow as it load whole quote entry when do the update.

My questions are
1) Is there any alternative option to do the sales quote update including item price ?
2) Does Quote.Save() support async execution?

Thanks.
User avatar
nsbandara
Occasional Contributor
Occasional Contributor
 
Posts: 43
Joined: Tue Jul 16, 2013 5:02 pm
Location: Sri Lanka
Topics Solved: 11

Re: Sales Quote Line Update Optimization  Topic is solved

Postby Mike.Sheen » Tue Jan 16, 2018 12:59 pm

nsbandara wrote:1) Is there any alternative option to do the sales quote update including item price ?


No - using the existing quote business logic is the only way to ensure the business logic rules are enforced and all relevant fields calculated correctly.

nsbandara wrote:2) Does Quote.Save() support async execution?


No - the Save method of the quote does in fact use asynchronous calls for saving the lines, notes, documents, et cetera - but the save itself is synchronous. You could still make your code asynchronous, however - and it would result in asynchronously reading and saving all those quotes.
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


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 37 guests