1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00

Merge pull request #1665 from hagendornIT/#1664-Hide-custom-invoice-item-title

Hide custom invoice items if no value was specified
This commit is contained in:
Hillel Coren 2017-09-14 16:02:45 +03:00 committed by GitHub
commit badd6fb7e7
2 changed files with 18 additions and 6 deletions

View File

@ -410,10 +410,10 @@ NINJA.invoiceColumns = function(invoice)
columns.push("*") columns.push("*")
if (invoice.features.invoice_settings && account.custom_invoice_item_label1) { if (invoice.has_custom_item_value1) {
columns.push("10%"); columns.push("10%");
} }
if (invoice.features.invoice_settings && account.custom_invoice_item_label2) { if (invoice.has_custom_item_value2) {
columns.push("10%"); columns.push("10%");
} }
@ -476,10 +476,10 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
grid[0].push({text: invoiceLabels.description, style: styles.concat('descriptionTableHeader')}); grid[0].push({text: invoiceLabels.description, style: styles.concat('descriptionTableHeader')});
if (invoice.features.invoice_settings && account.custom_invoice_item_label1) { if (invoice.has_custom_item_value1) {
grid[0].push({text: account.custom_invoice_item_label1, style: styles.concat('custom1TableHeader')}); grid[0].push({text: account.custom_invoice_item_label1, style: styles.concat('custom1TableHeader')});
} }
if (invoice.features.invoice_settings && account.custom_invoice_item_label2) { if (invoice.has_custom_item_value2) {
grid[0].push({text: account.custom_invoice_item_label2, style: styles.concat('custom2TableHeader')}); grid[0].push({text: account.custom_invoice_item_label2, style: styles.concat('custom2TableHeader')});
} }
@ -560,10 +560,10 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
row.push({style:["productKey", rowStyle], text:productKey || ' '}); // product key can be blank when selecting from a datalist row.push({style:["productKey", rowStyle], text:productKey || ' '}); // product key can be blank when selecting from a datalist
} }
row.push({style:["notes", rowStyle], stack:[{text:notes || ' '}]}); row.push({style:["notes", rowStyle], stack:[{text:notes || ' '}]});
if (invoice.features.invoice_settings && account.custom_invoice_item_label1) { if (invoice.has_custom_item_value1) {
row.push({style:["customValue1", rowStyle], text:custom_value1 || ' '}); row.push({style:["customValue1", rowStyle], text:custom_value1 || ' '});
} }
if (invoice.features.invoice_settings && account.custom_invoice_item_label2) { if (invoice.has_custom_item_value2) {
row.push({style:["customValue2", rowStyle], text:custom_value2 || ' '}); row.push({style:["customValue2", rowStyle], text:custom_value2 || ' '});
} }
if (!hideQuantity) { if (!hideQuantity) {

View File

@ -671,6 +671,8 @@ function calculateAmounts(invoice) {
var hasTaxes = false; var hasTaxes = false;
var taxes = {}; var taxes = {};
invoice.has_product_key = false; invoice.has_product_key = false;
invoice.has_custom_item_value1 = false;
invoice.has_custom_item_value2 = false;
// Bold designs currently breaks w/o the product column // Bold designs currently breaks w/o the product column
if (invoice.invoice_design_id == 2) { if (invoice.invoice_design_id == 2) {
@ -715,6 +717,16 @@ function calculateAmounts(invoice) {
invoice.has_product_key = true; invoice.has_product_key = true;
} }
if (invoice.features.invoice_settings) {
if (item.custom_value1) {
invoice.has_custom_item_value1 = true;
}
if (item.custom_value2) {
invoice.has_custom_item_value2 = true;
}
}
if (parseFloat(item.tax_rate1) != 0) { if (parseFloat(item.tax_rate1) != 0) {
taxRate1 = parseFloat(item.tax_rate1); taxRate1 = parseFloat(item.tax_rate1);
taxName1 = item.tax_name1; taxName1 = item.tax_name1;