Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions account_caba_payment_date/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
=========================
Account CABA Payment Date
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9c7e59147d182b4debe2d4dc4d06c29c40b8f038f5e6069c14c20933271fc4be
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--payment-lightgray.png?logo=github
:target: https://github.com/OCA/account-payment/tree/17.0/account_caba_payment_date
:alt: OCA/account-payment
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-payment-17-0/account-payment-17-0-account_caba_payment_date
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-payment&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module sets the date of the tax cash basis (CABA) journal entry to
the real payment date instead of the date Odoo chooses.

Standard Odoo dates the cash basis entry with the newest date of the
reconciled entries, and, when that date falls in a locked period, with
the date of the day the reconciliation is done. This shifts the cash
basis taxes (e.g. VAT effectively paid) to a fiscal month different from
the payment month, which is not acceptable in countries where those
taxes are due on the payment date (e.g. Mexico).

With this module the cash basis entry is always dated on the date of the
bank/cash entry of the reconciliation. When that date falls in a locked
period, the behavior is configurable per company:

- **Block the reconciliation** (default): raise an error asking to
reopen the period.
- **Use the first open date**: date the entry on the first day after the
lock date.
- **Keep the standard behavior**: let Odoo date the entry on the
reconciliation date.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure the behavior when the payment date falls in a locked
period:

1. Go to *Accounting > Configuration > Settings*.
2. In the *Taxes* section, under *Cash Basis*, select the *Cash Basis
Lock Policy*:

- *Block the reconciliation* (default)
- *Use the first open date*
- *Keep the standard behavior*

Usage
=====

- Create an invoice with a cash basis tax and register the payment.
- The generated cash basis entry is dated on the payment date, even if
the invoice or the reconciliation has a different date.
- If the payment date falls in a locked period, the configured lock
policy is applied (by default the reconciliation is blocked with an
explanatory error).

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-payment/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-payment/issues/new?body=module:%20account_caba_payment_date%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Jarsa

Contributors
------------

- `Jarsa <https://www.jarsa.com>`__:

- Alan Ramos <alan.ramos@jarsa.com>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-alan196| image:: https://github.com/alan196.png?size=40px
:target: https://github.com/alan196
:alt: alan196

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-alan196|

