X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Ft%2Fkivi%2Fparse_amount.js;fp=js%2Ft%2Fkivi%2Fparse_amount.js;h=8df776736021e15db7fcb0da076dd54a540dc617;hb=53593baa211863fbf66540cf1bcc36c8fb37257f;hp=d0c6e884f6bb2067691540db895b2606112c2930;hpb=deb4d2dbb676d7d6f69dfe7815d6e0cb09bd4a44;p=kivitendo-erp.git diff --git a/js/t/kivi/parse_amount.js b/js/t/kivi/parse_amount.js index d0c6e884f..8df776736 100644 --- a/js/t/kivi/parse_amount.js +++ b/js/t/kivi/parse_amount.js @@ -81,3 +81,43 @@ QUnit.test("kivi.parse_amount function English number style without thousand sep assert.equal(kivi.parse_amount('1010.987654321'), 1010.987654321, '1010.987654321'); assert.equal(kivi.parse_amount('1,010.987654321'), 1010.987654321, '1,010.987654321'); }); + +QUnit.test("kivi.parse_amount function Swiss number style with thousand separator", function( assert ) { + kivi.setup_formats({ numbers: '1\'000.00' }); + + assert.equal(kivi.parse_amount('10.00'), 10, '10.00'); + assert.equal(kivi.parse_amount('10.'), 10, '10.'); + assert.equal(kivi.parse_amount('1010.00'), 1010, '1010.00'); + assert.equal(kivi.parse_amount('1010.'), 1010, '1010.'); + assert.equal(kivi.parse_amount('1\'010.00'), 1010, '1\'010.00'); + assert.equal(kivi.parse_amount('1\'010.'), 1010, '1\'010.'); + assert.equal(kivi.parse_amount('9\'080\'070\'060\'050\'040\'030\'020\'010.00'), 9080070060050040030020010, '9\'080\'070\'060\'050\'040\'030\'020\'010.00'); + assert.equal(kivi.parse_amount('9\'080\'070\'060\'050\'040\'030\'020\'010.'), 9080070060050040030020010, '9\'080\'070\'060\'050\'040\'030\'020\'010.'); + + assert.equal(kivi.parse_amount('10.98'), 10.98, '10.98'); + assert.equal(kivi.parse_amount('1010.98'), 1010.98, '1010.98'); + assert.equal(kivi.parse_amount('1\'010.98'), 1010.98, '1\'010.98'); + + assert.equal(kivi.parse_amount('10.987654321'), 10.987654321, '10.987654321'); + assert.equal(kivi.parse_amount('1010.987654321'), 1010.987654321, '1010.987654321'); + assert.equal(kivi.parse_amount('1\'010.987654321'), 1010.987654321, '1\'010.987654321'); +}); + +QUnit.test("kivi.parse_amount function numbers with leading 0 should still be parsed as decimal and not octal", function( assert ) { + kivi.setup_formats({ numbers: '1000,00' }); + + assert.equal(kivi.parse_amount('0123456789'), 123456789, '0123456789'); + assert.equal(kivi.parse_amount('000123456789'), 123456789, '000123456789'); +}); + +QUnit.test("kivi.parse_amount function German number style with thousand separator & contains invalid characters", function( assert ) { + kivi.setup_formats({ numbers: '1.000,00' }); + + assert.equal(kivi.parse_amount('iuh !@#$% 10,00'), undefined, 'iuh !@#$% 10,00'); +}); + +QUnit.test("kivi.parse_amount function German number style with thousand separator & invalid math expression", function( assert ) { + kivi.setup_formats({ numbers: '1.000,00' }); + + assert.equal(kivi.parse_amount('54--42'), undefined, '54--42'); +});