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

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 (94) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/grosir_distribusi/app.rk +2 -1
  3. package/template/base/apps/jasa_proyek/app.rk +4 -0
  4. package/template/base/apps/jasa_proyek/dashboards/rekap_absen.rk +1 -1
  5. package/template/base/apps/kasir/skills/rangka-app-kasir/SKILL.md +17 -1
  6. package/template/base/apps/kelas_kursus/app.rk +3 -0
  7. package/template/base/apps/langganan_jasa/app.rk +8 -1
  8. package/template/base/apps/produksi_pabrik/dashboards/produksi_overview.rk +1 -1
  9. package/template/base/apps/ritel_cabang/app.rk +3 -0
  10. package/template/base/apps/sewa_alat/app.rk +6 -1
  11. package/template/base/connectors/doku/mock/doku_mock.py +16 -5
  12. package/template/base/connectors/moka/connector.rk +6 -5
  13. package/template/base/connectors/moka/mock/moka_mock.py +210 -0
  14. package/template/base/connectors/xendit/mock/xendit_mock.py +231 -0
  15. package/template/base/modules/bank_statement/flows/bank_transaction_booked.rk +12 -0
  16. package/template/base/modules/bank_statement/flows/bank_transaction_booked_released.rk +11 -0
  17. package/template/base/modules/bank_statement/flows/bank_transaction_claim.rk +11 -1
  18. package/template/base/modules/bank_statement/flows/bank_transaction_confirm.rk +23 -5
  19. package/template/base/modules/bank_statement/flows/bank_transaction_suggest.rk +56 -14
  20. package/template/base/modules/bank_statement/models/bank_transaction.rk +27 -4
  21. package/template/base/modules/bank_statement/models/bank_transaction_claim.rk +1 -1
  22. package/template/base/modules/catalogue/models/item.rk +9 -0
  23. package/template/base/modules/catalogue/models/item_category.rk +2 -0
  24. package/template/base/modules/contacts/models/customer.rk +10 -1
  25. package/template/base/modules/contacts/models/vendor.rk +10 -1
  26. package/template/base/modules/coretax/module.rk +2 -2
  27. package/template/base/modules/coretax/print/coretax_faktur.rk +1 -1
  28. package/template/base/modules/coretax/print/coretax_faktur.xml +13 -7
  29. package/template/base/modules/courses/flows/session_attendance_checked.rk +14 -0
  30. package/template/base/modules/courses/flows/session_of_the_day.rk +34 -0
  31. package/template/base/modules/courses/models/course_attendance.rk +2 -0
  32. package/template/base/modules/courses/models/course_session.rk +1 -0
  33. package/template/base/modules/courses/module.rk +1 -1
  34. package/template/base/modules/courses/screens/absen_kelas.rk +17 -0
  35. package/template/base/modules/delivery/flows/invoice_qty_from_deliveries.rk +1 -1
  36. package/template/base/modules/delivery/module.rk +1 -1
  37. package/template/base/modules/distribution/flows/order_tier_pricing_created.rk +2 -2
  38. package/template/base/modules/distribution/flows/order_tier_pricing_updated.rk +2 -2
  39. package/template/base/modules/distribution/module.rk +1 -1
  40. package/template/base/modules/invoicing/models/sales_invoice.rk +31 -4
  41. package/template/base/modules/invoicing/models/sales_invoice_item.rk +7 -0
  42. package/template/base/modules/invoicing/module.rk +1 -1
  43. package/template/base/modules/invoicing/print/sales_invoice.html +15 -2
  44. package/template/base/modules/orders/models/customer_order.rk +2 -0
  45. package/template/base/modules/orders/models/customer_order_item.rk +10 -0
  46. package/template/base/modules/orders/module.rk +1 -1
  47. package/template/base/modules/outlet_sales/flows/moka_api_opened.rk +30 -0
  48. package/template/base/modules/outlet_sales/flows/moka_held_release.rk +35 -0
  49. package/template/base/modules/outlet_sales/flows/moka_line_mapped.rk +12 -3
  50. package/template/base/modules/outlet_sales/flows/moka_transaction_refused.rk +15 -0
  51. package/template/base/modules/outlet_sales/flows/moka_transaction_staged.rk +31 -11
  52. package/template/base/modules/outlet_sales/models/moka_sale_line.rk +9 -1
  53. package/template/base/modules/outlets/models/outlet.rk +13 -1
  54. package/template/base/modules/payments/flows/payment_refund_from_doku.rk +14 -0
  55. package/template/base/modules/payroll/flows/payroll_close_on_submit.rk +2 -2
  56. package/template/base/modules/payroll/flows/payslip_advance_guard.rk +3 -0
  57. package/template/base/modules/payroll/flows/payslip_from_recap.rk +30 -1
  58. package/template/base/modules/payroll/flows/payslip_ytd_guard.rk +18 -1
  59. package/template/base/modules/payroll/flows/payslip_ytd_on_create.rk +28 -1
  60. package/template/base/modules/payroll/models/payslip.rk +19 -1
  61. package/template/base/modules/payroll/module.rk +2 -2
  62. package/template/base/modules/pos/screens/kasir.rk +1 -1
  63. package/template/base/modules/production/models/production_batch.rk +3 -0
  64. package/template/base/modules/production/module.rk +1 -1
  65. package/template/base/modules/projects/flows/attendance_close_on_submit.rk +6 -2
  66. package/template/base/modules/projects/flows/attendance_log_guard_created.rk +3 -1
  67. package/template/base/modules/projects/flows/attendance_log_guard_submitted.rk +8 -4
  68. package/template/base/modules/projects/flows/attendance_log_guard_updated.rk +2 -1
  69. package/template/base/modules/projects/models/assignment.rk +3 -0
  70. package/template/base/modules/projects/models/attendance_close.rk +4 -0
  71. package/template/base/modules/projects/models/attendance_guard.rk +1 -1
  72. package/template/base/modules/projects/models/attendance_log.rk +63 -66
  73. package/template/base/modules/projects/models/work_site.rk +2 -1
  74. package/template/base/modules/projects/module.rk +1 -1
  75. package/template/base/modules/projects/roles/field_worker.rk +2 -0
  76. package/template/base/modules/projects/screens/absen.rk +21 -0
  77. package/template/base/modules/quotation/models/quotation.rk +14 -4
  78. package/template/base/modules/quotation/models/quotation_item.rk +13 -0
  79. package/template/base/modules/quotation/module.rk +1 -1
  80. package/template/base/modules/quotation/print/quotation.html +16 -2
  81. package/template/base/modules/rental/flows/rental_return_on_cancel.rk +5 -3
  82. package/template/base/modules/rental/models/rental_checkout.rk +10 -15
  83. package/template/base/modules/rental/models/rental_return.rk +3 -11
  84. package/template/base/modules/rental/models/rental_schedule.rk +8 -0
  85. package/template/base/modules/rental/models/rental_unit.rk +7 -0
  86. package/template/base/modules/rental/module.rk +1 -1
  87. package/template/base/modules/rental/screens/alat_keluar.rk +19 -0
  88. package/template/base/modules/rental/screens/alat_kembali.rk +19 -0
  89. package/template/base/modules/rental/screens/jadwal_alat.rk +21 -0
  90. package/template/base/modules/subscriptions/models/collection_visit.rk +47 -0
  91. package/template/base/modules/subscriptions/models/subscription.rk +3 -1
  92. package/template/base/modules/subscriptions/module.rk +1 -1
  93. package/template/base/modules/subscriptions/screens/catat_tagih.rk +18 -0
  94. package/template/base/modules/subscriptions/screens/rute_tagih.rk +25 -0
