Invoice create tax rate issue solved
This commit is contained in:
parent
79ebd9d025
commit
475a39c818
@ -58,6 +58,18 @@ class CreateInvoice
|
||||
// Calculate totals
|
||||
$tax_total += $invoice_item->tax;
|
||||
$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;
|
||||
|
||||
if (!empty($this->data['tax_id'])) {
|
||||
$calculates = $compounds = [];
|
||||
$calculates = $compounds = $taxes = [];
|
||||
|
||||
foreach ((array) $this->data['tax_id'] as $tax_id) {
|
||||
$tax = Tax::find($tax_id);
|
||||
@ -112,6 +112,8 @@ class CreateInvoiceItem
|
||||
break;
|
||||
case 'normal':
|
||||
default:
|
||||
$taxes[] = $tax;
|
||||
|
||||
$tax_amount = ($item_discount_amount / 100) * $tax->rate;
|
||||
|
||||
$item_taxes[] = [
|
||||
@ -128,6 +130,27 @@ class CreateInvoiceItem
|
||||
}
|
||||
|
||||
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) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($compounds) {
|
||||
foreach ($compounds as $compound) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user