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

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 (45) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/jasa_proyek/app.rk +1 -1
  3. package/template/base/apps/ritel_cabang/dashboards/ritel_stock.rk +4 -4
  4. package/template/base/modules/accounting/flows/gl_cash_advance_post.rk +33 -0
  5. package/template/base/modules/accounting/flows/gl_cash_advance_reverse.rk +194 -0
  6. package/template/base/modules/accounting/models/gl_entry.rk +1 -1
  7. package/template/base/modules/accounting/module.rk +1 -1
  8. package/template/base/modules/coretax/module.rk +1 -1
  9. package/template/base/modules/coretax/print/coretax_bupot.rk +10 -5
  10. package/template/base/modules/coretax/print/coretax_faktur.rk +12 -7
  11. package/template/base/modules/coretax/print/coretax_faktur.xml +4 -0
  12. package/template/base/modules/invoicing/models/sales_invoice.rk +3 -2
  13. package/template/base/modules/invoicing/module.rk +1 -1
  14. package/template/base/modules/kitchen/flows/kitchen_ticket_on_sale.rk +26 -8
  15. package/template/base/modules/kitchen/flows/kitchen_ticket_on_update.rk +5 -1
  16. package/template/base/modules/kitchen/flows/kitchen_ticket_on_void.rk +9 -1
  17. package/template/base/modules/kitchen/models/kitchen_guard.rk +5 -0
  18. package/template/base/modules/kitchen/models/kitchen_ticket.rk +5 -0
  19. package/template/base/modules/outlet_sales/flows/moka_daily_sales.rk +39 -18
  20. package/template/base/modules/outlet_sales/flows/moka_line_mapped.rk +16 -1
  21. package/template/base/modules/outlet_sales/flows/moka_transaction_staged.rk +85 -24
  22. package/template/base/modules/outlet_sales/flows/sales_cancel_guard.rk +5 -1
  23. package/template/base/modules/outlet_sales/models/moka_sale_line.rk +6 -1
  24. package/template/base/modules/outlet_sales/models/pos_refund.rk +4 -1
  25. package/template/base/modules/outlet_sales/module.rk +1 -1
  26. package/template/base/modules/payroll/flows/cash_advance_cancel_guard.rk +15 -0
  27. package/template/base/modules/payroll/flows/payslip_advance_guard.rk +20 -0
  28. package/template/base/modules/payroll/flows/payslip_casual_guard.rk +19 -0
  29. package/template/base/modules/payroll/flows/payslip_from_recap.rk +1 -1
  30. package/template/base/modules/payroll/flows/payslip_ytd_guard.rk +3 -1
  31. package/template/base/modules/payroll/flows/payslip_ytd_on_create.rk +3 -1
  32. package/template/base/modules/payroll/models/cash_advance.rk +53 -0
  33. package/template/base/modules/payroll/models/payroll_guard.rk +15 -0
  34. package/template/base/modules/payroll/models/payroll_profile.rk +11 -1
  35. package/template/base/modules/payroll/models/payslip.rk +66 -7
  36. package/template/base/modules/payroll/module.rk +1 -1
  37. package/template/base/modules/payroll/print/payslip.html +4 -3
  38. package/template/base/modules/pos/models/pos_sale.rk +2 -1
  39. package/template/base/modules/pos/models/pos_sale_item.rk +3 -0
  40. package/template/base/modules/procurement/models/vendor_bill.rk +3 -2
  41. package/template/base/modules/procurement/module.rk +1 -1
  42. package/template/base/modules/projects/models/assignment.rk +2 -2
  43. package/template/base/modules/projects/models/timesheet.rk +5 -0
  44. package/template/base/modules/projects/module.rk +1 -1
  45. package/template/base/modules/workforce/models/worker.rk +4 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rangka-os/create",
3
- "version": "0.5.0-alpha.12",
3
+ "version": "0.5.0-alpha.14",
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",
@@ -40,7 +40,7 @@ menu:
40
40
  - group: {id: Tenaga kerja}
41
41
  items: [worker]
42
42
  - group: {id: Penggajian}
43
- items: [payroll_run, payslip, payroll_close, payroll_profile]
43
+ items: [payroll_run, payslip, payroll_close, payroll_profile, cash_advance]
44
44
  - group: {id: Keuangan}
45
45
  items: [payment, bank_transaction, invoice_reminder, withholding, vendor_bill, bank_account]
46
46
  - group: {id: Pembelian}
@@ -50,12 +50,12 @@ widgets:
50
50
  type: chart
51
51
  chart: bar
52
52
  label: {id: Barang laku (qty)}
53
- description: {id: 'Qty terjual per barang pada periode, semua cabang'}
53
+ description: {id: 'Qty terjual per barang pada periode, semua cabang, dikurangi yang kembali ke stok'}
54
54
  model: stock_move
55
55
  group_by: item
56
56
  aggregate: sum
57
57
  field: sold_qty
