@rangka-os/create 0.5.0-alpha.33 → 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/kasir/skills/rangka-app-kasir/SKILL.md +1 -1
- package/template/base/apps/pesanan_whatsapp/app.rk +28 -0
- 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/catalogue/defaults/uom.rk +19 -0
- package/template/base/modules/catalogue/models/item.rk +12 -0
- 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/pos/models/pos_sale_item.rk +1 -0
- package/template/base/modules/pos/screens/kasir.rk +1 -0
- package/template/base/modules/reimbursement/models/expense_claim.rk +1 -1
- package/template/base/modules/stock/flows/stock_balance_variant_group.rk +26 -0
- package/template/base/modules/stock/models/stock_balance.rk +1 -0
- package/template/base/modules/stock/models/stock_move.rk +1 -0
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rangka-os/create",
|
|
3
|
-
"version": "0.5.0-alpha.
|
|
3
|
+
"version": "0.5.0-alpha.34",
|
|
4
4
|
"description": "Start a Rangka OS project: npm create @rangka-os@latest my-shop",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"homepage": "https://rangka-os.github.io/rangka-os/guide/quick-start",
|
|
@@ -32,7 +32,7 @@ specific to the cashier.
|
|
|
32
32
|
|
|
33
33
|
## In the studio interview: when the cashier goes on the map
|
|
34
34
|
|
|
35
|
-
For
|
|
35
|
+
For Zafdoz's consultant interview (`rangka-consult`, contract 0042). The deciding fact is the tools the owner uses
|
|
36
36
|
today and whether Juragan replaces them:
|
|
37
37
|
|
|
38
38
|
- A business that serves buyers at a counter (kedai, kafe, restoran, toko) and has **no cashier app yet**, or chose
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/app.json
|
|
2
|
+
name: pesanan_whatsapp
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
title: {id: Pesanan dari WhatsApp, en: WhatsApp orders}
|
|
5
|
+
label: {id: Rangka Pesanan WhatsApp, en: Rangka WhatsApp Orders}
|
|
6
|
+
summary:
|
|
7
|
+
id: Chat pesanan di WhatsApp jadi draf berharga dari data barang; staf konfirmasi sekali ketuk dan pelanggan dibalas totalnya.
|
|
8
|
+
category: sales
|
|
9
|
+
icon: chat-check-line
|
|
10
|
+
rangka: '>=0.5'
|
|
11
|
+
# A piece on top of kasir (module whatsapp_order, its doc has the rules): the work screen pesanan_wa for the cashier and
|
|
12
|
+
# head office, the orders and the messages they came from in the menu. Needs the WhatsApp service from Rangka Cloud
|
|
13
|
+
# (connector rangka_whatsapp on the site), which reads the text into lines; prices always come from the item records.
|
|
14
|
+
modules:
|
|
15
|
+
users: ^1.2
|
|
16
|
+
contacts: ^1.3
|
|
17
|
+
catalogue: ^1.3
|
|
18
|
+
outlets: ^1.8
|
|
19
|
+
pos: ^1.3
|
|
20
|
+
whatsapp: ^1.1
|
|
21
|
+
whatsapp_order: ^1.0
|
|
22
|
+
roles: [cashier, head_office]
|
|
23
|
+
home: {model: whatsapp_order}
|
|
24
|
+
work:
|
|
25
|
+
- {screen: pesanan_wa, roles: [cashier, head_office]}
|
|
26
|
+
menu:
|
|
27
|
+
- group: {id: Pesanan WhatsApp}
|
|
28
|
+
items: [whatsapp_order, whatsapp_inbound, whatsapp_message]
|
|
@@ -109,6 +109,22 @@ widgets:
|
|
|
109
109
|
period: date
|
|
110
110
|
sort: -value
|
|
111
111
|
span: 6
|
|
112
|
+
# Terlaris per produk: the sizes and flavours of one product count together (hidden variant_group of the stock move);
|
|
113
|
+
# an item without a group is not in this chart (see Terlaris per barang). Cancelled sales and returns net out.
|
|
114
|
+
- name: best_sellers_by_product
|
|
115
|
+
type: chart
|
|
116
|
+
chart: bar
|
|
117
|
+
label: {id: Terlaris per produk}
|
|
118
|
+
description: {id: 'Jumlah terjual per produk; semua varian satu produk dihitung bersama'}
|
|
119
|
+
model: stock_move
|
|
120
|
+
group_by: variant_group
|
|
121
|
+
aggregate: sum
|
|
122
|
+
field: sold_qty
|
|
123
|
+
filter: "(voucher_type == 'outlet_sales' || voucher_type == 'outlet_return') && variant_group != ''"
|
|
124
|
+
period: posting_date
|
|
125
|
+
sort: -value
|
|
126
|
+
limit: 10
|
|
127
|
+
span: 6
|
|
112
128
|
- name: net_by_day
|
|
113
129
|
type: chart
|
|
114
130
|
chart: line
|
|
@@ -96,6 +96,19 @@ widgets:
|
|
|
96
96
|
limit: 20
|
|
97
97
|
columns: [outlet, item, qty, value]
|
|
98
98
|
span: 12
|
|
99
|
+
- name: stock_by_product
|
|
100
|
+
type: chart
|
|
101
|
+
chart: bar
|
|
102
|
+
label: {id: Stok per produk}
|
|
103
|
+
description: {id: 'Jumlah stok semua varian satu produk (ukuran, rasa) dijumlahkan'}
|
|
104
|
+
model: stock_balance
|
|
105
|
+
group_by: variant_group
|
|
106
|
+
aggregate: sum
|
|
107
|
+
field: qty
|
|
108
|
+
filter: "qty > 0 && variant_group != ''"
|
|
109
|
+
sort: -value
|
|
110
|
+
limit: 10
|
|
111
|
+
span: 6
|
|
99
112
|
- name: stock_value_by_outlet
|
|
100
113
|
type: chart
|
|
101
114
|
chart: bar
|
|
@@ -10,15 +10,15 @@ Read `rangka-compose` first. This draft only adds the first day.
|
|
|
10
10
|
|
|
11
11
|
## First day (first-day.json)
|
|
12
12
|
|
|
13
|
-
`first-day.json` next to this file is read by Rangka Cloud after the build (proposal "First day with
|
|
13
|
+
`first-day.json` next to this file is read by Rangka Cloud after the build (proposal "First day with Zafdoz", draft for rangka-os):
|
|
14
14
|
|
|
15
15
|
- `steps`: 3-5 steps in the order a rental business starts. A step is done when the kernel has at least `done.min`
|
|
16
16
|
records of `done.model`; a step without `done` is ticked by the owner.
|
|
17
|
-
- `seed`: what
|
|
17
|
+
- `seed`: what Zafdoz may prepare from the interview. Only values the owner said, each with the owner's quote (engine
|
|
18
18
|
`/v1/seed` drops the rest). Money fields are marked `money` and shown separately; nothing is written before the
|
|
19
19
|
owner agrees.
|
|
20
20
|
- `rename`: model labels that follow the owner's own word for what they rent (`{Word}` capitalised, `{word}` lower),
|
|
21
21
|
proposed as one low-risk change set of label overlays.
|
|
22
|
-
- `menu`: one sentence per menu item, said by
|
|
22
|
+
- `menu`: one sentence per menu item, said by Zafdoz when the owner first opens it.
|
|
23
23
|
|
|
24
24
|
Say these in the owner's words. Never invent units, plates, rates or fees the owner did not say.
|
|
@@ -34,7 +34,7 @@ What the kernel holds works for this business only and is not Meta's:
|
|
|
34
34
|
|
|
35
35
|
`send_template {to, template, type, components, idempotency_key}` → `{message_id, status}`.
|
|
36
36
|
|
|
37
|
-
- `type` is the business's message type: `receipt`, `reminder`, `order_ready`, `appointment`. Each can be switched off
|
|
37
|
+
- `type` is the business's message type: `receipt`, `reminder`, `order_ready`, `appointment`, `order_reply`. Each can be switched off
|
|
38
38
|
on its own.
|
|
39
39
|
- `components` is one body component with text parameters, in the template's order. The host rebuilds what goes to
|
|
40
40
|
Meta from them; a header, a button or media is refused.
|
|
@@ -74,7 +74,7 @@ Every event is one JSON object, signed over the raw body: `X-Rangka-Signature: s
|
|
|
74
74
|
| Trigger | Fields | When |
|
|
75
75
|
| --- | --- | --- |
|
|
76
76
|
| `message_status` | `message_id`, `idempotency_key`, `type`, `status` (`sent`, `delivered`, `read`, `failed`), `at`, `error` | Meta reported a status, or the host refused a send (`failed`, `message_id` empty, the code in `error`) |
|
|
77
|
-
| `message_received` | `message_id`, `from`, `text`, `profile_name`, `at` | a customer wrote to the number (it only sends in phase 1) |
|
|
77
|
+
| `message_received` | `message_id`, `from`, `text`, `kind`, `profile_name`, `at`, `lines`, `notes`, `order_signal` | a customer wrote to the number (it only sends in phase 1). The host reads a text as an order (deterministic, no catalogue): `lines` are `{qty, qty_given, unit, name, note, text}` with `name` lower-case ASCII words, `notes` the pick-up, delivery or time remarks, `order_signal` true when it reads as an order (an order word, a quantity, or a list of two or more). rangka-apps module `whatsapp_order` matches the lines against the business's items |
|
|
78
78
|
| `opted_out` | `phone`, `at`, `source` (`keyword`, `meta`, `staff`) | a customer replied `BERHENTI` or `STOP`, or Meta reported a block |
|
|
79
79
|
|
|
80
80
|
A status never carries the phone: the flow finds its document by `idempotency_key`.
|
|
@@ -92,6 +92,7 @@ language `id`, and end with *Balas BERHENTI untuk berhenti menerima pesan.*
|
|
|
92
92
|
| `terima_kasih_lunas` | `reminder` | Halo {{1}}, terima kasih. Pembayaran faktur {{2}} sudah kami terima dan faktur ini sudah lunas. |
|
|
93
93
|
| `pesanan_siap` | `order_ready` | Halo {{1}}, pesanan {{2}} di {{3}} sudah siap diambil. Sebutkan nomor pesanan saat mengambil. Terima kasih. |
|
|
94
94
|
| `pengingat_janji` | `appointment` | Halo {{1}}, kami mengingatkan {{2}} di {{3}} pada {{4}}. Kalau perlu mengubah jadwal, hubungi kami sebelum waktunya. Terima kasih. |
|
|
95
|
+
| `pesanan_diterima` | `order_reply` | Halo {{1}}, pesanan {{2}} di {{3}} sudah kami terima: {{4}}. Total {{5}}. Terima kasih. |
|
|
95
96
|
|
|
96
97
|
## Local mock
|
|
97
98
|
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
name: rangka_whatsapp
|
|
13
13
|
label: {id: WhatsApp dari Rangka Cloud, en: WhatsApp from Rangka Cloud}
|
|
14
14
|
summary:
|
|
15
|
-
id: Kirim struk, pengingat
|
|
15
|
+
id: Kirim struk, pengingat dan kabar pesanan, dan terima pesanan pelanggan, lewat nomor WhatsApp bisnismu dari Rangka Cloud.
|
|
16
16
|
en: Send receipts, payment reminders and order updates to customers from the WhatsApp number Rangka Cloud provides for your business.
|
|
17
17
|
category: messaging
|
|
18
18
|
icon: send-plane-line
|
|
19
|
-
version: 0.
|
|
19
|
+
version: 0.2.0
|
|
20
20
|
vendor: Rangka Cloud
|
|
21
21
|
docs: https://github.com/rangka-os/rangka-connectors/blob/main/rangka_whatsapp/README.md
|
|
22
22
|
# The host's public service address. A placeholder under the reserved .example domain until Rangka Cloud has one:
|
|
@@ -55,7 +55,11 @@ triggers:
|
|
|
55
55
|
status: status
|
|
56
56
|
at: at
|
|
57
57
|
error: error
|
|
58
|
-
# A customer wrote to the number. The number only sends (phase 1), so this is for the business to see.
|
|
58
|
+
# A customer wrote to the number. The number only sends (phase 1), so this is for the business to see. The host
|
|
59
|
+
# also reads a text as an order (Rangka Cloud internal/whatsapp/orderparse, deterministic, no catalogue): `lines`
|
|
60
|
+
# [{qty, qty_given, unit, name, note, text}], `notes` (pick-up, delivery, time) and `order_signal` (an order word,
|
|
61
|
+
# a quantity or a list). rangka-apps module whatsapp_order matches the lines against the business's own items;
|
|
62
|
+
# `kind` is Meta's message type (text, image, …; a non-text message has no text and no lines).
|
|
59
63
|
- name: message_received
|
|
60
64
|
label: {id: Pesan masuk, en: Incoming message}
|
|
61
65
|
via: webhook
|
|
@@ -69,8 +73,12 @@ triggers:
|
|
|
69
73
|
message_id: message_id
|
|
70
74
|
from: from
|
|
71
75
|
text: text
|
|
76
|
+
kind: kind
|
|
72
77
|
profile_name: profile_name
|
|
73
78
|
at: at
|
|
79
|
+
lines: lines
|
|
80
|
+
notes: notes
|
|
81
|
+
order_signal: order_signal
|
|
74
82
|
# A customer asked to stop (they replied BERHENTI or STOP, or Meta reported a block). The host already refuses
|
|
75
83
|
# sends to them; the flow marks the customer so staff see it.
|
|
76
84
|
- name: opted_out
|
|
@@ -102,7 +110,7 @@ actions:
|
|
|
102
110
|
input:
|
|
103
111
|
- {name: to, type: phone, required: true}
|
|
104
112
|
- {name: template, type: data, required: true}
|
|
105
|
-
# receipt | reminder | order_ready | appointment: which of the business's message types this is
|
|
113
|
+
# receipt | reminder | order_ready | appointment | order_reply: which of the business's message types this is
|
|
106
114
|
- {name: type, type: data, required: true}
|
|
107
115
|
- {name: components, type: json}
|
|
108
116
|
# <document>:<type>:<step>, e.g. STRK-KPI-2611-00142:receipt:1. The same key is sent once, by the kernel
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"message_status.json": {"message_id": "wam_contoh0001", "idempotency_key": "STRK-KPI-2611-00142:receipt:1", "type": "receipt", "status": "read", "error": ""},
|
|
3
3
|
"message_status_refused.json": {"message_id": "", "idempotency_key": "INV-2026-00031:reminder:7", "status": "failed", "error": "recipient_opted_out"},
|
|
4
|
-
"message_received.json": {"from": "+6281200000001", "text": "Terima kasih", "profile_name": "Pelanggan Contoh"},
|
|
4
|
+
"message_received.json": {"from": "+6281200000001", "text": "Terima kasih", "profile_name": "Pelanggan Contoh", "kind": "text", "order_signal": false},
|
|
5
5
|
"opted_out.json": {"phone": "+6281200000001", "source": "keyword"},
|
|
6
6
|
"send_template.json": {"message_id": "wam_contoh0001", "status": "accepted"},
|
|
7
7
|
"send_template_duplicate.json": {"message_id": "wam_contoh0001", "status": "delivered"},
|
|
8
|
-
"set_opt_out.json": {"status": "recorded"}
|
|
8
|
+
"set_opt_out.json": {"status": "recorded"},
|
|
9
|
+
"message_received_order.json": {"from": "+6281200000001", "order_signal": true, "notes": ["ambil jam 3"]}
|
|
9
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"message_id": "wamid.CONTOH0002", "from": "+6281200000001", "text": "Terima kasih", "profile_name": "Pelanggan Contoh", "at": "2026-11-19T03:05:00Z"}
|
|
1
|
+
{"message_id": "wamid.CONTOH0002", "from": "+6281200000001", "text": "Terima kasih", "kind": "text", "profile_name": "Pelanggan Contoh", "at": "2026-11-19T03:05:00Z", "lines": [], "notes": [], "order_signal": false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"message_id": "wamid.CONTOH0003", "from": "+6281200000001", "text": "pesan 2 kopi susu, 1 roti bakar coklat, ambil jam 3", "kind": "text", "profile_name": "Pelanggan Contoh", "at": "2026-11-19T03:06:00Z", "lines": [{"qty": 2, "qty_given": true, "unit": "", "name": "kopi susu", "note": "", "text": "pesan 2 kopi susu"}, {"qty": 1, "qty_given": true, "unit": "", "name": "roti bakar coklat", "note": "", "text": "1 roti bakar coklat"}], "notes": ["ambil jam 3"], "order_signal": true}
|
|
@@ -18,8 +18,10 @@ Stdlib only. The request, answer and event shapes follow connector.rk and README
|
|
|
18
18
|
- POST /svc/whatsapp/v1/opt-outs (Bearer token) {phone}: 200 {status: recorded | already}.
|
|
19
19
|
- POST /simulate/status {message_id | idempotency_key, status, error}: the message's status changes (sent, delivered,
|
|
20
20
|
read, failed) and the mock posts the message_status event to --hook-url/message_status, signed.
|
|
21
|
-
- POST /simulate/inbound {from, text}: a customer writes. BERHENTI or STOP opts them out
|
|
22
|
-
else posts message_received.
|
|
21
|
+
- POST /simulate/inbound {from, text[, lines, notes, order_signal]}: a customer writes. BERHENTI or STOP opts them out
|
|
22
|
+
and posts opted_out; anything else posts message_received. The host reads a text as an order with its own parser
|
|
23
|
+
(Rangka Cloud internal/whatsapp/orderparse); this mock has none, so a test passes the lines it wants the kernel to
|
|
24
|
+
hear (none by default).
|
|
23
25
|
- POST /simulate/redeliver[?key=<other>]: posts the last event again (the host retries an event that got no 2xx),
|
|
24
26
|
optionally signed with another key, to test the receiver's dedupe and its signature check.
|
|
25
27
|
- POST /simulate/service {state: active | stopped | paused}, POST /simulate/template {name, approved: true | false},
|
|
@@ -54,8 +56,9 @@ TEMPLATES = {
|
|
|
54
56
|
"terima_kasih_lunas": ("reminder", 2),
|
|
55
57
|
"pesanan_siap": ("order_ready", 3),
|
|
56
58
|
"pengingat_janji": ("appointment", 4),
|
|
59
|
+
"pesanan_diterima": ("order_reply", 5),
|
|
57
60
|
}
|
|
58
|
-
TYPES = {"receipt", "reminder", "order_ready", "appointment"}
|
|
61
|
+
TYPES = {"receipt", "reminder", "order_ready", "appointment", "order_reply"}
|
|
59
62
|
STOP_WORDS = {"BERHENTI", "STOP"}
|
|
60
63
|
KEY_RE = re.compile(r"^[A-Za-z0-9._:/-]{1,200}$")
|
|
61
64
|
SIGNATURE_HEADER = "X-Rangka-Signature"
|
|
@@ -299,7 +302,9 @@ def handler(state: State):
|
|
|
299
302
|
code = deliver(state, "opted_out", {"phone": phone, "at": now_iso(), "source": "keyword"})
|
|
300
303
|
else:
|
|
301
304
|
code = deliver(state, "message_received", {"message_id": "wamid.IN" + uuid.uuid4().hex[:12], "from": phone, "text": text,
|
|
302
|
-
"profile_name": str(b.get("profile_name") or "Pelanggan Contoh"),
|
|
305
|
+
"kind": "text", "profile_name": str(b.get("profile_name") or "Pelanggan Contoh"),
|
|
306
|
+
"at": now_iso(), "lines": b.get("lines") or [], "notes": b.get("notes") or [],
|
|
307
|
+
"order_signal": bool(b.get("order_signal"))})
|
|
303
308
|
return self._json(200, {"hook_status": code})
|
|
304
309
|
if what == "redeliver":
|
|
305
310
|
with state.lock:
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Default units (contract 0076): filled into a business's empty Satuan table when the catalogue module is installed,
|
|
2
|
+
# so its first item can be saved. A business that already has a unit gets none of these. Coretax codes only where
|
|
3
|
+
# the model's help names them; the rest stay empty (UM.0033 Lainnya).
|
|
4
|
+
uom:
|
|
5
|
+
- {uom_name: Unit, coretax_unit: UM.0018}
|
|
6
|
+
- {uom_name: Pcs}
|
|
7
|
+
- {uom_name: Buah}
|
|
8
|
+
- {uom_name: Set}
|
|
9
|
+
- {uom_name: Pak}
|
|
10
|
+
- {uom_name: Dus}
|
|
11
|
+
- {uom_name: Lusin}
|
|
12
|
+
- {uom_name: Kg, coretax_unit: UM.0003}
|
|
13
|
+
- {uom_name: Gram}
|
|
14
|
+
- {uom_name: Liter}
|
|
15
|
+
- {uom_name: Meter}
|
|
16
|
+
- {uom_name: Porsi}
|
|
17
|
+
- {uom_name: Jam, coretax_unit: UM.0027}
|
|
18
|
+
- {uom_name: Hari, coretax_unit: UM.0026}
|
|
19
|
+
- {uom_name: Bulan, coretax_unit: UM.0024}
|
|
@@ -48,6 +48,10 @@ fields:
|
|
|
48
48
|
type: data
|
|
49
49
|
label: {id: Varian}
|
|
50
50
|
help: {id: 'Misalnya "M / Hitam" atau "600 ml"'}
|
|
51
|
+
- name: variant_title
|
|
52
|
+
type: data
|
|
53
|
+
label: {id: Nama produk di kasir}
|
|
54
|
+
help: {id: 'Opsional. Nama yang tampil di kotak produk kasir; kalau kosong dipakai awalan nama barang yang sama'}
|
|
51
55
|
- name: kind
|
|
52
56
|
type: select
|
|
53
57
|
label: {id: Jenis}
|
|
@@ -220,6 +224,14 @@ fields:
|
|
|
220
224
|
in_list: true
|
|
221
225
|
in_filter: true
|
|
222
226
|
rules:
|
|
227
|
+
- name: variant_label_needs_group
|
|
228
|
+
on: save
|
|
229
|
+
check: "variant_group == '' || variant_label != ''"
|
|
230
|
+
message: {id: Isi nama varian (misalnya M / Hitam) untuk barang yang punya grup varian}
|
|
231
|
+
- name: variant_title_needs_group
|
|
232
|
+
on: save
|
|
233
|
+
check: "variant_title == '' || variant_group != ''"
|
|
234
|
+
message: {id: Nama produk di kasir hanya dipakai bersama grup varian}
|
|
223
235
|
- name: expiry_warning_not_negative
|
|
224
236
|
on: save
|
|
225
237
|
check: expiry_warning_days >= 0
|
|
@@ -126,6 +126,15 @@ fields:
|
|
|
126
126
|
label: {id: Modal kas kasir}
|
|
127
127
|
help: {id: 'Uang kembalian di laci tiap sesi kasir dibuka. Kosongkan kalau kasir yang mengisi'}
|
|
128
128
|
depends_on: app_installed('pos') && (location_type == '' || location_type == 'store' || location_type == 'vehicle')
|
|
129
|
+
# module whatsapp_order: the store that takes the orders customers write on WhatsApp (their drafts get this outlet,
|
|
130
|
+
# so its cashiers see and confirm them). With none ticked, a business with one store uses it; with several and none
|
|
131
|
+
# ticked, head office sets the outlet on each order.
|
|
132
|
+
- name: wa_orders
|
|
133
|
+
type: check
|
|
134
|
+
label: {id: Terima pesanan WhatsApp}
|
|
135
|
+
help: {id: 'Pesanan yang ditulis pelanggan di WhatsApp masuk ke outlet ini'}
|
|
136
|
+
default: 'false'
|
|
137
|
+
depends_on: app_installed('whatsapp_order') && (location_type == '' || location_type == 'store')
|
|
129
138
|
# module attendance (staff clock-in per outlet): the outlet's point and radius are the geofence of the clock screen
|
|
130
139
|
# (screens/absen_outlet.rk), and the default hours are the schedule lateness is measured against when the employee has
|
|
131
140
|
# no shift. Decimal degrees, as a phone's GPS or a map gives them (Bandung is about -6.9, 107.6).
|
|
@@ -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: outlets
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.8.0
|
|
4
4
|
title: {id: Outlet dan gudang, en: Outlets and warehouses}
|
|
5
5
|
summary:
|
|
6
6
|
id: Daftar cabang, gudang, dan lokasi stok usaha kamu.
|
|
@@ -10,6 +10,7 @@ fields:
|
|
|
10
10
|
# the item's category when the line was saved: the kitchen routes a paid line by it (module kitchen) without reading
|
|
11
11
|
# the whole catalogue during the payment
|
|
12
12
|
- {name: category, type: link, to: item_category, label: {id: Kategori}, hidden: true, compute: item.category}
|
|
13
|
+
- {name: variant_group, type: data, label: {id: Grup varian}, hidden: true, compute: item.variant_group}
|
|
13
14
|
- {name: description, type: text, label: {id: Uraian}, default: item.item_name}
|
|
14
15
|
- name: packing
|
|
15
16
|
type: link
|
|
@@ -15,7 +15,7 @@ title_field: description
|
|
|
15
15
|
# Paying it back (pay_with): cash or bank by finance (claim_payment), or with the next salary (payslip.reimbursement,
|
|
16
16
|
# untaxed). A submitted claim cannot change, so whether it was paid lives on its claim_settlement (made by
|
|
17
17
|
# claim_settlement_on_submit). A claim already paid cannot be cancelled (claim_cancel_guard): cancel the payment or the
|
|
18
|
-
# slip first.
|
|
18
|
+
# slip first. Zafdoz may suggest category and amount from the receipt into a draft; a person submits, an approver
|
|
19
19
|
# approves: money is never decided by an LLM.
|
|
20
20
|
permissions:
|
|
21
21
|
# Staff: their own claims only (permission if:, which also filters lists and dashboards). No cancel, no amend.
|
|
@@ -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}
|
|
@@ -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:
|
|
@@ -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]}
|
|
@@ -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}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# Staff confirm or turn down a WhatsApp order (state, one tap on the work screen pesanan_wa or the form). Runs inside
|
|
3
|
+
# that write, as the person (writes by flows start no flow, so the intake's appends are not seen here). Allowed moves:
|
|
4
|
+
# new -> confirmed, new -> rejected, rejected -> new; a confirmed order is final (its sale is voided at the kasir like
|
|
5
|
+
# any sale). The model's rules have already refused a confirm with no item line or an open choice.
|
|
6
|
+
# Confirm:
|
|
7
|
+
# 1. The customer: the order's link, else the customer with this WhatsApp number, else a new customer with the name on
|
|
8
|
+
# the order (free text the staff could correct) and the number.
|
|
9
|
+
# 2. The order the business works with: a draft pos_sale (module pos) on the confirming person's open shift (at the
|
|
10
|
+
# order's outlet when it has one); head office or the owner without a shift of their own use an open shift of that
|
|
11
|
+
# outlet. The sale prices its lines from the item (and its promos), so paying it at the counter is a sale like any
|
|
12
|
+
# other: stock, receipt (with module whatsapp_receipt the WhatsApp receipt and the order-ready message too) and
|
|
13
|
+
# reports. The buyer is "<name> (WAO-…)" so the counter shows where it came from. An order without an outlet is
|
|
14
|
+
# confirmed only on one's own shift (its outlet is then written on the order); otherwise refused (no_outlet).
|
|
15
|
+
# The reply lists the items up to 120 characters (Meta's 512-byte parameter limit, any script), else "N jenis barang". Without module pos: refused
|
|
16
|
+
# (no_target; a customer_order path for businesses without a kasir is a later step). No open shift: refused
|
|
17
|
+
# (no_shift), nothing kept.
|
|
18
|
+
# 3. The reply: one whatsapp_message (key <order>:order_reply:1) and the template pesanan_diterima through Rangka Cloud,
|
|
19
|
+
# with the items and the document's total; skipped for a number on the opt-out list. A template may go out in and
|
|
20
|
+
# outside Meta's 24-hour window (module doc), so no free text is ever sent.
|
|
21
|
+
name: whatsapp_order_on_update
|
|
22
|
+
label: {id: 'Pesanan WhatsApp dikonfirmasi: buat transaksi dan balas pelanggan'}
|
|
23
|
+
description: {id: 'Saat staf mengonfirmasi pesanan WhatsApp, pelanggan baru dicatat, draf transaksi kasir (atau pesanan pelanggan) dibuat dengan harga dari data barang, lalu pelanggan dibalas rincian dan totalnya lewat WhatsApp.'}
|
|
24
|
+
on: whatsapp_order.updated
|
|
25
|
+
if: event.before != null && event.before.state != event.state
|
|
26
|
+
steps:
|
|
27
|
+
- create: whatsapp_order_guard
|
|
28
|
+
if: "!((event.before.state + '>' + event.state) in ['new>confirmed', 'new>rejected', 'rejected>new'])"
|
|
29
|
+
set: {reason: "'bad_step'", document: event.name}
|
|
30
|
+
- create: whatsapp_order_guard
|
|
31
|
+
if: "event.state == 'confirmed' && !app_installed('pos')"
|
|
32
|
+
set: {reason: "'no_target'", document: event.name}
|
|
33
|
+
# 1. the customer
|
|
34
|
+
- find: customer
|
|
35
|
+
if: event.state == 'confirmed' && event.customer == ''
|
|
36
|
+
where: "event.wa_number != '' && wa_number == event.wa_number"
|
|
37
|
+
as: known
|
|
38
|
+
- create: customer
|
|
39
|
+
if: event.state == 'confirmed' && event.customer == '' && known == null
|
|
40
|
+
set:
|
|
41
|
+
customer_name: event.customer_name.trim()
|
|
42
|
+
phone: event.phone
|
|
43
|
+
as: added
|
|
44
|
+
# 2. the cashier's draft sale: an open shift of the confirming person, else, for head office or the owner, an open
|
|
45
|
+
# shift of the order's outlet
|
|
46
|
+
- find: pos_shift
|
|
47
|
+
if: event.state == 'confirmed' && app_installed('pos')
|
|
48
|
+
where: "cashier == user.email && state == 'open' && (event.outlet == '' || outlet == event.outlet)"
|
|
49
|
+
as: own
|
|
50
|
+
- find_all: pos_shift
|
|
51
|
+
if: event.state == 'confirmed' && app_installed('pos')
|
|
52
|
+
where: "event.outlet != '' && state == 'open' && outlet == event.outlet"
|
|
53
|
+
sort: -opening_date
|
|
54
|
+
limit: 1
|
|
55
|
+
as: open_shifts
|
|
56
|
+
- create: whatsapp_order_guard
|
|
57
|
+
if: >-
|
|
58
|
+
event.state == 'confirmed' && app_installed('pos') && own == null
|
|
59
|
+
&& event.outlet != '' && (open_shifts.size() == 0 || !('head_office' in user.roles || 'owner' in user.roles))
|
|
60
|
+
set: {reason: "'no_shift'", document: event.name}
|
|
61
|
+
# without an outlet and without a shift of one's own, the order's outlet must be chosen first (never the shift that
|
|
62
|
+
# happens to be open somewhere)
|
|
63
|
+
- create: whatsapp_order_guard
|
|
64
|
+
if: event.state == 'confirmed' && app_installed('pos') && own == null && event.outlet == ''
|
|
65
|
+
set: {reason: "'no_outlet'", document: event.name}
|
|
66
|
+
- create: pos_sale
|
|
67
|
+
if: event.state == 'confirmed' && app_installed('pos')
|
|
68
|
+
set:
|
|
69
|
+
shift: "own != null ? own.name : open_shifts[0].name"
|
|
70
|
+
buyer: "truncate(event.customer_name.trim(), 100) + ' (' + event.name + ')'"
|
|
71
|
+
customer: "event.customer != '' ? event.customer : (known != null ? known.name : added.name)"
|
|
72
|
+
items: >-
|
|
73
|
+
event.lines.filter(l, l.item != '').map(l, {'item': l.item, 'qty': l.qty, 'packing': '', 'discount_pct': 0,
|
|
74
|
+
'note': l.note, 'is_gift': false})
|
|
75
|
+
wa_phone: "app_installed('whatsapp_receipt') ? event.phone : ''"
|
|
76
|
+
wa_receipt: "app_installed('whatsapp_receipt') && event.phone != ''"
|
|
77
|
+
as: sale
|
|
78
|
+
# 3. the reply, with the sale's total (its promos applied)
|
|
79
|
+
- {find: whatsapp_message, if: "event.state == 'confirmed'", where: "key == event.name + ':order_reply:1'", as: done}
|
|
80
|
+
- {find: whatsapp_opt_out, if: "event.state == 'confirmed'", where: number == event.wa_number, as: out}
|
|
81
|
+
- {find: outlet, if: "event.state == 'confirmed' && app_installed('pos')", where: name == sale.outlet, as: o}
|
|
82
|
+
- create: whatsapp_message
|
|
83
|
+
if: event.state == 'confirmed' && app_installed('pos') && done == null && event.wa_number != ''
|
|
84
|
+
set:
|
|
85
|
+
key: event.name + ':order_reply:1'
|
|
86
|
+
message_type: "'order_reply'"
|
|
87
|
+
template: "'pesanan_diterima'"
|
|
88
|
+
document: event.name
|
|
89
|
+
customer: "event.customer != '' ? event.customer : (known != null ? known.name : added.name)"
|
|
90
|
+
number_tail: "'…' + event.wa_number.replace(truncate(event.wa_number, size(event.wa_number) - 4), '')"
|
|
91
|
+
amount: sale.grand_total
|
|
92
|
+
status: "out != null ? 'skipped' : 'queued'"
|
|
93
|
+
error: "out != null ? 'opted_out' : ''"
|
|
94
|
+
status_at: now()
|
|
95
|
+
as: msg
|
|
96
|
+
- call: rangka_whatsapp.send_template
|
|
97
|
+
if: event.state == 'confirmed' && app_installed('pos') && done == null && event.wa_number != '' && out == null
|
|
98
|
+
with:
|
|
99
|
+
to: "'+' + event.wa_number"
|
|
100
|
+
template: "'pesanan_diterima'"
|
|
101
|
+
type: "'order_reply'"
|
|
102
|
+
idempotency_key: event.name + ':order_reply:1'
|
|
103
|
+
components: >-
|
|
104
|
+
[{'type': 'body', 'parameters': [
|
|
105
|
+
{'type': 'text', 'text': truncate(event.customer_name.trim(), 60)},
|
|
106
|
+
{'type': 'text', 'text': event.name},
|
|
107
|
+
{'type': 'text', 'text': o != null ? o.outlet_name : org.legal_name},
|
|
108
|
+
{'type': 'text', 'text': size(event.summary) <= 120 ? event.summary : string(event.item_lines) + ' jenis barang'},
|
|
109
|
+
{'type': 'text', 'text': msg.amount_text}]}]
|
|
110
|
+
- {find: whatsapp_order, if: "event.state == 'confirmed'", where: name == event.name, as: me}
|
|
111
|
+
- update: me
|
|
112
|
+
if: event.state == 'confirmed'
|
|
113
|
+
set:
|
|
114
|
+
customer: "event.customer != '' ? event.customer : (known != null ? known.name : added.name)"
|
|
115
|
+
confirmed_by: user.name
|
|
116
|
+
confirmed_at: now()
|
|
117
|
+
confirmed_date: today()
|
|
118
|
+
- update: me
|
|
119
|
+
if: event.state == 'confirmed' && app_installed('pos')
|
|
120
|
+
set:
|
|
121
|
+
sale: sale.name
|
|
122
|
+
outlet: "app_installed('outlets') ? sale.outlet : ''"
|
|
123
|
+
reply_total: "done == null && event.wa_number != '' ? msg.amount : 0"
|
|
124
|
+
reply: "done == null && event.wa_number != '' ? msg.name : ''"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# One message a customer wrote to the business's WhatsApp number, kept once by Meta's message id (unique; the flow's
|
|
3
|
+
# idempotency key is the same id, so a webhook delivered twice makes one row and one draft). Written by flow
|
|
4
|
+
# whatsapp_order_intake only. It says what the message did: started an order, added to one, or was no order. A later
|
|
5
|
+
# shared inbox (rangka-apps#130) can read these rows instead of keeping its own copy.
|
|
6
|
+
name: whatsapp_inbound
|
|
7
|
+
label: {id: Pesan WhatsApp masuk, en: Incoming WhatsApp message}
|
|
8
|
+
icon: chat-download-line
|
|
9
|
+
naming: WAIN-{YY}{MM}-{######}
|
|
10
|
+
title_field: sender
|
|
11
|
+
permissions:
|
|
12
|
+
- {role: head_office, read: true, export: true}
|
|
13
|
+
- {role: sales_manager, read: true}
|
|
14
|
+
- {role: cashier, read: true}
|
|
15
|
+
fields:
|
|
16
|
+
- {name: message_id, type: data, label: {id: ID pesan WhatsApp}, required: true, unique: true, read_only: true, hidden: true}
|
|
17
|
+
# where the order came from: the text a customer wrote (Rangka Cloud reads it into lines); whatsapp_cart (a WhatsApp
|
|
18
|
+
# catalogue cart with product references) is the next source, fed into the same matching (module doc "Next: A1b")
|
|
19
|
+
- name: source
|
|
20
|
+
type: select
|
|
21
|
+
label: {id: Sumber}
|
|
22
|
+
default: "'whatsapp_text'"
|
|
23
|
+
read_only: true
|
|
24
|
+
in_filter: true
|
|
25
|
+
options:
|
|
26
|
+
- {value: whatsapp_text, label: {id: Chat WhatsApp}}
|
|
27
|
+
- {value: whatsapp_cart, label: {id: Keranjang katalog WhatsApp}}
|
|
28
|
+
# Meta's message type (text, image, order, …): the raw text is kept in `text` for audit
|
|
29
|
+
- {name: kind, type: data, label: {id: Jenis pesan}, read_only: true}
|
|
30
|
+
- {name: sender, type: data, label: {id: Pengirim}, read_only: true, in_list: true}
|
|
31
|
+
- {name: phone, type: phone, label: {id: Nomor WhatsApp}, read_only: true}
|
|
32
|
+
- {name: wa_number, type: data, label: {id: Nomor WhatsApp (seragam)}, read_only: true, hidden: true, index: true}
|
|
33
|
+
- {name: text, type: text, label: {id: Isi pesan}, read_only: true}
|
|
34
|
+
- {name: received_at, type: datetime, label: {id: Diterima}, read_only: true, in_list: true}
|
|
35
|
+
- name: result
|
|
36
|
+
type: select
|
|
37
|
+
label: {id: Hasil}
|
|
38
|
+
read_only: true
|
|
39
|
+
in_list: true
|
|
40
|
+
in_filter: true
|
|
41
|
+
chip: true
|
|
42
|
+
options:
|
|
43
|
+
- {value: order_new, label: {id: Pesanan baru}}
|
|
44
|
+
- {value: order_added, label: {id: Ditambahkan ke pesanan}}
|
|
45
|
+
- {value: order_full, label: {id: 'Tidak ditambahkan, pesanan sudah 60 baris'}}
|
|
46
|
+
- {value: not_order, label: {id: Bukan pesanan}}
|
|
47
|
+
- {name: order, type: link, to: whatsapp_order, label: {id: Pesanan WhatsApp}, read_only: true, in_list: true}
|
|
48
|
+
# the lines Rangka Cloud read in this message, matched against the items (flow whatsapp_order_intake): the order
|
|
49
|
+
# copies them, and they stay here as what this one message said
|
|
50
|
+
- {name: lines, type: table, of: whatsapp_order_line, label: {id: Baris terbaca}, read_only: true}
|
|
51
|
+
# how many lines were read and how many of them matched an item (or are a choice)
|
|
52
|
+
# more items for sale than the intake reads (5000): a line's single candidate may not be the only one, so the order
|
|
53
|
+
# waits for a look ("Perlu dicek")
|
|
54
|
+
- {name: catalogue_capped, type: check, label: {id: Katalog terlalu besar untuk dicocokkan penuh}, read_only: true, default: 'false'}
|
|
55
|
+
- {name: lines_read, type: int, label: {id: Baris terbaca}, read_only: true, default: '0'}
|
|
56
|
+
- {name: lines_matched, type: int, label: {id: Baris cocok dengan barang}, read_only: true, default: '0'}
|
|
57
|
+
# the outlet scopes the rows for the cashier (role scope outlet), the same outlet as the order's
|
|
58
|
+
- {name: outlet, type: link, to: outlet, label: {id: Outlet}, read_only: true, depends_on: app_installed('outlets')}
|
|
59
|
+
views:
|
|
60
|
+
list:
|
|
61
|
+
columns: [name, sender, received_at, result, order]
|
|
62
|
+
sort: -received_at
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# An order a customer wrote on WhatsApp, as a draft until a person confirms it (module doc). Made and added to by flow
|
|
3
|
+
# whatsapp_order_intake; confirmed or turned down by staff (state, on the work screen pesanan_wa or the form). Confirm
|
|
4
|
+
# runs flow whatsapp_order_on_update in the same write: the customer, the cashier's draft sale, and the reply. A confirmed order is final here (its sale is voided at the kasir like any sale); a turned-down
|
|
5
|
+
# one may be opened again.
|
|
6
|
+
# The total is an estimate from the items' rates; the reply carries the total of the document confirm makes (a promo
|
|
7
|
+
# at the kasir may lower it).
|
|
8
|
+
name: whatsapp_order
|
|
9
|
+
label: {id: Pesanan WhatsApp, en: WhatsApp order}
|
|
10
|
+
icon: chat-check-line
|
|
11
|
+
naming: WAO-{YY}{MM}-{#####}
|
|
12
|
+
title_field: customer_name
|
|
13
|
+
permissions:
|
|
14
|
+
- {role: head_office, read: true, write: true, export: true}
|
|
15
|
+
- {role: sales_manager, read: true, write: true, export: true}
|
|
16
|
+
- {role: cashier, read: true, write: true}
|
|
17
|
+
fields:
|
|
18
|
+
- name: state
|
|
19
|
+
type: select
|
|
20
|
+
label: {id: Status}
|
|
21
|
+
default: "'new'"
|
|
22
|
+
in_list: true
|
|
23
|
+
in_filter: true
|
|
24
|
+
chip: true
|
|
25
|
+
options:
|
|
26
|
+
- {value: new, label: {id: Baru}}
|
|
27
|
+
- {value: confirmed, label: {id: Dikonfirmasi}}
|
|
28
|
+
- {value: rejected, label: {id: Ditolak}}
|
|
29
|
+
# where the card sits on the work screen: needs a look (a choice or an unknown line), ready, or done
|
|
30
|
+
- name: stage
|
|
31
|
+
type: select
|
|
32
|
+
label: {id: Tahap}
|
|
33
|
+
in_filter: true
|
|
34
|
+
compute: "state == 'confirmed' ? 'confirmed' : (state == 'rejected' ? 'rejected' : (open_choices > 0 || item_lines == 0 || unknown_lines > 0 || price_diffs > 0 || catalogue_capped ? 'check' : 'ready'))"
|
|
35
|
+
options:
|
|
36
|
+
- {value: check, label: {id: Perlu dicek}}
|
|
37
|
+
- {value: ready, label: {id: Siap dikonfirmasi}}
|
|
38
|
+
- {value: confirmed, label: {id: Dikonfirmasi}}
|
|
39
|
+
- {value: rejected, label: {id: Ditolak}}
|
|
40
|
+
# where the order came from: the text a customer wrote (Rangka Cloud reads it into lines); whatsapp_cart (a WhatsApp
|
|
41
|
+
# catalogue cart with product references) is the next source, fed into the same matching (module doc "Next: A1b")
|
|
42
|
+
- name: source
|
|
43
|
+
type: select
|
|
44
|
+
label: {id: Sumber}
|
|
45
|
+
default: "'whatsapp_text'"
|
|
46
|
+
read_only: true
|
|
47
|
+
in_filter: true
|
|
48
|
+
options:
|
|
49
|
+
- {value: whatsapp_text, label: {id: Chat WhatsApp}}
|
|
50
|
+
- {value: whatsapp_cart, label: {id: Keranjang katalog WhatsApp}}
|
|
51
|
+
# free text: the WhatsApp profile name of a new number, which staff may correct; a known customer's name otherwise
|
|
52
|
+
- {name: customer_name, type: data, label: {id: Nama pelanggan}, required: true, in_list: true}
|
|
53
|
+
- name: customer
|
|
54
|
+
type: link
|
|
55
|
+
to: customer
|
|
56
|
+
label: {id: Pelanggan}
|
|
57
|
+
help: {id: 'Kosong kalau nomor ini belum terdaftar. Pelanggan baru dibuat saat pesanan dikonfirmasi'}
|
|
58
|
+
- {name: phone, type: phone, label: {id: Nomor WhatsApp}, read_only: true}
|
|
59
|
+
- {name: wa_number, type: data, label: {id: Nomor WhatsApp (seragam)}, read_only: true, hidden: true, index: true}
|
|
60
|
+
- name: outlet
|
|
61
|
+
type: link
|
|
62
|
+
to: outlet
|
|
63
|
+
label: {id: Outlet}
|
|
64
|
+
help: {id: 'Outlet yang menyiapkan pesanan. Terisi sendiri kalau usaha punya satu toko'}
|
|
65
|
+
depends_on: app_installed('outlets')
|
|
66
|
+
- {name: lines, type: table, of: whatsapp_order_line, label: {id: Pesanan}}
|
|
67
|
+
# pick-up, delivery or time remarks from the customer's messages, and the text of lines no item matched
|
|
68
|
+
- {name: notes, type: text, label: {id: Catatan pelanggan}}
|
|
69
|
+
# more items for sale than the intake reads (5000): a line's single candidate may not be the only one, so the order
|
|
70
|
+
# waits for a look ("Perlu dicek")
|
|
71
|
+
- {name: catalogue_capped, type: check, label: {id: Katalog terlalu besar untuk dicocokkan penuh}, read_only: true, default: 'false'}
|
|
72
|
+
- {name: line_count, type: int, label: {id: Jumlah baris}, hidden: true, compute: lines.size()}
|
|
73
|
+
- {name: big_qty_lines, type: int, label: {id: Baris jumlah besar}, hidden: true, compute: "lines.map(l, l.qty > 999 ? 1 : 0).sum()"}
|
|
74
|
+
- {name: item_lines, type: int, label: {id: Baris barang}, hidden: true, compute: "lines.map(l, l.item != '' ? 1 : 0).sum()"}
|
|
75
|
+
- {name: unknown_lines, type: int, label: {id: Baris tidak dikenali}, hidden: true, compute: "lines.map(l, l.item == '' && l.match != 'pilih' ? 1 : 0).sum()"}
|
|
76
|
+
- {name: open_choices, type: int, label: {id: Baris perlu dipilih}, hidden: true, compute: "lines.map(l, l.item == '' && l.match == 'pilih' ? 1 : 0).sum()"}
|
|
77
|
+
- {name: price_diffs, type: int, label: {id: Baris beda harga}, hidden: true, compute: "lines.map(l, l.item != '' && l.quoted_rate > 0 && l.quoted_rate != l.rate ? 1 : 0).sum()"}
|
|
78
|
+
# "2 Kopi Susu, 1 Roti Bakar Coklat": the lines with an item, as the reply writes them
|
|
79
|
+
- name: summary
|
|
80
|
+
type: data
|
|
81
|
+
label: {id: Isi pesanan}
|
|
82
|
+
compute: "lines.filter(l, l.item != '').map(l, string(l.qty) + ' ' + l.item_name).join(', ')"
|
|
83
|
+
- name: check_note
|
|
84
|
+
type: data
|
|
85
|
+
label: {id: Yang perlu dicek}
|
|
86
|
+
compute: >-
|
|
87
|
+
state != 'new' ? '' :
|
|
88
|
+
item_lines == 0 && open_choices == 0 ? 'Belum ada barang yang cocok' :
|
|
89
|
+
(open_choices > 0 ? string(open_choices) + ' baris perlu dipilih' : '') +
|
|
90
|
+
(open_choices > 0 && unknown_lines > 0 ? ', ' : '') +
|
|
91
|
+
(unknown_lines > 0 ? string(unknown_lines) + ' baris tidak dikenali' : '') +
|
|
92
|
+
((open_choices > 0 || unknown_lines > 0) && price_diffs > 0 ? ', ' : '') +
|
|
93
|
+
(price_diffs > 0 ? string(price_diffs) + ' baris beda harga' : '') +
|
|
94
|
+
(catalogue_capped ? (open_choices > 0 || unknown_lines > 0 || price_diffs > 0 ? ', ' : '') + 'katalog besar, cek barangnya' : '')
|
|
95
|
+
- {name: total, type: currency, label: {id: Perkiraan total}, help: {id: 'Dari harga barang. Total akhir mengikuti transaksinya'}, compute: "lines.map(l, l.amount).sum()", in_list: true}
|
|
96
|
+
# "Rp 66.000" for the work screen's card (a card prints numbers raw); the same cut as whatsapp_message.amount_text
|
|
97
|
+
- name: total_text
|
|
98
|
+
type: data
|
|
99
|
+
label: {id: Perkiraan total (teks)}
|
|
100
|
+
hidden: true
|
|
101
|
+
compute: >-
|
|
102
|
+
'Rp ' + (int(total) < 1000 ? string(int(total)) :
|
|
103
|
+
int(total) < 1000000 ? string(int(total) / 1000) + '.' + ('x' + string(1000 + int(total) - (int(total) / 1000) * 1000)).replace('x1', '') :
|
|
104
|
+
int(total) < 1000000000 ? string(int(total) / 1000000) + '.' + ('x' + string(1000 + int(total) / 1000 - (int(total) / 1000000) * 1000)).replace('x1', '') + '.' + ('x' + string(1000 + int(total) - (int(total) / 1000) * 1000)).replace('x1', '') :
|
|
105
|
+
string(int(total) / 1000000000) + '.' + ('x' + string(1000 + int(total) / 1000000 - (int(total) / 1000000000) * 1000)).replace('x1', '') + '.' + ('x' + string(1000 + int(total) / 1000 - (int(total) / 1000000) * 1000)).replace('x1', '') + '.' + ('x' + string(1000 + int(total) - (int(total) / 1000) * 1000)).replace('x1', ''))
|
|
106
|
+
- {name: messages, type: int, label: {id: Jumlah pesan}, read_only: true, default: '0'}
|
|
107
|
+
- {name: first_message_at, type: datetime, label: {id: Pesan pertama}, read_only: true}
|
|
108
|
+
- {name: last_message_at, type: datetime, label: {id: Pesan terakhir}, read_only: true}
|
|
109
|
+
# Unix seconds of the last message: the 30-minute window of flow whatsapp_order_intake
|
|
110
|
+
- {name: last_epoch, type: int, label: {id: Pesan terakhir (detik)}, read_only: true, hidden: true, default: '0'}
|
|
111
|
+
- {name: confirmed_by, type: data, label: {id: Dikonfirmasi oleh}, read_only: true}
|
|
112
|
+
- {name: confirmed_at, type: datetime, label: {id: Dikonfirmasi}, read_only: true}
|
|
113
|
+
# the site's date of the confirm (today() is the site timezone; confirmed_at is UTC), for lists and reports
|
|
114
|
+
- {name: confirmed_date, type: date, label: {id: Tanggal dikonfirmasi}, read_only: true, hidden: true}
|
|
115
|
+
- {name: sale, type: link, to: pos_sale, label: {id: Transaksi kasir}, read_only: true, depends_on: app_installed('pos')}
|
|
116
|
+
# the total the reply told the customer (the sale's)
|
|
117
|
+
- {name: reply_total, type: currency, label: {id: Total di balasan}, read_only: true, default: '0'}
|
|
118
|
+
- {name: reply, type: link, to: whatsapp_message, label: {id: Balasan WhatsApp}, read_only: true}
|
|
119
|
+
rules:
|
|
120
|
+
- name: confirm_has_items
|
|
121
|
+
on: save
|
|
122
|
+
check: "state != 'confirmed' || item_lines > 0"
|
|
123
|
+
message: {id: 'Belum ada barang di pesanan ini. Pilih barangnya di baris pesanan dulu'}
|
|
124
|
+
- name: confirm_choices_made
|
|
125
|
+
on: save
|
|
126
|
+
check: "state != 'confirmed' || open_choices == 0"
|
|
127
|
+
message: {id: 'Ada baris yang perlu dipilih barangnya (misalnya ukuran). Pilih dulu, lalu konfirmasi'}
|
|
128
|
+
- name: qty_positive
|
|
129
|
+
on: save
|
|
130
|
+
check: "lines.map(l, l.qty <= 0 ? 1 : 0).sum() == 0"
|
|
131
|
+
message: {id: Jumlah barang harus lebih dari 0}
|
|
132
|
+
- name: qty_sane
|
|
133
|
+
on: save
|
|
134
|
+
check: "state != 'confirmed' || big_qty_lines == 0"
|
|
135
|
+
message: {id: 'Ada baris dengan jumlah lebih dari 999. Cek lagi jumlahnya sebelum konfirmasi'}
|
|
136
|
+
- name: lines_limit
|
|
137
|
+
on: save
|
|
138
|
+
check: "line_count <= 60"
|
|
139
|
+
message: {id: 'Satu pesanan paling banyak 60 baris'}
|
|
140
|
+
- name: name_given
|
|
141
|
+
on: save
|
|
142
|
+
check: "customer_name.trim() != ''"
|
|
143
|
+
message: {id: Isi nama pelanggan}
|
|
144
|
+
views:
|
|
145
|
+
list:
|
|
146
|
+
columns: [name, customer_name, state, summary, total]
|
|
147
|
+
sort: -first_message_at
|
|
148
|
+
form:
|
|
149
|
+
layout:
|
|
150
|
+
- section: {id: Pesanan}
|
|
151
|
+
columns:
|
|
152
|
+
- [state, customer_name, customer, phone]
|
|
153
|
+
- [outlet, check_note, total]
|
|
154
|
+
- section: {id: Isi pesanan}
|
|
155
|
+
fields: [lines]
|
|
156
|
+
- section: {id: Catatan pelanggan}
|
|
157
|
+
fields: [notes]
|
|
158
|
+
- section: {id: Setelah dikonfirmasi}
|
|
159
|
+
columns:
|
|
160
|
+
- [sale, reply_total]
|
|
161
|
+
- [confirmed_by, confirmed_at, reply]
|
|
162
|
+
- section: {id: Pesan masuk}
|
|
163
|
+
columns:
|
|
164
|
+
- [messages, first_message_at, last_message_at]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# Never stored: flow whatsapp_order_on_update creates one when the confirm it runs in must be refused (the pattern of
|
|
3
|
+
# appointment_guard and rental_guard); the matching rule fails with the reason's message and rolls the whole write
|
|
4
|
+
# back, so a refused confirm leaves no customer, sale or reply behind. Create is granted to every role that confirms.
|
|
5
|
+
name: whatsapp_order_guard
|
|
6
|
+
label: {id: Penjaga pesanan WhatsApp, en: WhatsApp order guard}
|
|
7
|
+
icon: check
|
|
8
|
+
naming: WAOG-{######}
|
|
9
|
+
title_field: reason
|
|
10
|
+
permissions:
|
|
11
|
+
- {role: head_office, create: true}
|
|
12
|
+
- {role: sales_manager, create: true}
|
|
13
|
+
- {role: cashier, create: true}
|
|
14
|
+
fields:
|
|
15
|
+
- name: reason
|
|
16
|
+
type: select
|
|
17
|
+
label: {id: Alasan}
|
|
18
|
+
required: true
|
|
19
|
+
options:
|
|
20
|
+
- {value: bad_step, label: {id: Langkah status tidak boleh}}
|
|
21
|
+
- {value: no_shift, label: {id: Belum ada sesi kasir}}
|
|
22
|
+
- {value: no_target, label: {id: Kasir belum dipasang}}
|
|
23
|
+
- {value: no_outlet, label: {id: Outlet pesanan belum dipilih}}
|
|
24
|
+
- {value: locked, label: {id: Pesanan sudah dikonfirmasi}}
|
|
25
|
+
- {name: document, type: data, label: {id: Dokumen}}
|
|
26
|
+
rules:
|
|
27
|
+
- name: bad_step
|
|
28
|
+
on: save
|
|
29
|
+
check: reason != 'bad_step'
|
|
30
|
+
message: {id: 'Pesanan yang sudah dikonfirmasi tidak bisa diubah statusnya. Batalkan transaksinya di kasir kalau perlu'}
|
|
31
|
+
- name: no_shift
|
|
32
|
+
on: save
|
|
33
|
+
check: reason != 'no_shift'
|
|
34
|
+
message: {id: 'Buka sesi kasir dulu di outlet pesanan ini, lalu konfirmasi lagi'}
|
|
35
|
+
- name: no_target
|
|
36
|
+
on: save
|
|
37
|
+
check: reason != 'no_target'
|
|
38
|
+
message: {id: 'Pasang Kasir dulu supaya pesanan WhatsApp bisa dikonfirmasi'}
|
|
39
|
+
- name: no_outlet
|
|
40
|
+
on: save
|
|
41
|
+
check: reason != 'no_outlet'
|
|
42
|
+
message: {id: 'Pilih outlet pesanan ini dulu, lalu konfirmasi lagi'}
|
|
43
|
+
- name: locked
|
|
44
|
+
on: save
|
|
45
|
+
check: reason != 'locked'
|
|
46
|
+
message: {id: 'Pesanan yang sudah dikonfirmasi tidak bisa diubah. Ubah transaksinya di kasir kalau perlu'}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# One line of a WhatsApp order: what the customer wrote, and the item it was matched to (flow whatsapp_order_intake).
|
|
3
|
+
# The price is the item's own rate, computed here, never a number from the text. A line without an item is a note:
|
|
4
|
+
# kept and flagged (match tak_dikenal), or a choice the staff make (match pilih: the candidates in choices). Staff may
|
|
5
|
+
# pick or change the item on any line before confirming; a line still without an item is left out of the order.
|
|
6
|
+
name: whatsapp_order_line
|
|
7
|
+
is_child: true
|
|
8
|
+
fields:
|
|
9
|
+
- {name: text, type: data, label: {id: Tulisan pelanggan}, read_only: true}
|
|
10
|
+
- name: item
|
|
11
|
+
type: link
|
|
12
|
+
to: item
|
|
13
|
+
label: {id: Barang/layanan}
|
|
14
|
+
- {name: qty, type: int, label: {id: Qty}, default: '1'}
|
|
15
|
+
# what staff must look at, in words; empty when the line is plain
|
|
16
|
+
- name: flag
|
|
17
|
+
type: data
|
|
18
|
+
label: {id: Perlu dicek}
|
|
19
|
+
compute: >-
|
|
20
|
+
item == '' && match == 'pilih' ? 'Pilih salah satu: ' + choices :
|
|
21
|
+
item == '' ? 'Tidak dikenali, jadi catatan: ' + text :
|
|
22
|
+
match == 'ejaan' ? 'Dibaca dari "' + text + '"' :
|
|
23
|
+
quoted_rate > 0 && quoted_rate != rate ? 'Harga di pesan beda dengan harga barang; dipakai harga barang' : ''
|
|
24
|
+
- {name: note, type: data, label: {id: Catatan}}
|
|
25
|
+
- {name: amount, type: currency, label: {id: Jumlah}, compute: round(qty * rate)}
|
|
26
|
+
- {name: rate, type: currency, label: {id: Harga}, compute: "item != '' ? item.rate : 0"}
|
|
27
|
+
# a price the message itself carried (a catalogue cart does): kept only to compare, never charged
|
|
28
|
+
- {name: quoted_rate, type: currency, label: {id: Harga di pesan}, read_only: true, hidden: true, default: '0'}
|
|
29
|
+
- name: match
|
|
30
|
+
type: select
|
|
31
|
+
label: {id: Cara dibaca}
|
|
32
|
+
read_only: true
|
|
33
|
+
hidden: true
|
|
34
|
+
default: "'staf'"
|
|
35
|
+
options:
|
|
36
|
+
- {value: sama, label: {id: Nama sama}}
|
|
37
|
+
- {value: sebagian, label: {id: Sebagian nama}}
|
|
38
|
+
- {value: ejaan, label: {id: Dari ejaan mirip}}
|
|
39
|
+
- {value: pilih, label: {id: Perlu dipilih}}
|
|
40
|
+
- {value: tak_dikenal, label: {id: Tidak dikenali}}
|
|
41
|
+
- {value: staf, label: {id: Diisi staf}}
|
|
42
|
+
# the candidates of an ambiguous line, "Es Kopi Susu Regular / Es Kopi Susu Large"
|
|
43
|
+
- {name: choices, type: data, label: {id: Pilihan}, read_only: true, hidden: true}
|
|
44
|
+
- {name: unit, type: data, label: {id: Satuan ditulis}, read_only: true, hidden: true}
|
|
45
|
+
- {name: item_name, type: data, label: {id: Nama barang}, hidden: true, compute: "item != '' ? item.item_name : ''"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
|
|
2
|
+
name: whatsapp_order
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
title: {id: Pesanan dari WhatsApp, en: WhatsApp orders}
|
|
5
|
+
summary:
|
|
6
|
+
id: Chat pesanan di WhatsApp jadi draf berharga dari data barangmu; staf konfirmasi sekali ketuk, pelanggan dibalas rincian dan totalnya.
|
|
7
|
+
en: WhatsApp chat orders become drafts priced from your items; staff confirm with one tap and the customer gets the items and total.
|
|
8
|
+
category: sales
|
|
9
|
+
icon: chat-check-line
|
|
10
|
+
# rangka-plans A1 (the landing's lead scene). A customer writes to the business's WhatsApp number, for example "pesan
|
|
11
|
+
# 2 kopi susu, 1 roti bakar coklat". Rangka Cloud reads the text into lines (qty, name, note) with its deterministic
|
|
12
|
+
# parser (rangka-cloud internal/whatsapp/orderparse; no catalogue, no LLM) and forwards them with the connector
|
|
13
|
+
# trigger rangka_whatsapp.message_received. This module:
|
|
14
|
+
# - keeps every message it hears once, by Meta's message id (whatsapp_inbound; the kernel's flow key and a unique
|
|
15
|
+
# field), which a later shared inbox (rangka-apps#130) can read;
|
|
16
|
+
# - matches each line against the business's own items in CEL (flow whatsapp_order_intake): the exact name, a name
|
|
17
|
+
# that holds the customer's words, the customer's words that hold a name (the rest becomes the line's note), then
|
|
18
|
+
# the spelling skeleton (vowels dropped, c/k alike, doubled letters as one) for a typo. One candidate fills the
|
|
19
|
+
# line; several are a choice the staff make; none leaves the line unknown, kept and flagged, never guessed. Prices
|
|
20
|
+
# are the item's rate, read by the line (whatsapp_order_line.rate), never a number from the text;
|
|
21
|
+
# - puts the lines on a draft whatsapp_order of that customer (state new), or on the one still open from the same
|
|
22
|
+
# number when the last message came at most 30 minutes before (a burst of messages is one order). A message with
|
|
23
|
+
# no order in it (Rangka Cloud's order_signal false and nothing matched) starts no draft;
|
|
24
|
+
# - links the customer by WhatsApp number (customer.wa_number); an unknown number keeps the WhatsApp profile name as
|
|
25
|
+
# free text the staff can edit, and the customer is created only on confirm;
|
|
26
|
+
# - gives the draft its outlet: the store ticked "Terima pesanan WhatsApp" (outlet.wa_orders, the first one when
|
|
27
|
+
# several are), else the business's only store, else none (head office sets it); cashiers see their outlets' orders.
|
|
28
|
+
# Confirm (state new -> confirmed, one tap on the work screen pesanan_wa, flow whatsapp_order_on_update) is a person's
|
|
29
|
+
# act: nothing becomes an order without it, and no flow here confirms. It creates the customer when needed, then the
|
|
30
|
+
# order the business already works with: a draft pos_sale on the confirming cashier's open shift (module pos: paying
|
|
31
|
+
# it at the counter takes the stock out, prints the receipt and counts in the reports like any sale; a business
|
|
32
|
+
# without a kasir, through customer_order, is a later step). The customer then gets the template pesanan_diterima
|
|
33
|
+
# (type order_reply) with the items and the sale's total, through Rangka Cloud's relay (opt-out list respected, sent
|
|
34
|
+
# once per key).
|
|
35
|
+
# Meta's 24-hour rule: free-form text is allowed only within 24 hours of the customer's last message, a template at
|
|
36
|
+
# any time. The reply is always a UTILITY template (inside the window Meta does not charge it), and the relay rebuilds
|
|
37
|
+
# every message from template parameters (rangka-cloud relay.go parse), so no free-form message can leave here at all.
|
|
38
|
+
# Free text is one source: reading a message into lines (Rangka Cloud) and matching lines into a priced draft (here)
|
|
39
|
+
# stay apart, so a catalogue cart (lines with a product sku and Meta's price, kept only to compare) takes the same path
|
|
40
|
+
# from matching to confirm. The draft records its source (README.md "Next: A1b").
|
|
41
|
+
requires: {rangka: '>=0.5', users: ^1.2, contacts: ^1.3, catalogue: ^1.3, whatsapp: ^1.1}
|
|
42
|
+
optional: {outlets: ^1.8, pos: ^1.3, whatsapp_receipt: ^1.0}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/screen.json
|
|
2
|
+
# Pesanan dari WhatsApp: the drafts the customers' messages made, in three columns. "Perlu dicek": a line to choose
|
|
3
|
+
# (two sizes of a drink: no button until staff open the order, Pesanan WhatsApp, and pick the item) or a line no item
|
|
4
|
+
# matched (shown on the card as a note, the order can still be confirmed). "Siap dikonfirmasi": every line has its
|
|
5
|
+
# item. One tap on Konfirmasi confirms (flow whatsapp_order_on_update: the cashier's draft sale and the reply).
|
|
6
|
+
# A confirmed card leaves the screen (two columns fit a tablet beside the menu; a third was cut off): the order and its
|
|
7
|
+
# sale are in Pesanan WhatsApp (menu), and the sale is paid at the counter like any held basket. The renderer's
|
|
8
|
+
# "Urungkan" after Konfirmasi is refused (bad_step): a confirmed order made a sale and a reply.
|
|
9
|
+
name: pesanan_wa
|
|
10
|
+
type: queue
|
|
11
|
+
label: {id: Pesanan dari WhatsApp, en: WhatsApp orders}
|
|
12
|
+
description: {id: 'Pesanan yang ditulis pelanggan di WhatsApp. Cek isinya, lalu tekan Konfirmasi: transaksinya masuk ke kasir dan pelanggan dibalas totalnya.'}
|
|
13
|
+
icon: chat-check-line
|
|
14
|
+
roles: [cashier, head_office]
|
|
15
|
+
device: any
|
|
16
|
+
queue:
|
|
17
|
+
source: {model: whatsapp_order, filter: "state == 'new'", sort: first_message_at}
|
|
18
|
+
card: {title: customer_name, subtitle: check_note, lines: lines, line: [qty, item, note, flag], fields: [total_text], age_from: first_message_at}
|
|
19
|
+
columns: {by: stage, values: [check, ready]}
|
|
20
|
+
steps:
|
|
21
|
+
- {when: "state == 'new' && open_choices == 0 && item_lines > 0", set: {state: confirmed}, label: {id: Konfirmasi}}
|
|
22
|
+
refresh: 10
|