@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
@@ -0,0 +1,95 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Runs inside a sale's submit (the payment), as the cashier, also for a sale a paired device sends later (contract
3
+ # 0058 §10 turns the sale's own rules into exceptions there, but a record this flow writes still refuses). So the bill
4
+ # promo is checked again here: active, in its dates, outlet and hours (clock() at the sale's time), its code (a shared
5
+ # voucher's code, a single-use coupon of this promo), and a free gift line (the gift promo, its minimum spend, item,
6
+ # quantity in stock units, no pack). A voucher's uses are counted per promo and a coupon's per code, as post rows minus
7
+ # reverse rows of promotion_ledger read under the ledger's flow lock (contract 0025), so two sales racing for the last
8
+ # use or one coupon run one after the other and the second is refused (promo_guard), rolling its payment back.
9
+ # Then one ledger row per promo used: the bill promo (bill_promo + the free gift's price) and each item promo that
10
+ # still exists (the sum of its lines' promo_discount).
11
+ name: promotion_on_sale
12
+ label: {id: 'Transaksi kasir dibayar: cek dan catat promo'}
13
+ on: pos_sale.submitted
14
+ if: app_installed('pos')
15
+ steps:
16
+ - if: "event.promotion != ''"
17
+ then:
18
+ - find: promotion
19
+ where: name == event.promotion
20
+ as: p
21
+ - if: >-
22
+ p == null || !p.active || p.valid_from > event.date || p.valid_until < event.date
23
+ || (p.only_outlet != '' && p.only_outlet != event.outlet)
24
+ || (p.days != '' && !p.days.contains(string(days_between('2024-01-01', event.date) % 7 + 1)))
25
+ || (p.time_from != '' && (clock() < p.time_from || clock() >= p.time_until))
26
+ create: promo_guard
27
+ set: {reason: "'promo_ended'", document: event.name}
28
+ - if: "p.code_mode == 'shared' && event.promo_code.trim().upperAscii() != p.code"
29
+ create: promo_guard
30
+ set: {reason: "'code_unknown'", document: event.name}
31
+ - if: "event.bill_promo + event.gift_value > 0 && p.code_mode == 'shared' && p.max_uses > 0"
32
+ then:
33
+ # every use of this voucher so far, whatever code was typed, under the ledger's lock (contract 0025)
34
+ - find_all: promotion_ledger
35
+ where: promotion == event.promotion
36
+ as: uses
37
+ - if: "uses.filter(u, u.entry == 'post').size() - uses.filter(u, u.entry == 'reverse').size() >= p.max_uses"
38
+ create: promo_guard
39
+ set: {reason: "'code_limit'", document: event.name}
40
+ - if: "p.code_mode == 'unique'"
41
+ then:
42
+ - find: promo_code
43
+ where: "promotion == event.promotion && code == event.promo_code.trim().upperAscii()"
44
+ as: c
45
+ - if: c == null
46
+ create: promo_guard
47
+ set: {reason: "'code_unknown'", document: event.name}
48
+ - find_all: promotion_ledger
49
+ where: "promotion == event.promotion && code == event.promo_code.trim().upperAscii()"
50
+ as: used
51
+ - if: "used.filter(u, u.entry == 'post').size() - used.filter(u, u.entry == 'reverse').size() > 0"
52
+ create: promo_guard
53
+ set: {reason: "'code_used'", document: event.name}
54
+ - create: promotion_ledger
55
+ if: "event.bill_promo + event.gift_value > 0"
56
+ set:
57
+ promotion: event.promotion
58
+ sale: event.name
59
+ sale_outlet: event.outlet
60
+ date: event.date
61
+ code: "p.code_mode == 'none' || p.code_mode == '' ? '' : event.promo_code.trim().upperAscii()"
62
+ amount: event.bill_promo + event.gift_value
63
+ entry: "'post'"
64
+ entry_key: "event.name + '|' + event.promotion + '|post'"
65
+ # a free gift line, checked again for a sale whose rules a device's replay overrode
66
+ - if: "event.items.filter(l, l.is_gift).size() > 0"
67
+ then:
68
+ - find: promotion
69
+ if: "event.promotion != ''"
70
+ where: name == event.promotion
71
+ as: gp
72
+ - if: >-
73
+ event.promotion == '' || gp == null || gp.kind != 'free_gift' || event.subtotal < gp.min_spend
74
+ || event.items.filter(l, l.is_gift && (l.item != gp.gift_item || l.packing != '')).size() > 0
75
+ || event.items.filter(l, l.is_gift).map(l, l.stock_qty).sum() > gp.gift_qty
76
+ create: promo_guard
77
+ set: {reason: "'gift_invalid'", document: event.name}
78
+ # one row per item promo still there: its first line stands for all of its lines
79
+ - for_each: "event.items.filter(l, l.promotion != '' && l.promo_discount > 0 && event.items.filter(y, y.promotion == l.promotion && y.idx < l.idx).size() == 0)"
80
+ as: l
81
+ do:
82
+ - find: promotion
83
+ where: name == l.promotion
84
+ as: lpr
85
+ - create: promotion_ledger
86
+ if: lpr != null
87
+ set:
88
+ promotion: l.promotion
89
+ sale: event.name
90
+ sale_outlet: event.outlet
91
+ date: event.date
92
+ code: "''"
93
+ amount: "event.items.filter(y, y.promotion == l.promotion).map(y, y.promo_discount).sum()"
94
+ entry: "'post'"
95
+ entry_key: "event.name + '|' + l.promotion + '|post'"
@@ -0,0 +1,43 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # A voided sale gives its promos back: one reverse row (the amount negated) for each post row the sale wrote, so a
3
+ # voucher use and a coupon are free again and the promo's cost shrinks. The amounts come from the cancelled sale
4
+ # itself (the same expressions as promotion_on_sale), since the ledger's money is hidden from the cashier. An amended
5
+ # sale posts again under its own name when it is paid.
6
+ name: promotion_on_sale_cancel
7
+ label: {id: 'Transaksi kasir dibatalkan: kembalikan promo'}
8
+ on: pos_sale.cancelled
9
+ if: app_installed('pos')
10
+ steps:
11
+ - if: "event.promotion != ''"
12
+ then:
13
+ - find: promotion_ledger
14
+ where: "entry_key == event.name + '|' + event.promotion + '|post'"
15
+ as: bp
16
+ - create: promotion_ledger
17
+ if: bp != null
18
+ set:
19
+ promotion: event.promotion
20
+ sale: event.name
21
+ sale_outlet: event.outlet
22
+ date: event.date
23
+ code: bp.code
24
+ amount: 0 - (event.bill_promo + event.gift_value)
25
+ entry: "'reverse'"
26
+ entry_key: "event.name + '|' + event.promotion + '|reverse'"
27
+ - for_each: "event.items.filter(l, l.promotion != '' && l.promo_discount > 0 && event.items.filter(y, y.promotion == l.promotion && y.idx < l.idx).size() == 0)"
28
+ as: l
29
+ do:
30
+ - find: promotion_ledger
31
+ where: "entry_key == event.name + '|' + l.promotion + '|post'"
32
+ as: lp
33
+ - create: promotion_ledger
34
+ if: lp != null
35
+ set:
36
+ promotion: l.promotion
37
+ sale: event.name
38
+ sale_outlet: event.outlet
39
+ date: event.date
40
+ code: "''"
41
+ amount: "0 - event.items.filter(y, y.promotion == l.promotion).map(y, y.promo_discount).sum()"
42
+ entry: "'reverse'"
43
+ entry_key: "event.name + '|' + l.promotion + '|reverse'"
@@ -0,0 +1,27 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # A single-use coupon of a promo with code_mode unique, made by a promo_code_batch (flow promo_code_batch_on_submit):
3
+ # prefix + 8 characters of random_code() (rangka-os contract 0069 §3), so a code cannot be guessed from another. Whether
4
+ # it was used is in promotion_ledger (a post row with this code and no reverse row): flow promotion_on_sale checks it
5
+ # under the ledger's lock, so two sales with one coupon at the same moment cannot both pass, and a void frees it.
6
+ name: promo_code
7
+ label: {id: Kupon, en: Coupon}
8
+ icon: tag
9
+ naming: KPN-{######}
10
+ title_field: code
11
+ permissions:
12
+ # head office's batch submit creates the coupons (flow promo_code_batch_on_submit); every field is read_only, so a
13
+ # coupon is never typed by hand
14
+ - {role: head_office, read: true, create: true, export: true, print: true}
15
+ # flow promotion_on_sale reads the coupon inside the cashier's sale
16
+ - {role: cashier, read: true}
17
+ fields:
18
+ - {name: promotion, type: link, to: promotion, label: {id: Promo}, read_only: true, in_list: true}
19
+ # hidden from the cashier (audit F3): unissued coupons cannot be listed and used for a cash sale; flow
20
+ # promotion_on_sale still finds the code the buyer brings
21
+ - {name: code, type: data, label: {id: Kode kupon}, read_only: true, unique: true, in_list: true, hidden_for: [cashier]}
22
+ - {name: batch, type: link, to: promo_code_batch, label: {id: Kiriman kupon}, read_only: true, in_list: true}
23
+ views:
24
+ list:
25
+ columns: [name, code, promotion, batch]
26
+ filters: [promotion, batch]
27
+ sort: -name
@@ -0,0 +1,36 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # A batch of single-use coupons for a promo with code_mode unique: submitting it makes count coupons (flow
3
+ # promo_code_batch_on_submit), each prefix + 8 random characters. Export the list to print or send the codes.
4
+ name: promo_code_batch
5
+ label: {id: Kiriman kupon, en: Coupon batch}
6
+ icon: tag
7
+ is_submittable: true
8
+ naming: KPB-{####}
9
+ title_field: promotion
10
+ permissions:
11
+ - {role: head_office, read: true, create: true, write: true, delete: true, submit: true, export: true, print: true}
12
+ fields:
13
+ - {name: promotion, type: link, to: promotion, label: {id: Promo}, required: true, in_list: true}
14
+ - {name: count, type: int, label: {id: Jumlah kupon}, default: '20', required: true, in_list: true}
15
+ - name: prefix
16
+ type: data
17
+ label: {id: Awalan kode}
18
+ help: {id: 'Boleh kosong. 0 sampai 6 huruf besar atau angka, misalnya HUT'}
19
+ - {name: note, type: text, label: {id: Catatan}}
20
+ rules:
21
+ - name: unique_promo
22
+ on: save
23
+ check: promotion.code_mode == 'unique'
24
+ message: {id: 'Kupon sekali pakai hanya untuk promo dengan Kode Kupon sekali pakai'}
25
+ - name: count_range
26
+ on: save
27
+ check: count >= 1 && count <= 1000
28
+ message: {id: Jumlah kupon 1 sampai 1000 per kiriman}
29
+ - name: prefix_format
30
+ on: save
31
+ check: "prefix == '' || prefix.matches('^[A-Z0-9]{1,6}$')"
32
+ message: {id: 'Awalan kode 1 sampai 6 huruf besar atau angka, tanpa spasi'}
33
+ views:
34
+ list:
35
+ columns: [name, promotion, count, status]
36
+ sort: -name
@@ -0,0 +1,44 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # Never stored: a promo flow refuses a sale by creating one (as pos_guard does), and the rule of its reason fails
3
+ # with the cashier's message, so the sale's submit rolls back with its stock moves and number.
4
+ name: promo_guard
5
+ label: {id: Penjaga promo, en: Promotion guard}
6
+ icon: check
7
+ naming: PPG-{######}
8
+ title_field: reason
9
+ permissions:
10
+ - {role: head_office, create: true}
11
+ - {role: cashier, create: true}
12
+ fields:
13
+ - name: reason
14
+ type: select
15
+ label: {id: Alasan}
16
+ required: true
17
+ options:
18
+ - {value: code_used, label: {id: Kupon sudah dipakai}}
19
+ - {value: code_unknown, label: {id: Kupon tidak dikenal}}
20
+ - {value: code_limit, label: {id: Kuota voucher habis}}
21
+ - {value: promo_ended, label: {id: Promo tidak berlaku}}
22
+ - {value: gift_invalid, label: {id: Produk gratis tidak sesuai}}
23
+ - {name: document, type: data, label: {id: Dokumen}}
24
+ rules:
25
+ - name: code_used
26
+ on: save
27
+ check: reason != 'code_used'
28
+ message: {id: 'Kode kupon ini sudah dipakai'}
29
+ - name: code_unknown
30
+ on: save
31
+ check: reason != 'code_unknown'
32
+ message: {id: 'Kode kupon ini tidak ada untuk promo yang dipilih'}
33
+ - name: code_limit
34
+ on: save
35
+ check: reason != 'code_limit'
36
+ message: {id: 'Kuota voucher ini sudah habis'}
37
+ - name: promo_ended
38
+ on: save
39
+ check: reason != 'promo_ended'
40
+ message: {id: 'Promo ini tidak berlaku di outlet, tanggal atau jam ini'}
41
+ - name: gift_invalid
42
+ on: save
43
+ check: reason != 'gift_invalid'
44
+ message: {id: 'Produk gratis tidak sesuai promo hadiah: cek promo, minimal belanja, barang dan jumlahnya'}
@@ -0,0 +1,197 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # A promo the owner sets up. Item kinds apply by themselves at the counter: flow promotion_apply writes the live one
3
+ # with the highest priority onto each item in scope (item.promo*), and a sale line computes its promo from there.
4
+ # Bill kinds are picked at the counter's checkout and checked by the sale's rules (window, outlet, minimum spend,
5
+ # code). live is kept by promotion_apply (every 5 minutes and on every save): active, today within the dates and days,
6
+ # and now within the hours. Two one-outlet promos on one item at once: only the higher priority one applies there (one
7
+ # outlet slot per item). The outlet field is only_outlet, not outlet: the cashier role is scoped by outlet (contract
8
+ # 0010 §5), and a promo of every outlet (empty) must stay visible to every cashier.
9
+ name: promotion
10
+ label: {id: Promo, en: Promotion}
11
+ icon: tag
12
+ naming: PRM-{####}
13
+ title_field: promo_name
14
+ permissions:
15
+ - {role: head_office, read: true, create: true, write: true, delete: true, export: true, print: true}
16
+ # the cashier picks a bill promo at the counter; flows read the promo inside the sale
17
+ - {role: cashier, read: true}
18
+ - {role: outlet_staff, read: true}
19
+ fields:
20
+ - name: promo_name
21
+ type: data
22
+ label: {id: Nama promo}
23
+ help: {id: 'Tercetak di struk, misalnya Happy hour kopi'}
24
+ required: true
25
+ in_list: true
26
+ - name: kind
27
+ type: select
28
+ label: {id: Jenis promo}
29
+ required: true
30
+ in_list: true
31
+ chip: true
32
+ options:
33
+ - {value: item_pct, label: {id: Diskon persen per barang}}
34
+ - {value: item_off, label: {id: Potongan rupiah per barang}}
35
+ - {value: buy_get, label: {id: Beli X gratis Y}}
36
+ - {value: bill_pct, label: {id: Diskon persen nota}}
37
+ - {value: bill_off, label: {id: Potongan rupiah nota}}
38
+ - {value: free_gift, label: {id: Gratis produk}}
39
+ - name: is_bill
40
+ type: check
41
+ label: {id: Promo nota}
42
+ hidden: true
43
+ compute: "kind == 'bill_pct' || kind == 'bill_off' || kind == 'free_gift'"
44
+ - name: scope
45
+ type: select
46
+ label: {id: Berlaku untuk}
47
+ default: "'item'"
48
+ depends_on: "!is_bill"
49
+ options:
50
+ - {value: item, label: {id: Satu barang}}
51
+ - {value: category, label: {id: Satu kategori}}
52
+ - {name: item, type: link, to: item, label: {id: Barang}, depends_on: "!is_bill && scope == 'item'"}
53
+ - {name: category, type: link, to: item_category, label: {id: Kategori}, depends_on: "!is_bill && scope == 'category'"}
54
+ - {name: pct, type: float, label: {id: 'Diskon %'}, default: '0', depends_on: "kind == 'item_pct' || kind == 'bill_pct'"}
55
+ - name: amount_off
56
+ type: currency
57
+ label: {id: Potongan}
58
+ help: {id: 'Per barang untuk potongan per barang, sekali untuk potongan nota'}
59
+ default: '0'
60
+ depends_on: "kind == 'item_off' || kind == 'bill_off'"
61
+ - name: max_discount
62
+ type: currency
63
+ label: {id: Maksimal potongan}
64
+ help: {id: 'Isi 0 kalau tanpa batas'}
65
+ default: '0'
66
+ depends_on: "kind == 'bill_pct'"
67
+ - {name: buy_qty, type: int, label: {id: Beli}, default: '0', depends_on: "kind == 'buy_get'"}
68
+ - {name: get_qty, type: int, label: {id: Gratis}, default: '0', depends_on: "kind == 'buy_get'"}
69
+ - {name: gift_item, type: link, to: item, label: {id: Produk gratis}, depends_on: "kind == 'free_gift'"}
70
+ - {name: gift_qty, type: int, label: {id: Jumlah gratis}, default: '1', depends_on: "kind == 'free_gift'"}
71
+ - name: min_spend
72
+ type: currency
73
+ label: {id: Minimal belanja}
74
+ help: {id: 'Dihitung dari subtotal setelah promo per barang. Isi 0 kalau tanpa minimal'}
75
+ default: '0'
76
+ depends_on: is_bill
77
+ - name: only_outlet
78
+ type: link
79
+ to: outlet
80
+ label: {id: Outlet}
81
+ help: {id: 'Kosongkan kalau berlaku di semua outlet'}
82
+ in_list: true
83
+ depends_on: app_installed('outlets')
84
+ - {name: valid_from, type: date, label: {id: Berlaku dari}, required: true, default: today(), in_list: true}
85
+ - {name: valid_until, type: date, label: {id: Berlaku sampai}, required: true, in_list: true}
86
+ - name: days
87
+ type: data
88
+ label: {id: Hari}
89
+ help: {id: 'Angka hari dipisah koma, 1 Senin sampai 7 Minggu, misalnya 1,2,3,4,5. Kosongkan untuk setiap hari'}
90
+ - {name: time_from, type: data, label: {id: Jam mulai}, help: {id: 'Misalnya 14:00. Kosongkan untuk sepanjang hari'}}
91
+ - {name: time_until, type: data, label: {id: Jam selesai}, help: {id: 'Misalnya 16:00'}}
92
+ - name: code_mode
93
+ type: select
94
+ label: {id: Kode}
95
+ default: "'none'"
96
+ depends_on: is_bill
97
+ options:
98
+ - {value: none, label: {id: Tanpa kode}}
99
+ - {value: shared, label: {id: Satu kode bersama}}
100
+ - {value: unique, label: {id: Kupon sekali pakai}}
101
+ - name: code
102
+ type: data
103
+ label: {id: Kode voucher}
104
+ help: {id: '4 sampai 16 huruf besar atau angka, misalnya HEMAT10'}
105
+ unique: true
106
+ depends_on: "code_mode == 'shared'"
107
+ # the buyer brings the code: a cashier, outlet staff or a paired device never reads it (audit F3); the sale's
108
+ # rules and flows still check it, so a shared voucher needs the connection
109
+ hidden_for: [cashier, outlet_staff]
110
+ - name: max_uses
111
+ type: int
112
+ label: {id: Batas pemakaian}
113
+ help: {id: 'Isi 0 kalau tanpa batas'}
114
+ default: '0'
115
+ depends_on: "code_mode == 'shared'"
116
+ - name: priority
117
+ type: int
118
+ label: {id: Prioritas}
119
+ help: {id: 'Kalau dua promo kena satu barang, angka lebih besar yang dipakai'}
120
+ default: '0'
121
+ - name: channel
122
+ type: select
123
+ label: {id: Dipakai di}
124
+ default: "'kasir'"
125
+ options:
126
+ - {value: kasir, label: {id: Kasir}}
127
+ - {value: invoice, label: {id: Faktur}}
128
+ - {value: both, label: {id: Kasir dan faktur}}
129
+ - {name: active, type: check, label: {id: Aktif}, default: 'true', in_list: true, in_filter: true}
130
+ - name: live
131
+ type: check
132
+ label: {id: Sedang berlaku}
133
+ help: {id: 'Diperbarui sistem tiap 5 menit: aktif, di rentang tanggal, hari dan jamnya'}
134
+ read_only: true
135
+ in_list: true
136
+ rules:
137
+ - name: kind_fields
138
+ on: save
139
+ check: >-
140
+ (kind != 'item_pct' && kind != 'bill_pct' || pct > 0 && pct <= 100)
141
+ && (kind != 'item_off' && kind != 'bill_off' || amount_off > 0)
142
+ && (kind != 'buy_get' || buy_qty >= 1 && get_qty >= 1)
143
+ && (kind != 'free_gift' || gift_item != '' && gift_qty >= 1)
144
+ message: {id: 'Lengkapi isian jenis promo ini: persen 1 sampai 100, potongan lebih dari 0, beli dan gratis minimal 1, atau produk gratis'}
145
+ - name: item_scope
146
+ on: save
147
+ check: "is_bill || scope == 'item' && item != '' || scope == 'category' && category != ''"
148
+ message: {id: 'Pilih barang atau kategori yang kena promo'}
149
+ - name: dates_order
150
+ on: save
151
+ check: valid_until >= valid_from
152
+ message: {id: Tanggal selesai tidak boleh sebelum tanggal mulai}
153
+ - name: days_format
154
+ on: save
155
+ check: "days == '' || days.matches('^[1-7](,[1-7])*$')"
156
+ message: {id: 'Hari ditulis angka 1 sampai 7 dipisah koma, misalnya 1,2,3,4,5'}
157
+ - name: hours
158
+ on: save
159
+ check: >-
160
+ (time_from == '' && time_until == '')
161
+ || (time_from.matches('^[0-2][0-9]:[0-5][0-9]$') && time_until.matches('^[0-2][0-9]:[0-5][0-9]$') && time_from < time_until)
162
+ message: {id: 'Jam ditulis seperti 14:00, dan jam mulai sebelum jam selesai'}
163
+ - name: code_only_bill
164
+ on: save
165
+ check: "code_mode == 'none' || code_mode == '' || is_bill"
166
+ message: {id: 'Kode voucher atau kupon hanya untuk promo nota'}
167
+ - name: code_format
168
+ on: save
169
+ check: "code_mode != 'shared' || code.matches('^[A-Z0-9]{4,16}$')"
170
+ message: {id: 'Kode voucher 4 sampai 16 huruf besar atau angka, tanpa spasi'}
171
+ - name: invoice_item_pct
172
+ on: save
173
+ check: "channel == 'kasir' || channel == '' || kind == 'item_pct'"
174
+ message: {id: 'Di faktur hanya diskon persen per barang yang bisa dipakai'}
175
+ - {name: not_negative, on: save, check: "max_discount >= 0 && min_spend >= 0 && max_uses >= 0", message: {id: 'Angka promo tidak boleh negatif'}}
176
+ views:
177
+ list:
178
+ columns: [name, promo_name, kind, only_outlet, valid_from, valid_until, active, live]
179
+ filters: [kind, active, live, only_outlet]
180
+ sort: -name
181
+ form:
182
+ layout:
183
+ - section: {id: Promo}
184
+ columns:
185
+ - [promo_name, kind, channel]
186
+ - [active, live, priority]
187
+ - section: {id: Isi promo}
188
+ columns:
189
+ - [scope, item, category, pct, amount_off, max_discount]
190
+ - [buy_qty, get_qty, gift_item, gift_qty, min_spend]
191
+ - section: {id: Kapan dan di mana}
192
+ columns:
193
+ - [valid_from, valid_until, only_outlet]
194
+ - [days, time_from, time_until]
195
+ - section: {id: Kode}
196
+ columns:
197
+ - [code_mode, code, max_uses]
@@ -0,0 +1,35 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # What promos cost, one row per promo used on a paid sale (flow promotion_on_sale) and a negated row when the sale is
3
+ # voided (promotion_on_sale_cancel). Append-only (contract 0026): rows are never edited or deleted. A voucher's uses
4
+ # and a coupon's state are counted here (post rows minus reverse rows), under the flow read lock of contract 0025.
5
+ # The outlet field is sale_outlet, not outlet: the cashier's flow must count every outlet's uses of a shared voucher,
6
+ # and the cashier role is scoped by outlet. The cashier reads rows only for that count; the money is hidden from it.
7
+ name: promotion_ledger
8
+ label: {id: Pemakaian promo, en: Promotion use}
9
+ icon: history
10
+ naming: PRL-{YYYY}-{######}
11
+ append_only: true
12
+ permissions:
13
+ # create: the flows of a void or a coupon batch run as whoever started them; nobody creates a row by hand (append_only)
14
+ - {role: head_office, read: true, create: true, export: true}
15
+ - {role: cashier, read: true, create: true}
16
+ fields:
17
+ - {name: promotion, type: link, to: promotion, label: {id: Promo}, required: true, in_list: true}
18
+ - {name: sale, type: data, label: {id: Struk}, in_list: true}
19
+ - {name: sale_outlet, type: link, to: outlet, label: {id: Outlet}, in_list: true}
20
+ - {name: date, type: date, label: {id: Tanggal}, in_list: true}
21
+ - {name: code, type: data, label: {id: Kode voucher atau kupon}, index: true}
22
+ - {name: amount, type: currency, label: {id: Biaya promo}, in_list: true, hidden_for: [cashier]}
23
+ - name: entry
24
+ type: select
25
+ label: {id: Catatan}
26
+ required: true
27
+ options:
28
+ - {value: post, label: {id: Dipakai}}
29
+ - {value: reverse, label: {id: Dibatalkan}}
30
+ - {name: entry_key, type: data, label: {id: Kunci}, unique: true, hidden: true}
31
+ views:
32
+ list:
33
+ columns: [name, date, promotion, sale, sale_outlet, amount, entry]
34
+ filters: [promotion, sale_outlet, entry]
35
+ sort: -name
@@ -0,0 +1,20 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
+ name: promotions
3
+ version: 1.0.0
4
+ title: {id: Promo, en: Promotions}
5
+ summary:
6
+ id: Promo diskon, beli X gratis Y, voucher dan kupon di kasir.
7
+ en: Discounts, buy X get Y, vouchers and coupons at the counter.
8
+ category: sales
9
+ icon: price-tag-3-line
10
+ # Owner-defined promotions (rangka-apps#103). Item promos (percent, rupiah off per unit, buy X get Y) are written onto
11
+ # the items they cover by flow promotion_apply while they are live (dates, days, hours), so a sale line computes its
12
+ # promo from the item like its price, also on an offline device (rangka-os contract 0058 §10). Bill promos (percent
13
+ # with a cap, rupiah off, a free gift) are picked at the counter's checkout (rangka-os contract 0069), optionally with
14
+ # a shared voucher code (a use limit) or a single-use coupon from a generated batch; flow promotion_on_sale checks the
15
+ # code and the limit under the ledger's lock and writes promotion_ledger, the promo's cost per sale. The books need no
16
+ # new account: a promo lowers the sale's grand_total, which the accounting module posts net. Invoices take an item
17
+ # promo of channel invoice or both as the default line discount (module invoicing).
18
+ # outlets is optional: a services site (invoices only, no outlets) can use invoice promos
19
+ requires: {rangka: '>=0.5', users: ^1.2, catalogue: ^1.5}
20
+ optional: {outlets: ^1.5, pos: ^1.4, invoicing: ^1.13}
@@ -8,13 +8,16 @@ title_field: code
8
8
  # its serial number. An item with "Serah terima per unit" on (rental_item.track_units) goes out and comes back by
9
9
  # unit: the checkout and the return list which units, in what condition (checklist). Where the unit is (state,
10
10
  # booking, last documents) is written only by the flows of this module (rental_checkout_on_submit and the others);
11
- # the condition is also editable by hand, so a unit repaired or found again can go out again.
11
+ # the condition is also editable by hand, so a unit repaired or found again can go out again. With the fixed_assets
12
+ # module, `asset` is the fixed asset this unit is (written by that module's flows when the asset is submitted or
13
+ # cancelled), so its cost and depreciation are read per unit.
12
14
  permissions:
13
15
  - {role: finance_manager, read: true, create: true, write: true, export: true, print: true}
14
16
  # write: the checkout and return flows of whoever submits or cancels them update the unit (state fields read_only)
15
17
  - {role: sales_manager, read: true, create: true, write: true, export: true}
16
18
  - {role: rental_staff, read: true, write: true, export: true}
17
- - {role: head_office, read: true, export: true}
19
+ # write: only through the fixed_assets flows, which link the unit to its asset when head office submits one
20
+ - {role: head_office, read: true, write: true, export: true}
18
21
  fields:
19
22
  - {name: rental_item, type: link, to: rental_item, label: {id: Alat}, required: true, in_list: true}
20
23
  - name: code
@@ -53,6 +56,13 @@ fields:
53
56
  - {name: last_checkout, type: link, to: rental_checkout, label: {id: Alat keluar terakhir}, read_only: true}
54
57
  - {name: last_return, type: link, to: rental_return, label: {id: Alat kembali terakhir}, read_only: true}
55
58
  - {name: active, type: check, label: {id: Masih dipakai}, default: 'true'}
59
+ - name: asset
60
+ type: link
61
+ to: fixed_asset
62
+ label: {id: Aset tetap}
63
+ read_only: true
64
+ depends_on: app_installed('fixed_assets')
65
+ peek: [asset_name, acquisition_date]
56
66
  - {name: notes, type: text, label: {id: Catatan}}
57
67
  rules:
58
68
  # A unit out with a booking stays a unit of the booked item until it comes back (audit 8 Nov L2): moving it to another
@@ -71,7 +81,7 @@ views:
71
81
  - section: {id: Unit}
72
82
  columns:
73
83
  - [rental_item, code, serial_no, active]
74
- - [condition, state, booking]
84
+ - [condition, state, booking, asset]
75
85
  - section: {id: Riwayat}
76
86
  columns:
77
87
  - [last_checkout]
@@ -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: rental
3
- version: 1.2.0
3
+ version: 1.3.0
4
4
  title: {id: Sewa alat, en: Equipment rental}
5
5
  summary:
6
6
  id: Sewa alat dengan jadwal tanpa bentrok, alat keluar dan kembali.
@@ -22,4 +22,4 @@ icon: tools-line
22
22
  # The data matches the handover slot of contract 0030: document rental_checkout / rental_return, rows units {unit,
23
23
  # condition}, scan by rental_unit.code, photos photo, signature signature by signed_by, print the BAST, submit.
24
24
  requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0, invoicing: ^1.0}
25
- optional: {accounting: ^1.0}
25
+ optional: {accounting: ^1.0, fixed_assets: ^1.0}
@@ -2,6 +2,7 @@
2
2
  name: alat_keluar
3
3
  type: handover
4
4
  label: {id: Serah alat keluar, en: Equipment out}
5
+ description: {id: 'Serahkan alat ke penyewa: pindai alat, foto kondisinya, lalu minta tanda tangan.'}
5
6
  icon: truck
6
7
  # Equipment goes out with proof (contract 0030 §2 handover, WS8): scan each unit (rental_unit.code), mark its
7
8
  # condition, at least one photo, the renter signs, submit, print the BAST. Opened from jadwal_alat, the new draft gets
@@ -2,6 +2,7 @@
2
2
  name: alat_kembali
3
3
  type: handover
4
4
  label: {id: Terima alat kembali, en: Equipment back}
5
+ description: {id: 'Terima alat yang kembali: pindai alat, catat kondisinya, foto, lalu minta tanda tangan.'}
5
6
  icon: undo
6
7
  # Equipment comes back with proof (contract 0030 §2 handover): scan each unit, mark its condition (Hilang for a lost
7
8
  # one), photos of the damage, the renter signs. The warehouse only saves the checklist (submit: false): the damage
@@ -2,6 +2,7 @@
2
2
  name: jadwal_alat
3
3
  type: route
4
4
  label: {id: Jadwal alat hari ini, en: Today's equipment}
5
+ description: {id: 'Alat yang keluar dan kembali hari ini; buka satu untuk serah keluar atau terima kembali.'}
5
6
  icon: calendar
6
7
  # The warehouse's list of the day (plans/layar-kerja.md §3 #6-7): bookings whose equipment goes out today (or is
7
8
  # overdue to go out) and those due back today or late. Each opens the handover screen with the booking prefilled
@@ -0,0 +1,65 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Every morning at 06:30 (scheduler.timezone), and by the owner from the flow list: balances below their item's
3
+ # reorder level (item.reorder_level > 0) are compared with the open stock_reorder rows.
4
+ # - a row whose balance is no longer below its item's level (or whose item is no longer watched) is closed;
5
+ # - a balance below the level without an open row gets one, with the figures of today;
6
+ # - head office is told once, about the balances that are new today (notice stock_low). A balance that stays low
7
+ # tells nobody again until it recovered and fell once more.
8
+ # Nothing is ordered here: procurement/reorder_draft_po turns the open rows into draft purchase orders.
9
+ # `marks` is read before the rows are closed and opened, so the filters below see yesterday's state.
10
+ # At most 500 balances (the first 500 by item) per run; every open row is read: a business with more below-level balances
11
+ # hears about the rest on a later morning, once the first ones recovered.
12
+ name: stock_low_alert
13
+ label: {id: Kabari stok di bawah batas minimum, en: Low stock alert}
14
+ description: {id: 'Tiap pagi, barang yang stoknya baru turun di bawah batas minimum dikabarkan ke kantor pusat. Sekali saja sampai stoknya pulih.'}
15
+ schedule: '30 6 * * *'
16
+ steps:
17
+ - find_all: stock_balance
18
+ where: "item.reorder_level > 0 && item.active && qty < item.reorder_level"
19
+ sort: item
20
+ limit: 500
21
+ as: low
22
+ # every open row, no limit: a row missed here would get a second open row and a second draft (audit owner-automation-pack
23
+ # R1). Open rows are at most one per balance, and the loop below allows 2000.
24
+ - find_all: stock_reorder
25
+ where: open
26
+ as: marks
27
+ # each open row is checked against its own balance and item, not against `low`: `low` stops at 500 balances, and a
28
+ # balance outside it is not back above its level (audit owner-automation-pack 3)
29
+ - for_each: marks
30
+ as: m
31
+ do:
32
+ - {find: stock_balance, where: name == m.balance, as: mb}
33
+ - {find: item, where: name == m.item, as: mi}
34
+ - if: "mb == null || mi == null || !mi.active || mi.reorder_level <= 0 || mb.qty >= mi.reorder_level"
35
+ update: m
36
+ set: {open: 'false'}
37
+ - for_each: "low.filter(b, !marks.exists(m, m.balance == b.name))"
38
+ as: b
39
+ do:
40
+ - {find: item, where: name == b.item, as: it}
41
+ - create: stock_reorder
42
+ set:
43
+ balance: b.name
44
+ outlet: b.outlet
45
+ item: b.item
46
+ alerted_on: today()
47
+ qty: b.qty
48
+ level: it.reorder_level
49
+ order_qty: "it.reorder_qty > 0 ? it.reorder_qty : it.reorder_level - b.qty"
50
+ rate: b.avg_cost
51
+ vendor: it.default_vendor
52
+ open: 'true'
53
+ drafted: 'false'
54
+ as: mk
55
+ # `it` and `mk` are the last item and row of the loop above: the notice names one item and links to its row
56
+ - if: "low.filter(b, !marks.exists(m, m.balance == b.name)).size() > 0"
57
+ notify: head_office
58
+ notice: stock_low
59
+ channel: email
60
+ record: mk
61
+ id: "'low:' + mk.name"
62
+ title: '{low.filter(b, !marks.exists(m, m.balance == b.name)).size()} barang di bawah batas stok minimum'
63
+ template: >-
64
+ Stok {it.item_name} tinggal {mk.qty} (batas minimum {mk.level}){low.filter(b, !marks.exists(m, m.balance == b.name)).size() > 1 ? ', dan ' + string(low.filter(b, !marks.exists(m, m.balance == b.name)).size() - 1) + ' barang lain juga baru turun di bawah batas' : ''}.
65
+ Buka daftar "Stok di bawah batas minimum" untuk melihat semuanya.