def test_community_invoice(self):
        domain = generator.arbitrary_domain()
        generator.create_excess_community_users(domain)
        account = BillingAccount.get_or_create_account_by_domain(
            domain, created_by=self.dimagi_user)[0]
        billing_contact = generator.arbitrary_contact_info(account, self.dimagi_user)
        billing_contact.save()
        account.date_confirmed_extra_charges = datetime.date.today()
        account.save()
        tasks.generate_invoices()
        subscriber = Subscriber.objects.get(domain=domain.name)
        invoices = Invoice.objects.filter(subscription__subscriber=subscriber)
        self.assertEqual(invoices.count(), 1)
        invoice = invoices.get()
        self.assertEqual(invoice.subscription.subscriber.domain, domain.name)
        self.assertEqual(invoice.subscription.date_start, invoice.date_start)
        self.assertEqual(
            invoice.subscription.date_end - datetime.timedelta(days=1),
            invoice.date_end
        )
        domain.delete()
For an unsubscribed domain with any charges over the community limit for the month of invoicing,
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/accounting/tests/test_invoicing.py/TestInvoice.test_community_invoice