djaodjin / djaodjin-saas

Django application for software-as-service and subscription businesses
Other
564 stars 124 forks source link

Added API endpoint & page to retrieve customers with balances due - Issue #265 #274

Closed Deep-Chill closed 11 months ago

Deep-Chill commented 1 year ago

saas/api/metrics.py:

Added BalancesDueAPIView for balances due data.

serializers.py: Added BalancesDueSerializer class extending OrganizationSerializer to include balances_due field.

transactions.py: Added get_balances_due function to aggregate balance data per currency per subscriber, slightly different from the lifetime_value function which was overwriting currency units in the contract_values with the last currency unit: by_profiles = {val['slug']: {val['unit']: {'contract_value': val['amount']}} for val in contract_values} Removed deferred revenues.

mixins.py:

Added BalancesDueMixin. Decorates the queryset in order to be able to work with OrganizationSerializer.

extras.py:

Added metrics_balances_due URL to OrganizationMixinBase.

djaodjin-saas-vue.js:

Added balancesdue-list Vue component for fetching and rendering balance data on the front-end.

balances_due.html:

Created template to render the balances due table with a breakdown by currency units.

revenue.html:

Added link to the balances due page.

urls/api/provider/metrics.py:

Added URL pattern for BalancesDueAPIView.

urls/views/provider/metrics.py:

Added URL pattern for BalancesDueView.

saas/views/metrics.py:

Added BalancesDueView for rendering the front-end.