mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for large discounts
This commit is contained in:
parent
f67c3cf038
commit
3cab690af4
@ -391,15 +391,21 @@ class InvoiceItemSum
|
||||
{
|
||||
$this->setGroupedTaxes(collect([]));
|
||||
|
||||
$item_tax = 0;
|
||||
|
||||
|
||||
foreach ($this->line_items as $this->item) {
|
||||
foreach ($this->line_items as $key => $this->item) {
|
||||
if ($this->item->line_total == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item_tax = 0;
|
||||
|
||||
//$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / $this->sub_total));
|
||||
$amount = ($this->sub_total > 0) ? $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / $this->sub_total)) : 0;
|
||||
$amount = ($this->sub_total > 0) ? $this->item->line_total - ($this->invoice->discount * ( $this->item->line_total / $this->sub_total)) : 0;
|
||||
|
||||
nlog("amount discount tax calcs : {$this->item->line_total} - {$this->sub_total} {$amount} {$this->item->line_total} {$this->invoice->discount} / {$this->sub_total}");
|
||||
nlog(( $this->item->line_total / $this->sub_total));
|
||||
nlog(($this->invoice->discount * ( $this->item->line_total / $this->sub_total)));
|
||||
|
||||
$item_tax_rate1_total = $this->calcAmountLineTax($this->item->tax_rate1, $amount);
|
||||
|
||||
@ -424,9 +430,20 @@ class InvoiceItemSum
|
||||
if ($item_tax_rate3_total != 0) {
|
||||
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
||||
}
|
||||
|
||||
$this->item->gross_line_total = $this->getLineTotal() + $item_tax;
|
||||
$this->item->tax_amount = $item_tax;
|
||||
|
||||
$this->line_items[$key] = $this->item;
|
||||
nlog("amount discount tax calcs : {$this->getLineTotal()} {$this->sub_total} {$amount} {$item_tax} {$this->item->gross_line_total} ");
|
||||
|
||||
$this->setTotalTaxes($this->getTotalTaxes() + $item_tax);
|
||||
|
||||
}
|
||||
|
||||
$this->setTotalTaxes($item_tax);
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,8 +308,9 @@ class InvoiceSum
|
||||
|
||||
public function setTaxMap(): self
|
||||
{
|
||||
if ($this->invoice->is_amount_discount == true) {
|
||||
if ($this->invoice->is_amount_discount) {
|
||||
$this->invoice_items->calcTaxesWithAmountDiscount();
|
||||
$this->invoice->line_items = $this->invoice_items->getLineItems();
|
||||
}
|
||||
|
||||
$this->tax_map = collect();
|
||||
@ -327,8 +328,6 @@ class InvoiceSum
|
||||
return $value['key'] == $key;
|
||||
})->sum('total');
|
||||
|
||||
//$total_line_tax -= $this->discount($total_line_tax);
|
||||
|
||||
$this->tax_map[] = ['name' => $tax_name, 'total' => $total_line_tax];
|
||||
|
||||
$this->total_taxes += $total_line_tax;
|
||||
@ -377,16 +376,6 @@ class InvoiceSum
|
||||
|
||||
public function purgeTaxes(): self
|
||||
{
|
||||
// $this->tax_rate1 = 0;
|
||||
// $this->tax_name1 = '';
|
||||
|
||||
// $this->tax_rate2 = 0;
|
||||
// $this->tax_name2 = '';
|
||||
|
||||
// $this->tax_rate3 = 0;
|
||||
// $this->tax_name3 = '';
|
||||
|
||||
// $this->discount = 0;
|
||||
|
||||
$line_items = collect($this->invoice->line_items);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user