Module — Payroll¶
Monthly staff compensation. It generates the payroll run from HR contracts and attendance, splits each salary across project budget lines and donors, and manages the supporting employee documents — advances / loans (with ordinary and emergency cash boxes), overtime claims, and timesheets (including the leave requests that flow through the same controller).
Source: NKO.Main/NKO.Main/Controllers/{Payroll,Overtime,Timesheet}Controller.cs and
AdvanceController .cs; NKO.Main/NKO.Main/BAL/{BPayroll,BAdvance,BOvertime,BTimesheet}.cs;
NKO.Lib/NKO.Shared/ViewModels/Payroll/PayrollStatus.cs.
Purpose & scope¶
- In scope: the
Payrollrun and its per-employeePayrollInfolines, salary allocation across budget lines, advances / loans and the cash boxes, overtime claims, and timesheets. - Out of scope: the contracts and compensation records themselves (HR), the budget
lines and donor exchange rates (Grant), and the leave approval workflow
(Leave Management) — the leave requests live on
TimesheetControllerbut the rules are HR's. - Database:
NKO_DB(core), contextNKO_DBEntities1.
Key features¶
- Payroll run — one
Payrollper month/year;Generatebuilds aPayrollInfoper eligible (non-private) employee; four-tier sign-off (Requester → Allocator → Finance Manager → Country Director) with refuse-to-draft reset; the exchange rate is captured at the Finance stage; exports (full, "min", per-month, allocations); "Transfer Finance / Partners data" Excel import; the branch treasurer is notified on acceptance. - Allocations — distribute an employee's monthly basic salary across budget lines by LOE %,
converting to USD / EUR via
DonorExchangeRate; the allocator cannot sign until every shared employee is fully allocated (IsAllRatiosAvailable). - Advances & loans — an eligibility engine (core staff only, past the trial period, tenure and
prior-loan rules); advance ≤ 50 % of net salary (50–100 % needs justification); a loan repayment
schedule auto-split over N months; ordinary + emergency cash boxes (balances held in
CommonSetting), pending-loan auto-payment, a cash-box transaction ledger, "Set as paid", and guarantors. - Overtime — multi-date claims; amount
= hours × ((contract.Amount / 30) / 8) × factor(1.5normal,2.0weekend / public holiday); Complete / Edit recompute; copy-as-draft; emergent flag + finance disclosure. - Timesheets & leave — a monthly timesheet per employee (Draft → Manager → HR → Treasurer pay → payment confirm); leave requests with balance checks, a substitute user, hourly / daily types; project-ratio months; leave-balance create / import; the attendance calendar.
Screens¶
Route = /{Controller}/{Action}; primary screens only. Full list in the Payroll API reference.
PayrollController — /Payroll/*¶
| Feature | Route | View | Permission key |
|---|---|---|---|
| Payroll runs list | / |
Payroll/ |
Payroll |
| Run detail (per-employee lines + sign-off) | / |
Details. |
Payroll |
| Generate a run | / |
_Create. |
Payroll |
| Reset a run to draft | / |
(redirect) | Payroll |
| Upload partner-contribution split | / |
Transfer |
Payroll |
| Upload bank / finance data | / |
Transfer |
Payroll |
| Exports (bank file / min / allocations) | /, /, /, / |
(files) | Payroll, Payroll |
AdvanceController — /Advance/*¶
| Feature | Route | View | Permission key |
|---|---|---|---|
| Advance & loan requests | / |
Advance/ |
Advance |
| Request detail | / |
Details. |
Advance |
| Create / manage / complete | /, / |
Manage., Complete. |
Advance |
| Cash-box transaction ledger | / |
Cash |
Advance |
| Set a disbursement as paid | / |
_Advance |
Advance |
OvertimeController — /Overtime/*¶
| Feature | Route | View | Permission key |
|---|---|---|---|
| Overtime claims | / |
Overtime/ |
Overtime |
| Claim detail | / |
Details. |
Overtime |
| Create / edit / complete | /, /, / |
Create/ |
Overtime |
TimesheetController — /Timesheet/*¶
| Feature | Route | View | Permission key |
|---|---|---|---|
| Timesheets list | / |
Timesheet/ |
Timesheet |
| Timesheet detail | / |
Details. |
Timesheet |
| Create timesheet | / |
Create. |
Timesheet |
| Project ratios | / |
Projects |
Timesheet |
| Leaves list / details | /, / |
Leaves., Leave |
Timesheet, Timesheet |
| Create / edit / complete leave | /, /, / |
Create |
Timesheet, Timesheet |
| Leave-balance create / import | /, / |
_Create, Import |
User |
| Attendance calendar | / |
Attendance |
Timesheet |
| SR / payroll exports | /, / |
(files) | Timesheet, Timesheet |
Business logic¶
| Class | File | Responsibility & notable logic |
|---|---|---|
BPayroll |
NKO. (~1070 ln) |
Generate(id) / Create — wipe existing Payroll, call Get, materialise one Payroll per employee, then Proc. Get computes per employee (contract overlapping the month, !Is): basic salary — one contract → its Amount; several → pro-rate Amount/ capping the remaining days, rounded to 4 dp. Rewards = Σ App; SocialInsurance = Σ App. Loan = Σ BAdvance.; Advance = Σ accepted advances signed in the month. Overtime = BTimesheet.. Unpaid = BLeave. (from IAttendances); Un where user. TotalDeductions = auto, auto. Workflow: Set, Set (gated by BTimesheet.), Set, Set. |
BAdvance |
NKO. (~2440 ln) |
Get — core only, past trial period: Adv; Loan = 0 if tenure < OR an unpaid loan detail exists OR the last loan repaid < ago, else contract. (1–2 yrs) or contract. (≥ 2 yrs). Can — rejects non-core / in-trial / already-pending; > ½ (net + allowance) ⇒ Accepted. Map — Div; monthly; the first instalment carries the remainder; one App per month. Cash boxes — Get / Get read Common keys Cash / Emergency; Add/ mutate them. Complete — for accepted unpaid loans: emergent & ≤ ordinary → one ordinary Cash; > ordinary → split ordinary + emergency; non-emergent → ordinary only. Set — tops the emergency box back to Cash first, remainder to ordinary. Long list of Set* approval methods. |
BOvertime |
NKO. (~1460 ln) |
Create — daily; per date factor = 1., bumped to 2 if the date is in a public-holiday range (BCalendar.); Daily; Amount += Daily. Complete derives factor from Attendance. (Weekend / PublicHoliday → 2). Reuses BAdvance's advance/loan helpers. |
BTimesheet |
NKO. (~760 ln) |
Create — Created = last day of the month; status Draft. Get → Overtime (Total) — consumed by BPayroll. Is — Σ App must equal Payroll (the allocator sign-off gate). Pay / Accept — the treasurer pays and the recipient confirms; Accept calls BAdvance.. Get is data-scoped (All / Location / Custom / Default). |
Data¶
- Run:
Payroll,PayrollInfo(BasicSalary,TotalDeductions,UnpaidLeaves,SocialInsurance,Rewards,Overtime,OvertimeHours,TransferredToBank,Advance,AdvanceIdsCSV,Loan). - Allocation:
AppUserAllocation(SalaryRatio,BenefitRatio,Month,Year,BudgetLineId,PayrollInfoId,SalaryAmountUSD/EURO/TL,ExchangeRateUSD/Euro). - Advances & cash:
AppUserAdvance,AppUserAdvanceDetails,CashBoxTransaction,Bank(ref). - Overtime:
AppUserOvertime,AppUserOvertimeDates,AppUserOvertimeConsumption. - Timesheet:
Timesheet,PartnersContributionMain,PartnersContribution. - Compensation inputs (HR-owned):
AppUserSalary,AppUserAllowance,AppUserDeduction,AppUserCharge,AppUserReward,AppUserBankPayment,AppUserInsurance,AppUserContract.
Full column detail: Payroll database.
Permissions¶
Distinct keys: PayrollIndex, PayrollDetails, PayrollCreate, PayrollTransferData,
PayrollExport; AdvanceIndex, AdvanceDetails, AdvanceCreate, AdvanceEdit,
AdvanceCashBoxTransaction; OvertimeIndex, OvertimeDetails, OvertimeCreate; TimesheetIndex,
TimesheetDetails, TimesheetCreate, TimesheetEdit, TimesheetEditInvoice, TimesheetLeaves,
TimesheetLeaveDetails, TimesheetCreateLeave, TimesheetEditLeave, TimesheetCreateMonth,
TimesheetProjectsRatio, TimesheetRatioDetails, TimesheetExportSR, TimesheetTransferData.
Cross-module keys reused: AllocationsIndex, GetUsers, UserIndex, ProjectCreate,
HumanResourceExportUsers. Data scoping: SharedPermissions.{Advances = 6, Overtime = 15,
Timesheet = 3, Leave = 2}.
PayrollStatus: Draft (0) · WaitingForAllocations (1) · WaitingForFinanceManager (2) ·
WaitingForCountryDirector (3) · Accepted (4) · Refused (5). Refused (5) is declared but never assigned — a refusal at any step sends the payroll back to
Draft.
Screenshots¶
Payroll runs and a run's approval timeline — /Payroll and /Payroll/Details/{id}:

Timesheets that feed a run — /Timesheet:

Advance / Loan requests — /Advance (filter panel and ALL REQUESTS tab; this view is scoped to
the signed-in user's own / approval-chain requests, so it is empty for an admin — see
Recommendations R7-12):

Loans Box — /Advance/CashBoxTransaction (the Ordinary and Emergency cash boxes with owed /
available balances, plus the transaction and queue lists):

Overtime requests — /Overtime (employee names masked):

Related¶
- Payroll workflow · Leave Management.
- HR module — contracts, compensation records, and the attendance monthly summary that feed the calculation.
- Grant module — budget lines, donor exchange rates, and
ProcBudgetLineHandler.Reallocate. - Payroll API · Payroll database.