Bug 23354: Format price on item add

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2019-11-20 12:38:57 +00:00
parent e71b615cf6
commit b151f71ddc
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F

View file

@ -183,18 +183,6 @@
[% INCLUDE 'datatables.inc' %]
[% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
<script>
function fnClickAddRow( table, invoiceCode, invoiceTitle, invoicePrice ) {
table.fnAddData( [
invoiceTitle,
invoicePrice,
1,
null,
'<button class="drop"><i class="fa fa-trash"></i> Remove</button>',
invoiceCode
]
);
}
function moneyFormat(textObj) {
var newValue = textObj.value;
var decAmount = "";
@ -244,6 +232,20 @@
textObj.value = dolAmount + "." + decAmount;
}
function fnClickAddRow( table, invoiceCode, invoiceTitle, invoicePrice ) {
var defaultPrice = { value: invoicePrice };
moneyFormat(defaultPrice);
table.fnAddData( [
invoiceTitle,
defaultPrice.value,
1,
null,
'<button class="drop"><i class="fa fa-trash"></i> Remove</button>',
invoiceCode
]
);
}
function updateChangeValues() {
var change = $('#change')[0];
change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;