@rangka-os/create 0.5.0-alpha.14 → 0.5.0-alpha.15

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 (56) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/jasa_proyek/app.rk +4 -0
  3. package/template/base/apps/jasa_proyek/dashboards/rekap_absen.rk +1 -1
  4. package/template/base/apps/kasir/skills/rangka-app-kasir/SKILL.md +17 -1
  5. package/template/base/apps/kelas_kursus/app.rk +3 -0
  6. package/template/base/apps/langganan_jasa/app.rk +5 -1
  7. package/template/base/apps/sewa_alat/app.rk +6 -1
  8. package/template/base/connectors/moka/connector.rk +6 -5
  9. package/template/base/modules/catalogue/models/item.rk +9 -0
  10. package/template/base/modules/contacts/models/customer.rk +10 -1
  11. package/template/base/modules/contacts/models/vendor.rk +10 -1
  12. package/template/base/modules/courses/flows/session_attendance_checked.rk +14 -0
  13. package/template/base/modules/courses/flows/session_of_the_day.rk +34 -0
  14. package/template/base/modules/courses/models/course_attendance.rk +2 -0
  15. package/template/base/modules/courses/models/course_session.rk +1 -0
  16. package/template/base/modules/courses/module.rk +1 -1
  17. package/template/base/modules/courses/screens/absen_kelas.rk +17 -0
  18. package/template/base/modules/outlet_sales/flows/moka_api_opened.rk +30 -0
  19. package/template/base/modules/outlet_sales/flows/moka_held_release.rk +35 -0
  20. package/template/base/modules/outlet_sales/flows/moka_line_mapped.rk +12 -3
  21. package/template/base/modules/outlet_sales/flows/moka_transaction_refused.rk +15 -0
  22. package/template/base/modules/outlet_sales/flows/moka_transaction_staged.rk +31 -11
  23. package/template/base/modules/outlet_sales/models/moka_sale_line.rk +9 -1
  24. package/template/base/modules/outlets/models/outlet.rk +13 -1
  25. package/template/base/modules/payroll/flows/payslip_advance_guard.rk +3 -0
  26. package/template/base/modules/payroll/flows/payslip_from_recap.rk +30 -1
  27. package/template/base/modules/payroll/flows/payslip_ytd_guard.rk +18 -1
  28. package/template/base/modules/payroll/flows/payslip_ytd_on_create.rk +28 -1
  29. package/template/base/modules/payroll/models/payslip.rk +19 -1
  30. package/template/base/modules/pos/screens/kasir.rk +1 -1
  31. package/template/base/modules/projects/flows/attendance_close_on_submit.rk +6 -2
  32. package/template/base/modules/projects/flows/attendance_log_guard_created.rk +3 -1
  33. package/template/base/modules/projects/flows/attendance_log_guard_submitted.rk +8 -4
  34. package/template/base/modules/projects/flows/attendance_log_guard_updated.rk +2 -1
  35. package/template/base/modules/projects/models/assignment.rk +3 -0
  36. package/template/base/modules/projects/models/attendance_close.rk +4 -0
  37. package/template/base/modules/projects/models/attendance_guard.rk +1 -1
  38. package/template/base/modules/projects/models/attendance_log.rk +63 -66
  39. package/template/base/modules/projects/models/work_site.rk +2 -1
  40. package/template/base/modules/projects/module.rk +1 -1
  41. package/template/base/modules/projects/roles/field_worker.rk +2 -0
  42. package/template/base/modules/projects/screens/absen.rk +21 -0
  43. package/template/base/modules/rental/flows/rental_return_on_cancel.rk +5 -3
  44. package/template/base/modules/rental/models/rental_checkout.rk +10 -15
  45. package/template/base/modules/rental/models/rental_return.rk +3 -11
  46. package/template/base/modules/rental/models/rental_schedule.rk +8 -0
  47. package/template/base/modules/rental/models/rental_unit.rk +7 -0
  48. package/template/base/modules/rental/module.rk +1 -1
  49. package/template/base/modules/rental/screens/alat_keluar.rk +19 -0
  50. package/template/base/modules/rental/screens/alat_kembali.rk +19 -0
  51. package/template/base/modules/rental/screens/jadwal_alat.rk +21 -0
  52. package/template/base/modules/subscriptions/models/collection_visit.rk +47 -0
  53. package/template/base/modules/subscriptions/models/subscription.rk +3 -1
  54. package/template/base/modules/subscriptions/module.rk +1 -1
  55. package/template/base/modules/subscriptions/screens/catat_tagih.rk +18 -0
  56. package/template/base/modules/subscriptions/screens/rute_tagih.rk +25 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rangka-os/create",
3
- "version": "0.5.0-alpha.14",
3
+ "version": "0.5.0-alpha.15",
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",
@@ -30,6 +30,10 @@ dashboards: [jasa_overview, ar_aging, project_margin, absen_saya, rekap_absen]
30
30
  # field_worker and site_supervisor (field attendance, A2) have their role files in the projects module.
31
31
  roles: [sales_manager, finance_manager, purchasing_manager, project_admin, field_worker, site_supervisor]
32
32
  home: {dashboard: jasa_overview}
33
+ # Work screens (contract 0030 §3): the field worker lands on the clock; the site supervisor keeps the rekap_absen
34
+ # dashboard as home (first dashboard of their role) and decides held logs in Persetujuan.
35
+ work:
36
+ - {screen: absen, roles: [field_worker], home: true}
33
37
  menu:
34
38
  - group: {id: Penjualan}
35
39
  items: [quotation, customer_order, sales_invoice]
@@ -12,7 +12,7 @@ widgets:
12
12
  - {name: outside_today, type: number, label: {id: Di luar radius hari ini}, model: attendance_log, filter: work_date == today() && docstatus != 2 && outside_site, compact: true, span: 3, good_when: down}
