Page 1 of 1

DoLineCalculations() for Non-InventoryItems

PostPosted: Tue Aug 25, 2020 11:55 am
by neil.interactit
Hey guys,

I had the following code, which worked well ...

Code: Select all
            salesOrder.SalesOrderLines.AddInventoryItem(inventory.InventoryID, JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLineCollection.SalesOrderLineInventorySeedTypes.e_SalesOrderLineInventoryID, ref newKey);
            var salesOrderLine = salesOrder.SalesOrderLines[newKey.ToString()];
            salesOrderLine.PriceIncGST = orderLine.UnitPrice;
            salesOrderLine.DoLineCalculations(orderLine.Gst ? "PriceIncGST" : "SellPriceExGST");

Then the client wanted the line items to be non-inventory, so I changed the first line to ...

Code: Select all
            salesOrder.SalesOrderLines.AddNonInventoryItem(orderLine.CostAccount, orderLine.UnitPrice, 0, ref newKey);

Since that change, the DoLineCalculations() no longer seems to work correctly, and now all line items are processed as "PriceIncGST".

Can you advise?

Cheers,
Neil

Re: DoLineCalculations() for Non-InventoryItems

PostPosted: Tue Aug 25, 2020 12:02 pm
by Scott.Pearce
If you can set me up a ready-to-go plugin (or 2) that adds an inventory item each way, I can trace into DoLineCalculations() to see what's going on. Do it in demo data and tell me what you are expecting the outputs to be in each case.

Re: DoLineCalculations() for Non-InventoryItems

PostPosted: Fri Sep 11, 2020 12:35 pm
by neil.interactit
Hi Scott,

Sorry for the delay - I finally had a hole in my schedule to code up the demo plugin ... https://1drv.ms/u/s!AtpPHb6crliZjIEmC5h ... w?e=pWSv2i. It's pretty quick/dirty and is hardcoded to demo database ledgers and inventory.

To use: Sales / Order Entry / Utilities / Do Test. Then "Last (F9)" to see the added SOE.

With this demo, I am seeing Ex/Inc gst not work with both inventory and non-inventory items. It may be that the demo database has a system setting different from the client database, or maybe that the plugin code needs a retrofit to be compatible with 7.02???

Thanks for your help with this.

Cheers,
Neil

Re: DoLineCalculations() for Non-InventoryItems

PostPosted: Mon Sep 14, 2020 10:45 am
by Scott.Pearce
I get this:

Screenshot.png


Everything appears to be in order. What is the issue you are having?

Re: DoLineCalculations() for Non-InventoryItems

PostPosted: Mon Sep 14, 2020 12:34 pm
by neil.interactit
Hi Scott,

The intent is to add either inc or exl GST items. The seemed to be working previously using "PriceIncGST" and "SellPriceExGST" ... so I was expecting:
90.91 100.00 9.09
100.00 100.00 0.00
90.91 100.00 9.09
100.00 100.00 0.00

Could you adjust the test code to show the correct approach to add both GST and non-GST items for both inventory and non-inventory?

Cheers,
Neil

Re: DoLineCalculations() for Non-InventoryItems  Topic is solved

PostPosted: Mon Sep 14, 2020 1:47 pm
by Mike.Sheen
The SellPriceExGST is not for indicating if an item is exluding GST - it's simply the price excluding tax.

What you seem to be wanting to do is set the tax rate on the lines you want to be exclusive of GST. Also don't bother with the invoking of the DoLineCalculations method - you should not need to do that if you simply set the Tax Rate of the line.

You set the tax rate of the line by calling the ReadRecord method of the Tax property - for example:

Code: Select all
SalesOrder.SalesOrderLines[key].TaxRate.ReadRecord("TaxIDInHere");


Note the tax ID can be obtained from the GstTaxRates property of the SalesOrder which is a collection of rates applicable (it's a different set of rates when a credit note, but you can just use the same collection regardless).

Re: DoLineCalculations() for Non-InventoryItems

PostPosted: Wed Sep 16, 2020 2:01 pm
by neil.interactit
Many thanks Mike! That works a treat.