Add getters for line item discounts
This commit is contained in:
parent
8bd2213fc5
commit
587b4e102a
|
|
@ -148,6 +148,7 @@ class InvoiceItemSum
|
|||
public function __construct(RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice)
|
||||
{
|
||||
$this->tax_collection = collect([]);
|
||||
$this->total_discount = 0;
|
||||
|
||||
$this->invoice = $invoice;
|
||||
$this->client = $invoice->client ?? $invoice->vendor;
|
||||
|
|
@ -240,9 +241,10 @@ class InvoiceItemSum
|
|||
{
|
||||
if ($this->invoice->is_amount_discount) {
|
||||
$this->setLineTotal($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision));
|
||||
$this->total_discount += $this->item->discount;
|
||||
} else {
|
||||
$discount = ($this->item->line_total * ($this->item->discount / 100));
|
||||
|
||||
$this->total_discount += $discount;
|
||||
$this->setLineTotal($this->formatValue(($this->getLineTotal() - $discount), $this->currency->precision));
|
||||
}
|
||||
|
||||
|
|
@ -403,6 +405,11 @@ class InvoiceItemSum
|
|||
$this->tax_collection->push(collect($group_tax));
|
||||
}
|
||||
|
||||
public function getTotalDiscount()
|
||||
{
|
||||
return $this->total_discount;
|
||||
}
|
||||
|
||||
public function getTotalTaxes()
|
||||
{
|
||||
return $this->total_taxes;
|
||||
|
|
|
|||
|
|
@ -175,8 +175,10 @@ class InvoiceItemSumInclusive
|
|||
{
|
||||
if ($this->invoice->is_amount_discount) {
|
||||
$this->setLineTotal($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision));
|
||||
$this->total_discount += $this->item->discount;
|
||||
} else {
|
||||
$this->setLineTotal($this->getLineTotal() - $this->formatValue(($this->item->line_total * ($this->item->discount / 100)), $this->currency->precision));
|
||||
$this->total_discount += ($this->item->line_total * ($this->item->discount / 100));
|
||||
}
|
||||
|
||||
$this->item->is_amount_discount = $this->invoice->is_amount_discount;
|
||||
|
|
@ -294,6 +296,11 @@ class InvoiceItemSumInclusive
|
|||
$this->tax_collection->push(collect($group_tax));
|
||||
}
|
||||
|
||||
public function getTotalDiscount()
|
||||
{
|
||||
return $this->total_discount;
|
||||
}
|
||||
|
||||
public function getTotalTaxes()
|
||||
{
|
||||
return $this->total_taxes;
|
||||
|
|
|
|||
Loading…
Reference in New Issue