mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Only show line item discounts if set
This commit is contained in:
parent
b90d918925
commit
8c8ebf75c6
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -519,6 +519,12 @@ NINJA.invoiceColumns = function(invoice, design, isTasks)
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else if (field == 'product.discount') {
|
||||
if (invoice.has_item_discounts) {
|
||||
width = 15;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else if (field == 'product.description') {
|
||||
width = 0;
|
||||
} else {
|
||||
@ -652,6 +658,8 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
|
||||
}
|
||||
} else if (field == 'tax' && ! invoice.has_item_taxes) {
|
||||
continue;
|
||||
} else if (field == 'discount' && ! invoice.has_item_discounts) {
|
||||
continue;
|
||||
} else if (field == 'unit_cost' || field == 'rate' || field == 'hours') {
|
||||
headerStyles.push('cost');
|
||||
}
|
||||
@ -753,6 +761,8 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
|
||||
continue;
|
||||
} else if (field == 'tax' && ! invoice.has_item_taxes) {
|
||||
continue;
|
||||
} else if (field == 'discount' && ! invoice.has_item_discounts) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (field == 'item' || field == 'service') {
|
||||
@ -772,8 +782,10 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
|
||||
if (parseInt(invoice.is_amount_discount)) {
|
||||
value = formatMoneyInvoice(discount, invoice);
|
||||
} else {
|
||||
if (discount) {
|
||||
value = discount + '%';
|
||||
}
|
||||
}
|
||||
} else if (field == 'tax') {
|
||||
value = ' ';
|
||||
if (item.tax_name1) {
|
||||
|
@ -581,6 +581,7 @@ function calculateAmounts(invoice) {
|
||||
|
||||
var hasStandard = false;
|
||||
var hasTask = false;
|
||||
var hasDiscount = false;
|
||||
|
||||
// sum line item
|
||||
for (var i=0; i<invoice.invoice_items.length; i++) {
|
||||
@ -647,6 +648,7 @@ function calculateAmounts(invoice) {
|
||||
var lineTotal = roundSignificant(NINJA.parseFloat(item.cost)) * roundSignificant(NINJA.parseFloat(item.qty));
|
||||
var discount = roundToTwo(NINJA.parseFloat(item.discount));
|
||||
if (discount != 0) {
|
||||
hasDiscount = true;
|
||||
if (parseInt(invoice.is_amount_discount)) {
|
||||
lineTotal -= discount;
|
||||
} else {
|
||||
@ -696,6 +698,7 @@ function calculateAmounts(invoice) {
|
||||
}
|
||||
|
||||
invoice.has_item_taxes = hasTaxes;
|
||||
invoice.has_item_discounts = hasDiscount;
|
||||
invoice.subtotal_amount = total;
|
||||
|
||||
var discount = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user