@rangka-os/create 0.5.0-alpha.5 → 0.5.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/fnb_cabang/dashboards/stock_recap.rk +6 -4
  3. package/template/base/apps/grosir_distribusi/app.rk +48 -0
  4. package/template/base/apps/grosir_distribusi/dashboards/grosir_ar.rk +62 -0
  5. package/template/base/apps/grosir_distribusi/dashboards/grosir_overview.rk +85 -0
  6. package/template/base/apps/jasa_proyek/app.rk +5 -4
  7. package/template/base/apps/jasa_proyek/dashboards/jasa_overview.rk +20 -0
  8. package/template/base/apps/jasa_proyek/dashboards/project_margin.rk +66 -0
  9. package/template/base/apps/jasa_proyek/processes/quote_to_cash.rk +2 -1
  10. package/template/base/apps/produksi_pabrik/app.rk +46 -0
  11. package/template/base/apps/produksi_pabrik/dashboards/produksi_overview.rk +96 -0
  12. package/template/base/apps/produksi_pabrik/dashboards/produksi_upah.rk +39 -0
  13. package/template/base/apps/ritel_cabang/app.rk +50 -0
  14. package/template/base/apps/ritel_cabang/dashboards/ritel_overview.rk +123 -0
  15. package/template/base/apps/ritel_cabang/dashboards/ritel_stock.rk +146 -0
  16. package/template/base/apps/ritel_cabang/dashboards/ritel_tax.rk +76 -0
  17. package/template/base/connectors/loyverse/connector.rk +93 -0
  18. package/template/base/connectors/moka/connector.rk +81 -0
  19. package/template/base/connectors/whatsapp_business/connector.rk +16 -0
  20. package/template/base/connectors/whatsapp_business/templates.md +32 -0
  21. package/template/base/connectors/xendit/connector.rk +179 -0
  22. package/template/base/modules/bank_statement/flows/bank_transaction_claim.rk +19 -0
  23. package/template/base/modules/bank_statement/flows/bank_transaction_confirm.rk +43 -0
  24. package/template/base/modules/bank_statement/flows/bank_transaction_link_locked.rk +11 -0
  25. package/template/base/modules/bank_statement/flows/bank_transaction_matched.rk +13 -0
  26. package/template/base/modules/bank_statement/flows/bank_transaction_release.rk +11 -0
  27. package/template/base/modules/bank_statement/flows/bank_transaction_suggest.rk +21 -0
  28. package/template/base/modules/bank_statement/flows/bank_transaction_unmatched.rk +11 -0
  29. package/template/base/modules/bank_statement/imports/bank_statement_csv.rk +25 -0
  30. package/template/base/modules/bank_statement/models/bank_transaction.rk +124 -0
  31. package/template/base/modules/bank_statement/models/bank_transaction_claim.rk +49 -0
  32. package/template/base/modules/bank_statement/module.rk +7 -0
  33. package/template/base/modules/catalogue/imports/item_list.rk +20 -0
  34. package/template/base/modules/catalogue/imports/item_master.rk +25 -0
  35. package/template/base/modules/catalogue/models/item.rk +56 -1
  36. package/template/base/modules/catalogue/models/item_category.rk +27 -0
  37. package/template/base/modules/catalogue/models/uom.rk +1 -0
  38. package/template/base/modules/catalogue/module.rk +2 -1
  39. package/template/base/modules/consignment/flows/consignment_bill.rk +36 -0
  40. package/template/base/modules/consignment/flows/consignment_bill_cancelled.rk +14 -0
  41. package/template/base/modules/consignment/models/consignment_settlement.rk +93 -0
  42. package/template/base/modules/consignment/models/consignment_settlement_item.rk +37 -0
  43. package/template/base/modules/consignment/module.rk +10 -0
  44. package/template/base/modules/contacts/imports/customer_list.rk +17 -0
  45. package/template/base/modules/contacts/imports/vendor_list.rk +16 -0
  46. package/template/base/modules/contacts/models/customer.rk +58 -1
  47. package/template/base/modules/contacts/module.rk +1 -1
  48. package/template/base/modules/delivery/flows/delivery_cancel_guard.rk +18 -0
  49. package/template/base/modules/delivery/flows/fulfilment_on_delivery_cancelled.rk +21 -0
  50. package/template/base/modules/delivery/flows/fulfilment_on_delivery_submitted.rk +21 -0
  51. package/template/base/modules/delivery/flows/fulfilment_on_invoice_cancelled.rk +22 -0
  52. package/template/base/modules/delivery/flows/fulfilment_on_invoice_submitted.rk +22 -0
  53. package/template/base/modules/delivery/flows/fulfilment_on_order_created.rk +18 -0
  54. package/template/base/modules/delivery/flows/fulfilment_on_order_submitted.rk +16 -0
  55. package/template/base/modules/delivery/flows/fulfilment_on_order_updated.rk +19 -0
  56. package/template/base/modules/delivery/flows/fulfilment_on_return_cancelled.rk +16 -0
  57. package/template/base/modules/delivery/flows/fulfilment_on_return_submitted.rk +16 -0
  58. package/template/base/modules/delivery/flows/invoice_qty_from_deliveries.rk +20 -0
  59. package/template/base/modules/delivery/flows/order_cancel_guard.rk +10 -0
  60. package/template/base/modules/delivery/flows/return_cancel_guard.rk +11 -0
  61. package/template/base/modules/delivery/flows/return_credit_on_payment_cancelled.rk +11 -0
  62. package/template/base/modules/delivery/flows/return_credit_on_payment_submitted.rk +21 -0
  63. package/template/base/modules/delivery/flows/return_credit_on_return_cancelled.rk +11 -0
  64. package/template/base/modules/delivery/flows/return_credit_on_return_submitted.rk +10 -0
  65. package/template/base/modules/delivery/models/delivery_guard.rk +48 -0
  66. package/template/base/modules/delivery/models/delivery_note.rk +94 -0
  67. package/template/base/modules/delivery/models/delivery_note_item.rk +9 -0
  68. package/template/base/modules/delivery/models/order_fulfilment.rk +27 -0
  69. package/template/base/modules/delivery/models/order_fulfilment_item.rk +10 -0
  70. package/template/base/modules/delivery/models/return_credit.rk +23 -0
  71. package/template/base/modules/delivery/models/sales_return.rk +87 -0
  72. package/template/base/modules/delivery/models/sales_return_item.rk +16 -0
  73. package/template/base/modules/delivery/module.rk +11 -0
  74. package/template/base/modules/distribution/flows/credit_on_invoice_cancelled.rk +17 -0
  75. package/template/base/modules/distribution/flows/credit_on_invoice_submitted.rk +17 -0
  76. package/template/base/modules/distribution/flows/credit_on_order_cancelled.rk +17 -0
  77. package/template/base/modules/distribution/flows/credit_on_order_submitted.rk +17 -0
  78. package/template/base/modules/distribution/flows/credit_on_payment_cancelled.rk +17 -0
  79. package/template/base/modules/distribution/flows/credit_on_payment_submitted.rk +17 -0
  80. package/template/base/modules/distribution/flows/giro_bounced.rk +20 -0
  81. package/template/base/modules/distribution/flows/giro_from_payment.rk +21 -0
  82. package/template/base/modules/distribution/flows/order_tier_pricing_created.rk +17 -0
  83. package/template/base/modules/distribution/flows/order_tier_pricing_updated.rk +17 -0
  84. package/template/base/modules/distribution/models/giro.rk +79 -0
  85. package/template/base/modules/distribution/module.rk +9 -0
  86. package/template/base/modules/invoicing/flows/invoice_due_digest.rk +12 -0
  87. package/template/base/modules/invoicing/flows/milestone_invoiced.rk +23 -0
  88. package/template/base/modules/invoicing/flows/milestone_reopened.rk +19 -0
  89. package/template/base/modules/invoicing/flows/project_billed_on_cancel.rk +16 -0
  90. package/template/base/modules/invoicing/flows/project_billed_on_submit.rk +16 -0
  91. package/template/base/modules/invoicing/flows/project_revenue_on_cancel.rk +22 -0
  92. package/template/base/modules/invoicing/flows/project_revenue_on_submit.rk +17 -0
  93. package/template/base/modules/invoicing/models/invoice_reminder.rk +83 -0
  94. package/template/base/modules/invoicing/models/sales_invoice.rk +108 -3
  95. package/template/base/modules/invoicing/models/sales_invoice_item.rk +9 -0
  96. package/template/base/modules/invoicing/module.rk +2 -2
  97. package/template/base/modules/invoicing/print/sales_invoice.html +2 -1
  98. package/template/base/modules/invoicing/print/sales_invoice_whatsapp.html +33 -0
  99. package/template/base/modules/invoicing/print/sales_invoice_whatsapp.rk +8 -0
  100. package/template/base/modules/orders/models/customer_order.rk +80 -2
  101. package/template/base/modules/orders/models/customer_order_item.rk +19 -0
  102. package/template/base/modules/orders/module.rk +2 -2
  103. package/template/base/modules/outlet_sales/flows/moka_legacy_key_overlap.rk +22 -0
  104. package/template/base/modules/outlet_sales/imports/daily_form.rk +3 -1
  105. package/template/base/modules/outlet_sales/imports/loyverse_receipts.rk +28 -0
  106. package/template/base/modules/outlet_sales/imports/moka_item_details.rk +14 -4
  107. package/template/base/modules/outlet_sales/imports/pos_sales_file.rk +28 -0
  108. package/template/base/modules/outlet_sales/imports/takings_file.rk +23 -0
  109. package/template/base/modules/outlet_sales/models/outlet_sales.rk +72 -6
  110. package/template/base/modules/outlet_sales/models/outlet_sales_line.rk +1 -0
  111. package/template/base/modules/outlet_sales/models/outlet_takings.rk +83 -0
  112. package/template/base/modules/outlet_sales/models/outlet_takings_line.rk +37 -0
  113. package/template/base/modules/outlets/models/outlet.rk +18 -0
  114. package/template/base/modules/outlets/module.rk +1 -1
  115. package/template/base/modules/payments/flows/payment_gateway_claim_created.rk +19 -0
  116. package/template/base/modules/payments/flows/payment_gateway_claim_submitted.rk +19 -0
  117. package/template/base/modules/payments/flows/payment_gateway_release.rk +12 -0
  118. package/template/base/modules/payments/models/gateway_ref_claim.rk +42 -0
  119. package/template/base/modules/payments/models/payment.rk +59 -1
  120. package/template/base/modules/payments/models/withholding.rk +3 -1
  121. package/template/base/modules/payments/module.rk +2 -2
  122. package/template/base/modules/procurement/flows/project_vendor_cost_on_cancel.rk +22 -0
  123. package/template/base/modules/procurement/flows/project_vendor_cost_on_submit.rk +17 -0
  124. package/template/base/modules/procurement/imports/opening_stock.rk +25 -0
  125. package/template/base/modules/procurement/models/goods_receipt.rk +1 -1
  126. package/template/base/modules/procurement/models/purchase_order.rk +15 -7
  127. package/template/base/modules/procurement/models/purchase_request.rk +11 -1
  128. package/template/base/modules/procurement/models/vendor_bill.rk +12 -1
  129. package/template/base/modules/procurement/module.rk +1 -1
  130. package/template/base/modules/production/flows/batch_cancel_guard.rk +12 -0
  131. package/template/base/modules/production/flows/batch_from_bom.rk +19 -0
  132. package/template/base/modules/production/flows/wage_sheet_on_batch_cancelled.rk +14 -0
  133. package/template/base/modules/production/flows/wage_sheet_on_batch_submitted.rk +12 -0
  134. package/template/base/modules/production/flows/work_order_materials_created.rk +20 -0
  135. package/template/base/modules/production/flows/work_order_materials_updated.rk +20 -0
  136. package/template/base/modules/production/models/bom.rk +67 -0
  137. package/template/base/modules/production/models/bom_byproduct.rk +7 -0
  138. package/template/base/modules/production/models/bom_line.rk +11 -0
  139. package/template/base/modules/production/models/production_batch.rk +149 -0
  140. package/template/base/modules/production/models/production_guard.rk +23 -0
  141. package/template/base/modules/production/models/production_labour.rk +10 -0
  142. package/template/base/modules/production/models/production_material.rk +8 -0
  143. package/template/base/modules/production/models/production_output.rk +8 -0
  144. package/template/base/modules/production/models/production_stage.rk +19 -0
  145. package/template/base/modules/production/models/wage_line.rk +11 -0
  146. package/template/base/modules/production/models/wage_sheet.rk +28 -0
  147. package/template/base/modules/production/models/work_order.rk +63 -0
  148. package/template/base/modules/production/models/work_order_material.rk +8 -0
  149. package/template/base/modules/production/module.rk +12 -0
  150. package/template/base/modules/projects/flows/milestone_back_on_acceptance_cancel.rk +15 -0
  151. package/template/base/modules/projects/flows/milestone_lock_on_update.rk +16 -0
  152. package/template/base/modules/projects/flows/milestone_ready_on_acceptance.rk +40 -0
  153. package/template/base/modules/projects/flows/milestone_scheduled_on_create.rk +14 -0
  154. package/template/base/modules/projects/flows/milestone_scheduled_on_update.rk +27 -0
  155. package/template/base/modules/projects/flows/project_expense_on_cancel.rk +21 -0
  156. package/template/base/modules/projects/flows/project_expense_on_submit.rk +16 -0
  157. package/template/base/modules/projects/flows/project_labor_on_cancel.rk +22 -0
  158. package/template/base/modules/projects/flows/project_labor_on_submit.rk +17 -0
  159. package/template/base/modules/projects/flows/project_terms_lock.rk +26 -0
  160. package/template/base/modules/projects/flows/vendor_bill_cancel_guard.rk +15 -0
  161. package/template/base/modules/projects/imports/billing_milestone.rk +20 -0
  162. package/template/base/modules/projects/models/assignment.rk +21 -1
  163. package/template/base/modules/projects/models/billing_milestone.rk +217 -0
  164. package/template/base/modules/projects/models/project.rk +76 -2
  165. package/template/base/modules/projects/models/project_expense.rk +119 -0
  166. package/template/base/modules/projects/models/project_guard.rk +27 -0
  167. package/template/base/modules/projects/models/project_ledger.rk +132 -0
  168. package/template/base/modules/projects/models/timesheet.rk +38 -3
  169. package/template/base/modules/projects/module.rk +1 -1
  170. package/template/base/modules/stock/flows/adjustment_value_backfill.rk +94 -0
  171. package/template/base/modules/stock/flows/adjustment_value_on_cancel.rk +19 -0
  172. package/template/base/modules/stock/flows/adjustment_value_on_submit.rk +17 -0
  173. package/template/base/modules/stock/models/recipe.rk +8 -0
  174. package/template/base/modules/stock/models/stock_adjustment.rk +1 -0
  175. package/template/base/modules/stock/models/stock_adjustment_value.rk +75 -0
  176. package/template/base/modules/stock/models/stock_balance.rk +3 -0
  177. package/template/base/modules/stock/models/stock_move.rk +10 -1
  178. package/template/base/modules/stock/module.rk +1 -1
  179. package/template/base/modules/users/models/user.rk +1 -0
  180. package/template/base/modules/users/module.rk +1 -1
  181. package/template/base/modules/users/roles/field_sales.rk +7 -0
  182. package/template/base/modules/workforce/imports/worker_list.rk +16 -0
  183. package/template/base/modules/workforce/models/worker.rk +22 -1
@@ -9,6 +9,9 @@ permissions:
9
9
  - {role: sales_manager, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
10
10
  - {role: project_admin, read: true, create: true, write: true, submit: true}
11
11
  - {role: finance_manager, read: true, print: true}
12
+ # a salesman takes orders for his own customers (role scope salesman; rule customer_of_salesman)
13
+ - {role: field_sales, read: true, create: true, write: true, submit: true, print: true}
14
+ - {role: head_office, read: true, print: true}
12
15
  fields:
13
16
  - name: customer
14
17
  type: link
@@ -16,6 +19,35 @@ fields:
16
19
  label: {id: Pelanggan}
17
20
  required: true
18
21
  in_list: true
22
+ # Distributor sales (module distribution). salesman: the customer's, else the salesman taking the order. price_tier
23
+ # is the customer's; the lines are priced at it by the flow order_tier_pricing (a line cannot read the order).
24
+ - name: salesman
25
+ type: link
26
+ to: user
27
+ label: {id: Salesman}
28
+ default: "customer.salesman != '' ? customer.salesman : ('field_sales' in user.roles ? user.name : '')"
29
+ in_list: true
30
+ depends_on: app_installed('distribution')
31
+ - name: price_tier
32
+ type: select
33
+ label: {id: Tier harga}
34
+ compute: "customer.price_tier != '' ? customer.price_tier : 'retail'"
35
+ depends_on: app_installed('distribution')
36
+ options:
37
+ - {value: retail, label: {id: Eceran}}
38
+ - {value: wholesale, label: {id: Grosir}}
39
+ - {value: agent, label: {id: Agen}}
40
+ # What was delivered, returned and invoiced per item (module delivery); made with the order by a flow.
41
+ - name: fulfilment
42
+ type: link
43
+ to: order_fulfilment
44
+ label: {id: Pemenuhan pesanan}
45
+ read_only: true
46
+ depends_on: app_installed('delivery')
47
+ - name: delivery_date
48
+ type: date
49
+ label: {id: Tanggal kirim}
50
+ depends_on: app_installed('distribution')
19
51
  - name: quotation
20
52
  type: link
21
53
  to: quotation
@@ -52,6 +84,12 @@ fields:
52
84
  label: {id: Nilai pesanan (sebelum PPN)}
53
85
  compute: items.map(i, i.amount).sum()
54
86
  in_list: true
87
+ # What the order will cost the customer with PPN, for the credit limit check (customer.outstanding is with PPN).
88
+ - name: estimated_total
89
+ type: currency
90
+ label: {id: Perkiraan total (dengan PPN)}
91
+ compute: "tax.pkp ? round(subtotal * (100 * tax.dpp_den + tax.ppn_rate * tax.dpp_num) / (100 * tax.dpp_den)) : subtotal"
92
+ depends_on: app_installed('distribution')
55
93
  - name: invoiced_amount
56
94
  type: currency
57
95
  label: {id: Sudah ditagih}
@@ -59,7 +97,43 @@ fields:
59
97
  - name: notes
60
98
  type: text
61
99
  label: {id: Catatan}
100
+ # Credit control of a distributor (module distribution): an order is held for the sales manager when the customer
101
+ # is on hold, has an invoice past its due date, or would go over its credit limit (open invoices + orders not yet
102
+ # invoiced + this order). The customer is read when the order is submitted, so the due date check is always current.
103
+ approvals:
104
+ - name: credit_hold
105
+ on: submit
106
+ when: "app_installed('distribution') && customer.credit_hold"
107
+ approvers: [sales_manager, finance_manager]
108
+ label: {id: Pelanggan ditahan kreditnya, en: Customer on credit hold}
109
+ - name: overdue
110
+ on: submit
111
+ when: "app_installed('distribution') && customer.oldest_open_due != '' && customer.oldest_open_due < today()"
112
+ approvers: [sales_manager, finance_manager]
113
+ label: {id: Pelanggan punya tagihan lewat jatuh tempo, en: Customer has overdue invoices}
114
+ - name: below_tier_price
115
+ on: submit
116
+ when: "app_installed('distribution') && items.map(i, i.rate < i.list_rate ? 1 : 0).sum() > 0"
117
+ approvers: [sales_manager]
118
+ label: {id: Harga di bawah harga tier, en: Price below the tier price}
119
+ - name: over_credit_limit
120
+ on: submit
121
+ when: "app_installed('distribution') && customer.credit_limit > 0 && customer.outstanding + customer.open_orders + estimated_total > customer.credit_limit"
122
+ approvers: [sales_manager, finance_manager]
123
+ label: {id: Melewati batas kredit, en: Over the credit limit}
62
124
  rules:
125
+ - name: has_fulfilment
126
+ on: submit
127
+ check: "!app_installed('delivery') || fulfilment != ''"
128
+ message: {id: 'Simpan pesanan ini sekali lagi sebelum diajukan (catatan pemenuhan pesanan belum dibuat)'}
129
+ - name: one_line_per_item
130
+ on: save
131
+ check: "!app_installed('delivery') || items.map(i, items.map(x, x.item == i.item ? 1 : 0).sum() == 1 ? 0 : 1).sum() == 0"
132
+ message: {id: Satu barang cukup satu baris; jumlahkan qty-nya}
133
+ - name: customer_of_salesman
134
+ on: save
135
+ check: "!app_installed('distribution') || salesman == '' || customer.salesman == '' || customer.salesman == salesman"
136
+ message: {id: Pelanggan ini dipegang salesman lain}
63
137
  - name: quotation_same_customer
64
138
  on: save
65
139
  check: quotation == '' || quotation.customer == customer
@@ -83,7 +157,7 @@ actions:
83
157
  if: docstatus == 1 && app_installed('invoicing')
84
158
  views:
85
159
  list:
86
- columns: [name, customer, po_number, po_date, status, subtotal, invoiced_amount]
160
+ columns: [name, customer, salesman, po_number, po_date, status, subtotal, invoiced_amount]
87
161
  sort: -po_date
88
162
  form:
89
163
  layout:
@@ -91,10 +165,14 @@ views:
91
165
  columns:
92
166
  - [customer, quotation, po_number, po_date]
93
167
  - [work_order, site, start_date, end_date]
168
+ - section: {id: Salesman}
169
+ columns:
170
+ - [salesman, price_tier]
171
+ - [delivery_date, fulfilment]
94
172
  - section: {id: Barang/jasa}
95
173
  fields: [items]
96
174
  - section: {id: Ringkasan}
97
175
  columns:
98
- - [subtotal, invoiced_amount]
176
+ - [subtotal, estimated_total, invoiced_amount]
99
177
  - section: {id: Catatan}
100
178
  fields: [notes]
@@ -20,6 +20,25 @@ fields:
20
20
  to: uom
21
21
  label: {id: Satuan}
22
22
  default: "item.sales_uom != '' ? item.sales_uom : item.stock_uom"
23
+ # Tier pricing (module distribution): price_tier is set from the order by the flow order_tier_pricing, which then
24
+ # sets rate to list_rate once per tier (tier_applied), so a price typed by hand afterwards stays.
25
+ - name: price_tier
26
+ type: data
27
+ label: {id: Tier harga}
28
+ default: "'retail'"
29
+ read_only: true
30
+ depends_on: app_installed('distribution')
31
+ - name: tier_applied
32
+ type: data
33
+ label: {id: Tier yang sudah dipakai}
34
+ default: "'retail'"
35
+ read_only: true
36
+ depends_on: app_installed('distribution')
37
+ - name: list_rate
38
+ type: currency
39
+ label: {id: Harga daftar}
40
+ compute: "price_tier == 'agent' && item.rate_agent > 0 ? item.rate_agent : (price_tier == 'wholesale' && item.rate_wholesale > 0 ? item.rate_wholesale : item.rate)"
41
+ depends_on: app_installed('distribution')
23
42
  - name: rate
24
43
  type: currency
25
44
  label: {id: Harga}
@@ -1,9 +1,9 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
2
  name: orders
3
- version: 1.0.0
3
+ version: 1.1.0
4
4
  title: {id: Pesanan pelanggan, en: Customer orders}
5
5
  requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0}