13
13
  - {name: waiting, type: number, label: {id: Menunggu persetujuan}, description: {id: 'Sudah absen pulang tapi belum sah'}, model: attendance_log, filter: docstatus == 0 && clock_out != '', compact: true, span: 3, good_when: down}
14
14
  - {name: days_present, type: number, label: {id: Hari hadir sah}, model: attendance_log, filter: docstatus == 1, period: work_date, compact: true, span: 3}
15
- - {name: waiting_list, type: list, label: {id: Absen yang menunggu}, model: attendance_log, filter: docstatus == 0 && clock_out != '', columns: [name, worker_name, work_date, in_site_m, overtime_hours, reason], sort: work_date, limit: 20, span: 12}
15
+ - {name: waiting_list, type: list, label: {id: Absen yang menunggu}, model: attendance_log, filter: docstatus == 0 && clock_out != '', columns: [worker_name, work_date, in_site_m, out_site_m, overtime_hours, reason], sort: work_date, limit: 20, span: 12}
16
16
  - {name: by_worker, type: chart, chart: bar, label: {id: Hari hadir per pekerja}, model: attendance_log, group_by: worker_name, filter: docstatus == 1, period: work_date, sort: -value, span: 6}
17
17
  - {name: by_site, type: chart, chart: bar, label: {id: Hari hadir per lokasi}, model: attendance_log, group_by: work_site, filter: docstatus == 1, period: work_date, sort: -value, span: 6}
18
18
  - {name: today_list, type: list, label: {id: Absen hari ini}, model: attendance_log, filter: work_date == today() && docstatus != 2, columns: [worker_name, work_site, clock_in, clock_out, in_site_m, status], sort: clock_in, limit: 50, span: 12}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: rangka-app-kasir
3
- description: "Rangka Kasir (app kasir): the browser cashier for shops and F&B outlets, with shifts per outlet, numbered receipts, cash and QRIS, stock and recipes taken out automatically. Use when an owner asks for a cashier or POS (\"mau pakai kasir\", \"tambahin POS\", \"jualan langsung di outlet\"), to explain what it shares with apps they already run, and for what to set up after it is added."
3
+ description: "Rangka Kasir (app kasir): the browser cashier for shops and F&B outlets, with shifts per outlet, numbered receipts, cash and QRIS, stock and recipes taken out automatically. Use when an owner asks for a cashier or POS (\"mau pakai kasir\", \"tambahin POS\", \"jualan langsung di outlet\"), to explain what it shares with apps they already run, for what to set up after it is added, and in the studio interview to decide whether a counter business gets the cashier on its map."
4
4
  metadata: {rangka: {version: 1.0.0, app: kasir, requires: [rangka-compose, rangka-changesets]}}
5
5
  ---
6
6
 
@@ -30,6 +30,22 @@ specific to the cashier.
30
30
  - **Not GoFood, GrabFood or ShopeeFood.** Orders from those apps are not rung up here; see `rangka-compose`, "When
31
31
  nothing fits".
32
32
 
33
+ ## In the studio interview: when the cashier goes on the map
34
+
35
+ For Raka's consultant interview (`rangka-consult`, contract 0042). The deciding fact is the tools the owner uses
36
+ today and whether Juragan replaces them:
37
+
38
+ - A business that serves buyers at a counter (kedai, kafe, restoran, toko) and has **no cashier app yet**, or chose
39
+ **ganti penuh**, gets a piece `{kind: catalogue, ref: kasir}` at the payment stage. Tell the owner the cashier
40
+ screen runs on a tablet or a phone:
41
+
42
+ > Untuk meja kasir aku pasang Kasir. Layarnya jalan di tablet atau HP, jadi tidak perlu mesin kasir khusus.
43
+
44
+ - If the owner keeps their current cashier (**pendamping**, for example Moka or another POS), do not place kasir. Their
45
+ sales come in through the imports from the cashier they already use (check which imports exist with
46
+ `rangka_catalogue` / `rangka_meta` before naming one).
47
+ - If you do not know yet, ask what they use at the counter today before placing anything.
48
+
33
49
  ## Explaining it to an owner who already runs an app
34
50
 
35
51
  Use the catalogue's `shares` and `adds` for `kasir`. On a site running Rangka F&B Cabang it shares items, outlets,
@@ -20,6 +20,9 @@ modules:
20
20
  dashboards: [kursus_ringkas, kelas_saya]
21
21
  roles: [course_admin, instructor, finance_manager]
22
22
  home: {dashboard: kursus_ringkas}
23
+ # The instructor lands on the class roll (contract 0030 roll); Kelas saya stays their dashboard.
24
+ work:
25
+ - {screen: absen_kelas, roles: [instructor], home: true}
23
26
  menu:
24
27
  - group: {id: Kelas}
25
28
  items: [course_batch, course_session, enrollment]
@@ -23,10 +23,14 @@ modules:
23
23
  dashboards: [langganan_ringkas, penagihan_saya]
24
24
  roles: [finance_manager, collector]
25
25
  home: {dashboard: langganan_ringkas}
26
+ # The collector lands on the route of the day (contract 0030 route); Penagihan saya stays their dashboard.
27
+ work:
28
+ - {screen: rute_tagih, roles: [collector], home: true}
29
+ - {screen: catat_tagih, roles: [collector]}
26
30
  menu:
27
31
  - group: {id: Langganan}
28
32
  items: [subscription, subscription_bill, subscription_extra, subscription_status_log]
29
33
  - group: {id: Penagihan lapangan}
30
- items: [field_collection, collector_deposit, service_area]
34
+ items: [field_collection, collection_visit, collector_deposit, service_area]
31
35
  - group: {id: Pengaturan langganan}