@@ -1,7 +1,7 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
2
  # One item of one Moka transaction, waiting to become a line of the outlet's daily sales (flow moka_daily_sales). A flat
3
3
  # record, not a child table, so the daily flow can read every line of an outlet and day with one find_all.
4
- # status: staged (ready), unmapped (no outlet or no item matched: head office picks them here and the line becomes
4
+ # status: staged (ready), held (the outlet's API gate is closed for its day, see outlet.moka_api_from), unmapped (no outlet or no item matched: head office picks them here and the line becomes
5
5
  # staged, flow moka_line_mapped; head office may still correct them while staged), posted (in outlet_sales `sales`). A refunded quantity is its own line, as in the
6
6
  # export import: qty < 0, gross 0, refund = the refunded share of the line's net. A refund Moka reports after the first
7
7
  # poll is a refund line of its own, dated the day of the refund (flow moka_transaction_staged).
@@ -41,6 +41,9 @@ fields:
41
41
  - {value: staged, label: {id: Siap direkap}}
42
42
  - {value: unmapped, label: {id: Belum dipetakan}}
43
43
  - {value: posted, label: {id: Sudah direkap}}
44
+ # the outlet does not count Moka API sales for this day yet (outlet.moka_api_from empty or later): the export
45
+ # counts it; flow moka_api_opened stages it once head office opens the outlet's API from this day or earlier
46
+ - {value: held, label: {id: Ditahan (outlet masih ekspor)}}
44
47
  - {name: sales, type: link, to: outlet_sales, label: {id: Penjualan harian}, read_only: true, in_list: true}