6
- optional: {quotation: ^1.0}
6
+ optional: {quotation: ^1.0, delivery: ^1.0}
7
7
  # Semantics fixed in docs/kernel-hooks.md. The make_invoice action lives on customer_order, so the hook is declared
8
8
  # here; it is implemented with the invoicing hooks and needs the invoicing module installed.
9
9
  hooks: [invoicing.from_order]
@@ -0,0 +1,22 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ name: moka_legacy_key_overlap
3
+ label: {id: Tandai impor Moka yang tumpang tindih dengan impor lama}
4
+ # A Moka record written by the current import (key_version 2) for an outlet and day that already has a live Moka record
5
+ # from before Time joined the import key: those keys never match, so the repeated rows came in again. The record is
6
+ # marked and rule legacy_key_reviewed holds its submit until head office removed the repeated lines.
7
+ on: outlet_sales.created
8
+ if: event.source == 'moka' && event.key_version == 2
9
+ steps:
10
+ - find: outlet_sales
11
+ where: >-
12
+ source == 'moka' && outlet == event.outlet && date == event.date && docstatus != 2 && name != event.name
13
+ && key_version != 2
14
+ as: old
15
+ - find: outlet_sales
16
+ if: old != null
17
+ where: name == event.name
18
+ as: rec
19
+ - update: rec
20
+ if: old != null
21
+ set:
22
+ legacy_key_overlap: "true"
@@ -1,12 +1,14 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/import.json
2
2
  # The daily sales sheet an outlet fills in when it has no Moka export: one row per item sold, one file per day.
