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

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 (220) 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 +4 -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/apps/pembukuan/app.rk +3 -0
  11. package/template/base/connectors/midtrans/connector.rk +249 -0
  12. package/template/base/connectors/midtrans/fixtures/charge_gopay.json +34 -0
  13. package/template/base/connectors/midtrans/fixtures/charge_qris.json +23 -0
  14. package/template/base/connectors/midtrans/fixtures/charge_va.json +20 -0
  15. package/template/base/connectors/midtrans/fixtures/create_snap.json +4 -0
  16. package/template/base/connectors/midtrans/fixtures/expect.json +88 -0
  17. package/template/base/connectors/midtrans/fixtures/get_status.json +15 -0
  18. package/template/base/connectors/midtrans/fixtures/payment_notified.json +28 -0
  19. package/template/base/connectors/midtrans/fixtures/payment_notified_challenge.json +24 -0
  20. package/template/base/connectors/midtrans/fixtures/payment_notified_expire.json +24 -0
  21. package/template/base/connectors/midtrans/fixtures/payment_notified_other_amount.json +28 -0
  22. package/template/base/connectors/midtrans/fixtures/payment_notified_partial_refund.json +34 -0
  23. package/template/base/connectors/midtrans/fixtures/payment_notified_pending.json +31 -0
  24. package/template/base/connectors/midtrans/fixtures/payment_notified_refund.json +34 -0
  25. package/template/base/connectors/midtrans/fixtures/payment_notified_relabelled.json +28 -0
  26. package/template/base/connectors/midtrans/fixtures/payment_notified_va.json +32 -0
  27. package/template/base/connectors/midtrans/fixtures/signature_vector.txt +3 -0
  28. package/template/base/connectors/midtrans/mock/midtrans_mock.py +335 -0
  29. package/template/base/connectors/rangka_whatsapp/README.md +105 -0
  30. package/template/base/connectors/rangka_whatsapp/connector.rk +141 -0
  31. package/template/base/connectors/rangka_whatsapp/fixtures/expect.json +9 -0
  32. package/template/base/connectors/rangka_whatsapp/fixtures/message_received.json +1 -0
  33. package/template/base/connectors/rangka_whatsapp/fixtures/message_status.json +1 -0
  34. package/template/base/connectors/rangka_whatsapp/fixtures/message_status_refused.json +1 -0
  35. package/template/base/connectors/rangka_whatsapp/fixtures/opted_out.json +1 -0
  36. package/template/base/connectors/rangka_whatsapp/fixtures/send_template.json +1 -0
  37. package/template/base/connectors/rangka_whatsapp/fixtures/send_template_duplicate.json +1 -0
  38. package/template/base/connectors/rangka_whatsapp/fixtures/set_opt_out.json +1 -0
  39. package/template/base/connectors/rangka_whatsapp/mock/rangka_whatsapp_mock.py +354 -0
  40. package/template/base/connectors/shopee/connector.rk +360 -0
  41. package/template/base/connectors/shopee/fixtures/expect.json +119 -0
  42. package/template/base/connectors/shopee/fixtures/get_models.json +52 -0
  43. package/template/base/connectors/shopee/fixtures/get_order_detail.json +396 -0
  44. package/template/base/connectors/shopee/fixtures/get_settlement.json +90 -0
  45. package/template/base/connectors/shopee/fixtures/get_tracking.json +13 -0
  46. package/template/base/connectors/shopee/fixtures/list_items.json +29 -0
  47. package/template/base/connectors/shopee/fixtures/list_orders.json +31 -0
  48. package/template/base/connectors/shopee/fixtures/list_settlements.json +15 -0
  49. package/template/base/connectors/shopee/fixtures/order_changed.json +101 -0
  50. package/template/base/connectors/shopee/fixtures/order_changed_cancelled.json +72 -0
  51. package/template/base/connectors/shopee/fixtures/order_changed_completed.json +101 -0
  52. package/template/base/connectors/shopee/fixtures/order_changed_in_cancel.json +72 -0
  53. package/template/base/connectors/shopee/fixtures/order_changed_unpaid.json +71 -0
  54. package/template/base/connectors/shopee/fixtures/order_settled.json +92 -0
  55. package/template/base/connectors/shopee/fixtures/push_received.json +12 -0
  56. package/template/base/connectors/shopee/fixtures/push_received_tracking.json +11 -0
  57. package/template/base/connectors/shopee/fixtures/update_stock.json +15 -0
  58. package/template/base/connectors/shopee/mock/shopee_mock.py +894 -0
  59. package/template/base/connectors/tiktok_shop/connector.rk +300 -0
  60. package/template/base/connectors/tiktok_shop/fixtures/expect.json +105 -0
  61. package/template/base/connectors/tiktok_shop/fixtures/get_order_detail.json +136 -0
  62. package/template/base/connectors/tiktok_shop/fixtures/get_settlement.json +83 -0
  63. package/template/base/connectors/tiktok_shop/fixtures/get_tracking.json +28 -0
  64. package/template/base/connectors/tiktok_shop/fixtures/list_orders.json +242 -0
  65. package/template/base/connectors/tiktok_shop/fixtures/list_products.json +77 -0
  66. package/template/base/connectors/tiktok_shop/fixtures/list_settlements.json +22 -0
  67. package/template/base/connectors/tiktok_shop/fixtures/list_shops.json +17 -0
  68. package/template/base/connectors/tiktok_shop/fixtures/order_changed.json +129 -0
  69. package/template/base/connectors/tiktok_shop/fixtures/order_changed_cancelled.json +81 -0
  70. package/template/base/connectors/tiktok_shop/fixtures/order_changed_completed.json +106 -0
  71. package/template/base/connectors/tiktok_shop/fixtures/order_changed_on_hold.json +104 -0
  72. package/template/base/connectors/tiktok_shop/fixtures/order_changed_tokopedia.json +106 -0
  73. package/template/base/connectors/tiktok_shop/fixtures/order_changed_unpaid.json +79 -0
  74. package/template/base/connectors/tiktok_shop/fixtures/order_settled.json +73 -0
  75. package/template/base/connectors/tiktok_shop/fixtures/update_stock.json +6 -0
  76. package/template/base/connectors/tiktok_shop/fixtures/webhook_received.json +12 -0
  77. package/template/base/connectors/tiktok_shop/fixtures/webhook_received_cancellation.json +13 -0
  78. package/template/base/connectors/tiktok_shop/mock/tiktok_shop_mock.py +819 -0
  79. package/template/base/connectors/whatsapp_business/connector.rk +3 -1
  80. package/template/base/connectors/whatsapp_business/templates.md +13 -1
  81. package/template/base/modules/accounting/flows/gl_asset_disposal_post.rk +68 -0
  82. package/template/base/modules/accounting/flows/gl_asset_disposal_reverse.rk +194 -0
  83. package/template/base/modules/accounting/flows/gl_depreciation_run_post.rk +43 -0
  84. package/template/base/modules/accounting/flows/gl_depreciation_run_reverse.rk +36 -0
  85. package/template/base/modules/accounting/flows/gl_fixed_asset_post.rk +51 -0
  86. package/template/base/modules/accounting/flows/gl_fixed_asset_reverse.rk +194 -0
  87. package/template/base/modules/accounting/flows/gl_vendor_bill_post.rk +2 -2
  88. package/template/base/modules/accounting/models/gl_entry.rk +2 -0
  89. package/template/base/modules/accounting/module.rk +2 -2
  90. package/template/base/modules/attendance/flows/attendance_missing_digest.rk +30 -0
  91. package/template/base/modules/attendance/flows/attendance_period_on_cancel.rk +15 -0
  92. package/template/base/modules/attendance/flows/attendance_period_on_submit.rk +60 -0
  93. package/template/base/modules/attendance/flows/staff_attendance_cancel_guard.rk +14 -0
  94. package/template/base/modules/attendance/flows/staff_attendance_guard_created.rk +16 -0
  95. package/template/base/modules/attendance/flows/staff_attendance_guard_submitted.rk +37 -0
  96. package/template/base/modules/attendance/flows/staff_attendance_guard_updated.rk +14 -0
  97. package/template/base/modules/attendance/models/attendance_period.rk +62 -0
  98. package/template/base/modules/attendance/models/attendance_summary.rk +37 -0
  99. package/template/base/modules/attendance/models/staff_attendance.rk +281 -0
  100. package/template/base/modules/attendance/models/staff_attendance_guard.rk +50 -0
  101. package/template/base/modules/attendance/module.rk +18 -0
  102. package/template/base/modules/attendance/screens/absen_outlet.rk +22 -0
  103. package/template/base/modules/catalogue/models/item.rk +69 -0
  104. package/template/base/modules/catalogue/module.rk +1 -1
  105. package/template/base/modules/contacts/models/customer.rk +43 -19
  106. package/template/base/modules/contacts/module.rk +1 -1
  107. package/template/base/modules/coretax/module.rk +1 -1
  108. package/template/base/modules/coretax/print/coretax_faktur.rk +3 -2
  109. package/template/base/modules/coretax/print/coretax_faktur.xml +3 -1
  110. package/template/base/modules/coretax/print/rekap_ppn.html +9 -7
  111. package/template/base/modules/courses/flows/charge_invoice_on_submit.rk +15 -0
  112. package/template/base/modules/courses/module.rk +1 -1
  113. package/template/base/modules/courses/screens/absen_kelas.rk +1 -0
  114. package/template/base/modules/fixed_assets/flows/asset_disposal_on_cancel.rk +14 -0
  115. package/template/base/modules/fixed_assets/flows/asset_disposal_on_submit.rk +21 -0
  116. package/template/base/modules/fixed_assets/flows/asset_from_vendor_bill.rk +41 -0
  117. package/template/base/modules/fixed_assets/flows/depreciation_run_fill.rk +28 -0
  118. package/template/base/modules/fixed_assets/flows/depreciation_run_monthly.rk +36 -0
  119. package/template/base/modules/fixed_assets/flows/depreciation_run_on_cancel.rk +30 -0
  120. package/template/base/modules/fixed_assets/flows/depreciation_run_on_submit.rk +34 -0
  121. package/template/base/modules/fixed_assets/flows/fixed_asset_on_cancel.rk +24 -0
  122. package/template/base/modules/fixed_assets/flows/fixed_asset_on_submit.rk +69 -0
  123. package/template/base/modules/fixed_assets/flows/fixed_assets_setup.rk +29 -0
  124. package/template/base/modules/fixed_assets/flows/opening_balance_asset_guard.rk +15 -0
  125. package/template/base/modules/fixed_assets/flows/vendor_bill_asset_guard.rk +14 -0
  126. package/template/base/modules/fixed_assets/imports/asset_list.rk +22 -0
  127. package/template/base/modules/fixed_assets/models/asset_bill_line.rk +24 -0
  128. package/template/base/modules/fixed_assets/models/asset_book.rk +83 -0
  129. package/template/base/modules/fixed_assets/models/asset_category.rk +54 -0
  130. package/template/base/modules/fixed_assets/models/asset_disposal.rk +97 -0
  131. package/template/base/modules/fixed_assets/models/asset_guard.rk +90 -0
  132. package/template/base/modules/fixed_assets/models/depreciation_line.rk +13 -0
  133. package/template/base/modules/fixed_assets/models/depreciation_run.rk +65 -0
  134. package/template/base/modules/fixed_assets/models/fixed_asset.rk +165 -0
  135. package/template/base/modules/fixed_assets/models/fixed_asset_setting.rk +34 -0
  136. package/template/base/modules/fixed_assets/module.rk +30 -0
  137. package/template/base/modules/fixed_assets/print/fixed_asset_register.html +45 -0
  138. package/template/base/modules/fixed_assets/print/fixed_asset_register.rk +17 -0
  139. package/template/base/modules/invoicing/flows/invoice_due_digest.rk +45 -7
  140. package/template/base/modules/invoicing/models/sales_invoice_item.rk +4 -1
  141. package/template/base/modules/invoicing/module.rk +15 -2
  142. package/template/base/modules/kitchen/screens/dapur.rk +1 -0
  143. package/template/base/modules/outlets/models/outlet.rk +69 -0
  144. package/template/base/modules/outlets/module.rk +1 -1
  145. package/template/base/modules/payments/flows/payment_from_midtrans.rk +85 -0
  146. package/template/base/modules/payments/flows/payment_refund_from_midtrans.rk +22 -0
  147. package/template/base/modules/payments/models/payment.rk +2 -1
  148. package/template/base/modules/payments/module.rk +1 -1
  149. package/template/base/modules/payroll/flows/payroll_close_on_cancel.rk +8 -5
  150. package/template/base/modules/payroll/flows/payroll_close_on_submit.rk +8 -5
  151. package/template/base/modules/payroll/flows/payroll_reminder.rk +106 -0
  152. package/template/base/modules/payroll/flows/payroll_run_overlap_guard_created.rk +5 -3
  153. package/template/base/modules/payroll/flows/payroll_run_overlap_guard_updated.rk +5 -3
  154. package/template/base/modules/payroll/flows/payslip_from_recap.rk +1 -1
  155. package/template/base/modules/payroll/imports/payroll_profile_list.rk +27 -0
  156. package/template/base/modules/payroll/models/payroll_close.rk +10 -6
  157. package/template/base/modules/payroll/models/payroll_run.rk +64 -15
  158. package/template/base/modules/payroll/models/payslip.rk +48 -9
  159. package/template/base/modules/payroll/module.rk +22 -5
  160. package/template/base/modules/payroll/print/payslip.html +4 -1
  161. package/template/base/modules/pos/models/pos_sale.rk +136 -9
  162. package/template/base/modules/pos/models/pos_sale_item.rk +33 -1
  163. package/template/base/modules/pos/module.rk +5 -3
  164. package/template/base/modules/pos/print/pos_receipt.html +7 -3
  165. package/template/base/modules/pos/screens/kasir.rk +7 -2
  166. package/template/base/modules/procurement/flows/reorder_draft_po.rk +57 -0
  167. package/template/base/modules/procurement/models/vendor_bill.rk +21 -2
  168. package/template/base/modules/procurement/module.rk +11 -2
  169. package/template/base/modules/projects/screens/absen.rk +1 -0
  170. package/template/base/modules/promotions/flows/promo_code_batch_on_submit.rk +26 -0
  171. package/template/base/modules/promotions/flows/promotion_apply.rk +110 -0
  172. package/template/base/modules/promotions/flows/promotion_apply_on_create.rk +110 -0
  173. package/template/base/modules/promotions/flows/promotion_apply_on_delete.rk +111 -0
  174. package/template/base/modules/promotions/flows/promotion_apply_on_update.rk +110 -0
  175. package/template/base/modules/promotions/flows/promotion_on_sale.rk +95 -0
  176. package/template/base/modules/promotions/flows/promotion_on_sale_cancel.rk +43 -0
  177. package/template/base/modules/promotions/models/promo_code.rk +27 -0
  178. package/template/base/modules/promotions/models/promo_code_batch.rk +36 -0
  179. package/template/base/modules/promotions/models/promo_guard.rk +44 -0
  180. package/template/base/modules/promotions/models/promotion.rk +197 -0
  181. package/template/base/modules/promotions/models/promotion_ledger.rk +35 -0
  182. package/template/base/modules/promotions/module.rk +20 -0
  183. package/template/base/modules/rental/models/rental_unit.rk +13 -3
  184. package/template/base/modules/rental/module.rk +2 -2
  185. package/template/base/modules/rental/screens/alat_keluar.rk +1 -0
  186. package/template/base/modules/rental/screens/alat_kembali.rk +1 -0
  187. package/template/base/modules/rental/screens/jadwal_alat.rk +1 -0
  188. package/template/base/modules/stock/flows/stock_low_alert.rk +65 -0
  189. package/template/base/modules/stock/flows/stock_negative_alert.rk +14 -5
  190. package/template/base/modules/stock/models/stock_reorder.rk +34 -0
  191. package/template/base/modules/stock/module.rk +17 -2
  192. package/template/base/modules/subscriptions/screens/catat_tagih.rk +1 -0
  193. package/template/base/modules/subscriptions/screens/rute_tagih.rk +1 -0
  194. package/template/base/modules/users/flows/summary_daily.rk +83 -0
  195. package/template/base/modules/users/flows/summary_monthly.rk +83 -0
  196. package/template/base/modules/users/flows/summary_weekly.rk +83 -0
  197. package/template/base/modules/users/models/business_summary.rk +67 -0
  198. package/template/base/modules/users/models/summary_setting.rk +35 -0
  199. package/template/base/modules/users/models/user.rk +11 -3
  200. package/template/base/modules/users/module.rk +21 -2
  201. package/template/base/modules/users/roles/employee.rk +8 -0
  202. package/template/base/modules/users/roles/outlet_supervisor.rk +7 -0
  203. package/template/base/modules/whatsapp/flows/whatsapp_customer_opt_out.rk +16 -0
  204. package/template/base/modules/whatsapp/flows/whatsapp_customer_opt_out_new.rk +17 -0
  205. package/template/base/modules/whatsapp/flows/whatsapp_message_status.rk +24 -0
  206. package/template/base/modules/whatsapp/flows/whatsapp_opted_out.rk +26 -0
  207. package/template/base/modules/whatsapp/models/whatsapp_message.rk +99 -0
  208. package/template/base/modules/whatsapp/models/whatsapp_opt_out.rk +44 -0
  209. package/template/base/modules/whatsapp/module.rk +23 -0
  210. package/template/base/modules/whatsapp_booking/flows/whatsapp_booking_tomorrow.rk +48 -0
  211. package/template/base/modules/whatsapp_booking/module.rk +13 -0
  212. package/template/base/modules/whatsapp_order_ready/flows/whatsapp_pickup_on_sale.rk +19 -0
  213. package/template/base/modules/whatsapp_order_ready/flows/whatsapp_ticket_ready.rk +40 -0
  214. package/template/base/modules/whatsapp_order_ready/models/whatsapp_pickup.rk +22 -0
  215. package/template/base/modules/whatsapp_order_ready/module.rk +14 -0
  216. package/template/base/modules/whatsapp_receipt/flows/whatsapp_receipt_on_sale.rk +43 -0
  217. package/template/base/modules/whatsapp_receipt/module.rk +13 -0
  218. package/template/base/modules/whatsapp_reminder/flows/whatsapp_invoice_overdue.rk +64 -0
  219. package/template/base/modules/whatsapp_reminder/module.rk +15 -0
  220. package/template/base/modules/workforce/imports/worker_list.rk +4 -1
