dto.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Code generated by fkit v3.11.0. DO NOT EDIT.
  2. //
  3. // Source: schema/payroll
  4. // Regenerate with: go run ./tools/fkitgen ./schema/payroll
  5. package payroll
  6. import "time"
  7. // PayslipDTO is the generated wire representation of a payslip row.
  8. type PayslipDTO struct {
  9. ID string `json:"id"`
  10. CycleID string `json:"cycleId"`
  11. EmployeeID string `json:"employeeId"`
  12. Currency string `json:"currency"`
  13. PeriodFrom time.Time `json:"periodFrom"`
  14. PeriodTo time.Time `json:"periodTo"`
  15. GrossCents int64 `json:"grossCents"`
  16. DeductionCents int64 `json:"deductionCents"`
  17. NetCents int64 `json:"netCents"`
  18. }
  19. // PayrollCycleDTO is the generated wire representation of a payroll_cycle row.
  20. type PayrollCycleDTO struct {
  21. ID string `json:"id"`
  22. Start time.Time `json:"start"`
  23. End time.Time `json:"end"`
  24. Status string `json:"status"`
  25. }
  26. // PayslipListDTO is the generated list envelope for payslip rows.
  27. type PayslipListDTO struct {
  28. Items []PayslipDTO `json:"items"`
  29. NextCursor string `json:"nextCursor,omitempty"`
  30. Total int64 `json:"total"`
  31. }
  32. // PayslipToDTO converts a payslip row to its wire form.
  33. func PayslipToDTO(r PayslipRow) PayslipDTO {
  34. return PayslipDTO{
  35. ID: r.ID,
  36. CycleID: r.CycleID,
  37. EmployeeID: r.EmployeeID,
  38. Currency: r.Currency,
  39. PeriodFrom: r.PeriodFrom,
  40. PeriodTo: r.PeriodTo,
  41. GrossCents: r.GrossCents,
  42. DeductionCents: r.DeductionCents,
  43. NetCents: r.NetCents,
  44. }
  45. }
  46. // PayslipFromDTO converts a wire payslip back to a row.
  47. func PayslipFromDTO(d PayslipDTO) PayslipRow {
  48. return PayslipRow{
  49. ID: d.ID,
  50. CycleID: d.CycleID,
  51. EmployeeID: d.EmployeeID,
  52. Currency: d.Currency,
  53. PeriodFrom: d.PeriodFrom,
  54. PeriodTo: d.PeriodTo,
  55. GrossCents: d.GrossCents,
  56. DeductionCents: d.DeductionCents,
  57. NetCents: d.NetCents,
  58. }
  59. }
  60. // PayrollCycleToDTO converts a payroll_cycle row to its wire form.
  61. func PayrollCycleToDTO(r PayrollCycleRow) PayrollCycleDTO {
  62. return PayrollCycleDTO{ID: r.ID, Start: r.Start, End: r.End, Status: r.Status}
  63. }
  64. // PayslipsToListDTO wraps payslip rows in the generated list envelope.
  65. func PayslipsToListDTO(rows []PayslipRow, total int64) PayslipListDTO {
  66. items := make([]PayslipDTO, 0, len(rows))
  67. for _, r := range rows {
  68. items = append(items, PayslipToDTO(r))
  69. }
  70. return PayslipListDTO{Items: items, Total: total}
  71. }