@rangka-os/create 0.5.0-alpha.28 → 0.5.0-alpha.29

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 (41) hide show
  1. package/package.json +1 -1
  2. package/template/base/apps/jasa_proyek/app.rk +3 -0
  3. package/template/base/apps/pembukuan/app.rk +3 -0
  4. package/template/base/modules/accounting/flows/gl_asset_disposal_post.rk +68 -0
  5. package/template/base/modules/accounting/flows/gl_asset_disposal_reverse.rk +194 -0
  6. package/template/base/modules/accounting/flows/gl_depreciation_run_post.rk +43 -0
  7. package/template/base/modules/accounting/flows/gl_depreciation_run_reverse.rk +36 -0
  8. package/template/base/modules/accounting/flows/gl_fixed_asset_post.rk +51 -0
  9. package/template/base/modules/accounting/flows/gl_fixed_asset_reverse.rk +194 -0
  10. package/template/base/modules/accounting/flows/gl_vendor_bill_post.rk +2 -2
  11. package/template/base/modules/accounting/models/gl_entry.rk +2 -0
  12. package/template/base/modules/accounting/module.rk +2 -2
  13. package/template/base/modules/fixed_assets/flows/asset_disposal_on_cancel.rk +14 -0
  14. package/template/base/modules/fixed_assets/flows/asset_disposal_on_submit.rk +21 -0
  15. package/template/base/modules/fixed_assets/flows/asset_from_vendor_bill.rk +41 -0
  16. package/template/base/modules/fixed_assets/flows/depreciation_run_fill.rk +28 -0
  17. package/template/base/modules/fixed_assets/flows/depreciation_run_monthly.rk +36 -0
  18. package/template/base/modules/fixed_assets/flows/depreciation_run_on_cancel.rk +30 -0
  19. package/template/base/modules/fixed_assets/flows/depreciation_run_on_submit.rk +34 -0
  20. package/template/base/modules/fixed_assets/flows/fixed_asset_on_cancel.rk +24 -0
  21. package/template/base/modules/fixed_assets/flows/fixed_asset_on_submit.rk +69 -0
  22. package/template/base/modules/fixed_assets/flows/fixed_assets_setup.rk +29 -0
  23. package/template/base/modules/fixed_assets/flows/opening_balance_asset_guard.rk +15 -0
  24. package/template/base/modules/fixed_assets/flows/vendor_bill_asset_guard.rk +14 -0
  25. package/template/base/modules/fixed_assets/imports/asset_list.rk +22 -0
  26. package/template/base/modules/fixed_assets/models/asset_bill_line.rk +24 -0
  27. package/template/base/modules/fixed_assets/models/asset_book.rk +83 -0
  28. package/template/base/modules/fixed_assets/models/asset_category.rk +54 -0
  29. package/template/base/modules/fixed_assets/models/asset_disposal.rk +97 -0
  30. package/template/base/modules/fixed_assets/models/asset_guard.rk +90 -0
  31. package/template/base/modules/fixed_assets/models/depreciation_line.rk +13 -0
  32. package/template/base/modules/fixed_assets/models/depreciation_run.rk +65 -0
  33. package/template/base/modules/fixed_assets/models/fixed_asset.rk +165 -0
  34. package/template/base/modules/fixed_assets/models/fixed_asset_setting.rk +34 -0
  35. package/template/base/modules/fixed_assets/module.rk +30 -0
  36. package/template/base/modules/fixed_assets/print/fixed_asset_register.html +45 -0
  37. package/template/base/modules/fixed_assets/print/fixed_asset_register.rk +17 -0
  38. package/template/base/modules/procurement/models/vendor_bill.rk +7 -1
  39. package/template/base/modules/procurement/module.rk +2 -2
  40. package/template/base/modules/rental/models/rental_unit.rk +13 -3
  41. package/template/base/modules/rental/module.rk +2 -2
