Esempio n. 1
0
    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()
Esempio n. 2
0
    def create_sepa_xml(cls, qs):
        """ Create a SEPA XML file for Payouts 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()
            creditor = SepaAccount(
                name=payout.receiver_account_name,
                iban=payout.receiver_account_iban,
                bic=payout.receiver_account_bic
            )

            sepa.add_credit_transfer(
                creditor=creditor,
                amount=payout.amount_payable,
                creditor_payment_id=payout.invoice_reference
            )

        return sepa.as_xml()