@rangka-os/create 0.5.0-alpha.7 → 0.5.0-alpha.9

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 (32) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/jasa_proyek/dashboards/jasa_overview.rk +4 -0
  3. package/template/base/apps/jasa_proyek/dashboards/project_margin.rk +28 -0
  4. package/template/base/connectors/biteship/connector.rk +241 -0
  5. package/template/base/connectors/biteship/fixtures/cancel_order.json +1 -0
  6. package/template/base/connectors/biteship/fixtures/create_order.json +8 -0
  7. package/template/base/connectors/biteship/fixtures/expect.json +9 -0
  8. package/template/base/connectors/biteship/fixtures/get_order.json +2 -0
  9. package/template/base/connectors/biteship/fixtures/get_rates.json +7 -0
  10. package/template/base/connectors/biteship/fixtures/get_tracking.json +7 -0
  11. package/template/base/connectors/biteship/fixtures/order_price.json +11 -0
  12. package/template/base/connectors/biteship/fixtures/order_status.json +15 -0
  13. package/template/base/connectors/biteship/fixtures/order_status_cancelled.json +15 -0
  14. package/template/base/connectors/biteship/fixtures/order_waybill.json +7 -0
  15. package/template/base/connectors/biteship/fixtures/search_areas.json +1 -0
  16. package/template/base/modules/bank_statement/flows/bank_transaction_suggest.rk +13 -3
  17. package/template/base/modules/invoicing/flows/payment_instruction_on_submit.rk +24 -0
  18. package/template/base/modules/invoicing/models/bank_account.rk +134 -0
  19. package/template/base/modules/invoicing/models/payment_instruction.rk +68 -0
  20. package/template/base/modules/invoicing/module.rk +1 -1
  21. package/template/base/modules/payments/flows/payment_from_xendit_invoice.rk +59 -0
  22. package/template/base/modules/payments/flows/payment_from_xendit_qr.rk +59 -0
  23. package/template/base/modules/payments/flows/payment_from_xendit_va.rk +59 -0
  24. package/template/base/modules/payments/models/payment.rk +3 -1
  25. package/template/base/modules/payments/module.rk +1 -1
  26. package/template/base/modules/projects/flows/timesheet_assignment_on_create.rk +28 -0
  27. package/template/base/modules/projects/imports/attendance_recap.rk +23 -0
  28. package/template/base/modules/projects/models/assignment.rk +16 -3
  29. package/template/base/modules/projects/models/project_ledger.rk +5 -2
  30. package/template/base/modules/projects/models/timesheet.rk +58 -14
  31. package/template/base/modules/workforce/imports/worker_list.rk +6 -1
  32. package/template/base/modules/workforce/models/worker.rk +28 -8
@@ -0,0 +1,68 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # "Cara bayar" of one submitted invoice: a copy of the default bank_account (rekening, QRIS, instruction) and the
3
+ # payment reference, made by the flow payment_instruction_on_submit when the invoice is submitted. A submitted
4
+ # invoice is immutable, so the copy lives here (one per invoice, unique), and editing or replacing the account
5
+ # later never changes what an earlier invoice told the customer. Nobody writes or deletes it; the copied fields are
6
+ # read-only (only the flow sets them) and must equal the account at creation, so it cannot be made up by hand.
7
+ # An invoice submitted while the org has no default account has none: its print falls back to the letterhead.
8
+ name: payment_instruction
9
+ label: {id: Cara bayar faktur, en: Invoice payment instruction}
10
+ icon: bank
11
+ naming: CB-{YYYY}-{#####}
12
+ title_field: sales_invoice
13
+ permissions:
14
+ # create: the flow runs as whoever submits the invoice
15
+ - {role: finance_manager, read: true, create: true, export: true}
16
+ - {role: sales_manager, read: true, create: true, export: true}
17
+ - {role: head_office, read: true}
18
+ - {role: sales_rep, read: true}
19
+ # not field_sales: its row scope is salesman, which this model lacks, so it would read every invoice's amount
20
+ - {role: project_admin, read: true}
21
+ fields:
22
+ - name: sales_invoice
23
+ type: link
24
+ to: sales_invoice
25
+ label: {id: Faktur}
26
+ required: true
27
+ unique: true
28
+ in_list: true
29
+ - name: bank_account
30
+ type: link
31
+ to: bank_account
32
+ label: {id: Rekening}
33
+ required: true
34
+ in_list: true
35
+ # Payment reference the customer writes in the transfer note; bank_transaction_suggest finds the invoice by it.
36
+ - {name: reference, type: data, label: {id: Referensi bayar}, read_only: true, in_list: true}
37
+ - {name: amount, type: currency, label: {id: Tagihan saat diajukan}, read_only: true}
38
+ - {name: bank, type: data, label: {id: Bank}, read_only: true}
39
+ - {name: account_no, type: data, label: {id: Nomor rekening}, read_only: true}
40
+ - {name: holder, type: data, label: {id: Atas nama}, read_only: true}
41
+ - {name: instructions, type: text, label: {id: Instruksi bayar}, read_only: true}
42
+ - {name: qris_payload, type: text, label: {id: Isi QRIS (teks)}, read_only: true}
43
+ - {name: qris_nmid, type: data, label: {id: NMID}, read_only: true}
44
+ - {name: qris_merchant_name, type: data, label: {id: Nama merchant QRIS}, read_only: true}
45
+ rules:
46
+ - name: invoice_submitted
47
+ on: save
48
+ check: sales_invoice.docstatus == 1
49
+ message: {id: Cara bayar dibuat saat faktur diajukan}
50
+ - name: copy_of_invoice
51
+ on: save
52
+ check: reference == sales_invoice.name && amount == sales_invoice.amount_due
53
+ message: {id: Referensi dan nominal harus dari faktur ini}
54
+ - name: copy_of_account
55
+ on: save
56
+ check: >-
57
+ bank == bank_account.bank && account_no == bank_account.account_no && holder == bank_account.holder &&
58
+ instructions == bank_account.instructions && qris_payload == bank_account.qris_payload &&
59
+ qris_nmid == bank_account.qris_nmid && qris_merchant_name == bank_account.qris_merchant_name
60
+ message: {id: Cara bayar harus salinan rekening yang dipilih}
61
+ - name: account_active
62
+ on: save
63
+ check: bank_account.active
64
+ message: {id: Rekening tidak aktif}
65
+ views:
66
+ list:
67
+ columns: [name, sales_invoice, reference, bank, account_no, qris_nmid]
68
+ sort: -name
@@ -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: invoicing
3
- version: 1.3.0
3
+ version: 1.4.1
4
4
  title: {id: Faktur, en: Invoicing}
5
5
  requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0}