This module is part of the `OCA/account-payment <https://github.com/OCA/account-payment/tree/17.0/account_caba_payment_date>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions account_caba_payment_date/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 Jarsa (https://www.jarsa.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from . import models
17 changes: 17 additions & 0 deletions account_caba_payment_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Jarsa (https://www.jarsa.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

{
"name": "Account CABA Payment Date",
"version": "17.0.1.0.0",
"author": "Jarsa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-payment",
"license": "LGPL-3",
"category": "Accounting & Finance",
"summary": "Set CABA date based on payment date",
"depends": ["account"],
"data": ["views/res_config_settings_views.xml"],
"installable": True,
"development_status": "Alpha",
"maintainers": ["alan196"],
}
6 changes: 6 additions & 0 deletions account_caba_payment_date/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2024 Jarsa (https://www.jarsa.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from . import account_partial_reconcile
from . import res_company
from . import res_config_settings
68 changes: 68 additions & 0 deletions account_caba_payment_date/models/account_partial_reconcile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright 2024 Jarsa (https://www.jarsa.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from datetime import date as date_lib
from datetime import timedelta

from odoo import _, models
from odoo.exceptions import UserError


class AccountPartialReconcile(models.Model):
_inherit = "account.partial.reconcile"

def _caba_get_payment_date(self):
"""Return the real payment date of the reconciliation: the date of the
bank/cash journal entry when there is one, the newest date otherwise."""
self.ensure_one()
for line in (self.debit_move_id, self.credit_move_id):
if line.journal_id.type in ("bank", "cash"):
return line.date
return self.max_date

def _create_tax_cash_basis_moves(self):
moves = super()._create_tax_cash_basis_moves()
for move in moves:
partial = move.tax_cash_basis_rec_id
if not partial:
continue
date = partial._caba_get_payment_date()
# The tax lock date also applies: the cash basis entry affects the
# tax report, so it cannot be dated inside a tax-locked period.
lock_date = max(
move.company_id._get_user_fiscal_lock_date(),
move.company_id.max_tax_lock_date or date_lib.min,
)
if date <= lock_date:
policy = move.company_id.caba_payment_date_lock_policy
if policy == "standard":
continue
if policy == "next_open":
date = lock_date + timedelta(days=1)
else: # block
raise UserError(
_(
"The cash basis entry of this reconciliation must be "
"dated on the payment date %(date)s, but that period "
"is locked "
"(lock date: %(lock_date)s).\n"
"Reopen the period, or change the cash basis lock policy "
"in the accounting settings.",
date=date,
lock_date=lock_date,
)
)
if date != move.date:
month_changed = (date.year, date.month) != (
move.date.year,
move.date.month,
)
vals = {"date": date}
if month_changed:
# Clear the name so the date-sequence constraint does not
# reject the write, then resequence for the new period.
vals["name"] = False
move.write(vals)
if month_changed:
move._compute_name()
return moves
25 changes: 25 additions & 0 deletions account_caba_payment_date/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2026 Jarsa (https://www.jarsa.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

caba_payment_date_lock_policy = fields.Selection(
[
("block", "Block the reconciliation"),
("next_open", "Use the first open date"),
("standard", "Keep the standard behavior"),
],
default="block",
required=True,
string="Cash Basis Lock Policy",
help="What to do when the payment date of a cash basis entry falls in a "
"locked period:\n"
"- Block the reconciliation: raise an error asking to reopen the period.\n"
"- Use the first open date: date the entry on the first day after the lock.\n"
"- Keep the standard behavior: let Odoo date the entry on the "
"reconciliation date.",
)
13 changes: 13 additions & 0 deletions account_caba_payment_date/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2026 Jarsa (https://www.jarsa.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

caba_payment_date_lock_policy = fields.Selection(
related="company_id.caba_payment_date_lock_policy",
readonly=False,
)
3 changes: 3 additions & 0 deletions account_caba_payment_date/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
8 changes: 8 additions & 0 deletions account_caba_payment_date/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To configure the behavior when the payment date falls in a locked period:

1. Go to *Accounting \> Configuration \> Settings*.
2. In the *Taxes* section, under *Cash Basis*, select the *Cash Basis Lock
Policy*:
- *Block the reconciliation* (default)
- *Use the first open date*
- *Keep the standard behavior*
2 changes: 2 additions & 0 deletions account_caba_payment_date/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Jarsa](https://www.jarsa.com):
- Alan Ramos \<<alan.ramos@jarsa.com>\>
20 changes: 20 additions & 0 deletions account_caba_payment_date/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
This module sets the date of the tax cash basis (CABA) journal entry to the
real payment date instead of the date Odoo chooses.

Standard Odoo dates the cash basis entry with the newest date of the
reconciled entries, and, when that date falls in a locked period, with the
date of the day the reconciliation is done. This shifts the cash basis
taxes (e.g. VAT effectively paid) to a fiscal month different from the
payment month, which is not acceptable in countries where those taxes are
due on the payment date (e.g. Mexico).

With this module the cash basis entry is always dated on the date of the
bank/cash entry of the reconciliation. When that date falls in a locked
period, the behavior is configurable per company:

- **Block the reconciliation** (default): raise an error asking to reopen
the period.
- **Use the first open date**: date the entry on the first day after the
lock date.
- **Keep the standard behavior**: let Odoo date the entry on the
reconciliation date.
6 changes: 6 additions & 0 deletions account_caba_payment_date/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Create an invoice with a cash basis tax and register the payment.
- The generated cash basis entry is dated on the payment date, even if the
invoice or the reconciliation has a different date.
- If the payment date falls in a locked period, the configured lock policy
is applied (by default the reconciliation is blocked with an explanatory
error).
Loading
Loading