Added option to include line item taxes in line total

This commit is contained in:
Hillel Coren 2016-08-15 18:08:06 +03:00
parent d94974db59
commit c01e42ac87
8 changed files with 34 additions and 16 deletions

View File

@ -65,6 +65,7 @@ class Account extends Eloquent
'show_item_taxes',
'default_tax_rate_id',
'enable_second_tax_rate',
'include_item_taxes_inline',
'start_of_week',
];

View File

@ -696,6 +696,7 @@ class Invoice extends EntityModel implements BalanceAffecting
'custom_invoice_item_label2',
'invoice_embed_documents',
'page_size',
'include_item_taxes_inline',
]);
foreach ($this->invoice_items as $invoiceItem) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -362,7 +362,6 @@ NINJA.invoiceLines = function(invoice) {
}
grid[0].push({text: invoiceLabels.line_total, style: ['tableHeader', 'lineTotalTableHeader']});
for (var i = 0; i < invoice.invoice_items.length; i++) {
var row = [];
@ -401,6 +400,16 @@ NINJA.invoiceLines = function(invoice) {
}
var lineTotal = roundToTwo(NINJA.parseFloat(item.cost)) * roundToTwo(NINJA.parseFloat(item.qty));
if (account.include_item_taxes_inline == '1') {
if (tax1) {
lineTotal += lineTotal * tax1 / 100;
lineTotal = roundToTwo(lineTotal);
}
if (tax2) {
lineTotal += lineTotal * tax2 / 100;
lineTotal = roundToTwo(lineTotal);
}
}
lineTotal = formatMoneyInvoice(lineTotal, invoice);
rowStyle = (i % 2 == 0) ? 'odd' : 'even';

View File

@ -2073,6 +2073,8 @@ $LANG = array(
'bot_help_message' => 'I currently support:<br/>• Create\update\email an invoice<br/>• List products<br/>For example:<br/><i>invoice bob for 2 tickets, set the due date to next thursday and the discount to 10 percent</i>',
'list_products' => 'List Products',
'include_item_taxes_inline' => 'Include <b>line item taxes in line total</b>',
);
return $LANG;

View File

@ -11,6 +11,7 @@
{{ Former::populateField('invoice_item_taxes', intval($account->invoice_item_taxes)) }}
{{ Former::populateField('show_item_taxes', intval($account->show_item_taxes)) }}
{{ Former::populateField('enable_second_tax_rate', intval($account->enable_second_tax_rate)) }}
{{ Former::populateField('include_item_taxes_inline', intval($account->include_item_taxes_inline)) }}
<div class="panel panel-default">
@ -19,21 +20,25 @@
</div>
<div class="panel-body">
{!! Former::checkbox('invoice_taxes')
->text(trans('texts.enable_invoice_tax'))
->label('&nbsp;') !!}
{!! Former::checkbox('invoice_taxes')
->text(trans('texts.enable_invoice_tax'))
->label('&nbsp;') !!}
{!! Former::checkbox('invoice_item_taxes')
->text(trans('texts.enable_line_item_tax'))
->label('&nbsp;') !!}
{!! Former::checkbox('invoice_item_taxes')
->text(trans('texts.enable_line_item_tax'))
->label('&nbsp;') !!}
{!! Former::checkbox('show_item_taxes')
->text(trans('texts.show_line_item_tax'))
->label('&nbsp;') !!}
{!! Former::checkbox('show_item_taxes')
->text(trans('texts.show_line_item_tax'))
->label('&nbsp;') !!}
{!! Former::checkbox('enable_second_tax_rate')
->text(trans('texts.enable_second_tax_rate'))
->label('&nbsp;') !!}
{!! Former::checkbox('include_item_taxes_inline')
->text(trans('texts.include_item_taxes_inline'))
->label('&nbsp;') !!}
{!! Former::checkbox('enable_second_tax_rate')
->text(trans('texts.enable_second_tax_rate'))
->label('&nbsp;') !!}
&nbsp;