refs #688 add this changes InvoiceItem Tax
This commit is contained in:
parent
183e3c86e0
commit
31e076b59d
@ -130,23 +130,12 @@ class CreateInvoiceItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($inclusives) {
|
if ($inclusives) {
|
||||||
if ($this->discount) {
|
$item_amount = $item_discount_amount + $item_tax_total;
|
||||||
$item_tax_total = 0;
|
|
||||||
|
|
||||||
if ($taxes) {
|
$item_base_rate = $item_amount / (1 + collect($inclusives)->sum('rate')/100);
|
||||||
foreach ($taxes as $tax) {
|
|
||||||
$item_tax_amount = ($item_amount / 100) * $tax->rate;
|
|
||||||
|
|
||||||
$item_tax_total += $item_tax_amount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($inclusives as $inclusive) {
|
foreach ($inclusives as $inclusive) {
|
||||||
$item_sub_and_tax_total = $item_amount + $item_tax_total;
|
$item_tax_total += $tax_amount = $item_base_rate * ($inclusive->rate / 100);
|
||||||
|
|
||||||
$item_tax_total = $item_sub_and_tax_total - ($item_sub_and_tax_total / (1 + ($inclusive->rate / 100)));
|
|
||||||
|
|
||||||
$item_sub_total = $item_sub_and_tax_total - $item_tax_total;
|
|
||||||
|
|
||||||
$item_taxes[] = [
|
$item_taxes[] = [
|
||||||
'company_id' => $this->invoice->company_id,
|
'company_id' => $this->invoice->company_id,
|
||||||
@ -155,26 +144,9 @@ class CreateInvoiceItem
|
|||||||
'name' => $inclusive->name,
|
'name' => $inclusive->name,
|
||||||
'amount' => $tax_amount,
|
'amount' => $tax_amount,
|
||||||
];
|
];
|
||||||
|
|
||||||
$item_discount_amount = $item_sub_total - ($item_sub_total * ($this->discount / 100));
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
foreach ($inclusives as $inclusive) {
|
|
||||||
$item_sub_and_tax_total = $item_discount_amount + $item_tax_total;
|
|
||||||
|
|
||||||
$item_tax_total = $tax_amount = $item_sub_and_tax_total - ($item_sub_and_tax_total / (1 + ($inclusive->rate / 100)));
|
$item_amount = ($item_amount - $item_tax_total) / (1 - $this->discount / 100);
|
||||||
|
|
||||||
$item_taxes[] = [
|
|
||||||
'company_id' => $this->invoice->company_id,
|
|
||||||
'invoice_id' => $this->invoice->id,
|
|
||||||
'tax_id' => $inclusive->id,
|
|
||||||
'name' => $inclusive->name,
|
|
||||||
'amount' => $tax_amount,
|
|
||||||
];
|
|
||||||
|
|
||||||
$item_amount = $item_sub_and_tax_total - $item_tax_total;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($compounds) {
|
if ($compounds) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user