askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
asset_disposals.json · 5.4 KB · 65 lines
| 1 | { |
| 2 | "name": "asset_disposals", |
| 3 | "title": "Asset Disposals", |
| 4 | "version": 1, |
| 5 | "description": "How a fixed asset left the business: sold, scrapped, stolen, or destroyed (casualty). A person records the facts -- the date, what was received for it (proceeds), what the insurer paid or will pay (insurance recovery), the evidence -- and the books pass computes the rest: the cost basis (cost plus posted improvements), the depreciation on the books through the month before the disposal (full-month convention), the net book value, and the gain (positive) or loss (negative) = proceeds + insurance - net book value. Those numbers are stamped on this row (read-only, doctrine #1) at the moment the journal is composed (marker asset_disposals/{id}), and the asset is marked disposed, which freezes it. A theft or a casualty is not booked until loss_event_id names an APPROVED loss event: somebody other than the reporter has looked at the evidence. One disposal per asset (partial disposals are not modelled).", |
| 6 | "fields": [ |
| 7 | {"name": "id"}, |
| 8 | {"name": "asset_id", "type": "relation", "required": true, "label": "Asset", |
| 9 | "relation": {"collection": "fixed_assets", "display_field": "name", "requires": "update"}, |
| 10 | "help": "Disposing of an asset ends its depreciation and removes it from the books: the writer must be allowed to update it."}, |
| 11 | {"name": "disposed_on", "type": "date", "required": true, "label": "Disposed On"}, |
| 12 | {"name": "kind", "type": "enum", "required": true, "label": "Kind", "enum": ["sale", "scrap", "theft", "casualty"]}, |
| 13 | {"name": "proceeds_cents", "type": "integer", "label": "Proceeds (cents)", "default": "0", "validation": {"min": 0}, |
| 14 | "help": "What the buyer (or the scrap dealer) paid."}, |
| 15 | {"name": "insurance_recovery_cents", "type": "integer", "label": "Insurance Recovery (cents)", "default": "0", |
| 16 | "validation": {"min": 0}, |
| 17 | "help": "What the insurer paid or has agreed to pay. Left at 0 when the claim is still open: the loss event books the recovery when it is paid."}, |
| 18 | {"name": "proceeds_account_id", "label": "Proceeds Account", |
| 19 | "relation": {"collection": "fin_accounts", "display_field": "name", "requires": "update"}, |
| 20 | "help": "Blank: assets.journal.proceeds_account."}, |
| 21 | {"name": "insurance_account_id", "label": "Insurance Receivable Account", |
| 22 | "relation": {"collection": "fin_accounts", "display_field": "name", "requires": "update"}, |
| 23 | "help": "Blank: assets.journal.insurance_receivable_account."}, |
| 24 | {"name": "counterparty", "type": "text", "label": "Buyer Or Insurer", "validation": {"max_length": 200}}, |
| 25 | {"name": "evidence_refs", "type": "textarea", "label": "Evidence", |
| 26 | "validation": {"required_when": {"kind": ["sale", "theft", "casualty"]}}, |
| 27 | "help": "Bill of sale, police report number, adjuster's report, photos."}, |
| 28 | {"name": "loss_event_id", "type": "relation", "label": "Loss Event", |
| 29 | "relation": {"collection": "loss_events", "display_field": "what", "requires": "read"}, |
| 30 | "validation": {"required_when": {"kind": ["theft", "casualty"]}}, |
| 31 | "help": "Theft and casualty: the approved loss event with the evidence."}, |
| 32 | {"name": "status", "type": "enum", "label": "Booked", "enum": ["posted"], "read_only": true}, |
| 33 | {"name": "cost_basis_cents", "type": "integer", "label": "Cost Basis (cents)", "read_only": true}, |
| 34 | {"name": "accumulated_depreciation_cents", "type": "integer", "label": "Accumulated Depreciation (cents)", "read_only": true}, |
| 35 | {"name": "net_book_value_cents", "type": "integer", "label": "Net Book Value (cents)", "read_only": true}, |
| 36 | {"name": "gain_loss_cents", "type": "integer", "label": "Gain (Loss) (cents)", "read_only": true, |
| 37 | "help": "Positive is a gain, negative a loss."}, |
| 38 | {"name": "journal_id", "type": "text", "label": "Journal", "read_only": true}, |
| 39 | {"name": "posted_at", "type": "datetime", "label": "Posted", "read_only": true}, |
| 40 | {"name": "notes", "type": "textarea", "label": "Notes"}, |
| 41 | {"name": "owner_id", "type": "text", "label": "Owner"}, |
| 42 | {"name": "entity_id", "type": "text", "label": "Entity", |
| 43 | "relation": {"collection": "entities", "display_field": "name", "requires": "update"}}, |
| 44 | {"name": "created_at", "type": "datetime", "label": "Created", "read_only": true} |
| 45 | ], |
| 46 | "unique": [{"fields": ["asset_id"], "message": "This asset already has a disposal. An asset leaves the books once."}], |
| 47 | "locked_when": [ |
| 48 | {"when": {"status": ["posted"]}, "except": ["notes"], |
| 49 | "message": "This disposal is on the books. Correct it with a reversing journal, not an edit."} |
| 50 | ], |
| 51 | "locked_checks": [ |
| 52 | {"name": "disposal_fits_asset", "object": "check_assets", "function": "DISPOSAL_CHECK", |
| 53 | "reads": ["fixed_assets", "asset_work"], "lock": "assets", |
| 54 | "on": {"create": true, "update": ["asset_id", "disposed_on"], "delete": false}} |
| 55 | ], |
| 56 | "capabilities": {"comments": true, "attachments": true}, |
| 57 | "forms": {"default": {"fields": ["asset_id", "disposed_on", "kind", "proceeds_cents", "insurance_recovery_cents", |
| 58 | "proceeds_account_id", "insurance_account_id", "counterparty", |
| 59 | "evidence_refs", "loss_event_id", "notes"]}}, |
| 60 | "views": {"list_mode": "table", |
| 61 | "list_fields": ["disposed_on", "asset_id", "kind", "proceeds_cents", "insurance_recovery_cents", |
| 62 | "net_book_value_cents", "gain_loss_cents", "status"], |
| 63 | "filter_fields": ["kind"]}, |
| 64 | "search": {"fields": ["counterparty", "evidence_refs", "notes"]} |
| 65 | } |