Skip to content

Commit

Permalink
Update Items.php
Browse files Browse the repository at this point in the history
  • Loading branch information
sausin committed Feb 3, 2019
1 parent b135f0a commit 1bef573
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions app/Http/Controllers/Common/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,37 +358,12 @@ public function totalItem(TRequest $request)
}

if ($inclusives) {
if ($discount) {
$item_tax_total = 0;
$item_sub_and_tax_total = $item_discount_total + $item_tax_total;

if ($taxes) {
foreach ($taxes as $tax) {
$item_tax_amount = ($item_sub_total / 100) * $tax->rate;
$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_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_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));
}
}
$item_sub_total = $item_base_rate + $discount;
}

if ($compounds) {
Expand Down

0 comments on commit 1bef573

Please sign in to comment.