diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 755932691d18..912ade56f962 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -760,7 +760,7 @@ class AccountController extends BaseController } $labels = []; - foreach (['item', 'description', 'unit_cost', 'quantity', 'line_total', 'terms'] as $field) { + foreach (['item', 'description', 'unit_cost', 'quantity', 'line_total', 'terms', 'balance_due', 'partial_due'] as $field) { $labels[$field] = Input::get("labels_{$field}"); } $account->invoice_labels = json_encode($labels); diff --git a/app/Models/Account.php b/app/Models/Account.php index b2d5a7d22dce..f6a7194bdf6f 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -683,7 +683,7 @@ class Account extends Eloquent 'subtotal', 'paid_to_date', 'balance_due', - 'amount_due', + 'partial_due', 'terms', 'your_invoice', 'quote', diff --git a/app/Ninja/Presenters/InvoicePresenter.php b/app/Ninja/Presenters/InvoicePresenter.php index 560f2d49e6f4..ebb3297d5c1a 100644 --- a/app/Ninja/Presenters/InvoicePresenter.php +++ b/app/Ninja/Presenters/InvoicePresenter.php @@ -19,7 +19,7 @@ class InvoicePresenter extends Presenter { public function balanceDueLabel() { if ($this->entity->partial) { - return 'amount_due'; + return 'partial_due'; } elseif ($this->entity->is_quote) { return 'total'; } else { diff --git a/public/built.js b/public/built.js index cbb00de5285e..9fccf73e0bff 100644 --- a/public/built.js +++ b/public/built.js @@ -31183,7 +31183,7 @@ NINJA.decodeJavascript = function(invoice, javascript) var value = getDescendantProp(invoice, field); if (match.indexOf('?') < 0 || value) { if (invoice.partial && field == 'balance_due') { - field = 'amount_due'; + field = 'partial_due'; } else if (invoice.is_quote) { field = field.replace('invoice', 'quote'); } @@ -31440,12 +31440,22 @@ NINJA.subtotals = function(invoice, hideBalance) data.push([{text:invoiceLabels.paid_to_date}, {text:formatMoneyInvoice(paid, invoice)}]); } - if (!hideBalance) { - var isPartial = NINJA.parseFloat(invoice.partial); + var isPartial = NINJA.parseFloat(invoice.partial); + + if (!hideBalance || isPartial) { data.push([ - {text: isPartial ? invoiceLabels.amount_due : invoiceLabels.balance_due, style:['balanceDueLabel']}, - {text: formatMoneyInvoice(invoice.balance_amount, invoice), style:['balanceDue']} + { text: invoiceLabels.balance_due, style: [isPartial ? '' : 'balanceDueLabel'] }, + { text: formatMoneyInvoice(invoice.total_amount, invoice), style: [isPartial ? '' : 'balanceDue'] } + ]); + } + + if (!hideBalance) { + if (isPartial) { + data.push([ + { text: invoiceLabels.partial_due, style: ['balanceDueLabel'] }, + { text: formatMoneyInvoice(invoice.balance_amount, invoice), style: ['balanceDue'] } ]); + } } return NINJA.prepareDataPairs(data, 'subtotals'); @@ -31454,7 +31464,7 @@ NINJA.subtotals = function(invoice, hideBalance) NINJA.subtotalsBalance = function(invoice) { var isPartial = NINJA.parseFloat(invoice.partial); return [[ - {text: isPartial ? invoiceLabels.amount_due : invoiceLabels.balance_due, style:['balanceDueLabel']}, + {text: isPartial ? invoiceLabels.partial_due : invoiceLabels.balance_due, style:['balanceDueLabel']}, {text: formatMoneyInvoice(invoice.balance_amount, invoice), style:['balanceDue']} ]]; } @@ -31532,18 +31542,18 @@ NINJA.invoiceDetails = function(invoice) { if (NINJA.parseFloat(invoice.balance) < NINJA.parseFloat(invoice.amount)) { data.push([ - {text: invoiceLabels.total}, + {text: invoiceLabels.balance_due}, {text: formatMoneyInvoice(invoice.amount, invoice)} ]); } else if (isPartial) { data.push([ - {text: invoiceLabels.total}, + {text: invoiceLabels.balance_due}, {text: formatMoneyInvoice(invoice.total_amount, invoice)} ]); } data.push([ - {text: isPartial ? invoiceLabels.amount_due : invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']}, + {text: isPartial ? invoiceLabels.partial_due : invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']}, {text: formatMoneyInvoice(invoice.balance_amount, invoice), style: ['invoiceDetailBalanceDue']} ]) diff --git a/public/js/pdf.pdfmake.js b/public/js/pdf.pdfmake.js index d6e7906ca6d6..f8f30f4b546f 100644 --- a/public/js/pdf.pdfmake.js +++ b/public/js/pdf.pdfmake.js @@ -190,7 +190,7 @@ NINJA.decodeJavascript = function(invoice, javascript) var value = getDescendantProp(invoice, field); if (match.indexOf('?') < 0 || value) { if (invoice.partial && field == 'balance_due') { - field = 'amount_due'; + field = 'partial_due'; } else if (invoice.is_quote) { field = field.replace('invoice', 'quote'); } @@ -447,12 +447,22 @@ NINJA.subtotals = function(invoice, hideBalance) data.push([{text:invoiceLabels.paid_to_date}, {text:formatMoneyInvoice(paid, invoice)}]); } - if (!hideBalance) { - var isPartial = NINJA.parseFloat(invoice.partial); + var isPartial = NINJA.parseFloat(invoice.partial); + + if (!hideBalance || isPartial) { data.push([ - {text: isPartial ? invoiceLabels.amount_due : invoiceLabels.balance_due, style:['balanceDueLabel']}, - {text: formatMoneyInvoice(invoice.balance_amount, invoice), style:['balanceDue']} + { text: invoiceLabels.balance_due, style: [isPartial ? '' : 'balanceDueLabel'] }, + { text: formatMoneyInvoice(invoice.total_amount, invoice), style: [isPartial ? '' : 'balanceDue'] } + ]); + } + + if (!hideBalance) { + if (isPartial) { + data.push([ + { text: invoiceLabels.partial_due, style: ['balanceDueLabel'] }, + { text: formatMoneyInvoice(invoice.balance_amount, invoice), style: ['balanceDue'] } ]); + } } return NINJA.prepareDataPairs(data, 'subtotals'); @@ -461,7 +471,7 @@ NINJA.subtotals = function(invoice, hideBalance) NINJA.subtotalsBalance = function(invoice) { var isPartial = NINJA.parseFloat(invoice.partial); return [[ - {text: isPartial ? invoiceLabels.amount_due : invoiceLabels.balance_due, style:['balanceDueLabel']}, + {text: isPartial ? invoiceLabels.partial_due : invoiceLabels.balance_due, style:['balanceDueLabel']}, {text: formatMoneyInvoice(invoice.balance_amount, invoice), style:['balanceDue']} ]]; } @@ -539,18 +549,18 @@ NINJA.invoiceDetails = function(invoice) { if (NINJA.parseFloat(invoice.balance) < NINJA.parseFloat(invoice.amount)) { data.push([ - {text: invoiceLabels.total}, + {text: invoiceLabels.balance_due}, {text: formatMoneyInvoice(invoice.amount, invoice)} ]); } else if (isPartial) { data.push([ - {text: invoiceLabels.total}, + {text: invoiceLabels.balance_due}, {text: formatMoneyInvoice(invoice.total_amount, invoice)} ]); } data.push([ - {text: isPartial ? invoiceLabels.amount_due : invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']}, + {text: isPartial ? invoiceLabels.partial_due : invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']}, {text: formatMoneyInvoice(invoice.balance_amount, invoice), style: ['invoiceDetailBalanceDue']} ]) diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 5913944f9d79..f31e61a03263 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1073,7 +1073,8 @@ $LANG = array( 'user_view_all' => 'View all clients, invoices, etc.', 'user_edit_all' => 'Edit all clients, invoices, etc.', 'gateway_help_20' => ':link to sign up for Sage Pay.', - 'gateway_help_21' => ':link to sign up for Sage Pay.', + 'gateway_help_21' => ':link to sign up for Sage Pay.', + 'partial_due' => 'Partial Due', ); diff --git a/resources/views/accounts/invoice_design.blade.php b/resources/views/accounts/invoice_design.blade.php index 09bb55bfb1ba..4af173818dad 100644 --- a/resources/views/accounts/invoice_design.blade.php +++ b/resources/views/accounts/invoice_design.blade.php @@ -60,7 +60,16 @@ @else NINJA.headerFont = NINJA.bodyFont = 'Roboto'; @endif - var fields = ['item', 'description', 'unit_cost', 'quantity', 'line_total', 'terms']; + var fields = [ + 'item', + 'description', + 'unit_cost', + 'quantity', + 'line_total', + 'terms', + 'balance_due', + 'partial_due' + ]; invoiceLabels.old = {}; for (var i=0; ilabel(trans('texts.item')) !!} {!! Former::text('labels_description')->label(trans('texts.description')) !!} {!! Former::text('labels_unit_cost')->label(trans('texts.unit_cost')) !!} + {!! Former::text('labels_quantity')->label(trans('texts.quantity')) !!}
- {!! Former::text('labels_quantity')->label(trans('texts.quantity')) !!} {!! Former::text('labels_line_total')->label(trans('texts.line_total')) !!} {!! Former::text('labels_terms')->label(trans('texts.terms')) !!} + {!! Former::text('labels_balance_due')->label(trans('texts.balance_due')) !!} + {!! Former::text('labels_partial_due')->label(trans('texts.partial_due')) !!}
diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index c3c21fd5f50a..ce8160d25c02 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -385,11 +385,18 @@ @endif - + - {{ trans($entityType == ENTITY_INVOICE ? 'texts.balance_due' : 'texts.total') }} - + {{ $entityType == ENTITY_INVOICE ? $invoiceLabels['balance_due'] : trans('texts.total') }} + + + + + + + {{ $invoiceLabels['partial_due'] }} + diff --git a/resources/views/invoices/knockout.blade.php b/resources/views/invoices/knockout.blade.php index 3798cb458131..029a81bc0b67 100644 --- a/resources/views/invoices/knockout.blade.php +++ b/resources/views/invoices/knockout.blade.php @@ -512,7 +512,11 @@ function InvoiceModel(data) { }); self.totals.total = ko.computed(function() { - return self.formatMoney(self.partial() ? self.partial() : self.totals.rawTotal()); + return self.formatMoney(self.totals.rawTotal()); + }); + + self.totals.partial = ko.computed(function() { + return self.formatMoney(self.partial()); }); self.onDragged = function(item) {