Skip to content

Commit 910b6f7

Browse files
committed
fix:asset percentage
1 parent bb6edcb commit 910b6f7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

app/Http/Controllers/Frontend/TaxCalculatorController.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ public function calculate(Request $request)
4646
$income = (int) ($request->yearly_income ?? 0);
4747
$turnover = (int) ($request->yearly_turnover ?? 0);
4848
$asset = (int) ($request->total_asset ?? 0);
49+
$assetPercentage = $this->calcTax($asset, $request, 'asset');
4950
$incomeTaxAll = $this->calcTax($income, $request, 'income');
5051
$turnoverTaxAll = $this->calcTax($turnover, $request, 'turnover');
5152
$incomeTax = $incomeTaxAll['tax'];
5253
$turnoverTax = $turnoverTaxAll['tax'];
5354
$minTaxApplied = $incomeTax > $turnoverTax ? $incomeTaxAll['min-tax-applied'] : $turnoverTaxAll['min-tax-applied'];
5455
$originalTax = $incomeTax > $turnoverTax ? $incomeTaxAll['original-tax'] : $turnoverTaxAll['original-tax'];
55-
$assetPercentage = $this->calcTax($asset, $request, 'asset');
5656

5757
$assetTax = ($incomeTax > $turnoverTax) ? $incomeTax * ($assetPercentage / 100) : $turnoverTax * ($assetPercentage / 100);
5858
$tax = $turnoverTax > $incomeTax ? $turnoverTax : $incomeTax;
@@ -73,14 +73,14 @@ public function calculate(Request $request)
7373
'*Tax Paid a or b which is higher'.($minTaxApplied ? "<br> <small>Min. Tax Applied({$formatMinTax})</small>" : '') => currencyFormat($tax),
7474
],
7575
'add' => [
76-
'WealthTax' => currencyFormat($assetTax),
76+
'WealthTax' => "+ ".currencyFormat($assetTax),
7777
'*Total Payable Tax' => currencyFormat($totalTax),
7878
],
7979
'less' => [
80-
'Rebate' => "-".currencyFormat($request->rebate ?? 0),
80+
'Rebate' => "- ".currencyFormat($request->rebate ?? 0),
8181
'After Rebate' => $originalTax == 0 ? "<div class='text-center' style='border-bottom: 2px solid rgb(14 159 110);'>{$afterRebateFormatted}</div>" : $afterRebateFormatted,
8282
'Apply Min-Tax' => $afterRebate < $minTax && $originalTax > 0 ? currencyFormat($minTax) : 'Not Applied',
83-
"Others Paid" => $originalTax == 0 ? "<div class='text-center' style='border-bottom: 2px solid rgb(14 159 110);'>No Deduction applicable</div>" : "-".$formattedDeduction
83+
"Others Paid" => $originalTax == 0 ? "<div class='text-center' style='border-bottom: 2px solid rgb(14 159 110);'>No Deduction applicable</div>" : "- ".$formattedDeduction
8484
// 'Others Paid' => "-".$formattedDeduction,
8585
// '*Total Deduction' => currencyFormat($totalTax - $afterDeduction)
8686
],
@@ -166,10 +166,11 @@ public function calcTax(int $value, $request, string $type)
166166
'female' => (int) $taxSetting->tax_free->female,
167167
null => (int) $taxSetting->tax_free->amount ?? 0,
168168
};
169+
$afterFree = $value - $taxFree;
169170
} else {
170171
$taxFree = 0;
172+
$afterFree = $value - $taxFree;
171173
}
172-
$afterFree = $value - $taxFree;
173174
$minTax = $taxSetting->min_tax ?? 0;
174175
$lastValueSlot = $taxSetting->slots()->where('type', $type)
175176
->where('from', '<=', $afterFree)
@@ -183,7 +184,7 @@ public function calcTax(int $value, $request, string $type)
183184
* For Asset Type just return the last value slot percentage
184185
*/
185186
if ($type == 'asset') {
186-
return $lastValueSlot->percentage ?? 0;
187+
return $lastValueSlot->tax_percentage ?? 0 ;
187188
}
188189
$slotLimit = $lastValueSlot?->to ?? 0;
189190
$slots = $taxSetting->slots()->where('type', $type)->where('to', '<=', $slotLimit)->get();

0 commit comments

Comments
 (0)