@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,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
|