1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
This commit is contained in:
David Bomba 2019-04-05 15:52:30 +11:00
parent 56f05f7122
commit deface29da
2 changed files with 66 additions and 9 deletions

View File

@ -25,6 +25,11 @@ class InvoiceCalc
protected $invoice_total;
protected $tax_map;
protected $total_taxes;
protected $total_discount;
public function __construct(Invoice $invoice, int $precision = 2)
{
@ -52,7 +57,13 @@ class InvoiceCalc
$new_line_items[] = $item_calc->getLineItem();
//set collection of itemised taxes
$this->setTaxMap($this->getTaxMap()->merge($item_calc->getGroupedTaxes()));
//set running total of taxes
$this->setTotalTaxes($this->getTotalTaxes() + $item_calc->getTotalTaxes());
//set running total of discounts
$this->setTotalDiscount($this->getTotalDiscount() + $item_calc->getTotalDiscounts());
}
@ -60,6 +71,48 @@ class InvoiceCalc
}
/**
* Getters and Setters
*/
private function getTaxMap()
{
return $this->tax_map;
}
private function setTaxMap($value)
{
$htis->tax_map = $value;
return $this;
}
private function getTotalDiscount()
{
return $this->total_discount;
}
private function setTotalDiscount($value)
{
$this->total_discount = $value;
return $this;
}
private function getTotalTaxes()
{
return $this->total_taxes;
}
private function setTotalTaxes($value)
{
$this->total_taxes = $value;
return $this;
}
/*
private function setDiscount($amount, $discount, $is_amount_discount)
{

View File

@ -109,18 +109,10 @@ class InvoiceItemCalc
$group_tax[$key] = ['total' => $tax_total, 'tax_name' => $tax_name . ' ' . $tax_rate];
$this->groupTaxes($group_tax);
$this->setGroupedTaxes($group_tax);
}
private function groupTaxes($group_tax)
{
$this->tax_collection->merge(collect($group_tax));
return $this;
}
/****************
*
* Getters and Setters
@ -170,5 +162,17 @@ class InvoiceItemCalc
return $this;
}
public function getGroupedTaxes()
{
return $this->tax_collection;
}
public function setGroupedTaxes($group_tax)
{
$this->tax_collection->merge(collect($group_tax));
return $this;
}
}