MARX#58496: Handmatige factuur invoer. Btw bedrag in eerste instantie soms onjuist.

svn path=/Website/branches/v2019.1/; revision=43395
This commit is contained in:
Maykel Geerdink
2019-07-17 12:41:29 +00:00
parent d090d7d912
commit 47cd6e0ccb

View File

@@ -810,58 +810,11 @@ function allowInputExpression(thisObj)
}
}
// Afronden van geldbedragen.
// roundcurr(1.275, 2); // Returns 1.28
// roundcurr(-1.275, 2); // Returns -1.28
// roundcurr(1.27499, 2); // Returns 1.27
// roundcurr(-1.27499, 2); // Returns -1.27
// roundcurr(1.2345678e+2, 2); // Returns 123.46
// roundcurr(1234.5678, -2); // Returns 1200
// roundcurr(123.45); // Returns 123
function roundcurr(value, exp) {
if (typeof exp === 'undefined' || +exp === 0)
return Math.round(value);
value = +value;
exp = +exp;
if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0))
return NaN;
// Negatieve getallen voor het afronden even positief maken.
var negatief = false;
if (value < 0)
{
negatief = true;
value = value * -1;
}
// Shift
value = value.toString().split('e');
value = Math.round(+(value[0] + 'e' + (value[1]? (+value[1] + exp) : exp)));
// Negatieve getallen weer negatief maken.
if (negatief)
value = value * -1;
// Shift back
value = value.toString().split('e');
value = +(value[0] + 'e' + (value[1]? (+value[1] - exp) : -exp))
return (value).toFixed(exp); // value is al afgerond. ik kan nu gerust toFixed() gebruiken om eind nullen terug te krijgen (1.5toFixed(2) => 1.50).
}
// Voorheen num2curr.js
function num2curr(s) {
// debugger;
if( !isNaN(s) ) {
// MARX#58496: Be careful using ".toFixed()" as it might return different rounding results for different browsers.
//
// Afronding waarde.toFixed(2) voor verschillende browsers:
// IE: 251,075 => 251,08,
// FF,Crome: 251,075 => 251,07)
//
// Therefore we use roundcurr instead.
//s = s.toFixed(2);
s = roundcurr(s, 2);
s = s.toFixed(2);
}
return s;
}
@@ -875,15 +828,7 @@ function num2currEditable(fnum, decimals)
if (typeof decimals == "undefined")
decimals = 2;
// MARX#58496: Be careful using ".toFixed()" as it might return different rounding results for different browsers.
//
// Afronding waarde.toFixed(2) voor verschillende browsers:
// IE: 251,075 => 251,08,
// FF,Crome: 251,075 => 251,07)
//
// Therefore we use roundcurr instead.
//fnum = fnum.toFixed(decimals);
fnum = roundcurr(fnum, decimals);
fnum = fnum.toFixed(decimals);
var waarde2 = (1.5).toLocaleString(); // Eventueel gewenste komma.
fnum = fnum.substring(0, fnum.length - decimals - 1) + waarde2.substring(2, 1) + fnum.substring(fnum.length - decimals);