3
+ # No key on purpose: import keys are never released, so with [Tanggal, SKU] a corrected sheet for a day could not
4
+ # import again even after the old record was cancelled. The same file twice is still refused by its hash, and two
5
+ # submitted forms for one outlet and day are refused at submit (409 duplicate_sales).
3
6
  name: daily_form
4
7
  label: {id: Formulir penjualan harian, en: Daily sales form}
5
8
  model: outlet_sales
6
9
  source: csv
7
10
  header_row: 1
8
11
  per: outlet
9
- key: [Tanggal, SKU]
10
12
  group: [Tanggal]
11
13
  map:
12
14
  date: Tanggal
@@ -0,0 +1,28 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/import.json
2
+ # Loyverse Back Office "Receipts by item" export (Reports > Receipts > Export > Receipts by item), one store per file.
3
+ # GUESSED HEADERS: taken from Loyverse's help pages, not from a real export yet. Check them against the first real
4
+ # file and fix them here (the Moka import failed on guessed headers before rangka-apps P2).
5
+ # Loyverse writes a refund as its own receipt (Receipt type "Refund") with a positive Quantity; it is turned into a
6
+ # negative line with its Net sales in refund, so net sales match Loyverse; the sign of Quantity and Net sales on a
7
+ # refund row does not matter (both are taken as amounts). The Date column must be a date without
8
+ # the time (set the export's date format in Loyverse), else the row is refused.
9
+ name: loyverse_receipts
10
+ label: {id: Penjualan Loyverse (per barang), en: Loyverse sales (receipts by item)}
11
+ model: outlet_sales
12
+ source: csv
13
+ header_row: 1
14
+ per: outlet
15
+ key: [Date, Receipt number, SKU, Variant]
16
+ group: [Date]
17
+ map:
18
+ date: Date
19
+ source: "='loyverse'"
20
+ note: "='Loyverse ' + row['Date']"
21
+ lines:
22
+ field: lines
23
+ map:
24
+ item: {value: SKU, match: sku}
25
+ qty: "=row['Receipt type'] == 'Refund' ? -max(double(row['Quantity']), -double(row['Quantity'])) : double(row['Quantity'])"
26
+ gross: "=row['Receipt type'] == 'Refund' ? 0 : int(row['Gross sales'])"
27
+ discount: "=row['Receipt type'] == 'Refund' ? 0 : int(row['Discounts'])"
28
+ refund: "=row['Receipt type'] == 'Refund' ? max(int(row['Net sales']), -int(row['Net sales'])) : 0"
@@ -1,6 +1,14 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/import.json
2
- # Moka Backoffice "Export Item Details", one file per outlet and day (or several days). The headers are the English
3
- # Backoffice headers assumed in contract 0012; when the pilot's first real export arrives, fix them here, not in the kernel.
2
+ # Moka Backoffice "Export Item Details" (Reports > Transactions > Export > Item Details), one file per outlet and day
3
+ # (or several days), unzipped. The 25 English headers (Outlet, Receipt Number, Date, Time, Category, Brand, Items,
4
+ # Variant, SKU, Quantity, Modifier Applied, Discount Applied, Gross Sales, Discounts, Refunds, Net Sales, Gratuity, Tax,
5
+ # Sales Type, Collected By, Served By, Customer, Payment Method, Event Type, Reason of Refund) come from code that reads
6
+ # real exports; columns are matched by name, so their order does not matter. Dates are dd-mm-yyyy (rangka-os #32).
7
+ # When a pilot's real export differs, fix the headers here, not in the kernel.
8
+ # One outlet per file (choose it at upload): a row whose Outlet is not that outlet's moka_name is refused, so an All
9
+ # Outlets export or a file uploaded for the wrong outlet cannot land in another outlet's stock.
10
+ # Time is in the key: two partial refunds of one item on one receipt are two rows, not a "Baris ganda". Keys stored
11
+ # before Time joined do not match, so a day imported earlier is held at submit (outlet_sales.legacy_key_reviewed).
4
12
  # Same file twice -> duplicate (file hash). Overlapping exports -> only rows whose key is new. Records arrive as drafts.
