Update Items.php

This commit is contained in:
sausin 2019-02-03 21:23:50 +05:30 committed by GitHub
parent b135f0a57b
commit 1bef5738f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -358,37 +358,12 @@ class Items extends Controller
} }
if ($inclusives) { if ($inclusives) {
if ($discount) {
$item_tax_total = 0;
if ($taxes) {
foreach ($taxes as $tax) {
$item_tax_amount = ($item_sub_total / 100) * $tax->rate;
$item_tax_total += $item_tax_amount;
}
}
foreach ($inclusives as $inclusive) {
$item_sub_and_tax_total = $item_sub_total + $item_tax_total;
$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_discount_total = $item_sub_total - ($item_sub_total * ($discount / 100));
}
} else {
foreach ($inclusives as $inclusive) {
$item_sub_and_tax_total = $item_discount_total + $item_tax_total; $item_sub_and_tax_total = $item_discount_total + $item_tax_total;
$item_tax_total = $item_sub_and_tax_total - ($item_sub_and_tax_total / (1 + ($inclusive->rate / 100))); $item_base_rate = $item_sub_and_tax_total / (1 + collect($inclusives)->sum('rate')/100);
$item_tax_total = $item_sub_and_tax_total - $item_base_rate;
$item_sub_total = $item_sub_and_tax_total - $item_tax_total; $item_sub_total = $item_base_rate + $discount;
$item_discount_total = $item_sub_total - ($item_sub_total * ($discount / 100));
}
}
} }
if ($compounds) { if ($compounds) {