@rangka-os/create 0.5.0-alpha.27 → 0.5.0-alpha.28

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 (183) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/absen_karyawan/app.rk +37 -0
  3. package/template/base/apps/absen_karyawan/dashboards/absen_hari_ini.rk +20 -0
  4. package/template/base/apps/absen_karyawan/dashboards/absen_karyawan_saya.rk +14 -0
  5. package/template/base/apps/absen_karyawan/dashboards/rekap_absen_karyawan.rk +12 -0
  6. package/template/base/apps/jasa_proyek/app.rk +1 -1
  7. package/template/base/apps/kasir/app.rk +5 -1
  8. package/template/base/apps/kasir/dashboards/kasir_ringkas.rk +4 -0
  9. package/template/base/apps/kasir/skills/rangka-app-kasir/SKILL.md +20 -0
  10. package/template/base/connectors/midtrans/connector.rk +249 -0
  11. package/template/base/connectors/midtrans/fixtures/charge_gopay.json +34 -0
  12. package/template/base/connectors/midtrans/fixtures/charge_qris.json +23 -0
  13. package/template/base/connectors/midtrans/fixtures/charge_va.json +20 -0
  14. package/template/base/connectors/midtrans/fixtures/create_snap.json +4 -0
  15. package/template/base/connectors/midtrans/fixtures/expect.json +88 -0
  16. package/template/base/connectors/midtrans/fixtures/get_status.json +15 -0
  17. package/template/base/connectors/midtrans/fixtures/payment_notified.json +28 -0
  18. package/template/base/connectors/midtrans/fixtures/payment_notified_challenge.json +24 -0
  19. package/template/base/connectors/midtrans/fixtures/payment_notified_expire.json +24 -0
  20. package/template/base/connectors/midtrans/fixtures/payment_notified_other_amount.json +28 -0
  21. package/template/base/connectors/midtrans/fixtures/payment_notified_partial_refund.json +34 -0
  22. package/template/base/connectors/midtrans/fixtures/payment_notified_pending.json +31 -0
  23. package/template/base/connectors/midtrans/fixtures/payment_notified_refund.json +34 -0
  24. package/template/base/connectors/midtrans/fixtures/payment_notified_relabelled.json +28 -0
  25. package/template/base/connectors/midtrans/fixtures/payment_notified_va.json +32 -0
  26. package/template/base/connectors/midtrans/fixtures/signature_vector.txt +3 -0
  27. package/template/base/connectors/midtrans/mock/midtrans_mock.py +335 -0
  28. package/template/base/connectors/rangka_whatsapp/README.md +105 -0
  29. package/template/base/connectors/rangka_whatsapp/connector.rk +141 -0
  30. package/template/base/connectors/rangka_whatsapp/fixtures/expect.json +9 -0
  31. package/template/base/connectors/rangka_whatsapp/fixtures/message_received.json +1 -0
  32. package/template/base/connectors/rangka_whatsapp/fixtures/message_status.json +1 -0
  33. package/template/base/connectors/rangka_whatsapp/fixtures/message_status_refused.json +1 -0
  34. package/template/base/connectors/rangka_whatsapp/fixtures/opted_out.json +1 -0
  35. package/template/base/connectors/rangka_whatsapp/fixtures/send_template.json +1 -0
  36. package/template/base/connectors/rangka_whatsapp/fixtures/send_template_duplicate.json +1 -0
  37. package/template/base/connectors/rangka_whatsapp/fixtures/set_opt_out.json +1 -0
  38. package/template/base/connectors/rangka_whatsapp/mock/rangka_whatsapp_mock.py +354 -0
  39. package/template/base/connectors/shopee/connector.rk +360 -0
  40. package/template/base/connectors/shopee/fixtures/expect.json +119 -0
  41. package/template/base/connectors/shopee/fixtures/get_models.json +52 -0
  42. package/template/base/connectors/shopee/fixtures/get_order_detail.json +396 -0
  43. package/template/base/connectors/shopee/fixtures/get_settlement.json +90 -0
  44. package/template/base/connectors/shopee/fixtures/get_tracking.json +13 -0
  45. package/template/base/connectors/shopee/fixtures/list_items.json +29 -0
  46. package/template/base/connectors/shopee/fixtures/list_orders.json +31 -0
  47. package/template/base/connectors/shopee/fixtures/list_settlements.json +15 -0
  48. package/template/base/connectors/shopee/fixtures/order_changed.json +101 -0
  49. package/template/base/connectors/shopee/fixtures/order_changed_cancelled.json +72 -0
  50. package/template/base/connectors/shopee/fixtures/order_changed_completed.json +101 -0
  51. package/template/base/connectors/shopee/fixtures/order_changed_in_cancel.json +72 -0
  52. package/template/base/connectors/shopee/fixtures/order_changed_unpaid.json +71 -0
  53. package/template/base/connectors/shopee/fixtures/order_settled.json +92 -0
  54. package/template/base/connectors/shopee/fixtures/push_received.json +12 -0
  55. package/template/base/connectors/shopee/fixtures/push_received_tracking.json +11 -0
  56. package/template/base/connectors/shopee/fixtures/update_stock.json +15 -0
  57. package/template/base/connectors/shopee/mock/shopee_mock.py +894 -0
  58. package/template/base/connectors/tiktok_shop/connector.rk +300 -0
  59. package/template/base/connectors/tiktok_shop/fixtures/expect.json +105 -0
  60. package/template/base/connectors/tiktok_shop/fixtures/get_order_detail.json +136 -0
  61. package/template/base/connectors/tiktok_shop/fixtures/get_settlement.json +83 -0
  62. package/template/base/connectors/tiktok_shop/fixtures/get_tracking.json +28 -0
  63. package/template/base/connectors/tiktok_shop/fixtures/list_orders.json +242 -0
  64. package/template/base/connectors/tiktok_shop/fixtures/list_products.json +77 -0
  65. package/template/base/connectors/tiktok_shop/fixtures/list_settlements.json +22 -0
  66. package/template/base/connectors/tiktok_shop/fixtures/list_shops.json +17 -0
  67. package/template/base/connectors/tiktok_shop/fixtures/order_changed.json +129 -0
  68. package/template/base/connectors/tiktok_shop/fixtures/order_changed_cancelled.json +81 -0
  69. package/template/base/connectors/tiktok_shop/fixtures/order_changed_completed.json +106 -0
  70. package/template/base/connectors/tiktok_shop/fixtures/order_changed_on_hold.json +104 -0
  71. package/template/base/connectors/tiktok_shop/fixtures/order_changed_tokopedia.json +106 -0
  72. package/template/base/connectors/tiktok_shop/fixtures/order_changed_unpaid.json +79 -0
  73. package/template/base/connectors/tiktok_shop/fixtures/order_settled.json +73 -0
  74. package/template/base/connectors/tiktok_shop/fixtures/update_stock.json +6 -0
  75. package/template/base/connectors/tiktok_shop/fixtures/webhook_received.json +12 -0
  76. package/template/base/connectors/tiktok_shop/fixtures/webhook_received_cancellation.json +13 -0
  77. package/template/base/connectors/tiktok_shop/mock/tiktok_shop_mock.py +819 -0
  78. package/template/base/connectors/whatsapp_business/connector.rk +3 -1
  79. package/template/base/connectors/whatsapp_business/templates.md +13 -1
  80. package/template/base/modules/attendance/flows/attendance_missing_digest.rk +30 -0
  81. package/template/base/modules/attendance/flows/attendance_period_on_cancel.rk +15 -0
  82. package/template/base/modules/attendance/flows/attendance_period_on_submit.rk +60 -0
  83. package/template/base/modules/attendance/flows/staff_attendance_cancel_guard.rk +14 -0
  84. package/template/base/modules/attendance/flows/staff_attendance_guard_created.rk +16 -0
  85. package/template/base/modules/attendance/flows/staff_attendance_guard_submitted.rk +37 -0
  86. package/template/base/modules/attendance/flows/staff_attendance_guard_updated.rk +14 -0
  87. package/template/base/modules/attendance/models/attendance_period.rk +62 -0
  88. package/template/base/modules/attendance/models/attendance_summary.rk +37 -0
  89. package/template/base/modules/attendance/models/staff_attendance.rk +281 -0
  90. package/template/base/modules/attendance/models/staff_attendance_guard.rk +50 -0
  91. package/template/base/modules/attendance/module.rk +18 -0
  92. package/template/base/modules/attendance/screens/absen_outlet.rk +22 -0
  93. package/template/base/modules/catalogue/models/item.rk +69 -0
  94. package/template/base/modules/catalogue/module.rk +1 -1
  95. package/template/base/modules/contacts/models/customer.rk +43 -19
  96. package/template/base/modules/contacts/module.rk +1 -1
  97. package/template/base/modules/coretax/module.rk +1 -1
  98. package/template/base/modules/coretax/print/coretax_faktur.rk +3 -2
  99. package/template/base/modules/coretax/print/coretax_faktur.xml +3 -1
  100. package/template/base/modules/coretax/print/rekap_ppn.html +9 -7
  101. package/template/base/modules/courses/flows/charge_invoice_on_submit.rk +15 -0
  102. package/template/base/modules/courses/module.rk +1 -1
  103. package/template/base/modules/courses/screens/absen_kelas.rk +1 -0
  104. package/template/base/modules/invoicing/flows/invoice_due_digest.rk +45 -7
  105. package/template/base/modules/invoicing/models/sales_invoice_item.rk +4 -1
  106. package/template/base/modules/invoicing/module.rk +15 -2
  107. package/template/base/modules/kitchen/screens/dapur.rk +1 -0
  108. package/template/base/modules/outlets/models/outlet.rk +69 -0
  109. package/template/base/modules/outlets/module.rk +1 -1
  110. package/template/base/modules/payments/flows/payment_from_midtrans.rk +85 -0
  111. package/template/base/modules/payments/flows/payment_refund_from_midtrans.rk +22 -0
  112. package/template/base/modules/payments/models/payment.rk +2 -1
  113. package/template/base/modules/payments/module.rk +1 -1
  114. package/template/base/modules/payroll/flows/payroll_close_on_cancel.rk +8 -5
  115. package/template/base/modules/payroll/flows/payroll_close_on_submit.rk +8 -5
  116. package/template/base/modules/payroll/flows/payroll_reminder.rk +106 -0
  117. package/template/base/modules/payroll/flows/payroll_run_overlap_guard_created.rk +5 -3
  118. package/template/base/modules/payroll/flows/payroll_run_overlap_guard_updated.rk +5 -3
  119. package/template/base/modules/payroll/flows/payslip_from_recap.rk +1 -1
  120. package/template/base/modules/payroll/imports/payroll_profile_list.rk +27 -0
  121. package/template/base/modules/payroll/models/payroll_close.rk +10 -6
  122. package/template/base/modules/payroll/models/payroll_run.rk +64 -15
  123. package/template/base/modules/payroll/models/payslip.rk +48 -9
  124. package/template/base/modules/payroll/module.rk +22 -5
  125. package/template/base/modules/payroll/print/payslip.html +4 -1
  126. package/template/base/modules/pos/models/pos_sale.rk +136 -9
  127. package/template/base/modules/pos/models/pos_sale_item.rk +33 -1
  128. package/template/base/modules/pos/module.rk +5 -3
  129. package/template/base/modules/pos/print/pos_receipt.html +7 -3
  130. package/template/base/modules/pos/screens/kasir.rk +7 -2
  131. package/template/base/modules/procurement/flows/reorder_draft_po.rk +57 -0
  132. package/template/base/modules/procurement/models/vendor_bill.rk +14 -1
  133. package/template/base/modules/procurement/module.rk +11 -2
  134. package/template/base/modules/projects/screens/absen.rk +1 -0
  135. package/template/base/modules/promotions/flows/promo_code_batch_on_submit.rk +26 -0
  136. package/template/base/modules/promotions/flows/promotion_apply.rk +110 -0
  137. package/template/base/modules/promotions/flows/promotion_apply_on_create.rk +110 -0
  138. package/template/base/modules/promotions/flows/promotion_apply_on_delete.rk +111 -0
  139. package/template/base/modules/promotions/flows/promotion_apply_on_update.rk +110 -0
  140. package/template/base/modules/promotions/flows/promotion_on_sale.rk +95 -0
  141. package/template/base/modules/promotions/flows/promotion_on_sale_cancel.rk +43 -0
  142. package/template/base/modules/promotions/models/promo_code.rk +27 -0
  143. package/template/base/modules/promotions/models/promo_code_batch.rk +36 -0
  144. package/template/base/modules/promotions/models/promo_guard.rk +44 -0
  145. package/template/base/modules/promotions/models/promotion.rk +197 -0
  146. package/template/base/modules/promotions/models/promotion_ledger.rk +35 -0
  147. package/template/base/modules/promotions/module.rk +20 -0
  148. package/template/base/modules/rental/screens/alat_keluar.rk +1 -0
  149. package/template/base/modules/rental/screens/alat_kembali.rk +1 -0
  150. package/template/base/modules/rental/screens/jadwal_alat.rk +1 -0
  151. package/template/base/modules/stock/flows/stock_low_alert.rk +65 -0
  152. package/template/base/modules/stock/flows/stock_negative_alert.rk +14 -5
  153. package/template/base/modules/stock/models/stock_reorder.rk +34 -0
  154. package/template/base/modules/stock/module.rk +17 -2
  155. package/template/base/modules/subscriptions/screens/catat_tagih.rk +1 -0
  156. package/template/base/modules/subscriptions/screens/rute_tagih.rk +1 -0
  157. package/template/base/modules/users/flows/summary_daily.rk +83 -0
  158. package/template/base/modules/users/flows/summary_monthly.rk +83 -0
  159. package/template/base/modules/users/flows/summary_weekly.rk +83 -0
  160. package/template/base/modules/users/models/business_summary.rk +67 -0
  161. package/template/base/modules/users/models/summary_setting.rk +35 -0
  162. package/template/base/modules/users/models/user.rk +11 -3
  163. package/template/base/modules/users/module.rk +21 -2
  164. package/template/base/modules/users/roles/employee.rk +8 -0
  165. package/template/base/modules/users/roles/outlet_supervisor.rk +7 -0
  166. package/template/base/modules/whatsapp/flows/whatsapp_customer_opt_out.rk +16 -0
  167. package/template/base/modules/whatsapp/flows/whatsapp_customer_opt_out_new.rk +17 -0
  168. package/template/base/modules/whatsapp/flows/whatsapp_message_status.rk +24 -0
  169. package/template/base/modules/whatsapp/flows/whatsapp_opted_out.rk +26 -0
  170. package/template/base/modules/whatsapp/models/whatsapp_message.rk +99 -0
  171. package/template/base/modules/whatsapp/models/whatsapp_opt_out.rk +44 -0
  172. package/template/base/modules/whatsapp/module.rk +23 -0
  173. package/template/base/modules/whatsapp_booking/flows/whatsapp_booking_tomorrow.rk +48 -0
  174. package/template/base/modules/whatsapp_booking/module.rk +13 -0
  175. package/template/base/modules/whatsapp_order_ready/flows/whatsapp_pickup_on_sale.rk +19 -0
  176. package/template/base/modules/whatsapp_order_ready/flows/whatsapp_ticket_ready.rk +40 -0
  177. package/template/base/modules/whatsapp_order_ready/models/whatsapp_pickup.rk +22 -0
  178. package/template/base/modules/whatsapp_order_ready/module.rk +14 -0
  179. package/template/base/modules/whatsapp_receipt/flows/whatsapp_receipt_on_sale.rk +43 -0
  180. package/template/base/modules/whatsapp_receipt/module.rk +13 -0
  181. package/template/base/modules/whatsapp_reminder/flows/whatsapp_invoice_overdue.rk +64 -0
  182. package/template/base/modules/whatsapp_reminder/module.rk +15 -0
  183. package/template/base/modules/workforce/imports/worker_list.rk +4 -1
@@ -4,7 +4,8 @@ label: {id: Periode gaji, en: Payroll run}
4
4
  icon: calendar
5
5
  naming: PAY-{YYYY}-{####}
6
6
  title_field: project
7
- # One client contract (project) for one cut-off period. Create it before the attendance recaps are submitted: each
7
+ # One cut-off period of either one client contract (run_kind client: outsourced workers, a project, a client invoice at
8
+ # the close) or the firm's own staff (run_kind internal: no project and no invoice; optionally one outlet). Create it before the attendance recaps are submitted: each
8
9
  # submitted recap of a worker with a payroll profile becomes a draft payslip of this run (flow payslip_from_recap).
9
10
  # The totals are kept by the flows of payslip submit and cancel. The run is not itself submitted: slips link to it, and
10
11
  # a submit would rename a DRAFT- record without its links following. It is closed by submitting a payroll_close
@@ -16,18 +17,37 @@ permissions:
16
17
  - {role: finance_manager, read: true, create: true, write: true, export: true, print: true}
17
18
  - {role: project_admin, read: true}
18
19
  fields:
20
+ # client: a client contract (projects installed); internal: the firm's own staff. Runs made before 2.0 are all client
21
+ # (the upgrade fills the default, tests/upgrade_payroll_internal.py). A new run defaults to client only where the
22
+ # projects module is installed. Locked with the project once a slip is submitted (rule project_matches_kind).
23
+ - name: run_kind
24
+ type: select
25
+ label: {id: Jenis periode, en: Run kind}
26
+ required: true
27
+ default: "app_installed('projects') ? 'client' : 'internal'"
28
+ in_list: true
29
+ options:
30
+ - {value: client, label: {id: Kontrak klien, en: Client contract}}
31
+ - {value: internal, label: {id: Karyawan sendiri, en: Own staff}}
19
32
  - name: project
20
33
  type: link
21
34
  to: project
22
35
  label: {id: Proyek (kontrak klien)}
23
- required: true
24
36
  in_list: true
37
+ depends_on: run_kind == 'client'
25
38
  - name: customer
26
39
  type: link
27
40
  to: customer
28
41
  label: {id: Klien}
29
- default: project.customer
42
+ default: "app_installed('projects') && project != '' ? project.customer : ''"
30
43
  read_only: true
44
+ depends_on: run_kind == 'client'
45
+ # Cost centre of an internal run: the outlet whose staff it pays (empty = every outlet).
46
+ - name: outlet
47
+ type: link
48
+ to: outlet
49
+ label: {id: Outlet, en: Outlet}
50
+ depends_on: run_kind == 'internal' && app_installed('outlets')
31
51
  - name: period_from
32
52
  type: date
33
53
  label: {id: Periode dari}
@@ -75,7 +95,8 @@ fields:
75
95
  type: select
76
96
  label: {id: Cara tagih klien}
77
97
  required: true
78
- default: "'wages_plus_fee'"
98
+ default: "run_kind == 'internal' ? 'none' : 'wages_plus_fee'"
99
+ depends_on: run_kind == 'client'
79
100
  options:
80
101
  - {value: wages_plus_fee, label: {id: Gaji + BPJS + fee}}
81
102
  - {value: fee_only, label: {id: Fee saja}}
@@ -84,6 +105,7 @@ fields:
84
105
  type: select
85
106
  label: {id: Fee}
86
107
  default: "'percent'"
108
+ depends_on: run_kind == 'client' && billing_mode != 'none'
87
109
  options:
88
110
  - {value: percent, label: {id: Persen dari biaya tenaga kerja}}
89
111
  - {value: flat, label: {id: Flat per pekerja per bulan}}
@@ -91,32 +113,46 @@ fields:
91
113
  type: percent
92
114
  label: {id: Fee persen}
93
115
  default: '0'
94
- depends_on: fee_mode == 'percent'
116
+ depends_on: run_kind == 'client' && billing_mode != 'none' && fee_mode == 'percent'
95
117
  - name: fee_per_worker
96
118
  type: currency
97
119
  label: {id: Fee per pekerja}
98
120
  default: '0'
99
- depends_on: fee_mode == 'flat'
121
+ depends_on: run_kind == 'client' && billing_mode != 'none' && fee_mode == 'flat'
100
122
  - name: wage_item
101
123
  type: link
102
124
  to: item
125
+ depends_on: run_kind == 'client' && billing_mode != 'none'
103
126
  label: {id: Barang/jasa untuk baris gaji}
104
127
  - name: bpjs_item
105
128
  type: link
106
129
  to: item
130
+ depends_on: run_kind == 'client' && billing_mode != 'none'
107
131
  label: {id: Barang/jasa untuk baris BPJS}
108
132
  - name: fee_item
109
133
  type: link
110
134
  to: item
135
+ depends_on: run_kind == 'client' && billing_mode != 'none'
111
136
  label: {id: Barang/jasa untuk baris fee}
112
137
  - name: invoice_date
113
138
  type: date
114
139
  label: {id: Tanggal faktur klien}
140
+ depends_on: run_kind == 'client' && billing_mode != 'none'
115
141
  - name: pph23_applies
116
142
  type: check
117
143
  label: {id: Klien memotong PPh 23}
118
144
  default: 'true'
145
+ depends_on: run_kind == 'client' && billing_mode != 'none'
146
+ # Lateness deduction per minute late (staff attendance summary), 0 = off. Off by default (DECISIONS.md, 19 Nov 2026):
147
+ # a firm that deducts for lateness sets it here, and the slips show late minutes either way.
148
+ - name: late_rate_per_min
149
+ type: currency
150
+ label: {id: Potongan telat per menit, en: Lateness deduction per minute}
151
+ default: '0'
119
152
  - {name: closed, type: check, label: {id: Sudah ditutup}, default: 'false', read_only: true, in_list: true}
153
+ # Set by flow payroll_reminder on the morning it told finance the period is ready (notice payroll_ready), so a run is
154
+ # announced once and the daily check sends nothing more about it.
155
+ - {name: ready_told, type: check, label: {id: Sudah dikabari siap diproses}, default: 'false', read_only: true}
120
156
  # Locks (written by the flows): once a slip is submitted the run's rates, period, tax month and project are those of
121
157
  # the slips (lock_slip, the first submitted slip, stores copies); once closed, everything the close froze must stay
122
158
  # (closed_by). Cleared when the last slip is cancelled or the close is cancelled.
@@ -133,13 +169,14 @@ fields:
133
169
  label: {id: Masa pajak sebelumnya}
134
170
  hidden: true
135
171
  compute: "tax_month == 1 ? truncate(tax_year - 1, 4) + '-12' : truncate(tax_year, 4) + '-' + (tax_month < 11 ? '0' : '') + truncate(tax_month - 1, 2)"
136
- # One run per project and start of period.
172
+ # One client run per project and start of period; one internal run per outlet (or all outlets) and start of period.
173
+ # A client run's key is the same as before 2.0.
137
174
  - name: run_key
138
175
  type: data
139
176
  label: {id: Kunci periode}
140
177
  hidden: true
141
178
  unique: true
142
- compute: "project + ':' + period_from"
179
+ compute: "run_kind == 'internal' ? 'internal:' + outlet + ':' + period_from : project + ':' + period_from"
143
180
  # Totals of the submitted payslips (flows payroll_totals_on_payslip_*). Not typed by anyone.
144
181
  - {name: headcount, type: int, label: {id: Jumlah pekerja}, default: '0', read_only: true, in_list: true}
145
182
  - {name: total_cash_gross, type: currency, label: {id: 'Gaji, tunjangan, lembur, THR'}, default: '0', read_only: true}
@@ -162,6 +199,17 @@ fields:
162
199
  label: {id: Biaya tambahan ke untung proyek}
163
200
  compute: total_employer_cost - total_timesheet_cost
164
201
  rules:
202
+ # A client run has a project and an internal run none: the kind cannot change once a slip is submitted, since the
203
+ # project is locked by locked_by_slips.
204
+ - name: project_matches_kind
205
+ on: save
206
+ check: "run_kind == 'client' ? app_installed('projects') && project != '' : project == ''"
207
+ message: {id: 'Periode kontrak klien butuh proyek; periode karyawan sendiri tanpa proyek'}
208
+ # An internal run bills nobody; an outlet is the cost centre of an internal run only.
209
+ - name: internal_not_billed
210
+ on: save
211
+ check: "run_kind == 'client' ? outlet == '' : billing_mode == 'none'"
212
+ message: {id: 'Periode karyawan sendiri tidak ditagih ke klien; outlet hanya untuk periode karyawan sendiri'}
165
213
  - name: period_order
166
214
  on: save
167
215
  check: period_to >= period_from && period_to < period_from + duration(31)
@@ -172,8 +220,8 @@ rules:
172
220
  message: {id: 'Bulan pajak 1 sampai 12, tahun pajak mulai 2024 (TER)'}
173
221
  - name: rates_range
174
222
  on: save
175
- check: umk > 0 && jkk_rate >= 0.24 && jkk_rate <= 1.74 && jp_wage_cap > 0 && kes_wage_cap > 0 && (workdays_per_week == 5 || workdays_per_week == 6) && fee_percent >= 0 && fee_per_worker >= 0
176
- message: {id: 'Isi UMK; JKK 0,24 sampai 1,74 persen; batas upah lebih dari 0; hari kerja 5 atau 6; fee tidak negatif'}
223
+ check: umk > 0 && jkk_rate >= 0.24 && jkk_rate <= 1.74 && jp_wage_cap > 0 && kes_wage_cap > 0 && (workdays_per_week == 5 || workdays_per_week == 6) && fee_percent >= 0 && fee_per_worker >= 0 && late_rate_per_min >= 0
224
+ message: {id: 'Isi UMK; JKK 0,24 sampai 1,74 persen; batas upah lebih dari 0; hari kerja 5 atau 6; fee dan potongan telat tidak negatif'}
177
225
  # Pay of a period is paid (and taxed) in the month it ends or the month after: the tax month follows the period, so the
178
226
  # same days cannot be put into two tax months.
179
227
  - name: tax_month_follows_period
@@ -186,8 +234,9 @@ rules:
186
234
  lock_slip == '' || (lock_slip.project == project && lock_slip.tax_year == tax_year && lock_slip.tax_month == tax_month
187
235
  && lock_slip.run_umk == umk && lock_slip.run_jkk_rate == jkk_rate && lock_slip.run_jp_cap == jp_wage_cap
188
236
  && lock_slip.run_kes_cap == kes_wage_cap && lock_slip.run_workdays == workdays_per_week
189
- && lock_slip.run_period_from == period_from && lock_slip.run_period_to == period_to)
190
- message: {id: 'Periode sudah punya slip diajukan: proyek, periode, bulan pajak, UMK dan tarif terkunci'}
237
+ && lock_slip.run_period_from == period_from && lock_slip.run_period_to == period_to
238
+ && lock_slip.run_late_rate == late_rate_per_min && lock_slip.run_outlet == outlet)
239
+ message: {id: 'Periode sudah punya slip diajukan: jenis, proyek, outlet, periode, bulan pajak, UMK dan tarif terkunci'}
191
240
  - name: locked_by_close
192
241
  on: save
193
242
  check: >-
@@ -198,18 +247,18 @@ rules:
198
247
  message: {id: 'Periode gaji sudah ditutup: batalkan dokumen tutup periodenya dulu untuk mengubahnya'}
199
248
  views:
200
249
  list:
201
- columns: [name, project, period_from, period_to, headcount, total_net_pay, closed]
250
+ columns: [name, run_kind, project, period_from, period_to, headcount, total_net_pay, closed]
202
251
  sort: -period_from
203
252
  form:
204
253
  layout:
205
254
  - section: {id: Periode}
206
255
  columns:
207
- - [project, customer, period_from, period_to, closed]
256
+ - [run_kind, project, customer, outlet, period_from, period_to, closed]
208
257
  - [tax_year, tax_month, pay_date]
209
258
  - section: {id: Tarif dan batas}
210
259
  columns:
211
260
  - [umk, workdays_per_week, jkk_rate]
212
- - [jp_wage_cap, kes_wage_cap]
261
+ - [jp_wage_cap, kes_wage_cap, late_rate_per_min]
213
262
  - section: {id: Tagihan klien}
214
263
  columns:
215
264
  - [billing_mode, fee_mode, fee_percent, fee_per_worker, pph23_applies]
@@ -34,12 +34,21 @@ fields:
34
34
  - {name: run_workdays, type: int, label: {id: Hari kerja per minggu periode}, hidden: true, compute: payroll_run.workdays_per_week}
