Subscribed_organizations: Gets list of subscribed organizations to that organization from super SubscriberQuerysetMixin
Organizations_with_balance_due_ids: List of ids of organizations with balances due
For loop: For each organization that is subscribed to you, find balances due, if a balance exists, add the ID of the organization to the list above(Maybe this can be optimized better)
Return organizations with ids in the list above, which would be subscribers with due balances
New Serializer: OrganizationWithBalanceDueSerializer
Inherits from:
OrganizationWithSubscriptionsSerializer:
Provides operational information on an Organization, bundled with its subscriptions.
balance_due = serializers.SerializerMethodField()
uses Transaction.objects.get_statement_balances(obj, until=until) for subscribers
def get_balance_due
Calculate the balance due for a specific organization (obj)
Class Meta: OrganizationSerializer.Meta
Inherits the metadata settings from the parent serializer, OrganizationSerializer
Create a page and API endpoint for a provider to find all subscribers with a balance due.
References: