Refactor revenue and tax calculations in DirectorWorker: Adjust the pricing logic to account for cumulative tax inflation, ensuring accurate revenue and payout calculations. Update SQL query for sell logs to change conflict resolution order for better data integrity.

This commit is contained in:
Torsten Schulz (local)
2025-12-20 15:20:03 +01:00
parent 398e0ba677
commit 1719af2344
2 changed files with 20 additions and 9 deletions

View File

@@ -208,7 +208,7 @@ DELETE FROM falukant_data.inventory WHERE id = $1;
pub const QUERY_ADD_SELL_LOG: &str = r#"
INSERT INTO falukant_log.sell (region_id, product_id, quantity, seller_id, sell_timestamp)
VALUES ($1, $2, $3, $4, NOW())
ON CONFLICT (region_id, product_id, seller_id)
ON CONFLICT (seller_id, product_id, region_id)
DO UPDATE SET
quantity = falukant_log.sell.quantity + EXCLUDED.quantity,
sell_timestamp = COALESCE(EXCLUDED.sell_timestamp, NOW());