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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/grosir_distribusi/app.rk +48 -0
  3. package/template/base/apps/grosir_distribusi/dashboards/grosir_ar.rk +62 -0
  4. package/template/base/apps/grosir_distribusi/dashboards/grosir_overview.rk +85 -0
  5. package/template/base/apps/produksi_pabrik/app.rk +46 -0
  6. package/template/base/apps/produksi_pabrik/dashboards/produksi_overview.rk +96 -0
  7. package/template/base/apps/produksi_pabrik/dashboards/produksi_upah.rk +39 -0
  8. package/template/base/modules/catalogue/models/item.rk +22 -0
  9. package/template/base/modules/catalogue/models/item_category.rk +1 -0
  10. package/template/base/modules/catalogue/models/uom.rk +1 -0
  11. package/template/base/modules/catalogue/module.rk +2 -1
  12. package/template/base/modules/contacts/models/customer.rk +58 -1
  13. package/template/base/modules/contacts/module.rk +1 -1
  14. package/template/base/modules/delivery/flows/delivery_cancel_guard.rk +18 -0
  15. package/template/base/modules/delivery/flows/fulfilment_on_delivery_cancelled.rk +21 -0
  16. package/template/base/modules/delivery/flows/fulfilment_on_delivery_submitted.rk +21 -0
  17. package/template/base/modules/delivery/flows/fulfilment_on_invoice_cancelled.rk +22 -0
  18. package/template/base/modules/delivery/flows/fulfilment_on_invoice_submitted.rk +22 -0
  19. package/template/base/modules/delivery/flows/fulfilment_on_order_created.rk +18 -0
  20. package/template/base/modules/delivery/flows/fulfilment_on_order_submitted.rk +16 -0
  21. package/template/base/modules/delivery/flows/fulfilment_on_order_updated.rk +19 -0
  22. package/template/base/modules/delivery/flows/fulfilment_on_return_cancelled.rk +16 -0
  23. package/template/base/modules/delivery/flows/fulfilment_on_return_submitted.rk +16 -0
  24. package/template/base/modules/delivery/flows/invoice_qty_from_deliveries.rk +20 -0
  25. package/template/base/modules/delivery/flows/order_cancel_guard.rk +10 -0
  26. package/template/base/modules/delivery/flows/return_cancel_guard.rk +11 -0
  27. package/template/base/modules/delivery/flows/return_credit_on_payment_cancelled.rk +11 -0
  28. package/template/base/modules/delivery/flows/return_credit_on_payment_submitted.rk +21 -0
  29. package/template/base/modules/delivery/flows/return_credit_on_return_cancelled.rk +11 -0
  30. package/template/base/modules/delivery/flows/return_credit_on_return_submitted.rk +10 -0
  31. package/template/base/modules/delivery/models/delivery_guard.rk +48 -0
  32. package/template/base/modules/delivery/models/delivery_note.rk +94 -0
  33. package/template/base/modules/delivery/models/delivery_note_item.rk +9 -0
  34. package/template/base/modules/delivery/models/order_fulfilment.rk +27 -0
  35. package/template/base/modules/delivery/models/order_fulfilment_item.rk +10 -0
  36. package/template/base/modules/delivery/models/return_credit.rk +23 -0
  37. package/template/base/modules/delivery/models/sales_return.rk +87 -0
  38. package/template/base/modules/delivery/models/sales_return_item.rk +16 -0
  39. package/template/base/modules/delivery/module.rk +11 -0
  40. package/template/base/modules/distribution/flows/credit_on_invoice_cancelled.rk +17 -0
  41. package/template/base/modules/distribution/flows/credit_on_invoice_submitted.rk +17 -0
  42. package/template/base/modules/distribution/flows/credit_on_order_cancelled.rk +17 -0
  43. package/template/base/modules/distribution/flows/credit_on_order_submitted.rk +17 -0
  44. package/template/base/modules/distribution/flows/credit_on_payment_cancelled.rk +17 -0
  45. package/template/base/modules/distribution/flows/credit_on_payment_submitted.rk +17 -0
  46. package/template/base/modules/distribution/flows/giro_bounced.rk +20 -0
  47. package/template/base/modules/distribution/flows/giro_from_payment.rk +21 -0
  48. package/template/base/modules/distribution/flows/order_tier_pricing_created.rk +17 -0
  49. package/template/base/modules/distribution/flows/order_tier_pricing_updated.rk +17 -0
  50. package/template/base/modules/distribution/models/giro.rk +79 -0
  51. package/template/base/modules/distribution/module.rk +9 -0
  52. package/template/base/modules/invoicing/models/sales_invoice.rk +16 -1
  53. package/template/base/modules/invoicing/module.rk +2 -2
  54. package/template/base/modules/orders/models/customer_order.rk +80 -2
  55. package/template/base/modules/orders/models/customer_order_item.rk +19 -0
  56. package/template/base/modules/orders/module.rk +2 -2
  57. package/template/base/modules/outlets/models/outlet.rk +1 -0
  58. package/template/base/modules/outlets/module.rk +1 -1
  59. package/template/base/modules/payments/models/payment.rk +34 -1
  60. package/template/base/modules/payments/module.rk +2 -2
  61. package/template/base/modules/production/flows/batch_cancel_guard.rk +12 -0
  62. package/template/base/modules/production/flows/batch_from_bom.rk +19 -0
  63. package/template/base/modules/production/flows/wage_sheet_on_batch_cancelled.rk +14 -0
  64. package/template/base/modules/production/flows/wage_sheet_on_batch_submitted.rk +12 -0
  65. package/template/base/modules/production/flows/work_order_materials_created.rk +20 -0
  66. package/template/base/modules/production/flows/work_order_materials_updated.rk +20 -0
  67. package/template/base/modules/production/models/bom.rk +67 -0
  68. package/template/base/modules/production/models/bom_byproduct.rk +7 -0
  69. package/template/base/modules/production/models/bom_line.rk +11 -0
  70. package/template/base/modules/production/models/production_batch.rk +149 -0
  71. package/template/base/modules/production/models/production_guard.rk +23 -0
  72. package/template/base/modules/production/models/production_labour.rk +10 -0
  73. package/template/base/modules/production/models/production_material.rk +8 -0
  74. package/template/base/modules/production/models/production_output.rk +8 -0
  75. package/template/base/modules/production/models/production_stage.rk +19 -0
  76. package/template/base/modules/production/models/wage_line.rk +11 -0
  77. package/template/base/modules/production/models/wage_sheet.rk +28 -0
  78. package/template/base/modules/production/models/work_order.rk +63 -0
  79. package/template/base/modules/production/models/work_order_material.rk +8 -0
  80. package/template/base/modules/production/module.rk +12 -0
  81. package/template/base/modules/stock/models/stock_move.rk +4 -0
  82. package/template/base/modules/stock/module.rk +1 -1
  83. package/template/base/modules/users/models/user.rk +1 -0
  84. package/template/base/modules/users/module.rk +1 -1
  85. package/template/base/modules/users/roles/field_sales.rk +7 -0
