Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0039103
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Retail Modules] Web POSmajoralways2018-08-08 12:422019-01-28 18:33
ReportergorkaionView Statuspublic 
Assigned Torqueralta 
PriorityurgentResolutionfixedFixed in VersionRR18Q4
StatusclosedFix in branchFixed in SCM revision8374a14c7516
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Tomarvintm
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0039103: Wrong payment amoutns when there are payments in different currencies

DescriptionOn an order with 3 different payments:

1st non cash payment (credit card for example)
2nd foreign cash payment.
3rd store currency cash payment.

The third payment generates a change amount.
If the change amount converted to the foreign cash is zero the original amount of the 2nd cash payments is reduced by the change amount.

This results on payments for less amount of the order gross.

When the payment is synchronized to the backend the difference in the amount is added to the 1st payment.
Steps To ReproduceCreate a store using AED currency. Ensure that credit card and cash financial accounts are in AED.
Set a conversion rate to USD so 3.6USD are 1EUR.
Ensure that there is cash to return change in AED.

Create a ticket for a total amount of 552.78AED.
Add a card payment of 100AED
Add a USD Cash payment of 100 USD -> converted to 360AED
Add a cash payment of 92.79AED
The total amount paid is 552.79AED so a change of 0.01AED is required.

Click on Done button.

Notice that the amounts of the payments are changed to:
USD Cash payment -> 100USD (359.99AED)
Cash Payment -> 92.78

Go to backend and check the payment details of the order, the amounts are:
Credit card: 100.01
USD Cash 359.99
Cash: 92.78

The credit card and USD cash amounts are wrong.
Proposed SolutionThe issue is in the following lines of hte adjustPayments:

p.set('origAmount', OB.DEC.mul(p.get('amount'), p.get('rate')));
//Here we are trying to know if the current payment is making the pending to pay 0.
//to know that we are suming up every payments except the current one (getSumOfOrigAmounts)
//then we substract this amount from the total (getDifferenceBetweenPaymentsAndTotal)
//and finally we transform this difference to the foreign amount
//if the payment in the foreign amount makes pending to pay zero, then we will ensure that the payment
//in the default currency is satisfied
if (OB.DEC.compare(OB.DEC.sub(this.getDifferenceRemovingSpecificPayment(p), OB.DEC.abs(p.get('amount')))) === OB.DEC.Zero) {
  multiCurrencyDifference = this.getDifferenceBetweenPaymentsAndTotal(p);
  if (OB.DEC.abs(p.get('origAmount')) !== OB.DEC.abs(multiCurrencyDifference)) {
    p.set('origAmount', multiCurrencyDifference);
  }
}

The this.getDifferenceRemovingSpecificPayment(p) method for the USD cash is returning 100USD as it is the rounded conversion of 359.99 to USD. If the change amount is higher the method does not return 100 and the payment is not modified.
TagsNo tags attached.
Attached Files? file icon wrong-payments.json [^] (18,692 bytes) 2018-08-08 12:43

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0106193)
gorkaion (developer)
2018-08-08 12:45

Attached the json generated with the amounts of the steps to reproduce.

You can check how the payments sum 552.77 instead of 552.78 because the USD Cash payment is reduced to 359.99

Later the OrderLoader adds the 0.01 missing to the first payment.
(0106356)
hgbot (developer)
2018-08-15 21:12

Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 8374a14c75162946681011922a7bcc6557014f0b
Author: Rafael Queralta <rafaelcuba81 <at> gmail.com>
Date: Wed Aug 15 11:39:07 2018 -0400
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/8374a14c75162946681011922a7bcc6557014f0b [^]

Fixed issue 39103: Wrong payment amoutns when there are payments in different
currencies

- Into getDifferenceBetweenPaymentsAndTotal function was taked into account the
change if exist.

---
M web/org.openbravo.retail.posterminal/js/model/order.js
---
(0107888)
hgbot (developer)
2018-11-13 15:54

Repository: tools/automation/pi-mobile
Changeset: 2a0b9df1dcea610a9f8ae0c9823245a5ca90bc56
Author: Alejandro <alekosmp86 <at> gmail.com>
Date: Tue Nov 13 09:44:22 2018 -0500
URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/2a0b9df1dcea610a9f8ae0c9823245a5ca90bc56 [^]

Related to issue 39103: added automated test

---
M src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/payment/I33898_VerifyRoundingWhenPayingInForeignCurrency.java
A src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/payment/I39103_VerifyPaymentAmountsInDifferentCurrencies.java
---
(0108894)
hgbot (developer)
2019-01-10 14:00

Repository: erp/pmods/org.openbravo.retail.sampledata
Changeset: 5fea2a6c56faafb1eff0dc93c4353bdf1c88bc90
Author: Ranjith S R <ranjith <at> qualiantech.com>
Date: Thu Jan 10 18:30:14 2019 +0530
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.sampledata/rev/5fea2a6c56faafb1eff0dc93c4353bdf1c88bc90 [^]

Fixed issue 39874 : Added Sample data for Currency Conversion

* Added Sample data for Currency Conversion for the issue 39103
* Added Sample data for Currency Conversion for the issue 33059

---
M referencedata/sampledata/The_White_Valley_Group/C_CONVERSION_RATE.xml
---
(0109285)
hgbot (developer)
2019-01-28 18:33

Repository: tools/automation/pi-mobile
Changeset: 74e8b350af0917d685e42dadade009729a373252
Author: Alejandro <alekosmp86 <at> gmail.com>
Date: Wed Jan 23 14:50:41 2019 -0500
URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/74e8b350af0917d685e42dadade009729a373252 [^]

Related to issue 39103: test has been refactored due it no longer creates its
own sampledata

---
M src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/payment/I39103_VerifyPaymentAmountsInDifferentCurrencies.java
---

- Issue History
Date Modified Username Field Change
2018-08-08 12:42 gorkaion New Issue
2018-08-08 12:42 gorkaion Assigned To => Retail
2018-08-08 12:42 gorkaion Resolution time => 1535493600
2018-08-08 12:42 gorkaion Triggers an Emergency Pack => No
2018-08-08 12:43 gorkaion File Added: wrong-payments.json
2018-08-08 12:45 gorkaion Note Added: 0106193
2018-08-09 14:45 rqueralta Assigned To Retail => rqueralta
2018-08-09 14:46 rqueralta Status new => scheduled
2018-08-15 21:12 hgbot Checkin
2018-08-15 21:12 hgbot Note Added: 0106356
2018-08-15 21:12 hgbot Status scheduled => resolved
2018-08-15 21:12 hgbot Resolution open => fixed
2018-08-15 21:12 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/8374a14c75162946681011922a7bcc6557014f0b [^]
2018-08-23 11:55 marvintm Review Assigned To => marvintm
2018-08-23 11:55 marvintm Status resolved => closed
2018-08-23 11:55 marvintm Fixed in Version => RR18Q4
2018-11-13 15:54 hgbot Checkin
2018-11-13 15:54 hgbot Note Added: 0107888
2019-01-10 14:00 hgbot Checkin
2019-01-10 14:00 hgbot Note Added: 0108894
2019-01-28 18:33 hgbot Checkin
2019-01-28 18:33 hgbot Note Added: 0109285


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker