Skip to content

Earnings Engine Design

Rodrigo Silveira edited this page Aug 6, 2026 · 1 revision

12.1 Calculation strategies

Implement strategy pattern by payment method:

  • DailyWageCalculator
  • SalaryCalculator
  • CommissionCalculator

Each receives:

  • collaborator journey
  • plan item
  • work period
  • production data if needed
  • latest relevant rules

Returns:

  • currency
  • gross amount
  • transfer amount
  • net amount
  • basis metadata
  • hold reason if pending

12.2 Daily wage calculation

net_amount = configured daily wage amount
currency = BRL

12.3 Salary calculation

daily_rate = monthly_salary / configured_salary_divisor
net_amount = daily_rate
currency = BRL

12.4 Commission calculation

gross_amount = well_production_grams * collaborator_percentage
currency = GOLD_GRAMS

12.5 Sick substitution calculation

For commissioned collaborator on sick day:

  • commissioned collaborator earns full commission credit,
  • commissioned collaborator receives a gold debit of 1 gram,
  • substitute daily wager receives gold credit of 1 gram,
  • substitute daily wager also receives BRL wage credit.

12.6 License substitution calculation

For commissioned collaborator on license day:

  • commissioned collaborator receives half commission credit,
  • substitute daily wager receives half commission credit,
  • substitute daily wager receives no BRL wage credit for that substituted work.

Clone this wiki locally