@rangka-os/create 0.5.0-alpha.14 → 0.5.0-alpha.15

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 (56) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/jasa_proyek/app.rk +4 -0
  3. package/template/base/apps/jasa_proyek/dashboards/rekap_absen.rk +1 -1
  4. package/template/base/apps/kasir/skills/rangka-app-kasir/SKILL.md +17 -1
  5. package/template/base/apps/kelas_kursus/app.rk +3 -0
  6. package/template/base/apps/langganan_jasa/app.rk +5 -1
  7. package/template/base/apps/sewa_alat/app.rk +6 -1
  8. package/template/base/connectors/moka/connector.rk +6 -5
  9. package/template/base/modules/catalogue/models/item.rk +9 -0
  10. package/template/base/modules/contacts/models/customer.rk +10 -1
  11. package/template/base/modules/contacts/models/vendor.rk +10 -1
  12. package/template/base/modules/courses/flows/session_attendance_checked.rk +14 -0
  13. package/template/base/modules/courses/flows/session_of_the_day.rk +34 -0
  14. package/template/base/modules/courses/models/course_attendance.rk +2 -0
  15. package/template/base/modules/courses/models/course_session.rk +1 -0
  16. package/template/base/modules/courses/module.rk +1 -1
  17. package/template/base/modules/courses/screens/absen_kelas.rk +17 -0
  18. package/template/base/modules/outlet_sales/flows/moka_api_opened.rk +30 -0
  19. package/template/base/modules/outlet_sales/flows/moka_held_release.rk +35 -0
  20. package/template/base/modules/outlet_sales/flows/moka_line_mapped.rk +12 -3
  21. package/template/base/modules/outlet_sales/flows/moka_transaction_refused.rk +15 -0
  22. package/template/base/modules/outlet_sales/flows/moka_transaction_staged.rk +31 -11
  23. package/template/base/modules/outlet_sales/models/moka_sale_line.rk +9 -1
  24. package/template/base/modules/outlets/models/outlet.rk +13 -1
  25. package/template/base/modules/payroll/flows/payslip_advance_guard.rk +3 -0
  26. package/template/base/modules/payroll/flows/payslip_from_recap.rk +30 -1
  27. package/template/base/modules/payroll/flows/payslip_ytd_guard.rk +18 -1
  28. package/template/base/modules/payroll/flows/payslip_ytd_on_create.rk +28 -1
  29. package/template/base/modules/payroll/models/payslip.rk +19 -1
  30. package/template/base/modules/pos/screens/kasir.rk +1 -1
  31. package/template/base/modules/projects/flows/attendance_close_on_submit.rk +6 -2
  32. package/template/base/modules/projects/flows/attendance_log_guard_created.rk +3 -1
  33. package/template/base/modules/projects/flows/attendance_log_guard_submitted.rk +8 -4
  34. package/template/base/modules/projects/flows/attendance_log_guard_updated.rk +2 -1
  35. package/template/base/modules/projects/models/assignment.rk +3 -0
  36. package/template/base/modules/projects/models/attendance_close.rk +4 -0
  37. package/template/base/modules/projects/models/attendance_guard.rk +1 -1
  38. package/template/base/modules/projects/models/attendance_log.rk +63 -66
  39. package/template/base/modules/projects/models/work_site.rk +2 -1
  40. package/template/base/modules/projects/module.rk +1 -1
  41. package/template/base/modules/projects/roles/field_worker.rk +2 -0
  42. package/template/base/modules/projects/screens/absen.rk +21 -0
  43. package/template/base/modules/rental/flows/rental_return_on_cancel.rk +5 -3
  44. package/template/base/modules/rental/models/rental_checkout.rk +10 -15
  45. package/template/base/modules/rental/models/rental_return.rk +3 -11
  46. package/template/base/modules/rental/models/rental_schedule.rk +8 -0
  47. package/template/base/modules/rental/models/rental_unit.rk +7 -0
  48. package/template/base/modules/rental/module.rk +1 -1
  49. package/template/base/modules/rental/screens/alat_keluar.rk +19 -0
  50. package/template/base/modules/rental/screens/alat_kembali.rk +19 -0
  51. package/template/base/modules/rental/screens/jadwal_alat.rk +21 -0
  52. package/template/base/modules/subscriptions/models/collection_visit.rk +47 -0
  53. package/template/base/modules/subscriptions/models/subscription.rk +3 -1
  54. package/template/base/modules/subscriptions/module.rk +1 -1
  55. package/template/base/modules/subscriptions/screens/catat_tagih.rk +18 -0
  56. package/template/base/modules/subscriptions/screens/rute_tagih.rk +25 -0
@@ -27,10 +27,38 @@ steps:
27
27
  set:
28
28
  reason: "'second_slip'"
29
29
  document: other.name
30
+ - if: prof != null && run != null
31
+ find_all: cash_advance
32
+ where: worker == event.worker && docstatus == 1
33
+ sort: advance_date
34
+ as: kas
35
+ # A permanent employment that ended earlier this year (a submitted last_month slip) and was followed by casual months
36
+ # paid per day starts a new period of work: only the slips after it count (audit gelombang 3 r2 R2). A last_month
37
+ # ticked without a casual month after it (a mistake, the worker stayed) does not cut the year (audit apps-low F1).
38
+ - if: prof != null && run != null
39
+ find_all: payslip
40
+ where: worker == event.worker && tax_year == run.tax_year && tax_month < run.tax_month && docstatus == 1 && employment == 'casual' && pay_basis == 'daily'
41
+ sort: -tax_month
42
+ limit: 1
43
+ as: lastcas
30
44
  - if: prof != null && run != null
31
45
  find_all: payslip
