@rangka-os/create 0.5.0-alpha.8 → 0.5.0-alpha.9
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/jasa_proyek/dashboards/project_margin.rk +2 -2
- package/template/base/connectors/biteship/connector.rk +241 -0
- package/template/base/connectors/biteship/fixtures/cancel_order.json +1 -0
- package/template/base/connectors/biteship/fixtures/create_order.json +8 -0
- package/template/base/connectors/biteship/fixtures/expect.json +9 -0
- package/template/base/connectors/biteship/fixtures/get_order.json +2 -0
- package/template/base/connectors/biteship/fixtures/get_rates.json +7 -0
- package/template/base/connectors/biteship/fixtures/get_tracking.json +7 -0
- package/template/base/connectors/biteship/fixtures/order_price.json +11 -0
- package/template/base/connectors/biteship/fixtures/order_status.json +15 -0
- package/template/base/connectors/biteship/fixtures/order_status_cancelled.json +15 -0
- package/template/base/connectors/biteship/fixtures/order_waybill.json +7 -0
- package/template/base/connectors/biteship/fixtures/search_areas.json +1 -0
- package/template/base/modules/bank_statement/flows/bank_transaction_suggest.rk +13 -3
- package/template/base/modules/invoicing/flows/payment_instruction_on_submit.rk +24 -0
- package/template/base/modules/invoicing/models/bank_account.rk +134 -0
- package/template/base/modules/invoicing/models/payment_instruction.rk +68 -0
- package/template/base/modules/invoicing/module.rk +1 -1
- package/template/base/modules/payments/flows/payment_from_xendit_invoice.rk +59 -0
- package/template/base/modules/payments/flows/payment_from_xendit_qr.rk +59 -0
- package/template/base/modules/payments/flows/payment_from_xendit_va.rk +59 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rangka-os/create",
|
|
3
|
-
"version": "0.5.0-alpha.
|
|
3
|
+
"version": "0.5.0-alpha.9",
|
|
4
4
|
"description": "Start a Rangka OS project: npm create @rangka-os@latest my-shop",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"homepage": "https://rangka-os.github.io/rangka-os/guide/quick-start",
|
|
@@ -4,8 +4,8 @@ name: project_margin
|
|
|
4
4
|
label: {id: Untung per proyek, en: Project margin}
|
|
5
5
|
default_period: 365
|
|
6
6
|
# Margin is cost: owner, finance and the project admin only. Sales and purchasing read only their own rows of the
|
|
7
|
-
# ledger, so a sum would show them revenue as "untung"
|
|
8
|
-
# the ledger, timesheets or workers also
|
|
7
|
+
# ledger, so a sum would show them revenue as "untung". The kernel enforces `roles` from alpha.9 (contract 0027); every
|
|
8
|
+
# widget on the ledger, timesheets or workers also keeps the same `if` for older kernels.
|
|
9
9
|
roles: [finance_manager, project_admin]
|
|
10
10
|
cache: 5m
|
|
11
11
|
widgets:
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/connector.json
|
|
2
|
+
# Biteship (Indonesia): one shipping aggregator for many couriers (JNE, J&T, SiCepat, AnterAja, GoSend, Grab Express,
|
|
3
|
+
# Paxel and more): area search, courier rates, shipping orders (pickup or drop off, COD, insurance), tracking and
|
|
4
|
+
# status webhooks. Every request sends the API key in the Authorization header (as is or as Bearer; both accepted).
|
|
5
|
+
# Test mode: a key starting with biteship_test. talks to the same URLs; test orders are simulated from the dashboard
|
|
6
|
+
# (to delivered or cancelled) and send the same webhooks. Live keys start with biteship_live.
|
|
7
|
+
# Status: spec, no flow calls it yet. The kernel does not run connectors (contract 0002). Fields follow Biteship's public
|
|
8
|
+
# API reference (biteship.com/docs/api: rates/retrieve, orders/create, orders/delete, trackings/retrieve,
|
|
9
|
+
# webhook/overview) and have not been checked against a live account; the query parameters of maps/areas are to confirm.
|
|
10
|
+
# Synthetic payloads of every webhook and answer are in fixtures/ (tests/check_fixtures.py checks the emits against them).
|
|
11
|
+
# Webhooks: the owner adds one webhook per event in the dashboard (Integrations > Webhook) with the URL of the trigger
|
|
12
|
+
# and a Headers Signature Key / Secret. Biteship sends that pair as an HTTP header on every request; the key must be
|
|
13
|
+
# x-biteship-secret (the header verify below reads; the name is ours, chosen in the dashboard, not fixed by Biteship;
|
|
14
|
+
# the header pairing is from help.biteship.com, to confirm on a test account), the secret is auth.webhook_secret. Deliveries can repeat: a flow
|
|
15
|
+
# keys its work on shipment_ref + status (order.status), shipment_ref + price (order.price) or shipment_ref + waybill.
|
|
16
|
+
name: biteship
|
|
17
|
+
label: {id: Biteship}
|
|
18
|
+
version: 0.1.0
|
|
19
|
+
vendor: Biteship
|
|
20
|
+
docs: https://biteship.com/docs/api
|
|
21
|
+
auth:
|
|
22
|
+
type: token
|
|
23
|
+
fields:
|
|
24
|
+
- name: api_key
|
|
25
|
+
label: {id: API key}
|
|
26
|
+
secret: true
|
|
27
|
+
help: {id: 'Dashboard Biteship > Integrasi > API Key. Kunci biteship_test. untuk mode test.'}
|
|
28
|
+
- name: webhook_secret
|
|
29
|
+
label: {id: Headers signature secret}
|
|
30
|
+
secret: true
|
|
31
|
+
generate: true
|
|
32
|
+
help: {id: 'Isi di Dashboard Biteship > Integrasi > Webhook: Headers Signature Key x-biteship-secret, Secret nilai ini'}
|
|
33
|
+
settings:
|
|
34
|
+
- name: couriers
|
|
35
|
+
label: {id: Kurir yang ditawarkan}
|
|
36
|
+
default: "'jne,jnt,sicepat,anteraja,gojek,grab'"
|
|
37
|
+
help: {id: 'Kode kurir Biteship, dipisah koma'}
|
|
38
|
+
- name: origin_area_id
|
|
39
|
+
label: {id: Area asal (gudang)}
|
|
40
|
+
help: {id: 'ID area Biteship gudang pengirim, dari aksi Cari area'}
|
|
41
|
+
triggers:
|
|
42
|
+
# order.status: every change of a shipment's status, with the courier and (instant couriers) the driver
|
|
43
|
+
- name: order_status
|
|
44
|
+
label: {id: Status pengiriman berubah}
|
|
45
|
+
via: webhook
|
|
46
|
+
verify:
|
|
47
|
+
header: x-biteship-secret
|
|
48
|
+
equals: auth.webhook_secret
|
|
49
|
+
emit:
|
|
50
|
+
event: event
|
|
51
|
+
shipment_ref: order_id
|
|
52
|
+
tracking_id: courier_tracking_id
|
|
53
|
+
waybill: courier_waybill_id
|
|
54
|
+
courier: courier_company
|
|
55
|
+
service: courier_type
|
|
56
|
+
status: status
|
|
57
|
+
price: order_price
|
|
58
|
+
driver_name: courier_driver_name
|
|
59
|
+
driver_phone: courier_driver_phone
|
|
60
|
+
driver_plate: courier_driver_plate_number
|
|
61
|
+
link: courier_link
|
|
62
|
+
# what a flow acts on without knowing Biteship's status list (help.biteship.com shipping statuses, not in the API
|
|
63
|
+
# reference; to confirm on a test account: confirmed, scheduled, allocated,
|
|
64
|
+
# picking_up, picked, dropping_off, delivered, on_hold, courier_not_found, cancelled, return_in_transit, returned)
|
|
65
|
+
delivered: status == 'delivered'
|
|
66
|
+
failed: status == 'cancelled' || status == 'courier_not_found' || status == 'return_in_transit' || status == 'returned'
|
|
67
|
+
on_the_way: status == 'picked' || status == 'dropping_off'
|
|
68
|
+
# order.price: the courier re-weighed the parcel; the shipping cost the business pays changed
|
|
69
|
+
- name: order_price
|
|
70
|
+
label: {id: Ongkir berubah}
|
|
71
|
+
via: webhook
|
|
72
|
+
verify:
|
|
73
|
+
header: x-biteship-secret
|
|
74
|
+
equals: auth.webhook_secret
|
|
75
|
+
emit:
|
|
76
|
+
event: event
|
|
77
|
+
shipment_ref: order_id
|
|
78
|
+
tracking_id: courier_tracking_id
|
|
79
|
+
waybill: courier_waybill_id
|
|
80
|
+
status: status
|
|
81
|
+
price: price
|
|
82
|
+
shipping_fee: shippment_fee # sic: Biteship's field name
|
|
83
|
+
cod_fee: cash_on_delivery_fee
|
|
84
|
+
pod_fee: proof_of_delivery_fee
|
|
85
|
+
# order.waybill_id: the courier issued or changed the airway bill (resi), usually after pickup
|
|
86
|
+
- name: order_waybill
|
|
87
|
+
label: {id: Nomor resi terbit}
|
|
88
|
+
via: webhook
|
|
89
|
+
verify:
|
|
90
|
+
header: x-biteship-secret
|
|
91
|
+
equals: auth.webhook_secret
|
|
92
|
+
emit:
|
|
93
|
+
event: event
|
|
94
|
+
shipment_ref: order_id
|
|
95
|
+
tracking_id: courier_tracking_id
|
|
96
|
+
waybill: courier_waybill_id
|
|
97
|
+
status: status
|
|
98
|
+
actions:
|
|
99
|
+
- name: search_areas
|
|
100
|
+
label: {id: Cari area}
|
|
101
|
+
request:
|
|
102
|
+
method: GET
|
|
103
|
+
url: https://api.biteship.com/v1/maps/areas
|
|
104
|
+
headers: {Authorization: '{auth.api_key}'}
|
|
105
|
+
query: {countries: ID, input: '{input.query}', type: single}
|
|
106
|
+
input:
|
|
107
|
+
- {name: query, type: data, required: true, help: {id: 'Nama kecamatan, kota atau kode pos'}}
|
|
108
|
+
output: {areas: areas}
|
|
109
|
+
retry: {max: 3, backoff: exponential, on: [429, 500, 502, 503]}
|
|
110
|
+
- name: get_rates
|
|
111
|
+
label: {id: Cek ongkir}
|
|
112
|
+
request:
|
|
113
|
+
method: POST
|
|
114
|
+
url: https://api.biteship.com/v1/rates/couriers
|
|
115
|
+
headers: {Authorization: '{auth.api_key}'}
|
|
116
|
+
body:
|
|
117
|
+
origin_area_id: '{input.origin_area_id}'
|
|
118
|
+
destination_area_id: '{input.destination_area_id}'
|
|
119
|
+
destination_postal_code: '{input.destination_postal_code}'
|
|
120
|
+
couriers: '{input.couriers}'
|
|
121
|
+
destination_cash_on_delivery: '{input.cod_amount}'
|
|
122
|
+
destination_cash_on_delivery_type: '{input.cod_type}'
|
|
123
|
+
courier_insurance: '{input.insured_value}'
|
|
124
|
+
items: '{input.items}'
|
|
125
|
+
input:
|
|
126
|
+
- {name: origin_area_id, type: data, default: settings.origin_area_id}
|
|
127
|
+
- {name: destination_area_id, type: data}
|
|
128
|
+
- {name: destination_postal_code, type: int, help: {id: 'Dipakai kalau area tujuan kosong'}}
|
|
129
|
+
- {name: couriers, type: data, default: settings.couriers}
|
|
130
|
+
- {name: cod_amount, type: currency, help: {id: 'Nilai COD, maksimal Rp 15.000.000'}}
|
|
131
|
+
- {name: cod_type, type: data, help: {id: '3_days, 5_days atau 7_days; wajib kalau ada COD'}}
|
|
132
|
+
- {name: insured_value, type: currency}
|
|
133
|
+
- {name: items, type: json, required: true, help: {id: 'Daftar barang: name, value, quantity, weight (gram), length/width/height (cm)'}}
|
|
134
|
+
# one row per courier service: courier_code, courier_service_code, price (final, with insurance and COD fees),
|
|
135
|
+
# shipment_duration_range + shipment_duration_unit, available_for_cash_on_delivery
|
|
136
|
+
output: {pricing: pricing}
|
|
137
|
+
retry: {max: 3, backoff: exponential, on: [429, 500, 502, 503]}
|
|
138
|
+
- name: create_order
|
|
139
|
+
label: {id: Buat pengiriman}
|
|
140
|
+
request:
|
|
141
|
+
method: POST
|
|
142
|
+
url: https://api.biteship.com/v1/orders
|
|
143
|
+
headers: {Authorization: '{auth.api_key}'}
|
|
144
|
+
body:
|
|
145
|
+
reference_id: '{input.reference}'
|
|
146
|
+
shipper_contact_name: '{input.shipper_name}'
|
|
147
|
+
shipper_contact_phone: '{input.shipper_phone}'
|
|
148
|
+
shipper_organization: '{input.shipper_organization}'
|
|
149
|
+
origin_contact_name: '{input.origin_contact_name}'
|
|
150
|
+
origin_contact_phone: '{input.origin_contact_phone}'
|
|
151
|
+
origin_address: '{input.origin_address}'
|
|
152
|
+
origin_area_id: '{input.origin_area_id}'
|
|
153
|
+
origin_collection_method: '{input.collection_method}'
|
|
154
|
+
destination_contact_name: '{input.destination_contact_name}'
|
|
155
|
+
destination_contact_phone: '{input.destination_contact_phone}'
|
|
156
|
+
destination_address: '{input.destination_address}'
|
|
157
|
+
destination_area_id: '{input.destination_area_id}'
|
|
158
|
+
destination_postal_code: '{input.destination_postal_code}'
|
|
159
|
+
destination_note: '{input.destination_note}'
|
|
160
|
+
destination_cash_on_delivery: '{input.cod_amount}'
|
|
161
|
+
destination_cash_on_delivery_type: '{input.cod_type}'
|
|
162
|
+
courier_company: '{input.courier_company}'
|
|
163
|
+
courier_type: '{input.courier_type}'
|
|
164
|
+
courier_insurance: '{input.insured_value}'
|
|
165
|
+
delivery_type: '{input.delivery_type}'
|
|
166
|
+
order_note: '{input.note}'
|
|
167
|
+
items: '{input.items}'
|
|
168
|
+
input:
|
|
169
|
+
- {name: reference, type: data, required: true, help: {id: 'Nomor surat jalan atau faktur; Biteship menolak reference_id yang sudah dipakai'}}
|
|
170
|
+
- {name: shipper_name, type: data}
|
|
171
|
+
- {name: shipper_phone, type: data}
|
|
172
|
+
- {name: shipper_organization, type: data}
|
|
173
|
+
- {name: origin_contact_name, type: data, required: true}
|
|
174
|
+
- {name: origin_contact_phone, type: data, required: true}
|
|
175
|
+
- {name: origin_address, type: text, required: true}
|
|
176
|
+
- {name: origin_area_id, type: data, default: settings.origin_area_id}
|
|
177
|
+
- {name: collection_method, type: data, default: "'pickup'", help: {id: 'pickup (kurir menjemput) atau drop_off'}}
|
|
178
|
+
- {name: destination_contact_name, type: data, required: true}
|
|
179
|
+
- {name: destination_contact_phone, type: data, required: true}
|
|
180
|
+
- {name: destination_address, type: text, required: true}
|
|
181
|
+
- {name: destination_area_id, type: data}
|
|
182
|
+
- {name: destination_postal_code, type: int}
|
|
183
|
+
- {name: destination_note, type: data}
|
|
184
|
+
- {name: cod_amount, type: currency}
|
|
185
|
+
- {name: cod_type, type: data}
|
|
186
|
+
- {name: courier_company, type: data, required: true, help: {id: 'courier_code dari Cek ongkir, misalnya jne'}}
|
|
187
|
+
- {name: courier_type, type: data, required: true, help: {id: 'courier_service_code dari Cek ongkir, misalnya reg'}}
|
|
188
|
+
- {name: insured_value, type: currency}
|
|
189
|
+
- {name: delivery_type, type: data, default: "'now'", help: {id: 'now atau scheduled'}}
|
|
190
|
+
- {name: note, type: data}
|
|
191
|
+
- {name: items, type: json, required: true}
|
|
192
|
+
output:
|
|
193
|
+
shipment_ref: id
|
|
194
|
+
tracking_id: courier.tracking_id
|
|
195
|
+
waybill: courier.waybill_id
|
|
196
|
+
courier: courier.company
|
|
197
|
+
service: courier.type
|
|
198
|
+
price: price
|
|
199
|
+
status: status
|
|
200
|
+
reference: reference_id
|
|
201
|
+
retry: {max: 3, backoff: exponential, on: [429, 500, 502, 503]}
|
|
202
|
+
# Biteship refuses a second order with the same reference_id, so a retried call cannot ship twice
|
|
203
|
+
idempotency: input.reference
|
|
204
|
+
- name: get_order
|
|
205
|
+
label: {id: Ambil data pengiriman}
|
|
206
|
+
request:
|
|
207
|
+
method: GET
|
|
208
|
+
url: https://api.biteship.com/v1/orders/{input.shipment_ref}
|
|
209
|
+
headers: {Authorization: '{auth.api_key}'}
|
|
210
|
+
input:
|
|
211
|
+
- {name: shipment_ref, type: data, required: true}
|
|
212
|
+
output: {status: status, price: price, waybill: courier.waybill_id, tracking_id: courier.tracking_id}
|
|
213
|
+
retry: {max: 3, backoff: exponential, on: [429, 500, 502, 503]}
|
|
214
|
+
- name: cancel_order
|
|
215
|
+
label: {id: Batalkan pengiriman}
|
|
216
|
+
request:
|
|
217
|
+
method: POST
|
|
218
|
+
url: https://api.biteship.com/v1/orders/{input.shipment_ref}/cancel
|
|
219
|
+
headers: {Authorization: '{auth.api_key}'}
|
|
220
|
+
body:
|
|
221
|
+
cancellation_reason_code: '{input.reason_code}'
|
|
222
|
+
cancellation_reason: '{input.reason}'
|
|
223
|
+
input:
|
|
224
|
+
- {name: shipment_ref, type: data, required: true}
|
|
225
|
+
- {name: reason_code, type: data, default: "'others'", help: {id: 'change_courier, pickup_delay, change_address atau others'}}
|
|
226
|
+
- {name: reason, type: data}
|
|
227
|
+
output: {status: status, reason_code: cancellation_reason_code}
|
|
228
|
+
retry: {max: 3, backoff: exponential, on: [429, 500, 502, 503]}
|
|
229
|
+
idempotency: "'cancel:' + input.shipment_ref"
|
|
230
|
+
- name: get_tracking
|
|
231
|
+
label: {id: Lacak paket}
|
|
232
|
+
request:
|
|
233
|
+
method: GET
|
|
234
|
+
url: https://api.biteship.com/v1/trackings/{input.tracking_id}
|
|
235
|
+
headers: {Authorization: '{auth.api_key}'}
|
|
236
|
+
input:
|
|
237
|
+
- {name: tracking_id, type: data, required: true}
|
|
238
|
+
output: {status: status, waybill: waybill_id, courier: courier.company, history: history, link: link}
|
|
239
|
+
retry: {max: 3, backoff: exponential, on: [429, 500, 502, 503]}
|
|
240
|
+
limits:
|
|
241
|
+
note: {id: 'Order test (kunci biteship_test.) tidak dikirim kurir dan tidak ditagih; statusnya disimulasikan dari dashboard'}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"success": true, "message": "Order successfully deleted", "object": "order", "id": "ord-contoh-0002", "status": "cancelled", "cancellation_reason_code": "others", "cancellation_reason": "Salah alamat"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{"success": true, "message": "Order successfully created", "object": "order", "id": "ord-contoh-0001", "draft_order_id": null,
|
|
2
|
+
"shipper": {"name": "Toko Contoh", "phone": "081100000000", "organization": "Toko Contoh"},
|
|
3
|
+
"origin": {"contact_name": "Gudang Contoh", "contact_phone": "081100000000", "address": "Jl. Contoh No. 1, Bandung", "area_id": "IDNP9IDNC23IDND0001", "postal_code": 40132},
|
|
4
|
+
"destination": {"contact_name": "Pelanggan Contoh", "contact_phone": "081300000000", "address": "Jl. Tujuan No. 2, Bandung", "area_id": "IDNP9IDNC23IDND0002", "postal_code": 40617},
|
|
5
|
+
"courier": {"tracking_id": "trk-contoh-0001", "waybill_id": "WYB-CONTOH-0001", "company": "jne", "type": "reg", "insurance": {"amount": 0, "fee": 0}, "routing_code": null},
|
|
6
|
+
"delivery": {"datetime": "2026-11-07T10:00+07:00", "type": "now"},
|
|
7
|
+
"reference_id": "SJ-2026-00001", "items": [{"name": "Mi goreng (dus)", "value": 110000, "quantity": 2, "weight": 4000}],
|
|
8
|
+
"currency": "IDR", "tax_lines": [], "price": 18000, "metadata": {}, "note": "", "status": "confirmed"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"order_status.json": {"shipment_ref": "ord-contoh-0001", "waybill": "WYB-CONTOH-0001", "status": "delivered", "price": 18000, "delivered": true, "failed": false, "on_the_way": false},
|
|
3
|
+
"order_status_cancelled.json": {"shipment_ref": "ord-contoh-0002", "waybill": null, "delivered": false, "failed": true},
|
|
4
|
+
"order_price.json": {"price": 27000, "shipping_fee": 27000, "status": "picked"},
|
|
5
|
+
"order_waybill.json": {"waybill": "WYB-CONTOH-0001", "tracking_id": "trk-contoh-0001"},
|
|
6
|
+
"create_order.json": {"shipment_ref": "ord-contoh-0001", "tracking_id": "trk-contoh-0001", "waybill": "WYB-CONTOH-0001", "price": 18000, "status": "confirmed", "reference": "SJ-2026-00001"},
|
|
7
|
+
"cancel_order.json": {"status": "cancelled"},
|
|
8
|
+
"get_tracking.json": {"status": "delivered", "courier": "jne"}
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{"success": true, "object": "courier_pricing", "message": "Success to retrieve courier pricing", "code": 20001003,
|
|
2
|
+
"origin": {"area_id": "IDNP9IDNC23IDND0001", "postal_code": 40132},
|
|
3
|
+
"destination": {"area_id": "IDNP9IDNC23IDND0002", "postal_code": 40617},
|
|
4
|
+
"pricing": [
|
|
5
|
+
{"company": "jne", "courier_name": "JNE", "courier_code": "jne", "courier_service_name": "Reguler", "courier_service_code": "reg", "type": "reg", "service_type": "standard", "shipping_type": "parcel", "description": "Layanan reguler", "duration": "1 - 2 days", "shipment_duration_range": "1 - 2", "shipment_duration_unit": "days", "available_for_cash_on_delivery": true, "available_for_proof_of_delivery": false, "available_for_instant_waybill_id": true, "available_for_insurance": true, "available_collection_method": ["pickup", "drop_off"], "currency": "IDR", "shipping_fee": 18000, "insurance_fee": 0, "cash_on_delivery_fee": 0, "price": 18000, "tax_lines": []},
|
|
6
|
+
{"company": "sicepat", "courier_name": "SiCepat", "courier_code": "sicepat", "courier_service_name": "Reguler", "courier_service_code": "reg", "type": "reg", "service_type": "standard", "shipping_type": "parcel", "description": "Layanan reguler", "duration": "1 - 2 days", "shipment_duration_range": "1 - 2", "shipment_duration_unit": "days", "available_for_cash_on_delivery": true, "available_for_proof_of_delivery": false, "available_for_instant_waybill_id": true, "available_for_insurance": true, "available_collection_method": ["pickup"], "currency": "IDR", "shipping_fee": 15000, "insurance_fee": 0, "cash_on_delivery_fee": 0, "price": 15000, "tax_lines": []}
|
|
7
|
+
]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{"success": true, "message": "Successfully get tracking info", "object": "tracking", "id": "trk-contoh-0001", "waybill_id": "WYB-CONTOH-0001",
|
|
2
|
+
"courier": {"company": "jne", "driver_name": null, "driver_phone": null, "driver_photo_url": null, "driver_plate_number": null},
|
|
3
|
+
"origin": {"contact_name": "Gudang Contoh", "address": "Jl. Contoh No. 1, Bandung"},
|
|
4
|
+
"destination": {"contact_name": "Pelanggan Contoh", "address": "Jl. Tujuan No. 2, Bandung"},
|
|
5
|
+
"history": [{"note": "Paket dijemput kurir", "status": "picked", "updated_at": "2026-11-07T11:00:00+07:00", "service_type": "reg"},
|
|
6
|
+
{"note": "Paket diterima", "status": "delivered", "updated_at": "2026-11-08T14:00:00+07:00", "service_type": "reg"}],
|
|
7
|
+
"link": "https://track.example.test/WYB-CONTOH-0001", "order_id": "ord-contoh-0001", "status": "delivered"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"event": "order.price",
|
|
3
|
+
"order_id": "ord-contoh-0001",
|
|
4
|
+
"courier_tracking_id": "trk-contoh-0001",
|
|
5
|
+
"courier_waybill_id": "WYB-CONTOH-0001",
|
|
6
|
+
"status": "picked",
|
|
7
|
+
"price": 27000,
|
|
8
|
+
"shippment_fee": 27000,
|
|
9
|
+
"cash_on_delivery_fee": 0,
|
|
10
|
+
"proof_of_delivery_fee": 0
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"event": "order.status",
|
|
3
|
+
"courier_tracking_id": "trk-contoh-0001",
|
|
4
|
+
"courier_waybill_id": "WYB-CONTOH-0001",
|
|
5
|
+
"courier_company": "jne",
|
|
6
|
+
"courier_type": "reg",
|
|
7
|
+
"courier_driver_name": "Kurir Contoh",
|
|
8
|
+
"courier_driver_phone": "081200000000",
|
|
9
|
+
"courier_driver_photo_url": "",
|
|
10
|
+
"courier_driver_plate_number": "D 0000 XX",
|
|
11
|
+
"courier_link": "https://track.example.test/WYB-CONTOH-0001",
|
|
12
|
+
"order_id": "ord-contoh-0001",
|
|
13
|
+
"order_price": 18000,
|
|
14
|
+
"status": "delivered"
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"event": "order.status",
|
|
3
|
+
"courier_tracking_id": "trk-contoh-0002",
|
|
4
|
+
"courier_waybill_id": null,
|
|
5
|
+
"courier_company": "sicepat",
|
|
6
|
+
"courier_type": "reg",
|
|
7
|
+
"courier_driver_name": null,
|
|
8
|
+
"courier_driver_phone": null,
|
|
9
|
+
"courier_driver_photo_url": null,
|
|
10
|
+
"courier_driver_plate_number": null,
|
|
11
|
+
"courier_link": null,
|
|
12
|
+
"order_id": "ord-contoh-0002",
|
|
13
|
+
"order_price": 15000,
|
|
14
|
+
"status": "courier_not_found"
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"success": true, "areas": [{"id": "IDNP9IDNC23IDND0001", "name": "Coblong, Bandung, Jawa Barat. 40132", "country_name": "Indonesia", "country_code": "ID", "administrative_division_level_1_name": "Jawa Barat", "administrative_division_level_2_name": "Bandung", "administrative_division_level_3_name": "Coblong", "postal_code": 40132}]}
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
2
|
# A new statement line with money in looks for the invoice it pays. First choice: an open invoice whose number is in
|
|
3
|
-
# the transfer note. Otherwise: exactly one open invoice whose remaining amount equals
|
|
4
|
-
# the same amount -> no suggestion (the owner picks). It only suggests; the payment comes after the owner confirms.
|
|
3
|
+
# the transfer note (written loosely, see below). Otherwise: exactly one open invoice whose remaining amount equals
|
|
4
|
+
# the line. Two candidates of the same amount -> no suggestion (the owner picks). It only suggests; the payment comes after the owner confirms.
|
|
5
5
|
# outstanding is already net of PPh 23, so a customer who withheld tax still matches.
|
|
6
6
|
name: bank_transaction_suggest
|
|
7
7
|
label: {id: Usulan cocok mutasi ke faktur}
|
|
8
8
|
on: bank_transaction.created
|
|
9
9
|
if: event.amount > 0 && event.status == 'unmatched'
|
|
10
10
|
steps:
|
|
11
|
-
|
|
11
|
+
# The invoice number is the payment reference (payment_instruction.reference). Customers type it as they like:
|
|
12
|
+
# "INV-2026-00012", "inv 2026 00012", "INV202600012", "INV/2026/00012" all match, compared without case, spaces,
|
|
13
|
+
# dashes, slashes and dots on both sides. The number decides only when the line fits what the invoice still owes
|
|
14
|
+
# (a part payment fits, an overpayment does not): "0004 2" typed for invoice 00042 must not pull a larger line
|
|
15
|
+
# to invoice 0004; such a line falls back to the amount match.
|
|
16
|
+
- find_all: sales_invoice
|
|
17
|
+
where: >-
|
|
18
|
+
docstatus == 1 && outstanding >= event.amount && (event.description.contains(name) ||
|
|
19
|
+
event.description.upperAscii().replace(' ', '').replace('-', '').replace('/', '').replace('.', '')
|
|
20
|
+
.contains(name.upperAscii().replace(' ', '').replace('-', '').replace('/', '').replace('.', '')))
|
|
21
|
+
as: by_number
|
|
12
22
|
- {find_all: sales_invoice, where: "docstatus == 1 && outstanding == event.amount", as: by_amount}
|
|
13
23
|
- {find: bank_transaction, where: name == event.name, as: line}
|
|
14
24
|
- if: size(by_number) == 1
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# An invoice is submitted: copy the org's default bank account (rekening, QRIS, instruction) into its
|
|
3
|
+
# payment_instruction, with the invoice number as payment reference. The copy is what the print and the WhatsApp
|
|
4
|
+
# bill show, so an invoice keeps the account it was billed with. No default account: nothing is copied (the print
|
|
5
|
+
# falls back to the letterhead). Runs in the submit's transaction as the submitter: if the copy fails, the submit does.
|
|
6
|
+
name: payment_instruction_on_submit
|
|
7
|
+
label: {id: Salin cara bayar saat faktur diajukan}
|
|
8
|
+
on: sales_invoice.submitted
|
|
9
|
+
steps:
|
|
10
|
+
- {find: bank_account, where: "default_claim == 'default'", as: acct}
|
|
11
|
+
- create: payment_instruction
|
|
12
|
+
if: acct != null
|
|
13
|
+
set:
|
|
14
|
+
sales_invoice: event.name
|
|
15
|
+
bank_account: acct.name
|
|
16
|
+
reference: event.name
|
|
17
|
+
amount: event.amount_due
|
|
18
|
+
bank: acct.bank
|
|
19
|
+
account_no: acct.account_no
|
|
20
|
+
holder: acct.holder
|
|
21
|
+
instructions: acct.instructions
|
|
22
|
+
qris_payload: acct.qris_payload
|
|
23
|
+
qris_nmid: acct.qris_nmid
|
|
24
|
+
qris_merchant_name: acct.qris_merchant_name
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# Where customers pay: the business's own bank account and its static QRIS (from the bank or QRIS provider; no
|
|
3
|
+
# gateway). One active account per org is the default: invoices take their "cara bayar" from it when they are
|
|
4
|
+
# submitted (payment_instruction keeps that copy, so changing the account later never changes an old invoice).
|
|
5
|
+
# The QRIS text is optional (the text inside the QR, from scanning the sticker); when given it must be a static QRIS
|
|
6
|
+
# (EMVCo frame and CRC, point of initiation 11, rupiah, no fixed amount), and NMID and merchant name are read from it.
|
|
7
|
+
# The invoice print draws the QR from this text (a print page shows only data: images), so there is no image field:
|
|
8
|
+
# a photo of the sticker, if wanted, goes in the record's attachments.
|
|
9
|
+
name: bank_account
|
|
10
|
+
label: {id: Rekening & QRIS, en: Bank account & QRIS}
|
|
11
|
+
icon: bank
|
|
12
|
+
naming: REK-{####}
|
|
13
|
+
title_field: title
|
|
14
|
+
permissions:
|
|
15
|
+
# Changing where customers pay is a money control: only finance (and the owner's head office) write it.
|
|
16
|
+
- {role: finance_manager, read: true, create: true, write: true, delete: true, export: true}
|
|
17
|
+
# head office does not delete: removing the default account leaves the next invoices without "cara bayar" and the
|
|
18
|
+
# owner would not see it (card t_5b705279); finance and the owner delete
|
|
19
|
+
- {role: head_office, read: true, create: true, write: true, export: true}
|
|
20
|
+
# whoever submits an invoice reads the default account: the flow payment_instruction_on_submit runs as them
|
|
21
|
+
- {role: sales_manager, read: true}
|
|
22
|
+
- {role: sales_rep, read: true}
|
|
23
|
+
- {role: field_sales, read: true}
|
|
24
|
+
- {role: project_admin, read: true}
|
|
25
|
+
fields:
|
|
26
|
+
- name: bank
|
|
27
|
+
type: data
|
|
28
|
+
label: {id: Bank}
|
|
29
|
+
required: true
|
|
30
|
+
in_list: true
|
|
31
|
+
- name: account_no
|
|
32
|
+
type: data
|
|
33
|
+
label: {id: Nomor rekening}
|
|
34
|
+
help: {id: 'Angka saja, tanpa spasi, titik atau strip.'}
|
|
35
|
+
required: true
|
|
36
|
+
in_list: true
|
|
37
|
+
- name: holder
|
|
38
|
+
type: data
|
|
39
|
+
label: {id: Atas nama}
|
|
40
|
+
required: true
|
|
41
|
+
in_list: true
|
|
42
|
+
- name: title
|
|
43
|
+
type: data
|
|
44
|
+
label: {id: Rekening}
|
|
45
|
+
hidden: true
|
|
46
|
+
compute: "bank + ' ' + account_no + ' a.n. ' + holder"
|
|
47
|
+
- name: is_default
|
|
48
|
+
type: check
|
|
49
|
+
label: {id: Rekening utama di faktur}
|
|
50
|
+
default: 'false'
|
|
51
|
+
in_list: true
|
|
52
|
+
- name: active
|
|
53
|
+
type: check
|
|
54
|
+
label: {id: Aktif}
|
|
55
|
+
default: 'true'
|
|
56
|
+
# unique per org (the kernel's unique index is per org and skips ''): at most one active default account
|
|
57
|
+
- name: default_claim
|
|
58
|
+
type: data
|
|
59
|
+
label: {id: Rekening utama}
|
|
60
|
+
hidden: true
|
|
61
|
+
unique: true
|
|
62
|
+
compute: "is_default && active ? 'default' : ''"
|
|
63
|
+
- name: instructions
|
|
64
|
+
type: text
|
|
65
|
+
label: {id: Instruksi bayar}
|
|
66
|
+
help: {id: 'Satu dua kalimat untuk pelanggan, misalnya jam konfirmasi atau kirim bukti ke WhatsApp. Maksimal 280 huruf.'}
|
|
67
|
+
- name: qris_payload
|
|
68
|
+
type: text
|
|
69
|
+
label: {id: Isi QRIS (teks)}
|
|
70
|
+
help: {id: 'Opsional: teks hasil pindai QRIS statis, diawali 000201. Dicek formatnya; NMID dan nama merchant dibaca dari sini.'}
|
|
71
|
+
- name: qris_nmid
|
|
72
|
+
type: data
|
|
73
|
+
label: {id: NMID}
|
|
74
|
+
compute: "qris_payload == '' ? '' : qris_payload.emvcoTag('51').emvcoTag('02')"
|
|
75
|
+
- name: qris_merchant_name
|
|
76
|
+
type: data
|
|
77
|
+
label: {id: Nama merchant QRIS}
|
|
78
|
+
compute: "qris_payload == '' ? '' : qris_payload.emvcoTag('59')"
|
|
79
|
+
rules:
|
|
80
|
+
- name: account_digits
|
|
81
|
+
on: save
|
|
82
|
+
check: "account_no.matches('^[0-9]{5,20}$')"
|
|
83
|
+
message: {id: 'Nomor rekening hanya angka (5 sampai 20 digit), tanpa spasi, titik atau strip'}
|
|
84
|
+
- name: holder_not_blank
|
|
85
|
+
on: save
|
|
86
|
+
check: "holder.trim() != '' && bank.trim() != ''"
|
|
87
|
+
message: {id: Isi nama bank dan nama pemilik rekening}
|
|
88
|
+
- name: default_is_active
|
|
89
|
+
on: save
|
|
90
|
+
check: "!is_default || active"
|
|
91
|
+
message: {id: Rekening utama harus aktif}
|
|
92
|
+
- name: instructions_short
|
|
93
|
+
on: save
|
|
94
|
+
check: "size(instructions) <= 280"
|
|
95
|
+
message: {id: 'Instruksi bayar maksimal 280 huruf'}
|
|
96
|
+
- name: qris_format
|
|
97
|
+
on: save
|
|
98
|
+
check: "qris_payload == '' || qris_payload.emvcoValid()"
|
|
99
|
+
message: {id: 'Isi QRIS tidak valid (format atau kode CRC salah). Pindai ulang stiker QRIS dan tempel teksnya tanpa spasi'}
|
|
100
|
+
- name: qris_static
|
|
101
|
+
on: save
|
|
102
|
+
check: "qris_payload == '' || qris_payload.emvcoTag('01') == '11'"
|
|
103
|
+
message: {id: 'Ini QRIS dinamis (sekali pakai). Faktur butuh QRIS statis dari stiker toko'}
|
|
104
|
+
- name: qris_rupiah
|
|
105
|
+
on: save
|
|
106
|
+
check: "qris_payload == '' || qris_payload.emvcoTag('53') == '360'"
|
|
107
|
+
message: {id: QRIS harus dalam rupiah}
|
|
108
|
+
- name: qris_no_fixed_amount
|
|
109
|
+
on: save
|
|
110
|
+
check: "qris_payload == '' || qris_payload.emvcoTag('54') == ''"
|
|
111
|
+
message: {id: 'QRIS ini memuat nominal tetap; pakai QRIS statis tanpa nominal supaya pelanggan mengisi jumlah tagihan'}
|
|
112
|
+
# 55 = tip or convenience indicator: 02 a fixed fee (amount in 56), 03 a percentage (in 57). Either makes the
|
|
113
|
+
# customer pay more than the invoice, so the transfer never matches it. 01 (the customer may add a tip) is allowed.
|
|
114
|
+
- name: qris_no_fee
|
|
115
|
+
on: save
|
|
116
|
+
check: "qris_payload == '' || (qris_payload.emvcoTag('55') != '02' && qris_payload.emvcoTag('55') != '03' && qris_payload.emvcoTag('56') == '' && qris_payload.emvcoTag('57') == '')"
|
|
117
|
+
message: {id: 'QRIS ini menambah biaya layanan ke pelanggan; pakai QRIS statis tanpa biaya supaya nominal transfer sama dengan tagihan'}
|
|
118
|
+
- name: qris_has_merchant
|
|
119
|
+
on: save
|
|
120
|
+
check: "qris_payload == '' || (qris_payload.emvcoTag('59').trim() != '' && qris_payload.emvcoTag('51').emvcoTag('02').trim() != '')"
|
|
121
|
+
message: {id: 'QRIS tanpa nama merchant atau NMID; pakai QRIS dari bank atau penyedia QRIS resmi'}
|
|
122
|
+
views:
|
|
123
|
+
list:
|
|
124
|
+
columns: [name, bank, account_no, holder, is_default, active, qris_nmid]
|
|
125
|
+
form:
|
|
126
|
+
layout:
|
|
127
|
+
- section: {id: Rekening}
|
|
128
|
+
columns:
|
|
129
|
+
- [bank, account_no, holder]
|
|
130
|
+
- [is_default, active, instructions]
|
|
131
|
+
- section: {id: QRIS statis}
|
|
132
|
+
columns:
|
|
133
|
+
- [qris_payload]
|
|
134
|
+
- [qris_nmid, qris_merchant_name]
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
|
|
2
|
+
# "Cara bayar" of one submitted invoice: a copy of the default bank_account (rekening, QRIS, instruction) and the
|
|
3
|
+
# payment reference, made by the flow payment_instruction_on_submit when the invoice is submitted. A submitted
|
|
4
|
+
# invoice is immutable, so the copy lives here (one per invoice, unique), and editing or replacing the account
|
|
5
|
+
# later never changes what an earlier invoice told the customer. Nobody writes or deletes it; the copied fields are
|
|
6
|
+
# read-only (only the flow sets them) and must equal the account at creation, so it cannot be made up by hand.
|
|
7
|
+
# An invoice submitted while the org has no default account has none: its print falls back to the letterhead.
|
|
8
|
+
name: payment_instruction
|
|
9
|
+
label: {id: Cara bayar faktur, en: Invoice payment instruction}
|
|
10
|
+
icon: bank
|
|
11
|
+
naming: CB-{YYYY}-{#####}
|
|
12
|
+
title_field: sales_invoice
|
|
13
|
+
permissions:
|
|
14
|
+
# create: the flow runs as whoever submits the invoice
|
|
15
|
+
- {role: finance_manager, read: true, create: true, export: true}
|
|
16
|
+
- {role: sales_manager, read: true, create: true, export: true}
|
|
17
|
+
- {role: head_office, read: true}
|
|
18
|
+
- {role: sales_rep, read: true}
|
|
19
|
+
# not field_sales: its row scope is salesman, which this model lacks, so it would read every invoice's amount
|
|
20
|
+
- {role: project_admin, read: true}
|
|
21
|
+
fields:
|
|
22
|
+
- name: sales_invoice
|
|
23
|
+
type: link
|
|
24
|
+
to: sales_invoice
|
|
25
|
+
label: {id: Faktur}
|
|
26
|
+
required: true
|
|
27
|
+
unique: true
|
|
28
|
+
in_list: true
|
|
29
|
+
- name: bank_account
|
|
30
|
+
type: link
|
|
31
|
+
to: bank_account
|
|
32
|
+
label: {id: Rekening}
|
|
33
|
+
required: true
|
|
34
|
+
in_list: true
|
|
35
|
+
# Payment reference the customer writes in the transfer note; bank_transaction_suggest finds the invoice by it.
|
|
36
|
+
- {name: reference, type: data, label: {id: Referensi bayar}, read_only: true, in_list: true}
|
|
37
|
+
- {name: amount, type: currency, label: {id: Tagihan saat diajukan}, read_only: true}
|
|
38
|
+
- {name: bank, type: data, label: {id: Bank}, read_only: true}
|
|
39
|
+
- {name: account_no, type: data, label: {id: Nomor rekening}, read_only: true}
|
|
40
|
+
- {name: holder, type: data, label: {id: Atas nama}, read_only: true}
|
|
41
|
+
- {name: instructions, type: text, label: {id: Instruksi bayar}, read_only: true}
|
|
42
|
+
- {name: qris_payload, type: text, label: {id: Isi QRIS (teks)}, read_only: true}
|
|
43
|
+
- {name: qris_nmid, type: data, label: {id: NMID}, read_only: true}
|
|
44
|
+
- {name: qris_merchant_name, type: data, label: {id: Nama merchant QRIS}, read_only: true}
|
|
45
|
+
rules:
|
|
46
|
+
- name: invoice_submitted
|
|
47
|
+
on: save
|
|
48
|
+
check: sales_invoice.docstatus == 1
|
|
49
|
+
message: {id: Cara bayar dibuat saat faktur diajukan}
|
|
50
|
+
- name: copy_of_invoice
|
|
51
|
+
on: save
|
|
52
|
+
check: reference == sales_invoice.name && amount == sales_invoice.amount_due
|
|
53
|
+
message: {id: Referensi dan nominal harus dari faktur ini}
|
|
54
|
+
- name: copy_of_account
|
|
55
|
+
on: save
|
|
56
|
+
check: >-
|
|
57
|
+
bank == bank_account.bank && account_no == bank_account.account_no && holder == bank_account.holder &&
|
|
58
|
+
instructions == bank_account.instructions && qris_payload == bank_account.qris_payload &&
|
|
59
|
+
qris_nmid == bank_account.qris_nmid && qris_merchant_name == bank_account.qris_merchant_name
|
|
60
|
+
message: {id: Cara bayar harus salinan rekening yang dipilih}
|
|
61
|
+
- name: account_active
|
|
62
|
+
on: save
|
|
63
|
+
check: bank_account.active
|
|
64
|
+
message: {id: Rekening tidak aktif}
|
|
65
|
+
views:
|
|
66
|
+
list:
|
|
67
|
+
columns: [name, sales_invoice, reference, bank, account_no, qris_nmid]
|
|
68
|
+
sort: -name
|
|
@@ -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: invoicing
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.4.1
|
|
4
4
|
title: {id: Faktur, en: Invoicing}
|
|
5
5
|
requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0}
|
|
6
6
|
optional: {outlets: ^1.0, tax_id: ^1.0, currency: ^1.0, orders: ^1.0, projects: ^1.0, delivery: ^1.0}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# Rel uang U13/U17 (ready, not active): A payment-link callback (PAID or SETTLED is paid; EXPIRED is not). Xendit's external_id is
|
|
3
|
+
# the invoice number. The callback becomes a DRAFT payment allocated to that invoice (a flow cannot submit; finance
|
|
4
|
+
# submits it, which settles the invoice), carrying gateway xendit and the gateway id.
|
|
5
|
+
# Not active yet: the kernel has no connector runtime (no /hooks), so nothing fires this flow except
|
|
6
|
+
# POST /api/v1/flows/<name>/run with the callback as event (how day_one tests it). It is written against the xendit
|
|
7
|
+
# connector's trigger, not a payment.* port, because ports are not in the kernel yet (contract 0002 §B, proposal
|
|
8
|
+
# 0023); the three payment_from_xendit_* flows hold the same steps, one per trigger.
|
|
9
|
+
# Guards: a callback without gateway_ref, external_id, paid or paid_amount is skipped; only a completed payment of a
|
|
10
|
+
# positive amount records money. The gateway id is claimed BEFORE the payment is made: a new claim is an insert into
|
|
11
|
+
# gateway_ref_claim's unique index, so of two callbacks racing in parallel the second waits for the first and is
|
|
12
|
+
# refused (its whole run rolls back, nothing recorded); a later repeat finds the live payment or its claim and records
|
|
13
|
+
# nothing. A claim left by a deleted draft is released first (gateway_ref emptied, as payment_gateway_release does)
|
|
14
|
+
# and a new claim inserted, so racing repeats after a delete are refused the same way. Only a
|
|
15
|
+
# submitted invoice is paid (a cancelled one, or an unknown number, records nothing and tells the owner, since the
|
|
16
|
+
# money did arrive at Xendit); the allocation never exceeds what the invoice still owes after open drafts, the rest
|
|
17
|
+
# stays unallocated. A method outside payment's options is recorded as 'other'.
|
|
18
|
+
name: payment_from_xendit_invoice
|
|
19
|
+
label: {id: Link bayar Xendit dibayar jadi pembayaran}
|
|
20
|
+
on: xendit.invoice_paid
|
|
21
|
+
if: >-
|
|
22
|
+
'gateway_ref' in event && 'external_id' in event && 'paid' in event && 'paid_amount' in event &&
|
|
23
|
+
event.gateway_ref != '' && event.paid == true && event.paid_amount > 0
|
|
24
|
+
idempotency: event.gateway_ref
|
|
25
|
+
steps:
|
|
26
|
+
- {find: payment, where: "gateway_ref == event.gateway_ref && docstatus != 2", as: done}
|
|
27
|
+
- {find: sales_invoice, where: "name == event.external_id && docstatus == 1", as: inv}
|
|
28
|
+
- {find_all: payment, where: "docstatus == 0 && reference == event.external_id", as: drafts}
|
|
29
|
+
- {find: gateway_ref_claim, where: gateway_ref == event.gateway_ref, as: held}
|
|
30
|
+
# the payment the claim names, if it is still alive (a deleted draft is gone; a renamed draft is re-pointed on submit)
|
|
31
|
+
- {find: payment, where: "held != null && name == held.payment && docstatus != 2", as: holder}
|
|
32
|
+
- update: held
|
|
33
|
+
if: done == null && inv != null && held != null && holder == null
|
|
34
|
+
set: {gateway_ref: "''", released_ref: event.gateway_ref}
|
|
35
|
+
- create: gateway_ref_claim
|
|
36
|
+
if: done == null && inv != null && (held == null || holder == null)
|
|
37
|
+
set: {gateway_ref: event.gateway_ref, payment: "''"}
|
|
38
|
+
as: claim
|
|
39
|
+
- create: payment
|
|
40
|
+
if: done == null && inv != null && (held == null || holder == null)
|
|
41
|
+
set:
|
|
42
|
+
direction: "'receive'"
|
|
43
|
+
customer: inv.customer
|
|
44
|
+
payment_date: today()
|
|
45
|
+
amount: event.paid_amount
|
|
46
|
+
method: "'method' in event && event.method in ['va', 'qris', 'ewallet', 'transfer'] ? event.method : 'other'"
|
|
47
|
+
gateway: "'xendit'"
|
|
48
|
+
gateway_ref: event.gateway_ref
|
|
49
|
+
reference: inv.name
|
|
50
|
+
notes: "'Dari Xendit ' + event.gateway_ref"
|
|
51
|
+
allocations: "min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum()) > 0 ? [{'sales_invoice': inv.name, 'amount': min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum())}] : []"
|
|
52
|
+
as: pay
|
|
53
|
+
- update: claim
|
|
54
|
+
if: done == null && inv != null && (held == null || holder == null)
|
|
55
|
+
set: {payment: pay.name}
|
|
56
|
+
- notify: owner
|
|
57
|
+
if: done == null && inv == null
|
|
58
|
+
channel: email
|
|
59
|
+
template: {id: 'Xendit {event.gateway_ref}: Rp {event.paid_amount} untuk {event.external_id}, faktur tidak ada/terbuka. Catat manual.'}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# Rel uang U13/U17 (ready, not active): A QR callback (qr.payment SUCCEEDED is paid; a refund or a failed QR is not). Xendit's external_id is
|
|
3
|
+
# the invoice number. The callback becomes a DRAFT payment allocated to that invoice (a flow cannot submit; finance
|
|
4
|
+
# submits it, which settles the invoice), carrying gateway xendit and the gateway id.
|
|
5
|
+
# Not active yet: the kernel has no connector runtime (no /hooks), so nothing fires this flow except
|
|
6
|
+
# POST /api/v1/flows/<name>/run with the callback as event (how day_one tests it). It is written against the xendit
|
|
7
|
+
# connector's trigger, not a payment.* port, because ports are not in the kernel yet (contract 0002 §B, proposal
|
|
8
|
+
# 0023); the three payment_from_xendit_* flows hold the same steps, one per trigger.
|
|
9
|
+
# Guards: a callback without gateway_ref, external_id, paid or paid_amount is skipped; only a completed payment of a
|
|
10
|
+
# positive amount records money. The gateway id is claimed BEFORE the payment is made: a new claim is an insert into
|
|
11
|
+
# gateway_ref_claim's unique index, so of two callbacks racing in parallel the second waits for the first and is
|
|
12
|
+
# refused (its whole run rolls back, nothing recorded); a later repeat finds the live payment or its claim and records
|
|
13
|
+
# nothing. A claim left by a deleted draft is released first (gateway_ref emptied, as payment_gateway_release does)
|
|
14
|
+
# and a new claim inserted, so racing repeats after a delete are refused the same way. Only a
|
|
15
|
+
# submitted invoice is paid (a cancelled one, or an unknown number, records nothing and tells the owner, since the
|
|
16
|
+
# money did arrive at Xendit); the allocation never exceeds what the invoice still owes after open drafts, the rest
|
|
17
|
+
# stays unallocated. A method outside payment's options is recorded as 'other'.
|
|
18
|
+
name: payment_from_xendit_qr
|
|
19
|
+
label: {id: QRIS Xendit dibayar jadi pembayaran}
|
|
20
|
+
on: xendit.qr_paid
|
|
21
|
+
if: >-
|
|
22
|
+
'gateway_ref' in event && 'external_id' in event && 'paid' in event && 'paid_amount' in event &&
|
|
23
|
+
event.gateway_ref != '' && event.paid == true && event.paid_amount > 0
|
|
24
|
+
idempotency: event.gateway_ref
|
|
25
|
+
steps:
|
|
26
|
+
- {find: payment, where: "gateway_ref == event.gateway_ref && docstatus != 2", as: done}
|
|
27
|
+
- {find: sales_invoice, where: "name == event.external_id && docstatus == 1", as: inv}
|
|
28
|
+
- {find_all: payment, where: "docstatus == 0 && reference == event.external_id", as: drafts}
|
|
29
|
+
- {find: gateway_ref_claim, where: gateway_ref == event.gateway_ref, as: held}
|
|
30
|
+
# the payment the claim names, if it is still alive (a deleted draft is gone; a renamed draft is re-pointed on submit)
|
|
31
|
+
- {find: payment, where: "held != null && name == held.payment && docstatus != 2", as: holder}
|
|
32
|
+
- update: held
|
|
33
|
+
if: done == null && inv != null && held != null && holder == null
|
|
34
|
+
set: {gateway_ref: "''", released_ref: event.gateway_ref}
|
|
35
|
+
- create: gateway_ref_claim
|
|
36
|
+
if: done == null && inv != null && (held == null || holder == null)
|
|
37
|
+
set: {gateway_ref: event.gateway_ref, payment: "''"}
|
|
38
|
+
as: claim
|
|
39
|
+
- create: payment
|
|
40
|
+
if: done == null && inv != null && (held == null || holder == null)
|
|
41
|
+
set:
|
|
42
|
+
direction: "'receive'"
|
|
43
|
+
customer: inv.customer
|
|
44
|
+
payment_date: today()
|
|
45
|
+
amount: event.paid_amount
|
|
46
|
+
method: "'method' in event && event.method in ['va', 'qris', 'ewallet', 'transfer'] ? event.method : 'other'"
|
|
47
|
+
gateway: "'xendit'"
|
|
48
|
+
gateway_ref: event.gateway_ref
|
|
49
|
+
reference: inv.name
|
|
50
|
+
notes: "'Dari Xendit ' + event.gateway_ref"
|
|
51
|
+
allocations: "min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum()) > 0 ? [{'sales_invoice': inv.name, 'amount': min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum())}] : []"
|
|
52
|
+
as: pay
|
|
53
|
+
- update: claim
|
|
54
|
+
if: done == null && inv != null && (held == null || holder == null)
|
|
55
|
+
set: {payment: pay.name}
|
|
56
|
+
- notify: owner
|
|
57
|
+
if: done == null && inv == null
|
|
58
|
+
channel: email
|
|
59
|
+
template: {id: 'Xendit {event.gateway_ref}: Rp {event.paid_amount} untuk {event.external_id}, faktur tidak ada/terbuka. Catat manual.'}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# Rel uang U13/U17 (ready, not active): A fixed VA payment (always a completed payment). Xendit's external_id is
|
|
3
|
+
# the invoice number. The callback becomes a DRAFT payment allocated to that invoice (a flow cannot submit; finance
|
|
4
|
+
# submits it, which settles the invoice), carrying gateway xendit and the gateway id.
|
|
5
|
+
# Not active yet: the kernel has no connector runtime (no /hooks), so nothing fires this flow except
|
|
6
|
+
# POST /api/v1/flows/<name>/run with the callback as event (how day_one tests it). It is written against the xendit
|
|
7
|
+
# connector's trigger, not a payment.* port, because ports are not in the kernel yet (contract 0002 §B, proposal
|
|
8
|
+
# 0023); the three payment_from_xendit_* flows hold the same steps, one per trigger.
|
|
9
|
+
# Guards: a callback without gateway_ref, external_id, paid or paid_amount is skipped; only a completed payment of a
|
|
10
|
+
# positive amount records money. The gateway id is claimed BEFORE the payment is made: a new claim is an insert into
|
|
11
|
+
# gateway_ref_claim's unique index, so of two callbacks racing in parallel the second waits for the first and is
|
|
12
|
+
# refused (its whole run rolls back, nothing recorded); a later repeat finds the live payment or its claim and records
|
|
13
|
+
# nothing. A claim left by a deleted draft is released first (gateway_ref emptied, as payment_gateway_release does)
|
|
14
|
+
# and a new claim inserted, so racing repeats after a delete are refused the same way. Only a
|
|
15
|
+
# submitted invoice is paid (a cancelled one, or an unknown number, records nothing and tells the owner, since the
|
|
16
|
+
# money did arrive at Xendit); the allocation never exceeds what the invoice still owes after open drafts, the rest
|
|
17
|
+
# stays unallocated. A method outside payment's options is recorded as 'other'.
|
|
18
|
+
name: payment_from_xendit_va
|
|
19
|
+
label: {id: Virtual account Xendit dibayar jadi pembayaran}
|
|
20
|
+
on: xendit.va_paid
|
|
21
|
+
if: >-
|
|
22
|
+
'gateway_ref' in event && 'external_id' in event && 'paid' in event && 'paid_amount' in event &&
|
|
23
|
+
event.gateway_ref != '' && event.paid == true && event.paid_amount > 0
|
|
24
|
+
idempotency: event.gateway_ref
|
|
25
|
+
steps:
|
|
26
|
+
- {find: payment, where: "gateway_ref == event.gateway_ref && docstatus != 2", as: done}
|
|
27
|
+
- {find: sales_invoice, where: "name == event.external_id && docstatus == 1", as: inv}
|
|
28
|
+
- {find_all: payment, where: "docstatus == 0 && reference == event.external_id", as: drafts}
|
|
29
|
+
- {find: gateway_ref_claim, where: gateway_ref == event.gateway_ref, as: held}
|
|
30
|
+
# the payment the claim names, if it is still alive (a deleted draft is gone; a renamed draft is re-pointed on submit)
|
|
31
|
+
- {find: payment, where: "held != null && name == held.payment && docstatus != 2", as: holder}
|
|
32
|
+
- update: held
|
|
33
|
+
if: done == null && inv != null && held != null && holder == null
|
|
34
|
+
set: {gateway_ref: "''", released_ref: event.gateway_ref}
|
|
35
|
+
- create: gateway_ref_claim
|
|
36
|
+
if: done == null && inv != null && (held == null || holder == null)
|
|
37
|
+
set: {gateway_ref: event.gateway_ref, payment: "''"}
|
|
38
|
+
as: claim
|
|
39
|
+
- create: payment
|
|
40
|
+
if: done == null && inv != null && (held == null || holder == null)
|
|
41
|
+
set:
|
|
42
|
+
direction: "'receive'"
|
|
43
|
+
customer: inv.customer
|
|
44
|
+
payment_date: today()
|
|
45
|
+
amount: event.paid_amount
|
|
46
|
+
method: "'method' in event && event.method in ['va', 'qris', 'ewallet', 'transfer'] ? event.method : 'other'"
|
|
47
|
+
gateway: "'xendit'"
|
|
48
|
+
gateway_ref: event.gateway_ref
|
|
49
|
+
reference: inv.name
|
|
50
|
+
notes: "'Dari Xendit ' + event.gateway_ref"
|
|
51
|
+
allocations: "min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum()) > 0 ? [{'sales_invoice': inv.name, 'amount': min(event.paid_amount, inv.outstanding - drafts.map(p, p.allocated_total).sum())}] : []"
|
|
52
|
+
as: pay
|
|
53
|
+
- update: claim
|
|
54
|
+
if: done == null && inv != null && (held == null || holder == null)
|
|
55
|
+
set: {payment: pay.name}
|
|
56
|
+
- notify: owner
|
|
57
|
+
if: done == null && inv == null
|
|
58
|
+
channel: email
|
|
59
|
+
template: {id: 'Xendit {event.gateway_ref}: Rp {event.paid_amount} untuk {event.external_id}, faktur tidak ada/terbuka. Catat manual.'}
|