32
36
  items: [subscription_plan, subscription_month]
@@ -11,7 +11,7 @@ rangka: '>=0.5'
11
11
  # A piece (riset/desain/11-susunan-kepingan.md) for rental businesses (kamera, alat pesta, alat outdoor). The rent
12
12
  # invoices it drafts are collected through faktur_piutang (payments); the deposit journals need pembukuan. Staf gudang
13
13
  # (rental_staff) records equipment out and back per unit with a checklist and prints the BAST; their dashboard is
14
- # alat_hari_ini. The handover screens of contract 0030 (kernel WS8) bind here with work: once the renderer exists.
14
+ # alat_hari_ini; their home is the work screen jadwal_alat (contract 0030), which opens the handover screens.
15
15
  modules:
16
16
  users: ^1.0
17
17
  contacts: ^1.0
@@ -21,6 +21,11 @@ modules:
21
21
  dashboards: [sewa_ringkas, alat_hari_ini]
22
22
  roles: [sales_manager, finance_manager, head_office, rental_staff]
23
23
  home: {dashboard: sewa_ringkas}
24
+ work:
25
+ - {screen: jadwal_alat, roles: [rental_staff], home: true}
26
+ - {screen: jadwal_alat, roles: [sales_manager]}
27
+ - {screen: alat_keluar}
28
+ - {screen: alat_kembali}
24
29
  menu:
25
30
  - group: {id: Sewa alat}
26
31
  items: [rental_booking, rental_checkout, rental_return, rental_schedule]
@@ -46,11 +46,11 @@ triggers:
46
46
  # what is emitted, kept 30 days); a refunded one emits a new event (payment_refunds, refunded_quantity), and flow
47
47
  # moka_transaction_staged (rangka-apps) books only the quantity refunded since, per checkout uuid.
48
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).
49
+ # - Pages: next: next makes the kernel follow Moka's next_url (on api.mokapos.com only) until it is null (rangka-os
50
+ # contract 0002, refinement 11 Nov 2026; at most 50 pages of 100 per outlet and poll), so the whole window is read
51
+ # and nothing in it is lost. A refund made more than two days after the sale is outside the window (head office
52
+ # books it, or the export). An outlet moves from the export file to the API on the day head office sets its
53
+ # moka_api_from (rangka-apps outlet; until then its API transactions are kept without lines).
54
54
  # To confirm once Moka grants API access: synchronized_at for offline sales, the largest per_page, the offset of
55
55
  # created_at (flows take the day from its first 10 characters, a Z time as WIB).
56
56
  - name: transaction_created
@@ -64,6 +64,7 @@ triggers:
64
64
  since: "(days_between('1970-01-01', today()) - 2) * 86400"
65
65
  time_filter: "'synchronized_at'"
66
66
  reorder_type: "'DESC'"
67
+ next: next
67
68
  for_each: payments[]
68
69
  emit:
69
70
  transaction_id: item.id
@@ -122,6 +122,15 @@ fields:
122
122
  label: {id: Kode barang/jasa Coretax}
123
123
  help: {id: '6 angka dari referensi kode barang/jasa Coretax. Kosongkan bila tidak tahu (000000)'}
124
124
  depends_on: app_installed('coretax')
125
+ # Records already linked by documents cannot be deleted (kernel: 409 linked); one no longer used is switched off
126
+ # instead and kept for its history. Hiding it from link pickers is a kernel follow-up (web).
127
+ - name: active
128
+ type: check
129
+ label: {id: Aktif}
130
+ help: {id: 'Matikan bila barang tidak dijual atau dibeli lagi. Barang yang sudah dipakai transaksi tidak bisa dihapus'}
131
+ default: 'true'
132
+ in_list: true
133
+ in_filter: true
125
134
  rules:
126
135
  - name: coretax_code_6
127
136
  on: save
@@ -140,6 +140,15 @@ fields:
140
140
  type: table
141
141
  of: contact_person
142
142
  label: {id: Kontak person}
143
+ # Records already linked by documents cannot be deleted (kernel: 409 linked); one no longer used is switched off
144
+ # instead and kept for its history. Hiding it from link pickers is a kernel follow-up (web).
145
+ - name: active
146
+ type: check
147
+ label: {id: Aktif}
148
+ help: {id: 'Matikan bila pelanggan tidak aktif lagi. Pelanggan yang sudah punya transaksi tidak bisa dihapus'}
149
+ default: 'true'
150
+ in_list: true
151
+ in_filter: true
143
152
  rules:
144
153
  - name: npwp_16
145
154
  on: save
@@ -162,7 +171,7 @@ views:
162
171
  layout:
163
172
  - section: {id: Identitas}
164
173
  columns:
165
- - [customer_name, city, address]
174
+ - [customer_name, city, address, active]
166
175
  - [npwp, phone, email]
167
176
  - section: {id: Data pajak (e-Faktur)}
168
177
  columns:
@@ -68,6 +68,15 @@ fields:
68
68
  type: table
69
69
  of: contact_person
70
70
  label: {id: Kontak person}
71
+ # Records already linked by documents cannot be deleted (kernel: 409 linked); one no longer used is switched off
72
+ # instead and kept for its history. Hiding it from link pickers is a kernel follow-up (web).
73
+ - name: active
74
+ type: check
75
+ label: {id: Aktif}
76
+ help: {id: 'Matikan bila pemasok tidak dipakai lagi. Pemasok yang sudah punya transaksi tidak bisa dihapus'}
77
+ default: 'true'
78
+ in_list: true
79
+ in_filter: true
71
80
  rules:
72
81
  - name: npwp_16
73
82
  on: save
@@ -90,7 +99,7 @@ views:
90
99
  layout:
91
100
  - section: {id: Identitas}
92
101
  columns:
93
- - [vendor_name, city, address]
102
+ - [vendor_name, city, address, active]
94
103
  - [npwp, phone, email]
95
104
  - section: {id: Data pajak (bukti potong)}
96
105
  columns:
@@ -0,0 +1,14 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ name: session_attendance_checked
3
+ label: {id: Absen pertemuan dicek saat pengajar menyimpannya}
4
+ # The instructor's roll screen (screens/absen_kelas.rk) saves the attendance lines and nothing else (contract 0030 §2
5
+ # roll; course_session is not submittable). Saving them is the check: an instructor's save of a session on or before
6
+ # its day ticks attendance_taken, so the meeting leaves "Absen belum dicek" (dashboard kelas_saya). A save that
7
+ # unticks it (before ticked) is left as the instructor wrote it; the course admin's saves tick nothing.
8
+ on: course_session.updated
9
+ if: "event.before != null && !event.before.attendance_taken && !event.attendance_taken && size(event.attendance) > 0 && event.session_date <= today() && 'instructor' in user.roles"
10
+ steps:
11
+ - {find: course_session, where: name == event.name, as: me}
12
+ - update: me
13
+ set:
14
+ attendance_taken: 'true'
@@ -0,0 +1,34 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ name: session_of_the_day
3
+ label: {id: Pertemuan hari ini dibuka dari jadwal mingguan}
4
+ # Every day at 00:10 (scheduler.timezone), and by the owner from the flow list: each running batch with a class on
5
+ # today's weekday (class_days, the same test as dashboard kelas_saya) and no session dated today gets one, numbered
6
+ # after its last session, with one attendance line per registered or active student marked present. So the
7
+ # instructor's roll screen (screens/absen_kelas.rk) has today's class ready and only the exceptions are marked.
8
+ # A flow-made record runs no other flow, so the lines are filled here as session_fill_attendance does for a session
9
+ # made by hand. session_key (batch|session_no) is unique: a second run the same day makes nothing new.
10
+ # At most 200 batches per run.
11
+ schedule: '10 0 * * *'
12
+ steps:
13
+ - find_all: course_batch
14
+ where: "start_date <= today() && (end_date == '' || end_date >= today()) && class_days.contains(['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'][days_between('2024-01-01', today()) % 7])"
15
+ sort: name
16
+ limit: 200
17
+ as: batches
18
+ - for_each: batches
19
+ as: b
20
+ do:
21
+ - find_all: course_session
22
+ where: batch == b.name
23
+ as: past
24
+ - find_all: enrollment
25
+ where: batch == b.name && (status == 'registered' || status == 'active')
26
+ sort: student
27
+ as: list
28
+ - create: course_session
29
+ if: "past.map(x, x.session_date == today() ? 1 : 0).sum() == 0"
30
+ set:
31
+ batch: b.name
32
+ session_no: "past.size() == 0 ? 1 : max(past.map(x, x.session_no)) + 1"
33
+ session_date: today()
34
+ attendance: "list.map(e, {'enrollment': e.name, 'status': 'present'})"
@@ -9,6 +9,8 @@ fields:
9
9
  required: true
10
10
  - {name: student, type: link, to: student, label: {id: Peserta}, compute: enrollment.student}
11
11
  - {name: batch, type: link, to: course_batch, label: {id: Angkatan}, compute: enrollment.batch}
12
+ # the name the roll screen shows on each line (screens/absen_kelas.rk)
13
+ - {name: student_name, type: data, label: {id: Nama peserta}, compute: enrollment.student.student_name}
12
14
  - name: status
13
15
  type: select
14
16
  label: {id: Kehadiran}
@@ -18,6 +18,7 @@ fields:
18
18
  required: true
19
19
  in_list: true
20
20
  - {name: instructor, type: link, to: user, label: {id: Akun pengajar}, compute: batch.instructor}
21
+ - {name: batch_title, type: data, label: {id: Nama angkatan}, compute: batch.batch_name}
21
22
  - name: session_no
22
23
  type: int
23
24
  label: {id: Pertemuan ke}
@@ -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.1.0
3
+ version: 1.2.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,17 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/screen.json
2
+ name: absen_kelas
3
+ type: roll
4
+ label: {id: Absen kelas, en: Class roll}
5
+ icon: users
6
+ # The instructor marks today's class from the phone (plans/layar-kerja.md §3 #5, contract 0030 §2 roll): every
7
+ # student starts present (flow session_of_the_day or session_fill_attendance), the instructor marks only who is
8
+ # excused, sick or absent, and saves; saving ticks "Absen sudah dicek" (flow session_attendance_checked). The
9
+ # meetings offered are the instructor's own (row scope) up to today whose attendance is not checked yet, newest
10
+ # first; one opens by itself. No submit: course_session is not a submittable document.
11
+ roles: [instructor]
12
+ device: phone
13
+ offline: queue
14
+ roll:
15
+ document: {model: course_session, find: "session_date <= today() && !attendance_taken", sort: "-session_date", title: batch_title, subtitle: session_date}
16
+ rows: {table: attendance, label: student_name, mark: {field: status, values: [present, excused, sick, absent], default: present}, note: note}
17
+ submit: false
@@ -0,0 +1,30 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Head office set (or moved earlier) an outlet's moka_api_from: the outlet's held Moka lines dated on or after it become
3
+ # staged and go into the next daily recap (flow moka_daily_sales). Held lines are what the API polled before the gate
4
+ # opened (audit moka-guard H1): without this they would be counted by neither the API nor the export. Lines dated
5
+ # before the date stay held (the export counts those days). A held line without item (head office emptied it) goes back
6
+ # to unmapped instead of staged, so saving the outlet is never refused by rule staged_has_outlet_and_item (audit
7
+ # moka-guard D2); flow moka_held_release catches held lines this run did not see (D1). Lines of the outlet from the
8
+ # date on that are still unmapped (an unknown item polled while the outlet was on the export, which was not told then:
9
+ # D3) are told to head office now, so the day is not recapped without them unnoticed (audit held-release A2).
10
+ name: moka_api_opened
11
+ label: {id: Baris Moka yang ditahan dilepas saat outlet mulai pakai API}
12
+ on: outlet.updated
13
+ if: "event.moka_api_from != null && event.moka_api_from != ''"
14
+ steps:
15
+ - find_all: moka_sale_line
16
+ where: "outlet == event.name && status == 'held' && date >= event.moka_api_from"
17
+ as: held
18
+ - for_each: held
19
+ as: l
20
+ do:
21
+ - update: l
22
+ set:
23
+ status: "l.item != '' ? 'staged' : 'unmapped'"
24
+ - find_all: moka_sale_line
25
+ where: "outlet == event.name && status == 'unmapped' && date >= event.moka_api_from"
26
+ as: waiting
27
+ - notify: head_office
28
+ if: size(waiting) > 0
29
+ channel: email
30
+ template: {id: '{event.outlet_name} mulai pakai API Moka: {size(waiting)} baris Moka belum dipetakan, petakan di Baris penjualan Moka'}
@@ -0,0 +1,35 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Every hour at :10 (before the recap at :15, flow moka_daily_sales) and from the flow list: held Moka lines whose
3
+ # outlet now counts the API for their day (outlet.moka_api_from set, on or before the line's date) become staged.
4
+ # Flow moka_api_opened does this when head office saves the outlet; this run catches the rest (audit moka-guard D1): a
5
+ # held line head office moved to an outlet already on the API, or a line a poll wrote while the outlet was being
6
+ # saved. A held line without item (head office emptied it) goes back to unmapped instead (rule
7
+ # staged_has_outlet_and_item, D2). Only outlets whose API has started (moka_api_from <= today) are read, and only lines
8
+ # from the earliest of their dates on (audit held-release A1: an outlet with a future date or a long export period
9
+ # must not fill the 2000-line read), and each line against its own outlet's date in the read itself (A1': a held line
10
+ # before a later gate is never released, so it must not take a place in the 2000); if 2000 lines still come back,
11
+ # head office is told and the next runs go on with the rest.
12
+ # A held line without outlet is not read: it waits until head office gives it an outlet.
13
+ name: moka_held_release
14
+ label: {id: Baris Moka yang ditahan dilepas bila outlet sudah pakai API}
15
+ schedule: '10 * * * *'
16
+ steps:
17
+ - find_all: outlet
18
+ where: "moka_api_from != '' && moka_name != '' && moka_api_from <= today()"
19
+ sort: moka_api_from
20
+ as: open
21
+ - find_all: moka_sale_line
22
+ if: size(open) > 0
23
+ where: "status == 'held' && outlet in open.map(o, o.name) && date >= open[0].moka_api_from && open.exists(o, o.name == outlet && o.moka_api_from <= date)"
24
+ limit: 2000
25
+ as: held
26
+ - for_each: "size(open) > 0 ? held : []"
27
+ as: l
28
+ do:
29
+ - update: l
30
+ set:
31
+ status: "l.item != '' ? 'staged' : 'unmapped'"
32
+ - notify: head_office
33
+ if: size(open) > 0 && size(held) >= 2000
34
+ channel: email
35
+ template: {id: 'Lebih dari 2000 baris Moka masih ditahan; dilepas bertahap tiap jam. Cek tanggal Mulai pakai API Moka di outlet'}
@@ -2,22 +2,31 @@
2
2
  # Head office picked the outlet and the item of an unmapped Moka line: it becomes staged and goes into the next daily
3
3
  # recap (flow moka_daily_sales). The unmapped refund lines of the same Moka checkout (same transaction and checkout,
4
4
  # or for a line without checkout the same description) take the same outlet and item and are staged with it, so a
5
- # sale and its refund go into the recap together.
5
+ # sale and its refund go into the recap together. A line dated before the outlet's moka_api_from (or while it is
6
+ # empty) is held instead of staged (the export counts that day); flow moka_api_opened stages it later.
6
7
  name: moka_line_mapped
7
8
  label: {id: Baris Moka yang sudah dipetakan siap direkap}
8
9
  on: moka_sale_line.updated
9
10
  if: event.status == 'unmapped' && event.outlet != '' && event.item != ''
10
11
  steps:
12
+ # the outlet's API gate (outlet.moka_api_from): before it the line is held, the export counts that day
13
+ - find: outlet
14
+ where: "name == event.outlet && moka_api_from != '' && moka_api_from <= event.date"
15
+ as: open_for
11
16
  - find: moka_sale_line
12
17
  where: name == event.name
13
18
  as: rec
14
19
  - update: rec
15
20
  set:
16
- status: "'staged'"
21
+ status: "open_for != null ? 'staged' : 'held'"
17
22
  - find_all: moka_sale_line
18
23
  if: event.qty > 0
19
24
  where: "name != event.name && transaction == event.transaction && qty < 0 && status == 'unmapped' && (event.checkout != '' ? checkout == event.checkout : (checkout == '' && description == 'Retur ' + event.description))"
20
25
  as: refunds
26
+ - find: outlet
27
+ if: event.qty > 0
28
+ where: name == event.outlet
29
+ as: outlet_gate
21
30
  - for_each: refunds
22
31
  if: event.qty > 0
23
32
  as: r
@@ -26,4 +35,4 @@ steps:
26
35
  set:
27
36
  outlet: event.outlet
28
37
  item: event.item
29
- status: "'staged'"
38
+ status: "outlet_gate != null && outlet_gate.moka_api_from != '' && outlet_gate.moka_api_from <= r.date ? 'staged' : 'held'"
@@ -0,0 +1,15 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # A Moka transaction flow moka_transaction_staged does not book, told to head office instead of dropped silently:
3
+ # - no id (transaction_id missing, null or ""): the kernel does not dedupe an empty idempotency key, so a repeated poll
4
+ # would count the sale twice (audit kernel-gelombang1 Delta 2, t_34922edd);
5
+ # - a checkout with quantity or total_price missing or null (audit moka-guard L1): booking a guess is worse than asking.
6
+ # Head office checks it in Moka and books it by hand or through the export. The kernel's event dedupe (hash of the
7
+ # event, 30 days) keeps one notice per distinct event.
8
+ name: moka_transaction_refused
9
+ label: {id: Transaksi Moka yang tidak bisa dicatat diberitahukan}
10
+ on: moka.transaction_created
11
+ if: "!('transaction_id' in event) || event.transaction_id == null || string(event.transaction_id) == '' || ('checkouts' in event && event.checkouts.map(c, 'quantity' in c && c.quantity != null && 'total_price' in c && c.total_price != null ? 0 : 1).sum() > 0)"
12
+ steps:
13
+ - notify: head_office
14
+ channel: email
15
+ template: {id: 'Moka {event.receipt_no} ({event.outlet_name}): transaksi tanpa ID atau jumlah/harga dari Moka tidak dicatat, cek di Moka'}
@@ -21,11 +21,21 @@
21
21
  # new transaction (unmapped lines are told about line by line), two per checkout for a refund.
22
22
  # The day is the first 10 characters of created_at (Moka answers in the outlet's local time, +07:00); a time in UTC
23
23
  # (ending in Z) is taken as WIB (+7 hours) first. The same for refunded_date. To confirm once API access is granted.
24
- # Idempotency: the transaction and its refunded quantity, so a new refund is a new run and a repeat is not.
24
+ # Idempotency: the transaction and its refunded quantity, so a new refund is a new run and a repeat is not. An event
25
+ # without transaction_id (null or "") is not run: the kernel does not dedupe an empty key, so a repeated poll could book
26
+ # it twice; flow moka_transaction_without_id tells head office instead.
27
+ # Gate (audit sisa-1111 R1): a line of a known outlet whose day is before the outlet's moka_api_from (or while it is
28
+ # empty) is recorded as held, not staged: the export counts that day and the recap leaves it alone. When head office
29
+ # sets moka_api_from, flow moka_api_opened stages the held lines from that day on, so transactions polled before the
30
+ # gate opened are not lost (audit moka-guard H1). A late refund is gated by its own day (a sale counted by the export,
31
+ # refunded after the switch, is booked by the API: M1). Lines of an unknown outlet stay unmapped; mapping them checks
32
+ # the gate (flow moka_line_mapped, rule staged_outlet_api_open). refunded_quantity may be null in a checkout (Moka's
33
+ # spec does not list it): null is 0. A checkout with quantity or total_price null is not booked (flow
34
+ # moka_transaction_refused tells head office).
25
35
  name: moka_transaction_staged
26
36
  label: {id: Transaksi Moka masuk jadi baris penjualan}
27
37
  on: moka.transaction_created
28
- if: "'transaction_id' in event && 'created_at' in event && 'checkouts' in event && 'outlet_id' in event"
38
+ if: "'transaction_id' in event && event.transaction_id != null && string(event.transaction_id) != '' && 'created_at' in event && 'checkouts' in event && 'outlet_id' in event && event.checkouts.map(c, 'quantity' in c && c.quantity != null && 'total_price' in c && c.total_price != null ? 0 : 1).sum() == 0"
29
39
  idempotency: "string(event.transaction_id) + ':' + string(event.checkouts.map(c, 'refunded_quantity' in c && c.refunded_quantity != null ? c.refunded_quantity : 0).sum())"
30
40
  steps:
31
41
  - find: moka_transaction
@@ -53,6 +63,11 @@ steps:
53
63
  total_collected: "'total_collected' in event ? event.total_collected : 0"
54
64
  refunded: "'is_refunded' in event && event.is_refunded == true"
55
65
  as: tx
66
+ # the outlet's gate: open on and after its moka_api_from
67
+ - find: outlet
68
+ if: known == null
69
+ where: "tx.outlet != '' && name == tx.outlet && moka_api_from != '' && moka_api_from <= tx.date"
70
+ as: api_open
56
71
  - for_each: event.checkouts
57
72
  if: known == null
58
73
  as: c
@@ -79,11 +94,11 @@ steps:
79
94
  gross: c.total_price
80
95
  discount: "min('discount_amount' in c ? c.discount_amount : 0, c.total_price)"
81
96
  refund: "0"
82
- status: "tx.outlet == '' || (by_sku == null && by_item_name == null) ? 'unmapped' : 'staged'"
97
+ status: "tx.outlet == '' || (by_sku == null && by_item_name == null) ? 'unmapped' : (api_open != null ? 'staged' : 'held')"
83
98
  - create: moka_sale_line
84
99
  # a refund line only when it returns money: a refund of a free item (100% discount) changes nothing and a line of
85
100
  # qty < 0 without refund is refused by outlet_sales; never more than the quantity sold
86
- if: "c.quantity > 0 && c.total_price >= 0 && 'refunded_quantity' in c && c.refunded_quantity > 0 && round((c.total_price - min('discount_amount' in c ? c.discount_amount : 0, c.total_price)) * min(c.refunded_quantity, c.quantity) / c.quantity) > 0"
101
+ if: "c.quantity > 0 && c.total_price >= 0 && 'refunded_quantity' in c && c.refunded_quantity != null && c.refunded_quantity > 0 && round((c.total_price - min('discount_amount' in c ? c.discount_amount : 0, c.total_price)) * min(c.refunded_quantity, c.quantity) / c.quantity) > 0"
87
102
  set:
88
103
  transaction: tx.name
89
104
  checkout: "('uuid' in c && c.uuid != null && string(c.uuid) != '' ? string(c.uuid) : ('id' in c && c.id != null ? string(c.id) : ''))"
@@ -96,20 +111,25 @@ steps:
96
111
  gross: "0"
97
112
  discount: "0"
98
113
  refund: "round((c.total_price - min('discount_amount' in c ? c.discount_amount : 0, c.total_price)) * min(c.refunded_quantity, c.quantity) / c.quantity)"
99
- status: "tx.outlet == '' || (by_sku == null && by_item_name == null) ? 'unmapped' : 'staged'"
114
+ status: "tx.outlet == '' || (by_sku == null && by_item_name == null) ? 'unmapped' : (api_open != null ? 'staged' : 'held')"
100
115
  - notify: head_office
101
- if: "tx.outlet != '' && c.quantity > 0 && c.total_price >= 0 && by_sku == null && by_item_name == null"
116
+ # an outlet still on the export is not told about items (its lines wait held/unmapped; audit moka-guard D3)
117
+ if: "tx.outlet != '' && api_open != null && c.quantity > 0 && c.total_price >= 0 && by_sku == null && by_item_name == null"
102
118
  channel: email
103
119
  template: {id: 'Moka {tx.receipt_no} ({tx.moka_outlet}, {tx.date}): barang "{c.item_name}" belum dikenali, petakan di Baris penjualan Moka'}
104
120
  - notify: head_office
105
- if: "known == null && event.checkouts.map(c, c.quantity > 0 && c.total_price >= 0 ? 0 : 1).sum() > 0"
121
+ if: "known == null && (tx.outlet == '' || api_open != null) && event.checkouts.map(c, c.quantity > 0 && c.total_price >= 0 ? 0 : 1).sum() > 0"
106
122
  channel: email
107
123
  template: {id: 'Moka {tx.receipt_no} ({tx.moka_outlet}, {tx.date}) punya barang dengan qty 0 atau minus, atau total minus, tidak direkap. Cek di Moka'}
108
124
  - notify: head_office
109
125
  if: "known == null && tx.outlet == ''"
110
126
  channel: email
111
127
  template: {id: 'Moka {tx.receipt_no} ({tx.moka_outlet}, {tx.date}): outlet belum dikenali, petakan barisnya di Baris penjualan Moka'}
112
- # a known transaction that changed in Moka: refunds made after the first poll
128
+ # a known transaction that changed in Moka: refunds made after the first poll, gated by the refund's own day
129
+ - find: outlet
130
+ if: known != null
131
+ where: "known.outlet != '' && name == known.outlet"
132
+ as: ko
113
133
  - for_each: event.checkouts
114
134
  if: known != null
115
135
  as: c
@@ -126,7 +146,7 @@ steps:
126
146
  where: "transaction == known.name && qty < 0 && checkout == sold.checkout && description == 'Retur ' + sold.description"
127
147
  as: returned
128
148
  - create: moka_sale_line
129
- if: "sold != null && 'refunded_quantity' in c && min(c.refunded_quantity, sold.qty) + returned.map(l, l.qty).sum() > 0 && round((sold.gross - sold.discount) * (min(c.refunded_quantity, sold.qty) + returned.map(l, l.qty).sum()) / sold.qty) > 0"
149
+ if: "sold != null && 'refunded_quantity' in c && c.refunded_quantity != null && min(c.refunded_quantity, sold.qty) + returned.map(l, l.qty).sum() > 0 && round((sold.gross - sold.discount) * (min(c.refunded_quantity, sold.qty) + returned.map(l, l.qty).sum()) / sold.qty) > 0"
130
150
  set:
131
151
  transaction: known.name
132
152
  checkout: sold.checkout
@@ -139,10 +159,10 @@ steps:
139
159
  gross: "0"
140
160
  discount: "0"
141
161
  refund: "round((sold.gross - sold.discount) * (min(c.refunded_quantity, sold.qty) + returned.map(l, l.qty).sum()) / sold.qty)"
142
- status: "sold.status == 'unmapped' || sold.outlet == '' || sold.item == '' ? 'unmapped' : 'staged'"
162
+ status: "sold.status == 'unmapped' || sold.outlet == '' || sold.item == '' ? 'unmapped' : (ko != null && ko.name == sold.outlet && ko.moka_api_from != '' && ko.moka_api_from <= ('refunded_date' in event && event.refunded_date != null && event.refunded_date != '' ? (string(event.refunded_date).matches('Z$') ? event.refunded_date + duration('7h') : event.refunded_date) : today()) ? 'staged' : 'held')"
143
163
  as: late
144
164
  - notify: head_office
145
- if: "sold != null && 'refunded_quantity' in c && min(c.refunded_quantity, sold.qty) + returned.map(l, l.qty).sum() > 0 && round((sold.gross - sold.discount) * (min(c.refunded_quantity, sold.qty) + returned.map(l, l.qty).sum()) / sold.qty) > 0"
165
+ if: "sold != null && 'refunded_quantity' in c && c.refunded_quantity != null && min(c.refunded_quantity, sold.qty) + returned.map(l, l.qty).sum() > 0 && round((sold.gross - sold.discount) * (min(c.refunded_quantity, sold.qty) + returned.map(l, l.qty).sum()) / sold.qty) > 0"
146
166
  channel: email
147
167
  template: {id: 'Moka {known.receipt_no} ({known.moka_outlet}): retur susulan {sold.description} dicatat di Baris penjualan Moka'}
148
168
  - update: known
@@ -1,7 +1,7 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
2
  # One item of one Moka transaction, waiting to become a line of the outlet's daily sales (flow moka_daily_sales). A flat
3
3
  # record, not a child table, so the daily flow can read every line of an outlet and day with one find_all.
4
- # status: staged (ready), unmapped (no outlet or no item matched: head office picks them here and the line becomes
4
+ # status: staged (ready), held (the outlet's API gate is closed for its day, see outlet.moka_api_from), unmapped (no outlet or no item matched: head office picks them here and the line becomes
5
5
  # staged, flow moka_line_mapped; head office may still correct them while staged), posted (in outlet_sales `sales`). A refunded quantity is its own line, as in the
6
6
  # export import: qty < 0, gross 0, refund = the refunded share of the line's net. A refund Moka reports after the first
7
7
  # poll is a refund line of its own, dated the day of the refund (flow moka_transaction_staged).
@@ -41,6 +41,9 @@ fields:
41
41
  - {value: staged, label: {id: Siap direkap}}
42
42
  - {value: unmapped, label: {id: Belum dipetakan}}
43
43
  - {value: posted, label: {id: Sudah direkap}}
44
+ # the outlet does not count Moka API sales for this day yet (outlet.moka_api_from empty or later): the export
45
+ # counts it; flow moka_api_opened stages it once head office opens the outlet's API from this day or earlier
46
+ - {value: held, label: {id: Ditahan (outlet masih ekspor)}}
44
47
  - {name: sales, type: link, to: outlet_sales, label: {id: Penjualan harian}, read_only: true, in_list: true}
45
48
  rules:
46
49
  - name: staged_has_outlet_and_item
@@ -52,6 +55,11 @@ rules:
52
55
  on: save
53
56
  check: status != 'staged' || outlet == '' || outlet.moka_name != ''
54
57
  message: {id: 'Pilih outlet yang memakai Moka (Nama outlet di Moka terisi)'}
58
+ # an API line counts only from the outlet's moka_api_from on: before it the export counts that day (audit R1)
59
+ - name: staged_outlet_api_open
60
+ on: save
61
+ check: status != 'staged' || outlet == '' || (outlet.moka_api_from != '' && outlet.moka_api_from <= date)
62
+ message: {id: 'Outlet ini belum memakai API Moka untuk tanggal baris ini. Isi Mulai pakai API Moka di outlet, atau catat lewat ekspor'}
55
63
  views:
56
64
  list:
57
65
  columns: [date, outlet, description, qty, status, item, sales]
@@ -54,14 +54,26 @@ fields:
54
54
  label: {id: ID outlet di Moka}
55
55
  help: {id: 'Diisi saat Moka tersambung lewat API. Selama connector Moka aktif, outlet juga dicocokkan lewat Nama outlet di Moka'}
56
56
  depends_on: app_installed('outlet_sales') && moka_name != ''
57
+ # The gate from the export to the API (audit sisa-1111 R1): flow moka_transaction_staged books a transaction of this
58
+ # outlet only when its day is on or after this date; before it (or while empty) the outlet's Moka sales come from
59
+ # the Item Details export alone, so a day is never counted from both. Set it to the first day the API should count,
60
+ # after the last exported day. The kernel follows Moka's next_url since rangka-os t_277ba9bf, so the API reads the
61
+ # whole two-day window of every poll.
62
+ - name: moka_api_from
63
+ type: date
64
+ label: {id: Mulai pakai API Moka}
65
+ help: {id: 'Hari pertama penjualan diambil lewat API Moka (sesudah ekspor terakhir). Kosong = tetap ekspor'}
66
+ depends_on: app_installed('outlet_sales') && moka_name != ''
57
67
  # The sales source of an outlet without Moka (moka_name empty): the daily form (default when empty), a file from
58
68
  # another POS in Juragan's template, a Loyverse export, or Juragan's own cashier (module pos). One source per outlet,
59
- # so a day is never counted twice.
69
+ # so a day is never counted twice. With module pos installed a new outlet without Moka starts on the cashier (a site
70
+ # built with app kasir next to an outlet_sales app can ring up at once); head office switches it per outlet.
60
71
  - name: sales_source
61
72
  type: select
62
73
  label: {id: Sumber penjualan}
63
74
  help: {id: 'Untuk outlet yang tidak pakai Moka. Kosong berarti formulir harian'}
64
75
  depends_on: app_installed('outlet_sales') && moka_name == ''
76
+ default: "app_installed('pos') && moka_name == '' ? 'kasir' : ''"
65
77
  options:
66
78
  - {value: form, label: {id: Formulir harian}}
67
79
  - {value: file, label: {id: File POS (template Juragan)}}
@@ -3,6 +3,9 @@ name: payslip_advance_guard
3
3
  label: {id: Potongan kasbon tidak melebihi kasbonnya}
4
4
  # Inside a payslip submit: the live slips that repay one kasbon (this one included) never deduct more than the kasbon
5
5
  # (audit gelombang 3 F5). The kasbon's own cancel is refused while one of them is submitted (cash_advance_cancel_guard).
6
+ # Two slips repaying one kasbon submitted at the same moment run one after the other: the find steps take the flow
7
+ # read locks of cash_advance and payslip (contract 0025), so the second one reads the first one's deduction and is
8
+ # refused (audit gelombang 3 r2 R3; day_one scenario_payroll_advance_race).
6
9
  on: payslip.submitted
7
10
  steps:
8
11
  - if: event.cash_advance != ''