Report fixes

This commit is contained in:
Hillel Coren 2018-04-23 12:44:23 +03:00
parent 441d1f2724
commit 587601ce7d
3 changed files with 19 additions and 11 deletions

View File

@ -75,7 +75,7 @@ class InvoiceItem extends EntityModel
return $this->belongsTo('App\Models\Account'); return $this->belongsTo('App\Models\Account');
} }
public function amount() public function getPreTaxAmount()
{ {
$amount = $this->cost * $this->qty; $amount = $this->cost * $this->qty;
@ -83,21 +83,32 @@ class InvoiceItem extends EntityModel
if ($this->invoice->is_amount_discount) { if ($this->invoice->is_amount_discount) {
$amount -= $this->discount; $amount -= $this->discount;
} else { } else {
$amount -= $amount * $this->discount / 100; $amount -= round($amount * $this->discount / 100, 4);
} }
} }
$preTaxAmount = $amount; return $amount;
}
public function getTaxAmount()
{
$tax = 0;
$preTaxAmount = $this->getPreTaxAmount();
if ($this->tax_rate1) { if ($this->tax_rate1) {
$amount += $preTaxAmount * $this->tax_rate1 / 100; $tax += round($preTaxAmount * $this->tax_rate1 / 100, 2);
} }
if ($this->tax_rate2) { if ($this->tax_rate2) {
$amount += $preTaxAmount * $this->tax_rate2 / 100; $tax += round($preTaxAmount * $this->tax_rate2 / 100, 2);
} }
return $amount; return $tax;
}
public function amount()
{
return $this->getPreTaxAmount() + $this->getTaxAmount();
} }
public function markFeePaid() public function markFeePaid()

View File

@ -75,10 +75,7 @@ class ProductReport extends AbstractReport
]; ];
if ($account->invoice_item_taxes) { if ($account->invoice_item_taxes) {
$row[] = $item->present()->tax1; $row[] = Utils::roundSignificant($item->getTaxAmount(), 2);
if ($account->enable_second_tax_rate) {
$row[] = $item->present()->tax2;
}
} }
if ($account->customLabel('product1')) { if ($account->customLabel('product1')) {

View File

@ -702,7 +702,7 @@
var txt = $(this).find("td").eq(i).text(); var txt = $(this).find("td").eq(i).text();
subtotal += convertStringToNumber(txt) || 0; subtotal += convertStringToNumber(txt) || 0;
}); });
$cell.find(".group-count").append(' - ' + label + ': ' + roundToTwo(subtotal, true)); $cell.find(".group-count").append(' | ' + label + ': ' + roundToTwo(subtotal, true));
} }
}, },
} }