diff --git a/resources/assets/js/pdf.pdfmake.js b/resources/assets/js/pdf.pdfmake.js index 6763ad8485a4..7be26d9e3f91 100644 --- a/resources/assets/js/pdf.pdfmake.js +++ b/resources/assets/js/pdf.pdfmake.js @@ -410,10 +410,10 @@ NINJA.invoiceColumns = function(invoice) columns.push("*") - if (invoice.features.invoice_settings && account.custom_invoice_item_label1) { + if (invoice.has_custom_item_value1) { columns.push("10%"); } - if (invoice.features.invoice_settings && account.custom_invoice_item_label2) { + if (invoice.has_custom_item_value2) { columns.push("10%"); } @@ -476,10 +476,10 @@ NINJA.invoiceLines = function(invoice, isSecondTable) { 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')}); } - 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')}); } @@ -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:["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 || ' '}); } - if (invoice.features.invoice_settings && account.custom_invoice_item_label2) { + if (invoice.has_custom_item_value2) { row.push({style:["customValue2", rowStyle], text:custom_value2 || ' '}); } if (!hideQuantity) { diff --git a/resources/assets/js/script.js b/resources/assets/js/script.js index f9a370987cbb..8763d00c38c3 100644 --- a/resources/assets/js/script.js +++ b/resources/assets/js/script.js @@ -671,6 +671,8 @@ function calculateAmounts(invoice) { var hasTaxes = false; var taxes = {}; 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 if (invoice.invoice_design_id == 2) { @@ -715,6 +717,16 @@ function calculateAmounts(invoice) { 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) { taxRate1 = parseFloat(item.tax_rate1); taxName1 = item.tax_name1;