Refactor revenue and tax handling in DirectorWorker: Updated logic to separately account for gross revenue and tax deductions during product sales. Enhanced monetary transactions to ensure accurate tax income distribution, particularly when the seller differs from the treasury user, improving financial tracking and compliance.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m8s

This commit is contained in:
Torsten Schulz (local)
2026-05-06 11:09:42 +02:00
parent 8509a7e171
commit 9022b58dc7

View File

@@ -802,15 +802,28 @@ impl DirectorWorker {
total_payout = (total_payout * 100.0).round() / 100.0; total_payout = (total_payout * 100.0).round() / 100.0;
total_tax = (total_tax * 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 { if total_tax > 0.0 {
let _ = self.base.change_falukant_user_money( let _ = self.base.change_falukant_user_money(
DEFAULT_TREASURY_USER_ID, falukant_user_id,
total_tax, -total_tax,
&format!("tax from sales branch {}", director.branch_id), &format!("tax from sales branch {}", director.branch_id),
); );
} if DEFAULT_TREASURY_USER_ID != falukant_user_id {
if total_payout != 0.0 { let _ = self.base.change_falukant_user_money(
let _ = self.base.change_falukant_user_money(falukant_user_id, total_payout, "sell products"); DEFAULT_TREASURY_USER_ID,
total_tax,
&format!("tax income from sales branch {}", director.branch_id),
);
}
} }
if sold_any { if sold_any {
let message = format!( let message = format!(