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.7 KiB

  1. # Copyright (C) 2018-TODAY ACSONE SA/NV (<https://www.acsone.eu>).
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo.addons.point_of_sale.tests.common import TestPointOfSaleCommon
  4. class TestTransactions(TestPointOfSaleCommon):
  5. def test_matching(self):
  6. card_journal_id = self.env['account.journal'].create({
  7. 'name': 'Card Journal',
  8. 'code': 'CARD',
  9. 'type': 'bank',
  10. 'pos_terminal_payment_mode': 'card',
  11. }).id
  12. cash_journal_id = 0
  13. pos_order = {
  14. 'pos_session_id': self.pos_order_session0.id,
  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')