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

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 (94) 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/jasa_proyek/dashboards/jasa_overview.rk +4 -0
  6. package/template/base/apps/jasa_proyek/dashboards/project_margin.rk +28 -0
  7. package/template/base/apps/produksi_pabrik/app.rk +46 -0
  8. package/template/base/apps/produksi_pabrik/dashboards/produksi_overview.rk +96 -0
  9. package/template/base/apps/produksi_pabrik/dashboards/produksi_upah.rk +39 -0
  10. package/template/base/modules/catalogue/models/item.rk +22 -0
  11. package/template/base/modules/catalogue/models/item_category.rk +1 -0
  12. package/template/base/modules/catalogue/models/uom.rk +1 -0
  13. package/template/base/modules/catalogue/module.rk +2 -1
  14. package/template/base/modules/contacts/models/customer.rk +58 -1
  15. package/template/base/modules/contacts/module.rk +1 -1
  16. package/template/base/modules/delivery/flows/delivery_cancel_guard.rk +18 -0
  17. package/template/base/modules/delivery/flows/fulfilment_on_delivery_cancelled.rk +21 -0
  18. package/template/base/modules/delivery/flows/fulfilment_on_delivery_submitted.rk +21 -0
  19. package/template/base/modules/delivery/flows/fulfilment_on_invoice_cancelled.rk +22 -0
  20. package/template/base/modules/delivery/flows/fulfilment_on_invoice_submitted.rk +22 -0
  21. package/template/base/modules/delivery/flows/fulfilment_on_order_created.rk +18 -0
  22. package/template/base/modules/delivery/flows/fulfilment_on_order_submitted.rk +16 -0
  23. package/template/base/modules/delivery/flows/fulfilment_on_order_updated.rk +19 -0
  24. package/template/base/modules/delivery/flows/fulfilment_on_return_cancelled.rk +16 -0
  25. package/template/base/modules/delivery/flows/fulfilment_on_return_submitted.rk +16 -0
  26. package/template/base/modules/delivery/flows/invoice_qty_from_deliveries.rk +20 -0
  27. package/template/base/modules/delivery/flows/order_cancel_guard.rk +10 -0
  28. package/template/base/modules/delivery/flows/return_cancel_guard.rk +11 -0
  29. package/template/base/modules/delivery/flows/return_credit_on_payment_cancelled.rk +11 -0
  30. package/template/base/modules/delivery/flows/return_credit_on_payment_submitted.rk +21 -0
  31. package/template/base/modules/delivery/flows/return_credit_on_return_cancelled.rk +11 -0
  32. package/template/base/modules/delivery/flows/return_credit_on_return_submitted.rk +10 -0
  33. package/template/base/modules/delivery/models/delivery_guard.rk +48 -0
  34. package/template/base/modules/delivery/models/delivery_note.rk +94 -0
  35. package/template/base/modules/delivery/models/delivery_note_item.rk +9 -0
  36. package/template/base/modules/delivery/models/order_fulfilment.rk +27 -0
  37. package/template/base/modules/delivery/models/order_fulfilment_item.rk +10 -0
  38. package/template/base/modules/delivery/models/return_credit.rk +23 -0
  39. package/template/base/modules/delivery/models/sales_return.rk +87 -0
  40. package/template/base/modules/delivery/models/sales_return_item.rk +16 -0
  41. package/template/base/modules/delivery/module.rk +11 -0
  42. package/template/base/modules/distribution/flows/credit_on_invoice_cancelled.rk +17 -0
  43. package/template/base/modules/distribution/flows/credit_on_invoice_submitted.rk +17 -0
  44. package/template/base/modules/distribution/flows/credit_on_order_cancelled.rk +17 -0
  45. package/template/base/modules/distribution/flows/credit_on_order_submitted.rk +17 -0
  46. package/template/base/modules/distribution/flows/credit_on_payment_cancelled.rk +17 -0
  47. package/template/base/modules/distribution/flows/credit_on_payment_submitted.rk +17 -0
  48. package/template/base/modules/distribution/flows/giro_bounced.rk +20 -0
  49. package/template/base/modules/distribution/flows/giro_from_payment.rk +21 -0
  50. package/template/base/modules/distribution/flows/order_tier_pricing_created.rk +17 -0
  51. package/template/base/modules/distribution/flows/order_tier_pricing_updated.rk +17 -0
  52. package/template/base/modules/distribution/models/giro.rk +79 -0
  53. package/template/base/modules/distribution/module.rk +9 -0
  54. package/template/base/modules/invoicing/models/sales_invoice.rk +16 -1
  55. package/template/base/modules/invoicing/module.rk +2 -2
  56. package/template/base/modules/orders/models/customer_order.rk +80 -2
  57. package/template/base/modules/orders/models/customer_order_item.rk +19 -0
  58. package/template/base/modules/orders/module.rk +2 -2
  59. package/template/base/modules/outlets/models/outlet.rk +1 -0
  60. package/template/base/modules/outlets/module.rk +1 -1
  61. package/template/base/modules/payments/models/payment.rk +36 -1
  62. package/template/base/modules/payments/module.rk +2 -2
  63. package/template/base/modules/production/flows/batch_cancel_guard.rk +12 -0
  64. package/template/base/modules/production/flows/batch_from_bom.rk +19 -0
  65. package/template/base/modules/production/flows/wage_sheet_on_batch_cancelled.rk +14 -0
  66. package/template/base/modules/production/flows/wage_sheet_on_batch_submitted.rk +12 -0
  67. package/template/base/modules/production/flows/work_order_materials_created.rk +20 -0
  68. package/template/base/modules/production/flows/work_order_materials_updated.rk +20 -0
  69. package/template/base/modules/production/models/bom.rk +67 -0
  70. package/template/base/modules/production/models/bom_byproduct.rk +7 -0
  71. package/template/base/modules/production/models/bom_line.rk +11 -0
  72. package/template/base/modules/production/models/production_batch.rk +149 -0
  73. package/template/base/modules/production/models/production_guard.rk +23 -0
  74. package/template/base/modules/production/models/production_labour.rk +10 -0
  75. package/template/base/modules/production/models/production_material.rk +8 -0
  76. package/template/base/modules/production/models/production_output.rk +8 -0
  77. package/template/base/modules/production/models/production_stage.rk +19 -0
  78. package/template/base/modules/production/models/wage_line.rk +11 -0
  79. package/template/base/modules/production/models/wage_sheet.rk +28 -0
  80. package/template/base/modules/production/models/work_order.rk +63 -0
  81. package/template/base/modules/production/models/work_order_material.rk +8 -0
  82. package/template/base/modules/production/module.rk +12 -0
  83. package/template/base/modules/projects/flows/timesheet_assignment_on_create.rk +28 -0
  84. package/template/base/modules/projects/imports/attendance_recap.rk +23 -0
  85. package/template/base/modules/projects/models/assignment.rk +16 -3
  86. package/template/base/modules/projects/models/project_ledger.rk +5 -2
  87. package/template/base/modules/projects/models/timesheet.rk +58 -14
  88. package/template/base/modules/stock/models/stock_move.rk +4 -0
  89. package/template/base/modules/stock/module.rk +1 -1
  90. package/template/base/modules/users/models/user.rk +1 -0
  91. package/template/base/modules/users/module.rk +1 -1
  92. package/template/base/modules/users/roles/field_sales.rk +7 -0
  93. package/template/base/modules/workforce/imports/worker_list.rk +6 -1
  94. package/template/base/modules/workforce/models/worker.rk +28 -8