5
13
  name: moka_item_details
6
14
  label: {id: Penjualan Moka (detail item), en: Moka sales (item details)}
@@ -8,11 +16,13 @@ model: outlet_sales
8
16
  source: csv
9
17
  header_row: 1
10
18
  per: outlet
11
- key: [Date, Receipt Number, Item, Variant, Modifiers]
12
- group: [Date]
19
+ key: [Date, Time, Receipt Number, Items, Variant, Modifier Applied]
20
+ group: [Date, Outlet]
13
21
  map:
14
22
  date: Date
15
23
  source: "='moka'"
24
+ moka_outlet: Outlet
25
+ key_version: "=2"
16
26
  note: "='Moka ' + row['Date']"
17
27
  lines:
18
28
  field: lines
@@ -0,0 +1,28 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/import.json
2
+ # Juragan's sales template for any POS without its own import (Kasir Pintar, Pawoon, majoo, Olsera, a spreadsheet):
3
+ # one row per item sold per day, one outlet per file. Headers: Tanggal, No struk, Jenis (Jual or Retur), SKU, Qty,
4
+ # Penjualan kotor, Diskon, Retur. A return is its own row (Jenis Retur) with a negative Qty, Penjualan kotor 0 and the
5
+ # returned value in Retur, as Moka writes it. No struk may be empty when the POS only exports a daily total per item:
6
+ # then each SKU appears once per day and Jenis. The key leaves Qty out on purpose: a re-export of a day whose totals
7
+ # changed skips the rows already imported instead of adding them a second time; correct such a day on its draft.
8
+ # The outlet must have Sumber penjualan = File POS. Same file twice -> duplicate; overlapping files -> only new rows.
9
+ name: pos_sales_file
10
+ label: {id: Penjualan dari file POS, en: Sales from a POS file}
11
+ model: outlet_sales
12
+ source: csv
13
+ header_row: 1
14
+ per: outlet
15
+ key: [Tanggal, No struk, Jenis, SKU]
16
+ group: [Tanggal]
17
+ map:
18
+ date: Tanggal
19
+ source: "='file'"
20
+ note: "='File POS ' + row['Tanggal']"
21
+ lines:
22
+ field: lines
23
+ map:
24
+ item: {value: SKU, match: sku}
25
+ qty: Qty
26
+ gross: Penjualan kotor
27
+ discount: Diskon
28
+ refund: Retur
@@ -0,0 +1,23 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/import.json
2
+ # Juragan's daily takings template, one outlet per file: Tanggal, Metode (Tunai, QRIS, Kartu debit, Kartu kredit,
3
+ # Transfer bank, Dompet digital, Lainnya), Menurut POS, Disetor, Potongan, Referensi. Fill Menurut POS from the POS's
4
+ # payment report (Moka "Payment Methods", Loyverse "Sales by payment type"); a native import of those reports waits
5
+ # for a real export file.
6
+ name: takings_file
7
+ label: {id: Setoran harian (template), en: Daily takings (template)}
8
+ model: outlet_takings
9
+ source: csv
10
+ header_row: 1
11
+ per: outlet
12
+ key: [Tanggal, Metode]
13
+ group: [Tanggal]
14
+ map:
15
+ date: Tanggal
16
+ lines:
17
+ field: lines
18
+ map:
19
+ method: "=row['Metode'] == 'Tunai' ? 'cash' : row['Metode'] == 'QRIS' ? 'qris' : row['Metode'] == 'Kartu debit' ? 'debit' : row['Metode'] == 'Kartu kredit' ? 'credit' : row['Metode'] == 'Transfer bank' ? 'transfer' : row['Metode'] == 'Dompet digital' ? 'ewallet' : 'other'"
20
+ expected: Menurut POS
21
+ received: Disetor
22
+ fee: Potongan
23
+ bank_ref: Referensi
@@ -8,11 +8,20 @@ title_field: date
8
8
  # Created as a draft (by the daily form or by an import); stock moves only when head office or the outlet submits it.