58
- filter: voucher_type == 'outlet_sales'
58
+ filter: "voucher_type == 'outlet_sales' || voucher_type == 'outlet_return'"
59
59
  period: posting_date
60
60
  sort: -value
61
61
  limit: 10
@@ -64,12 +64,12 @@ widgets:
64
64
  type: chart
65
65
  chart: bar
66
66
  label: {id: Barang laku (harga pokok)}
67
- description: {id: 'Nilai harga pokok yang keluar karena penjualan'}
67
+ description: {id: 'Nilai harga pokok yang keluar karena penjualan, dikurangi yang kembali ke stok'}
68
68
  model: stock_move
69
69
  group_by: item
70
70
  aggregate: sum
71
71
  field: sold_cost
72
- filter: voucher_type == 'outlet_sales'
72
+ filter: "voucher_type == 'outlet_sales' || voucher_type == 'outlet_return'"
73
73
  period: posting_date
74
74
  sort: -value
75
75
  limit: 10
@@ -0,0 +1,33 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Generated by scripts/gen_accounting_flows.py; edit POSTINGS there, not this file.
3
+ name: gl_cash_advance_post
4
+ label: {id: Jurnal kasbon}
5
+ on: cash_advance.submitted
6
+ steps:
7
+ - find_all: period_close
8
+ where: docstatus == 1
9
+ sort: -closed_until
10
+ limit: 1
11
+ as: locks
12
+ - create: gl_entry
13
+ if: "(event.amount) != 0"
14
+ set:
15
+ posting_date: "event.advance_date"
16
+ account: "'11330'"
17
+ amount: "event.amount"
18
+ voucher_type: event.model
19
+ voucher: event.name
20
+ entry: "'post'"
21
+ line: "'1'"
22
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
23
+ - create: gl_entry
24
+ if: "(0 - event.amount) != 0"
25
+ set:
26
+ posting_date: "event.advance_date"
27
+ account: "event.method == 'cash' ? '11100' : '11200'"
28
+ amount: "0 - event.amount"
29
+ voucher_type: event.model
30
+ voucher: event.name
31
+ entry: "'post'"
32
+ line: "'2'"
33
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
@@ -0,0 +1,194 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Generated by scripts/gen_accounting_flows.py; edit POSTINGS there, not this file.
3
+ # The opposite of every line the document posted, on the post's own date, so a cancelled document nets to 0
4
+ # in its period. A document submitted before the accounting module was installed posted nothing and is not
5
+ # reversed. Amending posts the new document again.
6
+ name: gl_cash_advance_reverse
7
+ label: {id: Jurnal kasbon dibatalkan}
8
+ on: cash_advance.cancelled
9
+ steps:
10
+ - find_all: gl_entry
11
+ where: voucher_type == event.model && voucher == event.name && entry == 'post'
12
+ sort: line
13
+ as: posts
14
+ - find_all: period_close
15
+ where: docstatus == 1
16
+ sort: -closed_until
17
+ limit: 1
18
+ as: locks
19
+ - create: gl_entry
20
+ if: posts.size() > 0
21
+ set:
22
+ posting_date: posts[0].posting_date
23
+ account: posts[0].account
24
+ amount: 0 - posts[0].amount
25
+ voucher_type: posts[0].voucher_type
26
+ voucher: posts[0].voucher
27
+ entry: "'reverse'"
28
+ line: posts[0].line
29
+ reverses: posts[0].name
30
+ outlet: posts[0].outlet
31
+ project: posts[0].project
32
+ party: posts[0].party
33
+ against: posts[0].against
34
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
35
+ - create: gl_entry
36
+ if: posts.size() > 1
37
+ set:
38
+ posting_date: posts[1].posting_date
39
+ account: posts[1].account
40
+ amount: 0 - posts[1].amount
41
+ voucher_type: posts[1].voucher_type
42
+ voucher: posts[1].voucher
43
+ entry: "'reverse'"
44
+ line: posts[1].line
45
+ reverses: posts[1].name
46
+ outlet: posts[1].outlet
47
+ project: posts[1].project
48
+ party: posts[1].party
49
+ against: posts[1].against
50
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
51
+ - create: gl_entry
52
+ if: posts.size() > 2
53
+ set:
54
+ posting_date: posts[2].posting_date
55
+ account: posts[2].account
56
+ amount: 0 - posts[2].amount
57
+ voucher_type: posts[2].voucher_type
58
+ voucher: posts[2].voucher
59
+ entry: "'reverse'"
60
+ line: posts[2].line
61
+ reverses: posts[2].name
62
+ outlet: posts[2].outlet
63
+ project: posts[2].project
64
+ party: posts[2].party
65
+ against: posts[2].against
66
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
67
+ - create: gl_entry
68
+ if: posts.size() > 3
69
+ set:
70
+ posting_date: posts[3].posting_date
71
+ account: posts[3].account
72
+ amount: 0 - posts[3].amount
73
+ voucher_type: posts[3].voucher_type
74
+ voucher: posts[3].voucher
75
+ entry: "'reverse'"
76
+ line: posts[3].line
77
+ reverses: posts[3].name
78
+ outlet: posts[3].outlet
79
+ project: posts[3].project
80
+ party: posts[3].party
81
+ against: posts[3].against
82
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
83
+ - create: gl_entry
84
+ if: posts.size() > 4
85
+ set:
86
+ posting_date: posts[4].posting_date
87
+ account: posts[4].account
88
+ amount: 0 - posts[4].amount
89
+ voucher_type: posts[4].voucher_type
90
+ voucher: posts[4].voucher
91
+ entry: "'reverse'"
92
+ line: posts[4].line
93
+ reverses: posts[4].name
94
+ outlet: posts[4].outlet
95
+ project: posts[4].project
96
+ party: posts[4].party
97
+ against: posts[4].against
98
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
99
+ - create: gl_entry
100
+ if: posts.size() > 5
101
+ set:
102
+ posting_date: posts[5].posting_date
103
+ account: posts[5].account
104
+ amount: 0 - posts[5].amount
105
+ voucher_type: posts[5].voucher_type
106
+ voucher: posts[5].voucher
107
+ entry: "'reverse'"
108
+ line: posts[5].line
109
+ reverses: posts[5].name
110
+ outlet: posts[5].outlet
111
+ project: posts[5].project
112
+ party: posts[5].party
113
+ against: posts[5].against
114
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
115
+ - create: gl_entry
116
+ if: posts.size() > 6
117
+ set:
118
+ posting_date: posts[6].posting_date
119
+ account: posts[6].account
120
+ amount: 0 - posts[6].amount
121
+ voucher_type: posts[6].voucher_type
122
+ voucher: posts[6].voucher
123
+ entry: "'reverse'"
124
+ line: posts[6].line
125
+ reverses: posts[6].name
126
+ outlet: posts[6].outlet
127
+ project: posts[6].project
128
+ party: posts[6].party
129
+ against: posts[6].against
130
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
131
+ - create: gl_entry
132
+ if: posts.size() > 7
133
+ set:
134
+ posting_date: posts[7].posting_date
135
+ account: posts[7].account
136
+ amount: 0 - posts[7].amount
137
+ voucher_type: posts[7].voucher_type
138
+ voucher: posts[7].voucher
139
+ entry: "'reverse'"
140
+ line: posts[7].line
141
+ reverses: posts[7].name
142
+ outlet: posts[7].outlet
143
+ project: posts[7].project
144
+ party: posts[7].party
145
+ against: posts[7].against
146
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
147
+ - create: gl_entry
148
+ if: posts.size() > 8
149
+ set:
150
+ posting_date: posts[8].posting_date
151
+ account: posts[8].account
152
+ amount: 0 - posts[8].amount
153
+ voucher_type: posts[8].voucher_type
154
+ voucher: posts[8].voucher
155
+ entry: "'reverse'"
156
+ line: posts[8].line
157
+ reverses: posts[8].name
158
+ outlet: posts[8].outlet
159
+ project: posts[8].project
160
+ party: posts[8].party
161
+ against: posts[8].against
162
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
163
+ - create: gl_entry
164
+ if: posts.size() > 9
165
+ set:
166
+ posting_date: posts[9].posting_date
167
+ account: posts[9].account
168
+ amount: 0 - posts[9].amount
169
+ voucher_type: posts[9].voucher_type
170
+ voucher: posts[9].voucher
171
+ entry: "'reverse'"
172
+ line: posts[9].line
173
+ reverses: posts[9].name
174
+ outlet: posts[9].outlet
175
+ project: posts[9].project
176
+ party: posts[9].party
177
+ against: posts[9].against
178
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
179
+ - create: gl_entry
180
+ if: posts.size() > 10
181
+ set:
182
+ posting_date: posts[10].posting_date
183
+ account: posts[10].account
184
+ amount: 0 - posts[10].amount
185
+ voucher_type: posts[10].voucher_type
186
+ voucher: posts[10].voucher
187
+ entry: "'reverse'"
188
+ line: posts[10].line
189
+ reverses: posts[10].name
190
+ outlet: posts[10].outlet
191
+ project: posts[10].project
192
+ party: posts[10].party
193
+ against: posts[10].against
194
+ lock_date: "locks.size() > 0 ? locks[0].closed_until : null"
@@ -146,7 +146,7 @@ rules:
146
146
  - name: bill_cost_left
