def sms_billables(self): datespan = DateSpan(DateSentFilter.get_start_date(self.request), DateSentFilter.get_end_date(self.request)) selected_billables = SmsBillable.get_billables_sent_between(datespan) if DateCreatedFilter.use_filter(self.request): date_span = DateSpan( DateCreatedFilter.get_start_date(self.request), DateCreatedFilter.get_end_date(self.request)) selected_billables = SmsBillable.filter_selected_billables_by_date( selected_billables, date_span) domain = EnterpriseDomainFilter.get_value(self.request, self.domain) if domain: selected_billables = selected_billables.filter(domain=domain, ) else: account = BillingAccount.get_account_by_domain(self.request.domain) domains = Subscription.get_active_domains_for_account(account) selected_billables = selected_billables.filter(domain__in=domains) has_gateway_fee = HasGatewayFeeFilter.get_value( self.request, self.domain) if has_gateway_fee: if has_gateway_fee == HasGatewayFeeFilter.YES: selected_billables = selected_billables.exclude( gateway_fee=None) else: selected_billables = selected_billables.filter( gateway_fee=None) gateway_type = GatewayTypeFilter.get_value(self.request, self.domain) if gateway_type: selected_billables = selected_billables.filter( gateway_fee__criteria__backend_api_id=gateway_type, ) return selected_billables
def options(self): account = BillingAccount.get_account_by_domain(self.request.domain) return clean_options([ (domain, domain) for domain in Subscription.get_active_domains_for_account(account) ])
def test_get_active_domains_for_account(self): tasks.activate_subscriptions( based_on_date=self.subscription.date_start) test_domains = ['test'] domains = Subscription.get_active_domains_for_account(self.account) self.assertEqual(list(domains), test_domains)