9
9
  # stock.post_moves explodes each line through its active recipe, writes the line cogs and cogs_total, and refuses
10
10
  # a second submitted record for the same outlet and date when source is form (409 duplicate_sales).
11
+ # A refund from a POS file (Moka, Loyverse, Juragan's template) is its own line (qty < 0, gross 0, refund > 0, net < 0).
12
+ # The kernel posts no stock move for a line with qty <= 0, so the goods of the original sale stay out of stock: a refund
13
+ # lowers net sales and margin, not stock. For a shop that puts returned goods back on the shelf this undervalues stock
14
+ # until the kernel has a return document (draft contract 0021); the retail dashboard shows returned qty per day.
15
+ # That is also what Moka does with base ingredients on a refund. Returning materials to stock needs the kernel.
11
16
  on_submit: [stock.post_moves]
12
17
  on_cancel: [stock.reverse_moves]
13
18
  permissions:
14
19
  - {role: head_office, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, import: true, print: true}
15
- - {role: outlet_staff, read: true, create: true, write: true, submit: true}
20
+ # Outlet staff keep the daily form only. A record from Moka, a POS file or Loyverse (negative refund lines allowed) is
21
+ # the importer's, head office: staff cannot type such a source to book a negative net (audit #7 S1, kept for file
22
+ # and loyverse when ritel_cabang added them).
23
+ - {role: outlet_staff, read: true, create: true, write: true, submit: true, if: source == 'form'}
24
+ - {role: outlet_staff, read: true}
16
25
  fields:
17
26
  - name: outlet
18
27
  type: link
@@ -25,6 +34,9 @@ fields:
25
34
  label: {id: Tanggal}
26
35
  required: true
27
36
  in_list: true
37
+ # Set by the import (moka, file, loyverse) or left at form. Not read_only: the kernel drops read_only input from imports
38
+ # too. The outlet_staff permission holds only while source == 'form', so only head office (who imports) can write a
39
+ # record from Moka, a POS file or Loyverse.
28
40
  - name: source
29
41
  type: select
30
42
  label: {id: Sumber}
@@ -34,9 +46,30 @@ fields:
34
46
  options:
35
47
  - {value: moka, label: {id: Moka}}
36
48
  - {value: form, label: {id: Formulir harian}}
49
+ - {value: file, label: {id: File POS}}
50
+ - {value: loyverse, label: {id: Loyverse}}
37
51
  - name: note
38
52
  type: data
39
53
  label: {id: Catatan}
54
+ # The Outlet column of the Moka file this record came from; must equal the chosen outlet's moka_name.
55
+ - name: moka_outlet
56
+ type: data
57
+ label: {id: Outlet di file Moka}
58
+ depends_on: source == 'moka'
59
+ # The Moka import key gained Time (two partial refunds of one item on one receipt). Keys stored before that never
60
+ # match the new key, so an overlapping export re-imports rows of a day already imported. key_version is 2 on every
61
+ # record the current import writes; flow moka_legacy_key_overlap marks a new record whose outlet and day already have
62
+ # a live Moka record without it, and rule legacy_key_reviewed holds its submit until head office has removed the
63
+ # repeated lines and ticks legacy_key_checked.
64
+ - {name: key_version, type: int, label: {id: Versi kunci impor}, hidden: true}
65
+ - name: legacy_key_overlap
66
+ type: check
67
+ label: {id: Tumpang tindih impor lama}
68
+ read_only: true
69
+ help: {id: 'Tanggal ini sudah punya penjualan Moka yang diimpor sebelum pembaruan; baris yang sama bisa masuk lagi'}
70
+ - name: legacy_key_checked
71
+ type: check
72
+ label: {id: Baris ganda sudah dihapus}
40
73
  - name: lines
41
74
  type: table
42
75
  of: outlet_sales_line
@@ -74,19 +107,52 @@ fields:
74
107
  label: {id: Margin}
75
108
  compute: net_total - cogs_total
76
109
  in_list: true
110
+ # Monthly tax recap (no file): a PKP shop's sales prices include PPN, so the PPN inside net sales is
111
+ # net x rate x dpp / (100 + rate x dpp) (Digunggung amounts). The 0,5% final PPh of PP 55/2022 depends on turnover
112
+ # (up to Rp 4,8 miliar a year), not on PKP status, so it is shown for every shop on turnover without PPN; a shop
113
+ # above the limit ignores it.
114
+ # The XML for Coretax needs a kernel export.
115
+ - name: ppn_in_sales
116
+ type: currency
117
+ label: {id: PPN dalam penjualan}
118
+ compute: "tax.pkp ? round(net_total * tax.ppn_rate * tax.dpp_num / (100 * tax.dpp_den + tax.ppn_rate * tax.dpp_num)) : 0"
119
+ - name: pph_final
120
+ type: currency
121
+ label: {id: 'PPh final 0,5%'}
122
+ compute: round((net_total - ppn_in_sales) * 5 / 1000)
77
123
  rules:
124
+ - name: moka_outlet_matches
125
+ on: save
126
+ check: "source != 'moka' || moka_outlet == outlet.moka_name"
127
+ message: {id: 'Kolom Outlet di file Moka beda dengan Nama outlet di Moka pada outlet ini. Ekspor per outlet, atau cek data outlet'}
128
+ # One sales source per outlet: a Moka outlet (moka_name set) imports Moka files only, any other outlet uses the
129
+ # daily form. Without it, a form and a Moka export for the same outlet and day both take stock out.
130
+ - name: form_only_for_non_moka_outlets
131
+ on: save
132
+ check: "source != 'form' || outlet.moka_name == ''"
133
+ message: {id: 'Outlet ini memakai Moka: penjualannya diimpor dari file Moka, bukan formulir harian'}
134
+ # An outlet without Moka has one sales_source (empty = form): a POS file or a Loyverse export is accepted only for
135
+ # the outlet that names it, and a form only for an outlet whose source is the form.
136
+ - name: source_matches_outlet
137
+ on: save
138
+ check: "source == 'moka' || (outlet.moka_name == '' && (outlet.sales_source == '' ? 'form' : outlet.sales_source) == source)"
139
+ message: {id: 'Sumber penjualan ini beda dengan Sumber penjualan di data outlet. Cek data outlet, atau pilih outlet yang benar'}
78
140
  - name: qty_not_negative
79
141
  on: save
80
- check: "lines.map(l, l.qty < 0 ? 1 : 0).sum() == 0"
81
- message: {id: Jumlah terjual tidak boleh negatif}
142
+ check: "lines.map(l, l.qty < 0 && (l.refund == 0 || (source != 'moka' && source != 'file' && source != 'loyverse')) ? 1 : 0).sum() == 0"
143
+ message: {id: Jumlah terjual hanya boleh negatif di baris retur dari file POS}
82
144
  - name: discount_within_gross
83
145
  on: save
84
146
  check: "lines.map(l, l.discount > l.gross ? 1 : 0).sum() == 0"
85
147
  message: {id: Diskon tidak boleh melebihi penjualan kotor}
86
148
  - name: net_not_negative
87
149
  on: save
88
- check: "lines.map(l, l.net < 0 ? 1 : 0).sum() == 0"
89
- message: {id: Penjualan bersih per baris tidak boleh negatif}
150
+ check: "lines.map(l, l.net < 0 && (l.refund == 0 || (source != 'moka' && source != 'file' && source != 'loyverse')) ? 1 : 0).sum() == 0"
151
+ message: {id: Penjualan bersih per baris hanya boleh negatif di baris retur dari file POS}
152
+ - name: legacy_key_reviewed
153
+ on: submit
154
+ check: "!legacy_key_overlap || legacy_key_checked"
155
+ message: {id: 'Tanggal ini sudah diimpor sebelum pembaruan: hapus baris yang terulang, lalu centang Baris ganda sudah dihapus'}
90
156
  views:
91
157
  list:
92
158
  columns: [name, outlet, date, source, status, net_total, cogs_total, margin]
@@ -97,7 +163,7 @@ views:
97
163
  - section: {id: Penjualan}
98
164
  columns:
99
165
  - [outlet, date, source]
100
- - [note]
166
+ - [note, legacy_key_overlap, legacy_key_checked]
101
167
  - section: {id: Barang terjual}
102
168
  fields: [lines]
103
169
  - section: {id: Ringkasan}
@@ -14,6 +14,7 @@ fields:
14
14
  - name: qty
15
15
  type: float
16
16
  label: {id: Qty}
17
+ help: {id: 'Negatif di baris retur dari file POS. Barang atau bahan tidak dikembalikan ke stok'}
17
18
  required: true
18
19
  stock: true
19
20
  - name: gross