@@ -0,0 +1,14 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Inside an asset disposal's cancel: the register row is in use again, Aktif or Habis disusutkan by its book value.
3
+ name: asset_disposal_on_cancel
4
+ label: {id: Pelepasan aset dibatalkan}
5
+ on: asset_disposal.cancelled
6
+ steps:
7
+ - find: asset_book
8
+ where: name == event.book && disposal == event.name
9
+ as: b
10
+ - update: b
11
+ if: b != null
12
+ set:
13
+ state: "b.book_value <= b.residual_value ? 'fully_depreciated' : 'active'"
14
+ disposal: "''"
@@ -0,0 +1,21 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Inside an asset disposal's submit: refused when the asset was already sold or written off (another disposal won the
3
+ # race), or when its depreciation moved since the disposal's values were read (a run submitted at the same time: the
4
+ # frozen cost and accumulated depreciation must be the register's, read here under its lock; audit F2). Then the register row is marked Dijual or Dihapus and points at this disposal; the runs skip it from now on.
5
+ # The journal is the accounting module's (gl_asset_disposal_post).
6
+ name: asset_disposal_on_submit
7
+ label: {id: Pelepasan aset masuk daftar aset}
8
+ on: asset_disposal.submitted
9
+ if: "'docstatus' in event && event.docstatus == 1"
10
+ steps:
11
+ - find: asset_book
12
+ where: name == event.book
13
+ as: b
14
+ - if: "b == null || !(b.state in ['active', 'fully_depreciated'])"
15
+ create: asset_guard
16
+ set: {reason: "'disposal_taken'", document: event.book}
17
+ - if: "b != null && (b.cost != event.cost || b.opening_accumulated + b.accumulated != event.accumulated_total)"
18
+ create: asset_guard
19
+ set: {reason: "'disposal_stale'", document: event.book}
20
+ - update: b
21
+ set: {state: event.kind, disposal: event.name}
@@ -0,0 +1,41 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # A vendor bill submitted as "Aset tetap" (posting asset; its journal debits 1-2100): one draft fixed asset per bill
3
+ # line, its cost the line amount; a business that is not PKP cannot credit the input PPN, so the bill put the PPN in
4
+ # 1-2100 too and each asset takes its share of it (by cumulative line amounts, so the shares add up to the PPN
5
+ # exactly); that cost is kept per line in asset_bill_line, which only this flow writes. Finance adds the category and
6
+ # life and submits each draft. Refused (the bill's submit rolls back): a
7
+ # foreign-currency bill (assets in a foreign currency are not in v1), or a line below the capitalisation threshold
8
+ # (that purchase is an expense: split the bill). Runs as whoever submits the bill.
9
+ name: asset_from_vendor_bill
10
+ label: {id: Tagihan aset tetap jadi draft aset}
11
+ description: {id: 'Saat tagihan pemasok untuk aset tetap diajukan, tiap barisnya jadi draft aset tetap yang tinggal dilengkapi kelompok dan umurnya.'}
12
+ on: vendor_bill.submitted
13
+ if: "event.posting == 'asset'"
14
+ steps:
15
+ - if: event.currency != '' && event.currency != 'IDR'
16
+ create: asset_guard
17
+ set: {reason: "'bill_currency'", document: event.name}
18
+ - {find: fixed_asset_setting, as: cfg}
19
+ - if: "event.items.exists(l, l.amount < (cfg != null ? cfg.capitalisation_threshold : 1000000))"
20
+ create: asset_guard
21
+ set: {reason: "'below_threshold'", document: event.name}
22
+ - for_each: event.items
23
+ as: l
24
+ do:
25
+ - create: asset_bill_line
26
+ set:
27
+ vendor_bill: event.name
28
+ bill_line: l.idx
29
+ cost: "l.amount + (tax.pkp ? 0 : round(event.ppn * event.items.filter(y, y.idx <= l.idx).map(y, y.amount).sum() / event.subtotal) - round(event.ppn * event.items.filter(y, y.idx < l.idx).map(y, y.amount).sum() / event.subtotal))"
30
+ - create: fixed_asset
31
+ set:
32
+ asset_name: "l.description != '' ? truncate(l.description, 140) : l.item"
33
+ source: "'vendor_bill'"
34
+ vendor_bill: event.name
35
+ bill_line: l.idx
36
+ cost: "l.amount + (tax.pkp ? 0 : round(event.ppn * event.items.filter(y, y.idx <= l.idx).map(y, y.amount).sum() / event.subtotal) - round(event.ppn * event.items.filter(y, y.idx < l.idx).map(y, y.amount).sum() / event.subtotal))"
37
+ acquisition_date: event.bill_date
38
+ book_date: event.bill_date
39
+ depreciation_start: "add_months(truncate(string(event.bill_date), 7) + '-01', 1)"
40
+ project: event.project
41
+ notes: "'Dari tagihan ' + event.bill_no + ' baris ' + string(l.idx)"
@@ -0,0 +1,28 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Lists the assets of a new monthly depreciation run: every register row still active whose next month to depreciate
3
+ # (the month after the last one depreciated, else its first month) is on or before the run's month, with what it is
4
+ # owed up to that month: the monthly amount times the months not yet depreciated (one, or more when earlier months had
5
+ # no run), never past its residual value. The month whose remainder after it would be less than half a monthly
6
+ # amount takes all that is left (rounding a monthly amount down drifts by at most half a rupiah per month of life), so
7
+ # an amount rounded down never leaves a month past the useful life (audit F3). At most 900 assets per run (a run's
8
+ # cancel reverses two journal lines per asset within the kernel's 2000-item loop, audit F8); assets past that are
9
+ # caught up by the next month's run. Months between two first-of-month dates are their days / 30.436875 rounded
10
+ # (exact for any span: a calendar month is 28 to 31 days).
11
+ name: depreciation_run_fill
12
+ label: {id: Isi daftar aset penyusutan}
13
+ on: depreciation_run.created
14
+ steps:
15
+ - find: depreciation_run
16
+ where: name == event.name
17
+ as: run
18
+ - find_all: asset_book
19
+ where: state == 'active' && depreciation_start <= event.period
20
+ sort: asset
21
+ limit: 900
22
+ as: books
23
+ - update: run
24
+ set:
25
+ lines: >-
26
+ books.filter(b, b.state == 'active' && (b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)) <= string(event.period) && (b.book_value - b.residual_value) > 0).map(b, {'asset': b.asset,
27
+ 'months': (int((double(days_between((b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)), string(event.period))) + 15.0) / 30.436875) + 1), 'amount': (2 * ((b.book_value - b.residual_value) - b.monthly_depreciation * (int((double(days_between((b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)), string(event.period))) + 15.0) / 30.436875) + 1)) < b.monthly_depreciation ? (b.book_value - b.residual_value) : b.monthly_depreciation * (int((double(days_between((b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)), string(event.period))) + 15.0) / 30.436875) + 1)),
28
+ 'outlet': b.outlet, 'project': b.project, 'prev_through': b.depreciated_through})
@@ -0,0 +1,36 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # On the 1st at 06:00 (scheduler.timezone): drafts last month's depreciation run when there is none yet and an asset is
3
+ # due, with its lines (the same list and amounts as flow depreciation_run_fill, which a record made by a flow does not
4
+ # start), and tells finance and the owner. A person checks and submits it: nothing posts by itself, so a wrong asset
5
+ # can be fixed before the books move (DECISIONS.md, rangka-apps#113). Scheduled flows run for the default org only
6
+ # (contract 0031).
7
+ name: depreciation_run_monthly
8
+ label: {id: Draft penyusutan bulanan, en: Monthly depreciation draft}
9
+ description: {id: 'Tiap tanggal 1 pagi, draft penyusutan bulan lalu dibuat dan bagian keuangan dikabari untuk memeriksa dan mengajukannya.'}
10
+ schedule: '0 6 1 * *'
11
+ steps:
12
+ - find: depreciation_run
13
+ where: period == add_months(truncate(string(today()), 7) + '-01', -1) && docstatus != 2
14
+ as: done
15
+ - find_all: asset_book
16
+ where: state == 'active' && depreciation_start <= add_months(truncate(string(today()), 7) + '-01', -1)
17
+ sort: asset
18
+ limit: 900
19
+ as: books
20
+ - if: "done == null && books.exists(b, b.state == 'active' && (b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)) <= add_months(truncate(string(today()), 7) + '-01', -1) && (b.book_value - b.residual_value) > 0)"
21
+ create: depreciation_run
22
+ set:
23
+ period: "add_months(truncate(string(today()), 7) + '-01', -1)"
24
+ lines: >-
25
+ books.filter(b, b.state == 'active' && (b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)) <= add_months(truncate(string(today()), 7) + '-01', -1) && (b.book_value - b.residual_value) > 0).map(b, {'asset': b.asset,
26
+ 'months': (int((double(days_between((b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)), add_months(truncate(string(today()), 7) + '-01', -1))) + 15.0) / 30.436875) + 1), 'amount': (2 * ((b.book_value - b.residual_value) - b.monthly_depreciation * (int((double(days_between((b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)), add_months(truncate(string(today()), 7) + '-01', -1))) + 15.0) / 30.436875) + 1)) < b.monthly_depreciation ? (b.book_value - b.residual_value) : b.monthly_depreciation * (int((double(days_between((b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)), add_months(truncate(string(today()), 7) + '-01', -1))) + 15.0) / 30.436875) + 1)),
27
+ 'outlet': b.outlet, 'project': b.project, 'prev_through': b.depreciated_through})
28
+ as: run
29
+ - if: "done == null && books.exists(b, b.state == 'active' && (b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)) <= add_months(truncate(string(today()), 7) + '-01', -1) && (b.book_value - b.residual_value) > 0)"
30
+ notify: finance_manager
31
+ notice: depreciation_ready
32
+ id: "'depreciation:' + add_months(truncate(string(today()), 7) + '-01', -1)"
33
+ title: Penyusutan bulan lalu siap diajukan
34
+ template: >-
35
+ Draft penyusutan bulan {truncate(add_months(truncate(string(today()), 7) + '-01', -1), 7)} sudah dibuat untuk {books.filter(b, b.state == 'active' && (b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)) <= add_months(truncate(string(today()), 7) + '-01', -1) && (b.book_value - b.residual_value) > 0).size()} aset, total
36
+ Rp {books.filter(b, b.state == 'active' && (b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)) <= add_months(truncate(string(today()), 7) + '-01', -1) && (b.book_value - b.residual_value) > 0).map(b, (2 * ((b.book_value - b.residual_value) - b.monthly_depreciation * (int((double(days_between((b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)), add_months(truncate(string(today()), 7) + '-01', -1))) + 15.0) / 30.436875) + 1)) < b.monthly_depreciation ? (b.book_value - b.residual_value) : b.monthly_depreciation * (int((double(days_between((b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)), add_months(truncate(string(today()), 7) + '-01', -1))) + 15.0) / 30.436875) + 1))).sum()}. Periksa lalu ajukan di Penyusutan bulanan.
@@ -0,0 +1,30 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Inside a monthly depreciation run's cancel: only the latest submitted run may be cancelled, and not while an asset
3
+ # in it has been sold or written off since (cancel the disposal first). Each register row gives its line back: the
4
+ # accumulated depreciation, the month it was depreciated through before this run, and Aktif. The journal is reversed
5
+ # by the accounting module.
6
+ name: depreciation_run_on_cancel
7
+ label: {id: Penyusutan bulanan dibatalkan}
8
+ on: depreciation_run.cancelled
9
+ steps:
10
+ - find: depreciation_run
11
+ where: name != event.name && docstatus == 1 && period > event.period
12
+ as: later
13
+ - if: later != null
14
+ create: asset_guard
15
+ set: {reason: "'run_not_latest'", document: later.name}
16
+ - find_all: asset_book
17
+ where: asset in event.lines.map(l, l.asset) && state != 'cancelled'
18
+ as: books
19
+ - if: "books.exists(b, b.state in ['sold', 'written_off'])"
20
+ create: asset_guard
21
+ set: {reason: "'run_disposed'", document: event.name}
22
+ - for_each: books
23
+ as: b
24
+ do:
25
+ - update: b
26
+ set:
27
+ accumulated: b.accumulated - event.lines.filter(l, l.asset == b.asset)[0].amount
28
+ depreciated_through: event.lines.filter(l, l.asset == b.asset)[0].prev_through
29
+ last_run: "''"
30
+ state: "'active'"
@@ -0,0 +1,34 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Inside a monthly depreciation run's submit: refused when a run for this month or a later one is already submitted, or
3
+ # when a line no longer matches its asset (the asset was cancelled, disposed of or depreciated by another run since
4
+ # the draft was made, or its amount, outlet or project was changed): delete the draft and make it again. Then each register row takes its
5
+ # line: accumulated depreciation, the month depreciated, the run, and Habis disusutkan once the book value reaches the
6
+ # residual. The journal is the accounting module's (gl_depreciation_run_post).
7
+ name: depreciation_run_on_submit
8
+ label: {id: Penyusutan bulanan masuk daftar aset}
9
+ on: depreciation_run.submitted
10
+ if: "'docstatus' in event && event.docstatus == 1"
11
+ steps:
12
+ - find: depreciation_run
13
+ where: name != event.name && docstatus == 1 && period >= event.period
14
+ as: later
15
+ - if: later != null
16
+ create: asset_guard
17
+ set: {reason: "'run_exists'", document: later.name}
18
+ - find_all: asset_book
19
+ where: asset in event.lines.map(l, l.asset) && state != 'cancelled'
20
+ as: books
21
+ - if: >-
22
+ books.size() != event.lines.size() || !event.lines.all(l, books.exists(b, b.asset == l.asset
23
+ && b.state == 'active' && (b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)) <= string(event.period) && (b.book_value - b.residual_value) > 0 && b.depreciated_through == l.prev_through && l.outlet == b.outlet && l.project == b.project && l.amount == (2 * ((b.book_value - b.residual_value) - b.monthly_depreciation * (int((double(days_between((b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)), string(event.period))) + 15.0) / 30.436875) + 1)) < b.monthly_depreciation ? (b.book_value - b.residual_value) : b.monthly_depreciation * (int((double(days_between((b.depreciated_through == '' ? string(b.depreciation_start) : add_months(string(b.depreciated_through), 1)), string(event.period))) + 15.0) / 30.436875) + 1))))
24
+ create: asset_guard
25
+ set: {reason: "'run_stale'", document: event.name}
26
+ - for_each: books
27
+ as: b
28
+ do:
29
+ - update: b
30
+ set:
31
+ accumulated: b.accumulated + event.lines.filter(l, l.asset == b.asset)[0].amount
32
+ depreciated_through: event.period
33
+ last_run: event.name
34
+ state: "b.book_value - event.lines.filter(l, l.asset == b.asset)[0].amount <= b.residual_value ? 'fully_depreciated' : 'active'"
@@ -0,0 +1,24 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Inside a fixed asset's cancel: refused once a run has depreciated it or it was sold or written off (cancel those
3
+ # first, latest first). Otherwise its register row is closed (state cancelled, kept as history) and the rental unit
4
+ # no longer points at it. The purchase journal is reversed by the accounting module.
5
+ name: fixed_asset_on_cancel
6
+ label: {id: Aset tetap batal}
7
+ on: fixed_asset.cancelled
8
+ steps:
9
+ - find: asset_book
10
+ where: asset == event.name
11
+ as: b
12
+ - if: "b != null && (b.accumulated > 0 || b.state in ['sold', 'written_off'])"
13
+ create: asset_guard
14
+ set: {reason: "'asset_in_use'", document: b.name}
15
+ - update: b
16
+ if: b != null
17
+ set: {state: "'cancelled'"}
18
+ - find: rental_unit
19
+ if: event.rental_unit != ''
20
+ where: name == event.rental_unit && asset == event.name
21
+ as: u
22
+ - update: u
23
+ if: event.rental_unit != '' && u != null
24
+ set: {asset: "''"}
@@ -0,0 +1,69 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Inside a fixed asset's submit: refuses an asset below the capitalisation threshold (fixed_asset_setting; 0 = no
3
+ # threshold; Rp 1.000.000 until the setting exists, e.g. in an org the daily setup flow does not reach), an asset from a
4
+ # bill whose cost is not the cost the bill's flow recorded for its line (asset_bill_line, audit F1) or whose line is
5
+ # already another live asset, an old asset while Saldo awal already carries fixed assets as one number (audit F5), or a
6
+ # rental unit that is already another live asset;
7
+ # then opens its row in the register (asset_book, the values the runs and disposals move) and links the rental unit
8
+ # back to it. Reads in the order fixed_asset_setting, fixed_asset, asset_book, rental_unit (contract 0025).
9
+ name: fixed_asset_on_submit
10
+ label: {id: Aset tetap masuk daftar aset}
11
+ on: fixed_asset.submitted
12
+ if: "'docstatus' in event && event.docstatus == 1"
13
+ steps:
14
+ - {find: fixed_asset_setting, as: cfg}
15
+ - if: "event.cost < (cfg != null ? cfg.capitalisation_threshold : 1000000)"
16
+ create: asset_guard
17
+ set: {reason: "'below_threshold'", document: event.name}
18
+ - find: asset_bill_line
19
+ if: event.source == 'vendor_bill'
20
+ where: vendor_bill == event.vendor_bill && bill_line == event.bill_line
21
+ as: bl
22
+ - if: "event.source == 'vendor_bill' && (bl == null || bl.cost != event.cost)"
23
+ create: asset_guard
24
+ set: {reason: "'bill_cost'", document: event.vendor_bill}
25
+ - find: fixed_asset
26
+ if: event.source == 'vendor_bill'
27
+ where: name != event.name && docstatus == 1 && vendor_bill == event.vendor_bill && bill_line == event.bill_line
28
+ as: twin
29
+ - if: event.source == 'vendor_bill' && twin != null
30
+ create: asset_guard
31
+ set: {reason: "'bill_line_taken'", document: twin.name}
32
+ - find: opening_balance
33
+ if: event.source == 'opening'
34
+ where: docstatus == 1 && (fixed_assets != 0 || accumulated_depreciation != 0)
35
+ as: ob
36
+ - if: event.source == 'opening' && ob != null
37
+ create: asset_guard
38
+ set: {reason: "'opening_twice'", document: ob.name}
39
+ - find: asset_book
40
+ if: event.rental_unit != ''
41
+ where: rental_unit == event.rental_unit && state != 'cancelled'
42
+ as: other
43
+ - if: event.rental_unit != '' && other != null
44
+ create: asset_guard
45
+ set: {reason: "'unit_taken'", document: other.asset}
46
+ - create: asset_book
47
+ set:
48
+ asset: event.name
49
+ asset_name: event.asset_name
50
+ category: event.category
51
+ outlet: event.outlet
52
+ project: event.project
53
+ rental_unit: event.rental_unit
54
+ acquisition_date: event.acquisition_date
55
+ cost: event.cost
56
+ residual_value: event.residual_value
57
+ monthly_depreciation: event.monthly_depreciation
58
+ depreciation_start: event.depreciation_start
59
+ opening_accumulated: event.opening_accumulated
60
+ accumulated: '0'
61
+ # an old asset brought in already fully depreciated is not depreciated again (audit F7)
62
+ state: "event.cost - event.opening_accumulated <= event.residual_value ? 'fully_depreciated' : 'active'"
63
+ - find: rental_unit
64
+ if: event.rental_unit != ''
65
+ where: name == event.rental_unit
66
+ as: u
67
+ - update: u
68
+ if: event.rental_unit != '' && u != null
69
+ set: {asset: event.name}
@@ -0,0 +1,29 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Makes the one fixed_asset_setting record (capitalisation threshold Rp 1.000.000) and, when there is no category yet,
3
+ # the six default categories (useful life in months and fiscal group of PMK 72/2023). Every morning at 05:00, so a
4
+ # business that adds the module has them the next day; finance or the owner can also run it from the flow list right
5
+ # away. It never changes a record that exists. Scheduled flows run for the default org only (contract 0031).
6
+ name: fixed_assets_setup
7
+ label: {id: Siapkan aset tetap, en: Set up fixed assets}
8
+ description: {id: 'Membuat pengaturan aset tetap dan enam kelompok aset bawaan bila belum ada.'}
9
+ schedule: '0 5 * * *'
10
+ steps:
11
+ - {find: fixed_asset_setting, as: cfg}
12
+ - create: fixed_asset_setting
13
+ if: cfg == null
14
+ set: {key: "'usaha'", capitalisation_threshold: '1000000'}
15
+ - find_all: asset_category
16
+ limit: 1
17
+ as: cats
18
+ - for_each: >-
19
+ cats.size() > 0 ? [] : [
20
+ {'n': 'Kendaraan', 'm': 96, 'g': 'kelompok_2'},
21
+ {'n': 'Peralatan kantor', 'm': 48, 'g': 'kelompok_1'},
22
+ {'n': 'Komputer dan HP', 'm': 48, 'g': 'kelompok_1'},
23
+ {'n': 'Mesin', 'm': 96, 'g': 'kelompok_2'},
24
+ {'n': 'Alat sewa', 'm': 48, 'g': 'kelompok_1'},
25
+ {'n': 'Bangunan', 'm': 240, 'g': 'bangunan_permanen'}]
26
+ as: c
27
+ do:
28
+ - create: asset_category
29
+ set: {category_name: c.n, useful_life_months: c.m, residual_percent: '0', fiscal_group: c.g}
@@ -0,0 +1,15 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Inside a Saldo awal's submit (module accounting): refused when it carries fixed assets or their depreciation while
3
+ # old assets were already brought in one by one (fixed_asset source opening), which post the same 1-2100, 1-2900 and
4
+ # 3-1900 (audit F5). One way only: the per-asset register or the one number.
5
+ name: opening_balance_asset_guard
6
+ label: {id: Saldo awal tidak memuat aset lama dua kali}
7
+ on: opening_balance.submitted
8
+ if: "'docstatus' in event && event.docstatus == 1 && (event.fixed_assets != 0 || event.accumulated_depreciation != 0)"
9
+ steps:
10
+ - find: fixed_asset
11
+ where: docstatus == 1 && source == 'opening'
12
+ as: fa
13
+ - if: fa != null
14
+ create: asset_guard
15
+ set: {reason: "'opening_twice'", document: fa.name}
@@ -0,0 +1,14 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/flow.json
2
+ # Inside a vendor bill's cancel: refused while a submitted fixed asset was made from it (its cost is the bill's 1-2100
3
+ # debit). Cancel the assets first. Drafts made from the bill stay as drafts and can no longer be submitted (rule
4
+ # bill_source: the bill must be submitted); delete them.
5
+ name: vendor_bill_asset_guard
6
+ label: {id: Tagihan yang sudah jadi aset tidak bisa dibatalkan}
7
+ on: vendor_bill.cancelled
8
+ steps:
9
+ - find: fixed_asset
10
+ where: vendor_bill == event.name && docstatus == 1
11
+ as: fa
12
+ - if: fa != null
13
+ create: asset_guard
14
+ set: {reason: "'bill_has_asset'", document: fa.name}
@@ -0,0 +1,22 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/import.json
2
+ # Daftar aset lama from a spreadsheet: one row per asset the business already had before its books started in Rangka.
3
+ # Headers: Nama aset, Kelompok (the category name), Tanggal beli, Tanggal saldo awal, Harga perolehan, Akumulasi
4
+ # penyusutan, Umur manfaat (bulan), Nomor seri. Each row arrives as a draft fixed asset with source "Aset lama":
5
+ # check it (outlet, rental unit), then submit it to post (cost against the depreciation it had and Ekuitas saldo
6
+ # awal). Sample: examples/fixtures/imports/asset-list.csv.
7
+ name: asset_list
8
+ label: {id: Daftar aset lama, en: Opening asset list}
9
+ model: fixed_asset
10
+ source: csv
11
+ header_row: 1
12
+ key: [Nama aset, Tanggal beli, Nomor seri]
13
+ map:
14
+ asset_name: Nama aset
15
+ source: "='opening'"
16
+ category: {value: Kelompok, match: category_name}
17
+ acquisition_date: Tanggal beli
18
+ book_date: Tanggal saldo awal
19
+ cost: Harga perolehan
20
+ opening_accumulated: Akumulasi penyusutan
21
+ useful_life_months: Umur manfaat (bulan)
22
+ serial_no: Nomor seri
@@ -0,0 +1,24 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # The cost each line of a vendor bill posted as "Aset tetap" put in 1-2100 (the line, plus its share of PPN when the
3
+ # business is not PKP), written by flow asset_from_vendor_bill only (every field read_only: a client cannot create or
4
+ # change one). A fixed asset from a bill is submitted only at exactly this cost and only once per line (flow
5
+ # fixed_asset_on_submit), so the register can never hold more or less than the bill debited.
6
+ name: asset_bill_line
7
+ label: {id: Baris tagihan aset, en: Asset bill line}
8
+ icon: file-list-line
9
+ naming: ABL-{######}
10
+ title_field: bill_line_key
11
+ permissions:
12
+ # the bill's flow runs as the person who submits it; the asset's submit (finance, head office) reads the line
13
+ - {role: purchasing_manager, read: true, create: true}
14
+ - {role: finance_manager, read: true, create: true}
15
+ - {role: head_office, read: true, create: true}
16
+ fields:
17
+ - {name: vendor_bill, type: link, to: vendor_bill, label: {id: Tagihan pemasok}, required: true, read_only: true}
18
+ - {name: bill_line, type: int, label: {id: Baris tagihan}, required: true, read_only: true}
19
+ - {name: cost, type: currency, label: {id: Nilai aset baris ini}, required: true, read_only: true}
20
+ - {name: bill_line_key, type: data, label: {id: Kunci baris}, unique: true, compute: "vendor_bill + ':' + string(bill_line)"}
21
+ views:
22
+ list:
23
+ columns: [vendor_bill, bill_line, cost]
24
+ sort: vendor_bill
@@ -0,0 +1,83 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # Buku aset: one row per submitted fixed asset, made and kept current by the flows of this module (a submitted document
3
+ # cannot change, the pattern of rental_schedule): what the asset cost, how much has been depreciated, up to which
4
+ # month, and whether it is still in use, fully depreciated, sold or written off. The depreciation runs read and write
5
+ # these rows; a disposal picks one. Every field is read_only: only the flows write them. This is the register a person
6
+ # reads ("Daftar aset tetap"): book value = cost - depreciation before the books started - depreciation since.
7
+ name: asset_book
8
+ label: {id: Daftar aset tetap, en: Fixed asset register}
9
+ icon: building-2-line
10
+ naming: '{asset}-{##}'
11
+ title_field: asset_name
12
+ permissions:
13
+ # write: the runs and disposals of whoever submits or cancels them update the row (its fields are read_only)
14
+ - {role: finance_manager, read: true, create: true, write: true, export: true, print: true}
15
+ - {role: head_office, read: true, create: true, write: true, export: true, print: true}
16
+ - {role: rental_staff, read: true}
17
+ fields:
18
+ - {name: asset, type: link, to: fixed_asset, label: {id: Aset}, required: true, unique: true, read_only: true, in_list: true}
19
+ - {name: asset_name, type: data, label: {id: Nama aset}, read_only: true, in_list: true}
20
+ - {name: category, type: link, to: asset_category, label: {id: Kelompok aset}, read_only: true, in_list: true}
21
+ - {name: outlet, type: link, to: outlet, label: {id: Cabang}, read_only: true, in_list: true, depends_on: app_installed('outlets')}
22
+ - {name: project, type: link, to: project, label: {id: Proyek}, read_only: true, depends_on: app_installed('projects')}
23
+ - {name: rental_unit, type: link, to: rental_unit, label: {id: Unit alat sewa}, read_only: true, depends_on: app_installed('rental')}
24
+ - {name: acquisition_date, type: date, label: {id: Tanggal beli}, read_only: true}
25
+ - {name: cost, type: currency, label: {id: Harga perolehan}, read_only: true, in_list: true, hidden_for: [rental_staff]}
26
+ - {name: residual_value, type: currency, label: {id: Nilai sisa}, read_only: true, hidden_for: [rental_staff]}
27
+ - {name: monthly_depreciation, type: currency, label: {id: Penyusutan per bulan}, read_only: true, hidden_for: [rental_staff]}
28
+ - {name: depreciation_start, type: date, label: {id: Mulai disusutkan}, read_only: true}
29
+ - {name: opening_accumulated, type: currency, label: {id: Akumulasi sebelum pembukuan}, read_only: true, hidden_for: [rental_staff]}
30
+ - {name: accumulated, type: currency, label: {id: Akumulasi penyusutan}, read_only: true, hidden_for: [rental_staff]}
31
+ - name: accumulated_total
32
+ type: currency
33
+ label: {id: Total akumulasi penyusutan}
34
+ compute: opening_accumulated + accumulated
35
+ hidden_for: [rental_staff]
36
+ - name: book_value
37
+ type: currency
38
+ label: {id: Nilai buku}
39
+ compute: cost - opening_accumulated - accumulated
40
+ in_list: true
41
+ hidden_for: [rental_staff]
42
+ - name: depreciated_through
43
+ type: date
44
+ label: {id: Disusutkan sampai bulan}
45
+ help: {id: 'Tanggal 1 bulan terakhir yang sudah disusutkan'}
46
+ read_only: true
47
+ - {name: last_run, type: link, to: depreciation_run, label: {id: Penyusutan terakhir}, read_only: true}
48
+ - name: state
49
+ type: select
50
+ label: {id: Status}
51
+ default: "'active'"
52
+ read_only: true
53
+ in_list: true
54
+ chip: true
55
+ options:
56
+ - {value: active, label: {id: Aktif}}
57
+ - {value: fully_depreciated, label: {id: Habis disusutkan}}
58
+ - {value: sold, label: {id: Dijual}}
59
+ - {value: written_off, label: {id: Dihapus}}
60
+ - {value: cancelled, label: {id: Batal}}
61
+ - {name: disposal, type: link, to: asset_disposal, label: {id: Pelepasan}, read_only: true}
62
+ # words for the register print (a print reads option labels of its own model only)
63
+ - {name: category_name, type: data, label: {id: Nama kelompok}, hidden: true, compute: category.category_name}
64
+ - name: state_label
65
+ type: data
66
+ label: {id: Status (teks)}
67
+ hidden: true
68
+ compute: "state == 'active' ? 'Aktif' : (state == 'fully_depreciated' ? 'Habis disusutkan' : (state == 'sold' ? 'Dijual' : (state == 'written_off' ? 'Dihapus' : 'Batal')))"
69
+ views:
70
+ list:
71
+ columns: [asset, category, outlet, book_value, cost, accumulated_total, state]
72
+ filters: [category, outlet, state]
73
+ sort: asset
74
+ form:
75
+ layout:
76
+ - section: {id: Aset}
77
+ columns:
78
+ - [asset, asset_name, category, outlet, project, rental_unit]
79
+ - [acquisition_date, state, disposal]
80
+ - section: {id: Penyusutan}
81
+ columns:
82
+ - [cost, residual_value, monthly_depreciation, depreciation_start]
83
+ - [opening_accumulated, accumulated, accumulated_total, book_value, depreciated_through, last_run]
@@ -0,0 +1,54 @@
1
+ # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
2
+ # Kelompok aset: the defaults a new asset takes (useful life in months, residual value as a percent of the cost) and
3
+ # its fiscal group under PMK 72/2023 (useful life for tax: kelompok 1 four years, 2 eight, 3 sixteen, 4 twenty;
4
+ # permanent buildings twenty, non-permanent ten). The fiscal group is stored for a later Coretax report; v1 books the
5
+ # commercial straight line only. Six defaults are made by flow fixed_assets_setup.
6
+ name: asset_category
7
+ label: {id: Kelompok aset, en: Asset category}
8
+ icon: folder-2-line
9
+ naming: AKL-{###}
10
+ title_field: category_name
11
+ permissions:
12
+ - {role: finance_manager, read: true, create: true, write: true, delete: true, export: true}
13
+ - {role: head_office, read: true, create: true, write: true, delete: true, export: true}
14
+ - {role: purchasing_manager, read: true}
15
+ - {role: rental_staff, read: true}
16
+ fields:
17
+ - {name: category_name, type: data, label: {id: Nama kelompok}, required: true, unique: true, in_list: true}
18
+ - name: useful_life_months
19
+ type: int
20
+ label: {id: Umur manfaat (bulan)}
21
+ help: {id: 'Berapa bulan aset dipakai sampai habis disusutkan, misalnya 48 untuk 4 tahun'}
22
+ required: true
23
+ in_list: true
24
+ - name: residual_percent
25
+ type: percent
26
+ label: {id: Nilai sisa (% harga)}
27
+ help: {id: 'Perkiraan nilai jual di akhir umur manfaat, persen dari harga perolehan. Biasanya 0'}
28
+ default: '0'
29
+ in_list: true
30
+ - name: fiscal_group
31
+ type: select
32
+ label: {id: Kelompok fiskal (PMK 72/2023)}
33
+ help: {id: 'Untuk laporan pajak nanti. Belum mengubah penyusutan di pembukuan'}
34
+ in_list: true
35
+ options:
36
+ - {value: kelompok_1, label: {id: Kelompok 1 (4 tahun)}}
37
+ - {value: kelompok_2, label: {id: Kelompok 2 (8 tahun)}}
38
+ - {value: kelompok_3, label: {id: Kelompok 3 (16 tahun)}}
39
+ - {value: kelompok_4, label: {id: Kelompok 4 (20 tahun)}}
40
+ - {value: bangunan_permanen, label: {id: Bangunan permanen (20 tahun)}}
41
+ - {value: bangunan_tidak_permanen, label: {id: Bangunan tidak permanen (10 tahun)}}
42
+ rules:
43
+ - name: life_positive
44
+ on: save
45
+ check: useful_life_months > 0 && useful_life_months <= 600
46
+ message: {id: Umur manfaat antara 1 dan 600 bulan}
47
+ - name: residual_range
48
+ on: save
49
+ check: residual_percent >= 0 && residual_percent < 100
50
+ message: {id: Nilai sisa antara 0 dan kurang dari 100 persen}
51
+ views:
52
+ list:
53
+ columns: [category_name, useful_life_months, residual_percent, fiscal_group]
54
+ sort: category_name