147
147
  on: save
148
148
  check: against == '' || entry == 'reverse' || bill_left >= 0
149
- message: {id: 'Biaya proyek atas tagihan ini melebihi sisa nilai tagihannya. Kurangi nilainya, atau catat tanpa tagihan.'}
149
+ message: {id: 'Biaya proyek atas tagihan ini melebihi sisa nilai tagihannya. Kurangi nilainya sampai sisa tagihan.'}
150
150
  - name: reverse_matches_post
151
151
  on: save
152
152
  check: >-
@@ -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: accounting
3
- version: 1.2.0
3
+ version: 1.3.0
4
4
  title: {id: Akuntansi, en: Accounting}
5
5
  summary:
6
6
  id: Jurnal, saldo awal, tutup buku dan laporan keuangan dari transaksi yang sudah dicatat.
@@ -3,7 +3,7 @@
3
3
  # (TaxInvoiceBulk) and the unified withholding slips the firm issues (BPPU, BpuBulk), checked before download.
4
4
  # Decisions and sources: reports/keputusan-riset/09-pajak-coretax.md in the project folder.
5
5
  name: coretax
6
- version: 1.0.0
6
+ version: 1.0.1
7
7
  title: {id: Lapor pajak Coretax, en: Coretax tax filing}
8
8
  summary:
