@rangka-os/create 0.5.0-alpha.33 → 0.5.0-alpha.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/faktur_piutang/app.rk +4 -0
  3. package/template/base/apps/faktur_piutang/skills/rangka-app-faktur-piutang/SKILL.md +35 -0
  4. package/template/base/apps/fnb_cabang/app.rk +7 -0
  5. package/template/base/apps/fnb_cabang/skills/rangka-app-fnb-cabang/SKILL.md +43 -0
  6. package/template/base/apps/jasa_proyek/app.rk +11 -1
  7. package/template/base/apps/jasa_proyek/skills/rangka-app-jasa-proyek/SKILL.md +51 -0
  8. package/template/base/apps/karyawan_gaji/app.rk +2 -0
  9. package/template/base/apps/kasir/app.rk +2 -0
  10. package/template/base/apps/kasir/skills/rangka-app-kasir/SKILL.md +1 -1
  11. package/template/base/apps/pembelian_pemasok/app.rk +8 -0
  12. package/template/base/apps/pembelian_pemasok/skills/rangka-app-pembelian-pemasok/SKILL.md +43 -0
  13. package/template/base/apps/pesanan_whatsapp/app.rk +28 -0
  14. package/template/base/apps/ritel_cabang/app.rk +7 -0
  15. package/template/base/apps/ritel_cabang/dashboards/ritel_overview.rk +16 -0
  16. package/template/base/apps/ritel_cabang/dashboards/ritel_stock.rk +13 -0
  17. package/template/base/apps/ritel_cabang/skills/rangka-app-ritel-cabang/SKILL.md +43 -0
  18. package/template/base/apps/sewa_alat/skills/rangka-app-sewa-alat/SKILL.md +3 -3
  19. package/template/base/connectors/rangka_whatsapp/README.md +3 -2
  20. package/template/base/connectors/rangka_whatsapp/connector.rk +12 -4
  21. package/template/base/connectors/rangka_whatsapp/fixtures/expect.json +3 -2
  22. package/template/base/connectors/rangka_whatsapp/fixtures/message_received.json +1 -1
  23. package/template/base/connectors/rangka_whatsapp/fixtures/message_received_order.json +1 -0
  24. package/template/base/connectors/rangka_whatsapp/mock/rangka_whatsapp_mock.py +9 -4
  25. package/template/base/modules/accounting/flows/financial_report_compute.rk +1 -1
  26. package/template/base/modules/accounting/flows/financial_report_recompute.rk +1 -1
  27. package/template/base/modules/accounting/flows/gl_pos_sale_post.rk +38 -2
  28. package/template/base/modules/accounting/models/gl_entry.rk +3 -0
  29. package/template/base/modules/attendance/module.rk +4 -4
  30. package/template/base/modules/attendance/screens/absen_outlet.rk +3 -0
  31. package/template/base/modules/catalogue/defaults/uom.rk +19 -0
  32. package/template/base/modules/catalogue/models/item.rk +12 -0
  33. package/template/base/modules/kitchen/flows/kitchen_ticket_on_draft.rk +44 -0
  34. package/template/base/modules/kitchen/flows/kitchen_ticket_on_sale.rk +6 -5
  35. package/template/base/modules/loyalty/flows/loyalty_on_sale.rk +6 -5
  36. package/template/base/modules/loyalty/flows/loyalty_on_sale_cancel.rk +2 -2
  37. package/template/base/modules/outlet_sales/models/outlet_sales_line.rk +1 -0
  38. package/template/base/modules/outlets/models/outlet.rk +48 -0
  39. package/template/base/modules/outlets/module.rk +1 -1
  40. package/template/base/modules/payroll/flows/pph21_annual_on_slip_cancel.rk +28 -0
  41. package/template/base/modules/payroll/flows/pph21_annual_on_slip_submit.rk +84 -0
  42. package/template/base/modules/payroll/models/payslip.rk +4 -0
  43. package/template/base/modules/payroll/models/pph21_annual.rk +84 -0
  44. package/template/base/modules/payroll/models/pph21_period.rk +77 -0
  45. package/template/base/modules/payroll/module.rk +3 -2
  46. package/template/base/modules/payroll/print/bukti_potong_a1.html +53 -0
  47. package/template/base/modules/payroll/print/bukti_potong_a1.rk +9 -0
  48. package/template/base/modules/payroll/print/coretax_bp21.rk +44 -0
  49. package/template/base/modules/payroll/print/coretax_bp21.xml +36 -0
  50. package/template/base/modules/payroll/print/coretax_bpa1.rk +21 -0
  51. package/template/base/modules/payroll/print/coretax_bpa1.xml +46 -0
  52. package/template/base/modules/payroll/print/coretax_bpmp.rk +23 -0
  53. package/template/base/modules/payroll/print/coretax_bpmp.xml +31 -0
  54. package/template/base/modules/pos/flows/pos_sale_merge.rk +34 -0
  55. package/template/base/modules/pos/flows/pos_sale_on_cancel.rk +3 -0
  56. package/template/base/modules/pos/flows/pos_sale_on_submit.rk +28 -1
  57. package/template/base/modules/pos/flows/pos_sale_split.rk +37 -0
  58. package/template/base/modules/pos/flows/pos_shift_on_create.rk +9 -1
  59. package/template/base/modules/pos/flows/pos_table_guard_on_create.rk +24 -0
  60. package/template/base/modules/pos/flows/pos_table_guard_on_update.rk +23 -0
  61. package/template/base/modules/pos/models/dining_area.rk +23 -0
  62. package/template/base/modules/pos/models/dining_table.rk +38 -0
  63. package/template/base/modules/pos/models/pos_guard.rk +39 -0
  64. package/template/base/modules/pos/models/pos_payment.rk +2 -0
  65. package/template/base/modules/pos/models/pos_sale.rk +153 -7
  66. package/template/base/modules/pos/models/pos_sale_item.rk +4 -0
  67. package/template/base/modules/pos/models/pos_shift.rk +11 -1
  68. package/template/base/modules/pos/module.rk +9 -4
  69. package/template/base/modules/pos/print/pos_receipt.html +5 -2
  70. package/template/base/modules/pos/print/pos_receipt_part.html +30 -0
  71. package/template/base/modules/pos/print/pos_receipt_part.rk +8 -0
  72. package/template/base/modules/pos/screens/kasir.rk +6 -3
  73. package/template/base/modules/pos/screens/kasir_meja.rk +62 -0
  74. package/template/base/modules/reimbursement/models/expense_claim.rk +1 -1
  75. package/template/base/modules/shifts/module.rk +1 -1
  76. package/template/base/modules/stock/flows/stock_balance_variant_group.rk +26 -0
  77. package/template/base/modules/stock/models/stock_balance.rk +1 -0
  78. package/template/base/modules/stock/models/stock_move.rk +1 -0
  79. package/template/base/modules/users/flows/summary_daily.rk +3 -1
  80. package/template/base/modules/users/flows/summary_monthly.rk +3 -1
  81. package/template/base/modules/users/flows/summary_weekly.rk +3 -1
  82. package/template/base/modules/whatsapp/models/whatsapp_message.rk +2 -0
  83. package/template/base/modules/whatsapp/module.rk +2 -2
  84. package/template/base/modules/whatsapp_order/README.md +44 -0
  85. package/template/base/modules/whatsapp_order/flows/whatsapp_order_intake.rk +118 -0
  86. package/template/base/modules/whatsapp_order/flows/whatsapp_order_locked.rk +12 -0
  87. package/template/base/modules/whatsapp_order/flows/whatsapp_order_on_update.rk +124 -0
  88. package/template/base/modules/whatsapp_order/models/whatsapp_inbound.rk +62 -0
  89. package/template/base/modules/whatsapp_order/models/whatsapp_order.rk +164 -0
  90. package/template/base/modules/whatsapp_order/models/whatsapp_order_guard.rk +46 -0
  91. package/template/base/modules/whatsapp_order/models/whatsapp_order_line.rk +45 -0
  92. package/template/base/modules/whatsapp_order/module.rk +42 -0
  93. package/template/base/modules/whatsapp_order/screens/pesanan_wa.rk +22 -0
@@ -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