@@ -0,0 +1,20 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # The bank returned a giro: finance cancels its payment, the kernel opens the invoices again (payments.unallocate),
3
+ # and this flow marks the register line bounced and puts the customer on credit hold until finance releases it.
4
+ name: giro_bounced
5
+ label: {id: Giro ditolak}
6
+ on: payment.cancelled
7
+ if: "event.direction == 'receive' && event.method == 'giro'"
8
+ steps:
9
+ - {find: giro, where: payment == event.name, as: g}
10
+ - {find: customer, where: name == event.customer, as: cust}
11
+ - update: g
12
+ if: g != null && g.status != 'cleared'
13
+ set:
14
+ status: "'bounced'"
15
+ bounced_on: today()
16
+ - update: cust
17
+ if: g != null && g.status == 'bounced'
18
+ set:
19
+ credit_hold: "true"
20
+ credit_hold_reason: "'Giro ' + event.reference + ' ditolak ' + today()"
@@ -0,0 +1,21 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # A customer payment by giro goes into the giro register when it is submitted (once per payment: an amended payment
3
+ # is a new payment with its own line).
4
+ name: giro_from_payment
5
+ label: {id: Giro masuk ke register}
6
+ on: payment.submitted
7
+ if: "event.direction == 'receive' && event.method == 'giro'"
8
+ steps:
9
+ - {find: giro, where: payment == event.name, as: known}
10
+ - create: giro
11
+ if: known == null
12
+ set:
13
+ giro_no: event.reference
14
+ bank: event.giro_bank
15
+ customer: event.customer
16
+ salesman: event.salesman
17
+ payment: event.name
18
+ received_on: event.payment_date
19
+ effective_date: event.giro_due_date
20
+ amount: event.amount
21
+ status: "'received'"
@@ -0,0 +1,17 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Prices the lines of a draft order at the customer's tier. A line cannot read its order, so this flow copies the
3
+ # order's price_tier onto the lines (list_rate is then computed per line), and in a second step sets rate to the
4
+ # list price once per tier (tier_applied): a price typed by hand afterwards stays, a new line or another customer is
5
+ # priced again. Company fields (x_) on order lines are not carried (the rows are written whole).
6
+ name: order_tier_pricing_created
7
+ label: {id: Harga pesanan sesuai tier pelanggan}
8
+ on: customer_order.created
9
+ if: "event.docstatus == 0 && event.items.map(i, i.price_tier != event.price_tier || i.tier_applied != event.price_tier ? 1 : 0).sum() > 0"
10
+ steps:
11
+ - {find: customer_order, where: name == event.name, as: so}
12
+ - update: so
13
+ set:
14
+ items: "event.items.map(i, {'name': i.name, 'item': i.item, 'description': i.description, 'qty': i.qty, 'uom': i.uom, 'rate': i.rate, 'tier_applied': i.tier_applied, 'price_tier': event.price_tier})"
15
+ - update: so
16
+ set:
17
+ items: "so.items.map(i, {'name': i.name, 'item': i.item, 'description': i.description, 'qty': i.qty, 'uom': i.uom, 'rate': i.tier_applied == i.price_tier ? i.rate : i.list_rate, 'tier_applied': i.price_tier, 'price_tier': i.price_tier})"
@@ -0,0 +1,17 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Prices the lines of a draft order at the customer's tier. A line cannot read its order, so this flow copies the
3
+ # order's price_tier onto the lines (list_rate is then computed per line), and in a second step sets rate to the
4
+ # list price once per tier (tier_applied): a price typed by hand afterwards stays, a new line or another customer is
5
+ # priced again. Company fields (x_) on order lines are not carried (the rows are written whole).
6
+ name: order_tier_pricing_updated
7
+ label: {id: Harga pesanan sesuai tier pelanggan}
8
+ on: customer_order.updated
9
+ if: "event.docstatus == 0 && event.items.map(i, i.price_tier != event.price_tier || i.tier_applied != event.price_tier ? 1 : 0).sum() > 0"
10
+ steps:
11
+ - {find: customer_order, where: name == event.name, as: so}
12
+ - update: so
13
+ set:
14
+ items: "event.items.map(i, {'name': i.name, 'item': i.item, 'description': i.description, 'qty': i.qty, 'uom': i.uom, 'rate': i.rate, 'tier_applied': i.tier_applied, 'price_tier': event.price_tier})"
15
+ - update: so
16
+ set:
17
+ items: "so.items.map(i, {'name': i.name, 'item': i.item, 'description': i.description, 'qty': i.qty, 'uom': i.uom, 'rate': i.tier_applied == i.price_tier ? i.rate : i.list_rate, 'tier_applied': i.price_tier, 'price_tier': i.price_tier})"
@@ -0,0 +1,79 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # Giro register (bilyet giro received). A line is made by the flow giro_from_payment when a payment by giro is
3
+ # submitted; finance follows it to the bank (deposited, cleared). When the bank returns it, finance cancels the
4
+ # payment: the kernel opens the invoices again (payments.unallocate) and the flow giro_bounced marks the line bounced
5
+ # and puts the customer on credit hold. Lines are made by the flow (every field is read_only; a line must match its
6
+ # giro payment), once per payment.
7
+ name: giro
8
+ label: {id: Giro masuk, en: Giro received}
9
+ icon: card
10
+ naming: GIRO-{YYYY}-{#####}
11
+ title_field: giro_no
12
+ permissions:
13
+ - {role: finance_manager, read: true, create: true, write: true, export: true, print: true}
14
+ - {role: sales_manager, read: true, create: true, write: true, export: true, print: true}
15
+ - {role: field_sales, read: true}
16
+ fields:
17
+ - {name: giro_no, type: data, label: {id: No. giro}, required: true, read_only: true, in_list: true}
18
+ - {name: bank, type: data, label: {id: Bank penerbit}, read_only: true, in_list: true}
19
+ - {name: customer, type: link, to: customer, label: {id: Pelanggan}, required: true, read_only: true, in_list: true}
20
+ - {name: salesman, type: link, to: user, label: {id: Salesman}, read_only: true, in_list: true}
21
+ - {name: payment, type: link, to: payment, label: {id: Pembayaran}, required: true, read_only: true, peek: [amount, status]}
22
+ - {name: received_on, type: date, label: {id: Diterima}, read_only: true}
23
+ - {name: effective_date, type: date, label: {id: Tanggal efektif}, required: true, read_only: true, in_list: true}
24
+ - {name: amount, type: currency, label: {id: Nilai giro}, read_only: true, in_list: true}
25
+ - name: status
26
+ type: select
27
+ label: {id: Status}
28
+ default: "'received'"
29
+ required: true
30
+ in_list: true
31
+ chip: true
32
+ options:
33
+ - {value: received, label: {id: Diterima}, tone: neutral}
34
+ - {value: deposited, label: {id: Disetor ke bank}, tone: info}
35
+ - {value: cleared, label: {id: Cair}, tone: ok}
36
+ - {value: bounced, label: {id: Ditolak}, tone: bad}
37
+ - {name: deposited_on, type: date, label: {id: Tanggal setor}, depends_on: "status != 'received'"}
38
+ - {name: cleared_on, type: date, label: {id: Tanggal cair}, depends_on: "status == 'cleared'"}
39
+ - {name: bounced_on, type: date, label: {id: Tanggal ditolak}, read_only: true, depends_on: "status == 'bounced'"}
40
+ - {name: bounce_reason, type: data, label: {id: Alasan tolak}, depends_on: "status == 'bounced'"}
41
+ - {name: notes, type: text, label: {id: Catatan}}
42
+ rules:
43
+ - name: matches_payment
44
+ on: save
45
+ check: "payment.method == 'giro' && payment.customer == customer && payment.reference == giro_no"
46
+ message: {id: Baris giro harus sama dengan pembayaran gironya}
47
+ - name: bounced_only_by_cancel
48
+ on: save
49
+ check: "status != 'bounced' || payment.docstatus == 2"
50
+ message: {id: Giro ditolak dicatat dengan membatalkan pembayarannya (faktur terbuka lagi)}
51
+ - name: live_payment_not_bounced
52
+ on: save
53
+ check: "status == 'bounced' || payment.docstatus != 2"
54
+ message: {id: Pembayaran giro ini sudah dibatalkan; statusnya Ditolak}
55
+ - name: deposit_not_before_effective
56
+ on: save
57
+ check: "deposited_on == '' || deposited_on >= effective_date"
58
+ message: {id: Giro baru bisa disetor pada atau setelah tanggal efektifnya}
59
+ - name: cleared_needs_deposit
60
+ on: save
61
+ check: "status != 'cleared' || (deposited_on != '' && cleared_on != '' && cleared_on >= deposited_on)"
62
+ message: {id: Isi tanggal setor dan tanggal cair (tidak sebelum tanggal setor)}
63
+ views:
64
+ list:
65
+ columns: [name, giro_no, customer, salesman, effective_date, amount, status]
66
+ filters: [status, salesman, customer]
67
+ sort: effective_date
68
+ form:
69
+ layout:
70
+ - section: {id: Giro}
71
+ columns:
72
+ - [giro_no, bank, amount, effective_date]
73
+ - [customer, salesman, payment, received_on]
74
+ - section: {id: Ke bank}
75
+ columns:
76
+ - [status, deposited_on, cleared_on]
77
+ - [bounced_on, bounce_reason]
78
+ - section: {id: Catatan}
79
+ fields: [notes]
@@ -0,0 +1,9 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
+ # Sales controls of a distributor: salesmen and their customers (role field_sales), prices per tier, orders held when a
3
+ # customer is on hold, overdue or over its limit (approvals on customer_order), and the giro register. The fields
4
+ # this module switches on live in their own models (customer, item, customer_order, sales_invoice, payment) behind
5
+ # app_installed('distribution'); the flows here keep them current.
6
+ name: distribution
7
+ version: 1.0.0
8
+ title: {id: Distribusi, en: Distribution}
9
+ requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0, orders: ^1.0, invoicing: ^1.0, payments: ^1.0, procurement: ^1.0}
@@ -11,6 +11,7 @@ permissions:
11
11
  - {role: finance_manager, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
12
12
  - {role: sales_manager, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
13
13
  - {role: sales_rep, read: true}
14
+ - {role: field_sales, read: true, print: true}
14
15
  # project admins read invoices: the project flows that freeze contract terms read them as the project admin
15
16
  - {role: project_admin, read: true}
16
17
  fields:
@@ -36,6 +37,14 @@ fields:
36
37
  type: link
37
38
  to: customer_order
38
39
  label: {id: Pesanan pelanggan}
40
+ # The salesman whose customer this is (module distribution), for AR and collections per salesman.
41
+ - name: salesman
42
+ type: link
43
+ to: user
44
+ label: {id: Salesman}
45
+ default: "customer_order != '' && customer_order.salesman != '' ? customer_order.salesman : customer.salesman"
46
+ in_list: true
47
+ depends_on: app_installed('distribution')
39
48
  - name: project
40
49
  type: link
41
50
  to: project
@@ -209,6 +218,12 @@ fields:
209
218
  - {name: pph23_amount_fx, type: money, currency_field: currency, rate_field: exchange_rate, label: {id: PPh 23 dipotong (valas)}, compute: "pph23_applies && dpp != 0 ? round(dpp_fx * (pph23_dpp * 1.0 / dpp * pph23_rate / 100), 2) : 0"}
210
219
  - {name: amount_due_fx, type: money, currency_field: currency, rate_field: exchange_rate, label: {id: Tagihan bersih (valas)}, compute: "grand_total_fx - retention_amount_fx - pph23_amount_fx"}
211
220
  rules:
221
+ # A distributor bills what was delivered (module delivery): per item, no more than delivered, less returns and
222
+ # earlier invoices of the order (order_fulfilment). The flow invoice_qty_from_deliveries sets the draft that way.
223
+ - name: invoice_within_delivered
224
+ on: submit
225
+ check: "!app_installed('delivery') || customer_order == '' || customer_order.fulfilment == '' || items.map(l, items.map(x, x.item == l.item ? x.qty : 0).sum() <= customer_order.fulfilment.items.map(b, b.item == l.item ? b.delivered_qty - b.invoiced_qty : 0).sum() + 0.0005 ? 0 : 1).sum() == 0"
226
+ message: {id: Jumlah ditagih melebihi barang yang sudah dikirim dan belum ditagih}
212
227
  - name: qty_positive
213
228
  on: save
214
229
  check: "items.map(i, i.qty <= 0 ? 1 : 0).sum() == 0"
@@ -360,7 +375,7 @@ views:
360
375
  layout:
361
376
  - section: {id: Pelanggan}
362
377
  columns:
363
- - [kind, customer, po_number, customer_order, project, billing_milestone]
378
+ - [kind, customer, po_number, customer_order, project, billing_milestone, salesman]
364
379
  - [posting_date, due_date, outlet, acceptance]
365
380
  - section: {id: Barang/jasa}
366
381
  fields: [items]
@@ -1,9 +1,9 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
2
  name: invoicing
3
- version: 1.2.0
3
+ version: 1.3.0
4
4
  title: {id: Faktur, en: Invoicing}
5
5
  requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0}
6
- optional: {outlets: ^1.0, tax_id: ^1.0, currency: ^1.0, orders: ^1.0, projects: ^1.0}
6
+ optional: {outlets: ^1.0, tax_id: ^1.0, currency: ^1.0, orders: ^1.0, projects: ^1.0, delivery: ^1.0}
7
7
  # ledger.post_receivable is a core hook; this one is semantics fixed in docs/kernel-hooks.md.
8
8
  # invoicing.from_order is declared by the orders module, where the make_invoice action lives.
9
9
  hooks: [invoicing.reverse_receivable]
@@ -9,6 +9,9 @@ permissions:
9
9
  - {role: sales_manager, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
10
10
  - {role: project_admin, read: true, create: true, write: true, submit: true}
11
11
  - {role: finance_manager, read: true, print: true}
12
+ # a salesman takes orders for his own customers (role scope salesman; rule customer_of_salesman)
13
+ - {role: field_sales, read: true, create: true, write: true, submit: true, print: true}
14
+ - {role: head_office, read: true, print: true}
12
15
  fields:
13
16
  - name: customer
14
17
  type: link
@@ -16,6 +19,35 @@ fields:
16
19
  label: {id: Pelanggan}
17
20
  required: true
18
21
  in_list: true
22
+ # Distributor sales (module distribution). salesman: the customer's, else the salesman taking the order. price_tier
23
+ # is the customer's; the lines are priced at it by the flow order_tier_pricing (a line cannot read the order).
24
+ - name: salesman
25
+ type: link
26
+ to: user
27
+ label: {id: Salesman}
28
+ default: "customer.salesman != '' ? customer.salesman : ('field_sales' in user.roles ? user.name : '')"
29
+ in_list: true
30
+ depends_on: app_installed('distribution')
31
+ - name: price_tier
32
+ type: select
33
+ label: {id: Tier harga}
34
+ compute: "customer.price_tier != '' ? customer.price_tier : 'retail'"
35
+ depends_on: app_installed('distribution')
36
+ options:
37
+ - {value: retail, label: {id: Eceran}}
38
+ - {value: wholesale, label: {id: Grosir}}
39
+ - {value: agent, label: {id: Agen}}
40
+ # What was delivered, returned and invoiced per item (module delivery); made with the order by a flow.
41
+ - name: fulfilment
42
+ type: link
43
+ to: order_fulfilment
44
+ label: {id: Pemenuhan pesanan}
45
+ read_only: true
46
+ depends_on: app_installed('delivery')
47
+ - name: delivery_date
48
+ type: date
49
+ label: {id: Tanggal kirim}
50
+ depends_on: app_installed('distribution')
19
51
  - name: quotation
20
52
  type: link
21
53
  to: quotation
@@ -52,6 +84,12 @@ fields:
52
84
  label: {id: Nilai pesanan (sebelum PPN)}
53
85
  compute: items.map(i, i.amount).sum()
54
86
  in_list: true
87
+ # What the order will cost the customer with PPN, for the credit limit check (customer.outstanding is with PPN).
88
+ - name: estimated_total
89
+ type: currency
90
+ label: {id: Perkiraan total (dengan PPN)}
91
+ compute: "tax.pkp ? round(subtotal * (100 * tax.dpp_den + tax.ppn_rate * tax.dpp_num) / (100 * tax.dpp_den)) : subtotal"
92
+ depends_on: app_installed('distribution')
55
93
  - name: invoiced_amount
56
94
  type: currency
57
95
  label: {id: Sudah ditagih}
@@ -59,7 +97,43 @@ fields:
59
97
  - name: notes
60
98
  type: text
61
99
  label: {id: Catatan}
100
+ # Credit control of a distributor (module distribution): an order is held for the sales manager when the customer
101
+ # is on hold, has an invoice past its due date, or would go over its credit limit (open invoices + orders not yet
102
+ # invoiced + this order). The customer is read when the order is submitted, so the due date check is always current.
103
+ approvals:
104
+ - name: credit_hold
105
+ on: submit
106
+ when: "app_installed('distribution') && customer.credit_hold"
107
+ approvers: [sales_manager, finance_manager]
108
+ label: {id: Pelanggan ditahan kreditnya, en: Customer on credit hold}
109
+ - name: overdue
110
+ on: submit
111
+ when: "app_installed('distribution') && customer.oldest_open_due != '' && customer.oldest_open_due < today()"
112
+ approvers: [sales_manager, finance_manager]
113
+ label: {id: Pelanggan punya tagihan lewat jatuh tempo, en: Customer has overdue invoices}
114
+ - name: below_tier_price
115
+ on: submit
116
+ when: "app_installed('distribution') && items.map(i, i.rate < i.list_rate ? 1 : 0).sum() > 0"
117
+ approvers: [sales_manager]
118
+ label: {id: Harga di bawah harga tier, en: Price below the tier price}
119
+ - name: over_credit_limit
120
+ on: submit
121
+ when: "app_installed('distribution') && customer.credit_limit > 0 && customer.outstanding + customer.open_orders + estimated_total > customer.credit_limit"
122
+ approvers: [sales_manager, finance_manager]
123
+ label: {id: Melewati batas kredit, en: Over the credit limit}
62
124
  rules:
125
+ - name: has_fulfilment
126
+ on: submit
127
+ check: "!app_installed('delivery') || fulfilment != ''"
128
+ message: {id: 'Simpan pesanan ini sekali lagi sebelum diajukan (catatan pemenuhan pesanan belum dibuat)'}
129
+ - name: one_line_per_item
130
+ on: save
131
+ check: "!app_installed('delivery') || items.map(i, items.map(x, x.item == i.item ? 1 : 0).sum() == 1 ? 0 : 1).sum() == 0"
132
+ message: {id: Satu barang cukup satu baris; jumlahkan qty-nya}
133
+ - name: customer_of_salesman
134
+ on: save
135
+ check: "!app_installed('distribution') || salesman == '' || customer.salesman == '' || customer.salesman == salesman"
136
+ message: {id: Pelanggan ini dipegang salesman lain}
63
137
  - name: quotation_same_customer
64
138
  on: save
65
139
  check: quotation == '' || quotation.customer == customer
@@ -83,7 +157,7 @@ actions:
83
157
  if: docstatus == 1 && app_installed('invoicing')
84
158
  views:
85
159
  list:
86
- columns: [name, customer, po_number, po_date, status, subtotal, invoiced_amount]
160
+ columns: [name, customer, salesman, po_number, po_date, status, subtotal, invoiced_amount]
87
161
  sort: -po_date
88
162
  form:
89
163
  layout:
@@ -91,10 +165,14 @@ views:
91
165
  columns:
92
166
  - [customer, quotation, po_number, po_date]
93
167
  - [work_order, site, start_date, end_date]
168
+ - section: {id: Salesman}
169
+ columns:
170
+ - [salesman, price_tier]
171
+ - [delivery_date, fulfilment]
94
172
  - section: {id: Barang/jasa}
95
173
  fields: [items]
96
174
  - section: {id: Ringkasan}
97
175
  columns:
98
- - [subtotal, invoiced_amount]
176
+ - [subtotal, estimated_total, invoiced_amount]
99
177
  - section: {id: Catatan}
100
178
  fields: [notes]
@@ -20,6 +20,25 @@ fields:
20
20
  to: uom
21
21
  label: {id: Satuan}
22
22
  default: "item.sales_uom != '' ? item.sales_uom : item.stock_uom"
23
+ # Tier pricing (module distribution): price_tier is set from the order by the flow order_tier_pricing, which then
24
+ # sets rate to list_rate once per tier (tier_applied), so a price typed by hand afterwards stays.
25
+ - name: price_tier
26
+ type: data
27
+ label: {id: Tier harga}
28
+ default: "'retail'"
29
+ read_only: true
30
+ depends_on: app_installed('distribution')
31
+ - name: tier_applied
32
+ type: data
33
+ label: {id: Tier yang sudah dipakai}
34
+ default: "'retail'"
35
+ read_only: true
36
+ depends_on: app_installed('distribution')
37
+ - name: list_rate
38
+ type: currency
39
+ label: {id: Harga daftar}
40
+ compute: "price_tier == 'agent' && item.rate_agent > 0 ? item.rate_agent : (price_tier == 'wholesale' && item.rate_wholesale > 0 ? item.rate_wholesale : item.rate)"
41
+ depends_on: app_installed('distribution')
23
42
  - name: rate
24
43
  type: currency
25
44
  label: {id: Harga}
@@ -1,9 +1,9 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
2
  name: orders
3
- version: 1.0.0
3
+ version: 1.1.0
4
4
  title: {id: Pesanan pelanggan, en: Customer orders}
5
5
  requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, catalogue: ^1.0}
6
- optional: {quotation: ^1.0}
6
+ optional: {quotation: ^1.0, delivery: ^1.0}
7
7
  # Semantics fixed in docs/kernel-hooks.md. The make_invoice action lives on customer_order, so the hook is declared
8
8
  # here; it is implemented with the invoicing hooks and needs the invoicing module installed.
9
9
  hooks: [invoicing.from_order]
@@ -12,6 +12,7 @@ permissions:
12
12
  - {role: head_office, read: true, create: true, write: true, print: true}
13
13
  - {role: outlet_staff, read: true}
14
14
  - {role: sales_rep, read: true}
15
+ - {role: field_sales, read: true}
15
16
  fields:
16
17
  - name: outlet_name
17
18
  type: data
@@ -1,5 +1,5 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
2
  name: outlets
3
- version: 1.0.0
3
+ version: 1.1.0
4
4
  title: {id: Outlet, en: Outlets}
5
5
  requires: {rangka: '>=0.5', users: ^1.0}
@@ -12,6 +12,8 @@ permissions:
12
12
  - {role: sales_manager, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
13
13
  # head office records vendor payments only
14
14
  - {role: head_office, read: true, create: true, write: true, submit: true, print: true, if: direction == 'pay'}
15
+ # a salesman reads the payments of his own customers (role scope salesman)
16
+ - {role: field_sales, read: true, print: true}
15
17
  fields:
16
18
  - name: direction
17
19
  type: select
@@ -48,6 +50,7 @@ fields:
48
50
  - {value: transfer, label: {id: Transfer}}
49
51
  - {value: cash, label: {id: Tunai}}
50
52
  - {value: giro, label: {id: Giro}}
53
+ - {value: sales_return, label: {id: Potong retur}}
51
54
  - {value: qris, label: {id: QRIS}}
52
55
  - {value: va, label: {id: Virtual account}}
53
56
  - {value: ewallet, label: {id: E-wallet}}
@@ -55,6 +58,28 @@ fields:
55
58
  - name: reference
56
59
  type: data
57
60
  label: {id: No. bukti/transfer}
61
+ # A giro (bilyet giro) is a payment when received; module distribution keeps it in the giro register until it clears,
62
+ # and cancelling the payment when the bank returns it opens the invoices again.
63
+ - name: giro_bank
64
+ type: data
65
+ label: {id: Bank penerbit giro}
66
+ depends_on: "app_installed('distribution') && method == 'giro'"
67
+ - name: giro_due_date
68
+ type: date
69
+ label: {id: Tanggal efektif giro}
70
+ depends_on: "app_installed('distribution') && method == 'giro'"
71
+ # A sales return (module delivery) credited to the customer's invoice: no money moves, the invoice is reduced.
72
+ - name: sales_return
73
+ type: link
74
+ to: sales_return
75
+ label: {id: Retur penjualan}
76
+ depends_on: "app_installed('delivery') && method == 'sales_return'"
77
+ - name: salesman
78
+ type: link
79
+ to: user
80
+ label: {id: Salesman}
81
+ default: customer.salesman
82
+ depends_on: "app_installed('distribution') && direction == 'receive'"
58
83
  # Payments that arrive through a payment gateway (Xendit VA, QRIS, payment link) carry the gateway's id, so a
59
84
  # callback delivered twice finds the payment it already made instead of paying the invoice again. One live
60
85
  # payment per id is kept by gateway_ref_claim, not by `unique` here: the kernel's unique index also holds the id
@@ -105,6 +130,14 @@ fields:
105
130
  - {name: exchange_rate, type: float, label: {id: Kurs}, default: '1'} # IDR per 1 unit of the foreign currency
106
131
  - {name: amount_fx, type: money, currency_field: currency, rate_field: exchange_rate, label: {id: Jumlah uang (valas)}, default: '0'}
107
132
  rules:
133
+ - name: giro_has_number_and_date
134
+ on: save
135
+ check: "!app_installed('distribution') || method != 'giro' || direction != 'receive' || (reference != '' && giro_bank != '' && giro_due_date != '')"
136
+ message: {id: 'Giro wajib diisi nomor giro (No. bukti), bank penerbit dan tanggal efektif'}
137
+ - name: return_credit_matches
138
+ on: save
139
+ check: "method != 'sales_return' || (app_installed('delivery') && direction == 'receive' && sales_return != '' && sales_return.docstatus == 1 && sales_return.customer == customer && amount <= sales_return.return_total)"
140
+ message: {id: 'Potong retur: pilih retur yang sudah diajukan dari pelanggan yang sama, nilainya paling banyak nilai retur'}
108
141
  - name: gateway_has_ref
109
142
  on: save
110
143
  check: gateway == '' || gateway_ref != ''
@@ -166,7 +199,7 @@ views:
166
199
  - section: {id: Pembayaran}
167
200
  columns:
168
201
  - [direction, customer, vendor, payment_date]
169
- - [method, reference, amount, gateway, gateway_ref, bank_transaction]
202
+ - [method, reference, giro_bank, giro_due_date, sales_return, amount, gateway, gateway_ref, bank_transaction, salesman]
170
203
  - section: {id: Alokasi}
171
204
  fields: [allocations]
172
205
  - section: {id: Ringkasan}
@@ -1,8 +1,8 @@
1
1
  # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
2
  name: payments
3
- version: 1.1.0
3
+ version: 1.2.0
4
4
  title: {id: Pembayaran, en: Payments}
5
5
  requires: {rangka: '>=0.5', users: ^1.0, contacts: ^1.0, invoicing: ^1.0, procurement: ^1.0}
6
- optional: {currency: ^1.0}
6
+ optional: {currency: ^1.0, delivery: ^1.0}
7
7
  # Semantics fixed in docs/kernel-hooks.md (section payments).
8
8
  hooks: [payments.allocate, payments.unallocate]
@@ -0,0 +1,12 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Inside a batch's cancel: refused when the finished-goods outlet no longer holds the batch's outputs (they were used
3
+ # by a later batch or sold), or the reversal would leave that stock below zero while its value sits elsewhere.
4
+ name: batch_cancel_guard
5
+ label: {id: Batch yang hasilnya sudah terpakai tidak bisa dibatalkan}
6
+ on: production_batch.cancelled
7
+ steps:
8
+ # the cancel has already reversed the moves: a balance of any output (product or by-product) below zero means it was used
9
+ - {find_all: stock_balance, where: "outlet == event.output_outlet && item in event.outputs.map(o, o.item) && qty < -0.0005", as: used}
10
+ - if: size(used) > 0
11
+ create: production_guard
12
+ set: {reason: "'output_used'", document: event.name}
@@ -0,0 +1,19 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # A new batch with no lines yet is drafted from its BOM, scaled to the planned qty: materials, the main product with
3
+ # the BOM's material share and the by-products with theirs. Outlet staff fill a batch by hand (they cannot read a BOM
4
+ # back through an update, see work_order_materials_created).
5
+ name: batch_from_bom
6
+ label: {id: Batch diisi dari resep}
7
+ on: production_batch.created
8
+ if: "event.bom != '' && event.planned_qty > 0 && size(event.materials) == 0 && size(event.outputs) == 0 && !('outlet_staff' in user.roles)"
9
+ steps:
10
+ - {find: bom, where: name == event.bom, as: b}
11
+ - {find: production_batch, where: name == event.name, as: pb}
12
+ - update: b
13
+ if: b != null
14
+ set: {bom_name: b.bom_name}
15
+ - update: pb
16
+ if: b != null && b.output_qty > 0
17
+ set:
18
+ materials: "b.lines.map(l, {'item': l.item, 'qty': round(l.qty * event.planned_qty / b.output_qty * 1000) / 1000, 'uom': l.uom})"
19
+ outputs: "[{'item': event.item, 'qty': event.planned_qty, 'cost_share': 100 - b.byproduct_share}] + b.byproducts.map(x, {'item': x.item, 'qty': round(x.qty * event.planned_qty / b.output_qty * 1000) / 1000, 'cost_share': x.cost_share})"
@@ -0,0 +1,14 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # A cancelled batch cancels its wage sheet, line by line (the weekly recap reads the lines).
3
+ name: wage_sheet_on_batch_cancelled
4
+ label: {id: Upah borongan batch dibatalkan}
5
+ on: production_batch.cancelled
6
+ steps:
7
+ - {find: wage_sheet, where: production_batch == event.name && !cancelled, as: ws}
8
+ - update: ws
9
+ if: ws != null
10
+ set: {cancelled: true}
11
+ - update: ws
12
+ if: ws != null
13
+ set:
14
+ lines: "ws.lines.map(l, {'name': l.name, 'worker': l.worker, 'stage': l.stage, 'qty': l.qty, 'rate': l.rate, 'amount': l.amount, 'work_date': l.work_date, 'cancelled': true})"
@@ -0,0 +1,12 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # The wages of a submitted batch become a wage sheet (one line per labour row), dated the production day.
3
+ name: wage_sheet_on_batch_submitted
4
+ label: {id: Upah borongan dari batch}
5
+ on: production_batch.submitted
6
+ if: size(event.labour) > 0
7
+ steps:
8
+ - create: wage_sheet
9
+ set:
10
+ production_batch: event.name
11
+ work_date: event.production_date
12
+ lines: "event.labour.map(l, {'worker': l.worker, 'stage': l.stage, 'qty': l.qty, 'rate': l.rate, 'amount': l.amount, 'work_date': event.production_date, 'cancelled': false})"
@@ -0,0 +1,20 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Fills the SPK's material need from its BOM, scaled to the planned qty, whenever the qty or the BOM differs from
3
+ # the ones it was filled for; lines edited by hand stay until then. A find returns a record without its table rows,
4
+ # so the BOM is read back through an update that changes nothing (head office may write BOMs).
5
+ name: work_order_materials_created
6
+ label: {id: Kebutuhan bahan SPK dari resep}
7
+ on: work_order.created
8
+ if: "event.docstatus == 0 && event.bom != '' && event.qty > 0 && (event.materials_qty != event.qty || event.materials_bom != event.bom) && !('outlet_staff' in user.roles)"
9
+ steps:
10
+ - {find: bom, where: name == event.bom, as: b}
11
+ - {find: work_order, where: name == event.name, as: wo}
12
+ - update: b
13
+ if: b != null
14
+ set: {bom_name: b.bom_name}
15
+ - update: wo
16
+ if: b != null && b.output_qty > 0
17
+ set:
18
+ materials: "b.lines.map(l, {'item': l.item, 'qty': round(l.qty * event.qty / b.output_qty * 1000) / 1000, 'uom': l.uom})"
19
+ materials_qty: event.qty
20
+ materials_bom: event.bom
@@ -0,0 +1,20 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Fills the SPK's material need from its BOM, scaled to the planned qty, whenever the qty or the BOM differs from
3
+ # the ones it was filled for; lines edited by hand stay until then. A find returns a record without its table rows,
4
+ # so the BOM is read back through an update that changes nothing (head office may write BOMs).
5
+ name: work_order_materials_updated
6
+ label: {id: Kebutuhan bahan SPK dari resep}
7
+ on: work_order.updated
8
+ if: "event.docstatus == 0 && event.bom != '' && event.qty > 0 && (event.materials_qty != event.qty || event.materials_bom != event.bom) && !('outlet_staff' in user.roles)"
9
+ steps:
10
+ - {find: bom, where: name == event.bom, as: b}
11
+ - {find: work_order, where: name == event.name, as: wo}
12
+ - update: b
13
+ if: b != null
14
+ set: {bom_name: b.bom_name}
15
+ - update: wo
16
+ if: b != null && b.output_qty > 0
17
+ set:
18
+ materials: "b.lines.map(l, {'item': l.item, 'qty': round(l.qty * event.qty / b.output_qty * 1000) / 1000, 'uom': l.uom})"
19
+ materials_qty: event.qty
20
+ materials_bom: event.bom