Core Domain Model - RodrigoMattosoSilveira/EnterpriseRemoteSystems GitHub Wiki
5.1 Person
Permanent identity and contact record.
Fields
- id
- first_name
- last_name
- nick_name
- phone
- cpf
- rg
- address_street_1
- address-street_2
- address_city
- address_state
- address_coutry
- bank_name
- bank_numbere
- bank_checking
- pix_key
- emergency_contact_name
- emergency_contact_phone
- emergency_contact_notes
- status
- created_at
- updated_at
- archived_at nullable
Constraints
- unique(name)
- unique(phone)
- unique(email)
- unique(cpf)
- unique(pix_key)
Notes
A person may have many collaborator journeys over time.
5.2 Collaborator Journey
Represents a specific contractual work journey for a person.
Fields
- id
- person_id
- journey_start_date
- default_end_date
- extension_days
- projected_end_date
- payment_method_id
- payment_value
- sector_id
- location_id
- task_id
- status_id
- notes
- created_at
- updated_at
- closed_at nullable
Derived values
default_end_date = journey_start_date + 90 daysprojected_end_date = default_end_date + extension_days
Constraints
- no physical deletion
- one person may have multiple journeys across time
- optional rule: only one active collaborator journey per person at a time
5.3 Mine Well Production
Production recorded for a specific well and period.
Fields
- id
- work_date
- period_code
- location_id
- grams_produced
- comments
- created_by
- created_at
- updated_at
Constraints
- unique(work_date, period_code, location_id)
- location must be a mine-well type location
5.4 Gold Price
Daily gold reference price.
Fields
- id
- quote_date
- quoted_at_time
- price_brl_per_gram
- source_name
- comments
- created_by
- created_at
- updated_at
Constraints
- unique(quote_date)
Notes
Default rule: use most recent quote at time of transaction.
5.5 Price List Item
Catalog of goods and services.
Fields
- id
- code
- name
- description
- category
- price_brl
- active
- created_at
- updated_at
Derived field at runtime
price_gold_grams = price_brl / latest_gold_price_brl_per_gram
Notes
Gold price equivalent is usually computed dynamically and optionally snapshot into expense line items.
5.6 Current Account Entry
Immutable ledger entry representing a credit or debit in one currency.
Fields
- id
- reverted_entry_id nullable
- collaborator_id
- entry_date
- source_type
- source_id nullable
- method_id nullable
- currency_code
- cd_flag
- item_description
- quantity
- unit_price
- total_price
- comments
- status
- created_by
- created_at
Allowed source types
- earning_accrual
- expense
- reversal
- zero_out
- journey_close
- manual_adjustment
Allowed currencies
- BRL
- GOLD_GRAMS
Allowed cd_flag
- CREDIT
- DEBIT
Constraints
- quantity > 0
- total_price >= 0
- reversal entries reference original entry
- original entries are not edited after posting
5.7 Work Period
A plan/accrual anchor for operational periods.
Fields
- id
- work_date
- period_code
- starts_at
- ends_at
- status
- created_at
- updated_at
Status
- planned
- informed
- accrued
- locked
Constraints
- unique(work_date, period_code)
5.8 Work Plan Item
Operational assignment of a collaborator for a work period.
Fields
- id
- work_period_id
- collaborator_id
- include_flag
- sector_id
- location_id
- task_id
- method_id
- payment_value_snapshot
- assignment_status
- substituted_for_collaborator_id nullable
- exception_type nullable
- comments
- created_at
- updated_at
assignment_status
- planned
- worked
- sick
- license
- absent
- excluded
exception_type
- none
- sick_substitution
- license_substitution
5.9 Expense Transaction
Header record for an expense operation.
Fields
- id
- collaborator_id
- expense_date
- currency_code
- total_amount
- category
- collaborator_agreement
- comments
- created_by
- created_at
- updated_at
Categories
- canteen
- pix
- flights
- pay_daily_wager
- diverse
5.10 Expense Item
Line item under an expense transaction.
Fields
- id
- expense_id
- price_list_item_id nullable
- item_name_snapshot
- quantity
- unit_price
- total_price
- comments
- created_at
5.11 Earning Accrual Batch
Tracks the accrual operation for a work period.
Fields
- id
- work_period_id
- accrual_status
- comments
- created_by
- created_at
- updated_at
accrual_status
- draft
- pending_production
- posted
- partially_posted
- reverted
5.12 Earning Accrual Item
One collaborator’s earnings computation for a period.
Fields
- id
- accrual_batch_id
- collaborator_id
- method_id
- currency_code
- calculation_basis_json
- gross_amount
- transfer_amount
- net_amount
- ledger_entry_id nullable
- status
- comments
- created_at
5.13 Reference Data
Configurable lookup tables.
Recommended generic table structure:
- id
- type
- code
- label
- description
- active
- sort_order
- metadata_json
- created_at
- updated_at
Supported types:
- sector
- location
- task
- method
- person_status
- collaborator_status
- expense_category
- period_code
- ledger_currency
- ledger_cd_flag