@rangka-os/create 0.5.0-alpha.32 → 0.5.0-alpha.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/absen_karyawan/app.rk +1 -1
  3. package/template/base/apps/absen_karyawan/dashboards/absen_karyawan_saya.rk +2 -2
  4. package/template/base/apps/absen_karyawan/dashboards/jadwal_saya.rk +4 -4
  5. package/template/base/apps/grosir_distribusi/app.rk +1 -1
  6. package/template/base/apps/karyawan_gaji/app.rk +6 -2
  7. package/template/base/apps/karyawan_gaji/dashboards/klaim_kasbon_saya.rk +3 -3
  8. package/template/base/apps/karyawan_gaji/dashboards/saya.rk +20 -0
  9. package/template/base/apps/karyawan_gaji/skills/rangka-app-karyawan-gaji/SKILL.md +3 -0
  10. package/template/base/apps/kasir/skills/rangka-app-kasir/SKILL.md +1 -1
  11. package/template/base/apps/pesanan_whatsapp/app.rk +28 -0
  12. package/template/base/apps/produksi_pabrik/app.rk +1 -1
  13. package/template/base/apps/ritel_cabang/app.rk +1 -1
  14. package/template/base/apps/ritel_cabang/dashboards/ritel_overview.rk +16 -0
  15. package/template/base/apps/ritel_cabang/dashboards/ritel_stock.rk +13 -0
  16. package/template/base/apps/sewa_alat/skills/rangka-app-sewa-alat/SKILL.md +3 -3
  17. package/template/base/connectors/rangka_whatsapp/README.md +3 -2
  18. package/template/base/connectors/rangka_whatsapp/connector.rk +12 -4
  19. package/template/base/connectors/rangka_whatsapp/fixtures/expect.json +3 -2
  20. package/template/base/connectors/rangka_whatsapp/fixtures/message_received.json +1 -1
  21. package/template/base/connectors/rangka_whatsapp/fixtures/message_received_order.json +1 -0
  22. package/template/base/connectors/rangka_whatsapp/mock/rangka_whatsapp_mock.py +9 -4
  23. package/template/base/modules/attendance/models/attendance_summary.rk +2 -4
  24. package/template/base/modules/attendance/models/staff_attendance.rk +3 -0
  25. package/template/base/modules/attendance/module.rk +1 -1
  26. package/template/base/modules/catalogue/defaults/uom.rk +19 -0
  27. package/template/base/modules/catalogue/models/item.rk +36 -0
  28. package/template/base/modules/catalogue/module.rk +1 -1
  29. package/template/base/modules/delivery/models/delivery_note.rk +3 -1
  30. package/template/base/modules/delivery/models/delivery_note_item.rk +4 -0
  31. package/template/base/modules/delivery/models/sales_return.rk +2 -2
  32. package/template/base/modules/delivery/models/sales_return_item.rk +3 -0
  33. package/template/base/modules/delivery/module.rk +2 -2
  34. package/template/base/modules/outlet_sales/models/outlet_sales_line.rk +1 -0
  35. package/template/base/modules/outlets/models/outlet.rk +9 -0
  36. package/template/base/modules/outlets/module.rk +1 -1
  37. package/template/base/modules/payroll/models/cash_advance.rk +2 -0
  38. package/template/base/modules/payroll/models/cash_advance_balance.rk +2 -4
  39. package/template/base/modules/payroll/models/payroll_run.rk +1 -0
  40. package/template/base/modules/payroll/models/payslip.rk +43 -12
  41. package/template/base/modules/payroll/module.rk +1 -1
  42. package/template/base/modules/payroll/print/payslip.html +4 -4
  43. package/template/base/modules/pos/models/pos_sale_item.rk +1 -0
  44. package/template/base/modules/pos/screens/kasir.rk +1 -0
  45. package/template/base/modules/procurement/models/goods_receipt_item.rk +21 -0
  46. package/template/base/modules/procurement/module.rk +2 -2
  47. package/template/base/modules/production/models/production_batch.rk +10 -5
  48. package/template/base/modules/production/models/production_material.rk +3 -0
  49. package/template/base/modules/production/models/production_output.rk +12 -0
  50. package/template/base/modules/production/module.rk +2 -2
  51. package/template/base/modules/reimbursement/models/claim_settlement.rk +1 -0
  52. package/template/base/modules/reimbursement/models/expense_claim.rk +4 -1
  53. package/template/base/modules/reimbursement/module.rk +1 -1
  54. package/template/base/modules/shifts/models/shift_assignment.rk +2 -3
  55. package/template/base/modules/shifts/models/shift_swap.rk +2 -0
  56. package/template/base/modules/shifts/module.rk +1 -1
  57. package/template/base/modules/stock/flows/item_tracking_lock.rk +37 -0
  58. package/template/base/modules/stock/flows/lot_expiry_digest.rk +103 -0
  59. package/template/base/modules/stock/flows/stock_balance_variant_group.rk +26 -0
  60. package/template/base/modules/stock/models/serial_no.rk +55 -0
  61. package/template/base/modules/stock/models/stock_adjustment_item.rk +4 -0
  62. package/template/base/modules/stock/models/stock_balance.rk +1 -0
  63. package/template/base/modules/stock/models/stock_expiry.rk +47 -0
  64. package/template/base/modules/stock/models/stock_guard.rk +40 -0
  65. package/template/base/modules/stock/models/stock_lot.rk +38 -0
  66. package/template/base/modules/stock/models/stock_lot_balance.rk +30 -0
  67. package/template/base/modules/stock/models/stock_move.rk +7 -2
  68. package/template/base/modules/stock/models/stock_transfer_item.rk +4 -0
  69. package/template/base/modules/stock/models/stock_transfer_receipt_item.rk +3 -0
  70. package/template/base/modules/stock/module.rk +9 -2
  71. package/template/base/modules/whatsapp/models/whatsapp_message.rk +2 -0
  72. package/template/base/modules/whatsapp/module.rk +2 -2
  73. package/template/base/modules/whatsapp_order/README.md +44 -0
  74. package/template/base/modules/whatsapp_order/flows/whatsapp_order_intake.rk +118 -0
  75. package/template/base/modules/whatsapp_order/flows/whatsapp_order_locked.rk +12 -0
  76. package/template/base/modules/whatsapp_order/flows/whatsapp_order_on_update.rk +124 -0
  77. package/template/base/modules/whatsapp_order/models/whatsapp_inbound.rk +62 -0
  78. package/template/base/modules/whatsapp_order/models/whatsapp_order.rk +164 -0
  79. package/template/base/modules/whatsapp_order/models/whatsapp_order_guard.rk +46 -0
  80. package/template/base/modules/whatsapp_order/models/whatsapp_order_line.rk +45 -0
  81. package/template/base/modules/whatsapp_order/module.rk +42 -0
  82. package/template/base/modules/whatsapp_order/screens/pesanan_wa.rk +22 -0