@@ -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]}
@@ -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: pos
3
- version: 1.2.0
3
+ version: 1.4.0
4
4
  title: {id: Kasir, en: Point of sale}
5
5
  summary:
6
6
  id: Kasir di browser dengan sesi kas, transaksi dan tutup sesi per outlet.
@@ -17,6 +17,8 @@ icon: shopping-basket-line
17
17
  # (cancel, then amend without the returned items) only on its own day while its shift is open.
18
18
  # Sales of an outlet run either here or through outlet_sales (Jalur A), never both: an outlet whose sales_source is
19
19
  # 'kasir' takes no daily form or POS file, and a sale needs that source when outlet_sales is installed.
20
- requires: {rangka: '>=0.5', users: ^1.2, catalogue: ^1.3, outlets: ^1.5, stock: ^1.2}
20
+ # A sale may name its customer (contacts), and with module promotions it takes item promos by itself and a bill promo,
21
+ # voucher code or free gift picked at the counter's checkout (rangka-os contract 0069, rangka-apps#103).
22
+ requires: {rangka: '>=0.5', users: ^1.2, contacts: ^1.4, catalogue: ^1.5, outlets: ^1.5, stock: ^1.2}
21
23
  hooks: [stock.reverse_moves]
22
- optional: {accounting: ^1.2, outlet_sales: ^1.1}
24
+ optional: {accounting: ^1.2, outlet_sales: ^1.1, promotions: ^1.0}
@@ -25,16 +25,20 @@ body { font-size: 8.5pt; }
25
25
  <div class="row"><span>Struk</span><span>{{.Doc.name}}</span></div>
26
26
  <div class="row"><span>Tanggal</span><span>{{date .Doc.date}}</span></div>
27
27
  {{with .Doc.buyer}}<div class="row"><span>Pembeli</span><span>{{.}}</span></div>{{end}}
28
+ {{with .Links.customer}}{{with .customer_name}}<div class="row"><span>Pelanggan</span><span>{{.}}</span></div>{{end}}{{end}}
28
29
  <div class="rule"></div>
29
30
  {{range $row := .Doc.items}}
30
31
  <div class="line">
31
32
  <div>{{if $row.description}}{{$row.description}}{{else}}{{$row.item}}{{end}}</div>
32
- <div class="row sub"><span>{{number $row.qty}} x {{rupiah $row.rate}}{{if $row.discount_pct}} (-{{number $row.discount_pct}}%){{end}}</span><span class="num">{{rupiah $row.amount}}</span></div>
33
+ <div class="row sub"><span>{{number $row.qty}} x {{rupiah $row.rate}}{{if $row.discount_pct}} (-{{number $row.discount_pct}}%){{end}}</span><span class="num">{{if $row.is_gift}}Gratis{{else}}{{rupiah $row.amount}}{{end}}</span></div>
34
+ {{if $row.promo_discount}}<div class="row sub"><span>Promo {{$row.promo_name}}</span><span class="num">-{{rupiah $row.promo_discount}}</span></div>{{end}}
33
35
  </div>
34
36
  {{end}}
35
37
  <div class="rule"></div>
36
- {{if .Doc.discount_amount}}<div class="row"><span>Subtotal</span><span class="num">{{rupiah .Doc.subtotal}}</span></div>
37
- <div class="row"><span>Diskon nota</span><span class="num">-{{rupiah .Doc.discount_amount}}</span></div>{{end}}
38
+ {{if or .Doc.discount_amount .Doc.bill_promo}}<div class="row"><span>Subtotal</span><span class="num">{{rupiah .Doc.subtotal}}</span></div>{{end}}
39
+ {{if .Doc.bill_promo}}<div class="row"><span>Promo nota {{.Doc.promo_name}}</span><span class="num">-{{rupiah .Doc.bill_promo}}</span></div>{{end}}
40
+ {{if .Doc.discount_amount}}<div class="row"><span>Diskon nota</span><span class="num">-{{rupiah .Doc.discount_amount}}</span></div>{{end}}
41
+ {{if .Doc.promo_total}}<div class="row muted"><span>Hemat dari promo</span><span class="num">{{rupiah .Doc.promo_total}}</span></div>{{end}}
38
42
  <div class="row big"><span>Total</span><span class="num">{{rupiah .Doc.grand_total}}</span></div>
39
43
  {{if .Doc.ppn_in_sales}}<div class="row muted"><span>Termasuk PPN</span><span class="num">{{rupiah .Doc.ppn_in_sales}}</span></div>{{end}}
