Repository navigation
Earnings Engine Design
Rodrigo Silveira edited this page Aug 6, 2026
·
1 revision
Implement strategy pattern by payment method:
DailyWageCalculatorSalaryCalculatorCommissionCalculator
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
net_amount = configured daily wage amount
currency = BRL
daily_rate = monthly_salary / configured_salary_divisor
net_amount = daily_rate
currency = BRL
gross_amount = well_production_grams * collaborator_percentage
currency = GOLD_GRAMS
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.
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.