(cls, invoice, payment_record)
Make a payment for a billing account towards an invoice
Make a payment for a billing account towards an invoice
Make a payment for a billing account towards an invoice
def make_payment_towards_invoice(cls, invoice, payment_record):
        """ Make a payment for a billing account towards an invoice """
        if invoice.is_customer_invoice:
            billing_account = invoice.account
        else:
            billing_account = invoice.subscription.account
        cls.add_credit(
            payment_record.amount,
            account=billing_account,
            payment_record=payment_record,
        )
        cls.add_credit(
            -payment_record.amount,
            account=billing_account,
            invoice=invoice,
        )
def make_payment_towards_invoice ( cls , invoice , payment_record ) : if invoice . is_customer_invoice : billing_account = invoice . account else : billing_account = invoice . subscription . account cls . add_credit ( payment_record . amount , account = billing_account , payment_record = payment_record , ) cls . add_credit ( - payment_record . amount , account = billing_account , invoice = invoice , )