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.

50 lines
1.7 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. from odoo.addons.point_of_sale.tests.common import TestPointOfSaleCommon
  5. class TestTransactions(TestPointOfSaleCommon):
  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. 'pos_session_id': self.pos_order_session0.id,
  16. 'statement_ids': [
  17. (0, 0, {
  18. 'name': 'Payment1',
  19. 'amount': 45.2,
  20. 'journal_id': card_journal_id,
  21. }),
  22. (0, 0, {
  23. 'name': 'Payment2',
  24. 'amount': 10.5,
  25. 'journal_id': card_journal_id,
  26. }),
  27. (0, 0, {
  28. 'name': 'Payment3',
  29. 'amount': 22.0,
  30. 'journal_id': cash_journal_id,
  31. }),
  32. ],
  33. 'transactions': [
  34. {
  35. 'reference': 'ABCDE',
  36. 'amount_cents': 1050,
  37. },
  38. {
  39. 'reference': 'XPTO',
  40. 'amount_cents': 4520,
  41. },
  42. ]
  43. }
  44. self.env['pos.order']._match_transactions_to_payments(pos_order)
  45. self.assertEquals(pos_order['statement_ids'][0][2]['note'], 'XPTO')
  46. self.assertEquals(pos_order['statement_ids'][1][2]['note'], 'ABCDE')