@rangka-os/create 0.5.0-alpha.10 → 0.5.0-alpha.11
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/dapur/app.rk +35 -0
- package/template/base/apps/dapur/dashboards/dapur_hari_ini.rk +26 -0
- package/template/base/apps/fnb_cabang/app.rk +2 -2
- package/template/base/apps/fnb_cabang/dashboards/outlet_harian.rk +36 -0
- package/template/base/apps/jasa_proyek/app.rk +5 -2
- package/template/base/apps/jasa_proyek/dashboards/absen_saya.rk +15 -0
- package/template/base/apps/jasa_proyek/dashboards/rekap_absen.rk +18 -0
- package/template/base/apps/kelas_kursus/app.rk +1 -1
- package/template/base/apps/kelas_kursus/dashboards/kelas_saya.rk +41 -0
- package/template/base/apps/penjualan_harian/app.rk +1 -1
- package/template/base/apps/ritel_cabang/app.rk +1 -1
- package/template/base/apps/sewa_alat/app.rk +7 -5
- package/template/base/apps/sewa_alat/dashboards/alat_hari_ini.rk +90 -0
- package/template/base/apps/stok_outlet/app.rk +1 -1
- package/template/base/apps/stok_outlet/dashboards/outlet_hari_ini.rk +33 -0
- package/template/base/connectors/doku/connector.rk +128 -0
- package/template/base/connectors/doku/fixtures/create_checkout.json +6 -0
- package/template/base/connectors/doku/fixtures/expect.json +38 -0
- package/template/base/connectors/doku/fixtures/payment_notified.json +5 -0
- package/template/base/connectors/doku/fixtures/payment_notified_failed.json +3 -0
- package/template/base/connectors/doku/fixtures/payment_notified_no_type.json +3 -0
- package/template/base/connectors/doku/fixtures/payment_notified_null_type.json +3 -0
- package/template/base/connectors/doku/fixtures/payment_notified_refund.json +3 -0
- package/template/base/connectors/doku/mock/doku_mock.py +206 -0
- package/template/base/connectors/moka/connector.rk +46 -12
- package/template/base/connectors/moka/fixtures/expect.json +44 -0
- package/template/base/connectors/moka/fixtures/latest_transactions.json +79 -0
- package/template/base/connectors/moka/fixtures/list_items.json +4 -0
- package/template/base/connectors/moka/fixtures/list_outlets.json +4 -0
- package/template/base/connectors/moka/fixtures/transaction_created.json +44 -0
- package/template/base/connectors/moka/fixtures/transaction_created_refund.json +39 -0
- package/template/base/connectors/moka/fixtures/transaction_created_refund_later.json +51 -0
- package/template/base/modules/courses/models/course_batch.rk +7 -0
- package/template/base/modules/courses/models/course_session.rk +4 -1
- package/template/base/modules/courses/module.rk +1 -1
- package/template/base/modules/kitchen/flows/kitchen_ticket_on_sale.rk +29 -0
- package/template/base/modules/kitchen/flows/kitchen_ticket_on_update.rk +26 -0
- package/template/base/modules/kitchen/flows/kitchen_ticket_on_void.rk +15 -0
- package/template/base/modules/kitchen/models/kitchen_guard.rk +35 -0
- package/template/base/modules/kitchen/models/kitchen_route.rk +26 -0
- package/template/base/modules/kitchen/models/kitchen_station.rk +40 -0
- package/template/base/modules/kitchen/models/kitchen_ticket.rk +78 -0
- package/template/base/modules/kitchen/models/kitchen_ticket_item.rk +10 -0
- package/template/base/modules/kitchen/module.rk +18 -0
- package/template/base/modules/kitchen/print/kitchen_ticket.html +29 -0
- package/template/base/modules/kitchen/print/kitchen_ticket.rk +9 -0
- package/template/base/modules/kitchen/roles/kitchen.rk +6 -0
- package/template/base/modules/kitchen/screens/dapur.rk +22 -0
- package/template/base/modules/outlet_sales/flows/moka_daily_sales.rk +57 -0
- package/template/base/modules/outlet_sales/flows/moka_line_mapped.rk +14 -0
- package/template/base/modules/outlet_sales/flows/moka_transaction_staged.rk +90 -0
- package/template/base/modules/outlet_sales/models/moka_sale_line.rk +53 -0
- package/template/base/modules/outlet_sales/models/moka_transaction.rk +26 -0
- package/template/base/modules/outlet_sales/models/outlet_sales.rk +4 -3
- package/template/base/modules/outlet_sales/module.rk +1 -1
- package/template/base/modules/outlets/models/outlet.rk +9 -0
- package/template/base/modules/payments/flows/payment_from_doku.rk +73 -0
- package/template/base/modules/payments/models/payment.rk +1 -0
- package/template/base/modules/payments/module.rk +1 -1
- package/template/base/modules/projects/flows/attendance_close_cancel_guard.rk +15 -0
- package/template/base/modules/projects/flows/attendance_close_on_submit.rk +64 -0
- package/template/base/modules/projects/flows/attendance_log_cancel_guard.rk +14 -0
- package/template/base/modules/projects/flows/attendance_log_guard_created.rk +15 -0
- package/template/base/modules/projects/flows/attendance_log_guard_submitted.rk +34 -0
- package/template/base/modules/projects/flows/attendance_log_guard_updated.rk +14 -0
- package/template/base/modules/projects/flows/timesheet_attendance_overlap_guard.rk +20 -0
- package/template/base/modules/projects/models/assignment.rk +21 -1
- package/template/base/modules/projects/models/attendance_close.rk +63 -0
- package/template/base/modules/projects/models/attendance_guard.rk +57 -0
- package/template/base/modules/projects/models/attendance_log.rk +266 -0
- package/template/base/modules/projects/models/timesheet.rk +7 -1
- package/template/base/modules/projects/models/work_site.rk +73 -0
- package/template/base/modules/projects/module.rk +1 -1
- package/template/base/modules/projects/roles/field_worker.rk +7 -0
- package/template/base/modules/projects/roles/site_supervisor.rk +7 -0
- package/template/base/modules/rental/flows/rental_checkout_on_cancel.rk +11 -0
- package/template/base/modules/rental/flows/rental_checkout_on_submit.rk +13 -1
- package/template/base/modules/rental/flows/rental_return_on_cancel.rk +12 -1
- package/template/base/modules/rental/flows/rental_return_on_submit.rk +17 -0
- package/template/base/modules/rental/models/rental_booking.rk +1 -0
- package/template/base/modules/rental/models/rental_checkout.rk +61 -2
- package/template/base/modules/rental/models/rental_checkout_unit.rk +22 -0
- package/template/base/modules/rental/models/rental_guard.rk +21 -0
- package/template/base/modules/rental/models/rental_item.rk +10 -2
- package/template/base/modules/rental/models/rental_return.rk +67 -8
- package/template/base/modules/rental/models/rental_return_unit.rk +29 -0
- package/template/base/modules/rental/models/rental_schedule.rk +2 -0
- package/template/base/modules/rental/models/rental_unit.rk +73 -0
- package/template/base/modules/rental/module.rk +7 -1
- package/template/base/modules/rental/print/rental_bast_in.html +107 -0
- package/template/base/modules/rental/print/rental_bast_in.rk +9 -0
- package/template/base/modules/rental/print/rental_bast_out.html +98 -0
- package/template/base/modules/rental/print/rental_bast_out.rk +11 -0
- package/template/base/modules/rental/roles/rental_staff.rk +7 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""A local stand-in for the DOKU Non-SNAP Checkout API, for demos and tests without a DOKU account.
|
|
3
|
+
|
|
4
|
+
DOKU_MOCK_SECRET_KEY=SK-test-dummy-demo python3 doku/mock/doku_mock.py --port 8901 --client-id BRN-0001-CONTOH \
|
|
5
|
+
--notify-url http://127.0.0.1:8080/hooks/<org>/doku/payment_notified
|
|
6
|
+
|
|
7
|
+
Dummy keys only. The mock signs any notification it is asked for (/simulate/*), without authentication: it is a
|
|
8
|
+
signing oracle for its key. So it listens on 127.0.0.1 only, reads the key from DOKU_MOCK_SECRET_KEY (not argv, which
|
|
9
|
+
`ps` shows), and refuses a key that does not say it is a dummy (a part "dummy" or "test" between - _ or .). Never give it a
|
|
10
|
+
key from DOKU Back Office, sandbox or production.
|
|
11
|
+
|
|
12
|
+
Stdlib only. What it does, in DOKU's formats (rangka connector doku, research in Juragan's
|
|
13
|
+
reports/keputusan-riset/doku-connector.md):
|
|
14
|
+
|
|
15
|
+
- POST /checkout/v1/payment checks Client-Id and the signature (HMACSHA256= + base64 HMAC-SHA256 over Client-Id,
|
|
16
|
+
Request-Id, Request-Timestamp, Request-Target and Digest lines), answers like DOKU Checkout (response.payment.url,
|
|
17
|
+
token_id, expired_date). A bad signature is 401 {"error": {"code": "invalid_signature"}}.
|
|
18
|
+
- GET /checkout-link-v2/<token> a small page standing in for DOKU's payment page (QRIS text and a pay button).
|
|
19
|
+
- POST /simulate/pay/<token>[?status=FAILED] marks the payment and sends the signed HTTP notification to
|
|
20
|
+
--notify-url, the way DOKU's sandbox simulator does; answers with the notification's status code.
|
|
21
|
+
- POST /simulate/notify body {"invoice_number", "amount", "status"}: a notification for an invoice without Checkout
|
|
22
|
+
(a static QRIS paid at the counter).
|
|
23
|
+
- GET /calls every request it received (for tests).
|
|
24
|
+
|
|
25
|
+
The kernel only sends signed requests over https to api-sandbox.doku.com or api.doku.com (rangka-os contract 0017
|
|
26
|
+
§5), so a local kernel never calls this mock: the mock is the payer's side. Its Checkout endpoint is what a test calls
|
|
27
|
+
with requests signed the same way, and sign_lines() below is the reference used to check the kernel's signatures.
|
|
28
|
+
"""
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
import argparse
|
|
32
|
+
import base64
|
|
33
|
+
import html
|
|
34
|
+
import os
|
|
35
|
+
import re
|
|
36
|
+
import hashlib
|
|
37
|
+
import hmac
|
|
38
|
+
import json
|
|
39
|
+
import sys
|
|
40
|
+
import threading
|
|
41
|
+
import urllib.error
|
|
42
|
+
import urllib.parse
|
|
43
|
+
import urllib.request
|
|
44
|
+
import uuid
|
|
45
|
+
from datetime import datetime, timedelta, timezone
|
|
46
|
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def digest(body: bytes) -> str:
|
|
50
|
+
return base64.b64encode(hashlib.sha256(body).digest()).decode()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def sign_lines(secret: str, client_id: str, request_id: str, timestamp: str, target: str, body: bytes | None) -> str:
|
|
54
|
+
"""DOKU Non-SNAP signature: HMACSHA256= + base64(HMAC-SHA256(secret, lines)); no Digest line without a body."""
|
|
55
|
+
lines = [f"Client-Id:{client_id}", f"Request-Id:{request_id}", f"Request-Timestamp:{timestamp}", f"Request-Target:{target}"]
|
|
56
|
+
if body:
|
|
57
|
+
lines.append(f"Digest:{digest(body)}")
|
|
58
|
+
mac = hmac.new(secret.encode(), "\n".join(lines).encode(), hashlib.sha256).digest()
|
|
59
|
+
return "HMACSHA256=" + base64.b64encode(mac).decode()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def now_utc() -> str:
|
|
63
|
+
return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class State:
|
|
67
|
+
"""The mock's memory. secret is a dummy key: whoever reaches the mock can have anything signed with it."""
|
|
68
|
+
|
|
69
|
+
def __init__(self, client_id, secret, notify_url):
|
|
70
|
+
self.client_id, self.secret, self.notify_url = client_id, secret, notify_url
|
|
71
|
+
self.payments = {} # token -> {invoice_number, amount, request_id, status}
|
|
72
|
+
self.calls = []
|
|
73
|
+
self.lock = threading.Lock()
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def notify(state: State, invoice: str, amount: int, status: str, original_request_id: str, channel="QRIS") -> int:
|
|
77
|
+
"""Send one signed notification to the notify URL, as DOKU does; returns the HTTP status (0 when unreachable)."""
|
|
78
|
+
body = json.dumps({
|
|
79
|
+
"order": {"invoice_number": invoice, "amount": amount},
|
|
80
|
+
"transaction": {"type": "SALE", "status": status, "date": now_utc(), "original_request_id": original_request_id},
|
|
81
|
+
"service": {"id": "QRIS" if channel == "QRIS" else "VIRTUAL_ACCOUNT"}, "acquirer": {"id": "QRIS"},
|
|
82
|
+
"channel": {"id": channel}, "additional_info": {"origin": {"product": "CHECKOUT", "source": "doku-mock"}},
|
|
83
|
+
}, separators=(",", ":")).encode()
|
|
84
|
+
req_id, ts = str(uuid.uuid4()), now_utc()
|
|
85
|
+
target = urllib.parse.urlparse(state.notify_url).path
|
|
86
|
+
req = urllib.request.Request(state.notify_url, data=body, method="POST", headers={
|
|
87
|
+
"Content-Type": "application/json", "Client-Id": state.client_id, "Request-Id": req_id, "Request-Timestamp": ts,
|
|
88
|
+
"Signature": sign_lines(state.secret, state.client_id, req_id, ts, target, body)})
|
|
89
|
+
try:
|
|
90
|
+
with urllib.request.urlopen(req, timeout=10) as r:
|
|
91
|
+
return r.status
|
|
92
|
+
except urllib.error.HTTPError as e:
|
|
93
|
+
return e.code
|
|
94
|
+
except OSError:
|
|
95
|
+
return 0
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def handler(state: State):
|
|
99
|
+
class H(BaseHTTPRequestHandler):
|
|
100
|
+
def log_message(self, *a):
|
|
101
|
+
pass
|
|
102
|
+
|
|
103
|
+
def send(self, code, obj, ctype="application/json"):
|
|
104
|
+
raw = obj.encode() if isinstance(obj, str) else json.dumps(obj).encode()
|
|
105
|
+
self.send_response(code)
|
|
106
|
+
self.send_header("Content-Type", ctype)
|
|
107
|
+
self.send_header("Content-Length", str(len(raw)))
|
|
108
|
+
self.end_headers()
|
|
109
|
+
self.wfile.write(raw)
|
|
110
|
+
|
|
111
|
+
def body(self) -> bytes:
|
|
112
|
+
n = int(self.headers.get("Content-Length") or 0)
|
|
113
|
+
return self.rfile.read(n) if n else b""
|
|
114
|
+
|
|
115
|
+
def do_GET(self):
|
|
116
|
+
path = urllib.parse.urlparse(self.path).path
|
|
117
|
+
if path == "/calls":
|
|
118
|
+
with state.lock:
|
|
119
|
+
return self.send(200, state.calls)
|
|
120
|
+
if path.startswith("/checkout-link-v2/"):
|
|
121
|
+
tok = path.rsplit("/", 1)[-1]
|
|
122
|
+
p = state.payments.get(tok)
|
|
123
|
+
if not p:
|
|
124
|
+
return self.send(404, {"error": {"code": "not_found"}})
|
|
125
|
+
return self.send(200, f"<!doctype html><meta charset=utf-8><title>DOKU (mock)</title>"
|
|
126
|
+
f"<h1>Bayar {html.escape(str(p['invoice_number']))}</h1><p>QRIS Rp {p['amount']:,}</p>"
|
|
127
|
+
f"<form method=post action=/simulate/pay/{urllib.parse.quote(tok)}><button>Simulasi bayar</button></form>",
|
|
128
|
+
"text/html; charset=utf-8")
|
|
129
|
+
self.send(404, {"error": {"code": "not_found"}})
|
|
130
|
+
|
|
131
|
+
def do_POST(self):
|
|
132
|
+
u = urllib.parse.urlparse(self.path)
|
|
133
|
+
raw = self.body()
|
|
134
|
+
with state.lock:
|
|
135
|
+
state.calls.append({"method": "POST", "path": u.path, "headers": {k: v for k, v in self.headers.items()},
|
|
136
|
+
"body": raw.decode(errors="replace")})
|
|
137
|
+
if u.path == "/checkout/v1/payment":
|
|
138
|
+
h = self.headers
|
|
139
|
+
want = sign_lines(state.secret, state.client_id, h.get("Request-Id", ""), h.get("Request-Timestamp", ""), u.path, raw)
|
|
140
|
+
if h.get("Client-Id") != state.client_id or not hmac.compare_digest(h.get("Signature", ""), want):
|
|
141
|
+
return self.send(401, {"error": {"code": "invalid_signature", "message": "Invalid Header Signature"}})
|
|
142
|
+
try:
|
|
143
|
+
req = json.loads(raw)
|
|
144
|
+
order, pay = req["order"], req.get("payment", {})
|
|
145
|
+
amount = int(float(order["amount"]))
|
|
146
|
+
invoice = str(order["invoice_number"])
|
|
147
|
+
except (ValueError, KeyError, TypeError):
|
|
148
|
+
return self.send(400, {"error": {"code": "invalid_request"}})
|
|
149
|
+
tok = "tok-" + uuid.uuid4().hex[:12]
|
|
150
|
+
due = int(pay.get("payment_due_date") or 60)
|
|
151
|
+
with state.lock:
|
|
152
|
+
state.payments[tok] = {"invoice_number": invoice, "amount": amount, "request_id": h.get("Request-Id"), "status": "PENDING"}
|
|
153
|
+
host = self.headers.get("Host", "127.0.0.1")
|
|
154
|
+
expires = (datetime.now(timezone(timedelta(hours=7))) + timedelta(minutes=due)).strftime("%Y%m%d%H%M%S")
|
|
155
|
+
return self.send(200, {"message": ["SUCCESS"], "response": {
|
|
156
|
+
"order": {"amount": str(amount), "invoice_number": invoice, "currency": "IDR", "session_id": "sess-" + tok},
|
|
157
|
+
"payment": {"payment_method_types": pay.get("payment_method_types") or ["QRIS"], "payment_due_date": due,
|
|
158
|
+
"token_id": tok, "url": f"http://{host}/checkout-link-v2/{tok}", "expired_date": expires},
|
|
159
|
+
"headers": {"request_id": h.get("Request-Id")}}})
|
|
160
|
+
if u.path.startswith("/simulate/pay/"):
|
|
161
|
+
tok = u.path.rsplit("/", 1)[-1]
|
|
162
|
+
p = state.payments.get(tok)
|
|
163
|
+
if not p:
|
|
164
|
+
return self.send(404, {"error": {"code": "not_found"}})
|
|
165
|
+
status = urllib.parse.parse_qs(u.query).get("status", ["SUCCESS"])[0]
|
|
166
|
+
p["status"] = status
|
|
167
|
+
code = notify(state, p["invoice_number"], p["amount"], status, p["request_id"])
|
|
168
|
+
return self.send(200, {"notified": code, "status": status})
|
|
169
|
+
if u.path == "/simulate/notify":
|
|
170
|
+
try:
|
|
171
|
+
req = json.loads(raw or b"{}")
|
|
172
|
+
code = notify(state, str(req["invoice_number"]), int(req["amount"]), req.get("status", "SUCCESS"),
|
|
173
|
+
req.get("original_request_id") or str(uuid.uuid4()), req.get("channel", "QRIS"))
|
|
174
|
+
except (ValueError, KeyError, TypeError):
|
|
175
|
+
return self.send(400, {"error": {"code": "invalid_request"}})
|
|
176
|
+
return self.send(200, {"notified": code})
|
|
177
|
+
self.send(404, {"error": {"code": "not_found"}})
|
|
178
|
+
return H
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def dummy_key(secret: str) -> bool:
|
|
182
|
+
"""True for a key that says it is a dummy: the mock signs whatever it is asked, so a real key must never reach it."""
|
|
183
|
+
return bool(re.search(r"(^|[-_.])(dummy|test)([-_.]|$)", secret, re.IGNORECASE))
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def main(argv=None):
|
|
187
|
+
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
188
|
+
ap.add_argument("--port", type=int, default=8901)
|
|
189
|
+
ap.add_argument("--client-id", required=True)
|
|
190
|
+
ap.add_argument("--secret-key", help="deprecated (visible in ps): set DOKU_MOCK_SECRET_KEY instead")
|
|
191
|
+
ap.add_argument("--notify-url", required=True, help="the kernel hook: http://<kernel>/hooks/<org>/doku/payment_notified")
|
|
192
|
+
a = ap.parse_args(argv)
|
|
193
|
+
secret = os.environ.get("DOKU_MOCK_SECRET_KEY") or a.secret_key or ""
|
|
194
|
+
if not dummy_key(secret):
|
|
195
|
+
ap.error("set DOKU_MOCK_SECRET_KEY to a dummy key (a part dummy or test, e.g. SK-test-dummy-demo); never a real DOKU key")
|
|
196
|
+
srv = ThreadingHTTPServer(("127.0.0.1", a.port), handler(State(a.client_id, secret, a.notify_url)))
|
|
197
|
+
print(f"doku mock on http://127.0.0.1:{srv.server_address[1]} (notifications to {a.notify_url})", flush=True)
|
|
198
|
+
try:
|
|
199
|
+
srv.serve_forever()
|
|
200
|
+
except KeyboardInterrupt:
|
|
201
|
+
pass
|
|
202
|
+
return 0
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
if __name__ == "__main__":
|
|
206
|
+
sys.exit(main())
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
# Moka POS (GoTo): transactions, refunds, outlets and items through the Moka Connect API with OAuth 2.0
|
|
3
3
|
# (authorization code; the owner approves Juragan in Moka Backoffice).
|
|
4
4
|
# Status: spec. API access needs Moka's approval of the integration (developer application at Moka); the paths
|
|
5
|
-
# below follow Moka's published API reference and must be confirmed once access is granted.
|
|
6
|
-
#
|
|
7
|
-
#
|
|
5
|
+
# below follow Moka's published API reference and must be confirmed once access is granted. Until then, rangka-apps
|
|
6
|
+
# imports the Item Details export (modules/outlet_sales/imports/moka_item_details), whose headers were checked against
|
|
7
|
+
# real exports.
|
|
8
|
+
# fixtures/ are synthetic (no merchant data): two outlets of the demo F&B shop. The checkouts fields (sku, quantity,
|
|
9
|
+
# total_price, discount_amount, refunded_quantity) follow the API reference as read before access; rangka-apps flow
|
|
10
|
+
# moka_transaction_staged reads them, so a rename after access changes the flow and these fixtures together.
|
|
8
11
|
name: moka
|
|
9
12
|
label: {id: Moka POS}
|
|
10
13
|
summary:
|
|
@@ -31,19 +34,49 @@ auth:
|
|
|
31
34
|
label: {id: Refresh token}
|
|
32
35
|
secret: true
|
|
33
36
|
triggers:
|
|
34
|
-
# Moka has no webhook for sales:
|
|
35
|
-
#
|
|
37
|
+
# Moka has no webhook for sales: the kernel polls get_latest_transactions per outlet every 5 minutes (contract 0002
|
|
38
|
+
# §A.1, each:). list_outlets runs first. Moka's public API spec (api.mokapos.com/docs, swagger "MOKA API" 0.2,
|
|
39
|
+
# 6 Mar 2026): since/until are epoch seconds, results come newest first unless reorder_type is ASC, there is no page
|
|
40
|
+
# parameter (the answer's next_url is the next page), time_filter picks created_at, updated_at or synchronized_at.
|
|
41
|
+
# In its example a refund made after the sale shows in payment_refunds and in the checkout's refunded_quantity while
|
|
42
|
+
# updated_at stays the sale's time; synchronized_at is when Moka's server got the transaction (late for offline mode).
|
|
43
|
+
# So every poll reads the whole window again: the transactions Moka's server received (synchronized_at) since two
|
|
44
|
+
# days back, newest first, with no cursor.
|
|
45
|
+
# - A transaction that did not change emits the same event, which the kernel drops (the event key is the hash of
|
|
46
|
+
# what is emitted, kept 30 days); a refunded one emits a new event (payment_refunds, refunded_quantity), and flow
|
|
47
|
+
# moka_transaction_staged (rangka-apps) books only the quantity refunded since, per checkout uuid.
|
|
48
|
+
# - A sale synced late from offline mode comes in with its sync time, inside the window.
|
|
49
|
+
# - LIMIT until the kernel follows next_url (rangka-os card): one call reads the newest 100 of the window only. More
|
|
50
|
+
# than 100 transactions per outlet between two polls lose the oldest of them, and a refund of a transaction past
|
|
51
|
+
# the newest 100 is not seen. With next_url followed the whole window is read and nothing in it is lost; a refund
|
|
52
|
+
# made more than two days after the sale is outside the window either way (head office books it, or the export).
|
|
53
|
+
# An outlet moves from the export file to the API only after that kernel card (Juragan PROGRESS, audit moka H3/M1).
|
|
54
|
+
# To confirm once Moka grants API access: synchronized_at for offline sales, the largest per_page, the offset of
|
|
55
|
+
# created_at (flows take the day from its first 10 characters, a Z time as WIB).
|
|
36
56
|
- name: transaction_created
|
|
37
|
-
label: {id: Transaksi baru}
|
|
57
|
+
label: {id: Transaksi baru atau berubah}
|
|
38
58
|
via: poll
|
|
39
|
-
every:
|
|
40
|
-
|
|
59
|
+
every: 5m
|
|
60
|
+
action: latest_transactions
|
|
61
|
+
each: {action: list_outlets, items: outlets, as: outlet, key: outlet.id}
|
|
62
|
+
input:
|
|
63
|
+
outlet_id: outlet.id
|
|
64
|
+
since: "(days_between('1970-01-01', today()) - 2) * 86400"
|
|
65
|
+
time_filter: "'synchronized_at'"
|
|
66
|
+
reorder_type: "'DESC'"
|
|
67
|
+
for_each: payments[]
|
|
41
68
|
emit:
|
|
42
69
|
transaction_id: item.id
|
|
43
70
|
outlet_id: item.outlet_id
|
|
71
|
+
outlet_name: outlet.name
|
|
44
72
|
receipt_no: item.payment_no
|
|
45
73
|
created_at: item.created_at
|
|
74
|
+
synchronized_at: item.synchronized_at
|
|
46
75
|
is_refunded: item.is_refunded
|
|
76
|
+
refunded_date: item.refunded_date
|
|
77
|
+
# Moka's refunds of this sale (each with its own created_at and refund_amount); the checkouts carry
|
|
78
|
+
# refunded_quantity and a uuid per line
|
|
79
|
+
payment_refunds: item.payment_refunds
|
|
47
80
|
checkouts: item.checkouts
|
|
48
81
|
payment_type: item.payment_type
|
|
49
82
|
total_collected: item.total_collected
|
|
@@ -54,12 +87,13 @@ actions:
|
|
|
54
87
|
method: GET
|
|
55
88
|
url: https://api.mokapos.com/v3/outlets/{input.outlet_id}/reports/get_latest_transactions
|
|
56
89
|
headers: {Authorization: 'Bearer {auth.access_token}'}
|
|
57
|
-
query: {since: '{input.since}',
|
|
90
|
+
query: {since: '{input.since}', time_filter: '{input.time_filter}', reorder_type: '{input.reorder_type}', per_page: '100'}
|
|
58
91
|
input:
|
|
59
92
|
- {name: outlet_id, type: data, required: true}
|
|
60
|
-
- {name: since, type:
|
|
61
|
-
- {name:
|
|
62
|
-
|
|
93
|
+
- {name: since, type: int, required: true, help: {id: 'Detik epoch (UTC)'}}
|
|
94
|
+
- {name: time_filter, type: data, default: "'synchronized_at'", help: {id: 'created_at, updated_at atau synchronized_at'}}
|
|
95
|
+
- {name: reorder_type, type: data, default: "'DESC'", help: {id: 'DESC (terbaru dulu) atau ASC'}}
|
|
96
|
+
output: {payments: data.payments, next: data.next_url}
|
|
63
97
|
retry: {max: 5, backoff: exponential, on: [429, 500, 502, 503]}
|
|
64
98
|
- name: list_outlets
|
|
65
99
|
label: {id: Daftar outlet}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"transaction_created.json": {
|
|
3
|
+
"transaction_id": "4a3f6c1e-0b6d-4c1a-9a2e-91000001aaaa",
|
|
4
|
+
"outlet_id": 70002,
|
|
5
|
+
"outlet_name": "Tahu Contoh - Braga",
|
|
6
|
+
"receipt_no": "BRG-000101",
|
|
7
|
+
"created_at": "2026-11-10T11:42:10+07:00",
|
|
8
|
+
"is_refunded": false,
|
|
9
|
+
"total_collected": 63000,
|
|
10
|
+
"refunded_date": null,
|
|
11
|
+
"synchronized_at": "2026-11-10T11:42:10+07:00"
|
|
12
|
+
},
|
|
13
|
+
"transaction_created_refund.json": {
|
|
14
|
+
"transaction_id": "4a3f6c1e-0b6d-4c1a-9a2e-91000002bbbb",
|
|
15
|
+
"is_refunded": true,
|
|
16
|
+
"payment_type": "qris"
|
|
17
|
+
},
|
|
18
|
+
"list_outlets.json": {
|
|
19
|
+
"outlets": [
|
|
20
|
+
{
|
|
21
|
+
"id": 70001,
|
|
22
|
+
"name": "Tahu Contoh - Dago",
|
|
23
|
+
"address": "Jl. Contoh Dago No. 1",
|
|
24
|
+
"city": "Bandung"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": 70002,
|
|
28
|
+
"name": "Tahu Contoh - Braga",
|
|
29
|
+
"address": "Jl. Contoh Braga No. 2",
|
|
30
|
+
"city": "Bandung"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"latest_transactions.json": {
|
|
35
|
+
"next": null
|
|
36
|
+
},
|
|
37
|
+
"transaction_created_refund_later.json": {
|
|
38
|
+
"transaction_id": "4a3f6c1e-0b6d-4c1a-9a2e-91000001aaaa",
|
|
39
|
+
"is_refunded": true,
|
|
40
|
+
"refunded_date": "2026-11-11T09:15:30+07:00",
|
|
41
|
+
"created_at": "2026-11-10T11:42:10+07:00",
|
|
42
|
+
"synchronized_at": "2026-11-11T09:15:30+07:00"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"completed": true,
|
|
4
|
+
"next_url": null,
|
|
5
|
+
"payments": [
|
|
6
|
+
{
|
|
7
|
+
"id": "4a3f6c1e-0b6d-4c1a-9a2e-91000002bbbb",
|
|
8
|
+
"payment_no": "BRG-000102",
|
|
9
|
+
"outlet_id": 70002,
|
|
10
|
+
"created_at": "2026-11-10T19:05:44+07:00",
|
|
11
|
+
"payment_type": "qris",
|
|
12
|
+
"is_refunded": true,
|
|
13
|
+
"refunded_date": "2026-11-10T19:07:02+07:00",
|
|
14
|
+
"total_collected": 15000,
|
|
15
|
+
"checkouts": [
|
|
16
|
+
{
|
|
17
|
+
"item_id": 501,
|
|
18
|
+
"item_name": "Tahu goreng original",
|
|
19
|
+
"item_variant_name": "",
|
|
20
|
+
"sku": "TH-ORI",
|
|
21
|
+
"quantity": 1,
|
|
22
|
+
"item_price": 15000,
|
|
23
|
+
"total_price": 15000,
|
|
24
|
+
"discount_amount": 0,
|
|
25
|
+
"refunded_quantity": 1,
|
|
26
|
+
"uuid": "c0ffee00-0000-4000-8000-000066000003"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"synchronized_at": "2026-11-10T19:07:02+07:00",
|
|
30
|
+
"payment_refunds": [
|
|
31
|
+
{
|
|
32
|
+
"uuid": "a3f0e000-0000-4000-8000-000000000002",
|
|
33
|
+
"created_at": "2026-11-10T19:07:02+07:00",
|
|
34
|
+
"refund_amount": 15000,
|
|
35
|
+
"refund_type": "full"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "4a3f6c1e-0b6d-4c1a-9a2e-91000001aaaa",
|
|
41
|
+
"payment_no": "BRG-000101",
|
|
42
|
+
"outlet_id": 70002,
|
|
43
|
+
"created_at": "2026-11-10T11:42:10+07:00",
|
|
44
|
+
"payment_type": "cash",
|
|
45
|
+
"is_refunded": false,
|
|
46
|
+
"refunded_date": null,
|
|
47
|
+
"total_collected": 63000,
|
|
48
|
+
"checkouts": [
|
|
49
|
+
{
|
|
50
|
+
"item_id": 501,
|
|
51
|
+
"item_name": "Tahu goreng original",
|
|
52
|
+
"item_variant_name": "",
|
|
53
|
+
"sku": "TH-ORI",
|
|
54
|
+
"quantity": 2,
|
|
55
|
+
"item_price": 15000,
|
|
56
|
+
"total_price": 30000,
|
|
57
|
+
"discount_amount": 0,
|
|
58
|
+
"refunded_quantity": 0,
|
|
59
|
+
"uuid": "c0ffee00-0000-4000-8000-000066000001"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"item_id": 502,
|
|
63
|
+
"item_name": "Tahu goreng pedas",
|
|
64
|
+
"item_variant_name": "",
|
|
65
|
+
"sku": "TH-PDS",
|
|
66
|
+
"quantity": 2,
|
|
67
|
+
"item_price": 18000,
|
|
68
|
+
"total_price": 36000,
|
|
69
|
+
"discount_amount": 3000,
|
|
70
|
+
"refunded_quantity": 0,
|
|
71
|
+
"uuid": "c0ffee00-0000-4000-8000-000066000002"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"synchronized_at": "2026-11-10T11:42:10+07:00",
|
|
75
|
+
"payment_refunds": []
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"outlet": {
|
|
3
|
+
"id": 70002,
|
|
4
|
+
"name": "Tahu Contoh - Braga"
|
|
5
|
+
},
|
|
6
|
+
"item": {
|
|
7
|
+
"id": "4a3f6c1e-0b6d-4c1a-9a2e-91000001aaaa",
|
|
8
|
+
"payment_no": "BRG-000101",
|
|
9
|
+
"outlet_id": 70002,
|
|
10
|
+
"created_at": "2026-11-10T11:42:10+07:00",
|
|
11
|
+
"payment_type": "cash",
|
|
12
|
+
"is_refunded": false,
|
|
13
|
+
"refunded_date": null,
|
|
14
|
+
"total_collected": 63000,
|
|
15
|
+
"checkouts": [
|
|
16
|
+
{
|
|
17
|
+
"item_id": 501,
|
|
18
|
+
"item_name": "Tahu goreng original",
|
|
19
|
+
"item_variant_name": "",
|
|
20
|
+
"sku": "TH-ORI",
|
|
21
|
+
"quantity": 2,
|
|
22
|
+
"item_price": 15000,
|
|
23
|
+
"total_price": 30000,
|
|
24
|
+
"discount_amount": 0,
|
|
25
|
+
"refunded_quantity": 0,
|
|
26
|
+
"uuid": "c0ffee00-0000-4000-8000-000066000001"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"item_id": 502,
|
|
30
|
+
"item_name": "Tahu goreng pedas",
|
|
31
|
+
"item_variant_name": "",
|
|
32
|
+
"sku": "TH-PDS",
|
|
33
|
+
"quantity": 2,
|
|
34
|
+
"item_price": 18000,
|
|
35
|
+
"total_price": 36000,
|
|
36
|
+
"discount_amount": 3000,
|
|
37
|
+
"refunded_quantity": 0,
|
|
38
|
+
"uuid": "c0ffee00-0000-4000-8000-000066000002"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"synchronized_at": "2026-11-10T11:42:10+07:00",
|
|
42
|
+
"payment_refunds": []
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"outlet": {
|
|
3
|
+
"id": 70002,
|
|
4
|
+
"name": "Tahu Contoh - Braga"
|
|
5
|
+
},
|
|
6
|
+
"item": {
|
|
7
|
+
"id": "4a3f6c1e-0b6d-4c1a-9a2e-91000002bbbb",
|
|
8
|
+
"payment_no": "BRG-000102",
|
|
9
|
+
"outlet_id": 70002,
|
|
10
|
+
"created_at": "2026-11-10T19:05:44+07:00",
|
|
11
|
+
"payment_type": "qris",
|
|
12
|
+
"is_refunded": true,
|
|
13
|
+
"refunded_date": "2026-11-10T19:07:02+07:00",
|
|
14
|
+
"total_collected": 15000,
|
|
15
|
+
"checkouts": [
|
|
16
|
+
{
|
|
17
|
+
"item_id": 501,
|
|
18
|
+
"item_name": "Tahu goreng original",
|
|
19
|
+
"item_variant_name": "",
|
|
20
|
+
"sku": "TH-ORI",
|
|
21
|
+
"quantity": 1,
|
|
22
|
+
"item_price": 15000,
|
|
23
|
+
"total_price": 15000,
|
|
24
|
+
"discount_amount": 0,
|
|
25
|
+
"refunded_quantity": 1,
|
|
26
|
+
"uuid": "c0ffee00-0000-4000-8000-000066000003"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"synchronized_at": "2026-11-10T19:07:02+07:00",
|
|
30
|
+
"payment_refunds": [
|
|
31
|
+
{
|
|
32
|
+
"uuid": "a3f0e000-0000-4000-8000-000000000002",
|
|
33
|
+
"created_at": "2026-11-10T19:07:02+07:00",
|
|
34
|
+
"refund_amount": 15000,
|
|
35
|
+
"refund_type": "full"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"outlet": {
|
|
3
|
+
"id": 70002,
|
|
4
|
+
"name": "Tahu Contoh - Braga"
|
|
5
|
+
},
|
|
6
|
+
"item": {
|
|
7
|
+
"id": "4a3f6c1e-0b6d-4c1a-9a2e-91000001aaaa",
|
|
8
|
+
"payment_no": "BRG-000101",
|
|
9
|
+
"outlet_id": 70002,
|
|
10
|
+
"created_at": "2026-11-10T11:42:10+07:00",
|
|
11
|
+
"payment_type": "cash",
|
|
12
|
+
"is_refunded": true,
|
|
13
|
+
"refunded_date": "2026-11-11T09:15:30+07:00",
|
|
14
|
+
"total_collected": 63000,
|
|
15
|
+
"checkouts": [
|
|
16
|
+
{
|
|
17
|
+
"item_id": 501,
|
|
18
|
+
"item_name": "Tahu goreng original",
|
|
19
|
+
"item_variant_name": "",
|
|
20
|
+
"sku": "TH-ORI",
|
|
21
|
+
"quantity": 2,
|
|
22
|
+
"item_price": 15000,
|
|
23
|
+
"total_price": 30000,
|
|
24
|
+
"discount_amount": 0,
|
|
25
|
+
"refunded_quantity": 1,
|
|
26
|
+
"uuid": "c0ffee00-0000-4000-8000-000066000001"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"item_id": 502,
|
|
30
|
+
"item_name": "Tahu goreng pedas",
|
|
31
|
+
"item_variant_name": "",
|
|
32
|
+
"sku": "TH-PDS",
|
|
33
|
+
"quantity": 2,
|
|
34
|
+
"item_price": 18000,
|
|
35
|
+
"total_price": 36000,
|
|
36
|
+
"discount_amount": 3000,
|
|
37
|
+
"refunded_quantity": 0,
|
|
38
|
+
"uuid": "c0ffee00-0000-4000-8000-000066000002"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"synchronized_at": "2026-11-11T09:15:30+07:00",
|
|
42
|
+
"payment_refunds": [
|
|
43
|
+
{
|
|
44
|
+
"uuid": "a3f0e000-0000-4000-8000-000000000001",
|
|
45
|
+
"created_at": "2026-11-11T09:15:30+07:00",
|
|
46
|
+
"refund_amount": 15000,
|
|
47
|
+
"refund_type": "partial"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -70,6 +70,13 @@ fields:
|
|
|
70
70
|
type: table
|
|
71
71
|
of: course_batch_slot
|
|
72
72
|
label: {id: Jadwal mingguan}
|
|
73
|
+
# the weekdays of the schedule as text ("mon wed "), so a list or dashboard filter can ask "is there class today"
|
|
74
|
+
# (dashboard kelas_saya) without reading the table
|
|
75
|
+
- name: class_days
|
|
76
|
+
type: data
|
|
77
|
+
label: {id: Hari kelas}
|
|
78
|
+
hidden: true
|
|
79
|
+
compute: "(schedule.map(s, s.weekday == 'mon' ? 1 : 0).sum() > 0 ? 'mon ' : '') + (schedule.map(s, s.weekday == 'tue' ? 1 : 0).sum() > 0 ? 'tue ' : '') + (schedule.map(s, s.weekday == 'wed' ? 1 : 0).sum() > 0 ? 'wed ' : '') + (schedule.map(s, s.weekday == 'thu' ? 1 : 0).sum() > 0 ? 'thu ' : '') + (schedule.map(s, s.weekday == 'fri' ? 1 : 0).sum() > 0 ? 'fri ' : '') + (schedule.map(s, s.weekday == 'sat' ? 1 : 0).sum() > 0 ? 'sat ' : '') + (schedule.map(s, s.weekday == 'sun' ? 1 : 0).sum() > 0 ? 'sun ' : '')"
|
|
73
80
|
- {name: notes, type: text, label: {id: Catatan}}
|
|
74
81
|
rules:
|
|
75
82
|
- name: quota_positive
|
|
@@ -47,6 +47,9 @@ fields:
|
|
|
47
47
|
label: {id: Absen}
|
|
48
48
|
- {name: present_count, type: int, label: {id: Hadir}, compute: "attendance.map(a, a.status == 'present' ? 1 : 0).sum()", in_list: true}
|
|
49
49
|
- {name: absent_count, type: int, label: {id: Tidak hadir}, compute: "attendance.map(a, a.status != 'present' ? 1 : 0).sum()"}
|
|
50
|
+
# the teacher ticks this after checking the attendance (every line starts as present); dashboard kelas_saya lists
|
|
51
|
+
# the meetings of the teacher that are not ticked yet
|
|
52
|
+
- {name: attendance_taken, type: check, label: {id: Absen sudah dicek}, help: {id: 'Centang setelah absen semua peserta dicek'}, default: 'false', in_list: true}
|
|
50
53
|
- name: session_key
|
|
51
54
|
type: data
|
|
52
55
|
label: {id: Kunci pertemuan}
|
|
@@ -84,7 +87,7 @@ views:
|
|
|
84
87
|
- [batch, session_no, session_date, topic]
|
|
85
88
|
- [start_time, end_time, delivery, class_link]
|
|
86
89
|
- section: {id: Absen}
|
|
87
|
-
fields: [attendance]
|
|
90
|
+
fields: [attendance, attendance_taken]
|
|
88
91
|
- section: {id: Ringkasan}
|
|
89
92
|
columns:
|
|
90
93
|
- [present_count, absent_count]
|
|
@@ -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: courses
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.1.0
|
|
4
4
|
title: {id: Kursus dan pelatihan, en: Courses and training}
|
|
5
5
|
summary:
|
|
6
6
|
id: Program kursus, angkatan, peserta, pendaftaran, jadwal pertemuan dan tagihannya.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
|
|
2
|
+
# Runs inside a receipt's payment (pos_sale submitted), as the cashier: one ticket per active station of the outlet
|
|
3
|
+
# with the receipt's lines whose item category is routed to that station (kitchen_route). An outlet without stations
|
|
4
|
+
# (a shop) and a receipt without kitchen lines make nothing. A receipt paid again after a void (amend) sends its lines
|
|
5
|
+
# again as a revision. A failure here rolls the payment back, so a paid receipt never misses its tickets.
|
|
6
|
+
name: kitchen_ticket_on_sale
|
|
7
|
+
label: {id: 'Struk dibayar: kirim tiket ke stasiun dapur'}
|
|
8
|
+
on: pos_sale.submitted
|
|
9
|
+
steps:
|
|
10
|
+
- {find_all: kitchen_station, where: outlet == event.outlet && active, as: stations}
|
|
11
|
+
- if: stations.size() > 0
|
|
12
|
+
then:
|
|
13
|
+
- {find_all: kitchen_route, where: outlet == event.outlet, as: routes}
|
|
14
|
+
- find_all: item
|
|
15
|
+
where: name in event.items.map(l, l.item)
|
|
16
|
+
as: menu
|
|
17
|
+
- for_each: stations
|
|
18
|
+
as: st
|
|
19
|
+
do:
|
|
20
|
+
- if: "event.items.filter(l, menu.filter(m, m.name == l.item && routes.filter(r, r.station == st.name && r.category == m.category).size() > 0).size() > 0).size() > 0"
|
|
21
|
+
create: kitchen_ticket
|
|
22
|
+
set:
|
|
23
|
+
sale: event.name
|
|
24
|
+
outlet: event.outlet
|
|
25
|
+
station: st.name
|
|
26
|
+
date: event.date
|
|
27
|
+
buyer: event.buyer
|
|
28
|
+
revision_of: event.amended_from
|
|
29
|
+
items: "event.items.filter(l, menu.filter(m, m.name == l.item && routes.filter(r, r.station == st.name && r.category == m.category).size() > 0).size() > 0).map(l, {'item': l.item, 'description': l.description, 'qty': l.qty, 'uom': l.uom, 'note': l.note})"
|