@extends('layouts.master') @section('title',__('index.employee_tax_report')) @section('action',__('index.tax_report_detail')) @section('main-content')
@include('admin.section.flash_message') @include('admin.payroll.taxReport.common.breadcrumb')

{{ __('index.tax_report_detail_of') }} {{ $reportData->employee->name }} ({{ $reportData->fiscalYear->year }})

{{ __('index.salary_sheet') }}
@php $monthData = json_decode($reportData->months, true); // Count the number of months $totalMonth = count($monthData); $startMonth = 4; // Default start month (Shrawan) $endMonth = 3; // Default end month (Asar) // Create an array of all months $allMonths = array_merge(range(4, 12), range(1, 3)); $incomeComponents = [ 'Basic Salary' => $reportData['total_basic_salary']/$totalMonth, 'Allowance' => $reportData['total_allowance']/$totalMonth, 'SSF Contribution' => $reportData['total_ssf_contribution']/$totalMonth ]; $totalAnnualIncome = 0; $monthlyTotals = array_fill(1, 12, 0); // Accessing 'earning' type components $earningComponents = $reportData->componentDetail->groupBy('type')->get('earning', collect()); // Accessing 'deduction' type components $deductionComponents = $reportData->componentDetail->groupBy('type')->get('deductions', collect()); // access basic,salary, fixed allowance and ssf data $monthlyBasicSalary = []; $monthlyFixedAllowance = []; $monthlySsfContribution = []; $monthlySsfDeduction = []; if($reportData->reportDetail){ foreach ($reportData->reportDetail as $detail) { $month = $detail->month; // get the month $monthlyBasicSalary[$month] = $detail->basic_salary ?? 0; $monthlyFixedAllowance[$month] = $detail->fixed_allowance ?? 0; $monthlySsfContribution[$month] = $detail->ssf_contribution ?? 0; $monthlySsfDeduction[$month] = $detail->ssf_deduction ?? 0; } } @endphp @foreach($allMonths as $month) @endforeach @php $totalAnnualIncome += $reportData->total_basic_salary; @endphp @foreach($allMonths as $month) @php $showData = in_array($month, $monthData); $monthlyBasicSalaryValue = $monthlyBasicSalary[$month] ?? 0; @endphp @if($showData) @php $monthlyTotals[$month] += $monthlyBasicSalaryValue; @endphp @else @endif @endforeach @php $totalAnnualIncome += $reportData->total_allowance; @endphp @foreach($allMonths as $month) @php $showData = in_array($month, $monthData); $monthlyFixedAllowanceValue = $monthlyFixedAllowance[$month] ?? 0; @endphp @if($showData) @php $monthlyTotals[$month] += $monthlyFixedAllowanceValue; @endphp @else @endif @endforeach @php $totalAnnualIncome += $reportData->total_ssf_contribution; @endphp @foreach($allMonths as $month) @php $showData = in_array($month, $monthData); $monthlySsfContributionValue = $monthlySsfContribution[$month] ?? 0; @endphp @if($showData) @php $monthlyTotals[$month] += $monthlySsfContributionValue; @endphp @else @endif @endforeach @php $totalEarning = 0; $totalDeduction = 0; $totalBonusAmount = 0; @endphp @foreach($earningComponents as $earning) @php $annualAmount = 0; foreach($allMonths as $month) { if (in_array($month, $monthData)) { $annualAmount += $earning->amount; } } $totalEarning += $annualAmount; $totalAnnualIncome += $annualAmount; @endphp @foreach($allMonths as $month) @if(in_array($month, $monthData)) @php $monthlyTotals[$month] += $earning->amount; @endphp @else @endif @endforeach @endforeach @if(!empty($reportData->bonusDetail)) @foreach($reportData->bonusDetail as $bonus) @if(in_array($bonus['month'], $allMonths)) @php $showBonus = false; $totalBonus = 0; foreach($allMonths as $month) { if (in_array($month, $monthData)) { if ($bonus['month'] == $month) { $showBonus = true; $totalBonus = $bonus['amount']; $totalBonusAmount += $bonus['amount']; $totalAnnualIncome += $totalBonus; $totalEarning += $totalBonus; break; } } } @endphp @if($showBonus) @foreach($allMonths as $month) @if(in_array($month, $monthData)) @php $bonusAmount = ($bonus['month'] == $month) ? $bonus['amount'] : 0; $monthlyTotals[$month] += $bonusAmount; @endphp @else @endif @endforeach @endif @endif @endforeach @endif @foreach($allMonths as $month) @if(in_array($month, $monthData)) @else @endif @endforeach @php $totalMonthlyDeduction = array_fill(1, 12, 0); $totalAnnualDeduction = $reportData['total_ssf_deduction']; @endphp @foreach($allMonths as $month) @php $monthlySsfDeductionValue =$monthlySsfDeduction[$month] ?? 0; $totalMonthlyDeduction[$month] += $monthlySsfDeductionValue; @endphp @if(in_array($month, $monthData)) @else @endif @endforeach @foreach($deductionComponents as $deduction) @php $annualAmount = 0; foreach($allMonths as $month) { if (in_array($month, $monthData)) { $annualAmount += $deduction->amount; } $totalMonthlyDeduction[$month] += $deduction->amount; } $totalAnnualDeduction += $annualAmount; $totalDeduction += $annualAmount; @endphp @foreach($allMonths as $month) @if(in_array($month, $monthData)) @else @endif @endforeach @endforeach @foreach($allMonths as $month) @php $showData = in_array($month, $monthData); @endphp @if($showData) @else @endif @endforeach @php $monthlyTDS = array_fill(1, 12, 0); // Initialize an array for 12 months with 0 foreach ($reportData->tdsDetail as $tdsDetail) { $monthlyTDS[$tdsDetail->month] = ($tdsDetail->is_paid == 1) ? $tdsDetail->amount : 0; } @endphp @foreach($allMonths as $month) @if(in_array($month, $monthData)) @else @endif @endforeach @php $annualTotalPayable = $totalAnnualIncome - $totalAnnualDeduction - 0; @endphp @foreach($allMonths as $month) @php $monthlyTotalPayable = $monthlyTotals[$month] - $totalMonthlyDeduction[$month] - ($monthlyTDS[$month] ?? 0); $showData = in_array($month, $monthData); @endphp @if($showData) @else @endif @endforeach
{{ __('index.particular') }} {{ __('index.total') }}{{ $months[$month] }}
{{ __('index.income') }}
{{ __('index.basic_salary') }}{{ $currency.' '.number_format($reportData->total_basic_salary, 2) }}{{ $currency.' '.number_format($monthlyBasicSalaryValue, 2) }}
{{ __('index.fixed_allowance') }}{{ $currency.' '.number_format( $reportData->total_allowance, 2) }}{{ $currency.' '.number_format($monthlyFixedAllowanceValue, 2) }}
{{ __('index.ssf_contribution') }}{{ $currency.' '.number_format($reportData->total_ssf_contribution, 2) }}{{ $currency.' '.number_format($monthlySsfContributionValue, 2) }}
{{ $earning->salaryComponent->name }}{{ number_format($annualAmount, 2) }}{{ number_format($earning->amount, 2) }}
{{ $bonus->bonus->title }} {{ number_format($totalBonus, 2) }}{{ $bonusAmount > 0 ? number_format($bonusAmount, 2) : '' }}
{{ __('index.total_income') }} {{ number_format($totalAnnualIncome, 2) }}{{ number_format($monthlyTotals[$month], 2) }}
{{ __('index.deductions') }}
{{ __('index.ssf_deduction') }} {{ $currency.' '.($reportData['total_ssf_deduction']) }}{{ $currency.' '.$monthlySsfDeductionValue }}
{{ $deduction->salaryComponent->name }}{{ number_format($annualAmount, 2) }}{{ number_format($deduction->amount, 2) }}
{{ __('index.total_deduction') }} {{ number_format($totalAnnualDeduction, 2) }}{{ number_format($totalMonthlyDeduction[$month], 2) }}
{{ __('index.tds_paid') }} {{ $monthlyTDS[$month] ? number_format($monthlyTDS[$month], 2) : '' }}
{{ __('index.total_payable') }}{{ number_format($annualTotalPayable, 2) }}{{ number_format($monthlyTotalPayable, 2) }}
{{ __('index.additional_information') }}
@php $ssfContribution = 0; $totalRetirementContribution = 0; $totalMonthlyDeduction = array_fill(1, 12, 0); $totalRetirementContribution = $totalAnnualDeduction; @endphp @foreach($deductionComponents as $deduction) @php $annualAmount = 0; foreach($allMonths as $month) { if (in_array($month, $monthData)) { $annualAmount += $deduction->amount; } } @endphp @endforeach @php $annualSalary = $reportData['total_basic_salary']+$reportData['total_allowance']+$totalEarning - $totalDeduction; $basicSalary = $reportData['total_basic_salary']/$totalMonth; $totalOtherComponents = 0; @endphp @foreach ($reportData->additionalDetail as $component) @php // Adjust for joining date $monthlyComponentValue = $component->amount; $adjustedComponentValue = 0; foreach($allMonths as $month) { if (in_array($month, $monthData)) { $adjustedComponentValue += $monthlyComponentValue; } } $totalOtherComponents += $adjustedComponentValue; @endphp @endforeach @php $totalDeductions = $totalRetirementContribution + $totalOtherComponents; $taxableIncome = $totalAnnualIncome - $totalDeductions; @endphp
{{ __('index.particular') }} {{ __('index.amount') }} {{ __('index.amount') }}
{{ __('index.total_income') }} {{ number_format($totalAnnualIncome, 2) }}
{{ __('index.less') }} {{ __('index.total_retirement_contribution_allowed') }} {{ number_format($totalRetirementContribution, 2) }}
{{ __('index.ssf_contribution_salary') }} {{ number_format($reportData['total_ssf_deduction'], 2) }}
{{ $deduction->salaryComponent->name }}{{ number_format($annualAmount, 2) }}
{{ $component->salaryComponent->name }} {{ $adjustedComponentValue }}
{{ __('index.taxable_income') }} {{ number_format($taxableIncome, 2) }}
@if (isset($taxData[$reportData->employee->marital_status]))
{{ __('index.tax_calculation_on_taxable_income') }} ({{ ucfirst($reportData->employee->marital_status) }})
@php $remainingIncome = $taxableIncome; $totalTax = 0; $isFirstBracket = true; $totalBonusTax = 0; @endphp @foreach($taxData[$reportData->employee->marital_status] as $bracket) @php $from = $bracket->annual_salary_from; $to = $bracket->annual_salary_to >= 1.0E+20 ? null : $bracket->annual_salary_to; $percent = $bracket->tds_in_percent; $bracketIncome = min(max($remainingIncome, 0), $to ? $to - $from : $remainingIncome); $taxAmount = $bracketIncome * ($percent / 100); // Adjust the condition to check for SSF contribution if ($isFirstBracket && $reportData['total_ssf_deduction'] > 0) { $taxAmount = 0; } $totalTax += $taxAmount; $remainingIncome -= $bracketIncome; $isFirstBracket = false; @endphp @endforeach @php $taxDeduction = $reportData->medical_claim+$reportData->female_discount+$reportData->other_discount; @endphp
{{ __('index.from') }} {{ __('index.to') }} {{ __('index.income') }} {{ __('index.percent') }} {{ __('index.tax_amount') }}
{{ number_format($from, 2) }} {{ $to ? number_format($to, 2) : '' }} {{ number_format($bracketIncome, 2) }} {{ number_format($percent, 2) }}% {{ number_format($taxAmount, 2) }}
{{ __('index.total') }} {{ number_format($taxableIncome, 2) }} {{ number_format($totalTax, 2) }}
{{ __('index.less_tax_deduction') }} {{ __('index.medical_claim') }} {{ $reportData->medical_claim }}
{{ __('index.female_discount') }} {{ $reportData->female_discount }}
{{ __('index.other_discount') }} {{ $reportData->other_discount }}
{{ __('index.total_payable_tds') }} {{ number_format(($totalTax - $taxDeduction), 2) }}
{{ __('index.total_paid_tds') }} {{ $reportData->total_paid_tds }}
{{ __('index.total_due_tds') }} {{ number_format(($totalTax - $taxDeduction - $reportData->total_paid_tds),2) }}
@else

{{ __('index.tax_data_not_available') }} ({{ $reportData->employee->name }}).

@endif
@endsection @section('scripts') @endsection