@@ -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
@@ -0,0 +1,67 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # Bill of materials (resep produksi) for output_qty of a product. A line may be a semi-finished item that has its own
3
+ # BOM (item.default_bom): its unit cost is that BOM's unit_cost, so the cost rolls up any number of levels
4
+ # (multi-level). Each level is made with its own work order. By-products take a share of the material cost.
5
+ name: bom
6
+ label: {id: Resep produksi (BOM), en: Bill of materials}
7
+ icon: stock
8
+ naming: BOM-{####}
9
+ title_field: bom_name
10
+ permissions:
11
+ - {role: head_office, read: true, create: true, write: true, delete: true, export: true, print: true}
12
+ - {role: outlet_staff, read: true, print: true}
13
+ fields:
14
+ - {name: bom_name, type: data, label: {id: Nama resep}, required: true, in_list: true}
15
+ - {name: item, type: link, to: item, label: {id: Produk}, required: true, in_list: true}
16
+ - {name: output_qty, type: float, label: {id: Hasil standar per batch}, default: '1', required: true, in_list: true}
17
+ - {name: uom, type: link, to: uom, label: {id: Satuan hasil}, default: item.stock_uom}
18
+ - {name: yield_percent, type: float, label: {id: Rendemen standar (%)}, default: '100', help: {id: Hasil baik dibanding bahan yang masuk}}
19
+ - {name: active, type: check, label: {id: Aktif}, default: 'true', in_list: true}
20
+ - {name: lines, type: table, of: bom_line, label: {id: Bahan}, min_rows: 1}
21
+ - {name: byproducts, type: table, of: bom_byproduct, label: {id: Produk sampingan}}
22
+ - {name: labour_per_unit, type: currency, label: {id: Upah borongan per satuan}, help: {id: Jumlah tarif semua tahap per satuan hasil}}
23
+ - {name: overhead_per_unit, type: currency, label: {id: Overhead per satuan}, help: {id: 'Tarif sederhana: listrik, gas, sewa dibagi hasil sebulan'}}
24
+ - {name: material_cost, type: currency, label: {id: Biaya bahan per batch}, compute: "lines.map(l, l.cost).sum()"}
25
+ - {name: byproduct_share, type: float, label: {id: Porsi produk sampingan (%)}, compute: "byproducts.map(b, b.cost_share).sum()"}
26
+ - name: unit_cost
27
+ type: currency
28
+ label: {id: HPP standar per satuan}
29
+ compute: "output_qty > 0 ? round(material_cost * (100 - byproduct_share) / 100 / output_qty) + labour_per_unit + overhead_per_unit : 0"
30
+ in_list: true
31
+ - {name: notes, type: text, label: {id: Catatan}}
32
+ rules:
33
+ - name: output_positive
34
+ on: save
35
+ check: output_qty > 0
36
+ message: {id: Hasil standar harus lebih dari 0}
37
+ - name: not_itself
38
+ on: save
39
+ check: "lines.map(l, l.item == item ? 1 : 0).sum() == 0"
40
+ message: {id: Produk tidak boleh menjadi bahannya sendiri}
41
+ - name: share_below_100
42
+ on: save
43
+ check: byproduct_share < 100
44
+ message: {id: Porsi produk sampingan harus di bawah 100%}
45
+ - name: qty_positive
46
+ on: save
47
+ check: "lines.map(l, l.qty <= 0 ? 1 : 0).sum() == 0"
48
+ message: {id: Jumlah bahan harus lebih dari 0}
49
+ views:
50
+ list:
51
+ columns: [name, bom_name, item, output_qty, unit_cost, active]
52
+ form:
53
+ layout:
54
+ - section: {id: Resep}
55
+ columns:
56
+ - [bom_name, item, active]
57
+ - [output_qty, uom, yield_percent]
58
+ - section: {id: Bahan}
59
+ fields: [lines]
60
+ - section: {id: Produk sampingan}
61
+ fields: [byproducts]
62
+ - section: {id: Biaya standar}
63
+ columns:
64
+ - [material_cost, labour_per_unit, overhead_per_unit]
65
+ - [byproduct_share, unit_cost]
66
+ - section: {id: Catatan}
67
+ fields: [notes]
@@ -0,0 +1,7 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: bom_byproduct
3
+ is_child: true
4
+ fields:
5
+ - {name: item, type: link, to: item, label: {id: Produk sampingan}, required: true}
6
+ - {name: qty, type: float, label: {id: Qty per batch}, default: '1'}
7
+ - {name: cost_share, type: float, label: {id: Porsi biaya bahan (%)}, default: '0'}
@@ -0,0 +1,11 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: bom_line
3
+ is_child: true
4
+ fields:
5
+ - {name: item, type: link, to: item, label: {id: Bahan}, required: true}
6
+ - {name: qty, type: float, label: {id: Qty}, default: '1'}
7
+ - {name: uom, type: link, to: uom, label: {id: Satuan}, default: item.stock_uom}
8
+ - {name: semi_finished, type: check, label: {id: Setengah jadi}, compute: "item.default_bom != ''"}
9
+ # a semi-finished item costs what its own BOM says (rolled up); a raw material its standard cost
10
+ - {name: unit_cost, type: currency, label: {id: Biaya per satuan}, compute: "item.default_bom != '' ? item.default_bom.unit_cost : item.standard_cost"}
11
+ - {name: cost, type: currency, label: {id: Biaya}, compute: round(qty * unit_cost)}
@@ -0,0 +1,149 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # Hasil produksi per batch. The batch number is the production code printed on the pack; the expiry date follows the
3
+ # product's shelf life. Submit takes the materials out of the production outlet at their moving average and puts
4
+ # the outputs into the finished-goods outlet at the value of those materials, split by cost_share (contract 0021,
5
+ # K-o). The actual cost (HPP) of the batch adds the piece-rate wages and the overhead rate to the material cost; the
6
+ # stock value holds the material cost only until K-r. Cancel reverses the stock (stock.reverse_moves).
7
+ name: production_batch
8
+ label: {id: Hasil produksi (batch), en: Production batch}
9
+ icon: stock
10
+ is_submittable: true
11
+ naming: BATCH-{YY}{MM}-{####}
12
+ title_field: item
13
+ on_submit: [stock.post_moves]
14
+ on_cancel: [stock.reverse_moves]
15
+ permissions:
16
+ - {role: head_office, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
17
+ - {role: outlet_staff, read: true, create: true, write: true, submit: true, print: true}
18
+ fields:
19
+ - {name: work_order, type: link, to: work_order, label: {id: SPK}, required: true, in_list: true, peek: [qty, due_date]}
20
+ - {name: item, type: link, to: item, label: {id: Produk}, default: work_order.item, read_only: true, in_list: true}
21
+ - {name: bom, type: link, to: bom, label: {id: Resep (BOM)}, default: work_order.bom, read_only: true}
22
+ - {name: outlet, type: link, to: outlet, label: {id: Tempat produksi (bahan keluar)}, default: work_order.outlet, required: true}
23
+ - {name: output_outlet, type: link, to: outlet, label: {id: Gudang barang jadi}, required: true}
24
+ - {name: production_date, type: date, label: {id: Tanggal produksi}, default: today(), required: true, in_list: true}
25
+ - {name: shelf_life_days, type: int, label: {id: Umur simpan (hari)}, default: item.shelf_life_days}
26
+ - name: expiry_date
27
+ type: date
28
+ label: {id: Kedaluwarsa}
29
+ compute: "shelf_life_days > 0 ? production_date + duration(shelf_life_days) : ''"
30
+ in_list: true
31
+ # the SPK's qty, not typed on the batch: output, materials and wages are checked against it
32
+ - {name: planned_qty, type: float, label: {id: Qty rencana}, default: work_order.qty, read_only: true}
33
+ # no min_rows: a batch created empty is drafted from its BOM by the flow batch_from_bom (rules check at submit)
34
+ - {name: materials, type: table, of: production_material, label: {id: Bahan terpakai}}
35
+ - {name: outputs, type: table, of: production_output, label: {id: Hasil}}
36
+ - {name: reject_qty, type: float, label: {id: Qty reject}}
37
+ - {name: labour, type: table, of: production_labour, label: {id: Upah borongan}}
38
+ - {name: good_qty, type: float, label: {id: Hasil baik (produk utama)}, compute: "outputs.map(o, o.item == item ? o.qty : 0).sum()", in_list: true}
39
+ - {name: yield_percent, type: float, label: {id: Rendemen aktual (%)}, compute: "planned_qty > 0 ? round(good_qty * 10000 / planned_qty) / 100 : 0"}
40
+ - {name: share_total, type: float, label: {id: Total porsi biaya (%)}, compute: "outputs.map(o, o.cost_share).sum()"}
41
+ - {name: main_share, type: float, label: {id: Porsi biaya produk utama (%)}, compute: "outputs.map(o, o.item == item ? o.cost_share : 0).sum()"}
42
+ - {name: material_cost, type: currency, label: {id: Biaya bahan (aktual)}, read_only: true}
43
+ - {name: labour_cost, type: currency, label: {id: Upah borongan}, compute: "labour.map(l, l.amount).sum()"}
44
+ - {name: overhead_rate, type: currency, label: {id: Overhead per satuan}, default: bom.overhead_per_unit}
45
+ - {name: overhead_cost, type: currency, label: {id: Overhead}, compute: round(good_qty * overhead_rate)}
46
+ # The product's share of the materials, plus all wages and overhead (by-products carry only their material share).
47
+ - name: hpp_total
48
+ type: currency
49
+ label: {id: HPP batch (produk utama)}
50
+ compute: "round(material_cost * main_share / 100) + labour_cost + overhead_cost"
51
+ in_list: true
52
+ - {name: hpp_per_unit, type: currency, label: {id: HPP per satuan}, compute: "good_qty > 0 ? round(hpp_total / good_qty) : 0", in_list: true}
53
+ - {name: standard_unit_cost, type: currency, label: {id: HPP standar per satuan}, default: bom.unit_cost, read_only: true}
54
+ - {name: notes, type: text, label: {id: Catatan}}
55
+ stock:
56
+ date: production_date
57
+ moves:
58
+ - {lines: materials, out: outlet, reason: production_out, cogs: cogs}
59
+ - {lines: outputs, in: output_outlet, reason: production_in, cost: {consumed: true, split: cost_share}}
60
+ cogs_total: material_cost
61
+ # Deviations from the plan wait for head office: materials that are not in the BOM, or more good output than 110% of
62
+ # the planned qty (a batch puts stock in at the value of what it took out, so an inflated output dilutes the cost).
63
+ approvals:
64
+ - name: material_outside_bom
65
+ on: submit
66
+ when: "materials.map(m, bom.lines.map(b, b.item == m.item ? 1 : 0).sum() > 0 ? 0 : 1).sum() > 0"
67
+ approvers: [head_office]
68
+ label: {id: Bahan di luar resep, en: Material not in the BOM}
69
+ # materials per BOM line against the recipe scaled to the good output: under 90% (output inflated against what was
70
+ # used, so the stock comes in too cheap) or over 120% (waste, or materials booked to the wrong batch)
71
+ - name: material_off_bom
72
+ on: submit
73
+ when: "good_qty > 0 && bom.output_qty > 0 && bom.lines.map(b, materials.map(m, m.item == b.item ? m.qty : 0).sum() < b.qty * good_qty / bom.output_qty * 0.9 || materials.map(m, m.item == b.item ? m.qty : 0).sum() > b.qty * good_qty / bom.output_qty * 1.2 ? 1 : 0).sum() > 0"
74
+ approvers: [head_office]
75
+ label: {id: Pemakaian bahan menyimpang dari resep, en: Materials off the BOM}
76
+ # wages above the BOM's standard piece cost for the good output (+10%)
77
+ - name: labour_above_standard
78
+ on: submit
79
+ when: labour_cost > round(bom.labour_per_unit * good_qty * 1.1)
80
+ approvers: [head_office]
81
+ label: {id: Upah borongan di atas standar, en: Piece-rate wages above standard}
82
+ # outputs against the BOM: the product's cost share is 100% less the by-products', each by-product keeps its share and
83
+ # at most 120% of its standard qty for the good output (a share or qty moved between outputs shifts stock value)
84
+ - name: output_off_bom
85
+ on: submit
86
+ when: "main_share < 100 - bom.byproduct_share - 0.005 || main_share > 100 - bom.byproduct_share + 0.005 || bom.byproducts.map(b, outputs.map(o, o.item == b.item ? o.cost_share : 0).sum() < b.cost_share - 0.005 || outputs.map(o, o.item == b.item ? o.cost_share : 0).sum() > b.cost_share + 0.005 || (bom.output_qty > 0 && outputs.map(o, o.item == b.item ? o.qty : 0).sum() > b.qty * good_qty / bom.output_qty * 1.2) ? 1 : 0).sum() > 0"
87
+ approvers: [head_office]
88
+ label: {id: Hasil atau porsi biaya menyimpang dari resep, en: Outputs off the BOM}
89
+ - name: over_planned_output
90
+ on: submit
91
+ when: good_qty > planned_qty * 1.1
92
+ approvers: [head_office]
93
+ label: {id: Hasil melebihi rencana, en: Output above plan}
94
+ rules:
95
+ - name: outputs_of_bom
96
+ on: save
97
+ check: "outputs.map(o, o.item == item || bom.byproducts.map(b, b.item == o.item ? 1 : 0).sum() > 0 ? 0 : 1).sum() == 0"
98
+ message: {id: Hasil hanya produk SPK atau produk sampingan resepnya}
99
+ - name: output_outlet_of_staff
100
+ on: save
101
+ check: "!('outlet_staff' in user.roles) || output_outlet in user.outlets"
102
+ message: {id: Gudang barang jadi harus outlet tempat kamu bekerja}
103
+ - name: work_order_released
104
+ on: save
105
+ check: work_order.docstatus == 1 && item == work_order.item && bom == work_order.bom && planned_qty == work_order.qty
106
+ message: {id: 'Batch hanya untuk SPK yang sudah dirilis (diajukan); kalau SPK-nya diganti, buat batch baru'}
107
+ - name: has_lines
108
+ on: submit
109
+ check: size(materials) > 0 && size(outputs) > 0
110
+ message: {id: Isi bahan terpakai dan hasil}
111
+ - name: shares_add_up
112
+ on: save
113
+ check: "size(outputs) == 0 || (share_total > 99.995 && share_total < 100.005)"
114
+ message: {id: Porsi biaya semua hasil harus berjumlah 100%}
115
+ - name: main_product_out
116
+ on: submit
117
+ check: good_qty > 0
118
+ message: {id: Isi hasil baik produk utama}
119
+ - name: qty_positive
120
+ on: save
121
+ check: "materials.map(m, m.qty <= 0 ? 1 : 0).sum() + outputs.map(o, o.qty <= 0 ? 1 : 0).sum() + labour.map(l, l.qty <= 0 ? 1 : 0).sum() == 0"
122
+ message: {id: 'Jumlah bahan, hasil dan upah harus lebih dari 0'}
123
+ - name: reject_not_negative
124
+ on: save
125
+ check: reject_qty >= 0
126
+ message: {id: Qty reject tidak boleh minus}
127
+ views:
128
+ list:
129
+ columns: [name, production_date, item, good_qty, yield_percent, hpp_per_unit, expiry_date, status]
130
+ filters: [item, outlet, work_order]
131
+ sort: -production_date
132
+ form:
133
+ layout:
134
+ - section: {id: Batch}
135
+ columns:
136
+ - [work_order, item, bom, planned_qty]
137
+ - [production_date, shelf_life_days, expiry_date, outlet, output_outlet]
138
+ - section: {id: Bahan terpakai}
139
+ fields: [materials]
140
+ - section: {id: Hasil}
141
+ fields: [outputs, reject_qty]
142
+ - section: {id: Upah borongan}
143
+ fields: [labour]
144
+ - section: {id: HPP aktual}
145
+ columns:
146
+ - [material_cost, labour_cost, overhead_rate, overhead_cost]
147
+ - [good_qty, yield_percent, hpp_total, hpp_per_unit, standard_unit_cost]
148
+ - section: {id: Catatan}
149
+ fields: [notes]
@@ -0,0 +1,23 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # Never stored: a flow that must refuse a batch cancel creates one with a reason, and the matching rule fails with
3
+ # its message, rolling the cancel back (like project_guard).
4
+ name: production_guard
5
+ label: {id: Penjaga produksi, en: Production guard}
6
+ icon: check
7
+ naming: PGR-{######}
8
+ title_field: reason
9
+ permissions:
10
+ - {role: head_office, create: true}
11
+ fields:
12
+ - name: reason
13
+ type: select
14
+ label: {id: Alasan}
15
+ required: true
16
+ options:
17
+ - {value: output_used, label: {id: Hasil batch sudah terpakai}}
18
+ - {name: document, type: data, label: {id: Dokumen}}
19
+ rules:
20
+ - name: output_used
21
+ on: save
22
+ check: reason != 'output_used'
23
+ message: {id: 'Hasil batch ini sudah terpakai atau terjual (stoknya di bawah qty hasil); batalkan dokumen pemakainya dulu'}
@@ -0,0 +1,10 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: production_labour
3
+ is_child: true
4
+ fields:
5
+ - {name: worker, type: link, to: worker, label: {id: Pekerja}, required: true}
6
+ - {name: stage, type: link, to: production_stage, label: {id: Tahap}, required: true}
7
+ - {name: qty, type: float, label: {id: Qty dikerjakan}}
8
+ # always the stage's rate: the piece rate is head office's (production_stage), not typed on the batch
9
+ - {name: rate, type: currency, label: {id: Tarif}, compute: stage.rate}
10
+ - {name: amount, type: currency, label: {id: Upah}, compute: round(qty * rate)}
@@ -0,0 +1,8 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: production_material
3
+ is_child: true
4
+ fields:
5
+ - {name: item, type: link, to: item, label: {id: Bahan}, required: true}
6
+ - {name: qty, type: float, label: {id: Qty terpakai}}
7
+ - {name: uom, type: link, to: uom, label: {id: Satuan}, default: item.stock_uom}
8
+ - {name: cogs, type: currency, label: {id: Biaya bahan}, read_only: true}
@@ -0,0 +1,8 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: production_output
3
+ is_child: true
4
+ fields:
5
+ - {name: item, type: link, to: item, label: {id: Hasil}, required: true}
6
+ - {name: qty, type: float, label: {id: Qty}}
7
+ - {name: uom, type: link, to: uom, label: {id: Satuan}, default: item.stock_uom}
8
+ - {name: cost_share, type: float, label: {id: Porsi biaya bahan (%)}, default: '100'}
@@ -0,0 +1,19 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # A production stage paid by the piece (borongan): giling, cetak, kemas. The rate is per unit of work; a stage per
3
+ # product when products pay differently ("Cetak dimsum", "Cetak nugget").
4
+ name: production_stage
5
+ label: {id: Tahap borongan, en: Piece-rate stage}
6
+ icon: stock
7
+ naming: TAHAP-{###}
8
+ title_field: stage_name
9
+ permissions:
10
+ - {role: head_office, read: true, create: true, write: true, delete: true, export: true}
11
+ - {role: outlet_staff, read: true}
12
+ fields:
13
+ - {name: stage_name, type: data, label: {id: Tahap}, required: true, in_list: true}
14
+ - {name: unit, type: data, label: {id: Satuan kerja}, default: "'pak'", in_list: true}
15
+ - {name: rate, type: currency, label: {id: Tarif per satuan}, required: true, in_list: true}
16
+ - {name: active, type: check, label: {id: Aktif}, default: 'true'}
17
+ views:
18
+ list:
19
+ columns: [name, stage_name, unit, rate, active]
@@ -0,0 +1,11 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: wage_line
3
+ is_child: true
4
+ fields:
5
+ - {name: worker, type: link, to: worker, label: {id: Pekerja}, read_only: true}
6
+ - {name: stage, type: link, to: production_stage, label: {id: Tahap}, read_only: true}
7
+ - {name: qty, type: float, label: {id: Qty}, read_only: true}
8
+ - {name: rate, type: currency, label: {id: Tarif}, read_only: true}
9
+ - {name: amount, type: currency, label: {id: Upah}, read_only: true}
10
+ - {name: work_date, type: date, label: {id: Tanggal kerja}, read_only: true}
11
+ - {name: cancelled, type: check, label: {id: Batal}, read_only: true}
@@ -0,0 +1,28 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # Piece-rate wages earned in one submitted batch, one line per worker and stage, dated the production day. Made by
3
+ # the flow wage_sheet_on_batch_submitted; a cancelled batch marks its lines cancelled. The weekly recap per worker
4
+ # (dashboard produksi_upah) reads the lines. Every field is read_only: wages are changed on the batch, not here.
5
+ name: wage_sheet
6
+ label: {id: Lembar upah borongan, en: Piece-rate wage sheet}
7
+ icon: card
8
+ naming: UPAH-{YYYY}-{#####}
9
+ title_field: production_batch
10
+ permissions:
11
+ - {role: head_office, read: true, create: true, write: true, export: true, print: true}
12
+ # staff submitting a batch makes its sheet (the flow), but only head office reads wages
13
+ - {role: outlet_staff, create: true}
14
+ fields:
15
+ - {name: production_batch, type: data, label: {id: Batch}, read_only: true, in_list: true}
16
+ - {name: work_date, type: date, label: {id: Tanggal kerja}, read_only: true, in_list: true}
17
+ - {name: cancelled, type: check, label: {id: Batal}, read_only: true, in_list: true}
18
+ - {name: lines, type: table, of: wage_line, label: {id: Upah}, read_only: true}
19
+ - {name: total, type: currency, label: {id: Total upah}, compute: "cancelled ? 0 : lines.map(l, l.amount).sum()", in_list: true}
20
+ rules:
21
+ - name: made_by_batch
22
+ on: save
23
+ check: production_batch != ''
24
+ message: {id: Lembar upah dibuat dari batch yang diajukan}
25
+ views:
26
+ list:
27
+ columns: [name, production_batch, work_date, total, cancelled]
28
+ sort: -work_date
@@ -0,0 +1,63 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # Surat perintah kerja (SPK): make qty of a product with a BOM, for stock or for a customer order. The material need
3
+ # is filled from the BOM scaled to qty (flow work_order_materials) and can be edited before release (submit). A
4
+ # semi-finished line is made with its own SPK first. Batches (production_batch) report what was made against it.
5
+ name: work_order
6
+ label: {id: SPK produksi, en: Work order}
7
+ icon: stock
8
+ is_submittable: true
9
+ naming: SPK-{YYYY}-{#####}
10
+ title_field: item
11
+ permissions:
12
+ - {role: head_office, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
13
+ - {role: outlet_staff, read: true, print: true}
14
+ fields:
15
+ - {name: item, type: link, to: item, label: {id: Produk}, required: true, in_list: true}
16
+ - {name: bom, type: link, to: bom, label: {id: Resep (BOM)}, default: item.default_bom, required: true}
17
+ - {name: qty, type: float, label: {id: Qty rencana}, required: true, in_list: true}
18
+ - {name: uom, type: link, to: uom, label: {id: Satuan}, default: item.stock_uom}
19
+ - {name: outlet, type: link, to: outlet, label: {id: Tempat produksi}, required: true, in_list: true}
20
+ - {name: start_date, type: date, label: {id: Mulai}, default: today(), required: true, in_list: true}
21
+ - {name: due_date, type: date, label: {id: Target selesai}, in_list: true}
22
+ - name: customer_order
23
+ type: link
24
+ to: customer_order
25
+ label: {id: Untuk pesanan}
26
+ depends_on: app_installed('orders')
27
+ - {name: size_notes, type: text, label: {id: Rincian ukuran / spesifikasi}}
28
+ - {name: materials, type: table, of: work_order_material, label: {id: Kebutuhan bahan}}
29
+ # the qty and BOM the material need was last filled for (flow work_order_materials); a change refills it
30
+ - {name: materials_qty, type: float, label: {id: Bahan dihitung untuk qty}, read_only: true}
31
+ - {name: materials_bom, type: data, label: {id: Bahan dihitung dari resep}, read_only: true}
32
+ - {name: notes, type: text, label: {id: Catatan}}
33
+ rules:
34
+ - name: qty_positive
35
+ on: save
36
+ check: qty > 0
37
+ message: {id: Qty rencana harus lebih dari 0}
38
+ - name: bom_of_item
39
+ on: save
40
+ check: bom == '' || bom.item == item
41
+ message: {id: Resep ini untuk produk lain}
42
+ - name: bom_active
43
+ on: submit
44
+ check: bom.active
45
+ message: {id: Resep tidak aktif}
46
+ - name: due_after_start
47
+ on: save
48
+ check: due_date == '' || due_date >= start_date
49
+ message: {id: Target selesai tidak boleh sebelum tanggal mulai}
50
+ views:
51
+ list:
52
+ columns: [name, item, qty, outlet, start_date, due_date, status]
53
+ sort: -start_date
54
+ form:
55
+ layout:
56
+ - section: {id: SPK}
57
+ columns:
58
+ - [item, bom, qty, uom]
59
+ - [outlet, start_date, due_date, customer_order]
60
+ - section: {id: Kebutuhan bahan}
61
+ fields: [materials]
62
+ - section: {id: Spesifikasi}
63
+ fields: [size_notes, notes]
@@ -0,0 +1,8 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ name: work_order_material
3
+ is_child: true
4
+ fields:
5
+ - {name: item, type: link, to: item, label: {id: Bahan}, required: true}
6
+ - {name: qty, type: float, label: {id: Qty dibutuhkan}}
7
+ - {name: uom, type: link, to: uom, label: {id: Satuan}, default: item.stock_uom}
8
+ - {name: semi_finished, type: check, label: {id: Setengah jadi (SPK sendiri)}, compute: "item.default_bom != ''"}
@@ -0,0 +1,12 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/module.json
2
+ # Small-factory production: multi-level bills of materials with a rolled-up standard cost, work orders (SPK), batch
3
+ # results with expiry, actual cost per batch (materials at the cost the kernel took them out, piece-rate wages and a
4
+ # simple overhead rate) and piece-rate wage sheets per worker. A batch takes materials out and puts the products in
5
+ # at the value of those materials through the declarative stock block of contract 0021 (K-o). Wages and overhead are
6
+ # in the batch's actual cost (HPP) but not in the stock value until K-r.
7
+ name: production
8
+ version: 1.0.0
9
+ title: {id: Produksi, en: Production}
10
+ requires: {rangka: '>=0.5', users: ^1.0, catalogue: ^1.0, outlets: ^1.0, stock: ^1.0, workforce: ^1.0}
11
+ optional: {orders: ^1.0}
12
+ hooks: [stock.reverse_moves]
@@ -0,0 +1,28 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ name: timesheet_assignment_on_create
3
+ label: {id: Absensi memakai tarif penugasan}
4
+ # An attendance recap import (or a timesheet typed without its assignment) names only the project and the worker. This
5
+ # finds the worker's assignment on that project covering the start of the work and takes its rates, so the client's
6
+ # rate and the project's pay apply instead of the worker's general ones. No assignment found: the worker's rates
7
+ # (the timesheet defaults) stay. A recap counts days, so it stays per day: an hourly assignment gives its day rate
8
+ # and the worker's pay per day stays (an hourly assignment's cost_rate is per hour). Runs on the draft, before anyone submits it. Only for recaps (period_to set): a daily
9
+ # timesheet typed by hand keeps the rates its author typed.
10
+ on: timesheet.created
11
+ if: event.assignment == '' && event.period_to != '' && event.docstatus == 0
12
+ steps:
13
+ - find: assignment
14
+ where: project == event.project && worker == event.worker && start_date <= event.work_date && end_date >= event.work_date
15
+ as: asg
16
+ - if: asg != null
17
+ find: timesheet
18
+ where: name == event.name
19
+ as: ts
20
+ - if: asg != null
21
+ update: ts
22
+ set:
23
+ assignment: asg.name
24
+ day_rate: asg.day_rate
25
+ hour_rate: asg.hour_rate
26
+ cost_rate: "asg.rate_basis == 'day' ? asg.cost_rate : ts.cost_rate"
27
+ overtime_rate: asg.overtime_rate
28
+ overtime_cost_rate: asg.overtime_cost_rate
@@ -0,0 +1,23 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/import.json
2
+ # Monthly attendance recap (G7): one row per worker per project per cut-off period, as fingerprint machines and HR apps
3
+ # export it (Rekap Absensi: days present and overtime hours per person for a date range, often the 21st to the 20th).
4
+ # Each row becomes one draft timesheet for the period, priced from the worker's assignment on the project
5
+ # (timesheet_assignment_on_create) or, without one, from the worker. Proyek is the project number (PRJ-...), No.
6
+ # pegawai the worker's employee number. Columns Nama and others are ignored. The same worker, project and start date
7
+ # twice is skipped by the key; a wrong file is undone by deleting its drafts, a submitted one by cancelling it.
8
+ name: attendance_recap
9
+ label: {id: Rekap absensi bulanan, en: Monthly attendance recap}
10
+ model: timesheet
11
+ source: xlsx
12
+ header_row: 1
13
+ key: [Proyek, No. pegawai, Dari tanggal]
14
+ map:
15
+ project: Proyek
16
+ worker: {value: No. pegawai, match: employee_no}
17
+ work_date: Dari tanggal
18
+ period_to: Sampai tanggal
19
+ # An empty cell must not become the model's default of 1 day: -1 makes the row fail recap_days with its message.
20
+ days: "=row['Hari hadir'] == '' ? '-1' : row['Hari hadir']"
21
+ overtime_hours: "='Jam lembur' in row && row['Jam lembur'] != '' ? row['Jam lembur'] : '0'"
22
+ rate_basis: "='day'"
23
+ description: "='Rekap absensi ' + row['Dari tanggal'] + ' s.d. ' + row['Sampai tanggal']"
@@ -6,7 +6,7 @@ naming: ASG-{#####}
6
6
  title_field: worker
7
7
  permissions:
8
8
  - {role: project_admin, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
9
- - {role: sales_manager, read: true}
9
+ # No sales_manager: an assignment carries the cost rates (audit L1).
10
10
  - {role: finance_manager, read: true}
11
11
  fields:
12
12
  - name: project
@@ -57,10 +57,23 @@ fields:
57
57
  type: currency
58
58
  label: {id: Biaya per satuan}
59
59
  default: "rate_basis == 'hour' ? worker.cost_hour_rate : worker.cost_day_rate"
60
+ # Overtime per hour on this project, from the worker unless the client agreed another rate.
61
+ - name: overtime_rate
62
+ type: currency
63
+ label: {id: Tarif jual lembur per jam}
64
+ default: worker.overtime_rate
65
+ - name: overtime_cost_rate
66
+ type: currency
67
+ label: {id: Upah lembur per jam}
68
+ default: worker.overtime_cost_rate
60
69
  - name: notes
61
70
  type: text
62
71
  label: {id: Catatan}
63
72
  rules:
73
+ - name: rates_not_negative
74
+ on: save
75
+ check: day_rate >= 0 && hour_rate >= 0 && cost_rate >= 0 && overtime_rate >= 0 && overtime_cost_rate >= 0
76
+ message: {id: 'Tarif dan upah tidak boleh negatif'}
64
77
  - name: end_after_start
65
78
  on: save
66
79
  check: end_date >= start_date
@@ -77,7 +90,7 @@ views:
77
90
  - [start_date, end_date]
78
91
  - section: {id: Tarif}
79
92
  columns:
80
- - [rate_basis, day_rate, hour_rate]
81
- - [cost_rate]
93
+ - [rate_basis, day_rate, hour_rate, overtime_rate]
94
+ - [cost_rate, overtime_cost_rate]
82
95
  - section: {id: Catatan}
83
96
  fields: [notes]
@@ -19,8 +19,11 @@ title_field: project
19
19
  permissions:
20
20
  - {role: project_admin, read: true, create: true, export: true}
21
21
  - {role: finance_manager, read: true, create: true, export: true}
22
- - {role: sales_manager, read: true, create: true, export: true}
23
- - {role: purchasing_manager, read: true, create: true}
22
+ # Sales and purchasing read (and their flows write) only the rows of their own documents: labour rows carry pay and
23
+ # cost rows the firm's margin (audit L1). Read stays because the cancel flows find the row they reverse as the person
24
+ # cancelling. No export for sales.
25
+ - {role: sales_manager, read: true, create: true, if: kind == 'revenue'}
26
+ - {role: purchasing_manager, read: true, create: true, if: kind == 'vendor'}
24
27
  fields:
25
28
  - name: project
26
29
  type: link