Exemple #1
0
    def test_uk_high_value_priority_payment(self):
        # Changes from spec example: Removed DTM for transaction, HSBC ignores
        # it (section 2.8.3)
        expected = """\
UNB+UNOA:3+::ABC00000001+::HEXAGON ABC+041111:1500+UKHIGHVALUE'
UNH+1+PAYMUL:D:96A:UN:FUN01G'
BGM+452+UKHIGHVALUE+9'
DTM+137:20041111:102'
LIN+1'
DTM+203:20041112:102'
RFF+AEK:UKHIGHVALUE'
MOA+9:1.00:GBP'
FII+OR+12345678:HSBC NET TEST::GBP+:::400515:154:133+GB'
NAD+OY++HSBC BANK PLC:HSBC NET TEST:TEST:TEST:UNITED KINGDOM'
SEQ++1'
MOA+9:1.00:GBP'
RFF+CR:CRUKHV5'
RFF+PQ:PQUKHV5'
PAI+::52:::Z24'
FCA+13'
FII+BF+87654321:XYX LTD FROM FII BF 1:BEN NAME 2:GBP+:::403124:154:133+GB'
NAD+BE++SOME BANK PLC:HSBC NET TEST:TEST:TEST:UNITED KINGDOM'
CNT+39:1'
UNT+19+1'
UNZ+1+UKHIGHVALUE'"""

        src_account = paymul.UKAccount(number=12345678,
                                       holder='HSBC NET TEST',
                                       currency='GBP',
                                       sortcode=400515)

        dest_account = paymul.UKAccount(
            number=87654321,
            holder="XYX LTD FROM FII BF 1\nBEN NAME 2",
            currency='GBP',
            sortcode=403124)

        transaction = paymul.Transaction(amount=Decimal('1.00'),
                                         currency='GBP',
                                         account=dest_account,
                                         charges=paymul.CHARGES_PAYEE,
                                         means=paymul.MEANS_PRIORITY_PAYMENT,
                                         channel=paymul.CHANNEL_INTRA_COMPANY,
                                         name_address="SOME BANK PLC\n"
                                         "HSBC NET TEST\n"
                                         "TEST\n"
                                         "TEST\n"
                                         "UNITED KINGDOM",
                                         customer_reference='CRUKHV5',
                                         payment_reference='PQUKHV5')

        batch = paymul.Batch(exec_date=datetime.date(2004, 11, 12),
                             reference='UKHIGHVALUE',
                             debit_account=src_account,
                             name_address="HSBC BANK PLC\n"
                             "HSBC NET TEST\n"
                             "TEST\n"
                             "TEST\n"
                             "UNITED KINGDOM")
        batch.transactions.append(transaction)

        message = paymul.Message(reference='UKHIGHVALUE',
                                 dt=datetime.datetime(2004, 11, 11))
        message.batches.append(batch)

        interchange = paymul.Interchange(client_id='ABC00000001',
                                         reference='UKHIGHVALUE',
                                         create_dt=datetime.datetime(
                                             2004, 11, 11, 15, 00),
                                         message=message)

        self.assertMultiLineEqual(expected, str(interchange))
