Ejemplo n.º 1
0
 def _convert_to_models(self, statement: BankStatement) -> Iterable[BankPayment]:
     account_number = statement.account_number
     try:
         account = BankAccount.objects.get(account_number=account_number)
     except BankAccount.DoesNotExist:
         raise CommandError('Bank account {} does not exist.'.format(account_number))
     payments = []
     for payment_data in statement:
         payment = BankPayment.from_payment_data_class(payment_data)
         payment.account = account
         payments.append(payment)
     return payments
Ejemplo n.º 2
0
    def test_from_payment_data_class_blank_values(self):
        payment_data = Payment()
        payment_data.identifier = 'abc123'
        payment_data.transaction_date = date(2020, 9, 1)
        payment_data.counter_account = None
        payment_data.name = None
        payment_data.amount = Money(1, 'CZK')
        payment_data.description = None
        payment_data.constant_symbol = None
        payment_data.variable_symbol = None
        payment_data.specific_symbol = None

        model = BankPayment.from_payment_data_class(payment_data)

        self.assertEqual(model.identifier, payment_data.identifier)
        self.assertEqual(model.transaction_date, payment_data.transaction_date)
        self.assertEqual(model.counter_account_number, '')
        self.assertEqual(model.counter_account_name, '')
        self.assertEqual(model.amount, payment_data.amount)
        self.assertEqual(model.description, '')
        self.assertEqual(model.constant_symbol, '')
        self.assertEqual(model.variable_symbol, '')
        self.assertEqual(model.specific_symbol, '')
Ejemplo n.º 3
0
    def test_from_payment_data_class(self):
        payment_data = Payment()
        payment_data.identifier = 'abc123'
        payment_data.transaction_date = date(2020, 9, 1)
        payment_data.counter_account = '12345/678'
        payment_data.name = 'John Doe'
        payment_data.amount = Money(1, 'CZK')
        payment_data.description = 'Hello!'
        payment_data.constant_symbol = '123'
        payment_data.variable_symbol = '456'
        payment_data.specific_symbol = '789'

        model = BankPayment.from_payment_data_class(payment_data)

        self.assertEqual(model.identifier, payment_data.identifier)
        self.assertEqual(model.transaction_date, payment_data.transaction_date)
        self.assertEqual(model.counter_account_number,
                         payment_data.counter_account)
        self.assertEqual(model.counter_account_name, payment_data.name)
        self.assertEqual(model.amount, payment_data.amount)
        self.assertEqual(model.description, payment_data.description)
        self.assertEqual(model.constant_symbol, payment_data.constant_symbol)
        self.assertEqual(model.variable_symbol, payment_data.variable_symbol)
        self.assertEqual(model.specific_symbol, payment_data.specific_symbol)