32
- where: worker == event.worker && tax_year == run.tax_year && tax_month < run.tax_month && docstatus == 1 && !(employment == 'casual' && pay_basis == 'daily')
46
+ where: >-
47
+ worker == event.worker && tax_year == run.tax_year && tax_month < run.tax_month && docstatus == 1 && last_month && !(employment == 'casual' && pay_basis == 'daily')
48
+ && tax_month < (size(lastcas) > 0 ? lastcas[0].tax_month : 0)
49
+ sort: -tax_month
50
+ limit: 1
51
+ as: ended
52
+ - if: prof != null && run != null
53
+ find_all: payslip
54
+ where: >-
55
+ worker == event.worker && tax_year == run.tax_year && tax_month < run.tax_month && docstatus == 1 && !(employment == 'casual' && pay_basis == 'daily')
56
+ && tax_month > (size(ended) > 0 ? ended[0].tax_month : 0)
33
57
  as: prev
58
+ - if: prof != null && run != null
59
+ find_all: payslip
60
+ where: worker == event.worker && cash_advance != '' && docstatus == 1
61
+ as: repaid
34
62
  - if: prof != null && run != null
35
63
  create: payslip
36
64
  set:
@@ -45,3 +73,4 @@ steps:
45
73
  ytd_pph21: "prev.map(p, p.pph21).sum()"
46
74
  ytd_pension: "prev.map(p, p.jht_employee + p.jp_employee).sum()"
47
75
  ytd_months: "size(prev)"
