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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/absen_karyawan/app.rk +37 -0
  3. package/template/base/apps/absen_karyawan/dashboards/absen_hari_ini.rk +20 -0
  4. package/template/base/apps/absen_karyawan/dashboards/absen_karyawan_saya.rk +14 -0
  5. package/template/base/apps/absen_karyawan/dashboards/rekap_absen_karyawan.rk +12 -0
  6. package/template/base/apps/jasa_proyek/app.rk +1 -1
  7. package/template/base/apps/kasir/app.rk +5 -1
  8. package/template/base/apps/kasir/dashboards/kasir_ringkas.rk +4 -0
  9. package/template/base/apps/kasir/skills/rangka-app-kasir/SKILL.md +20 -0
  10. package/template/base/connectors/email/connector.rk +144 -0
  11. package/template/base/connectors/email/fixtures/email_received.json +33 -0
  12. package/template/base/connectors/email/fixtures/email_received_reply.json +31 -0
  13. package/template/base/connectors/email/fixtures/expect.json +20 -0
  14. package/template/base/connectors/email/fixtures/fetch_email.json +66 -0
  15. package/template/base/connectors/email/fixtures/send_email.json +4 -0
  16. package/template/base/connectors/midtrans/connector.rk +249 -0
  17. package/template/base/connectors/midtrans/fixtures/charge_gopay.json +34 -0
  18. package/template/base/connectors/midtrans/fixtures/charge_qris.json +23 -0
  19. package/template/base/connectors/midtrans/fixtures/charge_va.json +20 -0
  20. package/template/base/connectors/midtrans/fixtures/create_snap.json +4 -0
  21. package/template/base/connectors/midtrans/fixtures/expect.json +88 -0
  22. package/template/base/connectors/midtrans/fixtures/get_status.json +15 -0
  23. package/template/base/connectors/midtrans/fixtures/payment_notified.json +28 -0
  24. package/template/base/connectors/midtrans/fixtures/payment_notified_challenge.json +24 -0
  25. package/template/base/connectors/midtrans/fixtures/payment_notified_expire.json +24 -0
  26. package/template/base/connectors/midtrans/fixtures/payment_notified_other_amount.json +28 -0
  27. package/template/base/connectors/midtrans/fixtures/payment_notified_partial_refund.json +34 -0
  28. package/template/base/connectors/midtrans/fixtures/payment_notified_pending.json +31 -0
  29. package/template/base/connectors/midtrans/fixtures/payment_notified_refund.json +34 -0
  30. package/template/base/connectors/midtrans/fixtures/payment_notified_relabelled.json +28 -0
  31. package/template/base/connectors/midtrans/fixtures/payment_notified_va.json +32 -0
  32. package/template/base/connectors/midtrans/fixtures/signature_vector.txt +3 -0
  33. package/template/base/connectors/midtrans/mock/midtrans_mock.py +335 -0
  34. package/template/base/connectors/rangka_whatsapp/README.md +105 -0
  35. package/template/base/connectors/rangka_whatsapp/connector.rk +141 -0
  36. package/template/base/connectors/rangka_whatsapp/fixtures/expect.json +9 -0
  37. package/template/base/connectors/rangka_whatsapp/fixtures/message_received.json +1 -0
  38. package/template/base/connectors/rangka_whatsapp/fixtures/message_status.json +1 -0
  39. package/template/base/connectors/rangka_whatsapp/fixtures/message_status_refused.json +1 -0
  40. package/template/base/connectors/rangka_whatsapp/fixtures/opted_out.json +1 -0
  41. package/template/base/connectors/rangka_whatsapp/fixtures/send_template.json +1 -0
  42. package/template/base/connectors/rangka_whatsapp/fixtures/send_template_duplicate.json +1 -0
  43. package/template/base/connectors/rangka_whatsapp/fixtures/set_opt_out.json +1 -0
  44. package/template/base/connectors/rangka_whatsapp/mock/rangka_whatsapp_mock.py +354 -0
  45. package/template/base/connectors/shopee/connector.rk +360 -0
  46. package/template/base/connectors/shopee/fixtures/expect.json +119 -0
  47. package/template/base/connectors/shopee/fixtures/get_models.json +52 -0
  48. package/template/base/connectors/shopee/fixtures/get_order_detail.json +396 -0
  49. package/template/base/connectors/shopee/fixtures/get_settlement.json +90 -0
  50. package/template/base/connectors/shopee/fixtures/get_tracking.json +13 -0
  51. package/template/base/connectors/shopee/fixtures/list_items.json +29 -0
  52. package/template/base/connectors/shopee/fixtures/list_orders.json +31 -0
  53. package/template/base/connectors/shopee/fixtures/list_settlements.json +15 -0
  54. package/template/base/connectors/shopee/fixtures/order_changed.json +101 -0
  55. package/template/base/connectors/shopee/fixtures/order_changed_cancelled.json +72 -0
  56. package/template/base/connectors/shopee/fixtures/order_changed_completed.json +101 -0
  57. package/template/base/connectors/shopee/fixtures/order_changed_in_cancel.json +72 -0
  58. package/template/base/connectors/shopee/fixtures/order_changed_unpaid.json +71 -0
  59. package/template/base/connectors/shopee/fixtures/order_settled.json +92 -0
  60. package/template/base/connectors/shopee/fixtures/push_received.json +12 -0
  61. package/template/base/connectors/shopee/fixtures/push_received_tracking.json +11 -0
  62. package/template/base/connectors/shopee/fixtures/update_stock.json +15 -0
  63. package/template/base/connectors/shopee/mock/shopee_mock.py +894 -0
  64. package/template/base/connectors/tiktok_shop/connector.rk +300 -0
  65. package/template/base/connectors/tiktok_shop/fixtures/expect.json +105 -0
  66. package/template/base/connectors/tiktok_shop/fixtures/get_order_detail.json +136 -0
  67. package/template/base/connectors/tiktok_shop/fixtures/get_settlement.json +83 -0
  68. package/template/base/connectors/tiktok_shop/fixtures/get_tracking.json +28 -0
  69. package/template/base/connectors/tiktok_shop/fixtures/list_orders.json +242 -0
  70. package/template/base/connectors/tiktok_shop/fixtures/list_products.json +77 -0
  71. package/template/base/connectors/tiktok_shop/fixtures/list_settlements.json +22 -0
  72. package/template/base/connectors/tiktok_shop/fixtures/list_shops.json +17 -0
  73. package/template/base/connectors/tiktok_shop/fixtures/order_changed.json +129 -0
  74. package/template/base/connectors/tiktok_shop/fixtures/order_changed_cancelled.json +81 -0
  75. package/template/base/connectors/tiktok_shop/fixtures/order_changed_completed.json +106 -0
  76. package/template/base/connectors/tiktok_shop/fixtures/order_changed_on_hold.json +104 -0
  77. package/template/base/connectors/tiktok_shop/fixtures/order_changed_tokopedia.json +106 -0
  78. package/template/base/connectors/tiktok_shop/fixtures/order_changed_unpaid.json +79 -0
  79. package/template/base/connectors/tiktok_shop/fixtures/order_settled.json +73 -0
  80. package/template/base/connectors/tiktok_shop/fixtures/update_stock.json +6 -0
  81. package/template/base/connectors/tiktok_shop/fixtures/webhook_received.json +12 -0
  82. package/template/base/connectors/tiktok_shop/fixtures/webhook_received_cancellation.json +13 -0
  83. package/template/base/connectors/tiktok_shop/mock/tiktok_shop_mock.py +819 -0
  84. package/template/base/connectors/whatsapp_business/connector.rk +3 -1
  85. package/template/base/connectors/whatsapp_business/templates.md +13 -1
  86. package/template/base/modules/attendance/flows/attendance_missing_digest.rk +30 -0
  87. package/template/base/modules/attendance/flows/attendance_period_on_cancel.rk +15 -0
  88. package/template/base/modules/attendance/flows/attendance_period_on_submit.rk +60 -0
  89. package/template/base/modules/attendance/flows/staff_attendance_cancel_guard.rk +14 -0
  90. package/template/base/modules/attendance/flows/staff_attendance_guard_created.rk +16 -0
  91. package/template/base/modules/attendance/flows/staff_attendance_guard_submitted.rk +37 -0
  92. package/template/base/modules/attendance/flows/staff_attendance_guard_updated.rk +14 -0
  93. package/template/base/modules/attendance/models/attendance_period.rk +62 -0
  94. package/template/base/modules/attendance/models/attendance_summary.rk +37 -0
  95. package/template/base/modules/attendance/models/staff_attendance.rk +281 -0
  96. package/template/base/modules/attendance/models/staff_attendance_guard.rk +50 -0
  97. package/template/base/modules/attendance/module.rk +18 -0
  98. package/template/base/modules/attendance/screens/absen_outlet.rk +22 -0
  99. package/template/base/modules/catalogue/models/item.rk +69 -0
  100. package/template/base/modules/catalogue/module.rk +1 -1
  101. package/template/base/modules/contacts/models/customer.rk +43 -19
  102. package/template/base/modules/contacts/module.rk +1 -1
  103. package/template/base/modules/coretax/module.rk +1 -1
  104. package/template/base/modules/coretax/print/coretax_faktur.rk +3 -2
  105. package/template/base/modules/coretax/print/coretax_faktur.xml +3 -1
  106. package/template/base/modules/coretax/print/rekap_ppn.html +9 -7
  107. package/template/base/modules/courses/flows/charge_invoice_on_submit.rk +15 -0
  108. package/template/base/modules/courses/module.rk +1 -1
  109. package/template/base/modules/courses/screens/absen_kelas.rk +1 -0
  110. package/template/base/modules/invoicing/flows/invoice_due_digest.rk +45 -7
  111. package/template/base/modules/invoicing/models/sales_invoice_item.rk +4 -1
  112. package/template/base/modules/invoicing/module.rk +15 -2
  113. package/template/base/modules/kitchen/screens/dapur.rk +1 -0
  114. package/template/base/modules/outlets/models/outlet.rk +69 -0
  115. package/template/base/modules/outlets/module.rk +1 -1
  116. package/template/base/modules/payments/flows/payment_from_midtrans.rk +85 -0
  117. package/template/base/modules/payments/flows/payment_refund_from_midtrans.rk +22 -0
  118. package/template/base/modules/payments/models/payment.rk +2 -1
  119. package/template/base/modules/payments/module.rk +1 -1
  120. package/template/base/modules/payroll/flows/payroll_close_on_cancel.rk +8 -5
  121. package/template/base/modules/payroll/flows/payroll_close_on_submit.rk +8 -5
  122. package/template/base/modules/payroll/flows/payroll_reminder.rk +106 -0
  123. package/template/base/modules/payroll/flows/payroll_run_overlap_guard_created.rk +5 -3
  124. package/template/base/modules/payroll/flows/payroll_run_overlap_guard_updated.rk +5 -3
  125. package/template/base/modules/payroll/flows/payslip_from_recap.rk +1 -1
  126. package/template/base/modules/payroll/imports/payroll_profile_list.rk +27 -0
  127. package/template/base/modules/payroll/models/payroll_close.rk +10 -6
  128. package/template/base/modules/payroll/models/payroll_run.rk +64 -15
  129. package/template/base/modules/payroll/models/payslip.rk +48 -9
  130. package/template/base/modules/payroll/module.rk +22 -5
  131. package/template/base/modules/payroll/print/payslip.html +4 -1
  132. package/template/base/modules/pos/models/pos_sale.rk +136 -9
  133. package/template/base/modules/pos/models/pos_sale_item.rk +33 -1
  134. package/template/base/modules/pos/module.rk +5 -3
  135. package/template/base/modules/pos/print/pos_receipt.html +7 -3
  136. package/template/base/modules/pos/screens/kasir.rk +7 -2
  137. package/template/base/modules/procurement/flows/reorder_draft_po.rk +57 -0
  138. package/template/base/modules/procurement/models/vendor_bill.rk +14 -1
  139. package/template/base/modules/procurement/module.rk +11 -2
  140. package/template/base/modules/projects/screens/absen.rk +1 -0
  141. package/template/base/modules/promotions/flows/promo_code_batch_on_submit.rk +26 -0
  142. package/template/base/modules/promotions/flows/promotion_apply.rk +110 -0
  143. package/template/base/modules/promotions/flows/promotion_apply_on_create.rk +110 -0
  144. package/template/base/modules/promotions/flows/promotion_apply_on_delete.rk +111 -0
  145. package/template/base/modules/promotions/flows/promotion_apply_on_update.rk +110 -0
  146. package/template/base/modules/promotions/flows/promotion_on_sale.rk +95 -0
  147. package/template/base/modules/promotions/flows/promotion_on_sale_cancel.rk +43 -0
  148. package/template/base/modules/promotions/models/promo_code.rk +27 -0
  149. package/template/base/modules/promotions/models/promo_code_batch.rk +36 -0
  150. package/template/base/modules/promotions/models/promo_guard.rk +44 -0
  151. package/template/base/modules/promotions/models/promotion.rk +197 -0
  152. package/template/base/modules/promotions/models/promotion_ledger.rk +35 -0
  153. package/template/base/modules/promotions/module.rk +20 -0
  154. package/template/base/modules/rental/screens/alat_keluar.rk +1 -0
  155. package/template/base/modules/rental/screens/alat_kembali.rk +1 -0
  156. package/template/base/modules/rental/screens/jadwal_alat.rk +1 -0
  157. package/template/base/modules/stock/flows/stock_low_alert.rk +65 -0
  158. package/template/base/modules/stock/flows/stock_negative_alert.rk +14 -5
  159. package/template/base/modules/stock/models/stock_reorder.rk +34 -0
  160. package/template/base/modules/stock/module.rk +17 -2
  161. package/template/base/modules/subscriptions/screens/catat_tagih.rk +1 -0
  162. package/template/base/modules/subscriptions/screens/rute_tagih.rk +1 -0
  163. package/template/base/modules/users/flows/summary_daily.rk +83 -0
  164. package/template/base/modules/users/flows/summary_monthly.rk +83 -0
  165. package/template/base/modules/users/flows/summary_weekly.rk +83 -0
  166. package/template/base/modules/users/models/business_summary.rk +67 -0
  167. package/template/base/modules/users/models/summary_setting.rk +35 -0
  168. package/template/base/modules/users/models/user.rk +11 -3
  169. package/template/base/modules/users/module.rk +21 -2
  170. package/template/base/modules/users/roles/employee.rk +8 -0
  171. package/template/base/modules/users/roles/outlet_supervisor.rk +7 -0
  172. package/template/base/modules/whatsapp/flows/whatsapp_customer_opt_out.rk +16 -0
  173. package/template/base/modules/whatsapp/flows/whatsapp_customer_opt_out_new.rk +17 -0
  174. package/template/base/modules/whatsapp/flows/whatsapp_message_status.rk +24 -0
  175. package/template/base/modules/whatsapp/flows/whatsapp_opted_out.rk +26 -0
  176. package/template/base/modules/whatsapp/models/whatsapp_message.rk +99 -0
  177. package/template/base/modules/whatsapp/models/whatsapp_opt_out.rk +44 -0
  178. package/template/base/modules/whatsapp/module.rk +23 -0
  179. package/template/base/modules/whatsapp_booking/flows/whatsapp_booking_tomorrow.rk +48 -0
  180. package/template/base/modules/whatsapp_booking/module.rk +13 -0
  181. package/template/base/modules/whatsapp_order_ready/flows/whatsapp_pickup_on_sale.rk +19 -0
  182. package/template/base/modules/whatsapp_order_ready/flows/whatsapp_ticket_ready.rk +40 -0
  183. package/template/base/modules/whatsapp_order_ready/models/whatsapp_pickup.rk +22 -0
  184. package/template/base/modules/whatsapp_order_ready/module.rk +14 -0
  185. package/template/base/modules/whatsapp_receipt/flows/whatsapp_receipt_on_sale.rk +43 -0
  186. package/template/base/modules/whatsapp_receipt/module.rk +13 -0
  187. package/template/base/modules/whatsapp_reminder/flows/whatsapp_invoice_overdue.rk +64 -0
  188. package/template/base/modules/whatsapp_reminder/module.rk +15 -0
  189. package/template/base/modules/workforce/imports/worker_list.rk +4 -1