@@ -36,6 +36,8 @@ permissions:
36
36
  - {role: outlet_staff, create: true, write: true, delete: true, if: "requested_by == user.name && worker == ''"}
37
37
  - {role: outlet_supervisor, read: true, if: "requested_by == user.name || employee == user.name"}
38
38
  - {role: outlet_supervisor, create: true, write: true, delete: true, if: "requested_by == user.name && worker == ''"}
39
+ # Every employee whatever their role reads their own kasbon (member grant, rangka-os contract 0074).
40
+ - {role: member, read: true, if: "requested_by == user.name || employee == user.name"}
39
41
  fields:
40
42
  # Empty on a staff request (staff do not read the worker list): finance picks it before submitting (rule
41
43
  # worker_on_submit), and on a request it must be the requester's own worker record (rule request_own_worker).
@@ -15,10 +15,8 @@ permissions:
15
15
  - {role: head_office, read: true, export: true}
16
16
  # the recap flow of a client run reads it when it drafts a slip (payslip_from_recap runs as the project admin)
17
17
  - {role: project_admin, read: true}
18
- - {role: employee, read: true, if: "employee == user.name"}
19
- - {role: cashier, read: true, if: "employee == user.name"}
20
- - {role: outlet_staff, read: true, if: "employee == user.name"}
21
- - {role: outlet_supervisor, read: true, if: "employee == user.name"}
18
+ # what is left of their own kasbon: every employee whatever their role (member grant, rangka-os contract 0074)
19
+ - {role: member, read: true, if: "employee == user.name"}
22
20
  fields:
23
21
  - name: cash_advance
24
22
  type: link
@@ -61,6 +61,7 @@ fields:
61
61
  # The tax month is the month the pay is paid (masa pajak), not the cut-off period.
62
62
  - name: tax_year
63
63
  type: int
64
+ grouping: false
64
65
  label: {id: Tahun pajak}
65
66
  required: true
66
67
  - name: tax_month
@@ -15,14 +15,22 @@ permissions:
15
15
  - {role: finance_manager, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
16
16
  # Recaps are submitted by the project admin; their flow makes the draft slip as that person (no submit).
17
17
  - {role: project_admin, read: true, create: true}
18
+ # Every employee reads and prints their own slip from the phone, whatever their role (member grant, rangka-os contract
19
+ # 0074; rangka-os#261), once it is released: submitted, and its run closed or its pay date reached. A draft or a
20
+ # submitted slip before pay day stays with finance, so a figure still being checked is never shown. The run, profile
21
+ # and tax working fields are hidden_for every role but finance_manager and project_admin, so the employee sees
22
+ # period, pay, deductions, net pay and bank; the print reads only fields left visible.
23
+ - {role: member, read: true, print: true, if: "employee == user.name && docstatus == 1 && (payroll_run.closed || (payroll_run.pay_date != '' && payroll_run.pay_date <= today()))"}
18
24
  fields:
19
25
  - name: payroll_run
26
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
20
27
  type: link
21
28
  to: payroll_run
22
29
  label: {id: Periode gaji}
23
30
  required: true
24
31
  in_list: true
25
32
  - name: profile
33
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
26
34
  type: link
27
35
  to: payroll_profile
28
36
  label: {id: Data gaji pekerja}
@@ -49,12 +57,23 @@ fields:
49
57
  to: user
50
58
  label: {id: Karyawan, en: Employee}
51
59
  compute: profile.worker.employee
60
+ # Who the slip is for and where it is paid, copied from the worker and the profile so the printed slip (print payslip)
61
+ # needs no read of them: an employee reading their own slip (member grant) does not read the worker record, which
62
+ # holds the cost rates. A slip submitted before payroll 2.3.0 keeps these empty (the kernel does not backfill a
63
+ # computed link read on a submitted document): the print falls back to the linked worker and profile, which finance
64
+ # reads; the employee's own print of such an old slip shows no name or account line (audit 261a F1).
65
+ - {name: slip_worker_name, type: data, label: {id: Nama pekerja, en: Worker name}, hidden: true, compute: profile.worker.worker_name}
66
+ - {name: slip_employee_no, type: data, label: {id: No. pegawai, en: Employee number}, hidden: true, compute: profile.worker.employee_no}
67
+ - {name: slip_role_title, type: data, label: {id: Jabatan, en: Job title}, hidden: true, compute: profile.worker.role_title}
68
+ - {name: slip_bank_name, type: data, label: {id: Bank, en: Bank}, hidden: true, compute: profile.bank_name}
69
+ - {name: slip_bank_account, type: data, label: {id: Nomor rekening, en: Account number}, hidden: true, compute: profile.bank_account}
52
70
  - name: project
53
71
  type: link
54
72
  to: project
55
73
  label: {id: Proyek}
56
74
  compute: payroll_run.project
57
75
  - name: timesheet
76
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
58
77
  type: link
59
78
  to: timesheet
60
79
  label: {id: Rekap absensi}
@@ -62,6 +81,7 @@ fields:
62
81
  # The staff attendance summary (module attendance) the slip was filled from by payroll_run_fill or
63
82
  # payslip_from_attendance: the last one of the run's period when there were several. Empty for a slip typed by hand.
64
83
  - name: attendance_summary
84
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
65
85
  type: link
66
86
  to: attendance_summary
67
87
  label: {id: Rekap absen karyawan, en: Staff attendance summary}
@@ -76,10 +96,11 @@ fields:
76
96
  - {name: att_days, type: float, label: {id: Hari hadir menurut rekap}, default: '0', read_only: true, hidden: true}
77
97
  - {name: att_late, type: int, label: {id: Menit telat menurut rekap}, default: '0', read_only: true, hidden: true}
78
98
  - {name: att_ot, type: float, label: {id: Jam lembur menurut rekap}, default: '0', read_only: true, hidden: true}
79
- - {name: tax_year, type: int, label: {id: Tahun pajak}, default: payroll_run.tax_year}
99
+ - {name: tax_year, type: int, grouping: false, label: {id: Tahun pajak}, default: payroll_run.tax_year}
80
100
  - {name: tax_month, type: int, label: {id: Bulan pajak}, default: payroll_run.tax_month}
81
101
  # December, or the month the worker leaves: PPh 21 is recomputed for the year (Pasal 17).
82
102
  - name: last_month
103
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
83
104
  type: check
84
105
  label: {id: Masa pajak terakhir (Desember atau keluar)}
85
106
  default: payroll_run.tax_month == 12
@@ -92,6 +113,7 @@ fields:
92
113
  - {value: daily, label: {id: Harian}}
93
114
  - {value: monthly, label: {id: Bulanan}}
94
115
  - name: employment
116
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
95
117
  type: select
96
118
  label: {id: Status pegawai (PPh 21)}
97
119
  default: profile.employment
@@ -134,7 +156,7 @@ fields:
134
156
  # A kasbon of this worker not yet repaid in full by the submitted slips linking it, found when the slip is made
135
157
  # (payslip_ytd_on_create, payslip_from_recap). A deduction without a link while one is open is warned at submit
136
158
  # (audit gelombang 3 r2 R1): linked, the kasbon cannot be cancelled after its repayment.
137
- - {name: open_advance, type: link, to: cash_advance, label: {id: Kasbon belum lunas}, read_only: true}
159
+ - {name: open_advance, type: link, to: cash_advance, label: {id: Kasbon belum lunas}, read_only: true, hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]}
138
160
  # The slip-making flows (payslip_from_recap, payslip_from_attendance and the fills, payslip_ytd_on_create) put the
