Files
odoo_source/addons/account/tests/test_payment_term.py
T
fw-bot df5dde330c [FIX] account: allow full reconciliation for tax lines on entries mixing cash basis and regular taxes
Solves https://github.com/odoo/odoo/issues/56803

Use case:

1) Create accounts ACC TAX A, ACC TAX B, with reconcile = True, internal_type = other

2) Create Tax A, with tax_exigibilty = on_invoice and account_id = ACC TAX A, 20%

3) Create Tax B, with tax_exigibilty = on_payment and account_id = ACC TAX B and cash_basic_account_id = ACC TAX A, 20%

4) Create invoice A, account_id = Tax A, unit_price = 1000, Valide invoice

5) Create invoice B, account_id = Tax B, unit_price = 500, Valide invoice,

6) Register full payment for invoice B. The cash basis tax creates a miscellaneous operation MISC A, containing a line on ACC TAX A.

7) Create a mis operation MISC TVA, like this:
line 1 : account_id = ACC TAX A, credit = 300
line 2 : account_id = 401100, debit = 300

8) Reconcile the following move lines:
line of MISC A with account ACC TAX A (300)
line of invoice A with account ACC TAX A (200)
line of MISC TVA with account ACC TAX A (100)

==> When doing that, not full reconcile object was created between the reconciled lines, while it should have been.

X-original-commit: ff35a49

[IMP] account: reintroduce a test that should have been forward-ported …

This test was made together with a bugfix by https://github.com/odoo/odoo/pull/51529 . The fix did not need to be forward-ported to 13.0, but the test should have been, so that we are sure it does not break again in the future.

closes odoo/odoo#58072

X-original-commit: 5d00592f7d803888d8d5befd5a8cd1b096067860
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2020-09-18 17:34:46 +00:00

99 lines
4.1 KiB
Python

# -*- coding: utf-8 -*-
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.tests import tagged
from odoo import fields
from odoo.tests.common import Form
@tagged('post_install', '-at_install')
class TestAccountInvoiceRounding(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.pay_term_today = cls.env['account.payment.term'].create({
'name': 'Today',
'line_ids': [
(0, 0, {
'value': 'balance',
'days': 0,
'option': 'day_after_invoice_date',
}),
],
})
cls.pay_term_min_31days_15th = cls.env['account.payment.term'].create({
'name': 'the 15th of the month, min 31 days from now',
'line_ids': [
(0, 0, {
'value': 'balance',
'days': 31,
'day_of_the_month': 15,
'option': 'day_after_invoice_date',
}),
],
})
cls.pay_term_45_end_month = cls.env['account.payment.term'].create({
'name': '45 Days from End of Month',
'line_ids': [
(0, 0, {
'value': 'balance',
'days': 45,
'option': 'after_invoice_month',
}),
],
})
cls.pay_term_last_day_of_month = cls.env['account.payment.term'].create({
'name': 'Last Day of month',
'line_ids': [
(0, 0, {
'value': 'balance',
'days': 31,
'option': 'day_current_month',
}),
],
})
cls.pay_term_first_day_next_month = cls.env['account.payment.term'].create({
'name': 'First day next month',
'line_ids': [
(0, 0, {
'value': 'balance',
'days': 1,
'option': 'day_following_month',
}),
],
})
cls.invoice = cls.init_invoice('out_refund', products=cls.product_a+cls.product_b)
def assertPaymentTerm(self, pay_term, invoice_date, dates):
with Form(self.invoice) as move_form:
move_form.invoice_payment_term_id = pay_term
move_form.invoice_date = invoice_date
self.assertEqual(
self.invoice.line_ids.filtered(
lambda l: l.account_id == self.company_data['default_account_receivable']
).mapped('date_maturity'),
[fields.Date.from_string(date) for date in dates],
)
def test_payment_term(self):
self.assertPaymentTerm(self.pay_term_today, '2019-01-01', ['2019-01-01'])
self.assertPaymentTerm(self.pay_term_today, '2019-01-15', ['2019-01-15'])
self.assertPaymentTerm(self.pay_term_today, '2019-01-31', ['2019-01-31'])
self.assertPaymentTerm(self.pay_term_45_end_month, '2019-01-01', ['2019-03-17'])
self.assertPaymentTerm(self.pay_term_45_end_month, '2019-01-15', ['2019-03-17'])
self.assertPaymentTerm(self.pay_term_45_end_month, '2019-01-31', ['2019-03-17'])
self.assertPaymentTerm(self.pay_term_min_31days_15th, '2019-01-01', ['2019-02-15'])
self.assertPaymentTerm(self.pay_term_min_31days_15th, '2019-01-15', ['2019-02-15'])
self.assertPaymentTerm(self.pay_term_min_31days_15th, '2019-01-31', ['2019-03-15'])
self.assertPaymentTerm(self.pay_term_last_day_of_month, '2019-01-01', ['2019-01-31'])
self.assertPaymentTerm(self.pay_term_last_day_of_month, '2019-01-15', ['2019-01-31'])
self.assertPaymentTerm(self.pay_term_last_day_of_month, '2019-01-31', ['2019-01-31'])
self.assertPaymentTerm(self.pay_term_first_day_next_month, '2019-01-01', ['2019-02-01'])
self.assertPaymentTerm(self.pay_term_first_day_next_month, '2019-01-15', ['2019-02-01'])
self.assertPaymentTerm(self.pay_term_first_day_next_month, '2019-01-31', ['2019-02-01'])