Refactor a bit to avoid monster formula
This commit is contained in:
parent
f5b33cce74
commit
385db5422e
1 changed files with 15 additions and 12 deletions
|
|
@ -118,24 +118,27 @@ def generate_um_report(
|
|||
if not order.contains_sku(relevant_sku):
|
||||
continue
|
||||
logger.debug(f"Reporting for order {order[ORDER_KEYS.id]}")
|
||||
|
||||
# A few helper variables to make the last variable more understandable
|
||||
sats_received_for_sku = order.sats_received_for_sku(relevant_sku)
|
||||
bbo_fee_if_applicable = (BBO_ROYALTY_FEE_PERCENTAGE * (relevant_sku in BBO_SKUS))
|
||||
discount_factor_for_bbo_skus = 1 - bbo_fee_if_applicable
|
||||
|
||||
# We owe UM his percentages of the sats received after discounting
|
||||
# royalties paid to BBO for the BBO products.
|
||||
sats_owed_to_um = (
|
||||
(sats_received_for_sku * discount_factor_for_bbo_skus)
|
||||
* UM_FIRST_AGREEMENT_PERCENTAGE,
|
||||
)
|
||||
|
||||
report.append(
|
||||
{
|
||||
"order_id": order[ORDER_KEYS.id],
|
||||
"sku": relevant_sku,
|
||||
"units_sold": order.units_of_sku(relevant_sku),
|
||||
"eur_income": order.sales_of_sku(relevant_sku),
|
||||
"sats_income": order.sats_received_for_sku(relevant_sku),
|
||||
"sats_owed_to_um": (
|
||||
order.sats_received_for_sku(relevant_sku)
|
||||
* (
|
||||
1
|
||||
- (
|
||||
BBO_ROYALTY_FEE_PERCENTAGE
|
||||
* (relevant_sku in BBO_SKUS)
|
||||
)
|
||||
)
|
||||
)
|
||||
* UM_FIRST_AGREEMENT_PERCENTAGE,
|
||||
"sats_income": sats_received_for_sku,
|
||||
"sats_owed_to_um": sats_owed_to_um,
|
||||
}
|
||||
)
|
||||
logger.info("Report generated.")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue