Database — Core: Payroll¶
The monthly pay run and its inputs: salary and allowance history, advances and loans with their cash boxes, overtime, and timesheets.
Payroll reads from HR (AppUserContract, AppUserAllowance, AppUserDeduction) and from
Attendance, and writes allocations against Finance budget lines. See the
Payroll module and the Payroll flow.
17 entities in NKO_DB, context NKO_DBEntities1.
How to read this page
Generated from the EF Core model in NKO.Lib/NKO.DataAccess/DbModel/ — class names,
property types, nullability, data annotations and the relationships configured in
NKO_DBEntities1.OnModelCreating.
Each heading is the table name. Where the C# class is named differently — it is often
singular where the table is plural (StockDetail the class, StockDetails the table) — the
class name is stated under the heading. The file name is not authoritative:
StockDetails.cs declares public class StockDetail.
A ✓ in Null means the column is nullable: a nullable value type, or a reference type
with no [Required] — so a [Required] string is shown as not-null. Foreign keys are shown
where the fluent configuration or the <Entity>Id naming convention identifies a target.
Entities¶
AppUserAdvance¶
[Table("AppUserAdvance")] · DbSet AppUserAdvances · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/AppUserAdvance.cs
erDiagram
AppUserAdvance {
int Id PK
int CreatedBy FK
int ManagerId FK
int DeptId FK
int FinanceId FK
int HRId FK
int _1GuarantorId FK
int _2GuarantorId FK
int CountryId FK
int AccountingBranchId FK
int RefuseId FK
int CancelId FK
int NextUserId FK
}
AppUser {
int UserId PK
}
AppUserAdvanceDetails {
int Id PK
int AdvanceId FK
}
CashBoxTransaction {
int CashBoxTransactionsId PK
int AppUserAdvanceId FK
}
AppUser ||--o{ AppUserAdvance : "CreatedBy"
AppUser |o--o{ AppUserAdvance : "ManagerId, DeptId, FinanceId +8 more"
AppUserAdvance ||--o{ AppUserAdvanceDetails : "AdvanceId"
AppUserAdvance ||--o{ CashBoxTransaction : "AppUserAdvanceId"
| Column | Type | Null | Notes |
|---|---|---|---|
Id |
int |
PK | |
Advance |
Guid |
||
Amount |
decimal |
[Required] |
|
Fin |
decimal? |
✓ | |
Is |
bool |
[Required] |
|
Reason |
string |
✓ | |
Reason |
int? |
✓ | |
Description |
string |
✓ | |
Req |
bool |
||
Req |
string |
✓ | [String |
Req |
Date |
✓ | |
Manager |
int? |
✓ | FK → App |
Manager |
bool |
||
Manager |
string |
✓ | [String |
Manager |
Date |
✓ | |
Dept |
int? |
✓ | FK → App |
Dept |
bool |
||
Dept |
string |
✓ | [String |
Dept |
Date |
✓ | |
Finance |
int? |
✓ | FK → App |
Finance |
bool |
||
Finance |
Date |
✓ | |
Finance |
string |
✓ | [String |
Accounting |
int? |
✓ | FK → App |
Accounting |
bool |
||
Accounting |
string |
✓ | [String |
Accounting |
Date |
✓ | |
HRId |
int? |
✓ | FK → App |
HRSign |
bool |
||
HRSign |
Date |
✓ | |
HRNote |
string |
✓ | [String |
_1 |
int? |
✓ | FK → App |
_1 |
bool |
||
_1 |
Date |
✓ | |
_1 |
string |
✓ | [String |
_2 |
int? |
✓ | FK → App |
_2 |
bool |
||
_2 |
Date |
✓ | |
_2 |
string |
✓ | [String |
Country |
int? |
✓ | FK → App |
Country |
bool |
||
Country |
string |
✓ | [String |
Country |
Date |
✓ | |
Refuse |
int? |
✓ | FK → App |
Is |
bool |
||
Refuse |
Date |
✓ | |
Refuse |
string |
✓ | [String |
Cancel |
int? |
✓ | FK → App |
Is |
bool |
||
Cancel |
Date |
✓ | |
Cancel |
string |
✓ | [String |
Months |
int? |
✓ | |
Status |
int |
||
Is |
bool |
||
Is |
bool |
||
Is |
bool |
||
Department |
int? |
✓ | |
Branch |
int |
||
Sub |
int |
||
Created |
int |
FK → App |
|
Next |
int? |
✓ | FK → App |
Created |
Date |
Navigation: AppUserCreatedBy → AppUser, AppUserManager → AppUser, AppUserDept → AppUser, AppUserFinance → AppUser, AppUserHR → AppUser, AppUser_1Guarantor → AppUser, AppUser_2Guarantor → AppUser, AppUserCountry → AppUser, AppUserAccountingBranch → AppUser, AppUserRefuse → AppUser, AppUserCancel → AppUser, AppUserNext → AppUser, AppUserAdvanceDetails → List<AppUserAdvanceDetails>, CashBoxTransactions → ICollection<CashBoxTransaction>
AppUserAdvanceDetails¶
class AppUserAdvanceDetail · DbSet AppUserAdvanceDetails · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/AppUserAdvanceDetails.cs
erDiagram
AppUserAdvanceDetails {
int Id PK
int AdvanceId FK
}
AppUserAdvance {
int Id PK
}
AppUserAdvance ||--o{ AppUserAdvanceDetails : "AdvanceId"
| Column | Type | Null | Notes |
|---|---|---|---|
Id |
int |
PK | |
Advance |
int |
FK → App |
|
Month |
int |
||
Year |
int |
||
Amount |
decimal |
||
Is |
bool |
||
Paid |
Date |
✓ |
Navigation: AppUserAdvance → AppUserAdvance
AppUserAllocation¶
DbSet AppUserAllocations
NKO.Lib/NKO.DataAccess/DbModel/AppUserAllocation.cs
erDiagram
AppUserAllocation {
int Id PK
int UserId FK
int BudgetLineId FK
int PayrollInfoId FK
}
AppUser {
int UserId PK
}
BudgetLine {
int Id PK
}
PayrollInfo {
int PayrollInfoId PK
}
AppUser ||--o{ AppUserAllocation : "UserId"
BudgetLine ||--o{ AppUserAllocation : "BudgetLineId"
PayrollInfo ||--o{ AppUserAllocation : "PayrollInfoId"
| Column | Type | Null | Notes |
|---|---|---|---|
Id |
int |
PK | |
Salary |
decimal |
||
Benefit |
decimal |
||
Salary |
decimal |
||
Salary |
decimal |
||
Salary |
decimal |
||
Exchange |
decimal |
||
Exchange |
decimal |
||
Month |
int |
||
Year |
int |
||
Payroll |
int |
FK → Payroll |
|
Budget |
int |
FK → Budget |
|
User |
int |
FK → App |
Navigation: AppUser → AppUser, BudgetLine → BudgetLine, PayrollInfo → PayrollInfo
AppUserAllowance¶
[Table("AppUserAllowance")] · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/AppUserAllowance.cs
erDiagram
AppUserAllowance {
int AppUserAllowanceId PK
int UserId FK
}
AppUser {
int UserId PK
}
AppUser ||--o{ AppUserAllowance : "UserId"
| Column | Type | Null | Notes |
|---|---|---|---|
App |
int |
PK | |
Allowance |
Guid |
||
User |
int |
FK → App |
|
Start |
Date |
[Column(Type |
|
End |
Date |
✓ | [Column(Type |
Responsibility |
int |
||
Residence |
int |
||
Feeding |
int |
||
Transportation |
int |
||
Risk |
int |
||
Is |
bool |
||
Created |
int |
||
Created |
Date |
Navigation: AppUser → AppUser
AppUserBankPayment¶
[Table("AppUserBankPayment")] · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/AppUserBankPayment.cs
erDiagram
AppUserBankPayment {
int BankPaymentId PK
int UserId FK
}
AppUser {
int UserId PK
}
AppUser ||--o{ AppUserBankPayment : "UserId"
| Column | Type | Null | Notes |
|---|---|---|---|
Bank |
int |
PK | |
User |
int |
FK → App |
|
Payment |
decimal |
||
Payment |
decimal? |
✓ | |
Payment |
decimal? |
✓ | |
Month |
int |
||
Year |
int |
||
Reference |
string |
✓ | [String |
Created |
int |
||
Created |
Date |
Navigation: AppUser → AppUser
AppUserCharge¶
[Table("AppUserCharge")] · DbSet AppUserCharges · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/AppUserCharge.cs
erDiagram
AppUserCharge {
int Id PK
int PositionId FK
int UserId FK
}
AppUserPosition {
int PositionId PK
}
AppUser {
int UserId PK
}
AppUserPosition ||--o{ AppUserCharge : "PositionId"
AppUser ||--o{ AppUserCharge : "UserId"
| Column | Type | Null | Notes |
|---|---|---|---|
Id |
int |
PK | |
Description |
string |
✓ | |
Position |
int |
FK → App · [Required] |
|
User |
int |
FK → App · [Required] |
|
File |
string |
✓ | |
File |
string |
✓ |
Navigation: AppUserPosition → AppUserPosition, ApppUser → AppUser
AppUserDeduction¶
DbSet AppUserDeductions · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/AppUserDeduction.cs
erDiagram
AppUserDeduction {
int Id PK
int UserId FK
}
AppUser {
int UserId PK
}
AppUser ||--o{ AppUserDeduction : "UserId"
| Column | Type | Null | Notes |
|---|---|---|---|
Id |
int |
PK | |
Deduction |
Guid |
||
User |
int |
FK → App |
|
Amount |
double |
||
Currency |
int |
||
Year |
int |
||
Month |
int |
||
Description |
string |
✓ | [Column(Type |
File |
string |
✓ | |
File |
string |
✓ | |
Created |
int |
||
Created |
Date |
Navigation: AppUser → AppUser
AppUserOvertime¶
[Table("AppUserOvertime")] · DbSet AppUserOvertimes · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/AppUserOvertime.cs
erDiagram
direction LR
AppUserOvertime {
int OverTimeId PK
int CreatedBy FK
int EmployeeId FK
int ManagerId FK
int DeptId FK
int HRId FK
int GMId FK
int FinanceId FK
int RefusedBy FK
int CancelId FK
int NextUserId FK
int ContractId FK
}
AppUser {
int UserId PK
}
AppUserContract {
int ContractId PK
}
AppUserOvertimeDates {
int Id PK
int AppUserOvertimeId FK
}
AppUserOvertimeConsumption {
int Id PK
int AppUserOvertimeId FK
}
AppUser ||--o{ AppUserOvertime : "CreatedBy"
AppUser |o--o{ AppUserOvertime : "EmployeeId, ManagerId, DeptId +6 more"
AppUserContract ||--o{ AppUserOvertime : "ContractId"
AppUserOvertime ||--o{ AppUserOvertimeDates : "AppUserOvertimeId"
AppUserOvertime ||--o{ AppUserOvertimeConsumption : "AppUserOvertimeId"
| Column | Type | Null | Notes |
|---|---|---|---|
Over |
int |
PK | |
Over |
Guid? |
✓ | |
Start |
Date |
[Column(Type |
|
End |
Date |
[Column(Type |
|
Amount |
double |
||
Total |
int |
||
Tasks |
string |
[Required] · [Column(Type |
|
Description |
string |
[Required] · [Column(Type |
|
Req |
bool |
||
Req |
string |
✓ | [String |
Req |
Date |
✓ | |
Employee |
int? |
✓ | FK → App |
Employee |
bool |
||
Employee |
string |
✓ | [String |
Employee |
Date |
✓ | |
Manager |
int? |
✓ | FK → App |
Manager |
bool |
||
Manager |
string |
✓ | [String |
Manager |
Date |
✓ | |
Dept |
int? |
✓ | FK → App |
Dept |
bool |
||
Dept |
string |
✓ | [String |
Dept |
Date |
✓ | |
HRId |
int? |
✓ | FK → App |
HRSign |
bool |
||
HRNote |
string |
✓ | [String |
HRSign |
Date |
✓ | |
GMId |
int? |
✓ | FK → App |
GMSign |
bool |
||
GMNote |
string |
✓ | [String |
GMSign |
Date |
✓ | |
Finance |
int? |
✓ | FK → App |
Finance |
bool |
||
Finance |
string |
✓ | [String |
Finance |
Date |
✓ | |
Refused |
int? |
✓ | FK → App |
Refuse |
bool |
||
Refuse |
string |
✓ | [Column(Type |
Refuse |
Date |
✓ | |
Cancel |
int? |
✓ | FK → App |
Is |
bool |
||
Cancel |
Date |
✓ | |
Cancel |
string |
✓ | [String |
Manager |
bool? |
✓ | |
Manager |
string |
✓ | |
Department |
int |
||
Status |
int |
||
Contract |
int |
FK → App |
|
Branch |
int |
||
Sub |
int |
||
Type |
int |
||
Created |
int |
FK → App |
|
Next |
int? |
✓ | FK → App |
Created |
Date |
Navigation: AppUserReq → AppUser, AppUserEmployee → AppUser, AppUserManager → AppUser, AppUserDept → AppUser, AppUserHR → AppUser, AppUserGM → AppUser, AppUserFinance → AppUser, AppUserRefuse → AppUser, AppUserCancel → AppUser, AppUserNextUser → AppUser, AppUserContract → AppUserContract, AppUserOvertimeDates → ICollection<AppUserOvertimeDates>, AppUserOvertimeConsumptions → ICollection<AppUserOvertimeConsumption>
AppUserOvertimeConsumption¶
DbSet AppUserOvertimeConsumptions
NKO.Lib/NKO.DataAccess/DbModel/AppUserOvertimeConsumption.cs
erDiagram
AppUserOvertimeConsumption {
int Id PK
int LeaveId FK
int AppUserOvertimeId FK
}
Leave {
int LeaveId PK
}
AppUserOvertime {
int OverTimeId PK
}
Leave ||--o{ AppUserOvertimeConsumption : "LeaveId"
AppUserOvertime ||--o{ AppUserOvertimeConsumption : "AppUserOvertimeId"
| Column | Type | Null | Notes |
|---|---|---|---|
Id |
int |
PK | |
App |
int |
FK → App |
|
Leave |
int |
FK → Leave |
|
Amount |
double |
Navigation: Leave → Leave, AppUserOvertime → AppUserOvertime
AppUserOvertimeDates¶
class AppUserOvertimeDate · DbSet AppUserOvertimeDates
NKO.Lib/NKO.DataAccess/DbModel/AppUserOvertimeDates.cs
erDiagram
AppUserOvertimeDates {
int Id PK
int AppUserOvertimeId FK
}
AppUserOvertime {
int OverTimeId PK
}
AppUserOvertime ||--o{ AppUserOvertimeDates : "AppUserOvertimeId"
| Column | Type | Null | Notes |
|---|---|---|---|
Id |
int |
PK | |
App |
int |
FK → App |
|
Date |
Date |
||
Start |
string |
✓ | |
End |
string |
✓ | |
Daily |
double |
||
Is |
bool |
Navigation: AppUserOvertime → AppUserOvertime
AppUserReward¶
[Table("AppUserReward")] · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/AppUserReward.cs
erDiagram
AppUserReward {
int RewardId PK
int UserId FK
}
AppUser {
int UserId PK
}
AppUser ||--o{ AppUserReward : "UserId"
| Column | Type | Null | Notes |
|---|---|---|---|
Reward |
int |
PK | |
User |
int |
FK → App |
|
Amount |
double |
||
Year |
int |
||
Month |
int |
||
Description |
string |
✓ | [Column(Type |
Created |
int |
||
Created |
Date |
||
Currency |
int |
||
File |
string |
✓ | |
File |
string |
✓ |
Navigation: AppUser → AppUser
AppUserSalary¶
DbSet AppUserSalaries · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/AppUserSalary.cs
erDiagram
AppUserSalary {
int AppUserSalaryId PK
int UserId FK
}
AppUser {
int UserId PK
}
AppUser ||--o{ AppUserSalary : "UserId"
| Column | Type | Null | Notes |
|---|---|---|---|
App |
int |
PK | |
User |
int |
FK → App |
|
Amount |
decimal |
||
Start |
Date |
||
End |
Date |
||
Created |
int |
||
Created |
Date |
Navigation: AppUser → AppUser
Bank¶
DbSet Banks · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/Bank.cs
erDiagram
Bank {
int Id PK
}
AppUserExtend {
int UserId PK
int BankId FK
}
Bank |o--o{ AppUserExtend : "BankId"
| Column | Type | Null | Notes |
|---|---|---|---|
Id |
int |
PK | |
Name |
string |
✓ | |
Is |
bool |
Navigation: AppUserExtends → List<AppUserExtend>
CashBoxTransaction¶
DbSet CashBoxTransactions · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/CashBoxTransaction.cs
erDiagram
CashBoxTransaction {
int CashBoxTransactionsId PK
int AppUserAdvanceId FK
}
AppUserAdvance {
int Id PK
}
AppUserAdvance ||--o{ CashBoxTransaction : "AppUserAdvanceId"
| Column | Type | Null | Notes |
|---|---|---|---|
Cash |
int |
PK | |
Date |
Date |
||
App |
int |
FK → App |
|
Amount |
decimal |
||
Is |
bool |
||
Status |
int |
||
Is |
bool |
||
Created |
int |
||
Created |
Date |
Navigation: AppUserAdvance → AppUserAdvance
Payroll¶
[Table("Payroll")] · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/Payroll.cs
erDiagram
Payroll {
int PayrollId PK
int CreatedBy FK
int AllocatorId FK
int FManagerId FK
int CountryId FK
int NextUserId FK
int RefuseId FK
}
AppUser {
int UserId PK
}
PayrollInfo {
int PayrollInfoId PK
int PayrollId FK
}
AppUser ||--o{ Payroll : "CreatedBy"
AppUser |o--o{ Payroll : "AllocatorId, FManagerId, CountryId +2 more"
Payroll ||--o{ PayrollInfo : "PayrollId"
| Column | Type | Null | Notes |
|---|---|---|---|
Payroll |
int |
PK | |
Payroll |
Guid |
||
Year |
int |
||
Month |
int |
||
Req |
bool |
||
Req |
string |
✓ | |
Req |
Date |
✓ | |
Allocator |
int? |
✓ | FK → App |
Allocator |
bool |
||
Allocator |
Date |
✓ | |
Allocator |
string |
✓ | |
FManager |
int? |
✓ | FK → App |
FManager |
bool |
||
FManager |
string |
✓ | |
FManager |
Date |
✓ | |
Country |
int? |
✓ | FK → App |
Country |
bool |
||
Country |
string |
✓ | |
Country |
Date |
✓ | |
Refuse |
int? |
✓ | FK → App |
Is |
bool |
||
Refuse |
Date |
✓ | |
Refuse |
string |
✓ | |
Next |
int? |
✓ | FK → App |
Status |
int |
||
Exchange |
decimal |
||
Created |
Date |
||
Created |
int |
FK → App |
Navigation: AppUserCreatedBy → AppUser, AppUserAllocator → AppUser, AppUserFManager → AppUser, AppUserCountry → AppUser, AppUserNext → AppUser, AppUserRefuse → AppUser, PayrollInfo → ICollection<PayrollInfo>
PayrollInfo¶
[Table("PayrollInfo")] · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/PayrollInfo.cs
erDiagram
direction LR
PayrollInfo {
int PayrollInfoId PK
int UserId FK
int PositionId FK
int ProjectId FK
int BranchId FK
int SubBranchId FK
int DepartmentId FK
int PayrollId FK
}
AppUser {
int UserId PK
}
AppUserPosition {
int PositionId PK
}
Project {
int ProjectId PK
}
CommonBranch {
int BranchId PK
}
CommonSubBranch {
int SubBranchId PK
}
CommonDepartment {
int DepartmentId PK
}
Payroll {
int PayrollId PK
}
AppUserAllocation {
int Id PK
int PayrollInfoId FK
}
AppUser ||--o{ PayrollInfo : "UserId"
AppUserPosition |o--o{ PayrollInfo : "PositionId"
Project |o--o{ PayrollInfo : "ProjectId"
CommonBranch ||--o{ PayrollInfo : "BranchId"
CommonSubBranch |o--o{ PayrollInfo : "SubBranchId"
CommonDepartment |o--o{ PayrollInfo : "DepartmentId"
Payroll ||--o{ PayrollInfo : "PayrollId"
PayrollInfo ||--o{ AppUserAllocation : "PayrollInfoId"
| Column | Type | Null | Notes |
|---|---|---|---|
Payroll |
int |
PK | |
Payroll |
Guid |
||
Payroll |
int |
FK → Payroll |
|
User |
int |
FK → App |
|
Branch |
int |
FK → Common |
|
Sub |
int? |
✓ | FK → Common |
Department |
int? |
✓ | FK → Common |
Project |
int? |
✓ | FK → Project |
Is |
bool |
||
Position |
int? |
✓ | FK → App |
Basic |
decimal? |
✓ | |
Rewards |
decimal? |
✓ | |
Unpaid |
double? |
✓ | |
Total |
decimal? |
✓ | |
Overtime |
double? |
✓ | |
Overtime |
decimal? |
✓ | |
Transferred |
decimal? |
✓ | |
Advance |
decimal? |
✓ | |
Advance |
string |
✓ | |
Loan |
decimal? |
✓ | |
Social |
decimal? |
✓ | |
TLSalary |
decimal? |
✓ | |
Currency |
int |
||
Created |
Date |
||
Created |
int |
Navigation: AppUser → AppUser, AppUserPosition → AppUserPosition, Project → Project, CommonBranch → CommonBranch, CommonSubBranch → CommonSubBranch, CommonDepartment → CommonDepartment, Payroll → Payroll
Timesheet¶
[Table("Timesheet")] · inherits BaseEntity
NKO.Lib/NKO.DataAccess/DbModel/Timesheet.cs
erDiagram
Timesheet {
int TimesheetId PK
int CreatedBy FK
int ManagerId FK
int HRId FK
int PayerId FK
int CashReceivedById FK
int NextUserId FK
int BranchId FK
}
AppUser {
int UserId PK
}
CommonBranch {
int BranchId PK
}
AppUser ||--o{ Timesheet : "CreatedBy"
AppUser |o--o{ Timesheet : "ManagerId, HRId, PayerId +2 more"
CommonBranch ||--o{ Timesheet : "BranchId"
| Column | Type | Null | Notes |
|---|---|---|---|
Timesheet |
int |
PK | |
Timesheet |
Guid |
||
Req |
bool |
||
Req |
string |
✓ | [String |
Req |
Date |
✓ | |
Manager |
int? |
✓ | FK → App |
Manager |
bool |
||
Manager |
string |
✓ | [String |
Manager |
Date |
✓ | |
HRId |
int? |
✓ | FK → App |
HRSign |
bool |
||
HRNote |
string |
✓ | [String |
HRSign |
Date |
✓ | |
Payer |
int? |
✓ | FK → App |
Paid |
Date |
✓ | |
Payer |
string |
✓ | |
Is |
bool |
||
Cash |
int? |
✓ | FK → App |
Cash |
bool |
||
Cash |
Date |
✓ | |
Cash |
string |
✓ | [String |
Month |
int |
||
Year |
int |
||
Status |
int |
||
Pay |
int? |
✓ | |
Branch |
int |
FK → Common |
|
Deleted |
bool |
||
Created |
int |
FK → App |
|
Next |
int? |
✓ | FK → App |
Created |
Date |
Navigation: AppUserCreatedBy → AppUser, AppUserManager → AppUser, AppUserHR → AppUser, AppUserPayer → AppUser, AppUserCash → AppUser, AppUserNextUser → AppUser, CommonBranch → CommonBranch