Include line item discounts in tax reports

This commit is contained in:
Hillel Coren 2017-12-23 22:06:30 +02:00
parent eaf7e22060
commit 8f3952a938
2 changed files with 12 additions and 1 deletions

View File

@ -78,6 +78,15 @@ class InvoiceItem extends EntityModel
public function amount() public function amount()
{ {
$amount = $this->cost * $this->qty; $amount = $this->cost * $this->qty;
if ($this->discount != 0) {
if ($this->invoice->is_amount_discount) {
$amount -= $this->discount;
} else {
$amount -= $amount * $this->discount / 100;
}
}
$preTaxAmount = $amount; $preTaxAmount = $amount;
if ($this->tax_rate1) { if ($this->tax_rate1) {

View File

@ -374,7 +374,9 @@ class BasePaymentDriver
]); ]);
$items[] = $item; $items[] = $item;
$total += $invoiceItem->cost * $invoiceItem->qty;
$invoiceItem->setRelation('invoice', $invoice);
$total += $invoiceItem->amount();
} }
if ($total != $invoice->getRequestedAmount()) { if ($total != $invoice->getRequestedAmount()) {