Skip to content

Commit

Permalink
fix the appraisal letter data calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
GauravGusain98 committed Sep 13, 2024
1 parent 63c6b25 commit fa0a5a2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Modules/Salary/Http/Controllers/SalaryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public function generateAppraisalLetter(Request $request, Employee $employee)
}

$data = $salaryService->appraisalLetterData($request, $employee);
$employeeName = $data->employeeName;
$commencementDate = $data->commencementDate;
$employeeName = $data["employeeName"];
$commencementDate = $data["commencementDate"];
$date = Carbon::parse($commencementDate);
$commencementDateFormat = $date->format('F Y');
$pdf = $salaryService->getAppraisalLetterPdf($data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@
</div>
<hr></hr>
<div class="confidential-text">Confidential</div>
<div class="date" style="display: block; float: right;" >Date: <b>{{ $data->commencementDate }}</b></div>
<div class="date" style="display: block; float: right;" >Date: <b>{{ $data["commencementDate"] }}</b></div>
<div class="user-details">
To<br>
<span class="name">{{ $data->employeeName }}</span>,<br>
<span class="address">{!! $data->address !!}</span>
<span class="name">{{ $data["employeeName"] }}</span>,<br>
<span class="address">{!! $data["address"] !!}</span>
</div>
<div class="user-details name">Dear {{ $data->employeeFirstName }},</div>
<div class="user-details name">Dear {{ $data["employeeFirstName"] }},</div>
<div class="pay-details">
The management of ColoredCow Consulting Pvt. Ltd. takes pleasure in informing you that
your remuneration has been appraised with <b>{{ $data->salaryIncreasePercentage }}%</b> w.e.f <b>{{ $data->commencementDate }}</b>. Below are the
your remuneration has been appraised with <b>{{ $data["salaryIncreasePercentage"] }}%</b> w.e.f <b>{{ $data["commencementDate"] }}</b>. Below are the
details of the pay raise.
</div>
<div class="paddingTop content-font-size" style="width: 100%;">
Expand All @@ -162,32 +162,32 @@
<td class="table-content"><b>Effective Date</b></td>
</tr>
<tr>
<td class="table-content"><b>{{ $data->previousSalary }}/-</b></td>
<td class="table-content"><b>{{ $data->ctcAggregated}}/- </b></td>
<td class="table-content"><b>{{ $data->salaryIncreasePercentage }}</b></td>
<td class="table-content"><b>{{ $data->commencementDate}}</b></td>
<td class="table-content"><b>{{ $data["previousSalary"] }}/-</b></td>
<td class="table-content"><b>{{ $data["ctcAggregated"]}}/- </b></td>
<td class="table-content"><b>{{ $data["salaryIncreasePercentage"] }}</b></td>
<td class="table-content"><b>{{ $data["commencementDate"]}}</b></td>
</tr>
</table>
</div>
<div class="revised-details">
Your revised remuneration will be <b>INR {{ round(($data->ctcAggregated)/12, 2)}}/-</b> per month as per the following breakup.<br>
Your revised remuneration will be <b>INR {{ round(($data["ctcAggregated"])/12, 2)}}/-</b> per month as per the following breakup.<br>
<div class="salary-details">
<span class="salary-text">Basic Salary</span><span class="salary-number-1">Rs {{ $data->basicSalary }}/-</span><br>
<span class="salary-text">Basic Salary</span><span class="salary-number-1">Rs {{ $data["basicSalary"] }}/-</span><br>
</div>
<div class="salary-details">
<span class="salary-text">HRA. Allowance</span><span class="salary-number-2">Rs {{ $data->hra }}/-</span>
<span class="salary-text">HRA. Allowance</span><span class="salary-number-2">Rs {{ $data["hra"] }}/-</span>
</div>
<div class="salary-details">
<span class="salary-text">Conveyance Allowance</span><span class="salary-number-3">Rs {{ $data->tranportAllowance }}/-</span>
<span class="salary-text">Conveyance Allowance</span><span class="salary-number-3">Rs {{ $data["tranportAllowance"] }}/-</span>
</div>
<div class="salary-details">
<span class="salary-text">Other Allowance</span><span class="salary-number-4">Rs {{ $data->otherAllowance }}/-</span>
<span class="salary-text">Other Allowance</span><span class="salary-number-4">Rs {{ $data["otherAllowance"] }}/-</span>
</div>
<div class="salary-details">
<span class="salary-text" >P.F. and Charges(Employer share)</span><span class="salary-number-5">Rs {{ $data->employeeShare }}/-</span>
<span class="salary-text" >P.F. and Charges(Employer share)</span><span class="salary-number-5">Rs {{ $data["employeeShare"] }}/-</span>
</div>
<div class="salary-details">
<span class="salary-text" >Medical Insurance(per month)</span><span class="salary-number-6">Rs {{ round($data->monthlyHealthInsurance, 2) }}/-</span>
<span class="salary-text" >Medical Insurance(per month)</span><span class="salary-number-6">Rs {{ round($data["monthlyHealthInsurance"], 2) }}/-</span>
</div>
</div>
<div class="paddingTop content-font-size"><b>***Medical insurance of 5 Lakhs, rupees are added to your CTC.</b></div>
Expand Down Expand Up @@ -216,10 +216,10 @@
Yours Sincerely,<br>
<div class="signature-text">
<span style="display: inline-block; margin-right: 400px;">For Coloredcow Consulting Pvt. Ltd.<br><br><br></span>
<div style="display: block; float: right; margin-top:40px;">{{$data->employeeName}}</div>
<div style="display: block; float: right; margin-top:40px;">{{$data["employeeName"]}}</div>
<div>
<!-- <div style="position: absolute; top: 10px; left: 120px;">
<img src="data:image/png;base64,{{-- base64_encode($data->imageData) --}}" height="110" width="180">
<img src="data:image/png;base64,{{-- base64_encode($data["imageData"]) --}}" height="110" width="180">
</div> -->
Mohit Sharma,<br>
HR, Admin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
<div>This Employment Agreement is executed at Gurugram on <b>{{$data['formattedCommencementDate']}}</b> between </div>
<div>
<p>1. <b>Coloredcow Consulting Private Limited</b>, a company incorporated under the laws of India and having its registered office at F-61, Suncity, Sector 54, Gurugram, Haryana-122003, India <b>("Company")</b>; and </p>
<p>2. <b>{{$data['employeeFirstName']}}</b> is an Indian national, aged <b>{{$data['employeeAge']}}</b> years, holding Permanent Account Number(PAN) <b></b>, and presently residing at <b>hardcoded</b>
<p>2. <b>{{$data['employeeFirstName']}}</b> is an Indian national, aged <b>{{$data['employeeAge']}}</b> years, holding Permanent Account Number(PAN) <b>{{ $data['pan_details'] }}</b>, and presently residing at <b>{{ $data['employeeAddress'] }}</b>
<p>Each of the Company and the Employee is individually referred to as the <b>Party</b> and collectively as the <b>Parties</b>. </p>
<p><b>WHEREAS</b></p>
<p>1. The Employee is appointed by the Company through a letter of appointment dated<b>{{$data['formattedCommencementDate']}}</b></p>
Expand Down
26 changes: 9 additions & 17 deletions Modules/Salary/Services/SalaryCalculationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public function hra()

public function appraisalLetterData($request, $employee)
{
$fetchEmployeeSalarydetails = $this->employeeSalaryDetails($request, $employee);
$fetchEmployeeDetails = $this->employeeDetails($employee);
$commencementDate = Carbon::parse($request->commencementDate)->format('jS F Y');
$employeeName = $employee->name;
$employeeFirstName = explode(' ', $employeeName)[0];
Expand All @@ -58,18 +56,17 @@ public function appraisalLetterData($request, $employee)
$totalHealthInsurance = $newSalaryObject->health_insurance * (optional($employee->user->profile)->insurance_tenants ?? 1);
$monthlyHealthInsurance = $totalHealthInsurance / 12;
$newAggregateCTC = $newSalaryObject->ctc_annual + $totalHealthInsurance;
$currentAnnualCTC = $employee->getLatestSalary($employee->payroll_type)->ctc_annual;
$currentAnnualCTC = $employee->getLatestSalary($employee->payroll_type)->ctc_aggregated;
$salaryIncreasePercentage = $this->getLatestSalaryPercentageIncrementAttribute($currentAnnualCTC, $newAggregateCTC);
$employeeUserId = $employee->user_id;
// if ($request->signature) {
// $imageData = file_get_contents($request->signature);
// }
$userProfile = UserProfile::where('user_id', $employeeUserId)->first();
if ($userProfile) {
$address = $userProfile->address;
}

$data = (object) [
$data = [
'pan_details' => $request->pan_details,
'date_of_birth' => $request->date_of_birth,
'employeeName' => $employeeName,
'employeeFirstName' => $employeeFirstName,
'date' => $currentDate,
Expand All @@ -86,7 +83,6 @@ public function appraisalLetterData($request, $employee)
'previousSalary' => $currentAnnualCTC,
'salaryIncreasePercentage' => $salaryIncreasePercentage,
'address' => isset($address) ? $address : null, // Handle the case where $address might not be set
// 'imageData' => isset($imageData) ? $imageData : null,
];

return $data;
Expand Down Expand Up @@ -214,12 +210,6 @@ public function getEmployeeAddressDetail($employee)
return $address;
}

public function getEmployeeAge($employee)
{
$age = $employee->user->getUserAge($employee->user_id);
return $age;
}

public function getEmployeeDesignation($employee)
{
$user = $employee->user;
Expand Down Expand Up @@ -254,12 +244,14 @@ public function getContractorOnboardingLetterPdf($data, $employee)
$newSalaryObject = new EmployeeSalary();
$newSalaryObject->monthly_gross_salary = $data['grossSalary'];


$totalHealthInsurance = $newSalaryObject->health_insurance * (optional($employee->user->profile)->insurance_tenants ?? 1);
$monthlyHealthInsurance = $totalHealthInsurance / 12;

$dob = isset($data['date_of_birth']) ? Carbon::parse($data['date_of_birth']) : Carbon::parse(optional($employee->user->profile)->date_of_birth);
$data['pan_details'] = $data['pan_details'] ?? Carbon::parse(optional($employee->user->profile)->pan_details);
$data['formattedCommencementDate'] = $commencementDate;
$data['employeeAddress'] = $this->getEmployeeAddressDetail($employee);
$data['employeeAge'] = $this->getEmployeeAge($employee);
$data['employeeAge'] = $dob->age;
$data['employeeDesignation'] = $this->getEmployeeDesignation($employee);
$data['salaryPackage'] = $this->getSalaryPackage($data['ctcAggregated']);
$employeeFirstName = explode(' ', $employee->name)[0];
Expand All @@ -270,7 +262,7 @@ public function getContractorOnboardingLetterPdf($data, $employee)
$data['hra'] = $newSalaryObject->hra;
$data['transportAllowance'] = $newSalaryObject->transport_allowance;
$data['medicalInsurance'] = $monthlyHealthInsurance;
$data['epfShare'] = $newSalaryObject->employer_epf + $newSalaryObject->employee_epf;
$data['epfShare'] = $newSalaryObject->employee_epf + $newSalaryObject->edli_charges + $newSalaryObject->administration_charges;
$pdf = App::make('snappy.pdf.wrapper');
$template = 'contractor-onboarding-template';
$html = view('salary::render.' . $template, compact('data'));
Expand Down

0 comments on commit fa0a5a2

Please sign in to comment.