@rangka-os/create 0.5.0-alpha.27 → 0.5.0-alpha.29
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 +4 -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/apps/pembukuan/app.rk +3 -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/accounting/flows/gl_asset_disposal_post.rk +68 -0
- package/template/base/modules/accounting/flows/gl_asset_disposal_reverse.rk +194 -0
- package/template/base/modules/accounting/flows/gl_depreciation_run_post.rk +43 -0
- package/template/base/modules/accounting/flows/gl_depreciation_run_reverse.rk +36 -0
- package/template/base/modules/accounting/flows/gl_fixed_asset_post.rk +51 -0
- package/template/base/modules/accounting/flows/gl_fixed_asset_reverse.rk +194 -0
- package/template/base/modules/accounting/flows/gl_vendor_bill_post.rk +2 -2
- package/template/base/modules/accounting/models/gl_entry.rk +2 -0
- package/template/base/modules/accounting/module.rk +2 -2
- 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/fixed_assets/flows/asset_disposal_on_cancel.rk +14 -0
- package/template/base/modules/fixed_assets/flows/asset_disposal_on_submit.rk +21 -0
- package/template/base/modules/fixed_assets/flows/asset_from_vendor_bill.rk +41 -0
- package/template/base/modules/fixed_assets/flows/depreciation_run_fill.rk +28 -0
- package/template/base/modules/fixed_assets/flows/depreciation_run_monthly.rk +36 -0
- package/template/base/modules/fixed_assets/flows/depreciation_run_on_cancel.rk +30 -0
- package/template/base/modules/fixed_assets/flows/depreciation_run_on_submit.rk +34 -0
- package/template/base/modules/fixed_assets/flows/fixed_asset_on_cancel.rk +24 -0
- package/template/base/modules/fixed_assets/flows/fixed_asset_on_submit.rk +69 -0
- package/template/base/modules/fixed_assets/flows/fixed_assets_setup.rk +29 -0
- package/template/base/modules/fixed_assets/flows/opening_balance_asset_guard.rk +15 -0
- package/template/base/modules/fixed_assets/flows/vendor_bill_asset_guard.rk +14 -0
- package/template/base/modules/fixed_assets/imports/asset_list.rk +22 -0
- package/template/base/modules/fixed_assets/models/asset_bill_line.rk +24 -0
- package/template/base/modules/fixed_assets/models/asset_book.rk +83 -0
- package/template/base/modules/fixed_assets/models/asset_category.rk +54 -0
- package/template/base/modules/fixed_assets/models/asset_disposal.rk +97 -0
- package/template/base/modules/fixed_assets/models/asset_guard.rk +90 -0
- package/template/base/modules/fixed_assets/models/depreciation_line.rk +13 -0
- package/template/base/modules/fixed_assets/models/depreciation_run.rk +65 -0
- package/template/base/modules/fixed_assets/models/fixed_asset.rk +165 -0
- package/template/base/modules/fixed_assets/models/fixed_asset_setting.rk +34 -0
- package/template/base/modules/fixed_assets/module.rk +30 -0
- package/template/base/modules/fixed_assets/print/fixed_asset_register.html +45 -0
- package/template/base/modules/fixed_assets/print/fixed_asset_register.rk +17 -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 +21 -2
- 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/models/rental_unit.rk +13 -3
- package/template/base/modules/rental/module.rk +2 -2
- 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
|
@@ -155,7 +155,8 @@ fields:
|
|
|
155
155
|
in_list: true
|
|
156
156
|
# Accounting (module accounting): what the bill pays for. A project's cost goes to Biaya proyek; goods received
|
|
157
157
|
# into stock through a goods receipt or PO (or consigned goods sold) clear "Utang belum ditagih", only where the
|
|
158
|
-
# stock module keeps stock;
|
|
158
|
+
# stock module keeps stock; a fixed asset (module fixed_assets) to Aset tetap, one draft asset per line (flow
|
|
159
|
+
# asset_from_vendor_bill); anything else to the expense account chosen. The default follows the links on the bill.
|
|
159
160
|
- name: posting
|
|
160
161
|
type: select
|
|
161
162
|
label: {id: Dicatat sebagai}
|
|
@@ -165,6 +166,7 @@ fields:
|
|
|
165
166
|
- {value: stock, label: {id: Barang dagang atau bahan (sudah diterima)}}
|
|
166
167
|
- {value: project, label: {id: Biaya proyek}}
|
|
167
168
|
- {value: expense, label: {id: Beban operasional}}
|
|
169
|
+
- {value: asset, label: {id: Aset tetap}}
|
|
168
170
|
- name: expense_account
|
|
169
171
|
type: select
|
|
170
172
|
label: {id: Akun beban}
|
|
@@ -182,7 +184,9 @@ fields:
|
|
|
182
184
|
type: text
|
|
183
185
|
label: {id: Catatan}
|
|
184
186
|
- {name: currency, type: data, label: {id: Mata uang}, default: "'IDR'"}
|
|
185
|
-
|
|
187
|
+
# IDR per 1 unit of the foreign currency. With PPN on the bill in a PKP org the submit waits for finance (approval
|
|
188
|
+
# fx_rate_check): the rupiah DPP and input PPN (PPN masukan) follow this kurs, which must be the KMK kurs (PP 44/2022 art. 21).
|
|
189
|
+
- {name: exchange_rate, type: float, label: {id: Kurs}, default: '1', help: {id: 'Rupiah per 1 unit valas. PPN masukan memakai kurs Menteri Keuangan (KMK) minggu tanggal faktur; bagian keuangan memeriksanya.'}}
|
|
186
190
|
- {name: subtotal_fx, type: money, currency_field: currency, rate_field: exchange_rate, label: {id: Subtotal (valas)}, compute: "sum(items.map(i, i.amount_fx))"}
|
|
187
191
|
- {name: dpp_fx, type: money, currency_field: currency, rate_field: exchange_rate, label: {id: DPP (valas)}, compute: "subtotal_fx"}
|
|
188
192
|
- {name: ppn_fx, type: money, currency_field: currency, rate_field: exchange_rate, label: {id: PPN (valas)}, compute: "round(dpp_fx * dpp_num / dpp_den * tax_rate / 100, 2)"}
|
|
@@ -193,6 +197,10 @@ rules:
|
|
|
193
197
|
on: save
|
|
194
198
|
check: posting != 'stock' || app_installed('stock')
|
|
195
199
|
message: {id: Tagihan barang dagang hanya untuk usaha yang mencatat stok; pilih Beban operasional atau Biaya proyek}
|
|
200
|
+
- name: posting_asset_needs_module
|
|
201
|
+
on: save
|
|
202
|
+
check: "posting != 'asset' || (app_installed('fixed_assets') && (currency == '' || currency == 'IDR') && (goods_receipt == '' || !app_installed('stock')))"
|
|
203
|
+
message: {id: 'Tagihan aset tetap hanya untuk usaha yang memakai modul Aset tetap, dalam rupiah, dan tanpa penerimaan barang ke stok'}
|
|
196
204
|
- name: posting_project_needs_project
|
|
197
205
|
on: save
|
|
198
206
|
check: (posting != 'project' || project != '') && (project == '' || posting == 'project' || posting == null)
|
|
@@ -255,6 +263,17 @@ rules:
|
|
|
255
263
|
on: save
|
|
256
264
|
check: "items.map(i, i.rate < 0 || i.rate_fx < 0 ? 1 : 0).sum() == 0"
|
|
257
265
|
message: {id: Harga tidak boleh negatif}
|
|
266
|
+
approvals:
|
|
267
|
+
# The kurs of a foreign bill sets its rupiah DPP and the input PPN credited in the SPT (card t_d7bf36b3; audit
|
|
268
|
+
# ppn-base-fx N1, the purchase-side twin of sales_invoice fx_rate_check). A purchasing_manager must still draft the
|
|
269
|
+
# bill with its kurs, so the submit waits for finance instead of a field lock; read from the stored draft, so amend
|
|
270
|
+
# copies and drafts from before the upgrade are covered. Finance and the owner approve their own. A bill without PPN
|
|
271
|
+
# (non-PKP vendor or org) credits no PPN masukan and is left to the site's own spending approvals.
|
|
272
|
+
- name: fx_rate_check
|
|
273
|
+
on: submit
|
|
274
|
+
when: "tax.pkp && tax_rate > 0 && currency != '' && currency != 'IDR'"
|
|
275
|
+
approvers: [finance_manager]
|
|
276
|
+
label: {id: 'Tagihan valas dengan PPN: kurs pajak (KMK) perlu diperiksa keuangan', en: 'Foreign-currency bill with PPN: finance checks the tax rate (KMK)'}
|
|
258
277
|
views:
|
|
259
278
|
list:
|
|
260
279
|
columns: [name, vendor, bill_no, bill_date, due_date, status, amount_due, outstanding]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
|
|
2
2
|
name: procurement
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.4.0
|
|
4
4
|
title: {id: Pembelian, en: Procurement}
|
|
5
5
|
summary:
|
|
6
6
|
id: Permintaan dan pesanan pembelian, barang datang dan tagihan pemasok.
|
|
@@ -8,7 +8,16 @@ summary:
|
|
|
8
8
|
category: purchasing
|
|
9
9
|
icon: shopping-bag-line
|
|
10
10
|
requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0}
|
|
11
|
-
optional: {outlets: ^1.0, currency: ^1.0, stock: ^1.
|
|
11
|
+
optional: {outlets: ^1.0, currency: ^1.0, stock: ^1.4, projects: ^1.0, fixed_assets: ^1.0}
|
|
12
12
|
# Semantics fixed in docs/kernel-hooks.md (section procurement). stock.post_moves is a core hook (goods_receipt.on_submit);
|
|
13
13
|
# stock.reverse_moves (goods_receipt.on_cancel) is declared here too, since stock is optional for procurement (a no-op without it).
|
|
14
14
|
hooks: [procurement.make_po, procurement.receive, procurement.post_payable, procurement.reverse_payable, stock.reverse_moves]
|
|
15
|
+
# What this module tells people (contract 0066 §1.1). reorder_draft: flow reorder_draft_po made a draft purchase order
|
|
16
|
+
# for items below their reorder level; only roles that may read purchase orders are told.
|
|
17
|
+
notices:
|
|
18
|
+
- name: reorder_draft
|
|
19
|
+
label: {id: Draft pesanan pembelian stok menipis, en: Draft purchase order for low stock}
|
|
20
|
+
description: {id: 'Draft pesanan pembelian dibuat untuk barang di bawah batas stok minimum. Draft menunggu kamu periksa dan ajukan.'}
|
|
21
|
+
severity: warn
|
|
22
|
+
to: [owner, purchasing_manager, head_office]
|
|
23
|
+
can: {model: purchase_order, action: read}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
name: absen
|
|
3
3
|
type: clock
|
|
4
4
|
label: {id: Absen, en: Clock in}
|
|
5
|
+
description: {id: 'Absen masuk dan pulang di lokasi kerja dari HP, dengan foto; di luar radius, tulis alasannya untuk mandor.'}
|
|
5
6
|
icon: clock
|
|
6
7
|
# A worker clocks in and out at the client's site from their phone (plans/layar-kerja.md §3 #2, contract 0030 §2 clock).
|
|
7
8
|
# The site is today's assignment (the worker cannot read the firm's list of client sites, only their own assignments),
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# A submitted batch makes its coupons: count codes of prefix + 8 characters from random_code() (rangka-os contract 0069
|
|
3
|
+
# §3; 31^8 combinations, so a code cannot be guessed from another). A flow has no range, so the batch walks three
|
|
4
|
+
# digits (at most 1000 codes). A code that happened to exist already fails the unique check and the batch rolls back
|
|
5
|
+
# whole; submit it again.
|
|
6
|
+
name: promo_code_batch_on_submit
|
|
7
|
+
label: {id: 'Kiriman kupon diajukan: buat kode kupon'}
|
|
8
|
+
on: promo_code_batch.submitted
|
|
9
|
+
steps:
|
|
10
|
+
- for_each: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
|
|
11
|
+
as: a
|
|
12
|
+
do:
|
|
13
|
+
- for_each: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
|
|
14
|
+
as: b
|
|
15
|
+
if: a * 100 < event.count
|
|
16
|
+
do:
|
|
17
|
+
- for_each: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
|
|
18
|
+
as: c
|
|
19
|
+
if: a * 100 + b * 10 < event.count
|
|
20
|
+
do:
|
|
21
|
+
- create: promo_code
|
|
22
|
+
if: a * 100 + b * 10 + c < event.count
|
|
23
|
+
set:
|
|
24
|
+
promotion: event.promotion
|
|
25
|
+
code: event.prefix + random_code(8)
|
|
26
|
+
batch: event.name
|
|
@@ -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). Every 5 minutes: promos start and end on their dates, days and hours (happy hour precision 5 minutes).
|
|
3
|
+
name: promotion_apply
|
|
4
|
+
label: {id: 'Promo: perbarui yang sedang berlaku'}
|
|
5
|
+
schedule: '*/5 * * * *'
|
|
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,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 new promo reaches the items at once.
|
|
3
|
+
name: promotion_apply_on_create
|
|
4
|
+
label: {id: 'Promo baru: pasang ke barang'}
|
|
5
|
+
on: promotion.created
|
|
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,111 @@
|
|
|
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 deleted promo leaves the items at once (it runs in the delete, before the row goes, so it leaves the promo out).
|
|
3
|
+
name: promotion_apply_on_delete
|
|
4
|
+
label: {id: 'Promo dihapus: lepas dari barang'}
|
|
5
|
+
on: promotion.deleted
|
|
6
|
+
steps:
|
|
7
|
+
# 1. live: active, in its dates, days and hours now
|
|
8
|
+
- find_all: promotion
|
|
9
|
+
where: "name != event.name"
|
|
10
|
+
as: all
|
|
11
|
+
- for_each: all
|
|
12
|
+
as: p
|
|
13
|
+
do:
|
|
14
|
+
- update: p
|
|
15
|
+
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))"
|
|
16
|
+
set:
|
|
17
|
+
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)"
|
|
18
|
+
# 2. the live item promos for the counter, all outlets (kg) and one outlet (ko), and for invoices (vs)
|
|
19
|
+
- find_all: promotion
|
|
20
|
+
where: "live && !is_bill && channel != 'invoice' && only_outlet == '' && name != event.name"
|
|
21
|
+
as: kg
|
|
22
|
+
- find_all: promotion
|
|
23
|
+
where: "live && !is_bill && channel != 'invoice' && only_outlet != '' && name != event.name"
|
|
24
|
+
as: ko
|
|
25
|
+
- find_all: promotion
|
|
26
|
+
where: "live && kind == 'item_pct' && channel != 'kasir' && only_outlet == '' && name != event.name"
|
|
27
|
+
as: vs
|
|
28
|
+
# items that carry a promo now (it may have ended) ...
|
|
29
|
+
- find_all: item
|
|
30
|
+
where: "promo != '' || promo_o != '' || promo_invoice_pct != 0"
|
|
31
|
+
as: had
|
|
32
|
+
- for_each: had
|
|
33
|
+
as: it
|
|
34
|
+
do:
|
|
35
|
+
- 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)]"
|
|
36
|
+
as: w
|
|
37
|
+
do:
|
|
38
|
+
- 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)]"
|
|
39
|
+
as: v
|
|
40
|
+
do:
|
|
41
|
+
- 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)]"
|
|
42
|
+
as: o
|
|
43
|
+
do:
|
|
44
|
+
- update: it
|
|
45
|
+
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)"
|
|
46
|
+
set:
|
|
47
|
+
promo: "w.size() > 0 ? w[0].name : ''"
|
|
48
|
+
promo_name: "w.size() > 0 ? w[0].promo_name : ''"
|
|
49
|
+
promo_kind: "w.size() == 0 ? '' : (w[0].kind == 'item_pct' ? 'pct' : (w[0].kind == 'item_off' ? 'off' : 'buy_get'))"
|
|
50
|
+
promo_pct: "w.size() > 0 && w[0].kind == 'item_pct' ? w[0].pct : 0"
|
|
51
|
+
promo_off: "w.size() > 0 && w[0].kind == 'item_off' ? w[0].amount_off : 0"
|
|
52
|
+
promo_buy: "w.size() > 0 && w[0].kind == 'buy_get' ? w[0].buy_qty : 0"
|
|
53
|
+
promo_get: "w.size() > 0 && w[0].kind == 'buy_get' ? w[0].get_qty : 0"
|
|
54
|
+
promo_until: "w.size() > 0 ? w[0].valid_until : null"
|
|
55
|
+
promo_invoice_pct: "v.size() > 0 ? v[0].pct : 0"
|
|
56
|
+
promo_outlet: "''"
|
|
57
|
+
promo_o: "o.size() > 0 ? o[0].name : ''"
|
|
58
|
+
promo_o_name: "o.size() > 0 ? o[0].promo_name : ''"
|
|
59
|
+
promo_o_kind: "o.size() == 0 ? '' : (o[0].kind == 'item_pct' ? 'pct' : (o[0].kind == 'item_off' ? 'off' : 'buy_get'))"
|
|
60
|
+
promo_o_pct: "o.size() > 0 && o[0].kind == 'item_pct' ? o[0].pct : 0"
|
|
61
|
+
promo_o_off: "o.size() > 0 && o[0].kind == 'item_off' ? o[0].amount_off : 0"
|
|
62
|
+
promo_o_buy: "o.size() > 0 && o[0].kind == 'buy_get' ? o[0].buy_qty : 0"
|
|
63
|
+
promo_o_get: "o.size() > 0 && o[0].kind == 'buy_get' ? o[0].get_qty : 0"
|
|
64
|
+
promo_o_outlet: "o.size() > 0 ? o[0].only_outlet : ''"
|
|
65
|
+
promo_o_until: "o.size() > 0 ? o[0].valid_until : null"
|
|
66
|
+
# ... and the items each live item promo covers
|
|
67
|
+
- for_each: kg + ko + vs
|
|
68
|
+
as: pr
|
|
69
|
+
do:
|
|
70
|
+
- find_all: item
|
|
71
|
+
if: "pr.scope == 'item'"
|
|
72
|
+
where: name == pr.item
|
|
73
|
+
as: one
|
|
74
|
+
- find_all: item
|
|
75
|
+
if: "pr.scope == 'category'"
|
|
76
|
+
where: category == pr.category
|
|
77
|
+
as: cat
|
|
78
|
+
- for_each: "pr.scope == 'item' ? one : cat"
|
|
79
|
+
as: it
|
|
80
|
+
do:
|
|
81
|
+
- 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)]"
|
|
82
|
+
as: w
|
|
83
|
+
do:
|
|
84
|
+
- 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)]"
|
|
85
|
+
as: v
|
|
86
|
+
do:
|
|
87
|
+
- 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)]"
|
|
88
|
+
as: o
|
|
89
|
+
do:
|
|
90
|
+
- update: it
|
|
91
|
+
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)"
|
|
92
|
+
set:
|
|
93
|
+
promo: "w.size() > 0 ? w[0].name : ''"
|
|
94
|
+
promo_name: "w.size() > 0 ? w[0].promo_name : ''"
|
|
95
|
+
promo_kind: "w.size() == 0 ? '' : (w[0].kind == 'item_pct' ? 'pct' : (w[0].kind == 'item_off' ? 'off' : 'buy_get'))"
|
|
96
|
+
promo_pct: "w.size() > 0 && w[0].kind == 'item_pct' ? w[0].pct : 0"
|
|
97
|
+
promo_off: "w.size() > 0 && w[0].kind == 'item_off' ? w[0].amount_off : 0"
|
|
98
|
+
promo_buy: "w.size() > 0 && w[0].kind == 'buy_get' ? w[0].buy_qty : 0"
|
|
99
|
+
promo_get: "w.size() > 0 && w[0].kind == 'buy_get' ? w[0].get_qty : 0"
|
|
100
|
+
promo_until: "w.size() > 0 ? w[0].valid_until : null"
|
|
101
|
+
promo_invoice_pct: "v.size() > 0 ? v[0].pct : 0"
|
|
102
|
+
promo_outlet: "''"
|
|
103
|
+
promo_o: "o.size() > 0 ? o[0].name : ''"
|
|
104
|
+
promo_o_name: "o.size() > 0 ? o[0].promo_name : ''"
|
|
105
|
+
promo_o_kind: "o.size() == 0 ? '' : (o[0].kind == 'item_pct' ? 'pct' : (o[0].kind == 'item_off' ? 'off' : 'buy_get'))"
|
|
106
|
+
promo_o_pct: "o.size() > 0 && o[0].kind == 'item_pct' ? o[0].pct : 0"
|
|
107
|
+
promo_o_off: "o.size() > 0 && o[0].kind == 'item_off' ? o[0].amount_off : 0"
|
|
108
|
+
promo_o_buy: "o.size() > 0 && o[0].kind == 'buy_get' ? o[0].buy_qty : 0"
|
|
109
|
+
promo_o_get: "o.size() > 0 && o[0].kind == 'buy_get' ? o[0].get_qty : 0"
|
|
110
|
+
promo_o_outlet: "o.size() > 0 ? o[0].only_outlet : ''"
|
|
111
|
+
promo_o_until: "o.size() > 0 ? o[0].valid_until : null"
|
|
@@ -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"
|