139
161
  # open kasbon's monthly installment here: cash_advance = that kasbon, other_deduction = min(installment, what is left
140
162
  # after the submitted slips), when the kasbon has an installment (rangka-apps#117). Editable while the slip is a draft.
@@ -146,6 +168,7 @@ fields:
146
168
  # which are then marked paid by this slip; a cancel releases them.
147
169
  - {name: reimbursement, type: currency, label: {id: Penggantian biaya (tidak kena pajak), en: Expense reimbursement (untaxed)}, default: '0'}
148
170
  - name: ptkp_status
171
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
149
172
  type: select
150
173
  label: {id: Status PTKP}
151
174
  default: profile.ptkp_status
@@ -158,17 +181,17 @@ fields:
158
181
  - {value: k1, label: {id: K/1}}
159
182
  - {value: k2, label: {id: K/2}}
160
183
  - {value: k3, label: {id: K/3}}
161
- - {name: has_tax_id, type: check, label: {id: Punya NIK/NPWP valid}, default: profile.has_tax_id}
162
- - {name: bpjs_tk, type: check, label: {id: BPJS Ketenagakerjaan}, default: profile.bpjs_tk}
163
- - {name: bpjs_jp, type: check, label: {id: Jaminan Pensiun}, default: profile.bpjs_jp}
164
- - {name: bpjs_kes, type: check, label: {id: BPJS Kesehatan}, default: profile.bpjs_kes}
184
+ - {name: has_tax_id, type: check, label: {id: Punya NIK/NPWP valid}, default: profile.has_tax_id, hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]}
185
+ - {name: bpjs_tk, type: check, label: {id: BPJS Ketenagakerjaan}, default: profile.bpjs_tk, hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]}
186
+ - {name: bpjs_jp, type: check, label: {id: Jaminan Pensiun}, default: profile.bpjs_jp, hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]}
187
+ - {name: bpjs_kes, type: check, label: {id: BPJS Kesehatan}, default: profile.bpjs_kes, hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]}
165
188
  # The recap's own labour cost, already on the project ledger (project_labor_on_submit): the run books only the rest.
166
- - {name: timesheet_cost, type: currency, label: {id: Biaya sudah dibukukan absensi}, compute: "timesheet != '' ? timesheet.cost_amount : 0"}
189
+ - {name: timesheet_cost, type: currency, label: {id: Biaya sudah dibukukan absensi}, compute: "timesheet != '' ? timesheet.cost_amount : 0", hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]}
167
190
  # Year to date (earlier submitted slips of this worker and tax year), filled by payslip_ytd_on_create.
168
- - {name: ytd_gross, type: currency, label: {id: Bruto sebelumnya tahun ini}, default: '0', read_only: true}
169
- - {name: ytd_pph21, type: currency, label: {id: PPh 21 sebelumnya tahun ini}, default: '0', read_only: true}
170
- - {name: ytd_pension, type: currency, label: {id: JHT + JP pekerja sebelumnya}, default: '0', read_only: true}
171
- - {name: ytd_months, type: int, label: {id: Bulan sebelumnya tahun ini}, default: '0', read_only: true}
191
+ - {name: ytd_gross, type: currency, label: {id: Bruto sebelumnya tahun ini}, default: '0', read_only: true, hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]}
192
+ - {name: ytd_pph21, type: currency, label: {id: PPh 21 sebelumnya tahun ini}, default: '0', read_only: true, hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]}
193
+ - {name: ytd_pension, type: currency, label: {id: JHT + JP pekerja sebelumnya}, default: '0', read_only: true, hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]}
194
+ - {name: ytd_months, type: int, label: {id: Bulan sebelumnya tahun ini}, default: '0', read_only: true, hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]}
172
195
  # Pay.
173
196
  - name: unpaid_deduction
174
197
  type: currency
@@ -218,6 +241,7 @@ fields:
218
241
  label: {id: Dasar upah BPJS}
