Bug 30139: Fix javascript moneyFormat to be compatible with FR format

New way of formatting money amount to make it work with FR format

Test plan:
1- Set CurrencyFormat pref to FR
2- Activate Point of sale and cash register features
3- Add cash register
4- Add debit type that 'can be sold' with a price of 10.00
5- Go to point of sale, click on the item to purchase
6- Verify the Amount to be paid shows the wrong amount and can't be fixed on the interface
7- Apply the patch
8- Refresh the page and do step 5 again
9- Notice it now shows the right amount

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Shi Yao Wang 2022-05-10 13:34:15 -04:00 committed by Fridolin Somers
parent e0814f2cc0
commit b69e743ee3

View file

@ -203,26 +203,27 @@
var newValue = textObj.value;
var decAmount = "";
var dolAmount = "";
var decFlag = false;
var dolFlag = false;
var aChar = "";
for(var i=0; i < newValue.length; i++) {
aChar = newValue.substring(i, i+1);
if (aChar >= "0" && aChar <= "9") {
if(decFlag) {
decAmount = "" + decAmount + aChar;
for(var i = newValue.length; 0 < i; i--) {
aChar = newValue.substring(i-1, i);
if ("0" <= aChar && aChar <= "9") {
if(dolFlag) {
dolAmount = "" + aChar + dolAmount;
}
else {
dolAmount = "" + dolAmount + aChar;
decAmount = "" + aChar + decAmount;
}
}
if (aChar == ".") {
if (decFlag) {
dolAmount = "";
break;
if (aChar == "." || aChar == ",") {
dolFlag = true;
}
decFlag = true;
}
if (!dolFlag) {
dolAmount = decAmount;
decAmount = "";
}
if (dolAmount == "") {