@@ -6,9 +6,11 @@ summary:
6
6
  en: Receive customer messages and send template messages through WhatsApp Business.
7
7
  category: messaging
8
8
  icon: whatsapp-line
9
- version: 1.0.0
9
+ version: 1.0.1
10
10
  vendor: Meta WhatsApp Cloud API
11
11
  docs: https://developers.facebook.com/docs/whatsapp/cloud-api
12
+ # The only host a request with the owner's access token may go to (rangka-os contract 0017 §5).
13
+ hosts: [graph.facebook.com]
12
14
  auth:
13
15
  type: token
14
16
  fields:
@@ -1,4 +1,4 @@
1
- # Message templates for payment collection
1
+ # Message templates
2
2
 
3
3
  Templates sent outside the 24-hour window must be approved by Meta first (category **Utility**, language `id`).
4
4
  Names are lowercase `snake_case`, as Meta requires; rangka-apps uses the same names in `invoice_reminder.template`
@@ -10,6 +10,15 @@ the same thing. Utility templates carry no promotion; Meta charges per delivered
10
10
  | `tagihan_terbit` | invoice submitted | Halo {{1}}, berikut tagihan {{2}} no. {{3}} sebesar {{4}}, jatuh tempo {{5}}. Pembayaran ke {{6}}. Mohon tulis {{3}} di berita transfer. Terima kasih. |
