1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Include line item discounts in tax reports

This commit is contained in:
Hillel Coren 2017-12-23 21:51:40 +02:00
parent cbbef24120
commit eaf7e22060

View File

@ -1292,7 +1292,7 @@ class Invoice extends EntityModel implements BalanceAffecting
{ {
$total = $invoiceItem->qty * $invoiceItem->cost; $total = $invoiceItem->qty * $invoiceItem->cost;
if ($this->discount > 0) { if ($this->discount != 0) {
if ($this->is_amount_discount) { if ($this->is_amount_discount) {
$total -= $invoiceTotal ? ($total / ($invoiceTotal + $this->discount) * $this->discount) : 0; $total -= $invoiceTotal ? ($total / ($invoiceTotal + $this->discount) * $this->discount) : 0;
} else { } else {
@ -1300,6 +1300,14 @@ class Invoice extends EntityModel implements BalanceAffecting
} }
} }
if ($invoiceItem->discount != 0) {
if ($this->is_amount_discount) {
$total -= $invoiceItem->discount;
} else {
$total -= $total * $invoiceItem->discount / 100;
}
}
return round($total, 2); return round($total, 2);
} }
@ -1311,7 +1319,17 @@ class Invoice extends EntityModel implements BalanceAffecting
$total = 0; $total = 0;
foreach ($this->invoice_items as $invoiceItem) { foreach ($this->invoice_items as $invoiceItem) {
$total += $invoiceItem->qty * $invoiceItem->cost; $lineTotal = $invoiceItem->qty * $invoiceItem->cost;
if ($invoiceItem->discount != 0) {
if ($this->is_amount_discount) {
$lineTotal -= $invoiceItem->discount;
} else {
$lineTotal -= $lineTotal * $invoiceItem->discount / 100;
}
}
$total += $lineTotal;
} }
if ($this->discount > 0) { if ($this->discount > 0) {