Don't show zeros on invoice

This commit is contained in:
Hillel Coren 2017-10-17 14:38:02 +03:00
parent 79532ce2f6
commit b7ed5e98af
4 changed files with 13 additions and 7 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -497,7 +497,7 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
var row = []; var row = [];
var item = invoice.invoice_items[i]; var item = invoice.invoice_items[i];
var cost = formatMoneyInvoice(item.cost, invoice, null, getPrecision(item.cost)); var cost = NINJA.parseFloat(item.cost) ? formatMoneyInvoice(item.cost, invoice, null, getPrecision(item.cost)) : ' ';
var qty = NINJA.parseFloat(item.qty) ? roundSignificant(NINJA.parseFloat(item.qty)) + '' : ''; var qty = NINJA.parseFloat(item.qty) ? roundSignificant(NINJA.parseFloat(item.qty)) + '' : '';
var notes = item.notes; var notes = item.notes;
var productKey = item.product_key; var productKey = item.product_key;
@ -553,7 +553,9 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
lineTotal += taxAmount1 + taxAmount2; lineTotal += taxAmount1 + taxAmount2;
} }
lineTotal = formatMoneyInvoice(lineTotal, invoice); if (lineTotal != 0) {
lineTotal = formatMoneyInvoice(lineTotal, invoice);
}
rowStyle = (grid.length % 2 == 0) ? 'even' : 'odd'; rowStyle = (grid.length % 2 == 0) ? 'even' : 'odd';
if (invoice.has_product_key) { if (invoice.has_product_key) {

View File

@ -863,6 +863,8 @@ function ItemModel(data) {
var cost = parseFloat(this.cost()); var cost = parseFloat(this.cost());
if (cost) { if (cost) {
this.cost(cost.toFixed(Math.max(2, precision))); this.cost(cost.toFixed(Math.max(2, precision)));
} else {
this.cost('');
} }
this.qty(roundSignificant(this.qty())); this.qty(roundSignificant(this.qty()));
} }
@ -1012,9 +1014,11 @@ ko.bindingHandlers.productTypeahead = {
if (datum.notes && (!model.notes() || !model.task_public_id())) { if (datum.notes && (!model.notes() || !model.task_public_id())) {
model.notes(datum.notes); model.notes(datum.notes);
} }
if (datum.cost) { if (parseFloat(datum.cost)) {
if (! model.cost() || ! model.task_public_id()) { if (! model.cost() || ! model.task_public_id()) {
model.cost(roundSignificant(datum.cost, 2)); var cost = roundSignificant(datum.cost);
var precision = getPrecision(cost);
model.cost(cost.toFixed(precision));
} }
} }
if (!model.qty()) { if (!model.qty()) {