Skip to content

Commit

Permalink
fix: include discounts on shared revenue amounts
Browse files Browse the repository at this point in the history
related to #257
  • Loading branch information
igobranco committed Apr 1, 2024
1 parent d93aed3 commit 1b11656
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 14 additions & 0 deletions apps/billing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ def discount_rate(self):
except ZeroDivisionError:
return 0

@property
def price_excl_vat(self):
"""
The price payed excluding VAT
"""
return (self.unit_price_excl_vat - self.discount_excl_tax) * self.quantity

@property
def price_incl_vat(self):
"""
The price payed including VAT
"""
return (self.unit_price_incl_vat - self.discount_incl_tax) * self.quantity

def __str__(self):
return self.product_id

Expand Down
10 changes: 4 additions & 6 deletions apps/shared_revenue/services/split_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,11 @@ def _assembly_each_result(
"total_amount_including_vat": item.transaction.total_amount_include_vat,
"total_amount_exclude_vat": item.transaction.total_amount_exclude_vat,
"percentage_for_organization": configuration.partner_percentage,
"amount_for_organization_including_vat": (item.unit_price_incl_vat * configuration.partner_percentage)
* item.quantity,
"amount_for_organization_exclude_vat": (item.unit_price_excl_vat * configuration.partner_percentage)
* item.quantity,
"amount_for_organization_including_vat": item.price_incl_vat * configuration.partner_percentage,
"amount_for_organization_exclude_vat": item.price_excl_vat * configuration.partner_percentage,
"percentage_for_nau": configuration.nau_percentage,
"amount_for_nau_including_vat": (item.unit_price_incl_vat * configuration.nau_percentage) * item.quantity,
"amount_for_nau_exclude_vat": (item.unit_price_excl_vat * configuration.nau_percentage) * item.quantity,
"amount_for_nau_including_vat": item.price_incl_vat * configuration.nau_percentage,
"amount_for_nau_exclude_vat": item.price_excl_vat * configuration.nau_percentage,
"discount_rate": item.discount_rate,
}

Expand Down

0 comments on commit 1b11656

Please sign in to comment.