def _generate_for_single_subscription(self, subscription=None,
                                          billing_date=None):

        billing_date = billing_date or timezone.now().date()

        provider = subscription.plan.provider
        customer = subscription.customer

        document = self._create_document(provider, customer, subscription,
                                         billing_date)
        args = {
            'billing_date': billing_date,
            provider.flow: document,
        }

        self._log_subscription_billing(document, subscription)

        subscription.add_total_value_to_document(**args)

        if subscription.state == Subscription.STATES.CANCELED:
            subscription.end()
            subscription.save()

        if provider.default_document_state == Provider.DEFAULT_DOC_STATE.ISSUED:
            document.issue()
            document.save()
Generates the billing documents corresponding to a single subscription.
dataset/ETHPy150Open PressLabs/silver/silver/documents_generator.py/DocumentsGenerator._generate_for_single_subscription