45
48
  rules:
46
49
  - name: staged_has_outlet_and_item
@@ -52,6 +55,11 @@ rules:
52
55
  on: save
53
56
  check: status != 'staged' || outlet == '' || outlet.moka_name != ''
54
57
  message: {id: 'Pilih outlet yang memakai Moka (Nama outlet di Moka terisi)'}
58
+ # an API line counts only from the outlet's moka_api_from on: before it the export counts that day (audit R1)
59
+ - name: staged_outlet_api_open
60
+ on: save
61
+ check: status != 'staged' || outlet == '' || (outlet.moka_api_from != '' && outlet.moka_api_from <= date)
62
+ message: {id: 'Outlet ini belum memakai API Moka untuk tanggal baris ini. Isi Mulai pakai API Moka di outlet, atau catat lewat ekspor'}
55
63
  views:
56
64
  list:
57
65
  columns: [date, outlet, description, qty, status, item, sales]
@@ -54,14 +54,26 @@ fields:
54
54
  label: {id: ID outlet di Moka}
55
55
  help: {id: 'Diisi saat Moka tersambung lewat API. Selama connector Moka aktif, outlet juga dicocokkan lewat Nama outlet di Moka'}
56
56
  depends_on: app_installed('outlet_sales') && moka_name != ''
57
+ # The gate from the export to the API (audit sisa-1111 R1): flow moka_transaction_staged books a transaction of this
58
+ # outlet only when its day is on or after this date; before it (or while empty) the outlet's Moka sales come from
59
+ # the Item Details export alone, so a day is never counted from both. Set it to the first day the API should count,
60
+ # after the last exported day. The kernel follows Moka's next_url since rangka-os t_277ba9bf, so the API reads the
61
+ # whole two-day window of every poll.
62
+ - name: moka_api_from
63
+ type: date
64
+ label: {id: Mulai pakai API Moka}
65
+ help: {id: 'Hari pertama penjualan diambil lewat API Moka (sesudah ekspor terakhir). Kosong = tetap ekspor'}
66
+ depends_on: app_installed('outlet_sales') && moka_name != ''
57
67
  # The sales source of an outlet without Moka (moka_name empty): the daily form (default when empty), a file from
58
68
  # another POS in Juragan's template, a Loyverse export, or Juragan's own cashier (module pos). One source per outlet,
59
- # so a day is never counted twice.
69
+ # so a day is never counted twice. With module pos installed a new outlet without Moka starts on the cashier (a site
70
+ # built with app kasir next to an outlet_sales app can ring up at once); head office switches it per outlet.
60
71
  - name: sales_source
61
72
  type: select
62
73
  label: {id: Sumber penjualan}
63
74
  help: {id: 'Untuk outlet yang tidak pakai Moka. Kosong berarti formulir harian'}
