[TEST] point_of_sale: test fixed tax included
After a fix made in rev:bd621fd456811e7f3ce646e3ecade5e9e4a826e8 It was not possible to generate an invoice from the POS when you have a fixed tax included applied on a base amount with tax included. As it was not detected by a test, we are now creating a test with this use case. closes odoo/odoo#92106 X-original-commit: 291b564ffebaf8b8708072c981d1072b8bb33677 Signed-off-by: Masereel Pierre <pim@odoo.com>
This commit is contained in:
@@ -382,6 +382,7 @@ class TestPoSCommon(ValuationReconciliationTestCommon):
|
||||
'name': f'Tax {percentage}%',
|
||||
'amount': percentage,
|
||||
'price_include': price_include,
|
||||
'amount_type': 'percent',
|
||||
'include_base_amount': False,
|
||||
'invoice_repartition_line_ids': [
|
||||
(0, 0, {
|
||||
@@ -410,11 +411,48 @@ class TestPoSCommon(ValuationReconciliationTestCommon):
|
||||
}),
|
||||
],
|
||||
})
|
||||
def create_tax_fixed(amount, price_include=False):
|
||||
return cls.env['account.tax'].create({
|
||||
'name': f'Tax fixed amount {amount}',
|
||||
'amount': amount,
|
||||
'price_include': price_include,
|
||||
'include_base_amount': price_include,
|
||||
'amount_type': 'fixed',
|
||||
'invoice_repartition_line_ids': [
|
||||
(0, 0, {
|
||||
'factor_percent': 100,
|
||||
'repartition_type': 'base',
|
||||
'tag_ids': [(6, 0, cls.tax_tag_invoice_base.ids)],
|
||||
}),
|
||||
(0, 0, {
|
||||
'factor_percent': 100,
|
||||
'repartition_type': 'tax',
|
||||
'account_id': cls.tax_received_account.id,
|
||||
'tag_ids': [(6, 0, cls.tax_tag_invoice_tax.ids)],
|
||||
}),
|
||||
],
|
||||
'refund_repartition_line_ids': [
|
||||
(0, 0, {
|
||||
'factor_percent': 100,
|
||||
'repartition_type': 'base',
|
||||
'tag_ids': [(6, 0, cls.tax_tag_refund_base.ids)],
|
||||
}),
|
||||
(0, 0, {
|
||||
'factor_percent': 100,
|
||||
'repartition_type': 'tax',
|
||||
'account_id': cls.tax_received_account.id,
|
||||
'tag_ids': [(6, 0, cls.tax_tag_refund_tax.ids)],
|
||||
}),
|
||||
],
|
||||
})
|
||||
|
||||
tax_fixed006 = create_tax_fixed(0.06, price_include=True)
|
||||
tax_fixed012 = create_tax_fixed(0.12, price_include=True)
|
||||
tax7 = create_tax(7, price_include=False)
|
||||
tax10 = create_tax(10, price_include=True)
|
||||
tax21 = create_tax(21, price_include=True)
|
||||
|
||||
|
||||
tax_group_7_10 = tax7.copy()
|
||||
with Form(tax_group_7_10) as tax:
|
||||
tax.name = 'Tax 7+10%'
|
||||
@@ -426,6 +464,8 @@ class TestPoSCommon(ValuationReconciliationTestCommon):
|
||||
'tax7': tax7,
|
||||
'tax10': tax10,
|
||||
'tax21': tax21,
|
||||
'tax_fixed006': tax_fixed006,
|
||||
'tax_fixed012': tax_fixed012,
|
||||
'tax_group_7_10': tax_group_7_10
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,12 @@ class TestPoSProductsWithTax(TestPoSCommon):
|
||||
15.0,
|
||||
tax_ids=self.taxes['tax_group_7_10'].ids,
|
||||
)
|
||||
self.product4 = self.create_product(
|
||||
'Product 4',
|
||||
self.categ_basic,
|
||||
54.99,
|
||||
tax_ids=[self.taxes['tax_fixed006'].id, self.taxes['tax_fixed012'].id, self.taxes['tax21'].id],
|
||||
)
|
||||
self.adjust_inventory([self.product1, self.product2, self.product3], [100, 50, 50])
|
||||
|
||||
def test_orders_no_invoiced(self):
|
||||
@@ -144,15 +150,15 @@ class TestPoSProductsWithTax(TestPoSCommon):
|
||||
|
||||
def _before_closing_cb():
|
||||
# check values before closing the session
|
||||
self.assertEqual(3, self.pos_session.order_count)
|
||||
self.assertEqual(4, self.pos_session.order_count)
|
||||
orders_total = sum(order.amount_total for order in self.pos_session.order_ids)
|
||||
self.assertAlmostEqual(orders_total, self.pos_session.total_payments_amount, msg='Total order amount should be equal to the total payment amount.')
|
||||
|
||||
# check account move in the invoiced order
|
||||
invoiced_order = self.pos_session.order_ids.filtered(lambda order: '09876-098-0987' in order.pos_reference)
|
||||
self.assertEqual(1, len(invoiced_order), 'Only one order is invoiced in this test.')
|
||||
invoice = invoiced_order.account_move
|
||||
self.assertAlmostEqual(invoice.amount_total, 426.09)
|
||||
invoiced_orders = self.pos_session.order_ids.filtered(lambda order: order.is_invoiced)
|
||||
self.assertEqual(2, len(invoiced_orders), 'Only one order is invoiced in this test.')
|
||||
invoices = invoiced_orders.mapped('account_move')
|
||||
self.assertAlmostEqual(sum(invoices.mapped('amount_total')), 481.08)
|
||||
|
||||
def _after_closing_cb():
|
||||
session_move = self.pos_session.move_id
|
||||
@@ -172,6 +178,7 @@ class TestPoSProductsWithTax(TestPoSCommon):
|
||||
{'pos_order_lines_ui_args': [(self.product3, 1), (self.product1, 6), (self.product2, 3)], 'uid': '00100-010-0001'},
|
||||
{'pos_order_lines_ui_args': [(self.product2, 20), (self.product1, 1)], 'payments': [(self.bank_pm1, 410.7)], 'uid': '00100-010-0002'},
|
||||
{'pos_order_lines_ui_args': [(self.product1, 10), (self.product3, 10)], 'payments': [(self.bank_pm1, 426.09)], 'customer': self.customer, 'is_invoiced': True, 'uid': '09876-098-0987'},
|
||||
{'pos_order_lines_ui_args': [(self.product4, 1)], 'payments': [(self.bank_pm1, 54.99)], 'customer': self.customer, 'is_invoiced': True, 'uid': '00100-010-0004'},
|
||||
],
|
||||
'before_closing_cb': _before_closing_cb,
|
||||
'journal_entries_before_closing': {
|
||||
@@ -185,6 +192,16 @@ class TestPoSProductsWithTax(TestPoSCommon):
|
||||
}),
|
||||
],
|
||||
},
|
||||
'00100-010-0004': {
|
||||
'payments': [
|
||||
((self.bank_pm1, 54.99), {
|
||||
'line_ids': [
|
||||
{'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 54.99, 'reconciled': True},
|
||||
{'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 54.99, 'credit': 0, 'reconciled': False},
|
||||
]
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
'after_closing_cb': _after_closing_cb,
|
||||
'journal_entries_after_closing': {
|
||||
@@ -195,9 +212,9 @@ class TestPoSProductsWithTax(TestPoSCommon):
|
||||
{'account_id': self.sales_account.id, 'partner_id': False, 'debit': 0, 'credit': 27.27, 'reconciled': False},
|
||||
{'account_id': self.sales_account.id, 'partner_id': False, 'debit': 0, 'credit': 70, 'reconciled': False},
|
||||
{'account_id': self.sales_account.id, 'partner_id': False, 'debit': 0, 'credit': 418.19, 'reconciled': False},
|
||||
{'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 836.79, 'credit': 0, 'reconciled': True},
|
||||
{'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 891.78, 'credit': 0, 'reconciled': True},
|
||||
{'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 156.11, 'credit': 0, 'reconciled': True},
|
||||
{'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 426.09, 'reconciled': True},
|
||||
{'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 481.08, 'reconciled': True},
|
||||
],
|
||||
},
|
||||
'cash_statement': [
|
||||
@@ -209,10 +226,10 @@ class TestPoSProductsWithTax(TestPoSCommon):
|
||||
}),
|
||||
],
|
||||
'bank_payments': [
|
||||
((836.79, ), {
|
||||
((891.78, ), {
|
||||
'line_ids': [
|
||||
{'account_id': self.bank_pm1.outstanding_account_id.id, 'partner_id': False, 'debit': 836.79, 'credit': 0, 'reconciled': False},
|
||||
{'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 836.79, 'reconciled': True},
|
||||
{'account_id': self.bank_pm1.outstanding_account_id.id, 'partner_id': False, 'debit': 891.78, 'credit': 0, 'reconciled': False},
|
||||
{'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 891.78, 'reconciled': True},
|
||||
]
|
||||
}),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user