@@ -0,0 +1,83 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: outlet_takings
3
+ label: {id: Setoran harian, en: Daily takings}
4
+ icon: wallet
5
+ is_submittable: true
6
+ naming: STR-{YYYY}-{#####}
7
+ title_field: date
8
+ # What each payment method should have brought in per outlet per day (the POS's payment report) against what was
9
+ # deposited or credited (cash banked, QRIS/EDC settlement after MDR). The difference per line is the shortfall head
10
+ # office follows up. Matching a line to a bank statement line is manual for now (bank_ref holds the statement's
11
+ # reference); a link to bank_statement comes with the money rail (plan Tahap 1). No stock, no ledger: submit only
12
+ # freezes the day.
13
+ permissions:
14
+ - {role: head_office, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, import: true, print: true}
15
+ - {role: outlet_staff, read: true, create: true, write: true, submit: true}
16
+ fields:
17
+ - name: outlet
18
+ type: link
19
+ to: outlet
20
+ label: {id: Outlet}
21
+ required: true
22
+ in_list: true
23
+ - name: date
24
+ type: date
25
+ label: {id: Tanggal}
26
+ required: true
27
+ default: today()
28
+ in_list: true
29
+ - name: lines
30
+ type: table
31
+ of: outlet_takings_line
32
+ label: {id: Per metode bayar}
33
+ min_rows: 1
34
+ - name: expected_total
35
+ type: currency
36
+ label: {id: Menurut POS}
37
+ compute: lines.map(l, l.expected).sum()
38
+ in_list: true
39
+ - name: received_total
40
+ type: currency
41
+ label: {id: Disetor atau diterima}
42
+ compute: lines.map(l, l.received).sum()
43
+ in_list: true
44
+ - name: fee_total
45
+ type: currency
46
+ label: {id: Potongan MDR}
47
+ compute: lines.map(l, l.fee).sum()
48
+ - name: difference_total
49
+ type: currency
50
+ label: {id: Selisih}
51
+ help: {id: 'Diterima ditambah potongan dikurangi menurut POS. Minus berarti setoran kurang'}
52
+ compute: lines.map(l, l.difference).sum()
53
+ in_list: true
54
+ - name: short
55
+ type: check
56
+ label: {id: Setoran kurang}
57
+ compute: difference_total < 0
58
+ in_list: true
59
+ - name: note
60
+ type: text
61
+ label: {id: Catatan}
62
+ rules:
63
+ - name: amounts_not_negative
64
+ on: save
65
+ check: "lines.map(l, l.expected < 0 || l.received < 0 || l.fee < 0 ? 1 : 0).sum() == 0"
66
+ message: {id: Nilai setoran dan potongan tidak boleh negatif}
67
+ views:
68
+ list:
69
+ columns: [name, outlet, date, status, expected_total, received_total, difference_total, short]
70
+ filters: [outlet, short]
71
+ sort: -date
72
+ form:
73
+ layout:
74
+ - section: {id: Setoran}
75
+ columns:
76
+ - [outlet, date]
77
+ - [note]
78
+ - section: {id: Per metode bayar}
79
+ fields: [lines]
80
+ - section: {id: Ringkasan}
81
+ columns:
82
+ - [expected_total, received_total]
83
+ - [fee_total, difference_total]
@@ -0,0 +1,37 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: outlet_takings_line
3
+ is_child: true
4
+ fields:
5
+ - name: method
6
+ type: select
7
+ label: {id: Metode bayar}
8
+ required: true
9
+ options:
10
+ - {value: cash, label: {id: Tunai}}
11
+ - {value: qris, label: {id: QRIS}}
12
+ - {value: debit, label: {id: Kartu debit}}
13
+ - {value: credit, label: {id: Kartu kredit}}
14
+ - {value: transfer, label: {id: Transfer bank}}
15
+ - {value: ewallet, label: {id: Dompet digital}}
16
+ - {value: other, label: {id: Lainnya}}
17
+ - name: expected
18
+ type: currency
19
+ label: {id: Menurut POS}
20
+ required: true
21
+ - name: received
22
+ type: currency
23
+ label: {id: Disetor atau diterima}
24
+ default: '0'
25
+ - name: fee
26
+ type: currency
27
+ label: {id: Potongan MDR}
28
+ help: {id: 'Potongan bank atau penyedia QRIS/EDC, kalau ada'}
29
+ default: '0'
30
+ - name: difference
31
+ type: currency
32
+ label: {id: Selisih}
33
+ compute: received + fee - expected
34
+ - name: bank_ref
35
+ type: data
36
+ label: {id: Referensi mutasi bank}
37
+ help: {id: 'Keterangan atau nomor di mutasi rekening, untuk dicocokkan'}
@@ -12,6 +12,7 @@ permissions:
12
12
  - {role: head_office, read: true, create: true, write: true, print: true}
13
13
  - {role: outlet_staff, read: true}
14
14
  - {role: sales_rep, read: true}
15
+ - {role: field_sales, read: true}
15
16
  fields:
16
17
  - name: outlet_name
17
18
  type: data
@@ -37,3 +38,20 @@ fields:
37
38
  type: check
38
39
  label: {id: Aktif}
39
40
  default: 'true'
41
+ # Moka's Item Details export names the outlet in its Outlet column; outlet_sales checks each Moka file against it.
42
+ - name: moka_name
43
+ type: data
44
+ label: {id: Nama outlet di Moka}
45
+ help: {id: 'Persis seperti kolom Outlet di ekspor Moka, misalnya "Tahu Contoh - Dago". Kosongkan kalau outlet ini tidak pakai Moka'}
46
+ depends_on: app_installed('outlet_sales')
47
+ # The sales source of an outlet without Moka (moka_name empty): the daily form (default when empty), a file from
48
+ # another POS in Juragan's template, or a Loyverse export. One source per outlet, so a day is never counted twice.
49
+ - name: sales_source
50
+ type: select
51
+ label: {id: Sumber penjualan}
52
+ help: {id: 'Untuk outlet yang tidak pakai Moka. Kosong berarti formulir harian'}
53
+ depends_on: app_installed('outlet_sales') && moka_name == ''
54
+ options:
55
+ - {value: form, label: {id: Formulir harian}}
56
+ - {value: file, label: {id: File POS (template Juragan)}}
57
+ - {value: loyverse, label: {id: Loyverse}}
@@ -1,5 +1,5 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
2
  name: outlets
3
- version: 1.0.0
3
+ version: 1.1.0
4
4
  title: {id: Outlet, en: Outlets}
5
5
  requires: {rangka: '>=0.5', users: ^1.0}
@@ -0,0 +1,19 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # A payment with a gateway id is created: it claims the id in gateway_ref_claim (see that model). A claim whose
3
+ # payment is gone (a deleted draft, or this payment's own draft name before submit renamed it) or cancelled is
4
+ # taken over; otherwise a new claim is created, and the unique index refuses it when a live payment holds the id,
5
+ # which refuses the whole save: a gateway callback delivered twice cannot pay an invoice twice.
6
+ name: payment_gateway_claim_created
7
+ label: {id: Klaim ID gateway saat pembayaran dibuat}
8
+ on: payment.created
9
+ if: event.gateway_ref != ''
10
+ steps:
11
+ - {find: gateway_ref_claim, where: gateway_ref == event.gateway_ref, as: held}
12
+ - {find: payment, where: "held != null && name == held.payment && docstatus != 2", as: holder}
13
+ - if: held != null && holder == null
14
+ then:
15
+ - update: held
16
+ set: {payment: event.name}
17
+ else:
18
+ - create: gateway_ref_claim
19
+ set: {gateway_ref: event.gateway_ref, payment: event.name}
@@ -0,0 +1,19 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # A payment with a gateway id is submitted: it claims the id in gateway_ref_claim (see that model). A claim whose
3
+ # payment is gone (a deleted draft, or this payment's own draft name before submit renamed it) or cancelled is
4
+ # taken over; otherwise a new claim is created, and the unique index refuses it when a live payment holds the id,
5
+ # which refuses the whole save: a gateway callback delivered twice cannot pay an invoice twice.
6
+ name: payment_gateway_claim_submitted
7
+ label: {id: Klaim ID gateway saat pembayaran diajukan}
8
+ on: payment.submitted
9
+ if: event.gateway_ref != ''
10
+ steps:
11
+ - {find: gateway_ref_claim, where: gateway_ref == event.gateway_ref, as: held}
12
+ - {find: payment, where: "held != null && name == held.payment && docstatus != 2", as: holder}
13
+ - if: held != null && holder == null
14
+ then:
15
+ - update: held
16
+ set: {payment: event.name}
17
+ else:
18
+ - create: gateway_ref_claim
19
+ set: {gateway_ref: event.gateway_ref, payment: event.name}