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.