64
75
  depends_on: app_installed('outlet_sales') && moka_name == ''
76
+ default: "app_installed('pos') && moka_name == '' ? 'kasir' : ''"
65
77
  options:
66
78
  - {value: form, label: {id: Formulir harian}}
67
79
  - {value: file, label: {id: File POS (template Juragan)}}
@@ -0,0 +1,14 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # A DOKU refund (trigger payment_notified, transaction.type REFUND, status SUCCESS): the money went back to the payer
3
+ # from the DOKU balance. It is never money in (payment_from_doku runs only for paid == true) and it is not booked here
4
+ # either (no credit note or money-out document yet), so the owner is told, with the invoice, the amount and DOKU's id,
5
+ # to record it; before this a refund notification was dropped without a word (audit rel-uang-e2e M1).
6
+ name: payment_refund_from_doku
7
+ label: {id: Refund DOKU diberitahukan ke pemilik}
8
+ on: doku.payment_notified
9
+ if: "'type' in event && event.type == 'REFUND' && 'status' in event && event.status == 'SUCCESS'"
10
+ idempotency: "'gateway_ref' in event ? 'refund:' + event.gateway_ref + ':' + string(event.paid_amount) : ''"
11
+ steps:
12
+ - notify: owner
13
+ channel: email
14
+ template: {id: 'Refund DOKU Rp {event.paid_amount} untuk {event.external_id} ({event.gateway_ref}). Uang keluar dari saldo DOKU: catat pengembaliannya.'}
@@ -38,7 +38,7 @@ steps:
38
38
  pph23_applies: event.pph23_applies
39
39
  notes: "event.billing_mode == 'fee_only' ? 'Management fee tenaga kerja periode ' + event.period_from + ' s.d. ' + event.period_to + ' (' + event.name + ') [' + event.payroll_run + ']' : 'Tagihan tenaga kerja periode ' + event.period_from + ' s.d. ' + event.period_to + ' (' + event.name + ') [' + event.payroll_run + ']'"
40
40
  items: >-
