Skip to content

Commit

Permalink
use grid l10n instead of custom approximation
Browse files Browse the repository at this point in the history
  • Loading branch information
flack committed Feb 10, 2016
1 parent c3bb214 commit bc4a258
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions static/org.openpsa.invoices/invoices.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ function parse_input(string)
return parseFloat(string.replace(',' , '.'));
}

function format_number(input)
{
return $.fn.fmatter.number(input, $.jgrid.locales[$.jgrid.defaults.locale].formatter);
}

function calculate_row(id)
{
var price_unit = parse_input($("#price_per_unit_" + id).val()),
Expand All @@ -16,7 +21,7 @@ function calculate_row(id)
{
sum = price_unit * units;
}
$('#row_sum_' + id).html(sum.toFixed(2));
$('#row_sum_' + id).html(format_number(sum));
}

function calculate_total(table)
Expand All @@ -30,15 +35,14 @@ function calculate_total(table)
}
});

table.find('tfoot .totals').text(total.toFixed(2));
table.find('tfoot .totals').text(format_number(total));
}

function calculate_invoices_total(table)
{
var total = 0,
row_sum,
totals_field = table.closest('.ui-jqgrid-view').find('.ui-jqgrid-ftable .sum'),
decimal_separator = totals_field.text().slice(totals_field.text().length - 3, totals_field.text().length - 2);
totals_field = table.closest('.ui-jqgrid-view').find('.ui-jqgrid-ftable .sum');

table.find('tbody tr').not('.jqgfirstrow').each(function()
{
Expand All @@ -51,8 +55,7 @@ function calculate_invoices_total(table)
total += row_sum;
});

total = total.toFixed(2).replace('.', decimal_separator);
totals_field.text(total);
totals_field.text(format_number(total));
}

function process_invoice(button, action, invoice_url)
Expand Down

0 comments on commit bc4a258

Please sign in to comment.