diff --git a/app/ninja/repositories/InvoiceRepository.php b/app/ninja/repositories/InvoiceRepository.php index f4b7337a262a..1f07ecd01181 100755 --- a/app/ninja/repositories/InvoiceRepository.php +++ b/app/ninja/repositories/InvoiceRepository.php @@ -244,7 +244,7 @@ class InvoiceRepository $invoice->po_number = trim($data['po_number']); $invoice->invoice_design_id = $data['invoice_design_id']; - if (isset($data['tax_name']) && isset($data['tax_rate']) && Utils::parseFloat($data['tax_rate']) > 0) { + if (isset($data['tax_name']) && isset($data['tax_rate']) && $data['tax_name']) { $invoice->tax_rate = Utils::parseFloat($data['tax_rate']); $invoice->tax_name = trim($data['tax_name']); } else { @@ -345,7 +345,7 @@ class InvoiceRepository $invoiceItem->qty = Utils::parseFloat($item->qty); $invoiceItem->tax_rate = 0; - if (isset($item->tax_rate) && Utils::parseFloat($item->tax_rate) > 0) { + if (isset($item->tax_rate) && isset($item->tax_name) && $item->tax_name) { $invoiceItem->tax_rate = Utils::parseFloat($item->tax_rate); $invoiceItem->tax_name = trim($item->tax_name); } diff --git a/app/ninja/repositories/TaxRateRepository.php b/app/ninja/repositories/TaxRateRepository.php index e7888064d028..9fe1c854411e 100755 --- a/app/ninja/repositories/TaxRateRepository.php +++ b/app/ninja/repositories/TaxRateRepository.php @@ -14,7 +14,7 @@ class TaxRateRepository continue; } - if (!isset($record->name) || !Utils::parseFloat($record->rate) || !trim($record->name)) { + if (!isset($record->name) || !trim($record->name)) { continue; } diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index cfe34346ce53..8d8f8d79e4e8 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -920,8 +920,10 @@ var taxRate = new TaxRateModel(); taxRate.name(name); taxRate.rate(parseFloat(rate)); - if (parseFloat(rate) > 0) taxRate.is_deleted(true); - self.tax_rates.push(taxRate); + if (name) { + taxRate.is_deleted(true); + self.tax_rates.push(taxRate); + } return taxRate; } diff --git a/public/built.css b/public/built.css index 86d657a189bd..708eef54b02f 100644 --- a/public/built.css +++ b/public/built.css @@ -2906,3 +2906,6 @@ table.table thead .sorting_asc:after { content: '' !important } table.table thead .sorting_desc:after { content: '' !important} table.table thead .sorting_asc_disabled:after { content: '' !important } table.table thead .sorting_desc_disabled:after { content: '' !important } + +/* Prevent modal from shifting page a bit - https://github.com/twbs/bootstrap/issues/9886 */ +body.modal-open { overflow:inherit; padding-right:inherit !important; } \ No newline at end of file diff --git a/public/built.js b/public/built.js index 9f3875806f70..0d73f40ecede 100644 --- a/public/built.js +++ b/public/built.js @@ -32262,7 +32262,7 @@ function displaySubtotals(doc, layout, invoice, y, rightAlignTitleX) data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) }) } - data.push({'tax': invoice.tax_amount > 0 ? formatMoney(invoice.tax_amount, invoice.client.currency_id) : false}); + data.push({'tax': (invoice.tax && invoice.tax.name) || invoice.tax_name ? formatMoney(invoice.tax_amount, invoice.client.currency_id) : false}); if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') { data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) }) @@ -32355,8 +32355,11 @@ function displayGrid(doc, invoice, data, x, y, layout, options) { if (key.substring(0, 6) === 'custom') { key = invoice.account[key]; - } else if (key === 'tax' && invoice.tax_rate) { - key = invoiceLabels[key] + ' ' + (invoice.tax_rate*1).toString() + '%'; + } else if (key === 'tax' && invoice.tax_name) { + key = invoice.tax_name + ' ' + (invoice.tax_rate*1).toString() + '%'; + if (invoice.tax_name.toLowerCase().indexOf(invoiceLabels['tax'].toLowerCase()) == -1) { + key = invoiceLabels['tax'] + ': ' + key; + } } else if (key === 'discount' && NINJA.parseFloat(invoice.discount) && !parseInt(invoice.is_amount_discount)) { key = invoiceLabels[key] + ' ' + parseFloat(invoice.discount) + '%'; } else { @@ -32424,7 +32427,7 @@ function calculateAmounts(invoice) { total += lineTotal; } - if ((item.tax && item.tax.rate > 0) || (item.tax_rate && parseFloat(item.tax_rate) > 0)) { + if ((item.tax && item.tax.name) || item.tax_name) { hasTaxes = true; } } diff --git a/public/css/style.css b/public/css/style.css index 6522e541830d..006d313e0322 100755 --- a/public/css/style.css +++ b/public/css/style.css @@ -798,3 +798,6 @@ table.table thead .sorting_asc:after { content: '' !important } table.table thead .sorting_desc:after { content: '' !important} table.table thead .sorting_asc_disabled:after { content: '' !important } table.table thead .sorting_desc_disabled:after { content: '' !important } + +/* Prevent modal from shifting page a bit - https://github.com/twbs/bootstrap/issues/9886 */ +body.modal-open { overflow:inherit; padding-right:inherit !important; } \ No newline at end of file diff --git a/public/js/script.js b/public/js/script.js index 219ca1cf9612..1c99d557bc75 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -739,7 +739,7 @@ function displaySubtotals(doc, layout, invoice, y, rightAlignTitleX) data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) }) } - data.push({'tax': invoice.tax_amount > 0 ? formatMoney(invoice.tax_amount, invoice.client.currency_id) : false}); + data.push({'tax': (invoice.tax && invoice.tax.name) || invoice.tax_name ? formatMoney(invoice.tax_amount, invoice.client.currency_id) : false}); if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') { data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) }) @@ -832,8 +832,11 @@ function displayGrid(doc, invoice, data, x, y, layout, options) { if (key.substring(0, 6) === 'custom') { key = invoice.account[key]; - } else if (key === 'tax' && invoice.tax_rate) { - key = invoiceLabels[key] + ' ' + (invoice.tax_rate*1).toString() + '%'; + } else if (key === 'tax' && invoice.tax_name) { + key = invoice.tax_name + ' ' + (invoice.tax_rate*1).toString() + '%'; + if (invoice.tax_name.toLowerCase().indexOf(invoiceLabels['tax'].toLowerCase()) == -1) { + key = invoiceLabels['tax'] + ': ' + key; + } } else if (key === 'discount' && NINJA.parseFloat(invoice.discount) && !parseInt(invoice.is_amount_discount)) { key = invoiceLabels[key] + ' ' + parseFloat(invoice.discount) + '%'; } else { @@ -901,7 +904,7 @@ function calculateAmounts(invoice) { total += lineTotal; } - if ((item.tax && item.tax.rate > 0) || (item.tax_rate && parseFloat(item.tax_rate) > 0)) { + if ((item.tax && item.tax.name) || item.tax_name) { hasTaxes = true; } }