219
242
  compute: "(pay_basis == 'monthly' ? monthly_salary : base_pay) + fixed_allowance > payroll_run.umk ? (pay_basis == 'monthly' ? monthly_salary : base_pay) + fixed_allowance : payroll_run.umk"
220
243
  - name: below_umk
244
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
221
245
  type: check
222
246
  label: {id: Upah di bawah UMK}
223
247
  compute: "(pay_basis == 'monthly' ? monthly_salary : day_rate * (payroll_run.workdays_per_week == 5 ? 21 : 25)) < payroll_run.umk"
@@ -241,6 +265,7 @@ fields:
241
265
  # TER in basis points of a percent (25 = 0,25%): the PP 58/2023 tables as [upper bound, step to the next rate], summed
242
266
  # over the bounds the gross is above. Replace the three lists when the table changes.
243
267
  - name: ter_bp
268
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
244
269
  type: int
245
270
  label: {id: TER (per sepuluh ribu)}
246
271
  compute: >-
@@ -282,27 +307,32 @@ fields:
282
307
  + (gross_taxable * 0.5 > 5000000000 ? gross_taxable * 0.5 - 5000000000 : 0) * 35) * (has_tax_id ? 100 : 120) / 10000.0 - 0.5))
283
308
  # Annual recomputation (last_month).
284
309
  - name: ptkp
310
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
285
311
  type: currency
286
312
  label: {id: PTKP setahun}
287
313
  compute: "54000000 + (ptkp_status.startsWith('k') ? 4500000 : 0) + (ptkp_status.endsWith('1') ? 4500000 : (ptkp_status.endsWith('2') ? 9000000 : (ptkp_status.endsWith('3') ? 13500000 : 0)))"
288
- - {name: year_gross, type: currency, label: {id: Bruto setahun}, compute: ytd_gross + gross_taxable}
314
+ - {name: year_gross, type: currency, label: {id: Bruto setahun}, compute: ytd_gross + gross_taxable, hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]}
289
315
  # Biaya jabatan 5%, at most 500.000 per month worked (6.000.000 a year).
290
316
  - name: job_cost
317
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
291
318
  type: currency
292
319
  label: {id: Biaya jabatan setahun}
293
320
  compute: "round(year_gross * 5 / 100.0 - 0.5) < 500000 * (ytd_months + 1) ? round(year_gross * 5 / 100.0 - 0.5) : 500000 * (ytd_months + 1)"
294
321
  - name: year_net
322
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
295
323
  type: currency
296
324
  label: {id: Neto setahun}
297
325
  compute: year_gross - job_cost - ytd_pension - jht_employee - jp_employee
298
326
  # Rounded down to thousands.
299
327
  - name: year_pkp
328
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
300
329
  type: currency
301
330
  label: {id: PKP setahun}
302
331
  compute: "year_net > ptkp ? round((year_net - ptkp) / 1000.0 - 0.5) * 1000 : 0"
303
332
  # Pasal 17 layers 5/15/25/30/35% on PKP (a multiple of 1.000, so every layer is whole rupiah), x 120% without a tax
304
333
  # number, truncated to the rupiah.
305
334
  - name: year_pph21
335
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
306
336
  type: currency
307
337
  label: {id: PPh 21 setahun (Pasal 17)}
308
338
  compute: >-
@@ -338,6 +368,7 @@ fields:
338
368
  compute: cash_gross - employee_bpjs - pph21 - other_deduction + reimbursement
339
369
  in_list: true
340
370
  - name: employer_cost
371
+ hidden_for: [cashier, collector, course_admin, employee, field_sales, field_worker, head_office, instructor, kitchen, outlet_staff, outlet_supervisor, purchasing_manager, rental_staff, sales_manager, sales_rep, service_staff, site_supervisor, warehouse_staff]
341
372
  type: currency
342
373
  label: {id: Biaya perusahaan}
343
374
  compute: cash_gross + employer_bpjs
@@ -1,6 +1,6 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
2
  name: payroll
3
- version: 2.2.0
3
+ version: 2.3.0
4
4
  title: {id: Penggajian, en: Payroll}
5
5
  summary:
6
6
  id: Data gaji pekerja, periode gaji, slip gaji dan tutup periode.
@@ -14,9 +14,9 @@
14
14
  {{template "letterhead" .}}
15
15
  <h1>Slip gaji</h1>
16
16
  <table class="meta">
17
- <tr><td>Nama</td><td>: {{.Links.worker.worker_name}}</td><td>No. slip</td><td>: {{.Doc.name}}</td></tr>
18
- <tr><td>No. pegawai</td><td>: {{.Links.worker.employee_no}}</td><td>Masa pajak</td><td>: {{.Doc.tax_month}}/{{.Doc.tax_year}}</td></tr>
19
- <tr><td>Jabatan</td><td>: {{.Links.worker.role_title}}</td><td>Periode</td><td>: {{date .Links.payroll_run.period_from}} s.d. {{date .Links.payroll_run.period_to}}</td></tr>
17
+ <tr><td>Nama</td><td>: {{or .Doc.slip_worker_name .Links.worker.worker_name}}</td><td>No. slip</td><td>: {{.Doc.name}}</td></tr>
18
+ <tr><td>No. pegawai</td><td>: {{or .Doc.slip_employee_no .Links.worker.employee_no}}</td><td>Masa pajak</td><td>: {{.Doc.tax_month}}/{{.Doc.tax_year}}</td></tr>
19
+ <tr><td>Jabatan</td><td>: {{or .Doc.slip_role_title .Links.worker.role_title}}</td><td>Periode</td><td>: {{date .Doc.run_period_from}} s.d. {{date .Doc.run_period_to}}</td></tr>
20
20
  <tr><td>Hari hadir</td><td>: {{.Doc.days}}</td><td>Lembur</td><td>: {{.Doc.overtime_hours}} jam</td></tr>
21
21
  </table>
22
22
  <div class="cols">
@@ -55,4 +55,4 @@
55
55
  <div class="net"><span>Gaji bersih diterima</span><span>{{rupiah .Doc.net_pay}}</span></div>
