Loan / Advance Transaction
Navigation Path
Loan → Loan/Advance
URL
loan/loan-or-advance-transaction
Description
The Loan / Advance Transaction page is used to create, edit, view, and delete employee loan or advance records.
All operations (Add, Edit, Delete, View) are handled within a single page.
Employee Search Section
Used to search and filter employees before creating a loan/advance entry.
Fields
- Code – Employee Code
- Name – Employee Name
- Unit – Select or create a unit
- Department – Select department
Actions
- Search Employee – Fetch employee details based on search criteria
- Clear – Reset search inputs
Loan / Advance Entry Form
Used to add or update loan/advance details for the selected employee.
Fields
- Employee Code – Select employee
- Employee Name – Auto-filled
- Department – Auto-filled
- Unit – Select or create a unit
- Head – Select or create loan/advance head
- Allotment / Order No – Select order number
- Dated – Select date
- Effective Date – Select effective date
- Loan Type – Select loan type
- Remarks – Enter remarks
Actions
- Save – Create or update loan/advance transaction
- Reset – Clear form fields
Loan / Advance List Table
Displays all existing loan and advance records.
Table Columns
- S No
- Loan/Adv. Code
- Employee Code
- Employee Name
- Loan/Adv Type
- Actions
Table Features
- Column-wise search/filter
- Search by employee code
- Pagination support
Row Actions
- Edit – Loads the selected record into the form for updating
- Delete – Removes the selected record after confirmation
Delete Confirmation
When deleting a record, a confirmation alert is shown to prevent accidental deletion.
Notes
- This module uses only one URL for all operations.
- Add, Edit, View, and Delete are handled on the same page.
- Employee details are auto-populated after selection.
API Endpoints
The Loan or Advance Master module interacts with the following API endpoints:
Base URL
export const LOANORADVANCE_URL = '/api/loanMaster'
Endpoints
| Endpoint | Method | Description | Parameters/Body |
|---|---|---|---|
\$\{LOANORADVANCE_URL\} | GET | Get all loans with pagination | Query: page, limit |
\$\{LOANORADVANCE_URL\}/:loanId | GET | Get loan by ID | Path: loanId |
\$\{LOANORADVANCE_URL\} | POST | Create a new loan or advance | Body: data |
\$\{LOANORADVANCE_URL\}/:loanId | PATCH | Update an existing loan | Path: loanId, Body: body |
\$\{LOANORADVANCE_URL\}/delete/:loanId | PATCH | Delete a loan (soft delete) | Path: loanId |
\$\{LOANORADVANCE_URL\}/search/loan/export | GET | Search and export loans to Excel | Query: query (search criteria), Returns: Excel file (blob) |
\$\{LOANORADVANCE_URL\}/import/loan/excel | POST | Import loan reports from Excel | Body: data (file) |
\$\{LOANORADVANCE_URL\}/search/loan | GET | Search loans with filters | Query: query (search parameters) |
\$\{LOANORADVANCE_URL\}/import/loan/exported-sheet | POST | Import loans from exported sheet | Body: data (file) |
\$\{LOANORADVANCE_URL\}/search/left-employees | POST | Get loans of left employees | Body: data (search criteria) |
RTK Query Hooks
The following hooks are available for frontend integration:
useGetAllLoansQueryuseGetLoanByIdQueryuseCreateLoanMutationuseUpdateLoanMutationuseDeleteLoanMutationuseSearchAndExportLoansQueryuseImportLoanReportMutationuseGetLoansBySearchQueryuseImportLoansFromExportedSheetMutationuseGetLoansOfLeftEmployeesMutation
Field Definitions, Usage, and Calculation Logic
The Loan / Advance module manages the lifecycle of employee debt, from application to full recovery through monthly payroll deductions.
1. Field Definitions
| Field Name | Technical Name | Category | Description |
|---|---|---|---|
| Loan Code | loanCode | Identity | Unique identifier (e.g., LOAN00001). |
| Loan Type | loanType | Category | Type of loan (Loan, Special Loan, UNIFORM, TRAINEE). |
| Loan Amount | loanAmount | Principal | The total principal amount granted to the employee. |
| Installment Amt | installmentAmount | Deduction | The amount deducted each month from the salary. |
| No. of Installments | numberOfInstallments | Period | Total duration (in months) for repayment. |
| Balance Amount | balanceAmount | Principal | Current outstanding debt. Initially equals Loan Amount. |
| Remaining Inst. | remainingInstallments | Period | Count of upcoming monthly deductions. |
| Effective Date | effectiveDate | Period | The month from which deductions should begin. |
| Status | status | Workflow | PENDING, APPROVED, ACTIVE, COMPLETED, CANCELLED. |
2. Field Usage & Business Rules
A. Employee Status Validation
- The system prevents loan creation if the employee's
leftStatusis 'Y'. - Active loans of "Left" employees can be tracked via the specialized
Left Employee Searchendpoint.
B. Special Loan Constraints (Uniform & Trainee)
- Singleton Rule: An employee can only have one
UNIFORMand oneTRAINEEloan active in their entire history (not soft-deleted). - Master Synchronization: Saving a
UNIFORMorTRAINEEloan automatically updates the corresponding flags (uniformLoanDeducted,traineeLoanDeducted) in the Employee Master.
C. Status Lifecycle
- PENDING: Initial entry. No deductions occur.
- ACTIVE: Eligible for deduction during the next monthly salary process.
- COMPLETED: Automatically set when
balanceAmountreaches zero. - CANCELLED: Manual override to stop recovery permanently.
3. Calculation Logic
A. Monthly Deduction Formula
During the Salary Auto Process, the logic for each ACTIVE loan is:
- New Balance:
BalanceAmount = BalanceAmount - InstallmentAmount. - New Remaining Inst.:
RemainingInst = RemainingInst - 1. - If
New Balance <= 0, the loan status is updated toCOMPLETED.
B. Reversion Logic (Salary Deletion)
If a processed salary is deleted or recalculated:
- Restoration:
BalanceAmount = BalanceAmount + PreviouslyDeductedAmount. - Inst. Correction:
RemainingInst = RemainingInst + 1. - Status is reverted from
COMPLETEDback toACTIVEif the balance becomes positive.
C. Installment Auto-Calculation
By default, the installmentAmount is calculated as:
InstallmentAmount = LoanAmount / numberOfInstallments.- The system allows manual overrides of the
installmentAmountduring entry without forcing the division result.
End of Technical Documentation