35
35
  - {name: run_period_from, type: date, label: {id: Periode dari}, hidden: true, compute: payroll_run.period_from}
36
36
  - {name: run_period_to, type: date, label: {id: Periode sampai}, hidden: true, compute: payroll_run.period_to}
37
+ - {name: run_late_rate, type: currency, label: {id: Potongan telat per menit periode}, hidden: true, compute: payroll_run.late_rate_per_min}
38
+ - {name: run_outlet, type: data, label: {id: Outlet periode}, hidden: true, compute: payroll_run.outlet}
37
39
  - name: worker
38
40
  type: link
39
41
  to: worker
40
42
  label: {id: Tenaga kerja}
41
43
  compute: profile.worker
42
44
  in_list: true
45
+ # The worker's employee record (Karyawan in Tim, contract 0056), empty for a worker who never signs in. The employee
46
+ # app reads a person's own slips through it.
47
+ - name: employee
48
+ type: link
49
+ to: user
50
+ label: {id: Karyawan, en: Employee}
51
+ compute: profile.worker.employee
43
52
  - name: project
44
53
  type: link
45
54
  to: project
@@ -49,6 +58,7 @@ fields:
49
58
  type: link
50
59
  to: timesheet
51
60
  label: {id: Rekap absensi}
61
+ depends_on: app_installed('projects')
52
62
  - {name: tax_year, type: int, label: {id: Tahun pajak}, default: payroll_run.tax_year}
53
63
  - {name: tax_month, type: int, label: {id: Bulan pajak}, default: payroll_run.tax_month}
54
64
  # December, or the month the worker leaves: PPh 21 is recomputed for the year (Pasal 17).
@@ -72,6 +82,14 @@ fields:
72
82
  - {value: permanent, label: {id: Tetap atau dibayar bulanan}}
73
83
  - {value: casual, label: {id: 'Tidak tetap, dibayar harian'}}
74
84
  - {name: days, type: float, label: {id: Hari hadir}, default: '0', in_list: true}
85
+ # Days a monthly employee is not paid for (absent without leave, unpaid leave), typed by finance or filled from the
86
+ # attendance summary. Each costs one day of the monthly salary (salary / 25, or / 21 in a five-day week), taken off
87
+ # the base pay, so PPh 21 is withheld on what is paid. The BPJS base stays the contractual wage (salary + fixed
88
+ # allowance, never below the UMK): PP 44/2015, 46/2015, 45/2015 and Perpres 82/2018 take upah pokok + tunjangan
89
+ # tetap as reported, not the month's cut pay (audit 101a F1). A daily worker is paid for days present.
90
+ - {name: unpaid_days, type: float, label: {id: Hari tidak dibayar, en: Unpaid days}, default: '0'}
91
+ # Minutes late in the period (attendance summary, or typed). Deducted only when the run sets a rate per minute.
92
+ - {name: late_min_total, type: int, label: {id: Total menit telat, en: Minutes late}, default: '0'}
75
93
  - {name: day_rate, type: currency, label: {id: Upah per hari}, default: profile.worker.cost_day_rate}
76
94
  - {name: monthly_salary, type: currency, label: {id: Gaji pokok per bulan}, default: profile.monthly_salary}
77
95
  - {name: fixed_allowance, type: currency, label: {id: Tunjangan tetap}, default: profile.fixed_allowance}
@@ -125,10 +143,19 @@ fields:
125
143
  - {name: ytd_pension, type: currency, label: {id: JHT + JP pekerja sebelumnya}, default: '0', read_only: true}
126
144
  - {name: ytd_months, type: int, label: {id: Bulan sebelumnya tahun ini}, default: '0', read_only: true}
127
145
  # Pay.
146
+ - name: unpaid_deduction
147
+ type: currency
148
+ label: {id: Potongan hari tidak dibayar, en: Unpaid days deduction}
149
+ compute: "pay_basis == 'monthly' ? round(monthly_salary * unpaid_days * 1.0 / (payroll_run.workdays_per_week == 5 ? 21 : 25)) : 0"
128
150
  - name: base_pay
129
151
  type: currency
130
152
  label: {id: Gaji pokok}
131
- compute: "pay_basis == 'monthly' ? monthly_salary : round(days * day_rate)"
153
+ compute: "pay_basis == 'monthly' ? monthly_salary - unpaid_deduction : round(days * day_rate)"
154
+ # A pay cut, so it lowers the gross PPh 21 is withheld from; the BPJS base stays the contractual wage.
155
+ - name: late_deduction
156
+ type: currency
157
+ label: {id: Potongan telat, en: Lateness deduction}
158
+ compute: "round(late_min_total * run_late_rate)"
132
159
  # Upah sebulan (pokok + tunjangan tetap) for the hourly overtime wage and THR; a daily worker's month is 25 days
133
160
  # (6-day week) or 21 (5-day week).
134
161
  - name: month_wage
@@ -155,13 +182,14 @@ fields:
155
182
  - name: cash_gross
156
183
  type: currency
157
184
  label: {id: 'Penghasilan (gaji, tunjangan, lembur, THR)'}
158
- compute: base_pay + overtime_pay + holiday_overtime_pay + allowance_pay + thr_pay + other_income
185
+ compute: base_pay + overtime_pay + holiday_overtime_pay + allowance_pay + thr_pay + other_income - late_deduction
159
186
  in_list: true
160
- # BPJS wage: pokok + tunjangan tetap, never below the UMK of the site.
187
+ # BPJS wage: pokok + tunjangan tetap, never below the UMK of the site. A monthly salary counts whole: unpaid days and
188
+ # lateness cut the pay, not the reported wage (audit 101a F1).
161
189
  - name: bpjs_base
162
190
  type: currency
163
191
  label: {id: Dasar upah BPJS}
164
- compute: "base_pay + fixed_allowance > payroll_run.umk ? base_pay + fixed_allowance : payroll_run.umk"
192
+ 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"
165
193
  - name: below_umk
166
194
  type: check
167
195
  label: {id: Upah di bawah UMK}
@@ -290,11 +318,16 @@ rules:
290
318
  check: >-
291
319
  days >= 0 && days <= 31 && day_rate >= 0 && monthly_salary >= 0 && fixed_allowance >= 0 && daily_allowance >= 0
292
320
  && overtime_hours >= 0 && overtime_hours <= 744 && overtime_days >= 0 && overtime_days <= days + 0.0001 && overtime_rate >= 0
293
- && thr_tenure_months >= 0 && other_income >= 0 && other_deduction >= 0
321
+ && thr_tenure_months >= 0 && other_income >= 0 && other_deduction >= 0 && late_min_total >= 0
294
322
  && holiday_overtime_days >= 0 && holiday_overtime_days <= 31 && holiday_hours_2x >= 0 && holiday_hours_3x >= 0 && holiday_hours_4x >= 0
295
323
  && holiday_hours_2x <= holiday_overtime_days * (payroll_run.workdays_per_week == 5 ? 8 : 7)
296
324
  && holiday_hours_3x <= holiday_overtime_days && holiday_hours_4x <= holiday_overtime_days * 3
297
325
  message: {id: 'Hari 0 sampai 31, jam hari libur per tarif tidak melebihi batas per hari (2x: 7 atau 8, 3x: 1, 4x: 3), tidak negatif'}
326
+ # A monthly salary is cut by at most the whole month; a daily worker is paid for the days present only.
327
+ - name: unpaid_days_range
328
+ on: save
329
+ check: "unpaid_days >= 0 && unpaid_days <= (payroll_run.workdays_per_week == 5 ? 21 : 25) && (pay_basis == 'monthly' || unpaid_days == 0)"
330
+ message: {id: 'Hari tidak dibayar hanya untuk gaji bulanan, 0 sampai 25 hari (21 untuk 5 hari kerja)'}
298
331
  # Rest-day hours climb the tiers in order (PP 35/2021 Pasal 31; audit gelombang 3 r2 R4): an hour at 3x only after a
299
332
  # full day at 2x (at least 5 hours, the shortest day of a six-day week; 8 hours in a five-day week), hours at 4x only
300
333
  # after the hour at 3x (at most 3 per day that had one).
@@ -329,6 +362,12 @@ rules:
329
362
  level: warn
330
363
  check: other_deduction == 0 || cash_advance != '' || open_advance == ''
331
364
  message: {id: 'Pekerja ini punya kasbon belum lunas, tapi potongannya tidak ditautkan ke kasbon itu'}
365
+ # PP 36/2021 Pasal 65: deductions treated as fines stay within 50% of the pay of the period (audit 101a F6).
366
+ - name: late_within_half
367
+ on: submit
368
+ level: warn
369
+ check: late_deduction * 2 <= base_pay
370
+ message: {id: 'Potongan telat lebih dari separuh gaji pokok periode ini'}
332
371
  - name: umk_warning
333
372
  on: submit
334
373
  level: warn
@@ -342,11 +381,11 @@ views:
342
381
  layout:
343
382
  - section: {id: Slip}
344
383
  columns:
345
- - [payroll_run, profile, worker, timesheet]
384
+ - [payroll_run, profile, worker, employee, timesheet]
346
385
  - [tax_year, tax_month, last_month, ptkp_status, has_tax_id]
347
386
  - section: {id: Kehadiran dan upah}
348
387
  columns:
349
- - [pay_basis, employment, days, day_rate, monthly_salary, fixed_allowance, daily_allowance]
388
+ - [pay_basis, employment, days, unpaid_days, late_min_total, day_rate, monthly_salary, fixed_allowance, daily_allowance]
350
389
  - [overtime_hours, overtime_days, overtime_rate, thr_tenure_months, other_income, other_deduction, cash_advance, open_advance]
351
390
  - section: {id: Hari libur masuk kerja}
352
391
  columns:
@@ -354,8 +393,8 @@ views:
354
393
  - [holiday_hours_2x, holiday_hours_3x, holiday_hours_4x]
355
394
  - section: {id: Penghasilan}
356
395
  columns:
357
- - [base_pay, overtime_pay, holiday_overtime_pay, allowance_pay]
358
- - [thr_pay, cash_gross]
396
+ - [unpaid_deduction, base_pay, overtime_pay, holiday_overtime_pay, allowance_pay]
397
+ - [thr_pay, late_deduction, cash_gross]
359
398
  - section: {id: BPJS}
360
399
  columns:
361
400
  - [bpjs_base, jkk, jkm, jht_employer, jp_employer, kes_employer, employer_bpjs]
@@ -1,13 +1,30 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
2
  name: payroll
3
- version: 1.2.1
3
+ version: 2.0.0
4
4
  title: {id: Penggajian, en: Payroll}
5
5
  summary:
6
6
  id: Data gaji pekerja, periode gaji, slip gaji dan tutup periode.
7
7
  en: Worker pay data, pay periods, payslips and period close.
8
8
  category: people
9
9
  icon: money-dollar-box-line
10
- # Monthly pay of outsourced workers from the attendance recap (projects.timesheet with period_to): payslips with BPJS and
11
- # PPh 21 TER, the deposits of the month, the extra employer cost on the project margin and the client invoice (wages +
12
- # BPJS + fee, or fee only). Rules and sources: docs/payroll.md.
13
- requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0, workforce: ^1.0, projects: ^1.0, invoicing: ^1.7}
10
+ # Monthly pay with BPJS and PPh 21 TER and the deposits of the month, in two kinds of payroll run (2.0):
11
+ # - client: outsourced workers of one client contract, from the attendance recap (projects.timesheet with period_to);
12
+ # the close books the extra employer cost on the project margin and drafts the client invoice (wages + BPJS + fee, or
13
+ # fee only). Needs projects, invoicing, contacts and catalogue, which jasa_proyek installs.
14
+ # - internal: the firm's own staff, no project, no client invoice. Needs none of the optional modules.
15
+ # 2.0 moved projects, invoicing, contacts and catalogue from requires to optional (breaking only for what they pulled
16
+ # in). Rules and sources: docs/payroll.md.
17
+ requires: {rangka: '>=0.5', users: ^1.0, workforce: ^1.0}
18
+ optional: {projects: ^1.0, invoicing: ^1.7, contacts: ^1.0, catalogue: ^1.0, outlets: ^1.0, attendance: ^1.0}
19
+ # What this module tells people (contract 0066 §1.1), both from flow payroll_reminder. Nothing here runs payroll.
20
+ notices:
21
+ - name: payroll_ready
22
+ label: {id: Periode gaji siap diproses, en: Payroll period ready}
23
+ description: {id: 'Periode gaji sudah lewat dan rekap absennya lengkap. Slip gaji menunggu diperiksa.'}
24
+ severity: info
25
+ to: [owner, finance_manager]
26
+ - name: payroll_due
27
+ label: {id: Tanggal bayar gaji sudah dekat, en: Pay date is near}
28
+ description: {id: 'Tanggal bayar gaji tinggal tiga hari atau kurang dan periode gajinya belum ditutup.'}
29
+ severity: warn
30
+ to: [owner, finance_manager]
@@ -24,12 +24,15 @@
24
24
  <table class="items">
25
25
  <thead><tr><th>Penghasilan</th><th class="num">Rp</th></tr></thead>
26
26
  <tbody>
27
- <tr><td>Gaji pokok</td><td class="num">{{rupiah .Doc.base_pay}}</td></tr>
27
+ {{if .Doc.unpaid_deduction}}<tr><td>Gaji pokok sebulan</td><td class="num">{{rupiah .Doc.monthly_salary}}</td></tr>
28
+ <tr><td>Tidak dibayar {{.Doc.unpaid_days}} hari</td><td class="num">-{{rupiah .Doc.unpaid_deduction}}</td></tr>
29
+ {{else}}<tr><td>Gaji pokok</td><td class="num">{{rupiah .Doc.base_pay}}</td></tr>{{end}}
28
30
  {{if .Doc.allowance_pay}}<tr><td>Tunjangan</td><td class="num">{{rupiah .Doc.allowance_pay}}</td></tr>{{end}}
29
31
  {{if .Doc.overtime_pay}}<tr><td>Lembur</td><td class="num">{{rupiah .Doc.overtime_pay}}</td></tr>{{end}}
30
32
  {{if .Doc.holiday_overtime_pay}}<tr><td>Lembur hari libur ({{.Doc.holiday_overtime_days}} hari)</td><td class="num">{{rupiah .Doc.holiday_overtime_pay}}</td></tr>{{end}}
31
33
  {{if .Doc.thr_pay}}<tr><td>THR</td><td class="num">{{rupiah .Doc.thr_pay}}</td></tr>{{end}}
32
34
  {{if .Doc.other_income}}<tr><td>Insentif</td><td class="num">{{rupiah .Doc.other_income}}</td></tr>{{end}}
35
+ {{if .Doc.late_deduction}}<tr><td>Potongan telat {{.Doc.late_min_total}} menit</td><td class="num">-{{rupiah .Doc.late_deduction}}</td></tr>{{end}}
33
36
  <tr class="total"><td>Jumlah penghasilan</td><td class="num">{{rupiah .Doc.cash_gross}}</td></tr>
34
37
  </tbody>
35
38
  </table>
@@ -49,6 +49,40 @@ fields:
49
49
  label: {id: Pembeli atau meja}
50
50
  help: {id: 'Boleh kosong. Nama pembeli, nomor meja atau nomor antrean'}
51
51
  in_list: true
52
+ # the customer of record (contacts), picked or signed up at the counter's checkout; buyer stays for a name, table or
53
+ # queue number. Shared with module loyalty (rangka-apps#102).
54
+ - {name: customer, type: link, to: customer, label: {id: Pelanggan}, help: {id: 'Boleh kosong. Pilih pelanggan terdaftar'}}
55
+ # Bill promo (module promotions): picked at the checkout with its code; the sale's rules check its window, outlet,
56
+ # code and gift lines, and flow promotion_on_sale checks a voucher's limit and a coupon's single use.
57
+ - name: promotion
58
+ type: link
59
+ to: promotion
60
+ label: {id: Promo nota}
61
+ help: {id: 'Promo untuk seluruh nota, misalnya diskon 10% minimal belanja Rp 50.000'}
62
+ depends_on: app_installed('promotions')
63
+ - name: promo_code
64
+ type: data
65
+ label: {id: Kode voucher atau kupon}
66
+ depends_on: app_installed('promotions')
67
+ # WhatsApp receipt (module whatsapp_receipt): the buyer's number and their yes, asked at the counter ("Kirim struk ke
68
+ # WhatsApp?"). Nothing is sent without the tick. wa_number is the number in one form (digits with the country code).
69
+ - name: wa_phone
70
+ type: phone
71
+ label: {id: Nomor WhatsApp pembeli}
72
+ help: {id: 'Hanya kalau pembeli mau struk dan kabar pesanannya lewat WhatsApp'}
73
+ depends_on: app_installed('whatsapp_receipt')
74
+ - name: wa_receipt
75
+ type: check
76
+ label: {id: Kirim struk ke WhatsApp}
77
+ help: {id: 'Tanya dulu ke pembeli. Struk dikirim setelah dibayar'}
78
+ default: 'false'
79
+ depends_on: app_installed('whatsapp_receipt')
80
+ - name: wa_number
81
+ type: data
82
+ label: {id: Nomor WhatsApp (seragam)}
83
+ hidden: true
84
+ depends_on: app_installed('whatsapp_receipt')
85
+ compute: "(wa_phone.trim().startsWith('+') ? ('x' + wa_phone.replace(' ', '').replace('-', '').replace('.', '').replace('(', '').replace(')', '').replace('+', '')).replace('x620', 'x62').replace('x', '') : ('x' + wa_phone.replace(' ', '').replace('-', '').replace('.', '').replace('(', '').replace(')', '').replace('+', '')).replace('x8', 'x628').replace('x00', 'x').replace('x0', 'x62').replace('x620', 'x62').replace('x', '')).matches('^[1-9][0-9]{7,14}$') ? (wa_phone.trim().startsWith('+') ? ('x' + wa_phone.replace(' ', '').replace('-', '').replace('.', '').replace('(', '').replace(')', '').replace('+', '')).replace('x620', 'x62').replace('x', '') : ('x' + wa_phone.replace(' ', '').replace('-', '').replace('.', '').replace('(', '').replace(')', '').replace('+', '')).replace('x8', 'x628').replace('x00', 'x').replace('x0', 'x62').replace('x620', 'x62').replace('x', '')) : ''"
52
86
  - name: items
53
87
  type: table
54
88
  of: pos_sale_item
@@ -67,14 +101,41 @@ fields:
67
101
  label: {id: Diskon nota}
68
102
  help: {id: 'Potongan rupiah untuk seluruh nota, setelah diskon per barang'}
69
103
  default: '0'