56
56
  <p class="note">Ditanggung perusahaan, tidak dipotong dari gaji: JKK {{rupiah .Doc.jkk}}, JKM {{rupiah .Doc.jkm}}, JHT 3,7% {{rupiah .Doc.jht_employer}}, JP 2% {{rupiah .Doc.jp_employer}}, BPJS Kesehatan 4% {{rupiah .Doc.kes_employer}}.
57
57
  Dasar upah BPJS {{rupiah .Doc.bpjs_base}}. {{if .Doc.ter_daily}}PPh 21 TER harian, bruto sehari {{rupiah .Doc.daily_gross}}{{else}}PPh 21 kategori TER {{.Doc.ter_category}}{{end}}, bruto {{rupiah .Doc.gross_taxable}}.</p>
58
- {{if .Links.profile.bank_account}}<p class="note">Ditransfer ke {{.Links.profile.bank_name}} {{.Links.profile.bank_account}}.</p>{{end}}
58
+ {{with or .Doc.slip_bank_account .Links.profile.bank_account}}<p class="note">Ditransfer ke {{or $.Doc.slip_bank_name $.Links.profile.bank_name}} {{.}}.</p>{{end}}
@@ -10,6 +10,7 @@ fields:
10
10
  # the item's category when the line was saved: the kitchen routes a paid line by it (module kitchen) without reading
11
11
  # the whole catalogue during the payment
12
12
  - {name: category, type: link, to: item_category, label: {id: Kategori}, hidden: true, compute: item.category}
13
+ - {name: variant_group, type: data, label: {id: Grup varian}, hidden: true, compute: item.variant_group}
13
14
  - {name: description, type: text, label: {id: Uraian}, default: item.item_name}
14
15
  - name: packing
15
16
  type: link
@@ -19,6 +19,7 @@ counter:
19
19
  group_by: category
20
20
  price: rate
21
21
  barcode: barcode
22
+ variants: {group: variant_group, label: variant_label, title: variant_title}
22
23
  available: {model: stock_balance, item: item, qty: qty, match: {outlet: outlet}}
23
24
  document:
24
25
  model: pos_sale
@@ -40,3 +40,24 @@ fields:
40
40
  type: currency
41
41
  label: {id: Biaya per satuan stok}
42
42
  compute: "stock_qty > 0 ? round(amount / stock_qty) : 0"
43
+ # rangka-os contract 0070 §7 (goods_receipt stays on the kernel's Go rule, which reads these line fields): the lot
44
+ # number and dates printed on the pack, and for a serial item one serial per line. Empty lot number on a lot item puts
45
+ # the quantity in the no-lot bucket; a lot item with expiry needs it (409 lot_required at submit).
46
+ - name: lot_no
47
+ type: data
48
+ label: {id: Nomor lot / batch}
49
+ depends_on: "item.tracking in ['lot', 'lot_expiry']"
50
+ - name: expiry_date
51
+ type: date
52
+ label: {id: Kedaluwarsa}
53
+ help: {id: 'Wajib untuk lot baru. Lot yang sudah tercatat memakai tanggalnya sendiri'}
54
+ depends_on: "item.tracking == 'lot_expiry'"
55
+ - name: made_date
56
+ type: date
57
+ label: {id: Tanggal produksi}
58
+ depends_on: "item.tracking in ['lot', 'lot_expiry']"
59
+ - name: serial_nos
60
+ type: text
61
+ label: {id: Nomor seri}
62
+ help: {id: 'Satu nomor seri per baris; jumlahnya sama dengan qty'}
63
+ depends_on: "item.tracking == 'serial'"
@@ -1,13 +1,13 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
2
  name: procurement
3
- version: 1.4.0
3
+ version: 1.5.0
4
4
  title: {id: Pembelian, en: Procurement}
5
5
  summary:
6
6
  id: Permintaan dan pesanan pembelian, barang datang dan tagihan pemasok.
7
7
  en: Purchase requests and orders, goods received and supplier bills.
8
8
  category: purchasing
9
9
  icon: shopping-bag-line
10
- requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0}
10
+ requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.6}
11
11
  optional: {outlets: ^1.0, currency: ^1.0, stock: ^1.4, projects: ^1.0, fixed_assets: ^1.0}
12
12
  # Semantics fixed in docs/kernel-hooks.md (section procurement). stock.post_moves is a core hook (goods_receipt.on_submit);
13
13
  # stock.reverse_moves (goods_receipt.on_cancel) is declared here too, since stock is optional for procurement (a no-op without it).
@@ -1,6 +1,6 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
- # Hasil produksi per batch. The batch number is the production code printed on the pack; the expiry date follows the
3
- # product's shelf life. Submit takes the materials out of the production outlet at their moving average and puts
2
+ # Hasil produksi per batch. The production code printed on the pack is the lot of the outputs (contract 0070); the
3
+ # expiry date follows the product's shelf life. Submit takes the materials out of the production outlet at their moving average and puts
4
4
  # the outputs into the finished-goods outlet at the value of those materials, split by cost_share (contract 0021,
5
5
  # K-o). The actual cost (HPP) of the batch adds the piece-rate wages and the overhead rate to the material cost; the
6
6
  # stock value holds the material cost only until K-r. Cancel reverses the stock (stock.reverse_moves).
@@ -22,6 +22,9 @@ fields:
22
22
  - {name: outlet, type: link, to: outlet, label: {id: Tempat produksi (bahan keluar)}, default: work_order.outlet, required: true}
23
23
  - {name: output_outlet, type: link, to: outlet, label: {id: Gudang barang jadi}, required: true}
24
24
  - {name: production_date, type: date, label: {id: Tanggal produksi}, default: today(), required: true, in_list: true}
25
+ # rangka-os#260: the lot number of what this batch makes (contract 0070); empty = the production date, so batches of one
26
+ # item made on one day share a lot
27
+ - {name: production_code, type: data, label: {id: Kode produksi (lot)}, help: {id: 'Kode yang dicetak di kemasan. Kosongkan: tanggal produksi jadi nomor lotnya'}, in_list: true}
25
28
  - {name: shelf_life_days, type: int, label: {id: Umur simpan (hari)}, default: item.shelf_life_days}
26
29
  - name: expiry_date
27
30
  type: date