Exemple #2
0
    def test_ezone(self):
        # Changes from example in spec: Changed CNT from 27 to 39, because we
        # only generate that and it makes no difference which one we use
        # Removed DTM for transaction, HSBC ignores it (section 2.8.3)

        expected = """UNB+UNOA:3+::ABC12016001+::HEXAGON ABC+080110:0856+EZONE'
UNH+1+PAYMUL:D:96A:UN:FUN01G'
BGM+452+EZONE+9'
DTM+137:20080110:102'
LIN+1'
DTM+203:20080114:102'
RFF+AEK:EZONE'
MOA+9:1.00:EUR'
FII+OR+12345678:ACCOUNT HOLDER NAME::EUR+:::403124:154:133+GB'
NAD+OY++ORD PARTY NAME NADOY 01:CRG TC5 001 NADOY ADDRESS LINE 0001:CRG TC5 \
1001 NADOY ADDRESS LINE 0002'
SEQ++1'
MOA+9:1.00:EUR'
RFF+CR:EZONE 1A'
RFF+PQ:EZONE 1A'
PAI+::2'
FCA+14'
FII+BF+DE23300308800099990031:CRG TC5 001 BENE NAME FIIBF \
000001::EUR+AACSDE33:25:5:::+DE'
NAD+BE+++BENE NAME NADBE T1 001:CRG TC5 001T1 NADBE ADD LINE 1 0001:CRG TC5 \
001T1 NADBE ADD LINE 2 0001'
CNT+39:1'
UNT+19+1'
UNZ+1+EZONE'"""

        src_account = paymul.UKAccount(number=12345678,
                                       holder='ACCOUNT HOLDER NAME',
                                       currency='EUR',
                                       sortcode=403124)

        dest_account = paymul.IBANAccount(
            iban="DE23300308800099990031",
            holder="CRG TC5 001 BENE NAME FIIBF 000001",
            currency='EUR',
            bic="AACSDE33")

        party_name = ("BENE NAME NADBE T1 001\n"
                      "CRG TC5 001T1 NADBE ADD LINE 1 0001\n"
                      "CRG TC5 001T1 NADBE ADD LINE 2 0001")
        transaction = paymul.Transaction(amount=Decimal('1.00'),
                                         currency='EUR',
                                         account=dest_account,
                                         party_name=party_name,
                                         charges=paymul.CHARGES_EACH_OWN,
                                         means=paymul.MEANS_EZONE,
                                         customer_reference='EZONE 1A',
                                         payment_reference='EZONE 1A')

        name_address = ("ORD PARTY NAME NADOY 01\n"
                        "CRG TC5 001 NADOY ADDRESS LINE 0001\n"
                        "CRG TC5 001 NADOY ADDRESS LINE 0002")
        batch = paymul.Batch(exec_date=datetime.date(2008, 1, 14),
                             reference='EZONE',
                             debit_account=src_account,
                             name_address=name_address)
        batch.transactions.append(transaction)

        message = paymul.Message(reference='EZONE',
                                 dt=datetime.datetime(2008, 1, 10))
        message.batches.append(batch)

        interchange = paymul.Interchange(client_id='ABC12016001',
                                         reference='EZONE',
                                         create_dt=datetime.datetime(
                                             2008, 1, 10, 8, 56),
                                         message=message)

        self.assertMultiLineEqual(expected, str(interchange))
Exemple #3
0
    def test_uk_low_value_ach_instruction_level(self):
        dest_account1 = paymul.UKAccount(number=87654321,
                                         holder="HSBC NET RPS TEST\nHSBC BANK",
                                         currency='GBP',
                                         sortcode=403124)
        name_address = ("HSBC BANK PLC\n"
                        "PCM\n"
                        "8CS37\n"
                        "E14 5HQ\n"
                        "UNITED KINGDOM")
        transaction1 = paymul.Transaction(amount=Decimal('1.00'),
                                          currency='GBP',
                                          account=dest_account1,
                                          name_address=name_address,
                                          charges=paymul.CHARGES_PAYEE,
                                          means=paymul.MEANS_ACH,
                                          customer_reference='CREDIT',
                                          payment_reference='CREDIT')

        dest_account2 = paymul.UKAccount(number=12341234,
                                         holder="HSBC NET RPS TEST\nHSBC BANK",
                                         currency='GBP',
                                         sortcode=403124)
        name_address = ("HSBC BANK PLC\n"
                        "PCM\n"
                        "8CS37\n"
                        "E14 5HQ\n"
                        "UNITED KINGDOM")
        transaction2 = paymul.Transaction(amount=Decimal('1.00'),
                                          currency='GBP',
                                          account=dest_account2,
                                          name_address=name_address,
                                          charges=paymul.CHARGES_PAYEE,
                                          means=paymul.MEANS_ACH,
                                          customer_reference='CREDIT1',
                                          payment_reference='CREDIT1')

        name_address = ("HSBC BANK PLC\n"
                        "PCM\n"
                        "8CS37\n"
                        "E14 5HQ\n"
                        "UNITED KINGDOM")

        src_account = paymul.UKAccount(number=12345678,
                                       holder='BHEX RPS TEST',
                                       currency='GBP',
                                       sortcode=401234)
        batch = paymul.Batch(exec_date=datetime.date(2004, 11, 15),
                             reference='UKLVPLIL',
                             debit_account=src_account,
                             name_address=name_address)
        batch.transactions = [transaction1, transaction2]

        message = paymul.Message(reference='UKLVPLIL',
                                 dt=datetime.datetime(2004, 11, 11))
        message.batches.append(batch)

        interchange = paymul.Interchange(client_id='ABC00000001',
                                         reference='UKLVPLIL',
                                         create_dt=datetime.datetime(
                                             2004, 11, 11, 15, 0),
                                         message=message)

        # Changes from example:
        # * Change second transaction from EUR to GBP, because we don't support
        #   multi-currency batches
        # * Removed DTM for transaction, HSBC ignores it (section 2.8.3)
        expected = """\
UNB+UNOA:3+::ABC00000001+::HEXAGON ABC+041111:1500+UKLVPLIL'
UNH+1+PAYMUL:D:96A:UN:FUN01G'
BGM+452+UKLVPLIL+9'
DTM+137:20041111:102'
LIN+1'
DTM+203:20041115:102'
RFF+AEK:UKLVPLIL'
MOA+9:2.00:GBP'
FII+OR+12345678:BHEX RPS TEST::GBP+:::401234:154:133+GB'
NAD+OY++HSBC BANK PLC:PCM:8CS37:E14 5HQ:UNITED KINGDOM'
SEQ++1'
MOA+9:1.00:GBP'
RFF+CR:CREDIT'
RFF+PQ:CREDIT'
PAI+::2'
FCA+13'
FII+BF+87654321:HSBC NET RPS TEST:HSBC BANK:GBP+:::403124:154:133+GB'
NAD+BE++HSBC BANK PLC:PCM:8CS37:E14 5HQ:UNITED KINGDOM'
SEQ++2'
MOA+9:1.00:GBP'
RFF+CR:CREDIT1'
RFF+PQ:CREDIT1'
PAI+::2'
FCA+13'
FII+BF+12341234:HSBC NET RPS TEST:HSBC BANK:GBP+:::403124:154:133+GB'
NAD+BE++HSBC BANK PLC:PCM:8CS37:E14 5HQ:UNITED KINGDOM'
CNT+39:2'
UNT+27+1'
UNZ+1+UKLVPLIL'"""

        self.assertMultiLineEqual(expected, str(interchange))
Exemple #4
0
    def _create_account(self,
                        oe_account,
                        origin_country=None,
                        is_origin_account=False):
        # let the receiving bank select the currency from the batch
        currency = None
        holder = oe_account.owner_name or oe_account.partner_id.name
        self.logger.info('Create account %s' % (holder))
        self.logger.info('-- %s' % (oe_account.country_id.code))
        self.logger.info('-- %s' % (oe_account.acc_number))

        if oe_account.state == 'iban':
            self.logger.info('IBAN: %s' % (oe_account.acc_number))
            paymul_account = paymul.IBANAccount(
                iban=oe_account.acc_number,
                bic=oe_account.bank.bic,
                holder=holder,
                currency=currency,
            )
            transaction_kwargs = {
                'charges': paymul.CHARGES_EACH_OWN,
            }
        elif oe_account.country_id.code == 'GB':
            self.logger.info(
                'GB: %s %s' %
                (oe_account.country_id.code, oe_account.acc_number))
            split = oe_account.acc_number.split(" ", 2)
            if len(split) == 2:
                sortcode, accountno = split
            else:
                raise orm.except_orm(
                    _('Error'),
                    "Invalid GB acccount number '%s'" % oe_account.acc_number)
            paymul_account = paymul.UKAccount(
                number=accountno,
                sortcode=sortcode,
                holder=holder,
                currency=currency,
            )
            transaction_kwargs = {
                'charges': paymul.CHARGES_PAYEE,
            }
        elif oe_account.country_id.code in ('US', 'CA'):
            self.logger.info(
                'US/CA: %s %s' %
                (oe_account.country_id.code, oe_account.acc_number))
            split = oe_account.acc_number.split(' ', 2)
            if len(split) == 2:
                sortcode, accountno = split
            else:
                raise orm.except_orm(
                    _('Error'),
                    _("Invalid %s account number '%s'") %
                    (oe_account.country_id.code, oe_account.acc_number))
            paymul_account = paymul.NorthAmericanAccount(
                number=accountno,
                sortcode=sortcode,
                holder=holder,
                currency=currency,
                swiftcode=oe_account.bank.bic,
                country=oe_account.country_id.code,
                origin_country=origin_country,
                is_origin_account=is_origin_account)
            transaction_kwargs = {
                'charges': paymul.CHARGES_PAYEE,
            }
            transaction_kwargs = {
                'charges': paymul.CHARGES_PAYEE,
            }
        else:
            self.logger.info('SWIFT Account: %s' % oe_account.country_id.code)
            split = oe_account.acc_number.split(' ', 2)
            if len(split) == 2:
                sortcode, accountno = split
            else:
                raise orm.except_orm(
                    _('Error'),
                    _("Invalid %s account number '%s'") %
                    (oe_account.country_id.code, oe_account.acc_number))
            paymul_account = paymul.SWIFTAccount(
                number=accountno,
                sortcode=sortcode,
                holder=holder,
                currency=currency,
                swiftcode=oe_account.bank.bic,
                country=oe_account.country_id.code,
            )
            transaction_kwargs = {
                'charges': paymul.CHARGES_PAYEE,
            }
            transaction_kwargs = {
                'charges': paymul.CHARGES_PAYEE,
            }

        return paymul_account, transaction_kwargs