9
9
  id: Siapkan masa pajak dan berkas unduhan untuk lapor di Coretax.
@@ -14,13 +14,18 @@ related:
14
14
  sort: name
15
15
  limit: 1000
16
16
  require:
17
- - check: origin_bill_date != '' && origin_bill_date >= doc.period_start
17
+ # A bill submitted before this module was installed (or amended from one whose own origin is unknown) froze
18
+ # without its Coretax fields (origin_bill_date, recipient_*): only this message is shown for it, since filling
19
+ # in the vendor's tax data cannot change a submitted bill (audit pajak 7 Nov #8, D2).
20
+ - check: origin_bill_date != ''
21
+ message: {id: 'Tagihan ini (atau tagihan yang digantinya) diajukan sebelum ekspor Coretax dipasang: buat bukti potongnya langsung di Coretax'}
22
+ - check: origin_bill_date == '' || origin_bill_date >= doc.period_start
18
23
  message: {id: 'Tagihan ini mengganti tagihan masa sebelumnya yang bukti potongnya sudah dilaporkan: buat pembetulan bukti potong di Coretax'}
19
- - check: "size(recipient_tin) == 16 && recipient_tin.matches('^[0-9]+$')"
24
+ - check: "origin_bill_date == '' || (size(recipient_tin) == 16 && recipient_tin.matches('^[0-9]+$'))"
20
25
  message: {id: 'Pemasok belum punya NPWP atau NIK 16 angka: lengkapi Data pajak pemasok'}
21
- - check: "size(recipient_idtku) == 22 && recipient_idtku.startsWith(recipient_tin)"
26
+ - check: "origin_bill_date == '' || (size(recipient_idtku) == 22 && recipient_idtku.startsWith(recipient_tin))"
22
27
  message: {id: 'NITKU pemasok harus 22 angka dan diawali NPWP/NIK-nya'}
23
- - check: "pph23_object_code.matches('^24-10[0-6]-[0-9]{2}$')"
28
+ - check: "origin_bill_date == '' || pph23_object_code.matches('^24-10[0-6]-[0-9]{2}$')"
24
29
  message: {id: 'Kode objek PPh 23 belum diisi di tagihan (misalnya 24-104-17 jasa tenaga kerja)'}
25
- - check: "pph23_rate > 0 && pph23_amount == round(pph23_base * pph23_rate / 100)"
30
+ - check: "origin_bill_date == '' || (pph23_rate > 0 && pph23_amount == round(pph23_base * pph23_rate / 100))"
26
31
  message: {id: 'PPh 23 di tagihan tidak sama dengan DPP PPh 23 x tarif'}
@@ -15,20 +15,25 @@ related:
15
15
  sort: name
16
16
  children: true
17
17
  limit: 1000
18
+ # An invoice submitted before this module froze without its Coretax fields (efaktur_code, buyer_*): the
19
+ # efaktur_code check below names it once, the other checks skip it (audit pajak 7 Nov #8).
18
20
  require:
19
- - check: buyer_id_type != ''
21
+ - check: efaktur_code == '' || buyer_id_type != ''
20
22
  message: {id: 'Pelanggan belum punya NPWP, NIK, atau nomor paspor: lengkapi Data pajak pelanggan. Penjualan eceran tanpa identitas dilaporkan sebagai digunggung, bukan lewat file ini'}
21
- - check: "buyer_id_type != 'TIN' || (size(buyer_tin) == 16 && size(buyer_idtku) == 22 && buyer_idtku.startsWith(buyer_tin))"
23
+ - check: "efaktur_code == '' || buyer_id_type != 'TIN' || (size(buyer_tin) == 16 && size(buyer_idtku) == 22 && buyer_idtku.startsWith(buyer_tin))"
22
24
  message: {id: 'NPWP (16 angka) atau NITKU (22 angka) pelanggan belum benar'}
23
- - check: "buyer_id_type != 'National ID' || (size(buyer_doc_no) == 16 && buyer_doc_no.matches('^[0-9]+$'))"
25
+ - check: "efaktur_code == '' || buyer_id_type != 'National ID' || (size(buyer_doc_no) == 16 && buyer_doc_no.matches('^[0-9]+$'))"
24
26
  message: {id: 'NIK pelanggan harus 16 angka'}
