diff --git a/src/worker/director.rs b/src/worker/director.rs index a63ac60..9cc3d88 100644 --- a/src/worker/director.rs +++ b/src/worker/director.rs @@ -802,15 +802,28 @@ impl DirectorWorker { total_payout = (total_payout * 100.0).round() / 100.0; total_tax = (total_tax * 100.0).round() / 100.0; + // Für eine nachvollziehbare History buchen wir Brutto-Verkauf und Steuer getrennt: + // - Spieler: +Bruttoerlös, dann -Steuer + // - Treasury: +Steuer (nur wenn anderer User als Verkäufer) + let total_revenue = ((total_payout + total_tax) * 100.0).round() / 100.0; + if total_revenue != 0.0 { + let _ = self + .base + .change_falukant_user_money(falukant_user_id, total_revenue, "sell products"); + } if total_tax > 0.0 { let _ = self.base.change_falukant_user_money( - DEFAULT_TREASURY_USER_ID, - total_tax, + falukant_user_id, + -total_tax, &format!("tax from sales branch {}", director.branch_id), ); - } - if total_payout != 0.0 { - let _ = self.base.change_falukant_user_money(falukant_user_id, total_payout, "sell products"); + if DEFAULT_TREASURY_USER_ID != falukant_user_id { + let _ = self.base.change_falukant_user_money( + DEFAULT_TREASURY_USER_ID, + total_tax, + &format!("tax income from sales branch {}", director.branch_id), + ); + } } if sold_any { let message = format!(