@@ -59,8 +62,10 @@ fields:
59
62
  stock:
60
63
  date: production_date
61
64
  moves:
62
- - {lines: materials, out: outlet, reason: production_out, cogs: cogs}
63
- - {lines: outputs, in: output_outlet, reason: production_in, cost: {consumed: true, split: cost_share}}
65
+ # rangka-os contract 0070: materials leave from the picked lot, else earliest expiry first (expired lots skipped);
66
+ # outputs come in as the lot of the batch's production code (else its production date), with the batch's expiry
67
+ - {lines: materials, out: outlet, reason: production_out, cogs: cogs, lot: {pick: lot}, serials: serial_nos}
68
+ - {lines: outputs, in: output_outlet, reason: production_in, cost: {consumed: true, split: cost_share}, lot: {no: lot_no, expiry: expiry_date, made: made_date}, serials: serial_nos}
64
69
  cogs_total: material_cost
65
70
  # Deviations from the plan wait for head office: materials that are not in the BOM, or more good output than 110% of
66
71
  # the planned qty (a batch puts stock in at the value of what it took out, so an inflated output dilutes the cost).
@@ -138,7 +143,7 @@ views:
138
143
  - section: {id: Batch}
139
144
  columns:
140
145
  - [work_order, item, bom, planned_qty]
141
- - [production_date, shelf_life_days, expiry_date, outlet, output_outlet]
146
+ - [production_date, production_code, shelf_life_days, expiry_date, outlet, output_outlet]
142
147
  - section: {id: Bahan terpakai}
143
148
  fields: [materials]
144
149
  - section: {id: Hasil}
@@ -6,3 +6,6 @@ fields:
6
6
  - {name: qty, type: float, label: {id: Qty terpakai}}
7
7
  - {name: uom, type: link, to: uom, label: {id: Satuan}, default: item.stock_uom}
8
8
  - {name: cogs, type: currency, label: {id: Biaya bahan}, read_only: true, hidden_for: [outlet_staff]}
9
+ # rangka-os contract 0070: the lot used (empty = earliest expiry first) and, for a serial item, the units consumed
10
+ - {name: lot, type: link, to: stock_lot, label: {id: Lot bahan}, depends_on: "item.tracking in ['lot', 'lot_expiry']", help: {id: 'Kosongkan: lot yang paling dulu kedaluwarsa dipakai'}}
11
+ - {name: serial_nos, type: text, label: {id: Nomor seri}, depends_on: "item.tracking == 'serial'", help: {id: 'Satu nomor seri per baris'}}
@@ -6,3 +6,15 @@ fields:
6
6
  - {name: qty, type: float, label: {id: Qty}}
7
7
  - {name: uom, type: link, to: uom, label: {id: Satuan}, default: item.stock_uom}
8
8
  - {name: cost_share, type: float, label: {id: Porsi biaya bahan (%)}, default: '100'}
9
+ # rangka-os contract 0070: the batch's production code (printed on the pack) is the lot of what it made, else its
10
+ # production date; the main product takes the batch's expiry, a by-product its own shelf life. Not the batch number:
11
+ # a draft is named on submit, after its computes (follow-up: a kernel lot number from the document's own name).
12
+ # A serial product names its units.
13
+ - {name: lot_no, type: data, label: {id: Nomor lot}, compute: "parent.production_code != '' ? parent.production_code : string(parent.production_date)", depends_on: "item.tracking in ['lot', 'lot_expiry']"}
14
+ - name: expiry_date
15
+ type: date
16
+ label: {id: Kedaluwarsa}
17
+ compute: "item.tracking != 'lot_expiry' ? '' : (item == parent.item ? parent.expiry_date : (item.shelf_life_days > 0 ? parent.production_date + duration(item.shelf_life_days) : ''))"
18
+ depends_on: "item.tracking == 'lot_expiry'"
19
+ - {name: made_date, type: date, label: {id: Tanggal produksi}, compute: parent.production_date, hidden: true}
20
+ - {name: serial_nos, type: text, label: {id: Nomor seri}, depends_on: "item.tracking == 'serial'", help: {id: 'Satu nomor seri per baris'}}
@@ -5,13 +5,13 @@
5
5
  # at the value of those materials through the declarative stock block of contract 0021 (K-o). Wages and overhead are
6
6
  # in the batch's actual cost (HPP) but not in the stock value until K-r.
7
7
  name: production
8
- version: 1.2.2
8
+ version: 1.3.0
9
9
  title: {id: Produksi, en: Production}
10
10
  summary:
11
11
  id: Resep produksi, SPK, hasil per batch dan upah borongan.
12
12
  en: Bills of materials, work orders, batch output and piece-rate wages.
13
13
  category: operations
14
14
  icon: hammer-line
15
- requires: {rangka: '>=0.5', users: ^1.0, catalogue: ^1.0, outlets: ^1.0, stock: ^1.0, workforce: ^1.0}
15
+ requires: {rangka: '>=0.5', users: ^1.0, catalogue: ^1.6, outlets: ^1.0, stock: ^1.6, workforce: ^1.0}
16
16
  optional: {orders: ^1.0}
17
17
  hooks: [stock.reverse_moves]
@@ -16,6 +16,7 @@ permissions:
16
16
  - {role: employee, read: true, create: true, if: "employee == user.name"}
17
17
  - {role: cashier, read: true, create: true, if: "employee == user.name"}
18
18
  - {role: outlet_staff, read: true, create: true, if: "employee == user.name"}
19
+ - {role: member, read: true, if: "employee == user.name"}
19
20
  # the outlet supervisor reads the claims of their outlets (row scope on outlet) and creates their own
20
21
  - {role: outlet_supervisor, read: true}
21
22
  - {role: outlet_supervisor, create: true, if: "employee == user.name"}
@@ -15,13 +15,16 @@ title_field: description
15
15
  # Paying it back (pay_with): cash or bank by finance (claim_payment), or with the next salary (payslip.reimbursement,
16
16
  # untaxed). A submitted claim cannot change, so whether it was paid lives on its claim_settlement (made by
17
17
  # claim_settlement_on_submit). A claim already paid cannot be cancelled (claim_cancel_guard): cancel the payment or the