25
- - check: buyer_name != '' && buyer_address != ''
27
+ - check: efaktur_code == '' || (buyer_name != '' && buyer_address != '')
26
28
  message: {id: 'Nama dan alamat pelanggan wajib diisi untuk faktur pajak'}
27
29
  - check: "efaktur_code != '' && items.map(i, i.coretax_unit == '' ? 1 : 0).sum() == 0"
28
30
  message: {id: 'Faktur ini diajukan sebelum ekspor Coretax dipasang: buat faktur pajaknya langsung di Coretax'}
29
- - check: origin_posting_date != '' && origin_posting_date >= doc.period_start
31
+ # an amend chain whose middle invoice froze before this module (its origin unknown): audit pajak 7 Nov D2
32
+ - check: efaktur_code == '' || origin_posting_date != ''
33
+ message: {id: 'Faktur ini mengganti faktur yang diajukan sebelum ekspor Coretax dipasang: buat faktur pajaknya langsung di Coretax'}
34
+ - check: origin_posting_date == '' || origin_posting_date >= doc.period_start
30
35
  message: {id: 'Faktur ini mengganti faktur masa sebelumnya: buat Faktur Pengganti di Coretax, jangan diimpor'}
31
- - check: "items.map(i, i.qty * 100 - round(i.qty * 100) > 0.000001 || round(i.qty * 100) - i.qty * 100 > 0.000001 ? 1 : 0).sum() == 0"
36
+ - check: "efaktur_code == '' || items.map(i, i.qty * 100 - round(i.qty * 100) > 0.000001 || round(i.qty * 100) - i.qty * 100 > 0.000001 ? 1 : 0).sum() == 0"
32
37
  message: {id: 'Jumlah barang di faktur pajak maksimal 2 desimal: pakai satuan yang lebih kecil (misalnya gram)'}
33
- - check: buyer_id_type != 'Passport' || buyer_country != 'IDN'
38
+ - check: efaktur_code == '' || buyer_id_type != 'Passport' || buyer_country != 'IDN'
34
39
  message: {id: 'Pembeli dengan paspor harus punya kode negara selain IDN di Data pajak pelanggan'}
@@ -35,6 +35,10 @@
35
35
  {{- $q := round $l.qty 2}}
36
36
  {{- $tb := round (sub $b (div (mul $r $b) $s)) 2}}{{if eq (add $i 1) (add $n)}}{{$tb = sub $inv.dpp $acc}}{{end}}{{$acc = add $acc $tb}}
37
37
  {{- $otb := round (div (mul $tb $inv.dpp_num) $inv.dpp_den) 2}}
38
+ {{- /* Line amounts are whole rupiah while Price x Qty has 2 decimals, so Price x Qty can fall a few sen under TaxBase:
39
+ then Price is raised to TaxBase / Qty (rounded up to the sen) and TotalDiscount stays 0 or a few sen, never negative
40
+ (audit pajak 7 Nov D1). */}}
41
+ {{- if eq (slice (dec (sub (round (mul $p $q) 2) $tb) 2) 0 1) "-"}}{{$p = round (div $tb $q) 2}}{{if eq (slice (dec (sub (round (mul $p $q) 2) $tb) 2) 0 1) "-"}}{{$p = add $p "0.01"}}{{end}}{{end}}
38
42
  <GoodService>
39
43
  <Opt>{{$l.coretax_opt}}</Opt>
40
44
  <Code>{{$l.coretax_code}}</Code>
@@ -286,12 +286,13 @@ fields:
286
286
  hidden: true
287
287
  compute: amended_from
288
288
  # The posting date of the first invoice of the amend chain (A -> B -> C keeps A's date), frozen at submit: an
289
- # invoice whose chain started in an earlier period is a Faktur Pengganti in Coretax, however many amends later.
289
+ # invoice whose chain started in an earlier period is a Faktur Pengganti in Coretax, however many amends later. Empty
290
+ # when the invoice it amends froze before the coretax module and was itself an amend (its origin is unknown).
290
291
  - name: origin_posting_date
291
292
  type: data
292
293
  label: {id: Tanggal faktur asal}
293
294
  hidden: true
294
- compute: "replaces == '' ? posting_date : (replaces.origin_posting_date != '' ? replaces.origin_posting_date : replaces.posting_date)"
295
+ compute: "replaces == '' ? posting_date : (replaces.origin_posting_date != '' ? replaces.origin_posting_date : (replaces.replaces == '' ? replaces.posting_date : ''))"
295
296
  # Whether rule credit_limit warned on this submit (the same expression, computed in the same step from the same
296
297
  # customer row). The rule runs before any flow lock (contract 0025 §5); flow sales_invoice_credit_recheck reads the customer
297
298
  # again after the ledger hook has locked and updated it, and refuses an invoice that is over the limit only because
@@ -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.6.0
3
+ version: 1.6.1
4
4
  title: {id: Faktur, en: Invoicing}
5
5
  summary:
6
6
  id: Buat faktur penjualan, pilih cara bayar termasuk QRIS, dan kirim pengingat tagihan.
@@ -1,8 +1,12 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
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.
3
+ # with the receipt's lines whose item category (pos_sale_item.category, kept on the line) is routed to that station
4
+ # (kitchen_route). An outlet without stations (a shop) and a receipt without kitchen lines make nothing. A failure here
5
+ # rolls the payment back, so a paid receipt never misses its tickets.
6
+ # A receipt paid again after a void (amend) is a revision: what the voided receipt's picked-up tickets of that station
7
+ # already sent out is not cooked again. The served quantity of an item is spread over the revision's lines of that item
8
+ # in their order (line idx), so two lines of one item never both count the same served portion. The rest goes to the kitchen as Baru, and the part already served is kept as a
9
+ # ticket that is Diambil from the start, so a later revision knows it too.
6
10
  name: kitchen_ticket_on_sale
7
11
  label: {id: 'Struk dibayar: kirim tiket ke stasiun dapur'}
8
12
  on: pos_sale.submitted
@@ -11,13 +15,15 @@ steps:
11
15
  - if: stations.size() > 0
12
16
  then:
13
17
  - {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
18
+ - if: event.amended_from != ''
19
+ then:
20
+ - {find_all: kitchen_ticket, where: "sale == event.amended_from && status == 'picked_up'", as: served}
21
+ else:
22
+ - {find_all: kitchen_station, where: "false", as: served}
17
23
  - for_each: stations
18
24
  as: st
19
25
  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"
26
+ - if: "event.items.filter(l, routes.filter(r, r.station == st.name && r.category == l.category).size() > 0 && l.qty - max(0, min(l.qty, served.filter(t, t.station == st.name).map(t, t.served.map(x, x.item == l.item ? x.qty : 0).sum()).sum() - event.items.filter(y, y.item == l.item && y.idx < l.idx).map(y, y.qty).sum())) > 0).size() > 0"
21
27
  create: kitchen_ticket
22
28
  set:
23
29
  sale: event.name
@@ -26,4 +32,16 @@ steps:
26
32
  date: event.date
27
33
  buyer: event.buyer
28
34
  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})"
35
+ items: "event.items.filter(l, routes.filter(r, r.station == st.name && r.category == l.category).size() > 0 && l.qty - max(0, min(l.qty, served.filter(t, t.station == st.name).map(t, t.served.map(x, x.item == l.item ? x.qty : 0).sum()).sum() - event.items.filter(y, y.item == l.item && y.idx < l.idx).map(y, y.qty).sum())) > 0).map(l, {'item': l.item, 'description': l.description, 'qty': l.qty - max(0, min(l.qty, served.filter(t, t.station == st.name).map(t, t.served.map(x, x.item == l.item ? x.qty : 0).sum()).sum() - event.items.filter(y, y.item == l.item && y.idx < l.idx).map(y, y.qty).sum())), 'uom': l.uom, 'note': l.note})"
36
+ - if: "event.items.filter(l, routes.filter(r, r.station == st.name && r.category == l.category).size() > 0 && max(0, min(l.qty, served.filter(t, t.station == st.name).map(t, t.served.map(x, x.item == l.item ? x.qty : 0).sum()).sum() - event.items.filter(y, y.item == l.item && y.idx < l.idx).map(y, y.qty).sum())) > 0).size() > 0"
37
+ create: kitchen_ticket
38
+ set:
39
+ sale: event.name
40
+ outlet: event.outlet
41
+ station: st.name
42
+ date: event.date
43
+ buyer: event.buyer
44
+ revision_of: event.amended_from
45
+ status: "'picked_up'"
46
+ picked_up_at: now()
47
+ items: "event.items.filter(l, routes.filter(r, r.station == st.name && r.category == l.category).size() > 0 && max(0, min(l.qty, served.filter(t, t.station == st.name).map(t, t.served.map(x, x.item == l.item ? x.qty : 0).sum()).sum() - event.items.filter(y, y.item == l.item && y.idx < l.idx).map(y, y.qty).sum())) > 0).map(l, {'item': l.item, 'description': l.description, 'qty': max(0, min(l.qty, served.filter(t, t.station == st.name).map(t, t.served.map(x, x.item == l.item ? x.qty : 0).sum()).sum() - event.items.filter(y, y.item == l.item && y.idx < l.idx).map(y, y.qty).sum())), 'uom': l.uom, 'note': l.note})"
@@ -2,7 +2,7 @@
2
2
  # A ticket's status moves one step at a time, forward or back (Baru -> Dimasak -> Siap -> Diambil; back is the work
3
3
  # screen's "Urungkan"), and each step is stamped with its time; a step back clears the stamp of the step undone. Batal
4
4
  # is set only by flow kitchen_ticket_on_void (writes by flows start no flow), so a person cannot void a ticket, and a
5
- # void ticket does not come back. Runs inside the write, as the writer; kitchen_guard refuses the write.
5
+ # void ticket does not come back, nor does a picked-up ticket of a voided receipt (sale_void). Runs inside the write, as the writer; kitchen_guard refuses the write.
6
6
  name: kitchen_ticket_on_update
7
7
  label: {id: 'Tiket dapur diubah: satu langkah, catat waktunya'}
8
8
  on: kitchen_ticket.updated
@@ -14,6 +14,10 @@ steps:
14
14
  - if: event.status == 'void'
15
15
  create: kitchen_guard
16
16
  set: {reason: "'void_by_receipt'", document: event.name}
17
+ # a picked-up ticket of a voided receipt stays picked up: its receipt no longer exists to cook for
18
+ - if: event.before.status == 'picked_up' && event.sale_void
19
+ create: kitchen_guard
20
+ set: {reason: "'sale_void'", document: event.name}
17
21
  # positions 0..3; a jump of more than one step is refused
18
22
  - if: "event.status != 'void' && event.before.status != 'void' && ({'new': 0, 'cooking': 1, 'ready': 2, 'picked_up': 3}[event.status] - {'new': 0, 'cooking': 1, 'ready': 2, 'picked_up': 3}[event.before.status]) * ({'new': 0, 'cooking': 1, 'ready': 2, 'picked_up': 3}[event.status] - {'new': 0, 'cooking': 1, 'ready': 2, 'picked_up': 3}[event.before.status]) > 1"
19
23
  create: kitchen_guard
@@ -1,6 +1,7 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
2
  # A voided receipt (pos_sale cancelled, same day, open shift) voids its tickets that are not picked up yet, as the
3
- # cashier who voided it; the kitchen screen drops them. A ticket already picked up stays as it was (the food went out).
3
+ # cashier who voided it; the kitchen screen drops them. A ticket already picked up stays Diambil (the food went out)
4
+ # and is marked sale_void, so it cannot be pulled back into the queue (flow kitchen_ticket_on_update).
4
5
  name: kitchen_ticket_on_void
5
6
  label: {id: 'Struk dibatalkan: tiket dapurnya batal'}
6
7
  on: pos_sale.cancelled
@@ -13,3 +14,10 @@ steps:
13
14
  set:
14
15
  status: "'void'"
15
16
  void_at: now()
17
+ - {find_all: kitchen_ticket, where: "sale == event.name && status == 'picked_up' && !sale_void", as: served}
18
+ - for_each: served
19
+ as: t
20
+ do:
21
+ - update: t
22
+ set:
23
+ sale_void: "true"
@@ -19,6 +19,7 @@ fields:
19
19
  - {value: ticket_void, label: {id: Tiket sudah batal}}
20
20
  - {value: void_by_receipt, label: {id: Batal hanya dari struk}}
21
21
  - {value: one_step, label: {id: Satu langkah}}
22
+ - {value: sale_void, label: {id: Struk sudah batal}}
22
23
  - {name: document, type: data, label: {id: Dokumen}}
23
24
  rules:
24
25
  - name: ticket_void
@@ -33,3 +34,7 @@ rules:
33
34
  on: save
34
35
  check: reason != 'one_step'
35
36
  message: {id: 'Status tiket maju atau mundur satu langkah saja (Baru, Dimasak, Siap, Diambil)'}
37
+ - name: sale_void
38
+ on: save
39
+ check: reason != 'sale_void'
40
+ message: {id: 'Struk tiket ini sudah dibatalkan; tiket yang sudah diambil tidak bisa dikembalikan ke antrean'}
@@ -36,6 +36,11 @@ fields:
36
36
  in_list: true
37
37
  - {name: items, type: table, of: kitchen_ticket_item, label: {id: Menu}, read_only: true, min_rows: 1}
38
38
  - {name: item_count, type: float, label: {id: Jumlah porsi}, compute: "items.map(l, l.qty).sum()"}
39
+ # the lines as a list a flow can read (a flow's find does not load table rows): a revision of the receipt does not
40
+ # cook again what a picked-up ticket already sent out (flow kitchen_ticket_on_sale)
41
+ - {name: served, type: json, label: {id: Menu (data)}, hidden: true, compute: "items.map(l, {'item': l.item, 'qty': l.qty})"}
42
+ # set by flow kitchen_ticket_on_void on a ticket already picked up when its receipt is voided: it stays Diambil
43
+ - {name: sale_void, type: check, label: {id: Struk dibatalkan}, read_only: true}
39
44
  - name: status
40
45
  type: select
41
46
  label: {id: Status}
@@ -9,6 +9,14 @@
9
9
  # (legacy_key_overlap) and rule legacy_key_reviewed holds its submit until head office has removed what is counted
10
10
  # twice; an export imported after the API day is flagged by flow moka_legacy_key_overlap.
11
11
  # An unmapped line waits in Baris penjualan Moka and does not hold anything back; once mapped it joins the next recap.