40
44
  {{range $p := .Doc.payments}}<div class="row"><span>{{if eq (printf "%v" $p.method) "qris"}}QRIS{{with $p.ref}} {{.}}{{end}}{{else}}Tunai{{end}}</span><span class="num">{{rupiah $p.amount}}</span></div>
@@ -4,6 +4,7 @@
4
4
  name: kasir
5
5
  type: counter
6
6
  label: {id: Kasir, en: Cashier}
7
+ description: {id: 'Layani pembeli di sini: pilih barang, terima tunai atau QRIS, lalu cetak struk.'}
7
8
  icon: wallet
8
9
  roles: [cashier, head_office]
9
10
  device: tablet
@@ -22,10 +23,14 @@ counter:
22
23
  document:
23
24
  model: pos_sale
24
25
  lines: items
25
- line: {item: item, qty: qty, price: rate, note: note}
26
+ # amount: the model's line amount shows a promo (struck price) or a free gift; flag: the cashier marks the gift line
27
+ line: {item: item, qty: qty, price: rate, note: note, amount: amount, flag: is_gift}
26
28
  total: grand_total
27
29
  change: change_amount
28
- summary: [gross_total, discount_total, grand_total]
30
+ summary: [gross_total, promo_total, manual_discount_total, promo_shortfall, grand_total]
31
+ # rangka-os contract 0069: filled before paying; the promo picker lists live bill promos only. Fields of module
32
+ # promotions are left out when it is not installed (their depends_on).
33
+ checkout: [customer, {field: promotion, filter: "is_bill && live"}, promo_code]
29
34
  set: {date: "today()"}