18
- # slip first. Raka may suggest category and amount from the receipt into a draft; a person submits, an approver
18
+ # slip first. Zafdoz may suggest category and amount from the receipt into a draft; a person submits, an approver
19
19
  # approves: money is never decided by an LLM.
20
20
  permissions:
21
21
  # Staff: their own claims only (permission if:, which also filters lists and dashboards). No cancel, no amend.
22
22
  - {role: employee, read: true, create: true, write: true, delete: true, submit: true, if: "employee == user.name"}
23
23
  - {role: cashier, read: true, create: true, write: true, delete: true, submit: true, if: "employee == user.name"}
24
24
  - {role: outlet_staff, read: true, create: true, write: true, delete: true, submit: true, if: "employee == user.name"}
25
+ # Every employee whatever their role reads their own claims (member grant, rangka-os contract 0074); claiming stays
26
+ # with the roles above for now.
27
+ - {role: member, read: true, if: "employee == user.name"}
25
28
  # The outlet supervisor reads the claims of their outlets (role row scope on outlet) to approve them, and claims too.
26
29
  - {role: outlet_supervisor, read: true, print: true}
27
30
  - {role: outlet_supervisor, create: true, write: true, delete: true, submit: true, if: "employee == user.name"}
@@ -1,6 +1,6 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
2
  name: reimbursement
3
- version: 1.0.0
3
+ version: 1.1.0
4
4
  title: {id: Klaim biaya karyawan, en: Expense claims}
5
5
  summary:
6
6
  id: Karyawan mengajukan klaim biaya dengan foto struk, atasan menyetujui, keuangan membayar tunai, transfer, atau bersama gaji tanpa dipajaki.
@@ -19,9 +19,8 @@ title_field: employee_name
19
19
  permissions:
20
20
  - {role: head_office, read: true, create: true, write: true, delete: true, export: true, print: true}
21
21
  - {role: outlet_supervisor, read: true, create: true, write: true, delete: true, print: true}
22
- - {role: cashier, read: true, if: "employee == user.name && published"}
23
- - {role: outlet_staff, read: true, if: "employee == user.name && published"}
24
- - {role: employee, read: true, if: "employee == user.name && published"}
22
+ # their own published shifts: every employee whatever their role (member grant, rangka-os contract 0074)
23
+ - {role: member, read: true, if: "employee == user.name && published"}
25
24
  fields:
26
25
  - {name: employee, type: link, to: user, label: {id: Karyawan}, required: true, in_list: true}
27
26
  - name: employee_name
@@ -19,6 +19,8 @@ permissions:
19
19
  - {role: cashier, read: true, create: true, write: true, delete: true, if: "requested_by == user.name"}
20
20
  - {role: outlet_staff, read: true, create: true, write: true, delete: true, if: "requested_by == user.name"}
21
21
  - {role: employee, read: true, create: true, write: true, delete: true, if: "requested_by == user.name"}
22
+ # every employee whatever their role reads their own requests (member grant, rangka-os contract 0074; jadwal_saya)
23
+ - {role: member, read: true, if: "requested_by == user.name"}
22
24
  fields:
23
25
  - {name: requested_by, type: link, to: user, label: {id: Diminta oleh}, default: user.name, read_only: true}
24
26
  - {name: requested_name, type: data, label: {id: Nama}, read_only: true, in_list: true, compute: "requested_by != '' ? requested_by.full_name : ''"}
@@ -1,6 +1,6 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
2
  name: shifts
3
- version: 1.0.0
3
+ version: 1.1.0
4
4
  title: {id: Jadwal shift, en: Work shifts}
5
5
  summary:
6
6
  id: Pola shift per outlet, jadwal mingguan yang diterbitkan, jadwal tiap karyawan, tukar shift, dan absen dibandingkan dengan jadwal.