12
+ # One run is one unit of work: a refused create would roll back every outlet-day of the run, and the next run would
13
+ # pick the same oldest day again. So before creating, the lines whose item was deleted, whose outlet was deleted or
14
+ # whose outlet no longer uses Moka (Nama outlet di Moka emptied) go back to unmapped with that item or outlet emptied,
15
+ # head office is told, and the other lines of the day are recapped. (The kernel lets a linked record be deleted; a
16
+ # rangka-os card asks it to refuse.)
17
+ # Cost: the kernel reads a whole model for every find, so each slot reads moka_sale_line once (the oldest staged lines,
18
+ # the outlet-day taken from the first) and a slot runs only while the slot before found lines: a run with nothing to
19
+ # recap reads the table once, a run with N outlet-days N + 1 times.
12
20
  name: moka_daily_sales
13
21
  label: {id: Rekap harian penjualan Moka per outlet}
14
22
  schedule: '15 * * * *'
@@ -16,42 +24,55 @@ steps:
16
24
  - for_each: "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]"
17
25
  as: slot
18
26
  do:
27
+ # the oldest staged lines; the outlet-day of this slot is the first one's (lines are sorted by date, then the
28
+ # slot keeps those of the same outlet and day)
19
29
  - find_all: moka_sale_line
30
+ if: slot == 1 || size(batch) > 0
20
31
  where: "status == 'staged' && outlet != '' && date < today()"
21
32
  sort: date
22
- limit: 1
23
- as: first
24
- - find_all: moka_sale_line
25
- if: size(first) > 0
26
- where: "outlet == first[0].outlet && date == first[0].date && status == 'staged'"
27
- sort: name
28
33
  limit: 1000
29
- as: rows
34
+ as: batch
30
35
  - find: outlet
31
- if: size(first) > 0
32
- where: name == first[0].outlet
36
+ if: size(batch) > 0
37
+ where: name == batch[0].outlet
33
38
  as: o
39
+ - find_all: item
40
+ if: size(batch) > 0
41
+ where: "name in batch.filter(r, r.outlet == batch[0].outlet && r.date == batch[0].date).map(r, r.item)"
42
+ as: alive
34
43
  - find: outlet_sales
35
- if: size(first) > 0
36
- where: "outlet == first[0].outlet && date == first[0].date && source == 'moka' && docstatus != 2 && key_version != 3"
44
+ if: size(batch) > 0
45
+ where: "outlet == batch[0].outlet && date == batch[0].date && source == 'moka' && docstatus != 2 && key_version != 3"
37
46
  as: filed
38
47
  - create: outlet_sales
39
- if: size(first) > 0
48
+ if: "size(batch) > 0 && o != null && o.moka_name != '' && size(batch.filter(r, r.outlet == batch[0].outlet && r.date == batch[0].date && r.item in alive.map(i, i.name))) > 0"
40
49
  set:
41
- outlet: first[0].outlet
42
- date: first[0].date
50
+ outlet: batch[0].outlet
51
+ date: batch[0].date
43
52
  source: "'moka'"
44
- moka_outlet: "o != null ? o.moka_name : ''"
53
+ moka_outlet: o.moka_name
45
54
  key_version: "3"
46
55
  note: "'Dari Moka API'"
47
56
  legacy_key_overlap: filed != null
48
- lines: "rows.map(r, {'item': r.item, 'description': r.description, 'qty': r.qty, 'gross': r.gross, 'discount': r.discount, 'refund': r.refund})"
57
+ lines: "batch.filter(r, r.outlet == batch[0].outlet && r.date == batch[0].date && r.item in alive.map(i, i.name)).map(r, {'item': r.item, 'description': r.description, 'qty': r.qty, 'gross': r.gross, 'discount': r.discount, 'refund': r.refund})"
49
58
  as: sales
50
- - for_each: rows
51
- if: size(first) > 0
59
+ - for_each: "size(batch) > 0 && o != null && o.moka_name != '' ? batch.filter(r, r.outlet == batch[0].outlet && r.date == batch[0].date && r.item in alive.map(i, i.name)) : []"
52
60
  as: r
53
61
  do:
54
62
  - update: r
55
63
  set:
56
64
  status: "'posted'"
57
65
  sales: sales.name
66
+ # lines that cannot go into a record: back to unmapped, the missing item or outlet emptied, head office told
67
+ - for_each: "size(batch) > 0 ? batch.filter(r, r.outlet == batch[0].outlet && r.date == batch[0].date && (o == null || o.moka_name == '' || !(r.item in alive.map(i, i.name)))) : []"
68
+ as: r
69
+ do:
70
+ - update: r
71
+ set:
72
+ status: "'unmapped'"
73
+ outlet: "o != null && o.moka_name != '' ? r.outlet : ''"
74
+ item: "r.item in alive.map(i, i.name) ? r.item : ''"
75
+ - notify: head_office
76
+ if: "size(batch) > 0 && size(batch.filter(r, r.outlet == batch[0].outlet && r.date == batch[0].date && (o == null || o.moka_name == '' || !(r.item in alive.map(i, i.name))))) > 0"
77
+ channel: email
78
+ template: {id: 'Rekap Moka {batch[0].outlet} {batch[0].date}: barang/outlet terhapus atau outlet tanpa Moka, baris kembali Belum dipetakan'}