Invoice create tax rate issue solved
This commit is contained in:
parent
79ebd9d025
commit
475a39c818
@ -58,6 +58,18 @@ class CreateInvoice
|
|||||||
// Calculate totals
|
// Calculate totals
|
||||||
$tax_total += $invoice_item->tax;
|
$tax_total += $invoice_item->tax;
|
||||||
$sub_total += $invoice_item->total;
|
$sub_total += $invoice_item->total;
|
||||||
|
|
||||||
|
// Set taxes
|
||||||
|
foreach ($invoice_item->item_taxes as $item_tax) {
|
||||||
|
if (isset($taxes) && in_array($item['tax_id'], $taxes)) {
|
||||||
|
$taxes[$item_tax['tax_id']]['amount'] += $item_tax['amount'];
|
||||||
|
} else {
|
||||||
|
$taxes[$item_tax['tax_id']] = [
|
||||||
|
'name' => $item_tax['name'],
|
||||||
|
'amount' => $item_tax['amount']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ class CreateInvoiceItem
|
|||||||
$item_tax_total = 0;
|
$item_tax_total = 0;
|
||||||
|
|
||||||
if (!empty($this->data['tax_id'])) {
|
if (!empty($this->data['tax_id'])) {
|
||||||
$calculates = $compounds = [];
|
$calculates = $compounds = $taxes = [];
|
||||||
|
|
||||||
foreach ((array) $this->data['tax_id'] as $tax_id) {
|
foreach ((array) $this->data['tax_id'] as $tax_id) {
|
||||||
$tax = Tax::find($tax_id);
|
$tax = Tax::find($tax_id);
|
||||||
@ -112,6 +112,8 @@ class CreateInvoiceItem
|
|||||||
break;
|
break;
|
||||||
case 'normal':
|
case 'normal':
|
||||||
default:
|
default:
|
||||||
|
$taxes[] = $tax;
|
||||||
|
|
||||||
$tax_amount = ($item_discount_amount / 100) * $tax->rate;
|
$tax_amount = ($item_discount_amount / 100) * $tax->rate;
|
||||||
|
|
||||||
$item_taxes[] = [
|
$item_taxes[] = [
|
||||||
@ -128,6 +130,27 @@ class CreateInvoiceItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($calculates) {
|
if ($calculates) {
|
||||||
|
if ($this->discount) {
|
||||||
|
$item_tax_total = 0;
|
||||||
|
|
||||||
|
if ($taxes) {
|
||||||
|
foreach ($taxes as $tax) {
|
||||||
|
$item_tax_amount = ($item_amount / 100) * $tax->rate;
|
||||||
|
|
||||||
|
$item_tax_total += $item_tax_amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($calculates as $calculate) {
|
||||||
|
$item_sub_and_tax_total = $item_amount + $item_tax_total;
|
||||||
|
|
||||||
|
$item_tax_total = $item_sub_and_tax_total - (($item_sub_and_tax_total * (100 - $calculate->rate)) / 100);
|
||||||
|
|
||||||
|
$item_sub_total = $item_sub_and_tax_total - $item_tax_total;
|
||||||
|
|
||||||
|
$item_discount_amount = $item_sub_total - ($item_sub_total * ($this->discount / 100));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
foreach ($calculates as $calculate) {
|
foreach ($calculates as $calculate) {
|
||||||
$item_sub_and_tax_total = $item_discount_amount + $item_tax_total;
|
$item_sub_and_tax_total = $item_discount_amount + $item_tax_total;
|
||||||
|
|
||||||
@ -144,6 +167,7 @@ class CreateInvoiceItem
|
|||||||
$item_amount = $item_sub_and_tax_total - $item_tax_total;
|
$item_amount = $item_sub_and_tax_total - $item_tax_total;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($compounds) {
|
if ($compounds) {
|
||||||
foreach ($compounds as $compound) {
|
foreach ($compounds as $compound) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user