41
- event.billing_mode == 'fee_only' ? [{'item': event.fee_item, 'description': 'Management fee', 'qty': 1, 'rate': event.fee_amount, 'pph23_exclude': false}] : [{'item': event.wage_item, 'description': 'Gaji, tunjangan, lembur dan THR tenaga kerja', 'qty': 1, 'rate': event.total_cash_gross, 'pph23_exclude': true},
41
+ event.billing_mode == 'fee_only' ? [{'item': event.fee_item, 'description': 'Management fee', 'qty': 1, 'rate': event.fee_amount, 'pph23_exclude': false}] : [{'item': event.wage_item, 'description': 'Gaji, tunjangan, lembur dan THR tenaga kerja', 'qty': 1, 'rate': event.total_cash_gross, 'pph23_exclude': true, 'ppn_exclude': true},
42
42
  {'item': event.bpjs_item, 'description': 'Iuran BPJS Ketenagakerjaan dan Kesehatan bagian perusahaan', 'qty': 1, 'rate': event.total_employer_bpjs, 'pph23_exclude': false},
43
43
  {'item': event.fee_item, 'description': 'Management fee', 'qty': 1, 'rate': event.fee_amount, 'pph23_exclude': false}]
44
44
  - if: event.billing_mode == 'wages_plus_fee' && old == null
@@ -51,7 +51,7 @@ steps:
51
51
  pph23_rate: '2'
52
52
  notes: "'Tagihan tenaga kerja periode ' + event.period_from + ' s.d. ' + event.period_to + ' (' + event.name + ') [' + event.payroll_run + ']'"
53
53
  items: >-
54
- [{'item': event.wage_item, 'description': 'Gaji, tunjangan, lembur dan THR tenaga kerja', 'qty': 1, 'rate': event.total_cash_gross, 'pph23_exclude': true},
54
+ [{'item': event.wage_item, 'description': 'Gaji, tunjangan, lembur dan THR tenaga kerja', 'qty': 1, 'rate': event.total_cash_gross, 'pph23_exclude': true, 'ppn_exclude': true},
55
55
  {'item': event.bpjs_item, 'description': 'Iuran BPJS Ketenagakerjaan dan Kesehatan bagian perusahaan', 'qty': 1, 'rate': event.total_employer_bpjs, 'pph23_exclude': false},
56
56
  {'item': event.fee_item, 'description': 'Management fee', 'qty': 1, 'rate': event.fee_amount, 'pph23_exclude': false}]
57
57
  - if: event.billing_mode == 'fee_only' && old == null
@@ -3,6 +3,9 @@ name: payslip_advance_guard
3
3
  label: {id: Potongan kasbon tidak melebihi kasbonnya}
4
4
  # Inside a payslip submit: the live slips that repay one kasbon (this one included) never deduct more than the kasbon
5
5
  # (audit gelombang 3 F5). The kasbon's own cancel is refused while one of them is submitted (cash_advance_cancel_guard).
6
+ # Two slips repaying one kasbon submitted at the same moment run one after the other: the find steps take the flow
7
+ # read locks of cash_advance and payslip (contract 0025), so the second one reads the first one's deduction and is
8
+ # refused (audit gelombang 3 r2 R3; day_one scenario_payroll_advance_race).
6
9
  on: payslip.submitted
7
10
  steps:
8
11
  - if: event.cash_advance != ''
@@ -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]
@@ -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: payroll
3
- version: 1.1.0
3
+ version: 1.2.0
4
4
  title: {id: Penggajian, en: Payroll}
5
5
  summary:
6
6
  id: Data gaji pekerja, periode gaji, slip gaji dan tutup periode.
@@ -10,4 +10,4 @@ icon: money-dollar-box-line
10
10
  # Monthly pay of outsourced workers from the attendance recap (projects.timesheet with period_to): payslips with BPJS and
11
11
  # PPh 21 TER, the deposits of the month, the extra employer cost on the project margin and the client invoice (wages +
12
12
  # BPJS + fee, or fee only). Rules and sources: docs/payroll.md.
13
- requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0, workforce: ^1.0, projects: ^1.0, invoicing: ^1.0}
13
+ requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0, workforce: ^1.0, projects: ^1.0, invoicing: ^1.7}
@@ -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
@@ -36,6 +36,9 @@ fields:
36
36
  - {name: reject_qty, type: float, label: {id: Qty reject}}
37
37
  - {name: labour, type: table, of: production_labour, label: {id: Upah borongan}}
38
38
  - {name: good_qty, type: float, label: {id: Hasil baik (produk utama)}, compute: "outputs.map(o, o.item == item ? o.qty : 0).sum()", in_list: true}
39
+ # the unit good_qty is counted in (the product's stock unit), so a list of batches of different products never reads
40
+ # 100 pak and 30 kg as the same kind of number (gladi G10)
41
+ - {name: uom, type: link, to: uom, label: {id: Satuan}, compute: item.stock_uom, in_list: true}
39
42
  - {name: yield_percent, type: float, label: {id: Rendemen aktual (%)}, compute: "planned_qty > 0 ? round(good_qty * 10000 / planned_qty) / 100 : 0"}
40
43
  - {name: share_total, type: float, label: {id: Total porsi biaya (%)}, compute: "outputs.map(o, o.cost_share).sum()"}
41
44
  - {name: main_share, type: float, label: {id: Porsi biaya produk utama (%)}, compute: "outputs.map(o, o.item == item ? o.cost_share : 0).sum()"}
@@ -5,7 +5,7 @@
5
5
  # at the value of those materials through the declarative stock block of contract 0021 (K-o). Wages and overhead are
6
6
  # in the batch's actual cost (HPP) but not in the stock value until K-r.
7
7
  name: production
8
- version: 1.1.0
8
+ version: 1.2.0
9
9
  title: {id: Produksi, en: Production}
10
10
  summary:
11
11
  id: Resep produksi, SPK, hasil per batch dan upah borongan.
@@ -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'}