Page 1 of 1

Purchase Order decimals for 1 supplier

PostPosted: Wed Jul 29, 2020 9:19 pm
by DannyC
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.

Re: Purchase Order decimals for 1 supplier

PostPosted: Wed Jul 29, 2020 11:14 pm
by SBarnes
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.

Re: Purchase Order decimals for 1 supplier

PostPosted: Thu Jul 30, 2020 9:19 am
by DannyC
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.

Re: Purchase Order decimals for 1 supplier

PostPosted: Thu Jul 30, 2020 9:37 am
by SBarnes
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.