30
35
  payments: {table: payments, method: method, amount: amount, ref: ref, methods: [cash, qris]}
31
36
  session:
@@ -0,0 +1,57 @@
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, ten minutes after stock/stock_low_alert), and by the owner from the flow
3
+ # list: the open stock_reorder rows that have a supplier (item.default_vendor) and are not on a draft yet become
4
+ # DRAFT purchase orders, one per supplier and outlet, and the purchasing role is told (notice reorder_draft) with a
5
+ # link to each draft. The flow never submits, approves or sends anything: a person checks quantities and prices and
6
+ # submits the draft, where the site's own approval policy (custom/purchase_order.rk) applies as for any other PO.
7
+ # - quantity: item.reorder_qty, else up to the reorder level (stock_reorder.order_qty, fixed when the row opened);
8
+ # - price: the outlet's average cost of the item when the row opened (0 when it was never received);
9
+ # - one episode gives one draft: the row is ticked `drafted`, so deleting the draft does not make a new one until
10
+ # the stock recovered and fell again. An item without a supplier is only in the stock_low notice.
11
+ # A site without the stock module has no rows: the flow is skipped (if:).
12
+ # At most 500 rows per run.
13
+ name: reorder_draft_po
14
+ label: {id: Draft pesanan pembelian dari stok di bawah batas minimum, en: Draft purchase orders for low stock}
15
+ description: {id: 'Tiap pagi, barang di bawah batas minimum yang punya pemasok utama dimasukkan ke draft pesanan pembelian per pemasok. Draft tidak pernah diajukan otomatis.'}
16
+ schedule: '40 6 * * *'
17
+ if: app_installed('stock')
18
+ steps:
19
+ - find_all: stock_reorder
20
+ where: "open && !drafted && vendor != '' && order_qty > 0"
21
+ sort: item
22
+ limit: 500
23
+ as: need
24
+ - find_all: vendor
25
+ if: size(need) > 0
26
+ as: vendors
27
+ - find_all: outlet
28
+ if: size(need) > 0
29
+ as: outlets
30
+ - for_each: "size(need) > 0 ? vendors.filter(v, need.exists(r, r.vendor == v.name)) : []"
31
+ as: v
32
+ do:
33
+ - for_each: "outlets.filter(o, need.exists(r, r.vendor == v.name && r.outlet == o.name))"
34
+ as: o
35
+ do:
36
+ - create: purchase_order
37
+ set:
38
+ vendor: v.name
39
+ outlet: o.name
40
+ notes: "'Dibuat otomatis dari stok di bawah batas minimum. Periksa jumlah dan harga sebelum diajukan.'"
41
+ items: "need.filter(r, r.vendor == v.name && r.outlet == o.name).map(r, {'item': r.item, 'qty': r.order_qty, 'rate': r.rate})"
42
+ as: po
43
+ - for_each: "need.filter(r, r.vendor == v.name && r.outlet == o.name)"
44
+ as: row
45
+ do:
46
+ - update: row
47
+ set: {drafted: 'true', draft_ref: po.name}
48
+ - notify: purchasing_manager
49
+ notice: reorder_draft
50
+ channel: email
51
+ record: po
52
+ outlet: o.name
53
+ id: "'po:' + po.name"
54
+ title: 'Draft pesanan pembelian untuk {v.vendor_name}'
55
+ template: >-
56
+ {need.filter(r, r.vendor == v.name && r.outlet == o.name).size()} barang di {o.outlet_name} di bawah batas stok minimum.
57
+ Draft {po.name} sudah disiapkan. Periksa jumlah dan harganya, lalu ajukan kalau sudah benar. Draft ini tidak dikirim ke pemasok sebelum kamu ajukan.