104
+ # Promos (module promotions): item promos are inside subtotal already (the lines' amount); a free gift line is at 0;
105
+ # the bill promo comes off the subtotal (after item promos) when it reaches the promo's minimum spend, a percent one
106
+ # up to its cap. Stacking: item promos and one bill promo add up; the cashier's manual discounts come on top and are
107
+ # the only part big_discount looks at (a promo the owner set up never waits for head office).
108
+ - {name: line_promo_total, type: currency, label: {id: Promo per barang}, depends_on: app_installed('promotions'), compute: "items.map(l, l.promo_discount).sum()"}
109
+ - {name: gift_value, type: currency, label: {id: Harga produk gratis}, depends_on: app_installed('promotions'), compute: "items.map(l, l.is_gift ? l.gross : 0).sum()"}
110
+ - name: bill_promo
111
+ type: currency
112
+ label: {id: Promo nota}
113
+ depends_on: app_installed('promotions')
114
+ # nothing off while the promo cannot apply (switched off, outside its dates or outlet, a wrong shared code), so
115
+ # the counter's total never shows a discount the payment would refuse; hours are rule promo_valid's (clock())
116
+ compute: "promotion == '' || subtotal < promotion.min_spend || !promotion.active || promotion.valid_from > date || promotion.valid_until < date || (promotion.only_outlet != '' && promotion.only_outlet != outlet) || (promotion.code_mode == 'shared' && promo_code.trim().upperAscii() != promotion.code) ? 0 : (promotion.kind == 'bill_pct' ? (promotion.max_discount > 0 ? min(promotion.max_discount, round(subtotal * promotion.pct / 100)) : round(subtotal * promotion.pct / 100)) : (promotion.kind == 'bill_off' ? min(subtotal, promotion.amount_off) : 0))"
117
+ # what the cart still lacks for the bill promo's minimum spend: the counter shows it under the order only while it is
118
+ # above 0 (its depends_on), so the cashier can tell the buyer "kurang Rp 2.400"
119
+ - name: promo_shortfall
120
+ type: currency
121
+ label: {id: Kurang belanja untuk promo}
122
+ depends_on: app_installed('promotions') && promo_shortfall > 0
123
+ compute: "promotion == '' ? 0 : max(0, promotion.min_spend - subtotal)"
124
+ - {name: promo_name, type: data, label: {id: Nama promo nota}, hidden: true, depends_on: app_installed('promotions'), compute: "promotion != '' ? promotion.promo_name : ''"}
125
+ - {name: promo_total, type: currency, label: {id: Promo}, depends_on: app_installed('promotions'), compute: line_promo_total + gift_value + bill_promo}
70
126
  - name: discount_total
71
127
  type: currency
72
128
  label: {id: Total diskon}
73
- compute: gross_total - subtotal + discount_amount
129
+ compute: gross_total - subtotal + discount_amount + bill_promo
130
+ - name: manual_discount_total
131
+ type: currency
132
+ label: {id: Diskon kasir}
133
+ help: {id: 'Diskon yang diberi kasir, di luar promo'}
134
+ compute: discount_total - promo_total
74
135
  - name: grand_total
75
136
  type: currency
76
137
  label: {id: Total}
77
- compute: subtotal - discount_amount
138
+ compute: subtotal - bill_promo - discount_amount
78
139
  in_list: true
79
140
  # Payment (table payments, rows of pos_payment): no row means exact cash; a cash row is what the buyer handed over,
80
141
  # a QRIS row is paid exactly. Change comes only out of cash, so QRIS may not exceed the total.
@@ -126,14 +187,14 @@ fields:
126
187
  type: currency
127
188
  label: {id: 'PPh final 0,5%'}
128
189
  compute: round((grand_total - ppn_in_sales) * 5 / 1000)
129
- # Cashier controls (audit kasir M5): a receipt whose discounts exceed 20% of its price waits for head office
190
+ # Cashier controls (audit kasir M5): a receipt whose manual discounts exceed 20% of its price after promos waits for head office
130
191
  # (contract 0007; the owner may always approve). A void is not held: an approved verb runs again as a requester
131
192
  # without their outlets, so the flow's own-shift check cannot run (kernel card t_7782ebb1 follow-up); voids stay
132
193
  # same day, open shift, own shift, and are counted on the shift and the dashboard.
133
194
  approvals:
134
195
  - name: big_discount
135
196
  on: submit
136
- when: "discount_total * 100 > gross_total * 20 && !('head_office' in user.roles) && !('owner' in user.roles)"
197
+ when: "manual_discount_total * 100 > (gross_total - promo_total) * 20 && !('head_office' in user.roles) && !('owner' in user.roles)"
137
198
  approvers: [head_office]
138
199
  label: {id: Persetujuan kantor pusat untuk diskon di atas 20%, en: Head office approves a discount above 20%}
139
200
  stock:
@@ -142,6 +203,11 @@ stock:
142
203
  - {lines: items, out: outlet, explode: recipe, reason: sale, cogs: cogs}
143
204
  cogs_total: cogs_total
144
205
  rules:
206
+ # a WhatsApp receipt needs a number that reads as one (module whatsapp_receipt)
207
+ - name: wa_receipt_number
208
+ on: save
209
+ check: "!app_installed('whatsapp_receipt') || !wa_receipt || wa_number != ''"
210
+ message: {id: 'Nomor WhatsApp pembeli belum benar, misalnya 0812 3456 7890'}
145
211
  # the receipt number carries the outlet code (STRK-<code>-...); head office could have emptied it since the shift
146
212
  # opened: say so when saving, not only at payment (kernel 409 numbering)
147
213
  - name: outlet_has_code
@@ -183,8 +249,65 @@ rules:
183
249
  message: {id: 'Ada barang tanpa harga jual; isi Harga jual di data barang'}
184
250
  - name: receipt_discount_range
185
251
  on: save
186
- check: discount_amount >= 0 && discount_amount <= subtotal
252
+ check: discount_amount >= 0 && discount_amount <= subtotal - bill_promo
187
253
  message: {id: Diskon nota tidak boleh negatif atau melebihi subtotal}
254
+ # Bill promo (module promotions): a bill kind, active, in its dates, days and hours now (clock(), the site's wall
255
+ # clock; rangka-os contract 0069 §3) and at this outlet. Day 1 is Monday (2024-01-01 was one).
256
+ - name: promo_is_bill
257
+ on: save
258
+ check: "promotion == '' || promotion.is_bill"
259
+ message: {id: 'Promo ini otomatis per barang; untuk nota pilih promo nota'}
260
+ - name: promo_valid
261
+ on: save
262
+ check: >-
263
+ promotion == '' || promotion.active && promotion.valid_from <= date && promotion.valid_until >= date
264
+ && (promotion.only_outlet == '' || promotion.only_outlet == outlet)
265
+ && (promotion.days == '' || promotion.days.contains(string(days_between('2024-01-01', date) % 7 + 1)))
266
+ && (promotion.time_from == '' || clock() >= promotion.time_from && clock() < promotion.time_until)
267
+ message: {id: 'Promo ini tidak berlaku di outlet, tanggal atau jam ini'}
268
+ - name: promo_min_spend
269
+ on: save
270
+ level: warn
271
+ check: "promotion == '' || subtotal >= promotion.min_spend"
272
+ message: {id: 'Belanja belum mencapai minimal promo; promo nota belum dipotong'}
273
+ - name: promo_code_needed
274
+ on: save
275
+ check: "promotion == '' || promotion.code_mode == 'none' || promotion.code_mode == '' || promo_code.trim() != ''"
276
+ message: {id: 'Masukkan kode voucher atau kupon untuk promo ini'}
277
+ - name: promo_code_shared
278
+ on: save
279
+ check: "promotion == '' || promotion.code_mode != 'shared' || promo_code.trim().upperAscii() == promotion.code"
280
+ message: {id: 'Kode voucher tidak cocok dengan promo ini'}
281
+ - name: promo_code_without_promo
282
+ on: save
283
+ check: "promo_code.trim() == '' || promotion != ''"
284
+ message: {id: 'Pilih promo nota untuk kode ini'}
285
+ # a free gift line, told apart so the cashier knows what is missing (promo_shortfall shows how much to spend)
286
+ - name: gift_needs_promo
287
+ on: save
288
+ check: "items.map(l, l.is_gift ? 1 : 0).sum() == 0 || promotion != '' && promotion.kind == 'free_gift'"
289
+ message: {id: 'Produk gratis perlu promo hadiah: pilih promonya di Promo nota, atau matikan Produk gratis promo di barisnya'}
290
+ - name: gift_min_spend
291
+ on: save
292
+ check: "items.map(l, l.is_gift ? 1 : 0).sum() == 0 || promotion == '' || promotion.kind != 'free_gift' || subtotal >= promotion.min_spend"
293
+ message: {id: 'Belanja belum mencapai minimal promo hadiah; kekurangannya tertulis di Kurang belanja untuk promo'}
294
+ - name: gift_item
295
+ on: save
296
+ check: "promotion == '' || promotion.kind != 'free_gift' || items.map(l, l.is_gift && l.item != promotion.gift_item ? 1 : 0).sum() == 0"
297
+ message: {id: 'Barang ini bukan produk gratis promo yang dipilih'}
298
+ - name: gift_qty
299
+ on: save
300
+ check: "promotion == '' || promotion.kind != 'free_gift' || items.map(l, l.is_gift ? l.stock_qty : 0).sum() <= promotion.gift_qty"
301
+ message: {id: 'Jumlah produk gratis melebihi yang diberikan promo'}
302
+ # a gift is given in the item's own unit, never a pack (audit F1: a dus of 24 is 24 gifts)
303
+ - name: gift_no_packing
304
+ on: save
305
+ check: "items.map(l, l.is_gift && l.packing != '' ? 1 : 0).sum() == 0"
306
+ message: {id: 'Produk gratis diberikan per satuan barang; kosongkan Satuan lain di baris hadiah'}
307
+ - name: line_promo_live
308
+ on: submit
309
+ check: "items.map(l, l.promotion != '' && l.promo_until != '' && l.promo_until < date ? 1 : 0).sum() == 0"
310
+ message: {id: 'Promo ini sudah tidak berlaku hari ini; hapus barangnya lalu tambahkan lagi'}
188
311
  - name: payment_positive
