diff --git a/apps/billing/models.py b/apps/billing/models.py index f4b4c62..3f18068 100644 --- a/apps/billing/models.py +++ b/apps/billing/models.py @@ -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 diff --git a/apps/shared_revenue/services/split_execution.py b/apps/shared_revenue/services/split_execution.py index d8f12ab..68cce80 100644 --- a/apps/shared_revenue/services/split_execution.py +++ b/apps/shared_revenue/services/split_execution.py @@ -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, }