76
+ open_advance: "kas.exists(k, repaid.map(p, p.cash_advance == k.name ? p.other_deduction : 0).sum() < k.amount) ? kas.filter(k, repaid.map(p, p.cash_advance == k.name ? p.other_deduction : 0).sum() < k.amount)[0].name : ''"
@@ -8,8 +8,25 @@ label: {id: Slip gaji dengan penghasilan sebelumnya yang basi tidak bisa diajuka
8
8
  # months as a permanent employee only (PMK 168/2023; audit gelombang 3 F1).
9
9
  on: payslip.submitted
10
10
  steps:
11
+ # A permanent employment that ended earlier this year (a submitted last_month slip) and was followed by casual months
12
+ # paid per day starts a new period of work: only the slips after it count (audit gelombang 3 r2 R2). A last_month
13
+ # ticked without a casual month after it (a mistake, the worker stayed) does not cut the year (audit apps-low F1).
11
14
  - find_all: payslip
12
- where: worker == event.worker && tax_year == event.tax_year && tax_month < event.tax_month && docstatus == 1 && !(employment == 'casual' && pay_basis == 'daily')
15
+ where: worker == event.worker && tax_year == event.tax_year && tax_month < event.tax_month && docstatus == 1 && employment == 'casual' && pay_basis == 'daily'
16
+ sort: -tax_month
17
+ limit: 1
18
+ as: lastcas
19
+ - find_all: payslip
20
+ where: >-
21
+ worker == event.worker && tax_year == event.tax_year && tax_month < event.tax_month && docstatus == 1 && last_month && !(employment == 'casual' && pay_basis == 'daily')
22
+ && tax_month < (size(lastcas) > 0 ? lastcas[0].tax_month : 0)
23
+ sort: -tax_month
24
+ limit: 1
25
+ as: ended
26
+ - find_all: payslip
27
+ where: >-
28
+ worker == event.worker && tax_year == event.tax_year && tax_month < event.tax_month && docstatus == 1 && !(employment == 'casual' && pay_basis == 'daily')
29
+ && tax_month > (size(ended) > 0 ? ended[0].tax_month : 0)
13
30
  as: prev
14
31
  - if: size(prev) != event.ytd_months || prev.map(p, p.gross_taxable).sum() != event.ytd_gross || prev.map(p, p.pph21).sum() != event.ytd_pph21 || prev.map(p, p.jht_employee + p.jp_employee).sum() != event.ytd_pension
15
32
  create: payroll_guard
@@ -7,10 +7,36 @@ label: {id: Slip gaji membaca penghasilan sebelumnya tahun ini}
7
7
  # Slips under the daily TER (casual, paid per day) are not part of the year: the December recomputation covers the
8
8
  # months as a permanent employee only (PMK 168/2023; audit gelombang 3 F1).
9
9
  on: payslip.created
10
+ # It also notes a kasbon of the worker not yet repaid in full (open_advance; warned at submit when the deduction does not
11
+ # link it). Reads cash_advance before payslip, like payslip_advance_guard.
10
12
  steps:
13
+ - find_all: cash_advance
14
+ where: worker == event.worker && docstatus == 1
15
+ sort: advance_date
16
+ as: kas
17
+ # A permanent employment that ended earlier this year (a submitted last_month slip) and was followed by casual months
18
+ # paid per day starts a new period of work: only the slips after it count (audit gelombang 3 r2 R2). A last_month
19
+ # ticked without a casual month after it (a mistake, the worker stayed) does not cut the year (audit apps-low F1).
11
20
  - find_all: payslip
12
- where: worker == event.worker && tax_year == event.tax_year && tax_month < event.tax_month && docstatus == 1 && !(employment == 'casual' && pay_basis == 'daily')
21
+ where: worker == event.worker && tax_year == event.tax_year && tax_month < event.tax_month && docstatus == 1 && employment == 'casual' && pay_basis == 'daily'
22
+ sort: -tax_month
23
+ limit: 1
24
+ as: lastcas
25
+ - find_all: payslip
26
+ where: >-
27
+ worker == event.worker && tax_year == event.tax_year && tax_month < event.tax_month && docstatus == 1 && last_month && !(employment == 'casual' && pay_basis == 'daily')
28
+ && tax_month < (size(lastcas) > 0 ? lastcas[0].tax_month : 0)
29
+ sort: -tax_month
30
+ limit: 1
31
+ as: ended
32
+ - find_all: payslip
33
+ where: >-
34
+ worker == event.worker && tax_year == event.tax_year && tax_month < event.tax_month && docstatus == 1 && !(employment == 'casual' && pay_basis == 'daily')
35
+ && tax_month > (size(ended) > 0 ? ended[0].tax_month : 0)
13
36
  as: prev
37
+ - find_all: payslip
38
+ where: worker == event.worker && cash_advance != '' && docstatus == 1
39
+ as: repaid
14
40
  - find: payslip
15
41
  where: name == event.name
16
42
  as: me
@@ -20,3 +46,4 @@ steps:
20
46
  ytd_pph21: "prev.map(p, p.pph21).sum()"
21
47
  ytd_pension: "prev.map(p, p.jht_employee + p.jp_employee).sum()"
22
48
  ytd_months: "size(prev)"
49
+ open_advance: "kas.exists(k, repaid.map(p, p.cash_advance == k.name ? p.other_deduction : 0).sum() < k.amount) ? kas.filter(k, repaid.map(p, p.cash_advance == k.name ? p.other_deduction : 0).sum() < k.amount)[0].name : ''"
@@ -96,6 +96,10 @@ fields:
96
96
  # The kasbon this deduction repays (cash_advance of the same worker, submitted): its cancel is then refused, and the
97
97
  # live slips linking it never deduct more than it (payslip_advance_guard, audit gelombang 3 F5).
98
98
  - {name: cash_advance, type: link, to: cash_advance, label: {id: Kasbon yang dipotong}}
99
+ # A kasbon of this worker not yet repaid in full by the submitted slips linking it, found when the slip is made
100
+ # (payslip_ytd_on_create, payslip_from_recap). A deduction without a link while one is open is warned at submit
101
+ # (audit gelombang 3 r2 R1): linked, the kasbon cannot be cancelled after its repayment.
102
+ - {name: open_advance, type: link, to: cash_advance, label: {id: Kasbon belum lunas}, read_only: true}
99
103
  - name: ptkp_status
100
104
  type: select
101
105
  label: {id: Status PTKP}
@@ -291,6 +295,15 @@ rules:
291
295
  && holiday_hours_2x <= holiday_overtime_days * (payroll_run.workdays_per_week == 5 ? 8 : 7)
292
296
  && holiday_hours_3x <= holiday_overtime_days && holiday_hours_4x <= holiday_overtime_days * 3
293
297
  message: {id: 'Hari 0 sampai 31, jam hari libur per tarif tidak melebihi batas per hari (2x: 7 atau 8, 3x: 1, 4x: 3), tidak negatif'}
298
+ # Rest-day hours climb the tiers in order (PP 35/2021 Pasal 31; audit gelombang 3 r2 R4): an hour at 3x only after a
299
+ # full day at 2x (at least 5 hours, the shortest day of a six-day week; 8 hours in a five-day week), hours at 4x only
300
+ # after the hour at 3x (at most 3 per day that had one).
301
+ - name: holiday_tiers_in_order
302
+ on: save
303
+ check: >-
304
+ holiday_hours_2x >= holiday_hours_3x * (payroll_run.workdays_per_week == 5 ? 8 : 5)
305
+ && holiday_hours_4x <= holiday_hours_3x * 3
306
+ message: {id: 'Jam hari libur 3x baru setelah jam 2x penuh, dan 4x baru setelah jam 3x'}
294
307
  - name: pay_entered
295
308
  on: submit
296
309
  check: "pay_basis == 'monthly' ? monthly_salary > 0 : (days > 0 && day_rate > 0)"
@@ -311,6 +324,11 @@ rules:
311
324
  on: submit
312
325
  check: net_pay >= 0
313
326
  message: {id: 'Gaji bersih minus: kurangi potongan lain'}
327
+ - name: deduction_not_linked
328
+ on: submit
329
+ level: warn
330
+ check: other_deduction == 0 || cash_advance != '' || open_advance == ''
331
+ message: {id: 'Pekerja ini punya kasbon belum lunas, tapi potongannya tidak ditautkan ke kasbon itu'}
314
332
  - name: umk_warning
315
333
  on: submit
316
334
  level: warn
@@ -329,7 +347,7 @@ views:
329
347
  - section: {id: Kehadiran dan upah}
330
348
  columns:
331
349
  - [pay_basis, employment, days, day_rate, monthly_salary, fixed_allowance, daily_allowance]
332
- - [overtime_hours, overtime_days, overtime_rate, thr_tenure_months, other_income, other_deduction, cash_advance]
350
+ - [overtime_hours, overtime_days, overtime_rate, thr_tenure_months, other_income, other_deduction, cash_advance, open_advance]
333
351
  - section: {id: Hari libur masuk kerja}
334
352
  columns:
335
353
  - [holiday_overtime_days]
@@ -12,7 +12,7 @@ offline: queue
12
12
  counter:
13
13
  catalogue:
14
14
  model: item
15
- filter: "kind != 'material'"
15
+ filter: "kind != 'material' && active != false"
16
16
  title: item_name
17
17
  search: [item_name, sku, barcode]
18
18
  group_by: category
@@ -52,9 +52,13 @@ steps:
52
52
  set:
53
53
  project: event.project
54
54
  worker: a.worker
55
- # An hourly assignment's rates are per hour: its per-day recap takes the worker's day rates instead (no
56
- # assignment), as an imported recap does (audit r2 R2-1).
55
+ # An hourly assignment's cost rate is per hour: its per-day recap keeps the worker's day pay (no assignment,
56
+ # audit r2 R2-1) and takes the assignment's day and overtime rates, as an imported recap does (audit r3 R3-1).
57
57
  assignment: "a.rate_basis == 'hour' ? '' : a.name"
58
+ day_rate: a.day_rate
59
+ hour_rate: a.hour_rate
60
+ overtime_rate: a.overtime_rate
61
+ overtime_cost_rate: a.overtime_cost_rate
58
62
  work_date: event.period_from
59
63
  period_to: event.period_to
60
64
  rate_basis: "'day'"
@@ -4,9 +4,11 @@ label: {id: Satu absen per orang per hari (baru)}
4
4
  # A second live log of the same worker and day would count the day twice in the recap. The read takes the flow lock of
5
5
  # contract 0025, so two clock-ins sent at the same moment run one after the other and the second is refused.
6
6
  on: attendance_log.created
7
+ # A draft left without its clock-in time (the clock screen's second write failed) does not hold the day: the next
8
+ # clock-in may go ahead (audit 2026-11-12 F2). The submit guard still allows one counted log per day.
7
9
  steps:
8
10
  - find: attendance_log
9
- where: day_key == event.day_key && name != event.name && docstatus != 2
11
+ where: day_key == event.day_key && name != event.name && docstatus != 2 && (docstatus == 1 || clock_in != '')
10
12
  as: other
11
13
  - if: other != null
12
14
  create: attendance_guard
@@ -15,17 +15,21 @@ steps:
15
15
  reason: "'period_closed'"
16
16
  document: closed.name
17
17
  - find: attendance_log
18
- where: day_key == event.day_key && name != event.name && docstatus != 2
18
+ where: day_key == event.day_key && name != event.name && docstatus != 2 && (docstatus == 1 || clock_in != '')
19
19
  as: other
20
20
  - if: other != null
21
21
  create: attendance_guard
22
22
  set:
23
23
  reason: "'second_log'"
24
24
  document: other.name
25
- # One photo, one day (audit r2 R2-3): a clock-in photo already used by another live log is refused. That the photo
26
- # was uploaded to this very log is checked by the kernel only from WS6 (image fields).
25
+ # One photo, one day (audit r2 R2-3, r3 R3-2): a photo of this log already used as the clock-in or clock-out photo of
26
+ # another live log is refused. That the photo was uploaded to this very log is checked by the kernel only from WS6
27
+ # (image fields).
27
28
  - find: attendance_log
28
- where: in_photo == event.in_photo && name != event.name && docstatus != 2
29
+ where: >-
30
+ name != event.name && docstatus != 2 && (
31
+ in_photo == event.in_photo || out_photo == event.in_photo
32
+ || (event.out_photo != '' && (in_photo == event.out_photo || out_photo == event.out_photo)))
29
33
  as: same_photo
30
34
  - if: same_photo != null
31
35
  create: attendance_guard
@@ -3,9 +3,10 @@ name: attendance_log_guard_updated
3
3
  label: {id: Satu absen per orang per hari (diubah)}
4
4
  # The same check when the worker or the date of a draft changes.
5
5
  on: attendance_log.updated
6
+ # Drafts without a clock-in time do not hold the day (audit 2026-11-12 F2).
6
7
  steps:
7
8
  - find: attendance_log
8
- where: day_key == event.day_key && name != event.name && docstatus != 2
9
+ where: day_key == event.day_key && name != event.name && docstatus != 2 && (docstatus == 1 || clock_in != '')
9
10
  as: other
10
11
  - if: other != null
11
12
  create: attendance_guard
@@ -41,6 +41,9 @@ fields:
41
41
  - {name: site_lat, type: float, label: {id: Lintang lokasi absen}, read_only: true, compute: "work_site != '' ? work_site.lat : 0"}
42
42
  - {name: site_lng, type: float, label: {id: Bujur lokasi absen}, read_only: true, compute: "work_site != '' ? work_site.lng : 0"}
43
43
  - {name: site_radius_m, type: int, label: {id: Radius absen (m)}, read_only: true, compute: "work_site != '' ? work_site.radius_m : 0"}
44
+ # For the clock screen (screens/absen.rk): the worker picks today's assignment as the place to clock in.
45
+ - {name: site_name, type: data, label: {id: Nama lokasi absen}, read_only: true, compute: "work_site != '' ? work_site.site_name : ''"}
46
+ - {name: site_point, type: geo, label: {id: Titik lokasi absen}, read_only: true, hidden: true, compute: "work_site != '' ? {'lat': site_lat, 'lng': site_lng} : ''"}
44
47
  - name: start_date
45
48
  type: date
46
49
  label: {id: Mulai}
@@ -37,9 +37,13 @@ fields:
37
37
  label: {id: Sampai tanggal}
38
38
  required: true
39
39
  in_list: true
40
+ # Workers and supervisors keep read (the guards of their log submit read the close) and are not row scoped (no worker or
41
+ # work_site field, contract 0010 §5), so they can list every project's closes; the notes stay hidden from them
42
+ # (audit 8 Nov L7, accepted limit: project, period and status remain visible).
40
43
  - name: notes
41
44
  type: text
42
45
  label: {id: Catatan}
46
+ hidden_for: [field_worker, site_supervisor]
43
47
  # No unique key on the period: a cancelled close must not block its amendment or a new close of the same days. Two live
44
48
  # closes of overlapping days are refused by attendance_close_on_submit under the flow lock (contract 0025).
45
49
  rules:
@@ -54,4 +54,4 @@ rules:
54
54
  - name: photo_reused
55
55
  on: save
56
56
  check: reason != 'photo_reused'
57
- message: {id: 'Foto masuk ini sudah dipakai absen lain; ambil foto baru untuk absen hari ini'}
57
+ message: {id: 'Foto ini sudah dipakai absen lain; ambil foto baru untuk absen hari ini'}
@@ -15,15 +15,18 @@ title_field: worker_name
15
15
  # the distance and the photo; a rejected log stays a draft and is not counted. Nothing is refused for being far away
16
16
  # (contract 0030 §4, as Talenta and Gadjian do).
17
17
  #
18
- # Distance: the kernel has no distance_m yet (it comes with WS6, the `geo` field type). Until then the phone sends lat/lng
19
- # and its own distance (in_distance_m, kept for the record only), and the kernel decides inside/outside itself from lat/lng
20
- # with a flat-earth formula (equirectangular; cos(lat) by its Taylor series, enough for |lat| < 30): squared metres against
21
- # the squared radius, so no square root is needed. A faked position (fake GPS) is not detected; the supervisor checks the
22
- # photo (contract 0030 §4).
18
+ # Distance: the phone sends its position as a `geo` value {lat, lng, accuracy_m, at} (contract 0030 §4, WS6) and the
19
+ # kernel measures it against the site's point with distance_m (haversine). What the phone shows is only an estimate; the
20
+ # computes below decide. A faked position (fake GPS) is not detected; the supervisor checks the photo (contract 0030 §4).
23
21
  #
24
- # Photos are attachments of the record (contract 0011, POST /api/v1/r/attendance_log/{name}/attachments); in_photo and
25
- # out_photo (type image, contract 0030 §4) hold the attachment id. The kernel does not check yet that the id belongs to this
26
- # record, nor gives the field a camera widget (WS6).
22
+ # Photos are attachments of the record (contract 0011); in_photo and out_photo (type image) hold the attachment id, and
23
+ # the kernel accepts only an image attachment of this same log (contract 0030 §4). The clock screen (screens/absen.rk)
24
+ # creates the log with the position, attaches the photo, then sets the photo and the clock-in time together.
25
+ #
26
+ # The clock-in and clock-out time, position and photo are set_once (contract 0030 §4): a worker fills them once and can
27
+ # never move a clock-in the kernel measured as outside, and nobody else can either: amend copies them, locked. A wrong
28
+ # value is corrected by the project admin cancelling the log and making a new one for the day (not an amendment; the
29
+ # cancelled log stays as the trail, attendance_close counts only submitted logs). Audit 2026-11-12 F5.
27
30
  #
28
31
  # Not linked to by any record while it is a draft (contract 0030 §10), so it can be submittable.
29
32
  permissions:
@@ -72,28 +75,28 @@ fields:
72
75
  default: today()
73
76
  in_list: true
74
77
  # Clock-in
78
+ # Set by the clock screen together with the photo (a default would block that write: set_once). Required at submit.
75
79
  - name: clock_in
76
80
  type: datetime
77
81
  label: {id: Jam masuk}
78
- required: true
79
- default: now()
82
+ set_once: true
80
83
  in_list: true
81
- - {name: in_lat, type: float, label: {id: Lintang masuk}}
82
- - {name: in_lng, type: float, label: {id: Bujur masuk}}
83
- - {name: in_accuracy_m, type: float, label: {id: Akurasi GPS masuk (m)}}
84
- # What the phone computed, kept for the record; the kernel decides with its own measure (in_inside, in_site_m).
85
- - {name: in_distance_m, type: float, label: {id: Jarak masuk menurut HP (m)}}
86
- - {name: in_photo, type: image, label: {id: Foto masuk (lampiran)}}
84
+ - {name: in_pos, type: geo, label: {id: Posisi masuk}, set_once: true}
85
+ # Before the geo fields (projects 1.1) the position was two numbers. Kept read-only so a log made before the upgrade
86
+ # is still measured from where it was taken (audit 2026-11-12 F1); new logs leave them 0.
87
+ - {name: in_lat, type: float, label: {id: Lintang masuk (lama)}, hidden: true, read_only: true}
88
+ - {name: in_lng, type: float, label: {id: Bujur masuk (lama)}, hidden: true, read_only: true}
89
+ - {name: in_photo, type: image, label: {id: Foto masuk}, set_once: true}
87
90
  # Clock-out
88
91
  - name: clock_out
89
92
  type: datetime
90
93
  label: {id: Jam keluar}
94
+ set_once: true
91
95
  in_list: true
92
- - {name: out_lat, type: float, label: {id: Lintang keluar}}
93
- - {name: out_lng, type: float, label: {id: Bujur keluar}}
94
- - {name: out_accuracy_m, type: float, label: {id: Akurasi GPS keluar (m)}}
95
- - {name: out_distance_m, type: float, label: {id: Jarak keluar menurut HP (m)}}
96
- - {name: out_photo, type: image, label: {id: Foto keluar (lampiran)}}
96
+ - {name: out_pos, type: geo, label: {id: Posisi keluar}, set_once: true}
97
+ - {name: out_lat, type: float, label: {id: Lintang keluar (lama)}, hidden: true, read_only: true}
98
+ - {name: out_lng, type: float, label: {id: Bujur keluar (lama)}, hidden: true, read_only: true}
99
+ - {name: out_photo, type: image, label: {id: Foto keluar}, set_once: true}
97
100
  - name: overtime_hours
98
101
  type: float
99
102
  label: {id: Jam lembur}
@@ -106,54 +109,33 @@ fields:
106
109
  - {name: site_lat, type: float, label: {id: Lintang lokasi}, read_only: true, compute: "work_site != '' ? work_site.lat : 0"}
107
110
  - {name: site_lng, type: float, label: {id: Bujur lokasi}, read_only: true, compute: "work_site != '' ? work_site.lng : 0"}
108
111
  - {name: site_radius_m, type: int, label: {id: Radius lokasi (m)}, read_only: true, compute: "work_site != '' ? work_site.radius_m : 0"}
109
- # Metres per degree of longitude at the site: 111320 x cos(lat), cos by 1 - x^2/2 + x^4/24 - x^6/720 (x in radians).
110
- - name: site_m_per_lng
111
- type: float
112
- label: {id: Meter per derajat bujur}
113
- hidden: true
114
- read_only: true
115
- compute: "111320.0 * (1.0 - (site_lat * 0.0174532925) * (site_lat * 0.0174532925) / 2.0 + (site_lat * 0.0174532925) * (site_lat * 0.0174532925) * (site_lat * 0.0174532925) * (site_lat * 0.0174532925) / 24.0 - (site_lat * 0.0174532925) * (site_lat * 0.0174532925) * (site_lat * 0.0174532925) * (site_lat * 0.0174532925) * (site_lat * 0.0174532925) * (site_lat * 0.0174532925) / 720.0)"
116
- - {name: in_located, type: check, label: {id: Lokasi masuk ada}, read_only: true, compute: "in_lat != 0 || in_lng != 0"}
117
- - {name: in_dx, type: float, label: {id: Selisih timur masuk (m)}, hidden: true, read_only: true, compute: "(in_lng - site_lng) * site_m_per_lng"}
118
- - {name: in_ax, type: float, label: {id: Selisih timur masuk mutlak}, hidden: true, read_only: true, compute: "in_dx < 0 ? -in_dx : in_dx"}
119
- - {name: in_ay, type: float, label: {id: Selisih utara masuk mutlak}, hidden: true, read_only: true, compute: "in_dy < 0 ? -in_dy : in_dy"}
120
- # Square root of dx^2 + dy^2 by two Newton steps from the octagonal estimate (max + 0.4 min, within 4%): within
121
- # 0.01% of the flat-earth distance.
122
- - {name: in_r0, type: float, label: {id: Jarak awal masuk}, hidden: true, read_only: true, compute: "(in_ax > in_ay ? in_ax : in_ay) + 0.4 * (in_ax > in_ay ? in_ay : in_ax)"}
123
- - {name: in_r1, type: float, label: {id: Jarak langkah 1 masuk}, hidden: true, read_only: true, compute: "in_r0 == 0 ? 0.0 : (in_r0 + (in_dx * in_dx + in_dy * in_dy) / in_r0) / 2.0"}
124
- - {name: in_r2, type: float, label: {id: Jarak langkah 2 masuk}, hidden: true, read_only: true, compute: "in_r1 == 0 ? 0.0 : (in_r1 + (in_dx * in_dx + in_dy * in_dy) / in_r1) / 2.0"}
125
- - {name: in_dy, type: float, label: {id: Selisih utara masuk (m)}, hidden: true, read_only: true, compute: "(in_lat - site_lat) * 110574.0"}
112
+ - {name: site_point, type: geo, label: {id: Titik lokasi}, hidden: true, read_only: true, compute: "work_site != '' ? {'lat': site_lat, 'lng': site_lng} : ''"}
113
+ # distance_m is 1e9 without a position (contract 0030 §4): "no position" counts as far.
114
+ - {name: in_m, type: float, label: {id: Jarak masuk dari titik (m)}, hidden: true, read_only: true, compute: "distance_m(in_pos, site_point) < 100000000.0 ? distance_m(in_pos, site_point) : (in_lat != 0 || in_lng != 0 ? distance_m({'lat': in_lat, 'lng': in_lng}, site_point) : distance_m(in_pos, site_point))"}
115
+ - {name: in_located, type: check, label: {id: Lokasi masuk ada}, read_only: true, compute: "in_m < 100000000.0"}
126
116
  - name: in_inside
127
117
  type: check
128
118
  label: {id: Masuk di dalam radius}
129
119
  read_only: true
130
- compute: "in_located && work_site != '' && in_dx * in_dx + in_dy * in_dy <= site_radius_m * site_radius_m"
131
- # Distance in metres for people to read (the decision above does not depend on it).
120
+ compute: "in_located && work_site != '' && in_m <= site_radius_m"
121
+ # Distance in metres for people to read (0 without a position).
132
122
  - name: in_site_m
133
123
  type: int
134
124
  label: {id: Jarak masuk dari lokasi (m)}
135
125
  read_only: true
136
- compute: "!in_located || work_site == '' ? 0 : round(in_r2)"
137
- - {name: out_located, type: check, label: {id: Lokasi keluar ada}, read_only: true, compute: "out_lat != 0 || out_lng != 0"}
138
- - {name: out_dx, type: float, label: {id: Selisih timur keluar (m)}, hidden: true, read_only: true, compute: "(out_lng - site_lng) * site_m_per_lng"}
139
- - {name: out_ax, type: float, label: {id: Selisih timur keluar mutlak}, hidden: true, read_only: true, compute: "out_dx < 0 ? -out_dx : out_dx"}
140
- - {name: out_ay, type: float, label: {id: Selisih utara keluar mutlak}, hidden: true, read_only: true, compute: "out_dy < 0 ? -out_dy : out_dy"}
141
- # Square root of dx^2 + dy^2 by two Newton steps from the octagonal estimate (max + 0.4 min, within 4%): within
142
- # 0.01% of the flat-earth distance.
143
- - {name: out_r0, type: float, label: {id: Jarak awal keluar}, hidden: true, read_only: true, compute: "(out_ax > out_ay ? out_ax : out_ay) + 0.4 * (out_ax > out_ay ? out_ay : out_ax)"}
144
- - {name: out_r1, type: float, label: {id: Jarak langkah 1 keluar}, hidden: true, read_only: true, compute: "out_r0 == 0 ? 0.0 : (out_r0 + (out_dx * out_dx + out_dy * out_dy) / out_r0) / 2.0"}
145
- - {name: out_r2, type: float, label: {id: Jarak langkah 2 keluar}, hidden: true, read_only: true, compute: "out_r1 == 0 ? 0.0 : (out_r1 + (out_dx * out_dx + out_dy * out_dy) / out_r1) / 2.0"}
146
- - {name: out_dy, type: float, label: {id: Selisih utara keluar (m)}, hidden: true, read_only: true, compute: "(out_lat - site_lat) * 110574.0"}
126
+ compute: "!in_located || work_site == '' ? 0 : round(in_m)"
127
+ - {name: out_m, type: float, label: {id: Jarak keluar dari titik (m)}, hidden: true, read_only: true, compute: "distance_m(out_pos, site_point) < 100000000.0 ? distance_m(out_pos, site_point) : (out_lat != 0 || out_lng != 0 ? distance_m({'lat': out_lat, 'lng': out_lng}, site_point) : distance_m(out_pos, site_point))"}
128
+ - {name: out_located, type: check, label: {id: Lokasi keluar ada}, read_only: true, compute: "out_m < 100000000.0"}
147
129
  - name: out_inside
148
130
  type: check
149
131
  label: {id: Keluar di dalam radius}
150
132
  read_only: true
151
- compute: "out_located && work_site != '' && out_dx * out_dx + out_dy * out_dy <= site_radius_m * site_radius_m"
133
+ compute: "out_located && work_site != '' && out_m <= site_radius_m"
152
134
  - name: out_site_m
153
135
  type: int
154
136
  label: {id: Jarak keluar dari lokasi (m)}
155
137
  read_only: true
156
- compute: "!out_located || work_site == '' ? 0 : round(out_r2)"
138
+ compute: "!out_located || work_site == '' ? 0 : round(out_m)"
157
139
  # Outside: clock-in not inside the radius (or no position), or a clock-out entered and not inside.
158
140
  - name: outside_site
159
141
  type: check
@@ -190,30 +172,45 @@ rules:
190
172
  on: save
191
173
  check: work_date <= today()
192
174
  message: {id: 'Tidak bisa absen untuk tanggal yang belum datang'}
193
- - name: position_valid
194
- on: save
195
- check: in_lat >= -90 && in_lat <= 90 && in_lng >= -180 && in_lng <= 180 && out_lat >= -90 && out_lat <= 90 && out_lng >= -180 && out_lng <= 180 && in_accuracy_m >= 0 && out_accuracy_m >= 0 && in_distance_m >= 0 && out_distance_m >= 0
196
- message: {id: 'Posisi GPS tidak valid'}
197
- - name: photo_is_attachment
175
+ # The clock-in falls on the day being paid (audit 8 Nov L9). A clock-in with a local offset (+07:00) starts with the
176
+ # local date. A UTC one (Z or +00:00, how the store keeps it) falls between 00:00 WIT and 24:00 WIB of that date:
177
+ # 15:00 UTC the day before up to 17:00 UTC (audit apps-low F3). The org timezone is not readable in CEL.
178
+ - name: clock_in_on_work_date
198
179
  on: save
199
- check: (in_photo == '' || in_photo.startsWith('att_')) && (out_photo == '' || out_photo.startsWith('att_'))
200
- message: {id: 'Foto diisi dengan id lampiran (unggah fotonya dulu)'}
180
+ check: >-
181
+ clock_in == '' || ((clock_in.endsWith('Z') || clock_in.endsWith('+00:00'))
182
+ ? ((clock_in.startsWith(work_date) && clock_in < work_date + 'T17:00:00')
183
+ || (clock_in.startsWith(work_date - duration(1)) && clock_in >= (work_date - duration(1)) + 'T15:00:00'))
184
+ : clock_in.startsWith(work_date))
185
+ message: {id: 'Jam masuk harus di tanggal absen'}
201
186
  - name: out_after_in
202
187
  on: save
203
- check: clock_out == '' || clock_out > clock_in
188
+ check: clock_out == '' || (clock_in != '' && clock_out > clock_in)
204
189
  message: {id: 'Jam keluar harus sesudah jam masuk'}
205
190
  - name: overtime_range
206
191
  on: save
207
192
  check: overtime_hours >= 0 && overtime_hours <= 12
208
193
  message: {id: 'Jam lembur 0 sampai 12 jam per hari'}
194
+ # The reason is asked at the clock-in (the clock screen shows the box only then, contract 0030 §2 clock). A clock-out
195
+ # outside the radius needs none: it still marks the log outside_site, so the submit waits for the supervisor, who
196
+ # sees the distance and the photo.
209
197
  - name: reason_when_outside
210
198
  on: save
211
- check: "!outside_site || size(reason) >= 5"
199
+ check: "in_inside || size(reason) >= 5"
212
200
  message: {id: 'Kamu di luar radius lokasi kerja (atau lokasi tidak terbaca): tulis alasannya'}
213
201
  - name: reason_when_overtime
214
202
  on: save
215
203
  check: overtime_hours == 0 || size(reason) >= 5
216
204
  message: {id: 'Tulis alasan atau pekerjaan lemburnya'}
205
+ - name: clocked_in
206
+ on: submit
207
+ check: clock_in != ''
208
+ message: {id: 'Isi jam masuk dulu (absen masuk) sebelum diajukan'}
209
+ # The clock-out photo is its own evidence, not the clock-in photo again (audit 2026-11-12 F4).
210
+ - name: out_photo_own
211
+ on: save
212
+ check: out_photo == '' || out_photo != in_photo
213
+ message: {id: 'Foto keluar harus foto baru, bukan foto masuk'}
217
214
  - name: clocked_out
218
215
  on: submit
219
216
  check: clock_out != ''
@@ -253,12 +250,12 @@ views:
253
250
  - [work_date, overtime_hours, outside_site]
254
251
  - section: {id: Masuk}
255
252
  columns:
256
- - [clock_in, in_photo, in_site_m, in_inside]
257
- - [in_lat, in_lng, in_accuracy_m, in_distance_m]
253
+ - [clock_in, in_photo]
254
+ - [in_pos, in_site_m, in_inside]
258
255
  - section: {id: Keluar}
259
256
  columns:
260
- - [clock_out, out_photo, out_site_m, out_inside]
261
- - [out_lat, out_lng, out_accuracy_m, out_distance_m]
257
+ - [clock_out, out_photo]
258
+ - [out_pos, out_site_m, out_inside]
262
259
  - section: {id: Alasan}
263
260
  fields: [reason]
264
261
  - section: {id: Lokasi kerja}
@@ -37,6 +37,8 @@ fields:
37
37
  type: float
38
38
  label: {id: Bujur (lng)}
39
39
  required: true
40
+ # The point as a position (contract 0030 §4 geo) for distance_m and the clock screen's site slot.
41
+ - {name: point, type: geo, label: {id: Titik lokasi}, read_only: true, compute: "{'lat': lat, 'lng': lng}"}
40
42
  - name: radius_m
41
43
  type: int
42
44
  label: {id: Radius absen (meter)}
@@ -55,7 +57,6 @@ rules:
55
57
  on: save
56
58
  check: lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180 && (lat != 0 || lng != 0)
57
59
  message: {id: 'Titik lokasi tidak valid: lintang -90 sampai 90, bujur -180 sampai 180'}
58
- # The distance check (attendance_log) is a flat-earth approximation, good to well under a metre for these distances.
59
60
  - name: radius_range
60
61
  on: save
61
62
  check: radius_m >= 20 && radius_m <= 5000
@@ -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: projects
3
- version: 1.1.1
3
+ version: 1.2.0
4
4
  title: {id: Proyek, en: Projects}
5
5
  summary:
6
6
  id: Proyek dengan penugasan, absensi, biaya, termin tagihan dan untung per proyek.
@@ -2,6 +2,8 @@
2
2
  name: field_worker
3
3
  label: {id: Pekerja lapangan}
4
4
  description: {id: 'Absen masuk dan pulang di lokasi kerja, dan melihat absennya sendiri'}
5
+ # Works from the phone: the clock screen full screen (work shell, contract 0030 §3), no sidebar.
6
+ desk: false
5
7
  # Contract 0010 §5: records whose worker is the member's own worker record (rangka user add --record WRK-0001), so a
6
8
  # worker sees only their own logs and assignments. Pay and selling rates of an assignment are hidden (contract 0027).
7
9
  scope: {field: worker, from: '[user.name]'}
@@ -0,0 +1,21 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/screen.json
2
+ name: absen
3
+ type: clock
4
+ label: {id: Absen, en: Clock in}
5
+ icon: clock
6
+ # A worker clocks in and out at the client's site from their phone (plans/layar-kerja.md §3 #2, contract 0030 §2 clock).
7
+ # The site is today's assignment (the worker cannot read the firm's list of client sites, only their own assignments),
8
+ # its point and radius come from the work site. A clock-in outside the radius or without a position is saved with the
9
+ # reason and waits for the site supervisor (attendance_log approvals); the record's own computes decide, not the phone.
10
+ # No offline queue: every clock-in carries a photo, which needs the connection (contract 0030 §7).
11
+ roles: [field_worker]
12
+ device: phone
13
+ needs: [location, photo]
14
+ clock:
15
+ # The worker's own logs (row scope worker); the open one is the newest with a clock-in and no clock-out.
16
+ record: {model: attendance_log, filter: "docstatus == 0", set: {worker: user.name}}
17
+ in: {field: clock_in, location: in_pos, photo: in_photo}
18
+ out: {field: clock_out, location: out_pos, photo: out_photo}
19
+ site: {model: assignment, link: assignment, filter: "start_date <= today() && end_date >= today() && work_site != ''", title: site_name, location: site_point, radius_m: site_radius_m}
20
+ reason: reason
21
+ submit: true
@@ -3,7 +3,9 @@ name: rental_return_on_cancel
3
3
  label: {id: Alat kembali dibatalkan}
4
4
  # A return entered by mistake: the schedule goes back to out (the deposit journal is reversed by gl_rental_return_reverse),
5
5
  # refused while the invoice for what the deposit did not cover is submitted (cancel that first). Its units go back out
6
- # with the booking in the condition they left in, refused for a unit that went out again since.
6
+ # with the booking in the condition they left in, refused for a unit that went out again or moved to another item since. Each unit's last checkout
7
+ # becomes this booking's checkout again (the schedule keeps it), so that checkout can still be cancelled after a
8
+ # checkout of another booking took the unit and was cancelled in between (audit 8 Nov L1).
7
9
  on: rental_return.cancelled
8
10
  steps:
9
11
  - {find: rental_schedule, where: booking == event.booking, as: s}
@@ -19,8 +21,8 @@ steps:
19
21
  do:
20
22
  - {find: rental_unit, where: name == row.unit, as: u}
21
23
  - create: rental_guard
22
- if: "u == null || u.state != 'in' || u.last_return != event.name"
24
+ if: "u == null || u.state != 'in' || u.last_return != event.name || u.rental_item != event.rental_item"
23
25
  set: {reason: "'unit_moved'", document: event.name}
24
26
  - update: u
25
27
  if: u != null
26
- set: {state: "'out'", booking: event.booking, condition: u.out_condition, last_return: "''"}
28
+ set: {state: "'out'", booking: event.booking, condition: u.out_condition, last_return: "''", last_checkout: "s != null ? s.checkout : ''"}