DoLineCalculations() for Non-InventoryItems  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

DoLineCalculations() for Non-InventoryItems

Postby neil.interactit » Tue Aug 25, 2020 11:55 am

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
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: DoLineCalculations() for Non-InventoryItems

Postby Scott.Pearce » Tue Aug 25, 2020 12:02 pm

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.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: DoLineCalculations() for Non-InventoryItems

Postby neil.interactit » Fri Sep 11, 2020 12:35 pm

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
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: DoLineCalculations() for Non-InventoryItems

Postby Scott.Pearce » Mon Sep 14, 2020 10:45 am

I get this:

Screenshot.png


Everything appears to be in order. What is the issue you are having?
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: DoLineCalculations() for Non-InventoryItems

Postby neil.interactit » Mon Sep 14, 2020 12:34 pm

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
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

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

Postby Mike.Sheen » Mon Sep 14, 2020 1:47 pm

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).
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: DoLineCalculations() for Non-InventoryItems

Postby neil.interactit » Wed Sep 16, 2020 2:01 pm

Many thanks Mike! That works a treat.
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: No registered users and 4 guests