189
312
  on: save
190
313
  check: "payments.map(p, p.amount <= 0 ? 1 : 0).sum() == 0"
@@ -210,8 +333,12 @@ views:
210
333
  layout:
211
334
  - section: {id: Transaksi}
212
335
  columns:
213
- - [shift, outlet, date]
214
- - [buyer]
336
+ - [shift, outlet, date, customer]
337
+ - [buyer, wa_phone, wa_receipt]
338
+ - section: {id: Promo}
339
+ columns:
340
+ - [promotion]
341
+ - [promo_code]
215
342
  - section: {id: Barang}
216
343
  fields: [items]
217
344
  - section: {id: Bayar}
@@ -222,5 +349,5 @@ views:
222
349
  fields: [payments]
223
350
  - section: {id: Ringkasan}
224
351
  columns:
225
- - [gross_total, discount_total, cogs_total, margin]
226
- - [ppn_in_sales, pph_final]
352
+ - [gross_total, promo_total, line_promo_total, gift_value, bill_promo]
353
+ - [manual_discount_total, discount_total, promo_shortfall, cogs_total, margin, ppn_in_sales, pph_final]
@@ -38,9 +38,41 @@ fields:
38
38
  label: {id: Harga}
39
39
  compute: round(qty * rate)
40
40
  - {name: discount_pct, type: float, label: {id: 'Diskon %'}, default: '0'}
41
+ # Promo (module promotions, rangka-apps#103): the item's live promo (kept on the item by flow promotion_apply): the
42
+ # promo of this sale's outlet (parent.outlet, rangka-os contract 0069 §2) when the item has one, else the all-outlet
43
+ # one; never on a free gift line. Percent off the line; rupiah off per stock unit and buy X get Y per stock unit (a
44
+ # dus of 24 counts 24, free units at the item's unit price, never more than the line). The cashier's manual
45
+ # discount_pct applies after the promo and counts as a manual discount (big_discount).
46
+ - name: promo_slot
47
+ type: data
48
+ label: {id: Sumber promo}
49
+ hidden: true
50
+ depends_on: app_installed('promotions')
51
+ compute: "is_gift ? '' : (item.promo_o != '' && item.promo_o_outlet == parent.outlet ? 'o' : (item.promo != '' && (item.promo_outlet == '' || item.promo_outlet == parent.outlet) ? 'a' : ''))"
52
+ - {name: promotion, type: data, label: {id: Promo}, depends_on: app_installed('promotions'), compute: "promo_slot == 'o' ? item.promo_o : (promo_slot == 'a' ? item.promo : '')"}
53
+ - {name: promo_name, type: data, label: {id: Nama promo}, hidden: true, depends_on: app_installed('promotions'), compute: "promo_slot == 'o' ? item.promo_o_name : (promo_slot == 'a' ? item.promo_name : '')"}
54
+ - {name: promo_kind, type: data, label: {id: Jenis promo}, hidden: true, depends_on: app_installed('promotions'), compute: "promo_slot == 'o' ? item.promo_o_kind : (promo_slot == 'a' ? item.promo_kind : '')"}
55
+ - {name: promo_pct, type: float, label: {id: 'Promo %'}, hidden: true, depends_on: app_installed('promotions'), compute: "promo_slot == 'o' ? item.promo_o_pct : (promo_slot == 'a' ? item.promo_pct : 0)"}
56
+ - {name: promo_off, type: currency, label: {id: Potongan promo per satuan}, hidden: true, depends_on: app_installed('promotions'), compute: "promo_slot == 'o' ? item.promo_o_off : (promo_slot == 'a' ? item.promo_off : 0)"}
57
+ - {name: promo_buy, type: int, label: {id: Promo beli}, hidden: true, depends_on: app_installed('promotions'), compute: "promo_slot == 'o' ? item.promo_o_buy : (promo_slot == 'a' ? item.promo_buy : 0)"}
58
+ - {name: promo_get, type: int, label: {id: Promo gratis}, hidden: true, depends_on: app_installed('promotions'), compute: "promo_slot == 'o' ? item.promo_o_get : (promo_slot == 'a' ? item.promo_get : 0)"}
59
+ # the promo's last day as it was when the line was computed: rule line_promo_live reads it (a rule sees the rows'
60
+ # stored values, not their links)
61
+ - {name: promo_until, type: date, label: {id: Promo sampai}, hidden: true, depends_on: app_installed('promotions'), compute: "promo_slot == 'o' ? item.promo_o_until : (promo_slot == 'a' ? item.promo_until : null)"}
62
+ - name: promo_discount
63
+ type: currency
64
+ label: {id: Potongan promo}
65
+ depends_on: app_installed('promotions')
66
+ compute: "promotion == '' ? 0 : (promo_kind == 'pct' ? round(gross * promo_pct / 100) : (promo_kind == 'off' ? min(gross, round(stock_qty * promo_off)) : (promo_kind == 'buy_get' && promo_buy + promo_get > 0 ? min(gross, round(int(stock_qty / (promo_buy + promo_get)) * promo_get * item.rate)) : 0)))"
67
+ # the free gift of a bill promo (kind free_gift): a line of the gift item at 0, its stock and cost still out
68
+ - name: is_gift
69
+ type: check
70
+ label: {id: Produk gratis promo}
71
+ default: 'false'
72
+ depends_on: app_installed('promotions')
41
73
  - name: amount
42
74
  type: currency
43
75
  label: {id: Jumlah}
44
- compute: round(qty * rate * (100 - discount_pct) / 100)
76
+ compute: "is_gift ? 0 : (promo_discount == 0 ? round(qty * rate * (100 - discount_pct) / 100) : round((gross - promo_discount) * (100 - discount_pct) / 100))"
45
77
  - {name: note, type: data, label: {id: Catatan}, help: {id: 'Misalnya kurang manis, tanpa es'}}
46
78
  - {name: cogs, type: currency, label: {id: Harga pokok}, read_only: true, hidden_for: [cashier, outlet_staff]}