You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2018-TODAY ACSONE SA/NV (<https://www.acsone.eu>).
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import odoo
  5. class TestTransactions(odoo.tests.TransactionCase):
  6. def test_matching(self):
  7. card_journal_id = self.env['account.journal'].create({
  8. 'name': 'Card Journal',
  9. 'code': 'CARD',
  10. 'type': 'bank',
  11. 'payment_mode': 'card',
  12. }).id
  13. cash_journal_id = 0
  14. pos_order = {
  15. 'statement_ids': [
  16. (0, 0, {
  17. 'name': 'Payment1',
  18. 'amount': 45.2,
  19. 'journal_id': card_journal_id,
  20. }),
  21. (0, 0, {
  22. 'name': 'Payment2',
  23. 'amount': 10.5,
  24. 'journal_id': card_journal_id,
  25. }),
  26. (0, 0, {
  27. 'name': 'Payment3',
  28. 'amount': 22.0,
  29. 'journal_id': cash_journal_id,
  30. }),
  31. ],
  32. 'transactions': [
  33. {
  34. 'reference': 'ABCDE',
  35. 'amount_cents': 1050,
  36. },
  37. {
  38. 'reference': 'XPTO',
  39. 'amount_cents': 4520,
  40. },
  41. ]
  42. }
  43. self.env['pos.order']._match_transactions_to_payments(pos_order)
  44. self.assertEquals(pos_order['statement_ids'][0][2]['note'], 'XPTO')
  45. self.assertEquals(pos_order['statement_ids'][1][2]['note'], 'ABCDE')