@rangka-os/create 0.5.0-alpha.26 → 0.5.0-alpha.28
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 +37 -0
- package/template/base/apps/absen_karyawan/dashboards/absen_hari_ini.rk +20 -0
- package/template/base/apps/absen_karyawan/dashboards/absen_karyawan_saya.rk +14 -0
- package/template/base/apps/absen_karyawan/dashboards/rekap_absen_karyawan.rk +12 -0
- package/template/base/apps/jasa_proyek/app.rk +1 -1
- package/template/base/apps/kasir/app.rk +5 -1
- package/template/base/apps/kasir/dashboards/kasir_ringkas.rk +4 -0
- package/template/base/apps/kasir/skills/rangka-app-kasir/SKILL.md +20 -0
- package/template/base/connectors/email/connector.rk +144 -0
- package/template/base/connectors/email/fixtures/email_received.json +33 -0
- package/template/base/connectors/email/fixtures/email_received_reply.json +31 -0
- package/template/base/connectors/email/fixtures/expect.json +20 -0
- package/template/base/connectors/email/fixtures/fetch_email.json +66 -0
- package/template/base/connectors/email/fixtures/send_email.json +4 -0
- package/template/base/connectors/midtrans/connector.rk +249 -0
- package/template/base/connectors/midtrans/fixtures/charge_gopay.json +34 -0
- package/template/base/connectors/midtrans/fixtures/charge_qris.json +23 -0
- package/template/base/connectors/midtrans/fixtures/charge_va.json +20 -0
- package/template/base/connectors/midtrans/fixtures/create_snap.json +4 -0
- package/template/base/connectors/midtrans/fixtures/expect.json +88 -0
- package/template/base/connectors/midtrans/fixtures/get_status.json +15 -0
- package/template/base/connectors/midtrans/fixtures/payment_notified.json +28 -0
- package/template/base/connectors/midtrans/fixtures/payment_notified_challenge.json +24 -0
- package/template/base/connectors/midtrans/fixtures/payment_notified_expire.json +24 -0
- package/template/base/connectors/midtrans/fixtures/payment_notified_other_amount.json +28 -0
- package/template/base/connectors/midtrans/fixtures/payment_notified_partial_refund.json +34 -0
- package/template/base/connectors/midtrans/fixtures/payment_notified_pending.json +31 -0
- package/template/base/connectors/midtrans/fixtures/payment_notified_refund.json +34 -0
- package/template/base/connectors/midtrans/fixtures/payment_notified_relabelled.json +28 -0
- package/template/base/connectors/midtrans/fixtures/payment_notified_va.json +32 -0
- package/template/base/connectors/midtrans/fixtures/signature_vector.txt +3 -0
- package/template/base/connectors/midtrans/mock/midtrans_mock.py +335 -0
- package/template/base/connectors/rangka_whatsapp/README.md +105 -0
- package/template/base/connectors/rangka_whatsapp/connector.rk +141 -0
- package/template/base/connectors/rangka_whatsapp/fixtures/expect.json +9 -0
- package/template/base/connectors/rangka_whatsapp/fixtures/message_received.json +1 -0
- package/template/base/connectors/rangka_whatsapp/fixtures/message_status.json +1 -0
- package/template/base/connectors/rangka_whatsapp/fixtures/message_status_refused.json +1 -0
- package/template/base/connectors/rangka_whatsapp/fixtures/opted_out.json +1 -0
- package/template/base/connectors/rangka_whatsapp/fixtures/send_template.json +1 -0
- package/template/base/connectors/rangka_whatsapp/fixtures/send_template_duplicate.json +1 -0
- package/template/base/connectors/rangka_whatsapp/fixtures/set_opt_out.json +1 -0
- package/template/base/connectors/rangka_whatsapp/mock/rangka_whatsapp_mock.py +354 -0
- package/template/base/connectors/shopee/connector.rk +360 -0
- package/template/base/connectors/shopee/fixtures/expect.json +119 -0
- package/template/base/connectors/shopee/fixtures/get_models.json +52 -0
- package/template/base/connectors/shopee/fixtures/get_order_detail.json +396 -0
- package/template/base/connectors/shopee/fixtures/get_settlement.json +90 -0
- package/template/base/connectors/shopee/fixtures/get_tracking.json +13 -0
- package/template/base/connectors/shopee/fixtures/list_items.json +29 -0
- package/template/base/connectors/shopee/fixtures/list_orders.json +31 -0
- package/template/base/connectors/shopee/fixtures/list_settlements.json +15 -0
- package/template/base/connectors/shopee/fixtures/order_changed.json +101 -0
- package/template/base/connectors/shopee/fixtures/order_changed_cancelled.json +72 -0
- package/template/base/connectors/shopee/fixtures/order_changed_completed.json +101 -0
- package/template/base/connectors/shopee/fixtures/order_changed_in_cancel.json +72 -0
- package/template/base/connectors/shopee/fixtures/order_changed_unpaid.json +71 -0
- package/template/base/connectors/shopee/fixtures/order_settled.json +92 -0
- package/template/base/connectors/shopee/fixtures/push_received.json +12 -0
- package/template/base/connectors/shopee/fixtures/push_received_tracking.json +11 -0
- package/template/base/connectors/shopee/fixtures/update_stock.json +15 -0
- package/template/base/connectors/shopee/mock/shopee_mock.py +894 -0
- package/template/base/connectors/tiktok_shop/connector.rk +300 -0
- package/template/base/connectors/tiktok_shop/fixtures/expect.json +105 -0
- package/template/base/connectors/tiktok_shop/fixtures/get_order_detail.json +136 -0
- package/template/base/connectors/tiktok_shop/fixtures/get_settlement.json +83 -0
- package/template/base/connectors/tiktok_shop/fixtures/get_tracking.json +28 -0
- package/template/base/connectors/tiktok_shop/fixtures/list_orders.json +242 -0
- package/template/base/connectors/tiktok_shop/fixtures/list_products.json +77 -0
- package/template/base/connectors/tiktok_shop/fixtures/list_settlements.json +22 -0
- package/template/base/connectors/tiktok_shop/fixtures/list_shops.json +17 -0
- package/template/base/connectors/tiktok_shop/fixtures/order_changed.json +129 -0
- package/template/base/connectors/tiktok_shop/fixtures/order_changed_cancelled.json +81 -0
- package/template/base/connectors/tiktok_shop/fixtures/order_changed_completed.json +106 -0
- package/template/base/connectors/tiktok_shop/fixtures/order_changed_on_hold.json +104 -0
- package/template/base/connectors/tiktok_shop/fixtures/order_changed_tokopedia.json +106 -0
- package/template/base/connectors/tiktok_shop/fixtures/order_changed_unpaid.json +79 -0
- package/template/base/connectors/tiktok_shop/fixtures/order_settled.json +73 -0
- package/template/base/connectors/tiktok_shop/fixtures/update_stock.json +6 -0
- package/template/base/connectors/tiktok_shop/fixtures/webhook_received.json +12 -0
- package/template/base/connectors/tiktok_shop/fixtures/webhook_received_cancellation.json +13 -0
- package/template/base/connectors/tiktok_shop/mock/tiktok_shop_mock.py +819 -0
- package/template/base/connectors/whatsapp_business/connector.rk +3 -1
- package/template/base/connectors/whatsapp_business/templates.md +13 -1
- package/template/base/modules/attendance/flows/attendance_missing_digest.rk +30 -0
- package/template/base/modules/attendance/flows/attendance_period_on_cancel.rk +15 -0
- package/template/base/modules/attendance/flows/attendance_period_on_submit.rk +60 -0
- package/template/base/modules/attendance/flows/staff_attendance_cancel_guard.rk +14 -0
- package/template/base/modules/attendance/flows/staff_attendance_guard_created.rk +16 -0
- package/template/base/modules/attendance/flows/staff_attendance_guard_submitted.rk +37 -0
- package/template/base/modules/attendance/flows/staff_attendance_guard_updated.rk +14 -0
- package/template/base/modules/attendance/models/attendance_period.rk +62 -0
- package/template/base/modules/attendance/models/attendance_summary.rk +37 -0
- package/template/base/modules/attendance/models/staff_attendance.rk +281 -0
- package/template/base/modules/attendance/models/staff_attendance_guard.rk +50 -0
- package/template/base/modules/attendance/module.rk +18 -0
- package/template/base/modules/attendance/screens/absen_outlet.rk +22 -0
- package/template/base/modules/catalogue/models/item.rk +69 -0
- package/template/base/modules/catalogue/module.rk +1 -1
- package/template/base/modules/contacts/models/customer.rk +43 -19
- package/template/base/modules/contacts/module.rk +1 -1
- package/template/base/modules/coretax/module.rk +1 -1
- package/template/base/modules/coretax/print/coretax_faktur.rk +3 -2
- package/template/base/modules/coretax/print/coretax_faktur.xml +3 -1
- package/template/base/modules/coretax/print/rekap_ppn.html +9 -7
- package/template/base/modules/courses/flows/charge_invoice_on_submit.rk +15 -0
- package/template/base/modules/courses/module.rk +1 -1
- package/template/base/modules/courses/screens/absen_kelas.rk +1 -0
- package/template/base/modules/invoicing/flows/invoice_due_digest.rk +45 -7
- package/template/base/modules/invoicing/models/sales_invoice_item.rk +4 -1
- package/template/base/modules/invoicing/module.rk +15 -2
- package/template/base/modules/kitchen/screens/dapur.rk +1 -0
- package/template/base/modules/outlets/models/outlet.rk +69 -0
- package/template/base/modules/outlets/module.rk +1 -1
- package/template/base/modules/payments/flows/payment_from_midtrans.rk +85 -0
- package/template/base/modules/payments/flows/payment_refund_from_midtrans.rk +22 -0
- package/template/base/modules/payments/models/payment.rk +2 -1
- package/template/base/modules/payments/module.rk +1 -1
- package/template/base/modules/payroll/flows/payroll_close_on_cancel.rk +8 -5
- package/template/base/modules/payroll/flows/payroll_close_on_submit.rk +8 -5
- package/template/base/modules/payroll/flows/payroll_reminder.rk +106 -0
- package/template/base/modules/payroll/flows/payroll_run_overlap_guard_created.rk +5 -3
- package/template/base/modules/payroll/flows/payroll_run_overlap_guard_updated.rk +5 -3
- package/template/base/modules/payroll/flows/payslip_from_recap.rk +1 -1
- package/template/base/modules/payroll/imports/payroll_profile_list.rk +27 -0
- package/template/base/modules/payroll/models/payroll_close.rk +10 -6
- package/template/base/modules/payroll/models/payroll_run.rk +64 -15
- package/template/base/modules/payroll/models/payslip.rk +48 -9
- package/template/base/modules/payroll/module.rk +22 -5
- package/template/base/modules/payroll/print/payslip.html +4 -1
- package/template/base/modules/pos/models/pos_sale.rk +136 -9
- package/template/base/modules/pos/models/pos_sale_item.rk +33 -1
- package/template/base/modules/pos/module.rk +5 -3
- package/template/base/modules/pos/print/pos_receipt.html +7 -3
- package/template/base/modules/pos/screens/kasir.rk +7 -2
- package/template/base/modules/procurement/flows/reorder_draft_po.rk +57 -0
- package/template/base/modules/procurement/models/vendor_bill.rk +14 -1
- package/template/base/modules/procurement/module.rk +11 -2
- package/template/base/modules/projects/screens/absen.rk +1 -0
- package/template/base/modules/promotions/flows/promo_code_batch_on_submit.rk +26 -0
- package/template/base/modules/promotions/flows/promotion_apply.rk +110 -0
- package/template/base/modules/promotions/flows/promotion_apply_on_create.rk +110 -0
- package/template/base/modules/promotions/flows/promotion_apply_on_delete.rk +111 -0
- package/template/base/modules/promotions/flows/promotion_apply_on_update.rk +110 -0
- package/template/base/modules/promotions/flows/promotion_on_sale.rk +95 -0
- package/template/base/modules/promotions/flows/promotion_on_sale_cancel.rk +43 -0
- package/template/base/modules/promotions/models/promo_code.rk +27 -0
- package/template/base/modules/promotions/models/promo_code_batch.rk +36 -0
- package/template/base/modules/promotions/models/promo_guard.rk +44 -0
- package/template/base/modules/promotions/models/promotion.rk +197 -0
- package/template/base/modules/promotions/models/promotion_ledger.rk +35 -0
- package/template/base/modules/promotions/module.rk +20 -0
- package/template/base/modules/rental/screens/alat_keluar.rk +1 -0
- package/template/base/modules/rental/screens/alat_kembali.rk +1 -0
- package/template/base/modules/rental/screens/jadwal_alat.rk +1 -0
- package/template/base/modules/stock/flows/stock_low_alert.rk +65 -0
- package/template/base/modules/stock/flows/stock_negative_alert.rk +14 -5
- package/template/base/modules/stock/models/stock_reorder.rk +34 -0
- package/template/base/modules/stock/module.rk +17 -2
- package/template/base/modules/subscriptions/screens/catat_tagih.rk +1 -0
- package/template/base/modules/subscriptions/screens/rute_tagih.rk +1 -0
- package/template/base/modules/users/flows/summary_daily.rk +83 -0
- package/template/base/modules/users/flows/summary_monthly.rk +83 -0
- package/template/base/modules/users/flows/summary_weekly.rk +83 -0
- package/template/base/modules/users/models/business_summary.rk +67 -0
- package/template/base/modules/users/models/summary_setting.rk +35 -0
- package/template/base/modules/users/models/user.rk +11 -3
- package/template/base/modules/users/module.rk +21 -2
- package/template/base/modules/users/roles/employee.rk +8 -0
- package/template/base/modules/users/roles/outlet_supervisor.rk +7 -0
- package/template/base/modules/whatsapp/flows/whatsapp_customer_opt_out.rk +16 -0
- package/template/base/modules/whatsapp/flows/whatsapp_customer_opt_out_new.rk +17 -0
- package/template/base/modules/whatsapp/flows/whatsapp_message_status.rk +24 -0
- package/template/base/modules/whatsapp/flows/whatsapp_opted_out.rk +26 -0
- package/template/base/modules/whatsapp/models/whatsapp_message.rk +99 -0
- package/template/base/modules/whatsapp/models/whatsapp_opt_out.rk +44 -0
- package/template/base/modules/whatsapp/module.rk +23 -0
- package/template/base/modules/whatsapp_booking/flows/whatsapp_booking_tomorrow.rk +48 -0
- package/template/base/modules/whatsapp_booking/module.rk +13 -0
- package/template/base/modules/whatsapp_order_ready/flows/whatsapp_pickup_on_sale.rk +19 -0
- package/template/base/modules/whatsapp_order_ready/flows/whatsapp_ticket_ready.rk +40 -0
- package/template/base/modules/whatsapp_order_ready/models/whatsapp_pickup.rk +22 -0
- package/template/base/modules/whatsapp_order_ready/module.rk +14 -0
- package/template/base/modules/whatsapp_receipt/flows/whatsapp_receipt_on_sale.rk +43 -0
- package/template/base/modules/whatsapp_receipt/module.rk +13 -0
- package/template/base/modules/whatsapp_reminder/flows/whatsapp_invoice_overdue.rk +64 -0
- package/template/base/modules/whatsapp_reminder/module.rk +15 -0
- package/template/base/modules/workforce/imports/worker_list.rk +4 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# Generated by scripts/gen_promotion_flows.py (do not edit by hand). A changed promo reaches the items at once; the flow's own write of live changes nothing the second time.
|
|
3
|
+
name: promotion_apply_on_update
|
|
4
|
+
label: {id: 'Promo diubah: perbarui barang'}
|
|
5
|
+
on: promotion.updated
|
|
6
|
+
steps:
|
|
7
|
+
# 1. live: active, in its dates, days and hours now
|
|
8
|
+
- find_all: promotion
|
|
9
|
+
as: all
|
|
10
|
+
- for_each: all
|
|
11
|
+
as: p
|
|
12
|
+
do:
|
|
13
|
+
- update: p
|
|
14
|
+
if: "p.live != (p.active && p.valid_from <= today() && p.valid_until >= today() && (p.days == '' || p.days.contains(string(days_between('2024-01-01', today()) % 7 + 1))) && (p.time_from == '' || clock() >= p.time_from && clock() < p.time_until))"
|
|
15
|
+
set:
|
|
16
|
+
live: "p.active && p.valid_from <= today() && p.valid_until >= today() && (p.days == '' || p.days.contains(string(days_between('2024-01-01', today()) % 7 + 1))) && (p.time_from == '' || clock() >= p.time_from && clock() < p.time_until)"
|
|
17
|
+
# 2. the live item promos for the counter, all outlets (kg) and one outlet (ko), and for invoices (vs)
|
|
18
|
+
- find_all: promotion
|
|
19
|
+
where: "live && !is_bill && channel != 'invoice' && only_outlet == ''"
|
|
20
|
+
as: kg
|
|
21
|
+
- find_all: promotion
|
|
22
|
+
where: "live && !is_bill && channel != 'invoice' && only_outlet != ''"
|
|
23
|
+
as: ko
|
|
24
|
+
- find_all: promotion
|
|
25
|
+
where: "live && kind == 'item_pct' && channel != 'kasir' && only_outlet == ''"
|
|
26
|
+
as: vs
|
|
27
|
+
# items that carry a promo now (it may have ended) ...
|
|
28
|
+
- find_all: item
|
|
29
|
+
where: "promo != '' || promo_o != '' || promo_invoice_pct != 0"
|
|
30
|
+
as: had
|
|
31
|
+
- for_each: had
|
|
32
|
+
as: it
|
|
33
|
+
do:
|
|
34
|
+
- for_each: "[kg.filter(p, (p.scope == 'item' && p.item == it.name || p.scope == 'category' && p.category != '' && p.category == it.category) && kg.filter(q, (q.scope == 'item' && q.item == it.name || q.scope == 'category' && q.category != '' && q.category == it.category) && (q.priority > p.priority || q.priority == p.priority && q.name < p.name)).size() == 0)]"
|
|
35
|
+
as: w
|
|
36
|
+
do:
|
|
37
|
+
- for_each: "[vs.filter(p, (p.scope == 'item' && p.item == it.name || p.scope == 'category' && p.category != '' && p.category == it.category) && vs.filter(q, (q.scope == 'item' && q.item == it.name || q.scope == 'category' && q.category != '' && q.category == it.category) && (q.priority > p.priority || q.priority == p.priority && q.name < p.name)).size() == 0)]"
|
|
38
|
+
as: v
|
|
39
|
+
do:
|
|
40
|
+
- for_each: "[ko.filter(p, (p.scope == 'item' && p.item == it.name || p.scope == 'category' && p.category != '' && p.category == it.category) && ko.filter(q, (q.scope == 'item' && q.item == it.name || q.scope == 'category' && q.category != '' && q.category == it.category) && (q.priority > p.priority || q.priority == p.priority && q.name < p.name)).size() == 0).filter(x, w.size() == 0 || x.priority >= w[0].priority)]"
|
|
41
|
+
as: o
|
|
42
|
+
do:
|
|
43
|
+
- update: it
|
|
44
|
+
if: "it.promo != (w.size() > 0 ? w[0].name : '') || it.promo_name != (w.size() > 0 ? w[0].promo_name : '') || it.promo_kind != (w.size() == 0 ? '' : (w[0].kind == 'item_pct' ? 'pct' : (w[0].kind == 'item_off' ? 'off' : 'buy_get'))) || it.promo_pct != (w.size() > 0 && w[0].kind == 'item_pct' ? w[0].pct : 0) || it.promo_off != (w.size() > 0 && w[0].kind == 'item_off' ? w[0].amount_off : 0) || it.promo_buy != (w.size() > 0 && w[0].kind == 'buy_get' ? w[0].buy_qty : 0) || it.promo_get != (w.size() > 0 && w[0].kind == 'buy_get' ? w[0].get_qty : 0) || it.promo_until != (w.size() > 0 ? w[0].valid_until : null) || it.promo_invoice_pct != (v.size() > 0 ? v[0].pct : 0) || it.promo_outlet != ('') || it.promo_o != (o.size() > 0 ? o[0].name : '') || it.promo_o_name != (o.size() > 0 ? o[0].promo_name : '') || it.promo_o_kind != (o.size() == 0 ? '' : (o[0].kind == 'item_pct' ? 'pct' : (o[0].kind == 'item_off' ? 'off' : 'buy_get'))) || it.promo_o_pct != (o.size() > 0 && o[0].kind == 'item_pct' ? o[0].pct : 0) || it.promo_o_off != (o.size() > 0 && o[0].kind == 'item_off' ? o[0].amount_off : 0) || it.promo_o_buy != (o.size() > 0 && o[0].kind == 'buy_get' ? o[0].buy_qty : 0) || it.promo_o_get != (o.size() > 0 && o[0].kind == 'buy_get' ? o[0].get_qty : 0) || it.promo_o_outlet != (o.size() > 0 ? o[0].only_outlet : '') || it.promo_o_until != (o.size() > 0 ? o[0].valid_until : null)"
|
|
45
|
+
set:
|
|
46
|
+
promo: "w.size() > 0 ? w[0].name : ''"
|
|
47
|
+
promo_name: "w.size() > 0 ? w[0].promo_name : ''"
|
|
48
|
+
promo_kind: "w.size() == 0 ? '' : (w[0].kind == 'item_pct' ? 'pct' : (w[0].kind == 'item_off' ? 'off' : 'buy_get'))"
|
|
49
|
+
promo_pct: "w.size() > 0 && w[0].kind == 'item_pct' ? w[0].pct : 0"
|
|
50
|
+
promo_off: "w.size() > 0 && w[0].kind == 'item_off' ? w[0].amount_off : 0"
|
|
51
|
+
promo_buy: "w.size() > 0 && w[0].kind == 'buy_get' ? w[0].buy_qty : 0"
|
|
52
|
+
promo_get: "w.size() > 0 && w[0].kind == 'buy_get' ? w[0].get_qty : 0"
|
|
53
|
+
promo_until: "w.size() > 0 ? w[0].valid_until : null"
|
|
54
|
+
promo_invoice_pct: "v.size() > 0 ? v[0].pct : 0"
|
|
55
|
+
promo_outlet: "''"
|
|
56
|
+
promo_o: "o.size() > 0 ? o[0].name : ''"
|
|
57
|
+
promo_o_name: "o.size() > 0 ? o[0].promo_name : ''"
|
|
58
|
+
promo_o_kind: "o.size() == 0 ? '' : (o[0].kind == 'item_pct' ? 'pct' : (o[0].kind == 'item_off' ? 'off' : 'buy_get'))"
|
|
59
|
+
promo_o_pct: "o.size() > 0 && o[0].kind == 'item_pct' ? o[0].pct : 0"
|
|
60
|
+
promo_o_off: "o.size() > 0 && o[0].kind == 'item_off' ? o[0].amount_off : 0"
|
|
61
|
+
promo_o_buy: "o.size() > 0 && o[0].kind == 'buy_get' ? o[0].buy_qty : 0"
|
|
62
|
+
promo_o_get: "o.size() > 0 && o[0].kind == 'buy_get' ? o[0].get_qty : 0"
|
|
63
|
+
promo_o_outlet: "o.size() > 0 ? o[0].only_outlet : ''"
|
|
64
|
+
promo_o_until: "o.size() > 0 ? o[0].valid_until : null"
|
|
65
|
+
# ... and the items each live item promo covers
|
|
66
|
+
- for_each: kg + ko + vs
|
|
67
|
+
as: pr
|
|
68
|
+
do:
|
|
69
|
+
- find_all: item
|
|
70
|
+
if: "pr.scope == 'item'"
|
|
71
|
+
where: name == pr.item
|
|
72
|
+
as: one
|
|
73
|
+
- find_all: item
|
|
74
|
+
if: "pr.scope == 'category'"
|
|
75
|
+
where: category == pr.category
|
|
76
|
+
as: cat
|
|
77
|
+
- for_each: "pr.scope == 'item' ? one : cat"
|
|
78
|
+
as: it
|
|
79
|
+
do:
|
|
80
|
+
- for_each: "[kg.filter(p, (p.scope == 'item' && p.item == it.name || p.scope == 'category' && p.category != '' && p.category == it.category) && kg.filter(q, (q.scope == 'item' && q.item == it.name || q.scope == 'category' && q.category != '' && q.category == it.category) && (q.priority > p.priority || q.priority == p.priority && q.name < p.name)).size() == 0)]"
|
|
81
|
+
as: w
|
|
82
|
+
do:
|
|
83
|
+
- for_each: "[vs.filter(p, (p.scope == 'item' && p.item == it.name || p.scope == 'category' && p.category != '' && p.category == it.category) && vs.filter(q, (q.scope == 'item' && q.item == it.name || q.scope == 'category' && q.category != '' && q.category == it.category) && (q.priority > p.priority || q.priority == p.priority && q.name < p.name)).size() == 0)]"
|
|
84
|
+
as: v
|
|
85
|
+
do:
|
|
86
|
+
- for_each: "[ko.filter(p, (p.scope == 'item' && p.item == it.name || p.scope == 'category' && p.category != '' && p.category == it.category) && ko.filter(q, (q.scope == 'item' && q.item == it.name || q.scope == 'category' && q.category != '' && q.category == it.category) && (q.priority > p.priority || q.priority == p.priority && q.name < p.name)).size() == 0).filter(x, w.size() == 0 || x.priority >= w[0].priority)]"
|
|
87
|
+
as: o
|
|
88
|
+
do:
|
|
89
|
+
- update: it
|
|
90
|
+
if: "it.promo != (w.size() > 0 ? w[0].name : '') || it.promo_name != (w.size() > 0 ? w[0].promo_name : '') || it.promo_kind != (w.size() == 0 ? '' : (w[0].kind == 'item_pct' ? 'pct' : (w[0].kind == 'item_off' ? 'off' : 'buy_get'))) || it.promo_pct != (w.size() > 0 && w[0].kind == 'item_pct' ? w[0].pct : 0) || it.promo_off != (w.size() > 0 && w[0].kind == 'item_off' ? w[0].amount_off : 0) || it.promo_buy != (w.size() > 0 && w[0].kind == 'buy_get' ? w[0].buy_qty : 0) || it.promo_get != (w.size() > 0 && w[0].kind == 'buy_get' ? w[0].get_qty : 0) || it.promo_until != (w.size() > 0 ? w[0].valid_until : null) || it.promo_invoice_pct != (v.size() > 0 ? v[0].pct : 0) || it.promo_outlet != ('') || it.promo_o != (o.size() > 0 ? o[0].name : '') || it.promo_o_name != (o.size() > 0 ? o[0].promo_name : '') || it.promo_o_kind != (o.size() == 0 ? '' : (o[0].kind == 'item_pct' ? 'pct' : (o[0].kind == 'item_off' ? 'off' : 'buy_get'))) || it.promo_o_pct != (o.size() > 0 && o[0].kind == 'item_pct' ? o[0].pct : 0) || it.promo_o_off != (o.size() > 0 && o[0].kind == 'item_off' ? o[0].amount_off : 0) || it.promo_o_buy != (o.size() > 0 && o[0].kind == 'buy_get' ? o[0].buy_qty : 0) || it.promo_o_get != (o.size() > 0 && o[0].kind == 'buy_get' ? o[0].get_qty : 0) || it.promo_o_outlet != (o.size() > 0 ? o[0].only_outlet : '') || it.promo_o_until != (o.size() > 0 ? o[0].valid_until : null)"
|
|
91
|
+
set:
|
|
92
|
+
promo: "w.size() > 0 ? w[0].name : ''"
|
|
93
|
+
promo_name: "w.size() > 0 ? w[0].promo_name : ''"
|
|
94
|
+
promo_kind: "w.size() == 0 ? '' : (w[0].kind == 'item_pct' ? 'pct' : (w[0].kind == 'item_off' ? 'off' : 'buy_get'))"
|
|
95
|
+
promo_pct: "w.size() > 0 && w[0].kind == 'item_pct' ? w[0].pct : 0"
|
|
96
|
+
promo_off: "w.size() > 0 && w[0].kind == 'item_off' ? w[0].amount_off : 0"
|
|
97
|
+
promo_buy: "w.size() > 0 && w[0].kind == 'buy_get' ? w[0].buy_qty : 0"
|
|
98
|
+
promo_get: "w.size() > 0 && w[0].kind == 'buy_get' ? w[0].get_qty : 0"
|
|
99
|
+
promo_until: "w.size() > 0 ? w[0].valid_until : null"
|
|
100
|
+
promo_invoice_pct: "v.size() > 0 ? v[0].pct : 0"
|
|
101
|
+
promo_outlet: "''"
|
|
102
|
+
promo_o: "o.size() > 0 ? o[0].name : ''"
|
|
103
|
+
promo_o_name: "o.size() > 0 ? o[0].promo_name : ''"
|
|
104
|
+
promo_o_kind: "o.size() == 0 ? '' : (o[0].kind == 'item_pct' ? 'pct' : (o[0].kind == 'item_off' ? 'off' : 'buy_get'))"
|
|
105
|
+
promo_o_pct: "o.size() > 0 && o[0].kind == 'item_pct' ? o[0].pct : 0"
|
|
106
|
+
promo_o_off: "o.size() > 0 && o[0].kind == 'item_off' ? o[0].amount_off : 0"
|
|
107
|
+
promo_o_buy: "o.size() > 0 && o[0].kind == 'buy_get' ? o[0].buy_qty : 0"
|
|
108
|
+
promo_o_get: "o.size() > 0 && o[0].kind == 'buy_get' ? o[0].get_qty : 0"
|
|
109
|
+
promo_o_outlet: "o.size() > 0 ? o[0].only_outlet : ''"
|
|
110
|
+
promo_o_until: "o.size() > 0 ? o[0].valid_until : null"
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# Runs inside a sale's submit (the payment), as the cashier, also for a sale a paired device sends later (contract
|
|
3
|
+
# 0058 §10 turns the sale's own rules into exceptions there, but a record this flow writes still refuses). So the bill
|
|
4
|
+
# promo is checked again here: active, in its dates, outlet and hours (clock() at the sale's time), its code (a shared
|
|
5
|
+
# voucher's code, a single-use coupon of this promo), and a free gift line (the gift promo, its minimum spend, item,
|
|
6
|
+
# quantity in stock units, no pack). A voucher's uses are counted per promo and a coupon's per code, as post rows minus
|
|
7
|
+
# reverse rows of promotion_ledger read under the ledger's flow lock (contract 0025), so two sales racing for the last
|
|
8
|
+
# use or one coupon run one after the other and the second is refused (promo_guard), rolling its payment back.
|
|
9
|
+
# Then one ledger row per promo used: the bill promo (bill_promo + the free gift's price) and each item promo that
|
|
10
|
+
# still exists (the sum of its lines' promo_discount).
|
|
11
|
+
name: promotion_on_sale
|
|
12
|
+
label: {id: 'Transaksi kasir dibayar: cek dan catat promo'}
|
|
13
|
+
on: pos_sale.submitted
|
|
14
|
+
if: app_installed('pos')
|
|
15
|
+
steps:
|
|
16
|
+
- if: "event.promotion != ''"
|
|
17
|
+
then:
|
|
18
|
+
- find: promotion
|
|
19
|
+
where: name == event.promotion
|
|
20
|
+
as: p
|
|
21
|
+
- if: >-
|
|
22
|
+
p == null || !p.active || p.valid_from > event.date || p.valid_until < event.date
|
|
23
|
+
|| (p.only_outlet != '' && p.only_outlet != event.outlet)
|
|
24
|
+
|| (p.days != '' && !p.days.contains(string(days_between('2024-01-01', event.date) % 7 + 1)))
|
|
25
|
+
|| (p.time_from != '' && (clock() < p.time_from || clock() >= p.time_until))
|
|
26
|
+
create: promo_guard
|
|
27
|
+
set: {reason: "'promo_ended'", document: event.name}
|
|
28
|
+
- if: "p.code_mode == 'shared' && event.promo_code.trim().upperAscii() != p.code"
|
|
29
|
+
create: promo_guard
|
|
30
|
+
set: {reason: "'code_unknown'", document: event.name}
|
|
31
|
+
- if: "event.bill_promo + event.gift_value > 0 && p.code_mode == 'shared' && p.max_uses > 0"
|
|
32
|
+
then:
|
|
33
|
+
# every use of this voucher so far, whatever code was typed, under the ledger's lock (contract 0025)
|
|
34
|
+
- find_all: promotion_ledger
|
|
35
|
+
where: promotion == event.promotion
|
|
36
|
+
as: uses
|
|
37
|
+
- if: "uses.filter(u, u.entry == 'post').size() - uses.filter(u, u.entry == 'reverse').size() >= p.max_uses"
|
|
38
|
+
create: promo_guard
|
|
39
|
+
set: {reason: "'code_limit'", document: event.name}
|
|
40
|
+
- if: "p.code_mode == 'unique'"
|
|
41
|
+
then:
|
|
42
|
+
- find: promo_code
|
|
43
|
+
where: "promotion == event.promotion && code == event.promo_code.trim().upperAscii()"
|
|
44
|
+
as: c
|
|
45
|
+
- if: c == null
|
|
46
|
+
create: promo_guard
|
|
47
|
+
set: {reason: "'code_unknown'", document: event.name}
|
|
48
|
+
- find_all: promotion_ledger
|
|
49
|
+
where: "promotion == event.promotion && code == event.promo_code.trim().upperAscii()"
|
|
50
|
+
as: used
|
|
51
|
+
- if: "used.filter(u, u.entry == 'post').size() - used.filter(u, u.entry == 'reverse').size() > 0"
|
|
52
|
+
create: promo_guard
|
|
53
|
+
set: {reason: "'code_used'", document: event.name}
|
|
54
|
+
- create: promotion_ledger
|
|
55
|
+
if: "event.bill_promo + event.gift_value > 0"
|
|
56
|
+
set:
|
|
57
|
+
promotion: event.promotion
|
|
58
|
+
sale: event.name
|
|
59
|
+
sale_outlet: event.outlet
|
|
60
|
+
date: event.date
|
|
61
|
+
code: "p.code_mode == 'none' || p.code_mode == '' ? '' : event.promo_code.trim().upperAscii()"
|
|
62
|
+
amount: event.bill_promo + event.gift_value
|
|
63
|
+
entry: "'post'"
|
|
64
|
+
entry_key: "event.name + '|' + event.promotion + '|post'"
|
|
65
|
+
# a free gift line, checked again for a sale whose rules a device's replay overrode
|
|
66
|
+
- if: "event.items.filter(l, l.is_gift).size() > 0"
|
|
67
|
+
then:
|
|
68
|
+
- find: promotion
|
|
69
|
+
if: "event.promotion != ''"
|
|
70
|
+
where: name == event.promotion
|
|
71
|
+
as: gp
|
|
72
|
+
- if: >-
|
|
73
|
+
event.promotion == '' || gp == null || gp.kind != 'free_gift' || event.subtotal < gp.min_spend
|
|
74
|
+
|| event.items.filter(l, l.is_gift && (l.item != gp.gift_item || l.packing != '')).size() > 0
|
|
75
|
+
|| event.items.filter(l, l.is_gift).map(l, l.stock_qty).sum() > gp.gift_qty
|
|
76
|
+
create: promo_guard
|
|
77
|
+
set: {reason: "'gift_invalid'", document: event.name}
|
|
78
|
+
# one row per item promo still there: its first line stands for all of its lines
|
|
79
|
+
- for_each: "event.items.filter(l, l.promotion != '' && l.promo_discount > 0 && event.items.filter(y, y.promotion == l.promotion && y.idx < l.idx).size() == 0)"
|
|
80
|
+
as: l
|
|
81
|
+
do:
|
|
82
|
+
- find: promotion
|
|
83
|
+
where: name == l.promotion
|
|
84
|
+
as: lpr
|
|
85
|
+
- create: promotion_ledger
|
|
86
|
+
if: lpr != null
|
|
87
|
+
set:
|
|
88
|
+
promotion: l.promotion
|
|
89
|
+
sale: event.name
|
|
90
|
+
sale_outlet: event.outlet
|
|
91
|
+
date: event.date
|
|
92
|
+
code: "''"
|
|
93
|
+
amount: "event.items.filter(y, y.promotion == l.promotion).map(y, y.promo_discount).sum()"
|
|
94
|
+
entry: "'post'"
|
|
95
|
+
entry_key: "event.name + '|' + l.promotion + '|post'"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# A voided sale gives its promos back: one reverse row (the amount negated) for each post row the sale wrote, so a
|
|
3
|
+
# voucher use and a coupon are free again and the promo's cost shrinks. The amounts come from the cancelled sale
|
|
4
|
+
# itself (the same expressions as promotion_on_sale), since the ledger's money is hidden from the cashier. An amended
|
|
5
|
+
# sale posts again under its own name when it is paid.
|
|
6
|
+
name: promotion_on_sale_cancel
|
|
7
|
+
label: {id: 'Transaksi kasir dibatalkan: kembalikan promo'}
|
|
8
|
+
on: pos_sale.cancelled
|
|
9
|
+
if: app_installed('pos')
|
|
10
|
+
steps:
|
|
11
|
+
- if: "event.promotion != ''"
|
|
12
|
+
then:
|
|
13
|
+
- find: promotion_ledger
|
|
14
|
+
where: "entry_key == event.name + '|' + event.promotion + '|post'"
|
|
15
|
+
as: bp
|
|
16
|
+
- create: promotion_ledger
|
|
17
|
+
if: bp != null
|
|
18
|
+
set:
|
|
19
|
+
promotion: event.promotion
|
|
20
|
+
sale: event.name
|
|
21
|
+
sale_outlet: event.outlet
|
|
22
|
+
date: event.date
|
|
23
|
+
code: bp.code
|
|
24
|
+
amount: 0 - (event.bill_promo + event.gift_value)
|
|
25
|
+
entry: "'reverse'"
|
|
26
|
+
entry_key: "event.name + '|' + event.promotion + '|reverse'"
|
|
27
|
+
- for_each: "event.items.filter(l, l.promotion != '' && l.promo_discount > 0 && event.items.filter(y, y.promotion == l.promotion && y.idx < l.idx).size() == 0)"
|
|
28
|
+
as: l
|
|
29
|
+
do:
|
|
30
|
+
- find: promotion_ledger
|
|
31
|
+
where: "entry_key == event.name + '|' + l.promotion + '|post'"
|
|
32
|
+
as: lp
|
|
33
|
+
- create: promotion_ledger
|
|
34
|
+
if: lp != null
|
|
35
|
+
set:
|
|
36
|
+
promotion: l.promotion
|
|
37
|
+
sale: event.name
|
|
38
|
+
sale_outlet: event.outlet
|
|
39
|
+
date: event.date
|
|
40
|
+
code: "''"
|
|
41
|
+
amount: "0 - event.items.filter(y, y.promotion == l.promotion).map(y, y.promo_discount).sum()"
|
|
42
|
+
entry: "'reverse'"
|
|
43
|
+
entry_key: "event.name + '|' + l.promotion + '|reverse'"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# A single-use coupon of a promo with code_mode unique, made by a promo_code_batch (flow promo_code_batch_on_submit):
|
|
3
|
+
# prefix + 8 characters of random_code() (rangka-os contract 0069 §3), so a code cannot be guessed from another. Whether
|
|
4
|
+
# it was used is in promotion_ledger (a post row with this code and no reverse row): flow promotion_on_sale checks it
|
|
5
|
+
# under the ledger's lock, so two sales with one coupon at the same moment cannot both pass, and a void frees it.
|
|
6
|
+
name: promo_code
|
|
7
|
+
label: {id: Kupon, en: Coupon}
|
|
8
|
+
icon: tag
|
|
9
|
+
naming: KPN-{######}
|
|
10
|
+
title_field: code
|
|
11
|
+
permissions:
|
|
12
|
+
# head office's batch submit creates the coupons (flow promo_code_batch_on_submit); every field is read_only, so a
|
|
13
|
+
# coupon is never typed by hand
|
|
14
|
+
- {role: head_office, read: true, create: true, export: true, print: true}
|
|
15
|
+
# flow promotion_on_sale reads the coupon inside the cashier's sale
|
|
16
|
+
- {role: cashier, read: true}
|
|
17
|
+
fields:
|
|
18
|
+
- {name: promotion, type: link, to: promotion, label: {id: Promo}, read_only: true, in_list: true}
|
|
19
|
+
# hidden from the cashier (audit F3): unissued coupons cannot be listed and used for a cash sale; flow
|
|
20
|
+
# promotion_on_sale still finds the code the buyer brings
|
|
21
|
+
- {name: code, type: data, label: {id: Kode kupon}, read_only: true, unique: true, in_list: true, hidden_for: [cashier]}
|
|
22
|
+
- {name: batch, type: link, to: promo_code_batch, label: {id: Kiriman kupon}, read_only: true, in_list: true}
|
|
23
|
+
views:
|
|
24
|
+
list:
|
|
25
|
+
columns: [name, code, promotion, batch]
|
|
26
|
+
filters: [promotion, batch]
|
|
27
|
+
sort: -name
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# A batch of single-use coupons for a promo with code_mode unique: submitting it makes count coupons (flow
|
|
3
|
+
# promo_code_batch_on_submit), each prefix + 8 random characters. Export the list to print or send the codes.
|
|
4
|
+
name: promo_code_batch
|
|
5
|
+
label: {id: Kiriman kupon, en: Coupon batch}
|
|
6
|
+
icon: tag
|
|
7
|
+
is_submittable: true
|
|
8
|
+
naming: KPB-{####}
|
|
9
|
+
title_field: promotion
|
|
10
|
+
permissions:
|
|
11
|
+
- {role: head_office, read: true, create: true, write: true, delete: true, submit: true, export: true, print: true}
|
|
12
|
+
fields:
|
|
13
|
+
- {name: promotion, type: link, to: promotion, label: {id: Promo}, required: true, in_list: true}
|
|
14
|
+
- {name: count, type: int, label: {id: Jumlah kupon}, default: '20', required: true, in_list: true}
|
|
15
|
+
- name: prefix
|
|
16
|
+
type: data
|
|
17
|
+
label: {id: Awalan kode}
|
|
18
|
+
help: {id: 'Boleh kosong. 0 sampai 6 huruf besar atau angka, misalnya HUT'}
|
|
19
|
+
- {name: note, type: text, label: {id: Catatan}}
|
|
20
|
+
rules:
|
|
21
|
+
- name: unique_promo
|
|
22
|
+
on: save
|
|
23
|
+
check: promotion.code_mode == 'unique'
|
|
24
|
+
message: {id: 'Kupon sekali pakai hanya untuk promo dengan Kode Kupon sekali pakai'}
|
|
25
|
+
- name: count_range
|
|
26
|
+
on: save
|
|
27
|
+
check: count >= 1 && count <= 1000
|
|
28
|
+
message: {id: Jumlah kupon 1 sampai 1000 per kiriman}
|
|
29
|
+
- name: prefix_format
|
|
30
|
+
on: save
|
|
31
|
+
check: "prefix == '' || prefix.matches('^[A-Z0-9]{1,6}$')"
|
|
32
|
+
message: {id: 'Awalan kode 1 sampai 6 huruf besar atau angka, tanpa spasi'}
|
|
33
|
+
views:
|
|
34
|
+
list:
|
|
35
|
+
columns: [name, promotion, count, status]
|
|
36
|
+
sort: -name
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# Never stored: a promo flow refuses a sale by creating one (as pos_guard does), and the rule of its reason fails
|
|
3
|
+
# with the cashier's message, so the sale's submit rolls back with its stock moves and number.
|
|
4
|
+
name: promo_guard
|
|
5
|
+
label: {id: Penjaga promo, en: Promotion guard}
|
|
6
|
+
icon: check
|
|
7
|
+
naming: PPG-{######}
|
|
8
|
+
title_field: reason
|
|
9
|
+
permissions:
|
|
10
|
+
- {role: head_office, create: true}
|
|
11
|
+
- {role: cashier, create: true}
|
|
12
|
+
fields:
|
|
13
|
+
- name: reason
|
|
14
|
+
type: select
|
|
15
|
+
label: {id: Alasan}
|
|
16
|
+
required: true
|
|
17
|
+
options:
|
|
18
|
+
- {value: code_used, label: {id: Kupon sudah dipakai}}
|
|
19
|
+
- {value: code_unknown, label: {id: Kupon tidak dikenal}}
|
|
20
|
+
- {value: code_limit, label: {id: Kuota voucher habis}}
|
|
21
|
+
- {value: promo_ended, label: {id: Promo tidak berlaku}}
|
|
22
|
+
- {value: gift_invalid, label: {id: Produk gratis tidak sesuai}}
|
|
23
|
+
- {name: document, type: data, label: {id: Dokumen}}
|
|
24
|
+
rules:
|
|
25
|
+
- name: code_used
|
|
26
|
+
on: save
|
|
27
|
+
check: reason != 'code_used'
|
|
28
|
+
message: {id: 'Kode kupon ini sudah dipakai'}
|
|
29
|
+
- name: code_unknown
|
|
30
|
+
on: save
|
|
31
|
+
check: reason != 'code_unknown'
|
|
32
|
+
message: {id: 'Kode kupon ini tidak ada untuk promo yang dipilih'}
|
|
33
|
+
- name: code_limit
|
|
34
|
+
on: save
|
|
35
|
+
check: reason != 'code_limit'
|
|
36
|
+
message: {id: 'Kuota voucher ini sudah habis'}
|
|
37
|
+
- name: promo_ended
|
|
38
|
+
on: save
|
|
39
|
+
check: reason != 'promo_ended'
|
|
40
|
+
message: {id: 'Promo ini tidak berlaku di outlet, tanggal atau jam ini'}
|
|
41
|
+
- name: gift_invalid
|
|
42
|
+
on: save
|
|
43
|
+
check: reason != 'gift_invalid'
|
|
44
|
+
message: {id: 'Produk gratis tidak sesuai promo hadiah: cek promo, minimal belanja, barang dan jumlahnya'}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# A promo the owner sets up. Item kinds apply by themselves at the counter: flow promotion_apply writes the live one
|
|
3
|
+
# with the highest priority onto each item in scope (item.promo*), and a sale line computes its promo from there.
|
|
4
|
+
# Bill kinds are picked at the counter's checkout and checked by the sale's rules (window, outlet, minimum spend,
|
|
5
|
+
# code). live is kept by promotion_apply (every 5 minutes and on every save): active, today within the dates and days,
|
|
6
|
+
# and now within the hours. Two one-outlet promos on one item at once: only the higher priority one applies there (one
|
|
7
|
+
# outlet slot per item). The outlet field is only_outlet, not outlet: the cashier role is scoped by outlet (contract
|
|
8
|
+
# 0010 §5), and a promo of every outlet (empty) must stay visible to every cashier.
|
|
9
|
+
name: promotion
|
|
10
|
+
label: {id: Promo, en: Promotion}
|
|
11
|
+
icon: tag
|
|
12
|
+
naming: PRM-{####}
|
|
13
|
+
title_field: promo_name
|
|
14
|
+
permissions:
|
|
15
|
+
- {role: head_office, read: true, create: true, write: true, delete: true, export: true, print: true}
|
|
16
|
+
# the cashier picks a bill promo at the counter; flows read the promo inside the sale
|
|
17
|
+
- {role: cashier, read: true}
|
|
18
|
+
- {role: outlet_staff, read: true}
|
|
19
|
+
fields:
|
|
20
|
+
- name: promo_name
|
|
21
|
+
type: data
|
|
22
|
+
label: {id: Nama promo}
|
|
23
|
+
help: {id: 'Tercetak di struk, misalnya Happy hour kopi'}
|
|
24
|
+
required: true
|
|
25
|
+
in_list: true
|
|
26
|
+
- name: kind
|
|
27
|
+
type: select
|
|
28
|
+
label: {id: Jenis promo}
|
|
29
|
+
required: true
|
|
30
|
+
in_list: true
|
|
31
|
+
chip: true
|
|
32
|
+
options:
|
|
33
|
+
- {value: item_pct, label: {id: Diskon persen per barang}}
|
|
34
|
+
- {value: item_off, label: {id: Potongan rupiah per barang}}
|
|
35
|
+
- {value: buy_get, label: {id: Beli X gratis Y}}
|
|
36
|
+
- {value: bill_pct, label: {id: Diskon persen nota}}
|
|
37
|
+
- {value: bill_off, label: {id: Potongan rupiah nota}}
|
|
38
|
+
- {value: free_gift, label: {id: Gratis produk}}
|
|
39
|
+
- name: is_bill
|
|
40
|
+
type: check
|
|
41
|
+
label: {id: Promo nota}
|
|
42
|
+
hidden: true
|
|
43
|
+
compute: "kind == 'bill_pct' || kind == 'bill_off' || kind == 'free_gift'"
|
|
44
|
+
- name: scope
|
|
45
|
+
type: select
|
|
46
|
+
label: {id: Berlaku untuk}
|
|
47
|
+
default: "'item'"
|
|
48
|
+
depends_on: "!is_bill"
|
|
49
|
+
options:
|
|
50
|
+
- {value: item, label: {id: Satu barang}}
|
|
51
|
+
- {value: category, label: {id: Satu kategori}}
|
|
52
|
+
- {name: item, type: link, to: item, label: {id: Barang}, depends_on: "!is_bill && scope == 'item'"}
|
|
53
|
+
- {name: category, type: link, to: item_category, label: {id: Kategori}, depends_on: "!is_bill && scope == 'category'"}
|
|
54
|
+
- {name: pct, type: float, label: {id: 'Diskon %'}, default: '0', depends_on: "kind == 'item_pct' || kind == 'bill_pct'"}
|
|
55
|
+
- name: amount_off
|
|
56
|
+
type: currency
|
|
57
|
+
label: {id: Potongan}
|
|
58
|
+
help: {id: 'Per barang untuk potongan per barang, sekali untuk potongan nota'}
|
|
59
|
+
default: '0'
|
|
60
|
+
depends_on: "kind == 'item_off' || kind == 'bill_off'"
|
|
61
|
+
- name: max_discount
|
|
62
|
+
type: currency
|
|
63
|
+
label: {id: Maksimal potongan}
|
|
64
|
+
help: {id: 'Isi 0 kalau tanpa batas'}
|
|
65
|
+
default: '0'
|
|
66
|
+
depends_on: "kind == 'bill_pct'"
|
|
67
|
+
- {name: buy_qty, type: int, label: {id: Beli}, default: '0', depends_on: "kind == 'buy_get'"}
|
|
68
|
+
- {name: get_qty, type: int, label: {id: Gratis}, default: '0', depends_on: "kind == 'buy_get'"}
|
|
69
|
+
- {name: gift_item, type: link, to: item, label: {id: Produk gratis}, depends_on: "kind == 'free_gift'"}
|
|
70
|
+
- {name: gift_qty, type: int, label: {id: Jumlah gratis}, default: '1', depends_on: "kind == 'free_gift'"}
|
|
71
|
+
- name: min_spend
|
|
72
|
+
type: currency
|
|
73
|
+
label: {id: Minimal belanja}
|
|
74
|
+
help: {id: 'Dihitung dari subtotal setelah promo per barang. Isi 0 kalau tanpa minimal'}
|
|
75
|
+
default: '0'
|
|
76
|
+
depends_on: is_bill
|
|
77
|
+
- name: only_outlet
|
|
78
|
+
type: link
|
|
79
|
+
to: outlet
|
|
80
|
+
label: {id: Outlet}
|
|
81
|
+
help: {id: 'Kosongkan kalau berlaku di semua outlet'}
|
|
82
|
+
in_list: true
|
|
83
|
+
depends_on: app_installed('outlets')
|
|
84
|
+
- {name: valid_from, type: date, label: {id: Berlaku dari}, required: true, default: today(), in_list: true}
|
|
85
|
+
- {name: valid_until, type: date, label: {id: Berlaku sampai}, required: true, in_list: true}
|
|
86
|
+
- name: days
|
|
87
|
+
type: data
|
|
88
|
+
label: {id: Hari}
|
|
89
|
+
help: {id: 'Angka hari dipisah koma, 1 Senin sampai 7 Minggu, misalnya 1,2,3,4,5. Kosongkan untuk setiap hari'}
|
|
90
|
+
- {name: time_from, type: data, label: {id: Jam mulai}, help: {id: 'Misalnya 14:00. Kosongkan untuk sepanjang hari'}}
|
|
91
|
+
- {name: time_until, type: data, label: {id: Jam selesai}, help: {id: 'Misalnya 16:00'}}
|
|
92
|
+
- name: code_mode
|
|
93
|
+
type: select
|
|
94
|
+
label: {id: Kode}
|
|
95
|
+
default: "'none'"
|
|
96
|
+
depends_on: is_bill
|
|
97
|
+
options:
|
|
98
|
+
- {value: none, label: {id: Tanpa kode}}
|
|
99
|
+
- {value: shared, label: {id: Satu kode bersama}}
|
|
100
|
+
- {value: unique, label: {id: Kupon sekali pakai}}
|
|
101
|
+
- name: code
|
|
102
|
+
type: data
|
|
103
|
+
label: {id: Kode voucher}
|
|
104
|
+
help: {id: '4 sampai 16 huruf besar atau angka, misalnya HEMAT10'}
|
|
105
|
+
unique: true
|
|
106
|
+
depends_on: "code_mode == 'shared'"
|
|
107
|
+
# the buyer brings the code: a cashier, outlet staff or a paired device never reads it (audit F3); the sale's
|
|
108
|
+
# rules and flows still check it, so a shared voucher needs the connection
|
|
109
|
+
hidden_for: [cashier, outlet_staff]
|
|
110
|
+
- name: max_uses
|
|
111
|
+
type: int
|
|
112
|
+
label: {id: Batas pemakaian}
|
|
113
|
+
help: {id: 'Isi 0 kalau tanpa batas'}
|
|
114
|
+
default: '0'
|
|
115
|
+
depends_on: "code_mode == 'shared'"
|
|
116
|
+
- name: priority
|
|
117
|
+
type: int
|
|
118
|
+
label: {id: Prioritas}
|
|
119
|
+
help: {id: 'Kalau dua promo kena satu barang, angka lebih besar yang dipakai'}
|
|
120
|
+
default: '0'
|
|
121
|
+
- name: channel
|
|
122
|
+
type: select
|
|
123
|
+
label: {id: Dipakai di}
|
|
124
|
+
default: "'kasir'"
|
|
125
|
+
options:
|
|
126
|
+
- {value: kasir, label: {id: Kasir}}
|
|
127
|
+
- {value: invoice, label: {id: Faktur}}
|
|
128
|
+
- {value: both, label: {id: Kasir dan faktur}}
|
|
129
|
+
- {name: active, type: check, label: {id: Aktif}, default: 'true', in_list: true, in_filter: true}
|
|
130
|
+
- name: live
|
|
131
|
+
type: check
|
|
132
|
+
label: {id: Sedang berlaku}
|
|
133
|
+
help: {id: 'Diperbarui sistem tiap 5 menit: aktif, di rentang tanggal, hari dan jamnya'}
|
|
134
|
+
read_only: true
|
|
135
|
+
in_list: true
|
|
136
|
+
rules:
|
|
137
|
+
- name: kind_fields
|
|
138
|
+
on: save
|
|
139
|
+
check: >-
|
|
140
|
+
(kind != 'item_pct' && kind != 'bill_pct' || pct > 0 && pct <= 100)
|
|
141
|
+
&& (kind != 'item_off' && kind != 'bill_off' || amount_off > 0)
|
|
142
|
+
&& (kind != 'buy_get' || buy_qty >= 1 && get_qty >= 1)
|
|
143
|
+
&& (kind != 'free_gift' || gift_item != '' && gift_qty >= 1)
|
|
144
|
+
message: {id: 'Lengkapi isian jenis promo ini: persen 1 sampai 100, potongan lebih dari 0, beli dan gratis minimal 1, atau produk gratis'}
|
|
145
|
+
- name: item_scope
|
|
146
|
+
on: save
|
|
147
|
+
check: "is_bill || scope == 'item' && item != '' || scope == 'category' && category != ''"
|
|
148
|
+
message: {id: 'Pilih barang atau kategori yang kena promo'}
|
|
149
|
+
- name: dates_order
|
|
150
|
+
on: save
|
|
151
|
+
check: valid_until >= valid_from
|
|
152
|
+
message: {id: Tanggal selesai tidak boleh sebelum tanggal mulai}
|
|
153
|
+
- name: days_format
|
|
154
|
+
on: save
|
|
155
|
+
check: "days == '' || days.matches('^[1-7](,[1-7])*$')"
|
|
156
|
+
message: {id: 'Hari ditulis angka 1 sampai 7 dipisah koma, misalnya 1,2,3,4,5'}
|
|
157
|
+
- name: hours
|
|
158
|
+
on: save
|
|
159
|
+
check: >-
|
|
160
|
+
(time_from == '' && time_until == '')
|
|
161
|
+
|| (time_from.matches('^[0-2][0-9]:[0-5][0-9]$') && time_until.matches('^[0-2][0-9]:[0-5][0-9]$') && time_from < time_until)
|
|
162
|
+
message: {id: 'Jam ditulis seperti 14:00, dan jam mulai sebelum jam selesai'}
|
|
163
|
+
- name: code_only_bill
|
|
164
|
+
on: save
|
|
165
|
+
check: "code_mode == 'none' || code_mode == '' || is_bill"
|
|
166
|
+
message: {id: 'Kode voucher atau kupon hanya untuk promo nota'}
|
|
167
|
+
- name: code_format
|
|
168
|
+
on: save
|
|
169
|
+
check: "code_mode != 'shared' || code.matches('^[A-Z0-9]{4,16}$')"
|
|
170
|
+
message: {id: 'Kode voucher 4 sampai 16 huruf besar atau angka, tanpa spasi'}
|
|
171
|
+
- name: invoice_item_pct
|
|
172
|
+
on: save
|
|
173
|
+
check: "channel == 'kasir' || channel == '' || kind == 'item_pct'"
|
|
174
|
+
message: {id: 'Di faktur hanya diskon persen per barang yang bisa dipakai'}
|
|
175
|
+
- {name: not_negative, on: save, check: "max_discount >= 0 && min_spend >= 0 && max_uses >= 0", message: {id: 'Angka promo tidak boleh negatif'}}
|
|
176
|
+
views:
|
|
177
|
+
list:
|
|
178
|
+
columns: [name, promo_name, kind, only_outlet, valid_from, valid_until, active, live]
|
|
179
|
+
filters: [kind, active, live, only_outlet]
|
|
180
|
+
sort: -name
|
|
181
|
+
form:
|
|
182
|
+
layout:
|
|
183
|
+
- section: {id: Promo}
|
|
184
|
+
columns:
|
|
185
|
+
- [promo_name, kind, channel]
|
|
186
|
+
- [active, live, priority]
|
|
187
|
+
- section: {id: Isi promo}
|
|
188
|
+
columns:
|
|
189
|
+
- [scope, item, category, pct, amount_off, max_discount]
|
|
190
|
+
- [buy_qty, get_qty, gift_item, gift_qty, min_spend]
|
|
191
|
+
- section: {id: Kapan dan di mana}
|
|
192
|
+
columns:
|
|
193
|
+
- [valid_from, valid_until, only_outlet]
|
|
194
|
+
- [days, time_from, time_until]
|
|
195
|
+
- section: {id: Kode}
|
|
196
|
+
columns:
|
|
197
|
+
- [code_mode, code, max_uses]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# What promos cost, one row per promo used on a paid sale (flow promotion_on_sale) and a negated row when the sale is
|
|
3
|
+
# voided (promotion_on_sale_cancel). Append-only (contract 0026): rows are never edited or deleted. A voucher's uses
|
|
4
|
+
# and a coupon's state are counted here (post rows minus reverse rows), under the flow read lock of contract 0025.
|
|
5
|
+
# The outlet field is sale_outlet, not outlet: the cashier's flow must count every outlet's uses of a shared voucher,
|
|
6
|
+
# and the cashier role is scoped by outlet. The cashier reads rows only for that count; the money is hidden from it.
|
|
7
|
+
name: promotion_ledger
|
|
8
|
+
label: {id: Pemakaian promo, en: Promotion use}
|
|
9
|
+
icon: history
|
|
10
|
+
naming: PRL-{YYYY}-{######}
|
|
11
|
+
append_only: true
|
|
12
|
+
permissions:
|
|
13
|
+
# create: the flows of a void or a coupon batch run as whoever started them; nobody creates a row by hand (append_only)
|
|
14
|
+
- {role: head_office, read: true, create: true, export: true}
|
|
15
|
+
- {role: cashier, read: true, create: true}
|
|
16
|
+
fields:
|
|
17
|
+
- {name: promotion, type: link, to: promotion, label: {id: Promo}, required: true, in_list: true}
|
|
18
|
+
- {name: sale, type: data, label: {id: Struk}, in_list: true}
|
|
19
|
+
- {name: sale_outlet, type: link, to: outlet, label: {id: Outlet}, in_list: true}
|
|
20
|
+
- {name: date, type: date, label: {id: Tanggal}, in_list: true}
|
|
21
|
+
- {name: code, type: data, label: {id: Kode voucher atau kupon}, index: true}
|
|
22
|
+
- {name: amount, type: currency, label: {id: Biaya promo}, in_list: true, hidden_for: [cashier]}
|
|
23
|
+
- name: entry
|
|
24
|
+
type: select
|
|
25
|
+
label: {id: Catatan}
|
|
26
|
+
required: true
|
|
27
|
+
options:
|
|
28
|
+
- {value: post, label: {id: Dipakai}}
|
|
29
|
+
- {value: reverse, label: {id: Dibatalkan}}
|
|
30
|
+
- {name: entry_key, type: data, label: {id: Kunci}, unique: true, hidden: true}
|
|
31
|
+
views:
|
|
32
|
+
list:
|
|
33
|
+
columns: [name, date, promotion, sale, sale_outlet, amount, entry]
|
|
34
|
+
filters: [promotion, sale_outlet, entry]
|
|
35
|
+
sort: -name
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
|
|
2
|
+
name: promotions
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
title: {id: Promo, en: Promotions}
|
|
5
|
+
summary:
|
|
6
|
+
id: Promo diskon, beli X gratis Y, voucher dan kupon di kasir.
|
|
7
|
+
en: Discounts, buy X get Y, vouchers and coupons at the counter.
|
|
8
|
+
category: sales
|
|
9
|
+
icon: price-tag-3-line
|
|
10
|
+
# Owner-defined promotions (rangka-apps#103). Item promos (percent, rupiah off per unit, buy X get Y) are written onto
|
|
11
|
+
# the items they cover by flow promotion_apply while they are live (dates, days, hours), so a sale line computes its
|
|
12
|
+
# promo from the item like its price, also on an offline device (rangka-os contract 0058 §10). Bill promos (percent
|
|
13
|
+
# with a cap, rupiah off, a free gift) are picked at the counter's checkout (rangka-os contract 0069), optionally with
|
|
14
|
+
# a shared voucher code (a use limit) or a single-use coupon from a generated batch; flow promotion_on_sale checks the
|
|
15
|
+
# code and the limit under the ledger's lock and writes promotion_ledger, the promo's cost per sale. The books need no
|
|
16
|
+
# new account: a promo lowers the sale's grand_total, which the accounting module posts net. Invoices take an item
|
|
17
|
+
# promo of channel invoice or both as the default line discount (module invoicing).
|
|
18
|
+
# outlets is optional: a services site (invoices only, no outlets) can use invoice promos
|
|
19
|
+
requires: {rangka: '>=0.5', users: ^1.2, catalogue: ^1.5}
|
|
20
|
+
optional: {outlets: ^1.5, pos: ^1.4, invoicing: ^1.13}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
name: alat_keluar
|
|
3
3
|
type: handover
|
|
4
4
|
label: {id: Serah alat keluar, en: Equipment out}
|
|
5
|
+
description: {id: 'Serahkan alat ke penyewa: pindai alat, foto kondisinya, lalu minta tanda tangan.'}
|
|
5
6
|
icon: truck
|
|
6
7
|
# Equipment goes out with proof (contract 0030 §2 handover, WS8): scan each unit (rental_unit.code), mark its
|
|
7
8
|
# condition, at least one photo, the renter signs, submit, print the BAST. Opened from jadwal_alat, the new draft gets
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
name: alat_kembali
|
|
3
3
|
type: handover
|
|
4
4
|
label: {id: Terima alat kembali, en: Equipment back}
|
|
5
|
+
description: {id: 'Terima alat yang kembali: pindai alat, catat kondisinya, foto, lalu minta tanda tangan.'}
|
|
5
6
|
icon: undo
|
|
6
7
|
# Equipment comes back with proof (contract 0030 §2 handover): scan each unit, mark its condition (Hilang for a lost
|
|
7
8
|
# one), photos of the damage, the renter signs. The warehouse only saves the checklist (submit: false): the damage
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
name: jadwal_alat
|
|
3
3
|
type: route
|
|
4
4
|
label: {id: Jadwal alat hari ini, en: Today's equipment}
|
|
5
|
+
description: {id: 'Alat yang keluar dan kembali hari ini; buka satu untuk serah keluar atau terima kembali.'}
|
|
5
6
|
icon: calendar
|
|
6
7
|
# The warehouse's list of the day (plans/layar-kerja.md §3 #6-7): bookings whose equipment goes out today (or is
|
|
7
8
|
# overdue to go out) and those due back today or late. Each opens the handover screen with the booking prefilled
|