def create_sepa_xml(cls, qs): """ Create a SEPA XML file for OrganizationPayouts in QuerySet. """ batch_id = timezone.datetime.strftime(timezone.now(), "%Y%m%d%H%I%S") sepa = SepaDocument(sepa_type="CT") sepa.set_initiating_party(name=settings.BANK_ACCOUNT_DONATIONS["name"]) debtor = SepaAccount( name=settings.BANK_ACCOUNT_DONATIONS["name"], iban=settings.BANK_ACCOUNT_DONATIONS["iban"], bic=settings.BANK_ACCOUNT_DONATIONS["bic"], ) sepa.set_debtor(debtor) sepa.set_info(message_identification=batch_id, payment_info_id=batch_id) sepa.set_initiating_party(name=settings.BANK_ACCOUNT_DONATIONS["name"]) now = timezone.now() for payout in qs.all(): payout.status = StatusDefinition.IN_PROGRESS payout.submitted = now payout.save() creditor = SepaAccount( name=settings.BANK_ACCOUNT_ORGANISATION["name"], iban=settings.BANK_ACCOUNT_ORGANISATION["iban"], bic=settings.BANK_ACCOUNT_ORGANISATION["bic"], ) sepa.add_credit_transfer( creditor=creditor, amount=payout.payable_amount_incl, creditor_payment_id=payout.invoice_reference ) return sepa.as_xml()
def create_sepa_xml(cls, qs): """ Create a SEPA XML file for OrganizationPayouts in QuerySet. """ batch_id = timezone.datetime.strftime(timezone.now(), '%Y%m%d%H%I%S') sepa = SepaDocument(sepa_type='CT') sepa.set_initiating_party( name=settings.BANK_ACCOUNT_DONATIONS['name'] ) debtor = SepaAccount( name=settings.BANK_ACCOUNT_DONATIONS['name'], iban=settings.BANK_ACCOUNT_DONATIONS['iban'], bic=settings.BANK_ACCOUNT_DONATIONS['bic'] ) sepa.set_debtor(debtor) sepa.set_info( message_identification=batch_id, payment_info_id=batch_id) sepa.set_initiating_party(name=settings.BANK_ACCOUNT_DONATIONS['name']) for payout in qs.all(): payout.in_progress() payout.save() creditor = SepaAccount( name=settings.BANK_ACCOUNT_ORGANISATION['name'], iban=settings.BANK_ACCOUNT_ORGANISATION['iban'], bic=settings.BANK_ACCOUNT_ORGANISATION['bic'] ) sepa.add_credit_transfer( creditor=creditor, amount=payout.payable_amount_incl, creditor_payment_id=payout.invoice_reference ) return sepa.as_xml()