@rangka-os/create 0.5.0-alpha.32 → 0.5.0-alpha.34
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/absen_karyawan/app.rk +1 -1
- package/template/base/apps/absen_karyawan/dashboards/absen_karyawan_saya.rk +2 -2
- package/template/base/apps/absen_karyawan/dashboards/jadwal_saya.rk +4 -4
- package/template/base/apps/grosir_distribusi/app.rk +1 -1
- package/template/base/apps/karyawan_gaji/app.rk +6 -2
- package/template/base/apps/karyawan_gaji/dashboards/klaim_kasbon_saya.rk +3 -3
- package/template/base/apps/karyawan_gaji/dashboards/saya.rk +20 -0
- package/template/base/apps/karyawan_gaji/skills/rangka-app-karyawan-gaji/SKILL.md +3 -0
- package/template/base/apps/kasir/skills/rangka-app-kasir/SKILL.md +1 -1
- package/template/base/apps/pesanan_whatsapp/app.rk +28 -0
- package/template/base/apps/produksi_pabrik/app.rk +1 -1
- package/template/base/apps/ritel_cabang/app.rk +1 -1
- package/template/base/apps/ritel_cabang/dashboards/ritel_overview.rk +16 -0
- package/template/base/apps/ritel_cabang/dashboards/ritel_stock.rk +13 -0
- package/template/base/apps/sewa_alat/skills/rangka-app-sewa-alat/SKILL.md +3 -3
- package/template/base/connectors/rangka_whatsapp/README.md +3 -2
- package/template/base/connectors/rangka_whatsapp/connector.rk +12 -4
- package/template/base/connectors/rangka_whatsapp/fixtures/expect.json +3 -2
- package/template/base/connectors/rangka_whatsapp/fixtures/message_received.json +1 -1
- package/template/base/connectors/rangka_whatsapp/fixtures/message_received_order.json +1 -0
- package/template/base/connectors/rangka_whatsapp/mock/rangka_whatsapp_mock.py +9 -4
- package/template/base/modules/attendance/models/attendance_summary.rk +2 -4
- package/template/base/modules/attendance/models/staff_attendance.rk +3 -0
- package/template/base/modules/attendance/module.rk +1 -1
- package/template/base/modules/catalogue/defaults/uom.rk +19 -0
- package/template/base/modules/catalogue/models/item.rk +36 -0
- package/template/base/modules/catalogue/module.rk +1 -1
- package/template/base/modules/delivery/models/delivery_note.rk +3 -1
- package/template/base/modules/delivery/models/delivery_note_item.rk +4 -0
- package/template/base/modules/delivery/models/sales_return.rk +2 -2
- package/template/base/modules/delivery/models/sales_return_item.rk +3 -0
- package/template/base/modules/delivery/module.rk +2 -2
- package/template/base/modules/outlet_sales/models/outlet_sales_line.rk +1 -0
- package/template/base/modules/outlets/models/outlet.rk +9 -0
- package/template/base/modules/outlets/module.rk +1 -1
- package/template/base/modules/payroll/models/cash_advance.rk +2 -0
- package/template/base/modules/payroll/models/cash_advance_balance.rk +2 -4
- package/template/base/modules/payroll/models/payroll_run.rk +1 -0
- package/template/base/modules/payroll/models/payslip.rk +43 -12
- package/template/base/modules/payroll/module.rk +1 -1
- package/template/base/modules/payroll/print/payslip.html +4 -4
- package/template/base/modules/pos/models/pos_sale_item.rk +1 -0
- package/template/base/modules/pos/screens/kasir.rk +1 -0
- package/template/base/modules/procurement/models/goods_receipt_item.rk +21 -0
- package/template/base/modules/procurement/module.rk +2 -2
- package/template/base/modules/production/models/production_batch.rk +10 -5
- package/template/base/modules/production/models/production_material.rk +3 -0
- package/template/base/modules/production/models/production_output.rk +12 -0
- package/template/base/modules/production/module.rk +2 -2
- package/template/base/modules/reimbursement/models/claim_settlement.rk +1 -0
- package/template/base/modules/reimbursement/models/expense_claim.rk +4 -1
- package/template/base/modules/reimbursement/module.rk +1 -1
- package/template/base/modules/shifts/models/shift_assignment.rk +2 -3
- package/template/base/modules/shifts/models/shift_swap.rk +2 -0
- package/template/base/modules/shifts/module.rk +1 -1
- package/template/base/modules/stock/flows/item_tracking_lock.rk +37 -0
- package/template/base/modules/stock/flows/lot_expiry_digest.rk +103 -0
- package/template/base/modules/stock/flows/stock_balance_variant_group.rk +26 -0
- package/template/base/modules/stock/models/serial_no.rk +55 -0
- package/template/base/modules/stock/models/stock_adjustment_item.rk +4 -0
- package/template/base/modules/stock/models/stock_balance.rk +1 -0
- package/template/base/modules/stock/models/stock_expiry.rk +47 -0
- package/template/base/modules/stock/models/stock_guard.rk +40 -0
- package/template/base/modules/stock/models/stock_lot.rk +38 -0
- package/template/base/modules/stock/models/stock_lot_balance.rk +30 -0
- package/template/base/modules/stock/models/stock_move.rk +7 -2
- package/template/base/modules/stock/models/stock_transfer_item.rk +4 -0
- package/template/base/modules/stock/models/stock_transfer_receipt_item.rk +3 -0
- package/template/base/modules/stock/module.rk +9 -2
- package/template/base/modules/whatsapp/models/whatsapp_message.rk +2 -0
- package/template/base/modules/whatsapp/module.rk +2 -2
- package/template/base/modules/whatsapp_order/README.md +44 -0
- package/template/base/modules/whatsapp_order/flows/whatsapp_order_intake.rk +118 -0
- package/template/base/modules/whatsapp_order/flows/whatsapp_order_locked.rk +12 -0
- package/template/base/modules/whatsapp_order/flows/whatsapp_order_on_update.rk +124 -0
- package/template/base/modules/whatsapp_order/models/whatsapp_inbound.rk +62 -0
- package/template/base/modules/whatsapp_order/models/whatsapp_order.rk +164 -0
- package/template/base/modules/whatsapp_order/models/whatsapp_order_guard.rk +46 -0
- package/template/base/modules/whatsapp_order/models/whatsapp_order_line.rk +45 -0
- package/template/base/modules/whatsapp_order/module.rk +42 -0
- package/template/base/modules/whatsapp_order/screens/pesanan_wa.rk +22 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# stock_balance.variant_group is a compute through item, stored when the balance is written (rangka-os#267). An item
|
|
3
|
+
# grouped or regrouped after its balances exist keeps the old value on them until its next move, so the "Stok per
|
|
4
|
+
# produk" roll-up would miss it. A scheduled flow runs as the system (a flow on item.updated would run with the
|
|
5
|
+
# permissions of the person saving the item, and no role but the owner may write stock_balance). Every run rewrites up
|
|
6
|
+
# to 50 stale balances with nothing changed, which recomputes the field; a balance already right is not touched.
|
|
7
|
+
# Items whose group was cleared are left until their next stock move. Stock moves already posted keep the group they
|
|
8
|
+
# had when posted.
|
|
9
|
+
name: stock_balance_variant_group
|
|
10
|
+
label: {id: Perbarui grup varian di saldo stok}
|
|
11
|
+
description: {id: 'Tiap 10 menit, saldo stok yang grup variannya belum sama dengan data barang diperbarui, 50 baris sekali jalan.'}
|
|
12
|
+
schedule: "*/10 * * * *"
|
|
13
|
+
steps:
|
|
14
|
+
- find_all: item
|
|
15
|
+
where: "variant_group != ''"
|
|
16
|
+
limit: 2000
|
|
17
|
+
as: grouped
|
|
18
|
+
- find_all: stock_balance
|
|
19
|
+
where: "grouped.exists(i, i.name == item && i.variant_group != variant_group)"
|
|
20
|
+
limit: 50
|
|
21
|
+
as: stale
|
|
22
|
+
- for_each: stale
|
|
23
|
+
as: b
|
|
24
|
+
do:
|
|
25
|
+
- update: b
|
|
26
|
+
set: {last_move: b.last_move}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
name: serial_no
|
|
3
|
+
label: {id: Nomor seri, en: Serial number}
|
|
4
|
+
icon: stock
|
|
5
|
+
naming: SN-{######}
|
|
6
|
+
title_field: serial
|
|
7
|
+
# One row per item and serial (rangka-os contract 0070 §2 and §6): where the unit is and what moved it last. Written
|
|
8
|
+
# only by the stock hooks. history is the kernel's stack of the forward moves still standing (one line
|
|
9
|
+
# "<type>/<name>|<state before>" each, oldest first); with it a cancel must undo the serial's last document first
|
|
10
|
+
# (409 serial_moved), so cancelling an old sale never puts a resold unit back on the shelf.
|
|
11
|
+
permissions:
|
|
12
|
+
- {role: head_office, read: true, export: true}
|
|
13
|
+
- {role: purchasing_manager, read: true, export: true}
|
|
14
|
+
- {role: sales_manager, read: true}
|
|
15
|
+
- {role: outlet_staff, read: true}
|
|
16
|
+
- {role: warehouse_staff, read: true}
|
|
17
|
+
- {role: cashier, read: true}
|
|
18
|
+
fields:
|
|
19
|
+
- {name: serial, type: data, label: {id: Nomor seri}, required: true, read_only: true, in_list: true}
|
|
20
|
+
- {name: item, type: link, to: item, label: {id: Barang}, required: true, read_only: true, in_list: true}
|
|
21
|
+
- name: state
|
|
22
|
+
type: select
|
|
23
|
+
label: {id: Status}
|
|
24
|
+
read_only: true
|
|
25
|
+
in_list: true
|
|
26
|
+
chip: true
|
|
27
|
+
options:
|
|
28
|
+
- {value: in_stock, label: {id: Di gudang}}
|
|
29
|
+
- {value: in_transit, label: {id: Dalam perjalanan}}
|
|
30
|
+
- {value: sold, label: {id: Terjual}}
|
|
31
|
+
- {value: returned, label: {id: Diretur ke pemasok}}
|
|
32
|
+
- {value: consumed, label: {id: Dipakai produksi}}
|
|
33
|
+
- {value: scrapped, label: {id: Dibuang}}
|
|
34
|
+
- {value: cancelled, label: {id: Dibatalkan}}
|
|
35
|
+
- {name: outlet, type: link, to: outlet, label: {id: Lokasi}, read_only: true, in_list: true}
|
|
36
|
+
- {name: lot, type: link, to: stock_lot, label: {id: Lot}, read_only: true, hidden: true}
|
|
37
|
+
- {name: last_voucher_type, type: data, label: {id: Jenis dokumen terakhir}, read_only: true}
|
|
38
|
+
- {name: last_voucher, type: data, label: {id: Dokumen terakhir}, read_only: true, in_list: true}
|
|
39
|
+
- {name: in_date, type: date, label: {id: Tanggal masuk}, read_only: true}
|
|
40
|
+
- {name: out_date, type: date, label: {id: Tanggal keluar}, read_only: true}
|
|
41
|
+
- {name: prev_state, type: data, label: {id: Status sebelumnya}, read_only: true, hidden: true}
|
|
42
|
+
- {name: history, type: text, label: {id: Riwayat dokumen}, read_only: true}
|
|
43
|
+
views:
|
|
44
|
+
list:
|
|
45
|
+
columns: [serial, item, state, outlet, last_voucher]
|
|
46
|
+
filters: [item, state, outlet]
|
|
47
|
+
sort: serial
|
|
48
|
+
form:
|
|
49
|
+
layout:
|
|
50
|
+
- section: {id: Nomor seri}
|
|
51
|
+
columns:
|
|
52
|
+
- [serial, item, in_date, last_voucher_type]
|
|
53
|
+
- [state, outlet, out_date, last_voucher]
|
|
54
|
+
- section: {id: Riwayat}
|
|
55
|
+
fields: [history]
|
|
@@ -30,3 +30,7 @@ fields:
|
|
|
30
30
|
type: float
|
|
31
31
|
label: {id: Qty stok}
|
|
32
32
|
compute: "packing == '' ? qty : qty * packing.factor"
|
|
33
|
+
# rangka-os contract 0070 §7 (Go rule): the lot to take (empty = earliest expiry first; reason expired or waste takes
|
|
34
|
+
# expired lots first) and, for a serial item, the serials that leave, one per line.
|
|
35
|
+
- {name: lot, type: link, to: stock_lot, label: {id: Lot}, depends_on: "item.tracking in ['lot', 'lot_expiry']", help: {id: 'Kosongkan: lot yang paling dulu kedaluwarsa diambil'}}
|
|
36
|
+
- {name: serial_nos, type: text, label: {id: Nomor seri}, depends_on: "item.tracking == 'serial'", help: {id: 'Satu nomor seri per baris'}}
|
|
@@ -33,6 +33,7 @@ fields:
|
|
|
33
33
|
- {value: vehicle, label: {id: Mobil kanvas}}
|
|
34
34
|
- {value: quarantine, label: {id: Barang rusak / karantina}}
|
|
35
35
|
- {value: production, label: {id: Ruang produksi}}
|
|
36
|
+
- {name: variant_group, type: data, label: {id: Grup varian}, hidden: true, compute: item.variant_group}
|
|
36
37
|
- {name: last_sale_date, type: date, label: {id: Terakhir terjual}, read_only: true, in_list: true}
|
|
37
38
|
views:
|
|
38
39
|
list:
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# The expiry-soon list: one row per lot balance (outlet, item, lot) with stock that expires within the item's
|
|
3
|
+
# expiry_warning_days, or has expired. Written only by flow lot_expiry_digest, every morning: it opens a row for a lot
|
|
4
|
+
# balance newly in the window, refreshes qty, days_left and state of open rows, and closes a row (open = false) when the
|
|
5
|
+
# lot is used up, so head office and the warehouse are told once per lot, not every day. Every field is read_only.
|
|
6
|
+
name: stock_expiry
|
|
7
|
+
label: {id: Stok hampir kedaluwarsa, en: Expiring stock}
|
|
8
|
+
icon: alarm-warning-line
|
|
9
|
+
naming: EXP-{YYYY}-{#####}
|
|
10
|
+
title_field: item
|
|
11
|
+
permissions:
|
|
12
|
+
- {role: head_office, read: true, export: true}
|
|
13
|
+
- {role: purchasing_manager, read: true, export: true}
|
|
14
|
+
- {role: sales_manager, read: true}
|
|
15
|
+
- {role: outlet_staff, read: true}
|
|
16
|
+
- {role: warehouse_staff, read: true}
|
|
17
|
+
fields:
|
|
18
|
+
- {name: balance, type: link, to: stock_lot_balance, label: {id: Stok per lot}, required: true, read_only: true}
|
|
19
|
+
- {name: outlet, type: link, to: outlet, label: {id: Lokasi}, required: true, read_only: true, in_list: true}
|
|
20
|
+
- {name: item, type: link, to: item, label: {id: Barang}, required: true, read_only: true, in_list: true}
|
|
21
|
+
- {name: lot, type: link, to: stock_lot, label: {id: Lot}, required: true, read_only: true, in_list: true}
|
|
22
|
+
# the lot number and item name as text, for the notice (a template reads the row's own fields)
|
|
23
|
+
- {name: lot_no, type: data, label: {id: Nomor lot}, read_only: true}
|
|
24
|
+
- {name: item_name, type: data, label: {id: Nama barang}, read_only: true, hidden: true}
|
|
25
|
+
- {name: expiry_date, type: date, label: {id: Kedaluwarsa}, read_only: true, in_list: true}
|
|
26
|
+
- {name: qty, type: float, label: {id: Sisa qty}, read_only: true, in_list: true}
|
|
27
|
+
- {name: days_left, type: int, label: {id: Sisa hari}, read_only: true, in_list: true, help: {id: 'Dihitung tiap pagi; minus = sudah lewat'}}
|
|
28
|
+
- name: state
|
|
29
|
+
type: select
|
|
30
|
+
label: {id: Status}
|
|
31
|
+
read_only: true
|
|
32
|
+
in_list: true
|
|
33
|
+
chip: true
|
|
34
|
+
options:
|
|
35
|
+
- {value: soon, label: {id: Hampir kedaluwarsa}}
|
|
36
|
+
- {value: expired, label: {id: Sudah kedaluwarsa}}
|
|
37
|
+
- {name: alerted_on, type: date, label: {id: Tanggal dikabari}, read_only: true}
|
|
38
|
+
- {name: open, type: check, label: {id: Masih ada stoknya}, read_only: true, in_list: true, in_filter: true}
|
|
39
|
+
# the digest's bookkeeping: the day it last refreshed the row (it refreshes the least recently checked first) and
|
|
40
|
+
# whether the notice about the row went out
|
|
41
|
+
- {name: checked_on, type: date, label: {id: Terakhir diperiksa}, read_only: true}
|
|
42
|
+
- {name: notified, type: check, label: {id: Sudah dikabari}, read_only: true}
|
|
43
|
+
views:
|
|
44
|
+
list:
|
|
45
|
+
columns: [item, lot, expiry_date, days_left, outlet, qty, state]
|
|
46
|
+
filters: [outlet, item, state, open]
|
|
47
|
+
sort: expiry_date
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# Never stored: a flow that must refuse the change it runs in creates one of these with a reason, and the matching rule
|
|
3
|
+
# fails with that reason's message, which rolls the whole change back (the delivery_guard pattern). Create is granted
|
|
4
|
+
# to the roles that write items, whose saves run flow item_tracking_lock.
|
|
5
|
+
name: stock_guard
|
|
6
|
+
label: {id: Penjaga stok, en: Stock guard}
|
|
7
|
+
icon: check
|
|
8
|
+
naming: SGR-{######}
|
|
9
|
+
title_field: reason
|
|
10
|
+
permissions:
|
|
11
|
+
- {role: head_office, create: true}
|
|
12
|
+
- {role: sales_manager, create: true}
|
|
13
|
+
- {role: finance_manager, create: true}
|
|
14
|
+
- {role: purchasing_manager, create: true}
|
|
15
|
+
- {role: project_admin, create: true}
|
|
16
|
+
fields:
|
|
17
|
+
- name: reason
|
|
18
|
+
type: select
|
|
19
|
+
label: {id: Alasan}
|
|
20
|
+
required: true
|
|
21
|
+
options:
|
|
22
|
+
- {value: lots_in_stock, label: {id: Masih ada stok per lot}}
|
|
23
|
+
- {value: serials_in_stock, label: {id: Masih ada nomor seri di gudang}}
|
|
24
|
+
- {value: stock_without_serials, label: {id: Stok belum bernomor seri}}
|
|
25
|
+
- name: document
|
|
26
|
+
type: data
|
|
27
|
+
label: {id: Dokumen}
|
|
28
|
+
rules:
|
|
29
|
+
- name: lots_in_stock
|
|
30
|
+
on: save
|
|
31
|
+
check: reason != 'lots_in_stock'
|
|
32
|
+
message: {id: 'Barang ini masih punya stok per lot. Habiskan atau sesuaikan stok lotnya dulu sebelum pelacakan lot dimatikan'}
|
|
33
|
+
- name: serials_in_stock
|
|
34
|
+
on: save
|
|
35
|
+
check: reason != 'serials_in_stock'
|
|
36
|
+
message: {id: 'Masih ada nomor seri barang ini di gudang atau dalam perjalanan. Keluarkan unitnya dulu sebelum pelacakan nomor seri dimatikan'}
|
|
37
|
+
- name: stock_without_serials
|
|
38
|
+
on: save
|
|
39
|
+
check: reason != 'stock_without_serials'
|
|
40
|
+
message: {id: 'Barang ini masih punya stok tanpa nomor seri. Nolkan stoknya dulu (opname atau penyesuaian), lalu terima lagi dengan nomor serinya'}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
name: stock_lot
|
|
3
|
+
label: {id: Lot barang, en: Stock lot}
|
|
4
|
+
icon: stock
|
|
5
|
+
naming: LOT-{#####}
|
|
6
|
+
title_field: lot_no
|
|
7
|
+
# One row per item and lot number (rangka-os contract 0070 §2), created by the first incoming move that names the lot
|
|
8
|
+
# (goods receipt, production batch, transfer receipt, count). Written only by the stock hooks: every field but notes is
|
|
9
|
+
# read_only, and no role may create or delete one. The lot's trace is the stock_move list filtered by this lot.
|
|
10
|
+
permissions:
|
|
11
|
+
- {role: head_office, read: true, write: true, export: true, print: true}
|
|
12
|
+
- {role: purchasing_manager, read: true, export: true}
|
|
13
|
+
- {role: sales_manager, read: true}
|
|
14
|
+
- {role: field_sales, read: true}
|
|
15
|
+
- {role: outlet_staff, read: true}
|
|
16
|
+
- {role: warehouse_staff, read: true}
|
|
17
|
+
- {role: cashier, read: true}
|
|
18
|
+
fields:
|
|
19
|
+
- {name: lot_no, type: data, label: {id: Nomor lot}, required: true, read_only: true, in_list: true}
|
|
20
|
+
- {name: item, type: link, to: item, label: {id: Barang}, required: true, read_only: true, in_list: true}
|
|
21
|
+
- {name: expiry_date, type: date, label: {id: Kedaluwarsa}, read_only: true, in_list: true}
|
|
22
|
+
- {name: made_date, type: date, label: {id: Tanggal produksi}, read_only: true}
|
|
23
|
+
- {name: first_voucher_type, type: data, label: {id: Pertama masuk lewat}, read_only: true}
|
|
24
|
+
- {name: first_voucher, type: data, label: {id: Dokumen pertama}, read_only: true, in_list: true}
|
|
25
|
+
- {name: notes, type: text, label: {id: Catatan}}
|
|
26
|
+
views:
|
|
27
|
+
list:
|
|
28
|
+
columns: [lot_no, item, expiry_date, first_voucher]
|
|
29
|
+
filters: [item]
|
|
30
|
+
sort: expiry_date
|
|
31
|
+
form:
|
|
32
|
+
layout:
|
|
33
|
+
- section: {id: Lot}
|
|
34
|
+
columns:
|
|
35
|
+
- [lot_no, item, first_voucher_type]
|
|
36
|
+
- [expiry_date, made_date, first_voucher]
|
|
37
|
+
- section: {id: Catatan}
|
|
38
|
+
fields: [notes]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
name: stock_lot_balance
|
|
3
|
+
label: {id: Stok per lot, en: Stock per lot}
|
|
4
|
+
icon: stock
|
|
5
|
+
naming: LB-{######}
|
|
6
|
+
# Quantity per outlet, item and lot (rangka-os contract 0070 §2), written only by the stock hooks. The row with an empty
|
|
7
|
+
# lot is the no-lot bucket: stock from before the item was tracked, or moved by a document without a lot, so the rows
|
|
8
|
+
# of an outlet and item always add up to its stock_balance.qty. Value stays on stock_balance (moving average per
|
|
9
|
+
# outlet and item, no cost per lot in v1). expiry_date and expiry_warn copy the lot and item when the row is written.
|
|
10
|
+
permissions:
|
|
11
|
+
- {role: head_office, read: true, export: true}
|
|
12
|
+
- {role: purchasing_manager, read: true, export: true}
|
|
13
|
+
- {role: sales_manager, read: true}
|
|
14
|
+
- {role: outlet_staff, read: true}
|
|
15
|
+
- {role: warehouse_staff, read: true}
|
|
16
|
+
- {role: cashier, read: true}
|
|
17
|
+
fields:
|
|
18
|
+
- {name: outlet, type: link, to: outlet, label: {id: Lokasi}, required: true, read_only: true, in_list: true}
|
|
19
|
+
- {name: item, type: link, to: item, label: {id: Barang}, required: true, read_only: true, in_list: true}
|
|
20
|
+
- {name: lot, type: link, to: stock_lot, label: {id: Lot}, read_only: true, in_list: true, help: {id: 'Kosong = stok tanpa nomor lot'}}
|
|
21
|
+
# the lot number as text for the list, "Tanpa lot" on the no-lot bucket row (a link cell would be empty)
|
|
22
|
+
- {name: lot_no, type: data, label: {id: Nomor lot}, read_only: true, in_list: true, compute: "lot != '' ? lot.lot_no : 'Tanpa lot'"}
|
|
23
|
+
- {name: qty, type: float, label: {id: Qty}, read_only: true, in_list: true}
|
|
24
|
+
- {name: expiry_date, type: date, label: {id: Kedaluwarsa}, read_only: true, in_list: true, compute: "lot != '' ? lot.expiry_date : ''"}
|
|
25
|
+
- {name: negative, type: check, label: {id: Stok minus}, compute: qty < 0, in_list: true}
|
|
26
|
+
views:
|
|
27
|
+
list:
|
|
28
|
+
columns: [item, lot_no, expiry_date, outlet, qty, negative]
|
|
29
|
+
filters: [outlet, item, lot, negative]
|
|
30
|
+
sort: expiry_date
|
|
@@ -14,6 +14,7 @@ fields:
|
|
|
14
14
|
- {name: posting_date, type: date, label: {id: Tanggal}, read_only: true, in_list: true}
|
|
15
15
|
- {name: outlet, type: link, to: outlet, label: {id: Lokasi}, required: true, read_only: true, in_list: true}
|
|
16
16
|
- {name: item, type: link, to: item, label: {id: Barang}, required: true, read_only: true, in_list: true}
|
|
17
|
+
- {name: variant_group, type: data, label: {id: Grup varian}, hidden: true, compute: item.variant_group}
|
|
17
18
|
- {name: qty, type: float, label: {id: 'Qty (+ masuk, - keluar)'}, read_only: true, in_list: true}
|
|
18
19
|
- {name: unit_cost, type: currency, label: {id: Biaya per satuan}, read_only: true, hidden_for: [outlet_staff, cashier, warehouse_staff]}
|
|
19
20
|
- {name: value, type: currency, label: {id: Nilai}, read_only: true, in_list: true, hidden_for: [outlet_staff, cashier, warehouse_staff]}
|
|
@@ -47,8 +48,12 @@ fields:
|
|
|
47
48
|
- {value: return_in, label: {id: Retur penjualan masuk}}
|
|
48
49
|
- {value: production_out, label: {id: Bahan ke produksi}}
|
|
49
50
|
- {value: production_in, label: {id: Hasil produksi}}
|
|
51
|
+
# rangka-os contract 0070: the lot this move took or added (empty = the no-lot bucket) and the serials it moved, one
|
|
52
|
+
# per line. A lot item's line that spans lots writes one move per lot. Filter by lot to trace a lot.
|
|
53
|
+
- {name: lot, type: link, to: stock_lot, label: {id: Lot}, read_only: true, in_list: true}
|
|
54
|
+
- {name: serial_nos, type: text, label: {id: Nomor seri}, read_only: true}
|
|
50
55
|
views:
|
|
51
56
|
list:
|
|
52
|
-
columns: [name, posting_date, outlet, item, qty, value, balance_qty, negative, voucher_type, voucher, reason]
|
|
53
|
-
filters: [outlet, item, reason, negative]
|
|
57
|
+
columns: [name, posting_date, outlet, item, lot, qty, value, balance_qty, negative, voucher_type, voucher, reason]
|
|
58
|
+
filters: [outlet, item, lot, reason, negative]
|
|
54
59
|
sort: -name
|
|
@@ -32,3 +32,7 @@ fields:
|
|
|
32
32
|
compute: "packing == '' ? qty : qty * packing.factor"
|
|
33
33
|
- {name: unit_cost, type: currency, read_only: true, label: {id: Biaya per satuan}, help: {id: 'Diisi saat transfer dikirim: rata-rata outlet asal'}, hidden_for: [outlet_staff, cashier, warehouse_staff]}
|
|
34
34
|
- {name: received_qty, type: float, read_only: true, label: {id: Qty diterima}}
|
|
35
|
+
# rangka-os contract 0070 §7: the lot sent (empty = earliest expiry first) and the serials sent, one per line. The
|
|
36
|
+
# transfer receipt brings the same lots in.
|
|
37
|
+
- {name: lot, type: link, to: stock_lot, label: {id: Lot}, depends_on: "item.tracking in ['lot', 'lot_expiry']", help: {id: 'Kosongkan: lot yang paling dulu kedaluwarsa dikirim'}}
|
|
38
|
+
- {name: serial_nos, type: text, label: {id: Nomor seri}, depends_on: "item.tracking == 'serial'", help: {id: 'Satu nomor seri per baris'}}
|
|
@@ -16,3 +16,6 @@ fields:
|
|
|
16
16
|
label: {id: Qty diterima}
|
|
17
17
|
help: {id: 'Dalam satuan stok barang'}
|
|
18
18
|
required: true
|
|
19
|
+
# rangka-os contract 0070 §7: the serials that arrived, one per line; empty when the line takes the whole remainder
|
|
20
|
+
# of the item (every serial still in transit comes in). Lots follow the transfer, nothing to type.
|
|
21
|
+
- {name: serial_nos, type: text, label: {id: Nomor seri diterima}, depends_on: "item.tracking == 'serial'", help: {id: 'Kosongkan kalau semua unit yang dikirim sudah sampai'}}
|
|
@@ -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: stock
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.6.0
|
|
4
4
|
title: {id: Stok, en: Stock}
|
|
5
5
|
summary:
|
|
6
6
|
id: Saldo dan mutasi stok per toko dan gudang, permintaan barang ke gudang, transfer, opname dan penyesuaian.
|
|
@@ -8,7 +8,8 @@ summary:
|
|
|
8
8
|
category: stock
|
|
9
9
|
icon: archive-line
|
|
10
10
|
# contacts: stock_reorder.vendor links a vendor. catalogue already requires contacts, so no site gains a module.
|
|
11
|
-
requires: {rangka: '>=0.5', users: ^1.2, contacts: ^1.0, catalogue: ^1.
|
|
11
|
+
requires: {rangka: '>=0.5', users: ^1.2, contacts: ^1.0, catalogue: ^1.6, outlets: ^1.7}
|
|
12
|
+
# catalogue 1.6: item.tracking and expiry_warning_days (rangka-os contract 0070, lots and serials; rangka-os#260).
|
|
12
13
|
# outlets 1.7: location_type and supply_from (rangka-apps#104: warehouses apart from stores, stock_request).
|
|
13
14
|
# Semantics fixed in docs/kernel-hooks.md (section stock). stock.post_moves is a core hook on the on_submit of
|
|
14
15
|
# goods_receipt, stock_transfer, stock_transfer_receipt, stock_count, stock_adjustment and outlet_sales; stock.reverse_moves is declared here.
|
|
@@ -33,3 +34,9 @@ notices:
|
|
|
33
34
|
description: {id: 'Toko meminta barang ke gudang; gudang memproses atau menolak.'}
|
|
34
35
|
severity: info
|
|
35
36
|
to: [warehouse_staff, head_office]
|
|
37
|
+
# flow lot_expiry_digest: every morning, lots with stock that newly entered the item's expiry window (rangka-os#260)
|
|
38
|
+
- name: stock_expiry
|
|
39
|
+
label: {id: Stok hampir kedaluwarsa, en: Expiring stock}
|
|
40
|
+
description: {id: 'Ada lot barang yang masih punya stok dan akan atau sudah lewat tanggal kedaluwarsanya.'}
|
|
41
|
+
severity: warn
|
|
42
|
+
to: [owner, head_office, warehouse_staff]
|
|
@@ -40,6 +40,8 @@ fields:
|
|
|
40
40
|
- {value: reminder, label: {id: Pengingat tagihan}}
|
|
41
41
|
- {value: order_ready, label: {id: Kabar pesanan siap}}
|
|
42
42
|
- {value: appointment, label: {id: Pengingat janji}}
|
|
43
|
+
# module whatsapp_order: the reply after staff confirm an order the customer wrote on WhatsApp
|
|
44
|
+
- {value: order_reply, label: {id: Balasan pesanan WA}}
|
|
43
45
|
- {name: template, type: data, label: {id: Template}, read_only: true}
|
|
44
46
|
- {name: document, type: data, label: {id: Dokumen}, read_only: true, in_list: true}
|
|
45
47
|
- {name: customer, type: link, to: customer, label: {id: Pelanggan}, read_only: true, in_list: true}
|
|
@@ -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: whatsapp
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.1.0
|
|
4
4
|
title: {id: WhatsApp ke pelanggan, en: WhatsApp to customers}
|
|
5
5
|
summary:
|
|
6
6
|
id: Catatan pesan WhatsApp ke pelanggan (terkirim, dibaca, gagal) dan daftar pelanggan yang tidak mau dikirimi WA.
|
|
@@ -8,7 +8,7 @@ summary:
|
|
|
8
8
|
category: sales
|
|
9
9
|
icon: send-plane-line
|
|
10
10
|
# The shared part of the WhatsApp message types (whatsapp_receipt, whatsapp_reminder, whatsapp_order_ready,
|
|
11
|
-
# whatsapp_booking): each of those is its own module, so switching one type on or off is a change set the owner
|
|
11
|
+
# whatsapp_booking, whatsapp_order): each of those is its own module, so switching one type on or off is a change set the owner
|
|
12
12
|
# approves (config.modules). Messages go out through connector rangka_whatsapp (Rangka Cloud's relay, contract 0063
|
|
13
13
|
# §7): the relay checks the opt-out list, the kill switch, the template's approval and the caps before every send,
|
|
14
14
|
# and sends a key once. This module keeps what the business sees:
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# whatsapp_order: orders customers write on WhatsApp
|
|
2
|
+
|
|
3
|
+
A customer writes to the business's WhatsApp number ("pesan 2 kopi susu, 1 roti"). The order becomes a draft, priced
|
|
4
|
+
from the business's own item records. Staff confirm it with one tap on the work screen **Pesanan dari WhatsApp**
|
|
5
|
+
(`pesanan_wa`, app `pesanan_whatsapp`). Confirming creates the customer when needed and a draft `pos_sale` on the
|
|
6
|
+
cashier's open shift, then replies to the customer with the items and the total (template `pesanan_diterima`).
|
|
7
|
+
Nothing becomes an order without a person's confirm. The rules are in `module.rk` and the comments of each flow.
|
|
8
|
+
|
|
9
|
+
## Two steps, one path
|
|
10
|
+
|
|
11
|
+
1. **Message into lines.** For a text, Rangka Cloud does this (`rangka-cloud internal/whatsapp/orderparse`):
|
|
12
|
+
deterministic, no catalogue, no LLM. It gives `lines: [{qty, name, note, text, …}]`, `notes` and `order_signal`
|
|
13
|
+
on the connector trigger `rangka_whatsapp.message_received`.
|
|
14
|
+
2. **Lines into a priced draft.** Flow `whatsapp_order_intake` does this for any line:
|
|
15
|
+
- a line with `sku` is matched by `item.sku` only;
|
|
16
|
+
- a line with `name` is matched by the same name, part of the name, or the spelling skeleton. One candidate fills
|
|
17
|
+
the line, several make a choice for staff, none leaves an unknown line flagged as a note;
|
|
18
|
+
- a `price` on a line is kept as `quoted_rate` and only compared. The charged price is always the item's rate, and
|
|
19
|
+
a difference puts the order in "Perlu dicek".
|
|
20
|
+
|
|
21
|
+
The draft records its `source` (`whatsapp_text` today). Each message is kept once in `whatsapp_inbound`, with its
|
|
22
|
+
raw text, its Meta message type (`kind`) and the lines read from it, for audit and for a later shared inbox
|
|
23
|
+
(rangka-apps#130).
|
|
24
|
+
|
|
25
|
+
Names stay neutral (order, line, item, customer), so the same path fits a reseller re-ordering stock or a course
|
|
26
|
+
registration, not only a café.
|
|
27
|
+
|
|
28
|
+
## Next: A1b (interactive messages and catalogue carts)
|
|
29
|
+
|
|
30
|
+
Not built here. How it plugs in:
|
|
31
|
+
|
|
32
|
+
- **Catalogue cart** (Meta webhook message type `order`: `product_retailer_id`, `quantity`, `item_price`). Rangka
|
|
33
|
+
Cloud's intake maps each product to a line `{qty: quantity, sku: product_retailer_id, price: item_price, text}` and
|
|
34
|
+
sends `source: whatsapp_cart` and `order_signal: true`. The connector `rangka_whatsapp` adds `source` to its
|
|
35
|
+
`message_received` emit. The order then follows the same path: SKU match, price from the item, mismatch flagged,
|
|
36
|
+
one-tap confirm, the same reply. It needs catalogue sync to Meta (item SKU = retailer id). That is a separate piece
|
|
37
|
+
of work and costs money once real Meta is used.
|
|
38
|
+
- **Reply buttons and list messages** (`interactive` replies). The intake turns a picked row into one line with
|
|
39
|
+
`sku`, or into a staff note. A button that confirms an order still only records the customer's yes; a person
|
|
40
|
+
confirms the order.
|
|
41
|
+
- **WhatsApp Flows forms** (for example a course registration). Same idea: the form's answer becomes lines or notes
|
|
42
|
+
on a draft, never a confirmed document by itself.
|
|
43
|
+
- Sending interactive messages needs a new relay action in Rangka Cloud. Templates stay the only path outside the
|
|
44
|
+
24-hour window.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# A customer wrote to the business's WhatsApp number (connector rangka_whatsapp, trigger message_received; module
|
|
3
|
+
# doc). Runs once per Meta message id (idempotency, and whatsapp_inbound.message_id is unique), as the system.
|
|
4
|
+
# Two steps, kept apart so other sources can feed the second (module doc "Next: A1b"): reading a message into lines
|
|
5
|
+
# (Rangka Cloud's text parser today: name, qty, note) and matching lines to a priced draft (here). A line that names a
|
|
6
|
+
# product by reference (`sku`, as a WhatsApp catalogue cart will) is matched by item.sku only, never by name; a price
|
|
7
|
+
# a line carries (`price`) is kept as quoted_rate and only compared, the price is always the item's.
|
|
8
|
+
# 1. The message is kept (whatsapp_inbound, with its text and source) with its lines matched against the items in one
|
|
9
|
+
# pass (the expression in `lines` below), so the order steps copy rows that are already matched:
|
|
10
|
+
# - names are compared in one form: lower case, punctuation as a space, single spaces (Rangka Cloud's
|
|
11
|
+
# orderparse.Normalize; vectors in tests/day_one_whatsapp_order.py NORMALIZE_VECTORS);
|
|
12
|
+
# - candidates, first that has any: the same name (e); names holding the customer's words as whole words (p);
|
|
13
|
+
# the longest names the customer's words hold (rl: "kopi susu gula aren" holds "kopi susu", the rest becomes
|
|
14
|
+
# the note); the same spelling skeleton (t: no spaces and vowels, c/q as k, v as f, z as j, a doubled letter as
|
|
15
|
+
# one; only names of six or more letters, with the same first letter and word count);
|
|
16
|
+
# - one candidate fills the item; several make the line a choice (match pilih, candidates in choices); none leaves
|
|
17
|
+
# it tak_dikenal. The price is never set here: the line reads the item's rate.
|
|
18
|
+
# Only active items for sale with a price are candidates (kind not material, rate above 0).
|
|
19
|
+
# 2. A draft order: the customer's open one (state new) when its last message is at most 30 minutes from this one,
|
|
20
|
+
# else a new one, but only when Rangka Cloud read an order in the text (order_signal) or, for the open one, at least
|
|
21
|
+
# one line matched. Rows are appended; the window moves with each message. An order holds at most 60 lines: a
|
|
22
|
+
# message that would pass it is kept (result order_full) and not added.
|
|
23
|
+
# Candidates are the first 5001 items read; a catalogue past 5000 marks the draft catalogue_capped, which keeps it
|
|
24
|
+
# in "Perlu dicek" (a single candidate may not be the only one).
|
|
25
|
+
# 3. The customer: the one whose WhatsApp number this is, else the profile name as free text (created on confirm).
|
|
26
|
+
# The outlet: the store ticked "Terima pesanan WhatsApp" (outlet.wa_orders), else the only store, else empty (head
|
|
27
|
+
# office sets it).
|
|
28
|
+
name: whatsapp_order_intake
|
|
29
|
+
label: {id: 'Pesan WhatsApp masuk: jadi draf pesanan'}
|
|
30
|
+
description: {id: 'Pesanan yang ditulis pelanggan di WhatsApp jadi draf dengan harga dari data barang. Baris yang tidak dikenali atau punya beberapa pilihan ditandai untuk dicek staf. Tidak ada yang jadi pesanan sebelum staf mengonfirmasi.'}
|
|
31
|
+
on: rangka_whatsapp.message_received
|
|
32
|
+
if: "'message_id' in event && event.message_id != ''"
|
|
33
|
+
idempotency: event.message_id
|
|
34
|
+
steps:
|
|
35
|
+
- {find: whatsapp_inbound, where: message_id == event.message_id, as: seen}
|
|
36
|
+
- find_all: whatsapp_order
|
|
37
|
+
where: "wa_number == event.from.replace('+', '') && state == 'new'"
|
|
38
|
+
sort: -last_epoch
|
|
39
|
+
limit: 1
|
|
40
|
+
as: opens
|
|
41
|
+
- find: customer
|
|
42
|
+
where: "wa_number == event.from.replace('+', '')"
|
|
43
|
+
as: cust
|
|
44
|
+
- find_all: item
|
|
45
|
+
where: "kind != 'material' && active != false && rate > 0"
|
|
46
|
+
limit: 5001
|
|
47
|
+
as: menu
|
|
48
|
+
- find_all: outlet
|
|
49
|
+
if: "app_installed('outlets')"
|
|
50
|
+
where: "(location_type == '' || location_type == 'store') && active != false"
|
|
51
|
+
sort: -wa_orders
|
|
52
|
+
limit: 2
|
|
53
|
+
as: stores
|
|
54
|
+
- create: whatsapp_inbound
|
|
55
|
+
if: seen == null
|
|
56
|
+
set:
|
|
57
|
+
message_id: event.message_id
|
|
58
|
+
source: "'source' in event && event.source != '' ? event.source : 'whatsapp_text'"
|
|
59
|
+
kind: "'kind' in event ? event.kind : ''"
|
|
60
|
+
sender: "cust != null ? cust.customer_name : ('profile_name' in event && event.profile_name != '' ? event.profile_name : 'Pelanggan WhatsApp')"
|
|
61
|
+
phone: event.from
|
|
62
|
+
wa_number: event.from.replace('+', '')
|
|
63
|
+
text: "'text' in event ? event.text : ''"
|
|
64
|
+
received_at: event.at
|
|
65
|
+
lines_read: "'lines' in event ? event.lines.size() : 0"
|
|
66
|
+
catalogue_capped: menu.size() > 5000
|
|
67
|
+
outlet: "app_installed('outlets') && opens.size() > 0 ? opens[0].outlet : (app_installed('outlets') && ((stores.size() > 0 && stores[0].wa_orders) || stores.size() == 1) ? stores[0].name : '')"
|
|
68
|
+
lines: >-
|
|
69
|
+
!('lines' in event) || event.lines.size() == 0 ? [] : [menu.map(i, {'id': i.name, 'title': i.item_name, 'sku': i.sku, 'n': i.item_name.lowerAscii().replace('(', ' ').replace(')', ' ').replace('[', ' ').replace(']', ' ').replace('{', ' ').replace('}', ' ').replace('-', ' ').replace('/', ' ').replace('.', ' ').replace(',', ' ').replace(';', ' ').replace(':', ' ').replace('&', ' ').replace('+', ' ').replace('_', ' ').replace('#', ' ').replace('*', ' ').replace('!', ' ').replace('?', ' ').replace('~', ' ').replace("'", ' ').replace('"', ' ').replace(' ', ' ').replace(' ', ' ').replace(' ', ' ').trim()}).map(x, {'id': x.id, 'title': x.title, 'sku': x.sku, 'n': x.n, 'k': x.n.replace(' ', '').replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '').replace('c', 'k').replace('q', 'k').replace('v', 'f').replace('z', 'j').replace('bb', 'b').replace('dd', 'd').replace('ff', 'f').replace('gg', 'g').replace('hh', 'h').replace('jj', 'j').replace('kk', 'k').replace('ll', 'l').replace('mm', 'm').replace('nn', 'n').replace('pp', 'p').replace('rr', 'r').replace('ss', 's').replace('tt', 't').replace('ww', 'w').replace('xx', 'x').replace('yy', 'y'), 'w': (size(x.n) - size(x.n.replace(' ', '')))})].map(mm, event.lines.map(l, {'l': l, 'n': ('name' in l ? string(l.name) : '').lowerAscii().replace('(', ' ').replace(')', ' ').replace('[', ' ').replace(']', ' ').replace('{', ' ').replace('}', ' ').replace('-', ' ').replace('/', ' ').replace('.', ' ').replace(',', ' ').replace(';', ' ').replace(':', ' ').replace('&', ' ').replace('+', ' ').replace('_', ' ').replace('#', ' ').replace('*', ' ').replace('!', ' ').replace('?', ' ').replace('~', ' ').replace("'", ' ').replace('"', ' ').replace(' ', ' ').replace(' ', ' ').replace(' ', ' ').trim(), 'ref': 'sku' in l ? string(l.sku) : ''}).map(c, {'l': c.l, 'n': c.n, 'ref': c.ref, 'k': c.n.replace(' ', '').replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '').replace('c', 'k').replace('q', 'k').replace('v', 'f').replace('z', 'j').replace('bb', 'b').replace('dd', 'd').replace('ff', 'f').replace('gg', 'g').replace('hh', 'h').replace('jj', 'j').replace('kk', 'k').replace('ll', 'l').replace('mm', 'm').replace('nn', 'n').replace('pp', 'p').replace('rr', 'r').replace('ss', 's').replace('tt', 't').replace('ww', 'w').replace('xx', 'x').replace('yy', 'y'), 'w': (size(c.n) - size(c.n.replace(' ', ''))), 'e': c.ref != '' ? mm.filter(x, x.sku == c.ref) : mm.filter(x, x.n == c.n), 'p': c.ref != '' || c.n == '' ? [] : mm.filter(x, (' ' + x.n + ' ').contains(' ' + c.n + ' ')), 'r': c.ref != '' || c.n == '' ? [] : mm.filter(x, (' ' + c.n + ' ').contains(' ' + x.n + ' '))}).map(c, {'l': c.l, 'n': c.n, 'e': c.e, 'p': c.p, 'rl': c.r.size() == 0 ? [] : c.r.filter(x, size(x.n) == max(c.r.map(y, size(y.n)))), 't': c.n == '' || c.ref != '' ? [] : mm.filter(x, size(x.n) >= 6 && x.k == c.k && x.w == c.w && truncate(x.n, 1) == truncate(c.n, 1))}).map(c, {'l': c.l, 'n': c.n, 'cand': c.e.size() > 0 ? c.e : (c.p.size() > 0 ? c.p : (c.rl.size() > 0 ? c.rl : c.t)), 'how': c.e.size() > 0 ? 'sama' : (c.p.size() > 0 ? 'sebagian' : (c.rl.size() > 0 ? 'sebagian' : (c.t.size() > 0 ? 'ejaan' : 'tak_dikenal'))), 'rest': c.e.size() == 0 && c.p.size() == 0 && c.rl.size() == 1 ? c.n.replace(c.rl[0].n, '').replace(' ', ' ').trim() : ''}).map(c, {'text': 'text' in c.l ? string(c.l.text) : '', 'qty': int(c.l.qty) > 0 ? int(c.l.qty) : 1, 'unit': 'unit' in c.l ? string(c.l.unit) : '', 'quoted_rate': 'price' in c.l ? int(c.l.price) : 0, 'item': c.cand.size() == 1 ? c.cand[0].id : '', 'match': c.cand.size() > 1 ? 'pilih' : c.how, 'choices': c.cand.size() > 1 ? truncate(c.cand.map(x, x.title).join(' / '), 240) : '', 'note': ['note' in c.l ? string(c.l.note) : '', c.rest].filter(s, s != '').join('; ')}))[0]
|
|
70
|
+
as: inb
|
|
71
|
+
- create: whatsapp_order
|
|
72
|
+
if: >-
|
|
73
|
+
seen == null && inb.lines.size() > 0 && event.order_signal == true && !(opens.size() > 0 && epoch(event.at) - opens[0].last_epoch <= 1800 && opens[0].last_epoch - epoch(event.at) <= 1800)
|
|
74
|
+
set:
|
|
75
|
+
customer_name: "cust != null ? cust.customer_name : ('profile_name' in event && event.profile_name.trim() != '' ? event.profile_name.trim() : 'Pelanggan WhatsApp')"
|
|
76
|
+
customer: "cust != null ? cust.name : ''"
|
|
77
|
+
source: inb.source
|
|
78
|
+
catalogue_capped: inb.catalogue_capped
|
|
79
|
+
phone: event.from
|
|
80
|
+
wa_number: event.from.replace('+', '')
|
|
81
|
+
outlet: "app_installed('outlets') && ((stores.size() > 0 && stores[0].wa_orders) || stores.size() == 1) ? stores[0].name : ''"
|
|
82
|
+
lines: >-
|
|
83
|
+
inb.lines.map(l, {'text': l.text, 'item': l.item, 'qty': l.qty, 'unit': l.unit, 'note': l.note, 'match': l.match, 'choices': l.choices, 'quoted_rate': l.quoted_rate})
|
|
84
|
+
notes: "'notes' in event ? event.notes.join('; ') : ''"
|
|
85
|
+
messages: '1'
|
|
86
|
+
first_message_at: event.at
|
|
87
|
+
last_message_at: event.at
|
|
88
|
+
last_epoch: epoch(event.at)
|
|
89
|
+
as: fresh
|
|
90
|
+
# a flow find leaves table rows out: an empty update loads them before rows are appended
|
|
91
|
+
- find: whatsapp_order
|
|
92
|
+
if: >-
|
|
93
|
+
seen == null && inb.lines.size() > 0 && (opens.size() > 0 && epoch(event.at) - opens[0].last_epoch <= 1800 && opens[0].last_epoch - epoch(event.at) <= 1800) && opens[0].line_count + inb.lines.size() <= 60 && (event.order_signal == true || inb.lines.map(l, l.item != '' || l.match == 'pilih' ? 1 : 0).sum() > 0)
|
|
94
|
+
where: name == opens[0].name
|
|
95
|
+
as: o
|
|
96
|
+
- update: o
|
|
97
|
+
if: >-
|
|
98
|
+
seen == null && inb.lines.size() > 0 && (opens.size() > 0 && epoch(event.at) - opens[0].last_epoch <= 1800 && opens[0].last_epoch - epoch(event.at) <= 1800) && opens[0].line_count + inb.lines.size() <= 60 && (event.order_signal == true || inb.lines.map(l, l.item != '' || l.match == 'pilih' ? 1 : 0).sum() > 0)
|
|
99
|
+
set: {}
|
|
100
|
+
- update: o
|
|
101
|
+
if: >-
|
|
102
|
+
seen == null && inb.lines.size() > 0 && (opens.size() > 0 && epoch(event.at) - opens[0].last_epoch <= 1800 && opens[0].last_epoch - epoch(event.at) <= 1800) && opens[0].line_count + inb.lines.size() <= 60 && (event.order_signal == true || inb.lines.map(l, l.item != '' || l.match == 'pilih' ? 1 : 0).sum() > 0)
|
|
103
|
+
set:
|
|
104
|
+
lines: >-
|
|
105
|
+
o.lines.map(l, {'text': l.text, 'item': l.item, 'qty': l.qty, 'unit': l.unit, 'note': l.note, 'match': l.match, 'choices': l.choices, 'quoted_rate': l.quoted_rate}) + inb.lines.map(l, {'text': l.text, 'item': l.item, 'qty': l.qty, 'unit': l.unit, 'note': l.note, 'match': l.match, 'choices': l.choices, 'quoted_rate': l.quoted_rate})
|
|
106
|
+
notes: "'notes' in event && event.notes.size() > 0 ? (o.notes != '' ? o.notes + '; ' : '') + event.notes.join('; ') : o.notes"
|
|
107
|
+
messages: o.messages + 1
|
|
108
|
+
catalogue_capped: o.catalogue_capped || inb.catalogue_capped
|
|
109
|
+
last_message_at: "epoch(event.at) > o.last_epoch ? event.at : o.last_message_at"
|
|
110
|
+
last_epoch: max(o.last_epoch, epoch(event.at))
|
|
111
|
+
- update: inb
|
|
112
|
+
if: seen == null
|
|
113
|
+
set:
|
|
114
|
+
result: >-
|
|
115
|
+
seen == null && inb.lines.size() > 0 && event.order_signal == true && !(opens.size() > 0 && epoch(event.at) - opens[0].last_epoch <= 1800 && opens[0].last_epoch - epoch(event.at) <= 1800) ? 'order_new' : (seen == null && inb.lines.size() > 0 && (opens.size() > 0 && epoch(event.at) - opens[0].last_epoch <= 1800 && opens[0].last_epoch - epoch(event.at) <= 1800) && opens[0].line_count + inb.lines.size() <= 60 && (event.order_signal == true || inb.lines.map(l, l.item != '' || l.match == 'pilih' ? 1 : 0).sum() > 0) ? 'order_added' : (seen == null && inb.lines.size() > 0 && (opens.size() > 0 && epoch(event.at) - opens[0].last_epoch <= 1800 && opens[0].last_epoch - epoch(event.at) <= 1800) && opens[0].line_count + inb.lines.size() > 60 ? 'order_full' : 'not_order'))
|
|
116
|
+
order: >-
|
|
117
|
+
seen == null && inb.lines.size() > 0 && event.order_signal == true && !(opens.size() > 0 && epoch(event.at) - opens[0].last_epoch <= 1800 && opens[0].last_epoch - epoch(event.at) <= 1800) ? fresh.name : (seen == null && inb.lines.size() > 0 && (opens.size() > 0 && epoch(event.at) - opens[0].last_epoch <= 1800 && opens[0].last_epoch - epoch(event.at) <= 1800) && opens[0].line_count + inb.lines.size() <= 60 && (event.order_signal == true || inb.lines.map(l, l.item != '' || l.match == 'pilih' ? 1 : 0).sum() > 0) ? o.name : '')
|
|
118
|
+
lines_matched: "inb.lines.map(l, l.item != '' || l.match == 'pilih' ? 1 : 0).sum()"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# A confirmed WhatsApp order is final (audit 2026-11-21 finding 2): its sale and its reply were made from these lines,
|
|
3
|
+
# so a person's later edit of the order (lines, quantities, customer, outlet) is refused. Changes go on the sale at
|
|
4
|
+
# the kasir. Writes by flows start no flow, so the confirm's own write of the sale and the reply is not seen here.
|
|
5
|
+
name: whatsapp_order_locked
|
|
6
|
+
label: {id: 'Pesanan WhatsApp yang sudah dikonfirmasi tidak bisa diubah'}
|
|
7
|
+
description: {id: 'Setelah dikonfirmasi, isi pesanan WhatsApp tetap seperti yang dibalas ke pelanggan. Perubahan dilakukan di transaksi kasirnya.'}
|
|
8
|
+
on: whatsapp_order.updated
|
|
9
|
+
if: event.before != null && event.before.state == 'confirmed' && event.state == 'confirmed'
|
|
10
|
+
steps:
|
|
11
|
+
- create: whatsapp_order_guard
|
|
12
|
+
set: {reason: "'locked'", document: event.name}
|