6
6
  optional: {outlets: ^1.0, tax_id: ^1.0, currency: ^1.0, orders: ^1.0, projects: ^1.0, delivery: ^1.0}
@@ -0,0 +1,59 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Rel uang U13/U17 (ready, not active): A payment-link callback (PAID or SETTLED is paid; EXPIRED is not). Xendit's external_id is
3
+ # the invoice number. The callback becomes a DRAFT payment allocated to that invoice (a flow cannot submit; finance
4
+ # submits it, which settles the invoice), carrying gateway xendit and the gateway id.
5
+ # Not active yet: the kernel has no connector runtime (no /hooks), so nothing fires this flow except
6
+ # POST /api/v1/flows/<name>/run with the callback as event (how day_one tests it). It is written against the xendit
7
+ # connector's trigger, not a payment.* port, because ports are not in the kernel yet (contract 0002 §B, proposal
8
+ # 0023); the three payment_from_xendit_* flows hold the same steps, one per trigger.
9
+ # Guards: a callback without gateway_ref, external_id, paid or paid_amount is skipped; only a completed payment of a
10
+ # positive amount records money. The gateway id is claimed BEFORE the payment is made: a new claim is an insert into
11
+ # gateway_ref_claim's unique index, so of two callbacks racing in parallel the second waits for the first and is
12
+ # refused (its whole run rolls back, nothing recorded); a later repeat finds the live payment or its claim and records
13
+ # nothing. A claim left by a deleted draft is released first (gateway_ref emptied, as payment_gateway_release does)
14
+ # and a new claim inserted, so racing repeats after a delete are refused the same way. Only a
15
+ # submitted invoice is paid (a cancelled one, or an unknown number, records nothing and tells the owner, since the
16
+ # money did arrive at Xendit); the allocation never exceeds what the invoice still owes after open drafts, the rest
17
+ # stays unallocated. A method outside payment's options is recorded as 'other'.
18
+ name: payment_from_xendit_invoice
19
+ label: {id: Link bayar Xendit dibayar jadi pembayaran}
20
+ on: xendit.invoice_paid
21
+ if: >-
22
+ 'gateway_ref' in event && 'external_id' in event && 'paid' in event && 'paid_amount' in event &&
23
+ event.gateway_ref != '' && event.paid == true && event.paid_amount > 0
24
+ idempotency: event.gateway_ref
25
+ steps:
26
+ - {find: payment, where: "gateway_ref == event.gateway_ref && docstatus != 2", as: done}
27
+ - {find: sales_invoice, where: "name == event.external_id && docstatus == 1", as: inv}
28
+ - {find_all: payment, where: "docstatus == 0 && reference == event.external_id", as: drafts}
29
+ - {find: gateway_ref_claim, where: gateway_ref == event.gateway_ref, as: held}
30
+ # the payment the claim names, if it is still alive (a deleted draft is gone; a renamed draft is re-pointed on submit)
31
+ - {find: payment, where: "held != null && name == held.payment && docstatus != 2", as: holder}
32
+ - update: held
33
+ if: done == null && inv != null && held != null && holder == null
34
+ set: {gateway_ref: "''", released_ref: event.gateway_ref}
35
+ - create: gateway_ref_claim
36
+ if: done == null && inv != null && (held == null || holder == null)
37
+ set: {gateway_ref: event.gateway_ref, payment: "''"}
38
+ as: claim
39
+ - create: payment
40
+ if: done == null && inv != null && (held == null || holder == null)
41
+ set:
42
+ direction: "'receive'"
43
+ customer: inv.customer
44
+ payment_date: today()
45
+ amount: event.paid_amount
46
+ method: "'method' in event && event.method in ['va', 'qris', 'ewallet', 'transfer'] ? event.method : 'other'"
47
+ gateway: "'xendit'"
48
+ gateway_ref: event.gateway_ref
49
+ reference: inv.name
50
+ notes: "'Dari Xendit ' + event.gateway_ref"
51
+ allocations: "min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum()) > 0 ? [{'sales_invoice': inv.name, 'amount': min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum())}] : []"
52
+ as: pay
53
+ - update: claim
54
+ if: done == null && inv != null && (held == null || holder == null)
55
+ set: {payment: pay.name}
56
+ - notify: owner
57
+ if: done == null && inv == null
58
+ channel: email
59
+ template: {id: 'Xendit {event.gateway_ref}: Rp {event.paid_amount} untuk {event.external_id}, faktur tidak ada/terbuka. Catat manual.'}
@@ -0,0 +1,59 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Rel uang U13/U17 (ready, not active): A QR callback (qr.payment SUCCEEDED is paid; a refund or a failed QR is not). Xendit's external_id is
3
+ # the invoice number. The callback becomes a DRAFT payment allocated to that invoice (a flow cannot submit; finance
4
+ # submits it, which settles the invoice), carrying gateway xendit and the gateway id.
5
+ # Not active yet: the kernel has no connector runtime (no /hooks), so nothing fires this flow except
6
+ # POST /api/v1/flows/<name>/run with the callback as event (how day_one tests it). It is written against the xendit
7
+ # connector's trigger, not a payment.* port, because ports are not in the kernel yet (contract 0002 §B, proposal
8
+ # 0023); the three payment_from_xendit_* flows hold the same steps, one per trigger.
9
+ # Guards: a callback without gateway_ref, external_id, paid or paid_amount is skipped; only a completed payment of a
10
+ # positive amount records money. The gateway id is claimed BEFORE the payment is made: a new claim is an insert into
11
+ # gateway_ref_claim's unique index, so of two callbacks racing in parallel the second waits for the first and is
12
+ # refused (its whole run rolls back, nothing recorded); a later repeat finds the live payment or its claim and records
13
+ # nothing. A claim left by a deleted draft is released first (gateway_ref emptied, as payment_gateway_release does)
14
+ # and a new claim inserted, so racing repeats after a delete are refused the same way. Only a
15
+ # submitted invoice is paid (a cancelled one, or an unknown number, records nothing and tells the owner, since the
16
+ # money did arrive at Xendit); the allocation never exceeds what the invoice still owes after open drafts, the rest
17
+ # stays unallocated. A method outside payment's options is recorded as 'other'.
18
+ name: payment_from_xendit_qr
19
+ label: {id: QRIS Xendit dibayar jadi pembayaran}
20
+ on: xendit.qr_paid
21
+ if: >-
22
+ 'gateway_ref' in event && 'external_id' in event && 'paid' in event && 'paid_amount' in event &&
23
+ event.gateway_ref != '' && event.paid == true && event.paid_amount > 0
24
+ idempotency: event.gateway_ref
25
+ steps:
26
+ - {find: payment, where: "gateway_ref == event.gateway_ref && docstatus != 2", as: done}
27
+ - {find: sales_invoice, where: "name == event.external_id && docstatus == 1", as: inv}
28
+ - {find_all: payment, where: "docstatus == 0 && reference == event.external_id", as: drafts}
29
+ - {find: gateway_ref_claim, where: gateway_ref == event.gateway_ref, as: held}
30
+ # the payment the claim names, if it is still alive (a deleted draft is gone; a renamed draft is re-pointed on submit)
31
+ - {find: payment, where: "held != null && name == held.payment && docstatus != 2", as: holder}
32
+ - update: held
33
+ if: done == null && inv != null && held != null && holder == null
34
+ set: {gateway_ref: "''", released_ref: event.gateway_ref}
35
+ - create: gateway_ref_claim
36
+ if: done == null && inv != null && (held == null || holder == null)
37
+ set: {gateway_ref: event.gateway_ref, payment: "''"}
38
+ as: claim
39
+ - create: payment
40
+ if: done == null && inv != null && (held == null || holder == null)
41
+ set:
42
+ direction: "'receive'"
43
+ customer: inv.customer
44
+ payment_date: today()
45
+ amount: event.paid_amount
46
+ method: "'method' in event && event.method in ['va', 'qris', 'ewallet', 'transfer'] ? event.method : 'other'"
47
+ gateway: "'xendit'"
48
+ gateway_ref: event.gateway_ref
49
+ reference: inv.name
50
+ notes: "'Dari Xendit ' + event.gateway_ref"
51
+ allocations: "min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum()) > 0 ? [{'sales_invoice': inv.name, 'amount': min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum())}] : []"
52
+ as: pay
53
+ - update: claim
54
+ if: done == null && inv != null && (held == null || holder == null)
55
+ set: {payment: pay.name}
56
+ - notify: owner
57
+ if: done == null && inv == null
58
+ channel: email
59
+ template: {id: 'Xendit {event.gateway_ref}: Rp {event.paid_amount} untuk {event.external_id}, faktur tidak ada/terbuka. Catat manual.'}
@@ -0,0 +1,59 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Rel uang U13/U17 (ready, not active): A fixed VA payment (always a completed payment). Xendit's external_id is
3
+ # the invoice number. The callback becomes a DRAFT payment allocated to that invoice (a flow cannot submit; finance
4
+ # submits it, which settles the invoice), carrying gateway xendit and the gateway id.
5
+ # Not active yet: the kernel has no connector runtime (no /hooks), so nothing fires this flow except
6
+ # POST /api/v1/flows/<name>/run with the callback as event (how day_one tests it). It is written against the xendit
7
+ # connector's trigger, not a payment.* port, because ports are not in the kernel yet (contract 0002 §B, proposal
8
+ # 0023); the three payment_from_xendit_* flows hold the same steps, one per trigger.
9
+ # Guards: a callback without gateway_ref, external_id, paid or paid_amount is skipped; only a completed payment of a
10
+ # positive amount records money. The gateway id is claimed BEFORE the payment is made: a new claim is an insert into
11
+ # gateway_ref_claim's unique index, so of two callbacks racing in parallel the second waits for the first and is
12
+ # refused (its whole run rolls back, nothing recorded); a later repeat finds the live payment or its claim and records
13
+ # nothing. A claim left by a deleted draft is released first (gateway_ref emptied, as payment_gateway_release does)
14
+ # and a new claim inserted, so racing repeats after a delete are refused the same way. Only a
15
+ # submitted invoice is paid (a cancelled one, or an unknown number, records nothing and tells the owner, since the
16
+ # money did arrive at Xendit); the allocation never exceeds what the invoice still owes after open drafts, the rest
17
+ # stays unallocated. A method outside payment's options is recorded as 'other'.
18
+ name: payment_from_xendit_va
19
+ label: {id: Virtual account Xendit dibayar jadi pembayaran}
20
+ on: xendit.va_paid
21
+ if: >-
22
+ 'gateway_ref' in event && 'external_id' in event && 'paid' in event && 'paid_amount' in event &&
23
+ event.gateway_ref != '' && event.paid == true && event.paid_amount > 0
24
+ idempotency: event.gateway_ref
25
+ steps:
26
+ - {find: payment, where: "gateway_ref == event.gateway_ref && docstatus != 2", as: done}
27
+ - {find: sales_invoice, where: "name == event.external_id && docstatus == 1", as: inv}
28
+ - {find_all: payment, where: "docstatus == 0 && reference == event.external_id", as: drafts}
29
+ - {find: gateway_ref_claim, where: gateway_ref == event.gateway_ref, as: held}
30
+ # the payment the claim names, if it is still alive (a deleted draft is gone; a renamed draft is re-pointed on submit)
31
+ - {find: payment, where: "held != null && name == held.payment && docstatus != 2", as: holder}
32
+ - update: held
33
+ if: done == null && inv != null && held != null && holder == null
34
+ set: {gateway_ref: "''", released_ref: event.gateway_ref}
35
+ - create: gateway_ref_claim
36
+ if: done == null && inv != null && (held == null || holder == null)
37
+ set: {gateway_ref: event.gateway_ref, payment: "''"}
38
+ as: claim
39
+ - create: payment
40
+ if: done == null && inv != null && (held == null || holder == null)
41
+ set:
42
+ direction: "'receive'"
43
+ customer: inv.customer
44
+ payment_date: today()
45
+ amount: event.paid_amount
46
+ method: "'method' in event && event.method in ['va', 'qris', 'ewallet', 'transfer'] ? event.method : 'other'"
47
+ gateway: "'xendit'"
48
+ gateway_ref: event.gateway_ref
49
+ reference: inv.name
50
+ notes: "'Dari Xendit ' + event.gateway_ref"
51
+ allocations: "min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum()) > 0 ? [{'sales_invoice': inv.name, 'amount': min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum())}] : []"
52
+ as: pay
53
+ - update: claim
54
+ if: done == null && inv != null && (held == null || holder == null)
55
+ set: {payment: pay.name}
56
+ - notify: owner
57
+ if: done == null && inv == null
58
+ channel: email
59
+ template: {id: 'Xendit {event.gateway_ref}: Rp {event.paid_amount} untuk {event.external_id}, faktur tidak ada/terbuka. Catat manual.'}
@@ -46,11 +46,13 @@ fields:
46
46
  type: select
47
47
  label: {id: Metode}
48
48
  default: "'transfer'"
49
+ # "Potong retur" (sales_return) is not listed here: it only works with the delivery module, and a select option
50
+ # cannot depend on an installed app, so a site that installs delivery adds it in custom/payment.rk
51
+ # (examples/sites/demo-grosir). Without it the option was always refused (audit re-pin alpha.7, L2).
49
52
  options:
50
53
  - {value: transfer, label: {id: Transfer}}
51
54
  - {value: cash, label: {id: Tunai}}
52
55
  - {value: giro, label: {id: Giro}}
53
- - {value: sales_return, label: {id: Potong retur}}
54
56
  - {value: qris, label: {id: QRIS}}
55
57
  - {value: va, label: {id: Virtual account}}
56
58
  - {value: ewallet, label: {id: E-wallet}}
@@ -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: payments
3
- version: 1.2.0
3
+ version: 1.3.0
4
4
  title: {id: Pembayaran, en: Payments}
5
5
  requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, invoicing: ^1.0, procurement: ^1.0}
6
6
  optional: {currency: ^1.0, delivery: ^1.0}
@@ -0,0 +1,28 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ name: timesheet_assignment_on_create
3
+ label: {id: Absensi memakai tarif penugasan}
4
+ # An attendance recap import (or a timesheet typed without its assignment) names only the project and the worker. This
5
+ # finds the worker's assignment on that project covering the start of the work and takes its rates, so the client's
6
+ # rate and the project's pay apply instead of the worker's general ones. No assignment found: the worker's rates
7
+ # (the timesheet defaults) stay. A recap counts days, so it stays per day: an hourly assignment gives its day rate
8
+ # and the worker's pay per day stays (an hourly assignment's cost_rate is per hour). Runs on the draft, before anyone submits it. Only for recaps (period_to set): a daily
9
+ # timesheet typed by hand keeps the rates its author typed.
10
+ on: timesheet.created
11
+ if: event.assignment == '' && event.period_to != '' && event.docstatus == 0
12
+ steps:
13
+ - find: assignment
14
+ where: project == event.project && worker == event.worker && start_date <= event.work_date && end_date >= event.work_date
15
+ as: asg
16
+ - if: asg != null
17
+ find: timesheet
18
+ where: name == event.name
19
+ as: ts
20
+ - if: asg != null
21
+ update: ts
22
+ set:
23
+ assignment: asg.name
24
+ day_rate: asg.day_rate
25
+ hour_rate: asg.hour_rate
26
+ cost_rate: "asg.rate_basis == 'day' ? asg.cost_rate : ts.cost_rate"
27
+ overtime_rate: asg.overtime_rate
28
+ overtime_cost_rate: asg.overtime_cost_rate
@@ -0,0 +1,23 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/import.json
2
+ # Monthly attendance recap (G7): one row per worker per project per cut-off period, as fingerprint machines and HR apps
3
+ # export it (Rekap Absensi: days present and overtime hours per person for a date range, often the 21st to the 20th).
4
+ # Each row becomes one draft timesheet for the period, priced from the worker's assignment on the project
5
+ # (timesheet_assignment_on_create) or, without one, from the worker. Proyek is the project number (PRJ-...), No.
6
+ # pegawai the worker's employee number. Columns Nama and others are ignored. The same worker, project and start date
7
+ # twice is skipped by the key; a wrong file is undone by deleting its drafts, a submitted one by cancelling it.
8
+ name: attendance_recap
9
+ label: {id: Rekap absensi bulanan, en: Monthly attendance recap}
10
+ model: timesheet
11
+ source: xlsx
12
+ header_row: 1
13
+ key: [Proyek, No. pegawai, Dari tanggal]
14
+ map:
15
+ project: Proyek
16
+ worker: {value: No. pegawai, match: employee_no}
17
+ work_date: Dari tanggal
18
+ period_to: Sampai tanggal
19
+ # An empty cell must not become the model's default of 1 day: -1 makes the row fail recap_days with its message.
20
+ days: "=row['Hari hadir'] == '' ? '-1' : row['Hari hadir']"
21
+ overtime_hours: "='Jam lembur' in row && row['Jam lembur'] != '' ? row['Jam lembur'] : '0'"
22
+ rate_basis: "='day'"
23
+ description: "='Rekap absensi ' + row['Dari tanggal'] + ' s.d. ' + row['Sampai tanggal']"
@@ -6,7 +6,7 @@ naming: ASG-{#####}
6
6
  title_field: worker
7
7
  permissions:
8
8
  - {role: project_admin, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
9
- - {role: sales_manager, read: true}
9
+ # No sales_manager: an assignment carries the cost rates (audit L1).
10
10
  - {role: finance_manager, read: true}
11
11
  fields:
12
12
  - name: project
@@ -57,10 +57,23 @@ fields:
57
57
  type: currency
58
58
  label: {id: Biaya per satuan}
59
59
  default: "rate_basis == 'hour' ? worker.cost_hour_rate : worker.cost_day_rate"
60
+ # Overtime per hour on this project, from the worker unless the client agreed another rate.
61
+ - name: overtime_rate
62
+ type: currency
63
+ label: {id: Tarif jual lembur per jam}
64
+ default: worker.overtime_rate
65
+ - name: overtime_cost_rate
66
+ type: currency
67
+ label: {id: Upah lembur per jam}
68
+ default: worker.overtime_cost_rate
60
69
  - name: notes
61
70
  type: text
62
71
  label: {id: Catatan}
63
72
  rules:
73
+ - name: rates_not_negative
74
+ on: save
75
+ check: day_rate >= 0 && hour_rate >= 0 && cost_rate >= 0 && overtime_rate >= 0 && overtime_cost_rate >= 0
76
+ message: {id: 'Tarif dan upah tidak boleh negatif'}
64
77
  - name: end_after_start
65
78
  on: save
66
79
  check: end_date >= start_date
@@ -77,7 +90,7 @@ views:
77
90
  - [start_date, end_date]
78
91
  - section: {id: Tarif}
79
92
  columns:
80
- - [rate_basis, day_rate, hour_rate]
81
- - [cost_rate]
93
+ - [rate_basis, day_rate, hour_rate, overtime_rate]
94
+ - [cost_rate, overtime_cost_rate]
82
95
  - section: {id: Catatan}
83
96
  fields: [notes]
@@ -19,8 +19,11 @@ title_field: project
19
19
  permissions:
20
20
  - {role: project_admin, read: true, create: true, export: true}
21
21
  - {role: finance_manager, read: true, create: true, export: true}
22
- - {role: sales_manager, read: true, create: true, export: true}
23
- - {role: purchasing_manager, read: true, create: true}
22
+ # Sales and purchasing read (and their flows write) only the rows of their own documents: labour rows carry pay and
23
+ # cost rows the firm's margin (audit L1). Read stays because the cancel flows find the row they reverse as the person
24
+ # cancelling. No export for sales.
25
+ - {role: sales_manager, read: true, create: true, if: kind == 'revenue'}
26
+ - {role: purchasing_manager, read: true, create: true, if: kind == 'vendor'}
24
27
  fields:
25
28
  - name: project
26
29
  type: link
@@ -1,13 +1,13 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
2
  name: timesheet
3
- label: {id: Timesheet}
3
+ label: {id: Absensi, en: Timesheet}
4
4
  icon: calendar
5
5
  is_submittable: true
6
6
  naming: TS-{YYYY}-{#####}
7
7
  title_field: worker
8
8
  permissions:
9
- - {role: project_admin, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
10
- - {role: sales_manager, read: true}
9
+ - {role: project_admin, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, import: true, print: true}
10
+ # No sales_manager: a timesheet carries pay and cost (audit L1).
11
11
  - {role: finance_manager, read: true}
12
12
  fields:
13
13
  - name: project
@@ -31,11 +31,21 @@ fields:
31
31
  label: {id: Tanggal kerja}
32
32
  required: true
33
33
  in_list: true
34
+ # A monthly recap (G7): work_date is the first day of the cut-off period and period_to its last (21 Oct to 20 Nov,
35
+ # or a calendar month), days the days present in it. Empty period_to = one day, as before.
36
+ - name: period_to
37
+ type: date
38
+ label: {id: Sampai tanggal (rekap)}
39
+ in_list: true
34
40
  - name: days
35
41
  type: float
36
42
  label: {id: Hari kerja}
37
43
  default: '1'
38
44
  in_list: true
45
+ - name: overtime_hours
46
+ type: float
47
+ label: {id: Jam lembur}
48
+ default: '0'
39
49
  - name: hours
40
50
  type: float
41
51
  label: {id: Jam}
@@ -53,7 +63,7 @@ fields:
53
63
  - name: day_rate
54
64
  type: currency
55
65
  label: {id: Tarif per hari}
56
- default: assignment.day_rate
66
+ default: "assignment != '' ? assignment.day_rate : worker.day_rate"
57
67
  # Per hour when the assignment bills per hour (consultants); per day otherwise, as before.
58
68
  - name: rate_basis
59
69
  type: select
@@ -70,48 +80,82 @@ fields:
70
80
  type: currency
71
81
  label: {id: Biaya per satuan}
72
82
  default: "assignment != '' ? assignment.cost_rate : (rate_basis == 'hour' ? worker.cost_hour_rate : worker.cost_day_rate)"
83
+ - name: overtime_rate
84
+ type: currency
85
+ label: {id: Tarif jual lembur per jam}
86
+ default: "assignment != '' ? assignment.overtime_rate : worker.overtime_rate"
87
+ - name: overtime_cost_rate
88
+ type: currency
89
+ label: {id: Upah lembur per jam}
90
+ default: "assignment != '' ? assignment.overtime_cost_rate : worker.overtime_cost_rate"
73
91
  - name: amount
74
92
  type: currency
75
93
  label: {id: Jumlah}
76
- compute: "rate_basis == 'hour' ? round(hours * hour_rate) : round(days * day_rate)"
94
+ compute: "(rate_basis == 'hour' ? round(hours * hour_rate) : round(days * day_rate)) + round(overtime_hours * overtime_rate)"
77
95
  in_list: true
78
96
  - name: cost_amount
79
97
  type: currency
80
98
  label: {id: Biaya}
81
- compute: "round((rate_basis == 'hour' ? hours : days) * cost_rate)"
99
+ compute: "round((rate_basis == 'hour' ? hours : days) * cost_rate) + round(overtime_hours * overtime_cost_rate)"
100
+ # No pay entered for this work (G5): the cost is not 0, it is unknown. The project margin dashboard counts these so
101
+ # a margin without labour cost is read as incomplete; fix the pay on the worker, then cancel and amend.
102
+ - name: cost_missing
103
+ type: check
104
+ label: {id: Upah belum diisi}
105
+ compute: "cost_rate == 0 || (overtime_hours > 0 && overtime_cost_rate == 0)"
82
106
  - name: billable_amount
83
107
  type: currency
84
108
  label: {id: Jumlah dapat ditagih}
85
109
  compute: "billable ? amount : 0"
86
110
  rules:
111
+ - name: rates_not_negative
112
+ on: save
113
+ check: day_rate >= 0 && hour_rate >= 0 && cost_rate >= 0 && overtime_rate >= 0 && overtime_cost_rate >= 0
114
+ message: {id: 'Tarif dan upah tidak boleh negatif'}
87
115
  - name: days_range
88
116
  on: save
89
- check: rate_basis == 'hour' || (days > 0 && days <= 1.5)
117
+ check: rate_basis == 'hour' || period_to != '' || (days > 0 && days <= 1.5)
90
118
  message: {id: 'Hari kerja harus lebih dari 0 dan paling banyak 1,5'}
119
+ # A recap covers at most 31 days, never runs backwards, and cannot hold more days present than days in the period.
120
+ # date + duration drops a fraction of a day, so days are rounded up first (round(x + 0.49): 1,5 -> 2, 1,9 -> 2).
121
+ - name: recap_period
122
+ on: save
123
+ check: period_to == '' || (period_to >= work_date && period_to < work_date + duration(31))
124
+ message: {id: 'Periode rekap: sampai tanggal tidak boleh sebelum tanggal mulai, paling lama 31 hari'}
125
+ - name: recap_days
126
+ on: save
127
+ check: >-
128
+ period_to == '' || rate_basis == 'hour'
129
+ || (days >= 0 && (days > 0 || overtime_hours > 0) && work_date + duration(round(days + 0.49) - 1) <= period_to)
130
+ message: {id: 'Hari hadir rekap harus lebih dari 0 dan tidak melebihi jumlah hari di periodenya'}
131
+ - name: overtime_range
132
+ on: save
133
+ check: "overtime_hours >= 0 && (period_to == '' ? overtime_hours <= 24 : work_date + duration(round(overtime_hours / 24 + 0.49) - 1) <= period_to)"
134
+ message: {id: 'Jam lembur tidak boleh negatif atau melebihi jam di periodenya'}
91
135
  - name: hour_rate_for_billable_hours
92
136
  on: save
93
137
  check: rate_basis != 'hour' || !billable || hour_rate > 0
94
138
  message: {id: 'Timesheet per jam yang ditagih butuh tarif per jam (isi di tenaga kerja atau penugasan)'}
95
139
  - name: hours_range
96
140
  on: save
97
- check: rate_basis != 'hour' || (hours > 0 && hours <= 24)
98
- message: {id: 'Jam kerja harus lebih dari 0 dan paling banyak 24'}
141
+ check: "rate_basis != 'hour' || (hours > 0 && hours <= (period_to == '' ? 24 : 744))"
142
+ message: {id: 'Jam kerja harus lebih dari 0 dan paling banyak 24 per hari'}
99
143
  views:
100
144
  list:
101
- columns: [name, project, worker, work_date, days, status, amount]
145
+ columns: [name, project, worker, work_date, period_to, days, status, amount]
102
146
  sort: -work_date
103
147
  form:
104
148
  layout:
105
149
  - section: {id: Timesheet}
106
150
  columns:
107
151
  - [project, worker, assignment]
108
- - [work_date, days, hours]
152
+ - [work_date, period_to, days, hours, overtime_hours]
109
153
  - section: {id: Pekerjaan}
110
154
  columns:
111
155
  - [description, evidence]
112
156
  - section: {id: Tagihan}
113
157
  columns:
114
- - [billable, rate_basis, day_rate, hour_rate, amount]
115
- - section: {id: Biaya internal}
158
+ - [billable, rate_basis, day_rate, hour_rate, overtime_rate, amount]
159
+ - section: {id: Upah (biaya internal)}
116
160
  columns:
117
- - [cost_rate, cost_amount]
161
+ - [cost_rate, overtime_cost_rate, cost_amount, cost_missing]
@@ -1,7 +1,9 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/import.json
2
2
  # The opening list of field workers (manpower, inspectors, trainers): one row per person. Certifications are added on
3
3
  # the worker afterwards (a table field, not part of this file). Name plus employee number is the duplicate key, so
4
- # workers without a number can share a file.
4
+ # workers without a number can share a file. Tarif harian is the selling rate per day; Upah harian (pay per day) and
5
+ # the overtime rates per hour are optional columns, so a file in the older template still imports: a worker without
6
+ # pay is flagged on the project margin dashboard instead of counting as zero cost.
5
7
  name: worker_list
6
8
  label: {id: Daftar tenaga kerja, en: Worker list}
7
9
  model: worker
@@ -14,3 +16,6 @@ map:
14
16
  role_title: Jabatan
15
17
  phone: WhatsApp
16
18
  day_rate: Tarif harian
19
+ cost_day_rate: "='Upah harian' in row && row['Upah harian'] != '' ? row['Upah harian'] : '0'"
20
+ overtime_rate: "='Tarif lembur per jam' in row && row['Tarif lembur per jam'] != '' ? row['Tarif lembur per jam'] : '0'"
21
+ overtime_cost_rate: "='Upah lembur per jam' in row && row['Upah lembur per jam'] != '' ? row['Upah lembur per jam'] : '0'"
@@ -5,9 +5,9 @@ icon: user
5
5
  naming: WRK-{####}
6
6
  title_field: worker_name
7
7
  permissions:
8
- - {role: sales_manager, read: true, create: true, write: true, print: true}
8
+ # Pay (cost_*_rate, overtime_cost_rate) lives on the worker and hidden_for is not enforced by the kernel, so sales and
9
+ # purchasing have no access at all (audit L1): workers are managed by finance and the project admin.
9
10
  - {role: finance_manager, read: true, create: true, write: true, print: true}
10
- - {role: purchasing_manager, read: true, create: true, write: true, print: true}
11
11
  - {role: project_admin, read: true, create: true, write: true, print: true}
12
12
  - {role: head_office, read: true, create: true, write: true, print: true}
13
13
  - {role: outlet_staff, read: true}
@@ -28,9 +28,10 @@ fields:
28
28
  - name: phone
29
29
  type: phone
30
30
  label: {id: Nomor WhatsApp}
31
+ # Selling rate per day: what the client pays for a day of this person (the invoice side).
31
32
  - name: day_rate
32
33
  type: currency
33
- label: {id: Tarif per hari}
34
+ label: {id: Tarif jual per hari}
34
35
  in_list: true
35
36
  # Selling rate per hour, and what an hour or a day of this person costs the firm (pay divided by working days or
36
37
  # hours, entered by the owner): project margin reads the cost, the invoice reads the selling rate.
@@ -40,14 +41,27 @@ fields:
40
41
  default: '0'
41
42
  # Pay per person: hidden in forms and lists for roles that do not need it (hidden_for is not enforced by the kernel
42
43
  # yet; the REST API still returns it to anyone who may read worker).
44
+ # Pay per day (upah harian). 0 means not entered yet: timesheets of this person are then flagged cost_missing and
45
+ # the project margin dashboard counts them, so a margin without labour cost is never read as complete.
43
46
  - name: cost_day_rate
44
47
  type: currency
45
- label: {id: Biaya per hari}
48
+ label: {id: Upah per hari}
46
49
  default: '0'
47
50
  hidden_for: [sales_manager, purchasing_manager, head_office, outlet_staff, sales_rep]
48
51
  - name: cost_hour_rate
49
52
  type: currency
50
- label: {id: Biaya per jam}
53
+ label: {id: Upah per jam}
54
+ default: '0'
55
+ hidden_for: [sales_manager, purchasing_manager, head_office, outlet_staff, sales_rep]
56
+ # Overtime per hour: what the client pays (overtime_rate) and what the firm pays (overtime_cost_rate). Enter the
57
+ # rates already weighted the way the firm counts overtime (PP 35/2021 multipliers vary per hour of the day).
58
+ - name: overtime_rate
59
+ type: currency
60
+ label: {id: Tarif jual lembur per jam}
61
+ default: '0'
62
+ - name: overtime_cost_rate
63
+ type: currency
64
+ label: {id: Upah lembur per jam}
51
65
  default: '0'
52
66
  hidden_for: [sales_manager, purchasing_manager, head_office, outlet_staff, sales_rep]
53
67
  - name: active
@@ -58,6 +72,12 @@ fields:
58
72
  type: table
59
73
  of: certification
60
74
  label: {id: Sertifikasi}
75
+ rules:
76
+ # A negative pay would raise the project margin instead of lowering it (audit 6 Nov).
77
+ - name: rates_not_negative
78
+ on: save
79
+ check: day_rate >= 0 && hour_rate >= 0 && cost_day_rate >= 0 && cost_hour_rate >= 0 && overtime_rate >= 0 && overtime_cost_rate >= 0
80
+ message: {id: 'Tarif dan upah tidak boleh negatif'}
61
81
  views:
62
82
  list:
63
83
  columns: [name, worker_name, role_title, day_rate, active]
@@ -66,9 +86,9 @@ views:
66
86
  - section: {id: Identitas}
67
87
  columns:
68
88
  - [worker_name, employee_no, role_title]
69
- - [phone, day_rate, hour_rate, active]
70
- - section: {id: Biaya internal}
89
+ - [phone, day_rate, hour_rate, overtime_rate, active]
90
+ - section: {id: Upah (biaya internal)}
71
91
  columns:
72
- - [cost_day_rate, cost_hour_rate]
92
+ - [cost_day_rate, cost_hour_rate, overtime_cost_rate]
73
93
  - section: {id: Sertifikasi}
74
94
  fields: [certifications]