11
11
  | `pengingat_jatuh_tempo` | due date passed, still owed | Halo {{1}}, kami mengingatkan faktur {{2}} sebesar {{3}} sudah lewat {{4}} hari dari jatuh tempo ({{5}}). Pembayaran ke {{6}}. Mohon tulis {{2}} di berita transfer. Abaikan pesan ini kalau sudah membayar. Terima kasih. |
12
12
  | `terima_kasih_lunas` | invoice paid | Halo {{1}}, terima kasih. Pembayaran faktur {{2}} sudah kami terima dan faktur ini sudah lunas. |
13
+ | `struk_pembayaran` | a kasir sale is paid and the customer asked for the receipt on WhatsApp | Terima kasih, {{1}}. Struk {{2}} dari {{3}}: {{4}}. Total {{5}}, dibayar {{6}}. |
14
+ | `pesanan_siap` | a pick-up order is marked ready | Halo {{1}}, pesanan {{2}} di {{3}} sudah siap diambil. Sebutkan nomor pesanan saat mengambil. Terima kasih. |
15
+ | `pengingat_janji` | a booking starts tomorrow | Halo {{1}}, kami mengingatkan {{2}} di {{3}} pada {{4}}. Kalau perlu mengubah jadwal, hubungi kami sebelum waktunya. Terima kasih. |
16
+
17
+ Every template has the footer *Balas BERHENTI untuk berhenti menerima pesan.* (how to stop; the wording is to confirm
18
+ against Meta's template rules). A customer who replies BERHENTI or STOP must not be messaged again: with this
19
+ self-hosted connector that list is the owner's to keep (rangka-apps marks the customer "Tidak mau dikirimi WA" and the
20
+ flows skip them). With Rangka Cloud's [`rangka_whatsapp`](../rangka_whatsapp/README.md) the host also enforces it
21
+ before every send.
13
22
 
14
23
  Parameters, in order:
15
24
 
@@ -17,6 +26,9 @@ Parameters, in order:
17
26
  (`Bank Contoh 111 000 0001 a.n. PT Contoh`)
18
27
  - `pengingat_jatuh_tempo`: customer name, invoice number, outstanding amount, days late, due date, bank account
