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
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m8s
This commit is contained in:
@@ -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(
|
||||
falukant_user_id,
|
||||
-total_tax,
|
||||
&format!("tax from sales branch {}", director.branch_id),
|
||||
);
|
||||
if DEFAULT_TREASURY_USER_ID != falukant_user_id {
|
||||
let _ = self.base.change_falukant_user_money(
|
||||
DEFAULT_TREASURY_USER_ID,
|
||||
total_tax,
|
||||
&format!("tax from sales branch {}", director.branch_id),
|
||||
&format!("tax income 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 sold_any {
|
||||
let message = format!(
|
||||
|
||||
Reference in New Issue
Block a user