Purchase Order decimals for 1 supplier

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Purchase Order decimals for 1 supplier

Postby DannyC » Wed Jul 29, 2020 9:19 pm

Hi,

Revisiting this topic from a few years ago.
viewtopic.php?f=26&t=462&hilit=decimals

I have the identical dilemma from another client and was about to deploy the plugin when I thought I'd do some due diligence and just test it out in my demo.
BTW, this is for version 7.0.175 latest SR.

For one particular supplier my client wants the monetary decimals to be set to 4, local currency AUD.

So using the the code
Code: Select all
   Public Sub PurchaseOrder_CreateEnd(sender As Object, e As System.EventArgs)
      Dim purchaseOrder As JiwaPurchaseOrders.PurchaseOrder = DirectCast(sender, JiwaPurchaseOrders.PurchaseOrder)
      If purchaseOrder.Creditor.AccountNo = "5647" Then
         purchaseOrder.SystemSettings.MoneyDecimalPlaces = 4
      Else
         purchaseOrder.SystemSettings.MoneyDecimalPlaces = 2
      End If
   End Sub

It does what's expected and sets the money (unit price, line total, inc price) to 4 decimals. All is good, but when you enter in a unit price & the quantity, the Line Total calcs to 2 decimals. The display is 4, but the figure is 2 decimals.
Then the reverse happens when you enter in a Line Total to 4 decimal places, the Unit Price reverts to 2 decimals.

Is there another setting I need to configure so that all the values calculate to 4 decimals?

EDIT: Just tested in 7.2.1 SR4 and I get the same behaviour.
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Purchase Order decimals for 1 supplier

Postby SBarnes » Wed Jul 29, 2020 11:14 pm

There is a home currency decimal places on the line you might want to check the value of that, there is also an fx decimal places on the line as well, so check what they are set to.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Purchase Order decimals for 1 supplier

Postby DannyC » Thu Jul 30, 2020 9:19 am

There is a home currency decimal places on the line you might want to check the value of that, there is also an fx decimal places on the line as well, so check what they are set to.

Been there.

Fairly sure it's something within DoLineCalculations.

When the line values are calculated, Jiwa is calling a function ToMoneyDP. The last parameter is decimals, for example
Code: Select all
LineTotalIncTax = this.ToMoneyDP(decimal.Add(LineTotalExTax, LineTaxAmount), this.LocalCurrency.DecimalPlaces);


then a few lines down we can see this line
Code: Select all
LineTotalIncTax = this.ToMoneyDP(decimal.Multiply(UnitIncTax, Quantity), -1);


So sometimes Jiwa is using this.LocalCurrency.DecimalsPlaces, othertimes it is -1. I'm not sure what -1 would mean for decimals.

Dunno if the above is a red herring or not.
Last edited by DannyC on Thu Jul 30, 2020 9:39 am, edited 1 time in total.
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Purchase Order decimals for 1 supplier

Postby SBarnes » Thu Jul 30, 2020 9:37 am

In setting the quantity property almost the very last line is

Code: Select all
 this.Manager.DoLineCalculations(this._Quantity, ref this._Cost, ref this._LineTotalExTax, ref this._IncPrice, ref this._LineTotal, this._TaxRate, ref this._TaxAmount, this._FXDecimalPlaces, ref this._FXCost, ref this._FxTotal, ref num2, ref num3, ref num4, this._CurrencyRateUsed, true, this._FXChanged, this._ExChanged, this._TaxRateChanged);




That's why I said check those properties as I would bet setting the line total, price etc call the same calculation.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 2 guests