19
28
  - `terima_kasih_lunas`: customer name, invoice number
29
+ - `struk_pembayaran`: customer name, receipt number, business name, items, total, paid with
30
+ - `pesanan_siap`: customer name, order number, business name
31
+ - `pengingat_janji`: customer name, what (for example "janji potong rambut"), business name, when (date and time as one text)
20
32
 
21
33
  `send_template` takes them as `components`:
22
34
 
@@ -0,0 +1,30 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Every morning at 10:00 (scheduler.timezone): head office and the owner are told which outlet staff have not clocked in
3
+ # today (contract 0066 notice, in-app and email; WhatsApp once paid WhatsApp credits exist). Only employees with access
4
+ # active, an outlet and not attendance_exempt are expected; without shifts (rangka-apps#120) every such employee is
5
+ # expected every day, so a day off shows here too. The flow only reads and tells. Scheduled flows run for the default
6
+ # org only until rangka-os#263 slice a lands.
7
+ # The notice gives the count, not the names: the kernel's CEL has no join(), and a failed {...} part is left in the
8
+ # message as code. Names come back once rangka-os adds a list-to-text function.
9
+ name: attendance_missing_digest
10
+ label: {id: Karyawan belum absen masuk, en: Staff not clocked in}
11
+ description: {id: 'Tiap pagi jam 10, kantor pusat dan pemilik dikabari berapa karyawan outlet yang belum absen masuk hari ini.'}
12
+ schedule: '0 10 * * *'
13
+ steps:
14
+ - find_all: user
15
+ where: access == 'active' && !attendance_exempt && size(outlets) > 0
16
+ sort: full_name
17
+ limit: 300
18
+ as: emps
19
+ - find_all: staff_attendance
20
+ where: work_date == today() && docstatus != 2 && clock_in != ''
21
+ as: logs
22
+ - if: "emps.filter(u, !logs.exists(l, l.employee == u.name)).size() > 0"
23
+ notify: head_office
24
+ notice: attendance_missing
25
+ channel: email
26
+ id: "'missing:' + string(today())"
27
+ title: '{emps.filter(u, !logs.exists(l, l.employee == u.name)).size()} karyawan belum absen masuk hari ini'
28
+ template: >-
29
+ {emps.filter(u, !logs.exists(l, l.employee == u.name)).size()} karyawan outlet belum absen masuk sampai jam 10.
30
+ Siapa yang sudah masuk ada di dasbor Absen hari ini.
@@ -0,0 +1,15 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ name: attendance_period_on_cancel
3
+ label: {id: 'Rekap absen karyawan dibatalkan: ringkasannya ditandai batal'}
4
+ # The summaries stay as the trail, marked cancelled (payroll skips cancelled summaries).
5
+ on: attendance_period.cancelled
6
+ if: "'docstatus' in event && event.docstatus == 2"
7
+ steps:
8
+ - find_all: attendance_summary
9
+ where: attendance_period == event.name && !cancelled
10
+ as: sums
11
+ - for_each: sums
12
+ as: s
13
+ do:
14
+ - update: s
15
+ set: {cancelled: true}
@@ -0,0 +1,60 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ name: attendance_period_on_submit
3
+ label: {id: Rekap absen karyawan jadi ringkasan per karyawan}
4
+ # One attendance_summary per employee with access active and not attendance_exempt, from the submitted logs of the period
5
+ # (of the period's outlet, or of every outlet). A period of one outlet summarises the employees who clocked in there
6
+ # (an employee of another outlet who never came is not that outlet's absence). Logs waiting for approval do not count.
7
+ # Refused (the whole submit rolls back) when another submitted period overlaps the days for the same outlet or the whole
8
+ # business. Reads in the order attendance_period, user, staff_attendance (contract 0025 locks), like the log guards.
9
+ on: attendance_period.submitted
10
+ # Only a real submit: a hand run (POST /flows/.../run) carries no submitted period and would summarise twice.
11
+ if: "'docstatus' in event && event.docstatus == 1"
12
+ steps:
13
+ - find: attendance_summary
14
+ where: attendance_period == event.name && !cancelled
15
+ as: done
16
+ - if: done != null
17
+ create: staff_attendance_guard
18
+ set:
19
+ reason: "'period_summarised'"
20
+ document: event.name
21
+ - find: attendance_period
22
+ where: >-
23
+ name != event.name && docstatus == 1 && period_from <= event.period_to && period_to >= event.period_from
24
+ && (only_outlet == '' || event.only_outlet == '' || only_outlet == event.only_outlet)
25
+ as: other
26
+ - if: other != null
27
+ create: staff_attendance_guard
28
+ set:
29
+ reason: "'period_overlap'"
30
+ document: other.name
31
+ - find_all: user
32
+ where: access == 'active' && !attendance_exempt
33
+ sort: full_name
34
+ as: emps
35
+ - find_all: staff_attendance
36
+ where: >-
37
+ docstatus == 1 && work_date >= event.period_from && work_date <= event.period_to
38
+ && (event.only_outlet == '' || outlet == event.only_outlet)
39
+ sort: work_date
40
+ as: logs
41
+ - for_each: emps
42
+ as: u
43
+ do:
44
+ - if: "event.only_outlet == '' || logs.exists(l, l.employee == u.name)"
45
+ create: attendance_summary
46
+ set:
47
+ attendance_period: event.name
48
+ employee: u.name
49
+ employee_name: u.full_name
50
+ # the period's outlet, else where they clocked in first; empty for a whole-business period without a log (a flow
51
+ # find does not load table fields, so the member's outlets in Tim cannot be read here: rangka-os follow-up)
52
+ outlet: "event.only_outlet != '' ? event.only_outlet : (logs.exists(l, l.employee == u.name) ? logs.filter(l, l.employee == u.name)[0].outlet : '')"
53
+ period_from: event.period_from
54
+ period_to: event.period_to
55
+ days_present: "logs.map(l, l.employee == u.name ? 1 : 0).sum()"
56
+ late_count: "logs.map(l, l.employee == u.name && l.late_min > 0 ? 1 : 0).sum()"
57
+ late_min_total: "logs.map(l, l.employee == u.name ? l.late_min : 0).sum()"
58
+ early_min_total: "logs.map(l, l.employee == u.name ? l.early_min : 0).sum()"
59
+ overtime_hours: "logs.map(l, l.employee == u.name ? l.overtime_hours : 0.0).sum()"
60
+ worked_min_total: "logs.map(l, l.employee == u.name ? l.worked_min : 0).sum()"
@@ -0,0 +1,14 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ name: staff_attendance_cancel_guard
3
+ label: {id: Absen di periode yang sudah direkap tidak bisa dibatalkan}
4
+ # The day is already in a submitted period's summaries: cancel the period first.
5
+ on: staff_attendance.cancelled
6
+ steps:
7
+ - find: attendance_period
8
+ where: docstatus == 1 && period_from <= event.work_date && period_to >= event.work_date && (only_outlet == '' || only_outlet == event.outlet)
9
+ as: closed
10
+ - if: closed != null
11
+ create: staff_attendance_guard
12
+ set:
13
+ reason: "'period_closed'"
14
+ document: closed.name
@@ -0,0 +1,16 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ name: staff_attendance_guard_created
3
+ label: {id: Satu absen karyawan per orang per hari (baru)}
4
+ # A second live log of the same employee and day would count the day twice. The read takes the flow lock of contract
5
+ # 0025, so two clock-ins sent at the same moment run one after the other and the second is refused. A draft left without
6
+ # its clock-in time (the clock screen's second write failed) does not hold the day.
7
+ on: staff_attendance.created
8
+ steps:
9
+ - find: staff_attendance
10
+ where: day_key == event.day_key && name != event.name && docstatus != 2 && (docstatus == 1 || clock_in != '')
11
+ as: other
12
+ - if: other != null
13
+ create: staff_attendance_guard
14
+ set:
15
+ reason: "'second_log'"
16
+ document: other.name
@@ -0,0 +1,37 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ name: staff_attendance_guard_submitted
3
+ label: {id: 'Absen karyawan yang diajukan tidak dobel, tidak masuk periode yang sudah direkap, fotonya tidak dipakai ulang'}
4
+ # Runs again at submit (also the submit an approval runs as the employee): no new day inside a submitted period of the
5
+ # same outlet or the whole business, one counted log per employee and day, one photo per log. Reads attendance_period
6
+ # before staff_attendance, the order of attendance_period_on_submit (contract 0025).
7
+ on: staff_attendance.submitted
8
+ steps:
9
+ - find: attendance_period
10
+ where: docstatus == 1 && period_from <= event.work_date && period_to >= event.work_date && (only_outlet == '' || only_outlet == event.outlet)
11
+ as: closed
12
+ - if: closed != null
13
+ create: staff_attendance_guard
14
+ set:
15
+ reason: "'period_closed'"
16
+ document: closed.name
17
+ - find: staff_attendance
18
+ where: day_key == event.day_key && name != event.name && docstatus != 2 && (docstatus == 1 || clock_in != '')
19
+ as: other
20
+ - if: other != null
21
+ create: staff_attendance_guard
22
+ set:
23
+ reason: "'second_log'"
24
+ document: other.name
25
+ # A photo already used by another live log of the same employee (the only logs a staff member can read).
26
+ - if: event.in_photo != ''
27
+ find: staff_attendance
28
+ where: >-
29
+ name != event.name && docstatus != 2 && (
30
+ in_photo == event.in_photo || out_photo == event.in_photo
31
+ || (event.out_photo != '' && (in_photo == event.out_photo || out_photo == event.out_photo)))
32
+ as: same_photo
33
+ - if: event.in_photo != '' && same_photo != null
34
+ create: staff_attendance_guard
35
+ set:
36
+ reason: "'photo_reused'"
37
+ document: same_photo.name
@@ -0,0 +1,14 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ name: staff_attendance_guard_updated
3
+ label: {id: Satu absen karyawan per orang per hari (diubah)}
4
+ # The same check when the clock-in time, the employee or the date of a draft is set or changed.
5
+ on: staff_attendance.updated
6
+ steps:
7
+ - find: staff_attendance
8
+ where: day_key == event.day_key && name != event.name && docstatus != 2 && (docstatus == 1 || clock_in != '')
9
+ as: other
10
+ - if: other != null && event.clock_in != ''
11
+ create: staff_attendance_guard
12
+ set:
13
+ reason: "'second_log'"
14
+ document: other.name
@@ -0,0 +1,62 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: attendance_period
3
+ label: {id: Rekap absen karyawan, en: Staff attendance period}
4
+ icon: calendar
5
+ is_submittable: true
6
+ naming: RAK-{YYYY}-{####}
7
+ title_field: period_from
8
+ # Closes the staff attendance of a period (a calendar month, or 21st to 20th), for one outlet or the whole business.
9
+ # On submit, flow attendance_period_on_submit writes one attendance_summary per active employee (not attendance_exempt)
10
+ # from the submitted logs of the period: days present, late count and minutes, early leave minutes, overtime hours.
11
+ # Logs still waiting for approval are not counted: decide them first (dashboard absen_hari_ini). While the period is
12
+ # submitted, logs dated inside it can be neither submitted nor cancelled; cancelling the period marks its summaries
13
+ # cancelled. Two submitted periods of overlapping days for the same outlet (or the whole business) are refused.
14
+ permissions:
15
+ - {role: head_office, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
16
+ # Read so the guard flows that run in their submit and cancel can see whether a day is closed. Not row scoped
17
+ # (only_outlet is not named outlet): every period's dates and outlet stay visible, the notes do not.
18
+ - {role: outlet_supervisor, read: true}
19
+ - {role: cashier, read: true}
20
+ - {role: outlet_staff, read: true}
21
+ - {role: employee, read: true}
22
+ fields:
23
+ - name: period_from
24
+ type: date
25
+ label: {id: Dari tanggal}
26
+ required: true
27
+ in_list: true
28
+ - name: period_to
29
+ type: date
30
+ label: {id: Sampai tanggal}
31
+ required: true
32
+ in_list: true
33
+ # Empty = every outlet of the business.
34
+ - name: only_outlet
35
+ type: link
36
+ to: outlet
37
+ label: {id: Outlet}
38
+ help: {id: 'Kosongkan untuk merekap semua outlet'}
39
+ in_list: true
40
+ - name: notes
41
+ type: text
42
+ label: {id: Catatan}
43
+ hidden_for: [outlet_supervisor, cashier, outlet_staff, employee]
44
+ rules:
45
+ - name: period_valid
46
+ on: save
47
+ check: period_to >= period_from && days_between(period_from, period_to) <= 30
48
+ message: {id: 'Periode rekap: sampai tanggal tidak boleh sebelum tanggal mulai, paling lama 31 hari'}
49
+ - name: period_over
50
+ on: submit
51
+ check: period_to < today()
52
+ message: {id: 'Periode ini belum selesai; rekap absen setelah tanggal terakhirnya lewat'}
53
+ views:
54
+ list:
55
+ columns: [name, period_from, period_to, only_outlet, status]
56
+ sort: -period_from
57
+ form:
58
+ layout:
59
+ - section: {id: Rekap absen karyawan}
60
+ columns:
61
+ - [period_from, period_to, only_outlet]
62
+ - [notes]
@@ -0,0 +1,37 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: attendance_summary
3
+ label: {id: Ringkasan absen, en: Attendance summary}
4
+ icon: list
5
+ naming: RGA-{YYYY}-{#####}
6
+ title_field: employee_name
7
+ # One employee's attendance in one submitted attendance_period, written only by its flows (every field read only):
8
+ # days present, lateness, early leave, overtime and minutes worked from the submitted staff_attendance logs. Payroll
9
+ # for in-house staff reads it (rangka-apps#101). Leave days and absent days come with leave and shifts
10
+ # (rangka-apps#114, #120). Cancelling the period marks its summaries cancelled; they are kept as the trail.
11
+ permissions:
12
+ - {role: head_office, read: true, create: true, write: true, export: true, print: true}
13
+ # The outlet supervisor reads the summaries of their outlets (row scope outlet: the employee's outlet in the period).
14
+ - {role: outlet_supervisor, read: true}
15
+ # Staff read their own.
16
+ - {role: cashier, read: true, if: "employee == user.name"}
17
+ - {role: outlet_staff, read: true, if: "employee == user.name"}
18
+ - {role: employee, read: true, if: "employee == user.name"}
19
+ fields:
20
+ - {name: attendance_period, type: link, to: attendance_period, label: {id: Rekap absen}, read_only: true, in_list: true}
21
+ - {name: employee, type: link, to: user, label: {id: Karyawan}, read_only: true}
22
+ - {name: employee_name, type: data, label: {id: Nama}, read_only: true, in_list: true}
23
+ # The period's outlet, else the outlet of the employee's first log in the period (empty without a log).
24
+ - {name: outlet, type: link, to: outlet, label: {id: Outlet}, read_only: true, in_list: true}
25
+ - {name: period_from, type: date, label: {id: Periode dari}, read_only: true, in_list: true}
26
+ - {name: period_to, type: date, label: {id: Periode sampai}, read_only: true}
27
+ - {name: days_present, type: int, label: {id: Hari hadir (sah)}, read_only: true, in_list: true}
28
+ - {name: late_count, type: int, label: {id: Kali terlambat}, read_only: true, in_list: true}
29
+ - {name: late_min_total, type: int, label: {id: Total terlambat (menit)}, read_only: true, in_list: true}
30
+ - {name: early_min_total, type: int, label: {id: Total pulang cepat (menit)}, read_only: true}
31
+ - {name: overtime_hours, type: float, label: {id: Jam lembur}, read_only: true, in_list: true}
32
+ - {name: worked_min_total, type: int, label: {id: Total lama kerja (menit)}, read_only: true}
33
+ - {name: cancelled, type: check, label: {id: Batal}, read_only: true, in_list: true, chip: true}
34
+ views:
35
+ list:
36
+ columns: [employee_name, outlet, period_from, period_to, days_present, late_min_total, overtime_hours, cancelled]
37
+ sort: -period_from
@@ -0,0 +1,281 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: staff_attendance
3
+ label: {id: Absen karyawan, en: Staff attendance}
4
+ icon: clock
5
+ is_submittable: true
6
+ naming: ABK-{YYYY}{MM}-{#####}
7
+ title_field: employee_name
8
+ # One employee, one day at one outlet: clocked in and out from the phone with its position and a selfie (screen
9
+ # absen_outlet, contract 0030 §2 clock). The shape is the project field attendance (projects/models/attendance_log.rk),
10
+ # keyed on the employee (users.user, contract 0056) and the outlet instead of the worker, the assignment and the work site.
11
+ # The employee creates it at clock-in (draft), fills the clock-out and the screen submits it. A submitted log is one day
12
+ # present; attendance_period turns the days of a period into one attendance_summary per employee.
13
+ #
14
+ # Outside the outlet radius, without a position, entered more than a day late or with overtime: saved with a reason and
15
+ # the submit waits for the outlet supervisor or head office (approvals below). Never refused for being far away
16
+ # (contract 0030 §4). Lateness is measured, not held: it is a fact for the summary (and later for payroll rules).
17
+ #
18
+ # Distance: distance_m (haversine) between the phone's geo position and the outlet's point; 1e9 without a position, so
19
+ # "no position" counts as outside. A faked position (fake GPS) is not detected; the selfie and the approver are the check.
20
+ #
21
+ # Clock times, positions and photos are set_once: nobody moves a measured value. A wrong log is corrected by head office
22
+ # cancelling it and making a new one (source manual); the cancelled log stays as the trail.
23
+ #
24
+ # Privacy: positions and selfies are personal data (UU PDP). Staff read only their own logs (permission if: below, which
25
+ # also filters lists and dashboards); the outlet supervisor reads the logs of their outlets (row scope outlet); head
26
+ # office reads all. The selfie is an attachment of this record and is readable by whoever can read the record.
27
+ permissions:
28
+ # Staff: only their own logs, at their own outlets (cashier and outlet_staff are also row scoped by outlet). No cancel,
29
+ # no delete.
30
+ - {role: cashier, read: true, create: true, write: true, submit: true, if: "employee == user.name"}
31
+ - {role: outlet_staff, read: true, create: true, write: true, submit: true, if: "employee == user.name"}
32
+ - {role: employee, read: true, create: true, write: true, submit: true, if: "employee == user.name"}
33
+ # The outlet supervisor reads and prints the logs of their outlets and decides the held submits; they clock in too.
34
+ - {role: outlet_supervisor, read: true, print: true}
35
+ - {role: outlet_supervisor, create: true, write: true, submit: true, if: "employee == user.name"}
36
+ # No amend: a wrong log is cancelled and replaced by a manual log, so a measured clock-in, position and selfie can
37
+ # never be carried over to another employee, outlet or day (audit 2026-11-19 F1). Delete removes a stuck draft.
38
+ - {role: head_office, read: true, create: true, write: true, delete: true, submit: true, cancel: true, export: true, print: true}
39
+ fields:
40
+ # The member's own employee record (contract 0056). Rule employee_self: only head office names someone else.
41
+ - name: employee
42
+ type: link
43
+ to: user
44
+ label: {id: Karyawan}
45
+ required: true
46
+ in_list: true
47
+ default: user.name
48
+ # set once: the position and selfie of a log can never be moved to another person (audit 2026-11-19 F1)
49
+ set_once: true
50
+ - name: employee_name
51
+ type: data
52
+ label: {id: Nama}
53
+ read_only: true
54
+ in_list: true
55
+ compute: "employee != '' ? employee.full_name : ''"
56
+ - name: outlet
57
+ type: link
58
+ to: outlet
59
+ label: {id: Outlet}
60
+ required: true
61
+ in_list: true
62
+ default: "user.outlets.size() > 0 ? user.outlets[0] : ''"
63
+ set_once: true
64
+ - name: work_date
65
+ type: date
66
+ label: {id: Tanggal}
67
+ required: true
68
+ default: today()
69
+ in_list: true
70
+ set_once: true
71
+ # phone: the clock screen; manual: a head office correction (no selfie needed, always held: it has no position).
72
+ # kiosk is kept for the shared outlet tablet (contract 0048), not accepted yet (rule source_allowed).
73
+ - name: source
74
+ type: select
75
+ label: {id: Sumber}
76
+ default: "'phone'"
77
+ options:
78
+ - {value: phone, label: {id: HP karyawan}}
79
+ - {value: manual, label: {id: Koreksi kantor pusat}}
80
+ - {value: kiosk, label: {id: Tablet outlet}}
81
+ # Clock-in (set by the clock screen together with the photo; set_once)
82
+ - name: clock_in
83
+ type: datetime
84
+ label: {id: Jam masuk}
85
+ set_once: true
86
+ in_list: true
87
+ - {name: in_pos, type: geo, label: {id: Posisi masuk}, set_once: true}
88
+ - {name: in_photo, type: image, label: {id: Foto masuk}, set_once: true}
89
+ # Clock-out
90
+ - name: clock_out
91
+ type: datetime
92
+ label: {id: Jam keluar}
93
+ set_once: true
94
+ in_list: true
95
+ - {name: out_pos, type: geo, label: {id: Posisi keluar}, set_once: true}
96
+ - {name: out_photo, type: image, label: {id: Foto keluar}, set_once: true}
97
+ - name: overtime_hours
98
+ type: float
99
+ label: {id: Jam lembur}
100
+ default: '0'
101
+ - name: reason
102
+ type: text
103
+ label: {id: Alasan}
104
+ # The outlet's point, radius, UTC offset and hours at the time of the log (frozen at submit with the rest of the record,
105
+ # so moving an outlet later leaves old logs measured where they were taken). An outlet without a radius uses 100 m.
106
+ - {name: site_point, type: geo, label: {id: Titik outlet}, hidden: true, read_only: true, compute: "outlet != '' ? outlet.point : ''"}
107
+ - {name: site_radius_m, type: int, label: {id: Radius outlet (m)}, read_only: true, compute: "outlet != '' && outlet.radius_m > 0 ? outlet.radius_m : 100"}
108
+ - {name: utc_offset, type: data, label: {id: Zona waktu}, hidden: true, read_only: true, compute: "outlet == '' ? '+07:00' : (outlet.time_zone == 'wita' ? '+08:00' : (outlet.time_zone == 'wit' ? '+09:00' : '+07:00'))"}
109
+ - {name: grace_min, type: int, label: {id: Toleransi terlambat (menit)}, hidden: true, read_only: true, compute: "outlet != '' && outlet.late_grace_min > 0 ? outlet.late_grace_min : 0"}
110
+ # The schedule of the day: the outlet's default hours (shifts, rangka-apps#120, will fill it per employee). Empty when
111
+ # the outlet has no hours: then no lateness or early leave is measured. A work_end before work_start ends the next day.
112
+ - name: sched_start
113
+ type: datetime
114
+ label: {id: Jadwal masuk}
115
+ read_only: true
116
+ compute: "outlet != '' && outlet.work_start != '' ? string(work_date) + 'T' + outlet.work_start + ':00' + utc_offset : ''"
117
+ - name: sched_end
118
+ type: datetime
119
+ label: {id: Jadwal pulang}
120
+ read_only: true
121
+ compute: >-
122
+ outlet == '' || outlet.work_end == '' ? ''
123
+ : ((outlet.work_start != '' && outlet.work_end <= outlet.work_start ? string(work_date + duration(1)) : string(work_date))
124
+ + 'T' + outlet.work_end + ':00' + utc_offset)
125
+ # distance_m is 1e9 without a position (contract 0030 §4): "no position" counts as far.
126
+ - {name: in_m, type: float, label: {id: Jarak masuk dari titik (m)}, hidden: true, read_only: true, compute: "distance_m(in_pos, site_point)"}
127
+ - {name: in_located, type: check, label: {id: Lokasi masuk ada}, read_only: true, compute: "in_m < 100000000.0"}
128
+ - {name: in_inside, type: check, label: {id: Masuk di dalam radius}, read_only: true, compute: "in_located && in_m <= site_radius_m"}
129
+ # Text, empty without a position (GPS failed or refused): an int would show 0 m, which reads as "at the outlet".
130
+ - {name: in_site_m, type: data, label: {id: Jarak masuk dari outlet (m)}, read_only: true, compute: "in_located ? string(int(round(in_m))) : ''"}
131
+ - {name: out_m, type: float, label: {id: Jarak keluar dari titik (m)}, hidden: true, read_only: true, compute: "distance_m(out_pos, site_point)"}
132
+ - {name: out_located, type: check, label: {id: Lokasi keluar ada}, read_only: true, compute: "out_m < 100000000.0"}
133
+ - {name: out_inside, type: check, label: {id: Keluar di dalam radius}, read_only: true, compute: "out_located && out_m <= site_radius_m"}
134
+ - {name: out_site_m, type: data, label: {id: Jarak keluar dari outlet (m)}, read_only: true, compute: "out_located ? string(int(round(out_m))) : ''"}
135
+ - name: outside_site
136
+ type: check
137
+ label: {id: Di luar radius}
138
+ read_only: true
139
+ in_list: true
140
+ chip: true
141
+ compute: "!in_inside || (clock_out != '' && !out_inside)"
142
+ # Whole minutes after the scheduled start, less the outlet's grace (08:25 against 08:00 with 10 minutes grace = 15).
143
+ - name: late_min
144
+ type: int
145
+ label: {id: Terlambat (menit)}
146
+ read_only: true
147
+ in_list: true
148
+ compute: "clock_in == '' || sched_start == '' || (epoch(clock_in) - epoch(sched_start)) / 60 <= grace_min ? 0 : (epoch(clock_in) - epoch(sched_start)) / 60 - grace_min"
149
+ - name: early_min
150
+ type: int
151
+ label: {id: Pulang cepat (menit)}
152
+ read_only: true
153
+ compute: "clock_out == '' || sched_end == '' || epoch(clock_out) >= epoch(sched_end) ? 0 : (epoch(sched_end) - epoch(clock_out)) / 60"
154
+ - name: worked_min
155
+ type: int
156
+ label: {id: Lama kerja (menit)}
157
+ read_only: true
158
+ compute: "clock_in == '' || clock_out == '' || epoch(clock_out) <= epoch(clock_in) ? 0 : (epoch(clock_out) - epoch(clock_in)) / 60"
159
+ # One live log per employee per day (flows staff_attendance_guard_*: a cancelled one frees the day).
160
+ - name: day_key
161
+ type: data
162
+ label: {id: Kunci hari}
163
+ hidden: true
164
+ read_only: true
165
+ compute: "employee + ':' + string(work_date)"
166
+ rules:
167
+ - name: source_allowed
168
+ on: save
169
+ check: "source == 'phone' || (source == 'manual' && ('head_office' in user.roles || 'owner' in user.roles))"
170
+ message: {id: 'Absen manual hanya dibuat kantor pusat'}
171
+ - name: employee_self
172
+ on: save
173
+ check: "employee == user.name || 'head_office' in user.roles || 'owner' in user.roles"
174
+ message: {id: 'Kamu hanya bisa absen untuk diri sendiri'}
175
+ - name: own_outlet
176
+ on: save
177
+ check: "outlet in user.outlets || 'head_office' in user.roles || 'owner' in user.roles"
178
+ message: {id: 'Kamu hanya bisa absen di outlet tempatmu bekerja. Kalau outletnya belum ada, minta kantor pusat menambahkannya di Tim'}
179
+ - name: not_future
180
+ on: save
181
+ check: work_date <= today()
182
+ message: {id: 'Tidak bisa absen untuk tanggal yang belum datang'}
183
+ # The clock-in falls on the work date at the outlet's local time (a UTC or a local clock-in string alike).
184
+ - name: clock_in_on_work_date
185
+ on: save
186
+ check: >-
187
+ clock_in == '' || (epoch(clock_in) >= epoch(string(work_date) + 'T00:00:00' + utc_offset)
188
+ && epoch(clock_in) < epoch(string(work_date) + 'T00:00:00' + utc_offset) + 86400)
189
+ message: {id: 'Jam masuk harus di tanggal absen'}
190
+ - name: out_after_in
191
+ on: save
192
+ check: clock_out == '' || (clock_in != '' && epoch(clock_out) > epoch(clock_in))
193
+ message: {id: 'Jam keluar harus sesudah jam masuk. Kalau tadi salah tekan masuk, minta kantor pusat membatalkan absennya.'}
194
+ - name: overtime_range
195
+ on: save
196
+ check: overtime_hours >= 0 && overtime_hours <= 12
197
+ message: {id: 'Jam lembur 0 sampai 12 jam per hari'}
198
+ # Asked at clock-in, when the clock screen shows the reason box (outside or no position).
199
+ - name: reason_when_outside
200
+ on: save
201
+ check: "in_inside || size(reason) >= 5"
202
+ message: {id: 'Kamu di luar radius outlet (atau lokasi tidak terbaca): tulis alasannya'}
203
+ - name: reason_when_overtime
204
+ on: save
205
+ check: overtime_hours == 0 || size(reason) >= 5
206
+ message: {id: 'Tulis alasan atau pekerjaan lemburnya'}
207
+ - name: out_photo_own
208
+ on: save
209
+ check: out_photo == '' || out_photo != in_photo
210
+ message: {id: 'Foto keluar harus foto baru, bukan foto masuk'}
211
+ - name: clocked_in
212
+ on: submit
213
+ check: clock_in != ''
214
+ message: {id: 'Isi jam masuk dulu (absen masuk) sebelum diajukan'}
215
+ - name: clocked_out
216
+ on: submit
217
+ check: clock_out != ''
218
+ message: {id: 'Isi jam keluar dulu (absen pulang) sebelum diajukan'}
219
+ - name: photo_required
220
+ on: submit
221
+ check: in_photo != '' || source == 'manual'
222
+ message: {id: 'Absen butuh foto masuk'}
223
+ # Held for the outlet supervisor or head office (contract 0007); the owner may always approve. The verb then runs as the
224
+ # employee who asked.
225
+ approvals:
226
+ # An outlet supervisor's own log goes to head office, never to themselves or a fellow supervisor (audit 2026-11-19 F2).
227
+ # Head office and the owner are approvers of their own logs (contract 0007): their corrections count at once.
228
+ - name: outside_site
229
+ on: submit
230
+ when: "outside_site && !('outlet_supervisor' in user.roles)"
231
+ approvers: [outlet_supervisor, head_office]
232
+ label: {id: Absen di luar radius outlet, en: Clock-in outside the outlet radius}
233
+ - name: late_entry
234
+ on: submit
235
+ when: "days_between(work_date, today()) > 1 && !('outlet_supervisor' in user.roles)"
236
+ approvers: [outlet_supervisor, head_office]
237
+ label: {id: Absen diisi lebih dari sehari kemudian, en: Attendance entered more than a day late}
238
+ - name: overtime
239
+ on: submit
240
+ when: "overtime_hours > 0 && !('outlet_supervisor' in user.roles)"
241
+ approvers: [outlet_supervisor, head_office]
242
+ label: {id: Lembur, en: Overtime}
243
+ - name: supervisor_outside_site
244
+ on: submit
245
+ when: "outside_site && 'outlet_supervisor' in user.roles"
246
+ approvers: [head_office]
247
+ label: {id: Absen kepala outlet di luar radius, en: Outlet supervisor clock-in outside the radius}
248
+ - name: supervisor_late_entry
249
+ on: submit
250
+ when: "days_between(work_date, today()) > 1 && 'outlet_supervisor' in user.roles"
251
+ approvers: [head_office]
252
+ label: {id: Absen kepala outlet diisi terlambat, en: Outlet supervisor attendance entered late}
253
+ - name: supervisor_overtime
254
+ on: submit
255
+ when: "overtime_hours > 0 && 'outlet_supervisor' in user.roles"
256
+ approvers: [head_office]
257
+ label: {id: Lembur kepala outlet, en: Outlet supervisor overtime}
258
+ views:
259
+ list:
260
+ columns: [name, employee_name, outlet, work_date, clock_in, clock_out, late_min, outside_site, status]
261
+ sort: -work_date
262
+ form:
263
+ layout:
264
+ - section: {id: Absen}
265
+ columns:
266
+ - [employee, outlet, work_date]
267
+ - [source, overtime_hours, outside_site]
268
+ - section: {id: Masuk}
269
+ columns:
270
+ - [clock_in, in_photo]
271
+ - [in_pos, in_site_m, in_inside]
272
+ - section: {id: Keluar}
273
+ columns:
274
+ - [clock_out, out_photo]
275
+ - [out_pos, out_site_m, out_inside]
276
+ - section: {id: Jadwal}
277
+ columns:
278
+ - [sched_start, late_min]
279
+ - [sched_end, early_min, worked_min]
280
+ - section: {id: Alasan}
281
+ fields: [reason]