Skip to content

Commit

Permalink
fix: agian
Browse files Browse the repository at this point in the history
  • Loading branch information
itsemon245 committed May 4, 2024
1 parent d63ae31 commit 4ae8fb3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
15 changes: 9 additions & 6 deletions app/Http/Controllers/Frontend/TaxCalculatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ public function calculate(Request $request)
$formatMinTax = currencyFormat($minTax);
$formattedOriginalTax = currencyFormat($originalTax);
$afterRebateFormatted = currencyFormat($afterRebate);
$formattedDeduction = currencyFormat($request->deduction);
$data = [
'taxes' => [
'a) Tax On Turnover' => currencyFormat($turnoverTax),
'b) Tax On Income' => currencyFormat($incomeTax),
'Actual Tax' => $actualTax,
"b) Tax On Income<br>".($originalTax != 0 ? "<small>Actual Tax ({$formattedOriginalTax})</small>" : '') => currencyFormat($incomeTax),
'actual-tax' => $originalTax,
'*Tax Paid a or b which is higher'.($minTaxApplied ? "<br> <small>Min. Tax Applied({$formatMinTax})</small>" : '') => currencyFormat($tax),
],
'add' => [
Expand All @@ -77,12 +78,13 @@ public function calculate(Request $request)
],
'less' => [
'Rebate' => currencyFormat($request->rebate ?? 0),
'After Rebate' => $originalTax == 0 ? "<div class='text-center border-b-2 border-green-500'>{$afterRebateFormatted}</div>" : $afterRebateFormatted,
'After Rebate' => $originalTax == 0 ? "<div class='text-center' style='border-bottom: 2px solid rgb(14 159 110);'>No Rebate applicable</div>" : $afterRebateFormatted,
'Apply Min-Tax' => $afterRebate < $minTax && $originalTax > 0 ? currencyFormat($minTax) : 'Not Applied',
'Others Paid' => currencyFormat($request->deduction),
'*Total Deduction' => currencyFormat($totalTax - $afterDeduction)
"Others Paid" => $originalTax == 0 ? "<div class='text-center' style='border-bottom: 2px solid rgb(14 159 110);'>No Deduction applicable</div>" : $formattedDeduction
// 'Others Paid' => "-".$formattedDeduction,
// '*Total Deduction' => currencyFormat($totalTax - $afterDeduction)
],
'*Total Balance Payable' => $originalTax == 0 ? "<div class='text-center border-b-2 border-green-500'>{$afterDeduction}</div>" : $afterDeduction
'*Total Balance Payable' => $originalTax == 0 ? "<div class='text-center' style='border-bottom: 2px solid rgb(14 159 110);'>No tax applicable</div>" : currencyFormat($afterDeduction)
];
$incomeOther = $this->calcOthers($income, $request, 'income');
$turnoverOther = $this->calcOthers($turnover, $request, 'turnover');
Expand Down Expand Up @@ -187,6 +189,7 @@ public function calcTax(int $value, $request, string $type)
$slots = $taxSetting->slots()->where('type', $type)->where('to', '<=', $slotLimit)->get();
$value = $afterFree;
$minTaxApplied = false;
$originalTax = 0;
if ($for == 'company') {
$totalTax = $value > $minTax ? $value * $taxSetting[$type.'_percentage'] / 100 : $minTax;
} elseif ($slots->count() > 0) {
Expand Down
20 changes: 11 additions & 9 deletions resources/views/frontend/pages/taxCalculator/result.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,20 @@
<table class="table table-auto border">
@foreach ($items as $text => $amount)
@php
if (str($text)->contains('Actual Tax')) {
if ($text == 'actual-tax') {
$actualTax = $amount;
}
@endphp
<tr>
<td
class="border-2 !border-green-500 px-4 py-2 {{ str($text)->contains('*') ? 'font-bold' : '' }}">
{!! $text !!}</td>
<td
class="border-2 !border-green-500 px-4 py-2 {{ str($text)->contains('*') ? 'font-bold' : '' }}">
{!! str($text)->contains('Actual Tax') ? currencyFormat($amount) : $amount !!}</td>
</tr>
@if ($text != 'actual-tax')
<tr>
<td
class="border-2 !border-green-500 px-4 py-2 {{ str($text)->contains('*') ? 'font-bold' : '' }}">
{!! $text !!}</td>
<td
class="border-2 !border-green-500 px-4 py-2 {{ str($text)->contains('*') ? 'font-bold' : '' }}">
{!! $text == 'actual-tax' ? currencyFormat($amount) : $amount !!}</td>
</tr>
@endif
@endforeach
</table>
@endif
Expand Down

0 comments on commit 4ae8fb3

Please sign in to comment.