@@ -0,0 +1,37 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Inside an item's save (rangka-os#260, audit 2026-11-21 F2/F3): item.tracking may change only where the stock registers
3
+ # stay true. Switching lots on (none -> lot / lot_expiry, or between the two lot modes) is always allowed: stock from
4
+ # before sits in the no-lot bucket (contract 0070 §2). Refused:
5
+ # - leaving the lot modes while a real lot still holds stock (the lot rows would freeze, and Σ lots would drift from
6
+ # stock_balance as the item keeps moving untracked);
7
+ # - leaving serial while a serial is in stock or in transit (the register would go stale);
8
+ # - switching to serial while the item has stock anywhere (no document could take those units out: every one would
9
+ # be refused serial_count_mismatch or serial_not_here).
10
+ # Each find runs only for the switch it guards; a role that cannot read the register is refused by the kernel, so the
11
+ # change fails safe (head office and the owner read every register).
12
+ name: item_tracking_lock
13
+ label: {id: Pelacakan stok hanya diubah bila stoknya cocok}
14
+ on: item.updated
15
+ if: "event.before != null && (event.before.tracking == '' ? 'none' : event.before.tracking) != (event.tracking == '' ? 'none' : event.tracking)"
16
+ steps:
17
+ - if: "event.before.tracking in ['lot', 'lot_expiry'] && !(event.tracking in ['lot', 'lot_expiry'])"
18
+ find: stock_lot_balance
19
+ where: "item == event.name && lot != '' && qty != 0"
20
+ as: lb
21
+ - if: "event.before.tracking in ['lot', 'lot_expiry'] && !(event.tracking in ['lot', 'lot_expiry']) && lb != null"
22
+ create: stock_guard
23
+ set: {reason: "'lots_in_stock'", document: event.name}
24
+ - if: "event.before.tracking == 'serial'"
25
+ find: serial_no
26
+ where: "item == event.name && state in ['in_stock', 'in_transit']"
27
+ as: sn
28
+ - if: "event.before.tracking == 'serial' && sn != null"
29
+ create: stock_guard
30
+ set: {reason: "'serials_in_stock'", document: event.name}
31
+ - if: "event.tracking == 'serial'"
32
+ find: stock_balance
33
+ where: "item == event.name && qty != 0"
34
+ as: sb
35
+ - if: "event.tracking == 'serial' && sb != null"
36
+ create: stock_guard
37
+ set: {reason: "'stock_without_serials'", document: event.name}
@@ -0,0 +1,103 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Every morning at 06:40 (scheduler.timezone), and by the owner from the flow list: the expiry-soon list stock_expiry
3
+ # (rangka-os#260, contract 0070). A lot balance is in the window when it holds stock and its lot expires within the item's
4
+ # expiry_warning_days (0 = 30 days, the default of items made before catalogue 1.6), or has expired.
5
+ # 1. Open rows, the 1000 least recently checked: a row whose lot balance is used up, gone, or out of the window is
6
+ # closed with today's qty; any other gets today's qty, days_left and state (soon, or expired once the date passed).
7
+ # Every row touched gets checked_on = today, so a business with more open rows refreshes them over several mornings.
8
+ # 2. Candidates: the 500 lot balances in the window that expire soonest from today, and the 500 that expired most
9
+ # recently (so new ones are never starved by old expired stock). Each without an open row gets one.
10
+ # 3. The rows not yet told about (notified false) go out once to head office and the warehouse (notice stock_expiry),
11
+ # then are marked notified. Running twice a day tells nobody twice.
12
+ # Nothing is moved here: expired stock leaves through a stock adjustment with reason expired (the kernel takes expired
13
+ # lots first), and deliveries skip expired lots by default.
14
+ name: lot_expiry_digest
15
+ label: {id: Kabari stok yang hampir kedaluwarsa, en: Expiring stock digest}
16
+ description: {id: 'Tiap pagi, lot barang yang masih ada stoknya dan mendekati atau melewati tanggal kedaluwarsa dikabarkan sekali ke kantor pusat dan gudang.'}
17
+ schedule: '40 6 * * *'
18
+ steps:
19
+ - find_all: stock_expiry
20
+ where: open
21
+ sort: checked_on
22
+ limit: 1000
23
+ as: marks
24
+ - for_each: marks
25
+ as: m
26
+ do:
27
+ - {find: stock_lot_balance, where: name == m.balance, as: mb}
28
+ - {find: item, where: name == m.item, as: mi}
29
+ - if: "mb == null || mi == null || mb.qty <= 0 || days_between(today(), m.expiry_date) > (mi.expiry_warning_days > 0 ? mi.expiry_warning_days : 30)"
30
+ update: m
31
+ set: {open: 'false', qty: "mb == null ? 0 : mb.qty", checked_on: today()}
32
+ - if: "mb != null && mi != null && mb.qty > 0 && days_between(today(), m.expiry_date) <= (mi.expiry_warning_days > 0 ? mi.expiry_warning_days : 30)"
33
+ update: m
34
+ set:
35
+ qty: mb.qty
36
+ days_left: days_between(today(), m.expiry_date)
37
+ state: "days_between(today(), m.expiry_date) < 0 ? 'expired' : 'soon'"
38
+ checked_on: today()
39
+ - find_all: stock_lot_balance
40
+ where: "qty > 0 && lot != '' && expiry_date != '' && days_between(today(), expiry_date) >= 0 && days_between(today(), expiry_date) <= (item.expiry_warning_days > 0 ? item.expiry_warning_days : 30)"
41
+ sort: expiry_date
42
+ limit: 500
43
+ as: upcoming
44
+ - find_all: stock_lot_balance
45
+ where: "qty > 0 && lot != '' && expiry_date != '' && days_between(today(), expiry_date) < 0"
46
+ sort: -expiry_date
47
+ limit: 500
48
+ as: expired
49
+ - for_each: "upcoming + expired"
50
+ as: b
51
+ do:
52
+ - {find: stock_expiry, where: "open && balance == b.name", as: had}
53
+ - {find: stock_lot, where: name == b.lot, as: lt}
54
+ - {find: item, where: name == b.item, as: it}
55
+ - if: had == null
56
+ create: stock_expiry
57
+ set:
58
+ balance: b.name
59
+ outlet: b.outlet
60
+ item: b.item
61
+ lot: b.lot
62
+ lot_no: lt.lot_no
63
+ item_name: it.item_name
64
+ expiry_date: b.expiry_date
65
+ qty: b.qty
66
+ days_left: days_between(today(), b.expiry_date)
67
+ state: "days_between(today(), b.expiry_date) < 0 ? 'expired' : 'soon'"
68
+ alerted_on: today()
69
+ checked_on: today()
70
+ open: 'true'
71
+ notified: 'false'
72
+ - find_all: stock_expiry
73
+ where: "open && !notified"
74
+ sort: expiry_date
75
+ limit: 500
76
+ as: fresh
77
+ - {if: "fresh.size() > 0", find: stock_expiry, where: "name == fresh[0].name", as: ex}
78
+ # the notice links to the soonest new row and counts the others
79
+ - if: fresh.size() > 0
80
+ notify: head_office
81
+ notice: stock_expiry
82
+ channel: email
83
+ record: ex
84
+ id: "'expiry:' + ex.name"
85
+ title: '{fresh.size()} lot barang hampir kedaluwarsa'
86
+ template: >-
87
+ {ex.item_name} lot {ex.lot_no} ({ex.qty} tersisa) kedaluwarsa {ex.expiry_date}{fresh.size() > 1 ? ', dan ' + string(fresh.size() - 1) + ' lot lain juga baru masuk daftar' : ''}.
88
+ Buka daftar "Stok hampir kedaluwarsa" untuk melihat semuanya.
89
+ - if: fresh.size() > 0
90
+ notify: warehouse_staff
91
+ notice: stock_expiry
92
+ channel: email
93
+ record: ex
94
+ id: "'expiry-wh:' + ex.name"
95
+ title: '{fresh.size()} lot barang hampir kedaluwarsa'
96
+ template: >-
97
+ {ex.item_name} lot {ex.lot_no} kedaluwarsa {ex.expiry_date}. Keluarkan dulu lot yang paling dekat
98
+ kedaluwarsanya, dan catat barang yang sudah lewat di Penyesuaian stok dengan alasan Kedaluwarsa.
99
+ - for_each: fresh
100
+ as: f
101
+ do:
102
+ - update: f
103
+ set: {notified: 'true'}