@rangka-os/create 0.5.0-alpha.10 → 0.5.0-alpha.11
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.
- package/package.json +1 -1
- package/template/base/apps/dapur/app.rk +35 -0
- package/template/base/apps/dapur/dashboards/dapur_hari_ini.rk +26 -0
- package/template/base/apps/fnb_cabang/app.rk +2 -2
- package/template/base/apps/fnb_cabang/dashboards/outlet_harian.rk +36 -0
- package/template/base/apps/jasa_proyek/app.rk +5 -2
- package/template/base/apps/jasa_proyek/dashboards/absen_saya.rk +15 -0
- package/template/base/apps/jasa_proyek/dashboards/rekap_absen.rk +18 -0
- package/template/base/apps/kelas_kursus/app.rk +1 -1
- package/template/base/apps/kelas_kursus/dashboards/kelas_saya.rk +41 -0
- package/template/base/apps/penjualan_harian/app.rk +1 -1
- package/template/base/apps/ritel_cabang/app.rk +1 -1
- package/template/base/apps/sewa_alat/app.rk +7 -5
- package/template/base/apps/sewa_alat/dashboards/alat_hari_ini.rk +90 -0
- package/template/base/apps/stok_outlet/app.rk +1 -1
- package/template/base/apps/stok_outlet/dashboards/outlet_hari_ini.rk +33 -0
- package/template/base/connectors/doku/connector.rk +128 -0
- package/template/base/connectors/doku/fixtures/create_checkout.json +6 -0
- package/template/base/connectors/doku/fixtures/expect.json +38 -0
- package/template/base/connectors/doku/fixtures/payment_notified.json +5 -0
- package/template/base/connectors/doku/fixtures/payment_notified_failed.json +3 -0
- package/template/base/connectors/doku/fixtures/payment_notified_no_type.json +3 -0
- package/template/base/connectors/doku/fixtures/payment_notified_null_type.json +3 -0
- package/template/base/connectors/doku/fixtures/payment_notified_refund.json +3 -0
- package/template/base/connectors/doku/mock/doku_mock.py +206 -0
- package/template/base/connectors/moka/connector.rk +46 -12
- package/template/base/connectors/moka/fixtures/expect.json +44 -0
- package/template/base/connectors/moka/fixtures/latest_transactions.json +79 -0
- package/template/base/connectors/moka/fixtures/list_items.json +4 -0
- package/template/base/connectors/moka/fixtures/list_outlets.json +4 -0
- package/template/base/connectors/moka/fixtures/transaction_created.json +44 -0
- package/template/base/connectors/moka/fixtures/transaction_created_refund.json +39 -0
- package/template/base/connectors/moka/fixtures/transaction_created_refund_later.json +51 -0
- package/template/base/modules/courses/models/course_batch.rk +7 -0
- package/template/base/modules/courses/models/course_session.rk +4 -1
- package/template/base/modules/courses/module.rk +1 -1
- package/template/base/modules/kitchen/flows/kitchen_ticket_on_sale.rk +29 -0
- package/template/base/modules/kitchen/flows/kitchen_ticket_on_update.rk +26 -0
- package/template/base/modules/kitchen/flows/kitchen_ticket_on_void.rk +15 -0
- package/template/base/modules/kitchen/models/kitchen_guard.rk +35 -0
- package/template/base/modules/kitchen/models/kitchen_route.rk +26 -0
- package/template/base/modules/kitchen/models/kitchen_station.rk +40 -0
- package/template/base/modules/kitchen/models/kitchen_ticket.rk +78 -0
- package/template/base/modules/kitchen/models/kitchen_ticket_item.rk +10 -0
- package/template/base/modules/kitchen/module.rk +18 -0
- package/template/base/modules/kitchen/print/kitchen_ticket.html +29 -0
- package/template/base/modules/kitchen/print/kitchen_ticket.rk +9 -0
- package/template/base/modules/kitchen/roles/kitchen.rk +6 -0
- package/template/base/modules/kitchen/screens/dapur.rk +22 -0
- package/template/base/modules/outlet_sales/flows/moka_daily_sales.rk +57 -0
- package/template/base/modules/outlet_sales/flows/moka_line_mapped.rk +14 -0
- package/template/base/modules/outlet_sales/flows/moka_transaction_staged.rk +90 -0
- package/template/base/modules/outlet_sales/models/moka_sale_line.rk +53 -0
- package/template/base/modules/outlet_sales/models/moka_transaction.rk +26 -0
- package/template/base/modules/outlet_sales/models/outlet_sales.rk +4 -3
- package/template/base/modules/outlet_sales/module.rk +1 -1
- package/template/base/modules/outlets/models/outlet.rk +9 -0
- package/template/base/modules/payments/flows/payment_from_doku.rk +73 -0
- package/template/base/modules/payments/models/payment.rk +1 -0
- package/template/base/modules/payments/module.rk +1 -1
- package/template/base/modules/projects/flows/attendance_close_cancel_guard.rk +15 -0
- package/template/base/modules/projects/flows/attendance_close_on_submit.rk +64 -0
- package/template/base/modules/projects/flows/attendance_log_cancel_guard.rk +14 -0
- package/template/base/modules/projects/flows/attendance_log_guard_created.rk +15 -0
- package/template/base/modules/projects/flows/attendance_log_guard_submitted.rk +34 -0
- package/template/base/modules/projects/flows/attendance_log_guard_updated.rk +14 -0
- package/template/base/modules/projects/flows/timesheet_attendance_overlap_guard.rk +20 -0
- package/template/base/modules/projects/models/assignment.rk +21 -1
- package/template/base/modules/projects/models/attendance_close.rk +63 -0
- package/template/base/modules/projects/models/attendance_guard.rk +57 -0
- package/template/base/modules/projects/models/attendance_log.rk +266 -0
- package/template/base/modules/projects/models/timesheet.rk +7 -1
- package/template/base/modules/projects/models/work_site.rk +73 -0
- package/template/base/modules/projects/module.rk +1 -1
- package/template/base/modules/projects/roles/field_worker.rk +7 -0
- package/template/base/modules/projects/roles/site_supervisor.rk +7 -0
- package/template/base/modules/rental/flows/rental_checkout_on_cancel.rk +11 -0
- package/template/base/modules/rental/flows/rental_checkout_on_submit.rk +13 -1
- package/template/base/modules/rental/flows/rental_return_on_cancel.rk +12 -1
- package/template/base/modules/rental/flows/rental_return_on_submit.rk +17 -0
- package/template/base/modules/rental/models/rental_booking.rk +1 -0
- package/template/base/modules/rental/models/rental_checkout.rk +61 -2
- package/template/base/modules/rental/models/rental_checkout_unit.rk +22 -0
- package/template/base/modules/rental/models/rental_guard.rk +21 -0
- package/template/base/modules/rental/models/rental_item.rk +10 -2
- package/template/base/modules/rental/models/rental_return.rk +67 -8
- package/template/base/modules/rental/models/rental_return_unit.rk +29 -0
- package/template/base/modules/rental/models/rental_schedule.rk +2 -0
- package/template/base/modules/rental/models/rental_unit.rk +73 -0
- package/template/base/modules/rental/module.rk +7 -1
- package/template/base/modules/rental/print/rental_bast_in.html +107 -0
- package/template/base/modules/rental/print/rental_bast_in.rk +9 -0
- package/template/base/modules/rental/print/rental_bast_out.html +98 -0
- package/template/base/modules/rental/print/rental_bast_out.rk +11 -0
- package/template/base/modules/rental/roles/rental_staff.rk +7 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# A DOKU payment notification (connector doku, trigger payment_notified; DOKU Checkout with QRIS or another channel)
|
|
3
|
+
# whose invoice_number is a sales invoice becomes a DRAFT payment allocated to that invoice, gateway doku, as the
|
|
4
|
+
# Xendit flows do (payment_from_xendit_qr holds the reasoning). The kernel checks DOKU's signature before this runs
|
|
5
|
+
# (rangka-os contract 0002, canonical-line signatures), so a forged notification never starts it.
|
|
6
|
+
# Only transaction.status SUCCESS of a positive amount records money (paid). gateway_ref is DOKU's original request id
|
|
7
|
+
# of the payment: the flow's idempotency key and the payment's gateway_ref, claimed in gateway_ref_claim BEFORE the
|
|
8
|
+
# payment is made, so two notifications racing (DOKU retries at +30 min, +6 h, +12 h) record one payment.
|
|
9
|
+
# A notification for an unknown or cancelled invoice records nothing and tells the owner: the money is at DOKU.
|
|
10
|
+
# Method: DOKU channel QRIS is qris, a VIRTUAL_ACCOUNT channel or service is va, the rest other.
|
|
11
|
+
name: payment_from_doku
|
|
12
|
+
label: {id: Pembayaran DOKU jadi pembayaran faktur}
|
|
13
|
+
on: doku.payment_notified
|
|
14
|
+
# Every paid notification runs the flow; one without DOKU's id or with no readable positive amount records nothing and
|
|
15
|
+
# tells the owner (the money is at DOKU), instead of being skipped silently (audit 2026-11-11 M2). The amount may come
|
|
16
|
+
# as a number or a string of digits.
|
|
17
|
+
if: "'paid' in event && event.paid == true"
|
|
18
|
+
idempotency: "'gateway_ref' in event ? event.gateway_ref : ''"
|
|
19
|
+
steps:
|
|
20
|
+
- find: payment
|
|
21
|
+
if: "'gateway_ref' in event && event.gateway_ref != '' && 'external_id' in event && 'paid_amount' in event && string(event.paid_amount).matches('^[0-9]+([.][0-9]+)?$') && double(string(event.paid_amount)) > 0"
|
|
22
|
+
where: "gateway_ref == event.gateway_ref && docstatus != 2"
|
|
23
|
+
as: done
|
|
24
|
+
- find: sales_invoice
|
|
25
|
+
if: "'gateway_ref' in event && event.gateway_ref != '' && 'external_id' in event && 'paid_amount' in event && string(event.paid_amount).matches('^[0-9]+([.][0-9]+)?$') && double(string(event.paid_amount)) > 0"
|
|
26
|
+
where: "name == event.external_id && docstatus == 1"
|
|
27
|
+
as: inv
|
|
28
|
+
- find_all: payment
|
|
29
|
+
if: "'gateway_ref' in event && event.gateway_ref != '' && 'external_id' in event && 'paid_amount' in event && string(event.paid_amount).matches('^[0-9]+([.][0-9]+)?$') && double(string(event.paid_amount)) > 0"
|
|
30
|
+
where: "docstatus == 0 && reference == event.external_id"
|
|
31
|
+
as: drafts
|
|
32
|
+
- find: gateway_ref_claim
|
|
33
|
+
if: "'gateway_ref' in event && event.gateway_ref != '' && 'external_id' in event && 'paid_amount' in event && string(event.paid_amount).matches('^[0-9]+([.][0-9]+)?$') && double(string(event.paid_amount)) > 0"
|
|
34
|
+
where: gateway_ref == event.gateway_ref
|
|
35
|
+
as: held
|
|
36
|
+
- find: payment
|
|
37
|
+
if: "'gateway_ref' in event && event.gateway_ref != '' && 'external_id' in event && 'paid_amount' in event && string(event.paid_amount).matches('^[0-9]+([.][0-9]+)?$') && double(string(event.paid_amount)) > 0"
|
|
38
|
+
where: "held != null && name == held.payment && docstatus != 2"
|
|
39
|
+
as: holder
|
|
40
|
+
- update: held
|
|
41
|
+
if: "'gateway_ref' in event && event.gateway_ref != '' && 'external_id' in event && 'paid_amount' in event && string(event.paid_amount).matches('^[0-9]+([.][0-9]+)?$') && double(string(event.paid_amount)) > 0 && done == null && inv != null && held != null && holder == null"
|
|
42
|
+
set: {gateway_ref: "''", released_ref: event.gateway_ref}
|
|
43
|
+
- create: gateway_ref_claim
|
|
44
|
+
if: "'gateway_ref' in event && event.gateway_ref != '' && 'external_id' in event && 'paid_amount' in event && string(event.paid_amount).matches('^[0-9]+([.][0-9]+)?$') && double(string(event.paid_amount)) > 0 && done == null && inv != null && (held == null || holder == null)"
|
|
45
|
+
set: {gateway_ref: event.gateway_ref, payment: "''"}
|
|
46
|
+
as: claim
|
|
47
|
+
- create: payment
|
|
48
|
+
if: "'gateway_ref' in event && event.gateway_ref != '' && 'external_id' in event && 'paid_amount' in event && string(event.paid_amount).matches('^[0-9]+([.][0-9]+)?$') && double(string(event.paid_amount)) > 0 && done == null && inv != null && (held == null || holder == null)"
|
|
49
|
+
set:
|
|
50
|
+
direction: "'receive'"
|
|
51
|
+
customer: inv.customer
|
|
52
|
+
payment_date: today()
|
|
53
|
+
amount: "double(string(event.paid_amount))"
|
|
54
|
+
method: >-
|
|
55
|
+
'channel' in event && event.channel == 'QRIS' ? 'qris'
|
|
56
|
+
: (('channel' in event && event.channel.startsWith('VIRTUAL_ACCOUNT')) || ('service' in event && event.service == 'VIRTUAL_ACCOUNT') ? 'va' : 'other')
|
|
57
|
+
gateway: "'doku'"
|
|
58
|
+
gateway_ref: event.gateway_ref
|
|
59
|
+
reference: inv.name
|
|
60
|
+
notes: "'Dari DOKU ' + event.gateway_ref"
|
|
61
|
+
allocations: "min(double(string(event.paid_amount)), inv.outstanding - drafts.map(p, p.allocated_total).sum()) > 0 ? [{'sales_invoice': inv.name, 'amount': min(double(string(event.paid_amount)), inv.outstanding - drafts.map(p, p.allocated_total).sum())}] : []"
|
|
62
|
+
as: pay
|
|
63
|
+
- update: claim
|
|
64
|
+
if: "'gateway_ref' in event && event.gateway_ref != '' && 'external_id' in event && 'paid_amount' in event && string(event.paid_amount).matches('^[0-9]+([.][0-9]+)?$') && double(string(event.paid_amount)) > 0 && done == null && inv != null && (held == null || holder == null)"
|
|
65
|
+
set: {payment: pay.name}
|
|
66
|
+
- notify: owner
|
|
67
|
+
if: "'gateway_ref' in event && event.gateway_ref != '' && 'external_id' in event && 'paid_amount' in event && string(event.paid_amount).matches('^[0-9]+([.][0-9]+)?$') && double(string(event.paid_amount)) > 0 && done == null && inv == null"
|
|
68
|
+
channel: email
|
|
69
|
+
template: {id: 'DOKU {event.gateway_ref}: Rp {event.paid_amount} untuk {event.external_id}, faktur tidak ada/terbuka. Catat manual.'}
|
|
70
|
+
- notify: owner
|
|
71
|
+
if: "!('gateway_ref' in event && event.gateway_ref != '' && 'external_id' in event && 'paid_amount' in event && string(event.paid_amount).matches('^[0-9]+([.][0-9]+)?$') && double(string(event.paid_amount)) > 0)"
|
|
72
|
+
channel: email
|
|
73
|
+
template: {id: 'DOKU: ada pembayaran lunas tanpa ID transaksi atau jumlah yang terbaca. Cek DOKU Back Office dan log connector, catat manual.'}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
name: attendance_close_cancel_guard
|
|
3
|
+
label: {id: Rekap absen yang sudah jadi timesheet tidak bisa dibatalkan}
|
|
4
|
+
# Its recap timesheets carry the days into payroll: delete the drafts or cancel the submitted ones first (a recap used by
|
|
5
|
+
# a submitted payslip cannot be cancelled either, recap_cancel_guard), then cancel the close.
|
|
6
|
+
on: attendance_close.cancelled
|
|
7
|
+
steps:
|
|
8
|
+
- find: timesheet
|
|
9
|
+
where: attendance_close == event.name && docstatus != 2
|
|
10
|
+
as: ts
|
|
11
|
+
- if: ts != null
|
|
12
|
+
create: attendance_guard
|
|
13
|
+
set:
|
|
14
|
+
reason: "'close_has_recap'"
|
|
15
|
+
document: ts.name
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
name: attendance_close_on_submit
|
|
3
|
+
label: {id: Rekap absen lapangan jadi timesheet bulanan}
|
|
4
|
+
# For each assignment of the project during the period: the submitted daily logs of that assignment in the period become
|
|
5
|
+
# one draft monthly recap timesheet (days present, overtime hours, per day) with the assignment's rates. Only submitted
|
|
6
|
+
# logs count: drafts, logs waiting for the supervisor and rejected ones do not.
|
|
7
|
+
# Refused (the whole close rolls back), so a day is never paid or booked twice and never at the wrong rate:
|
|
8
|
+
# - another submitted close of the project overlaps the period;
|
|
9
|
+
# - a worker has logs on two assignments of the project in the period (payroll pays one slip per worker per month at one
|
|
10
|
+
# rate): close the period at the end of the first assignment instead;
|
|
11
|
+
# - a worker with logs already has a live timesheet of the project inside the period (a daily timesheet, an imported
|
|
12
|
+
# recap or a recap of another close).
|
|
13
|
+
# Reads in the order attendance_close, assignment, attendance_log, timesheet (contract 0025 locks), like the log guards.
|
|
14
|
+
on: attendance_close.submitted
|
|
15
|
+
steps:
|
|
16
|
+
- find: attendance_close
|
|
17
|
+
where: project == event.project && name != event.name && docstatus == 1 && period_from <= event.period_to && period_to >= event.period_from
|
|
18
|
+
as: other
|
|
19
|
+
- if: other != null
|
|
20
|
+
create: attendance_guard
|
|
21
|
+
set:
|
|
22
|
+
reason: "'close_overlap'"
|
|
23
|
+
document: other.name
|
|
24
|
+
- find_all: assignment
|
|
25
|
+
where: project == event.project && start_date <= event.period_to && end_date >= event.period_from
|
|
26
|
+
sort: start_date
|
|
27
|
+
as: asgs
|
|
28
|
+
- find_all: attendance_log
|
|
29
|
+
where: project == event.project && docstatus == 1 && work_date >= event.period_from && work_date <= event.period_to
|
|
30
|
+
as: logs
|
|
31
|
+
- for_each: asgs
|
|
32
|
+
as: a
|
|
33
|
+
do:
|
|
34
|
+
- if: "logs.map(l, l.assignment == a.name ? 1 : 0).sum() > 0 && logs.map(l, l.worker == a.worker && l.assignment != a.name ? 1 : 0).sum() > 0"
|
|
35
|
+
create: attendance_guard
|
|
36
|
+
set:
|
|
37
|
+
reason: "'two_assignments'"
|
|
38
|
+
document: a.name
|
|
39
|
+
- if: "logs.map(l, l.assignment == a.name ? 1 : 0).sum() > 0"
|
|
40
|
+
find: timesheet
|
|
41
|
+
where: >-
|
|
42
|
+
project == event.project && worker == a.worker && docstatus != 2 && work_date <= event.period_to
|
|
43
|
+
&& (period_to == '' ? work_date >= event.period_from : period_to >= event.period_from)
|
|
44
|
+
as: ts
|
|
45
|
+
- if: "logs.map(l, l.assignment == a.name ? 1 : 0).sum() > 0 && ts != null"
|
|
46
|
+
create: attendance_guard
|
|
47
|
+
set:
|
|
48
|
+
reason: "'recap_overlap'"
|
|
49
|
+
document: ts.name
|
|
50
|
+
- if: "logs.map(l, l.assignment == a.name ? 1 : 0).sum() > 0"
|
|
51
|
+
create: timesheet
|
|
52
|
+
set:
|
|
53
|
+
project: event.project
|
|
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).
|
|
57
|
+
assignment: "a.rate_basis == 'hour' ? '' : a.name"
|
|
58
|
+
work_date: event.period_from
|
|
59
|
+
period_to: event.period_to
|
|
60
|
+
rate_basis: "'day'"
|
|
61
|
+
days: "logs.map(l, l.assignment == a.name ? 1 : 0).sum()"
|
|
62
|
+
overtime_hours: "logs.map(l, l.assignment == a.name ? l.overtime_hours : 0.0).sum()"
|
|
63
|
+
description: "'Rekap absen lapangan ' + event.name"
|
|
64
|
+
attendance_close: event.name
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
name: attendance_log_cancel_guard
|
|
3
|
+
label: {id: Absen di periode yang sudah direkap tidak bisa dibatalkan}
|
|
4
|
+
# The day is already in a recap timesheet (and maybe a payslip): cancel the close first.
|
|
5
|
+
on: attendance_log.cancelled
|
|
6
|
+
steps:
|
|
7
|
+
- find: attendance_close
|
|
8
|
+
where: project == event.project && docstatus == 1 && period_from <= event.work_date && period_to >= event.work_date
|
|
9
|
+
as: closed
|
|
10
|
+
- if: closed != null
|
|
11
|
+
create: attendance_guard
|
|
12
|
+
set:
|
|
13
|
+
reason: "'period_closed'"
|
|
14
|
+
document: closed.name
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
name: attendance_log_guard_created
|
|
3
|
+
label: {id: Satu absen per orang per hari (baru)}
|
|
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
|
+
# contract 0025, so two clock-ins sent at the same moment run one after the other and the second is refused.
|
|
6
|
+
on: attendance_log.created
|
|
7
|
+
steps:
|
|
8
|
+
- find: attendance_log
|
|
9
|
+
where: day_key == event.day_key && name != event.name && docstatus != 2
|
|
10
|
+
as: other
|
|
11
|
+
- if: other != null
|
|
12
|
+
create: attendance_guard
|
|
13
|
+
set:
|
|
14
|
+
reason: "'second_log'"
|
|
15
|
+
document: other.name
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
name: attendance_log_guard_submitted
|
|
3
|
+
label: {id: 'Absen yang diajukan tidak dobel, tidak masuk periode yang sudah direkap, fotonya tidak dipakai ulang'}
|
|
4
|
+
# Runs again at submit (also the submit an approval runs as the worker): one counted log per worker and day, and no new
|
|
5
|
+
# day inside a period whose close is submitted (its recap timesheets are already made). Reads attendance_close before
|
|
6
|
+
# attendance_log, the order of attendance_close_on_submit (contract 0025).
|
|
7
|
+
on: attendance_log.submitted
|
|
8
|
+
steps:
|
|
9
|
+
- find: attendance_close
|
|
10
|
+
where: project == event.project && docstatus == 1 && period_from <= event.work_date && period_to >= event.work_date
|
|
11
|
+
as: closed
|
|
12
|
+
- if: closed != null
|
|
13
|
+
create: attendance_guard
|
|
14
|
+
set:
|
|
15
|
+
reason: "'period_closed'"
|
|
16
|
+
document: closed.name
|
|
17
|
+
- find: attendance_log
|
|
18
|
+
where: day_key == event.day_key && name != event.name && docstatus != 2
|
|
19
|
+
as: other
|
|
20
|
+
- if: other != null
|
|
21
|
+
create: attendance_guard
|
|
22
|
+
set:
|
|
23
|
+
reason: "'second_log'"
|
|
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).
|
|
27
|
+
- find: attendance_log
|
|
28
|
+
where: in_photo == event.in_photo && name != event.name && docstatus != 2
|
|
29
|
+
as: same_photo
|
|
30
|
+
- if: same_photo != null
|
|
31
|
+
create: attendance_guard
|
|
32
|
+
set:
|
|
33
|
+
reason: "'photo_reused'"
|
|
34
|
+
document: same_photo.name
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
name: attendance_log_guard_updated
|
|
3
|
+
label: {id: Satu absen per orang per hari (diubah)}
|
|
4
|
+
# The same check when the worker or the date of a draft changes.
|
|
5
|
+
on: attendance_log.updated
|
|
6
|
+
steps:
|
|
7
|
+
- find: attendance_log
|
|
8
|
+
where: day_key == event.day_key && name != event.name && docstatus != 2
|
|
9
|
+
as: other
|
|
10
|
+
- if: other != null
|
|
11
|
+
create: attendance_guard
|
|
12
|
+
set:
|
|
13
|
+
reason: "'second_log'"
|
|
14
|
+
document: other.name
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
name: timesheet_attendance_overlap_guard
|
|
3
|
+
label: {id: Timesheet lain tidak boleh menumpuk rekap absen lapangan}
|
|
4
|
+
# The other direction of attendance_close_on_submit: a timesheet (daily, imported recap, typed) of a worker whose days in
|
|
5
|
+
# that span are already in a live recap made by any field attendance close would book and bill them twice. Refused at
|
|
6
|
+
# submit; the recap of the close itself passes (live closes never overlap, so its own close is the only one it may share).
|
|
7
|
+
on: timesheet.submitted
|
|
8
|
+
steps:
|
|
9
|
+
- find: timesheet
|
|
10
|
+
where: >-
|
|
11
|
+
project == event.project && worker == event.worker && name != event.name && docstatus != 2 && attendance_close != ''
|
|
12
|
+
&& attendance_close != event.attendance_close
|
|
13
|
+
&& work_date <= (event.period_to != '' ? event.period_to : event.work_date)
|
|
14
|
+
&& (period_to != '' ? period_to : work_date) >= event.work_date
|
|
15
|
+
as: ts
|
|
16
|
+
- if: ts != null
|
|
17
|
+
create: attendance_guard
|
|
18
|
+
set:
|
|
19
|
+
reason: "'recap_overlap'"
|
|
20
|
+
document: ts.name
|
|
@@ -8,6 +8,9 @@ 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
9
|
# No sales_manager: an assignment carries the cost rates (audit L1).
|
|
10
10
|
- {role: finance_manager, read: true}
|
|
11
|
+
# A worker reads their own assignments and a supervisor those of their sites (row scopes); rates are hidden from both.
|
|
12
|
+
- {role: field_worker, read: true}
|
|
13
|
+
- {role: site_supervisor, read: true}
|
|
11
14
|
fields:
|
|
12
15
|
- name: project
|
|
13
16
|
type: link
|
|
@@ -26,6 +29,18 @@ fields:
|
|
|
26
29
|
type: data
|
|
27
30
|
label: {id: Lokasi}
|
|
28
31
|
default: project.site
|
|
32
|
+
# Where the worker clocks in (attendance_log): point and radius of the work site.
|
|
33
|
+
- name: work_site
|
|
34
|
+
type: link
|
|
35
|
+
to: work_site
|
|
36
|
+
label: {id: Lokasi absen}
|
|
37
|
+
in_list: true
|
|
38
|
+
# The site's point and radius as the worker's phone reads them for its message (the worker cannot read work_site, so
|
|
39
|
+
# the firm's other client sites stay private). Refreshed when the assignment is saved; the kernel's check in
|
|
40
|
+
# attendance_log reads the site itself.
|
|
41
|
+
- {name: site_lat, type: float, label: {id: Lintang lokasi absen}, read_only: true, compute: "work_site != '' ? work_site.lat : 0"}
|
|
42
|
+
- {name: site_lng, type: float, label: {id: Bujur lokasi absen}, read_only: true, compute: "work_site != '' ? work_site.lng : 0"}
|
|
43
|
+
- {name: site_radius_m, type: int, label: {id: Radius absen (m)}, read_only: true, compute: "work_site != '' ? work_site.radius_m : 0"}
|
|
29
44
|
- name: start_date
|
|
30
45
|
type: date
|
|
31
46
|
label: {id: Mulai}
|
|
@@ -39,6 +54,7 @@ fields:
|
|
|
39
54
|
- name: day_rate
|
|
40
55
|
type: currency
|
|
41
56
|
label: {id: Tarif per hari}
|
|
57
|
+
hidden_for: [field_worker, site_supervisor]
|
|
42
58
|
default: worker.day_rate
|
|
43
59
|
in_list: true
|
|
44
60
|
# Billed per day (manpower, the default) or per hour (consultants); the rates default from the worker.
|
|
@@ -52,19 +68,23 @@ fields:
|
|
|
52
68
|
- name: hour_rate
|
|
53
69
|
type: currency
|
|
54
70
|
label: {id: Tarif per jam}
|
|
71
|
+
hidden_for: [field_worker, site_supervisor]
|
|
55
72
|
default: worker.hour_rate
|
|
56
73
|
- name: cost_rate
|
|
57
74
|
type: currency
|
|
58
75
|
label: {id: Biaya per satuan}
|
|
76
|
+
hidden_for: [field_worker, site_supervisor]
|
|
59
77
|
default: "rate_basis == 'hour' ? worker.cost_hour_rate : worker.cost_day_rate"
|
|
60
78
|
# Overtime per hour on this project, from the worker unless the client agreed another rate.
|
|
61
79
|
- name: overtime_rate
|
|
62
80
|
type: currency
|
|
63
81
|
label: {id: Tarif jual lembur per jam}
|
|
82
|
+
hidden_for: [field_worker, site_supervisor]
|
|
64
83
|
default: worker.overtime_rate
|
|
65
84
|
- name: overtime_cost_rate
|
|
66
85
|
type: currency
|
|
67
86
|
label: {id: Upah lembur per jam}
|
|
87
|
+
hidden_for: [field_worker, site_supervisor]
|
|
68
88
|
default: worker.overtime_cost_rate
|
|
69
89
|
- name: notes
|
|
70
90
|
type: text
|
|
@@ -86,7 +106,7 @@ views:
|
|
|
86
106
|
layout:
|
|
87
107
|
- section: {id: Penugasan}
|
|
88
108
|
columns:
|
|
89
|
-
- [project, worker, site]
|
|
109
|
+
- [project, worker, site, work_site]
|
|
90
110
|
- [start_date, end_date]
|
|
91
111
|
- section: {id: Tarif}
|
|
92
112
|
columns:
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
name: attendance_close
|
|
3
|
+
label: {id: Rekap absen lapangan, en: Field attendance close}
|
|
4
|
+
icon: calendar
|
|
5
|
+
is_submittable: true
|
|
6
|
+
naming: RAB-{YYYY}-{####}
|
|
7
|
+
title_field: project
|
|
8
|
+
# Closes the field attendance of one project for a pay period (21 Oct to 20 Nov, or a calendar month): on submit, flow
|
|
9
|
+
# attendance_close_on_submit counts each assigned worker's submitted daily logs (attendance_log) of the period and makes
|
|
10
|
+
# one draft monthly recap timesheet per worker (work_date = period_from, period_to, days, overtime hours), the same shape
|
|
11
|
+
# the attendance_recap import makes. The project admin checks and submits those recaps; payroll then makes the slips
|
|
12
|
+
# (payslip_from_recap) and the client invoice as before. While the close is submitted, logs of its period can be neither
|
|
13
|
+
# submitted nor cancelled (attendance_log_guard_submitted, attendance_log_cancel_guard); to reopen, delete or cancel its
|
|
14
|
+
# recaps, then cancel the close (and amend it, or make a new one). Logs still waiting for the supervisor when the close is
|
|
15
|
+
# submitted are not counted and can no longer be approved into the period: decide them before closing (dashboard
|
|
16
|
+
# rekap_absen, "Menunggu persetujuan").
|
|
17
|
+
permissions:
|
|
18
|
+
- {role: project_admin, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
|
|
19
|
+
- {role: finance_manager, read: true}
|
|
20
|
+
# Read so the flows that run in their submit can see whether a period is closed.
|
|
21
|
+
- {role: site_supervisor, read: true}
|
|
22
|
+
- {role: field_worker, read: true}
|
|
23
|
+
fields:
|
|
24
|
+
- name: project
|
|
25
|
+
type: link
|
|
26
|
+
to: project
|
|
27
|
+
label: {id: Proyek}
|
|
28
|
+
required: true
|
|
29
|
+
in_list: true
|
|
30
|
+
- name: period_from
|
|
31
|
+
type: date
|
|
32
|
+
label: {id: Dari tanggal}
|
|
33
|
+
required: true
|
|
34
|
+
in_list: true
|
|
35
|
+
- name: period_to
|
|
36
|
+
type: date
|
|
37
|
+
label: {id: Sampai tanggal}
|
|
38
|
+
required: true
|
|
39
|
+
in_list: true
|
|
40
|
+
- name: notes
|
|
41
|
+
type: text
|
|
42
|
+
label: {id: Catatan}
|
|
43
|
+
# 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
|
+
# closes of overlapping days are refused by attendance_close_on_submit under the flow lock (contract 0025).
|
|
45
|
+
rules:
|
|
46
|
+
- name: period_valid
|
|
47
|
+
on: save
|
|
48
|
+
check: period_to >= period_from && days_between(period_from, period_to) <= 30
|
|
49
|
+
message: {id: 'Periode rekap: sampai tanggal tidak boleh sebelum tanggal mulai, paling lama 31 hari'}
|
|
50
|
+
- name: period_over
|
|
51
|
+
on: submit
|
|
52
|
+
check: period_to <= today()
|
|
53
|
+
message: {id: 'Periode ini belum selesai; rekap absen setelah tanggal terakhirnya'}
|
|
54
|
+
views:
|
|
55
|
+
list:
|
|
56
|
+
columns: [name, project, period_from, period_to, status]
|
|
57
|
+
sort: -period_from
|
|
58
|
+
form:
|
|
59
|
+
layout:
|
|
60
|
+
- section: {id: Rekap absen}
|
|
61
|
+
columns:
|
|
62
|
+
- [project, period_from, period_to]
|
|
63
|
+
- [notes]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
name: attendance_guard
|
|
3
|
+
label: {id: Penjaga absen, en: Attendance guard}
|
|
4
|
+
icon: check
|
|
5
|
+
naming: AGD-{######}
|
|
6
|
+
title_field: reason
|
|
7
|
+
# Never stored (the pattern of project_guard and payroll_guard): a flow that must refuse the action it runs in creates
|
|
8
|
+
# one, and the rule of its reason fails with that message, which rolls the whole action back. Create is granted to the
|
|
9
|
+
# roles whose saves and submits run those flows (an approved submit runs as the worker who asked).
|
|
10
|
+
permissions:
|
|
11
|
+
- {role: field_worker, create: true}
|
|
12
|
+
- {role: project_admin, create: true}
|
|
13
|
+
fields:
|
|
14
|
+
- name: reason
|
|
15
|
+
type: select
|
|
16
|
+
label: {id: Alasan}
|
|
17
|
+
required: true
|
|
18
|
+
options:
|
|
19
|
+
- {value: second_log, label: {id: Absen kedua di hari yang sama}}
|
|
20
|
+
- {value: period_closed, label: {id: Periode absen sudah direkap}}
|
|
21
|
+
- {value: close_overlap, label: {id: Periode rekap tumpang tindih}}
|
|
22
|
+
- {value: close_has_recap, label: {id: Rekap absen dipakai timesheet}}
|
|
23
|
+
- {value: two_assignments, label: {id: Dua penugasan dalam satu rekap}}
|
|
24
|
+
- {value: recap_overlap, label: {id: Timesheet lain di periode rekap}}
|
|
25
|
+
- {value: photo_reused, label: {id: Foto absen dipakai ulang}}
|
|
26
|
+
- name: document
|
|
27
|
+
type: data
|
|
28
|
+
label: {id: Dokumen}
|
|
29
|
+
rules:
|
|
30
|
+
- name: second_log
|
|
31
|
+
on: save
|
|
32
|
+
check: reason != 'second_log'
|
|
33
|
+
message: {id: 'Tenaga kerja ini sudah punya absen di tanggal itu (satu absen per orang per hari)'}
|
|
34
|
+
- name: period_closed
|
|
35
|
+
on: save
|
|
36
|
+
check: reason != 'period_closed'
|
|
37
|
+
message: {id: 'Absen tanggal ini sudah masuk rekap absen lapangan yang diajukan; batalkan rekapnya dulu'}
|
|
38
|
+
- name: close_overlap
|
|
39
|
+
on: save
|
|
40
|
+
check: reason != 'close_overlap'
|
|
41
|
+
message: {id: 'Proyek ini sudah punya rekap absen lapangan yang tanggalnya tumpang tindih'}
|
|
42
|
+
- name: close_has_recap
|
|
43
|
+
on: save
|
|
44
|
+
check: reason != 'close_has_recap'
|
|
45
|
+
message: {id: 'Rekap ini sudah jadi timesheet; hapus draf atau batalkan timesheet-nya dulu'}
|
|
46
|
+
- name: two_assignments
|
|
47
|
+
on: save
|
|
48
|
+
check: reason != 'two_assignments'
|
|
49
|
+
message: {id: 'Ada absen di dua penugasan dalam periode ini; rekap sampai akhir penugasan pertama dulu'}
|
|
50
|
+
- name: recap_overlap
|
|
51
|
+
on: save
|
|
52
|
+
check: reason != 'recap_overlap'
|
|
53
|
+
message: {id: 'Tenaga kerja ini sudah punya timesheet lain di periode rekap absen; batalkan salah satunya'}
|
|
54
|
+
- name: photo_reused
|
|
55
|
+
on: save
|
|
56
|
+
check: reason != 'photo_reused'
|
|
57
|
+
message: {id: 'Foto masuk ini sudah dipakai absen lain; ambil foto baru untuk absen hari ini'}
|