Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] account_payment_batch_process_discount #697

111 changes: 111 additions & 0 deletions account_payment_batch_process_discount/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
==========================
Discount on batch payments
==========================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--payment-lightgray.png?logo=github
:target: https://github.com/OCA/account-payment/tree/16.0/account_payment_batch_process_discount
: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-16-0/account-payment-16-0-account_payment_batch_process_discount
: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=16.0
:alt: Try me on Runboat

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

This module allows you to define discounts for early payment and apply them on batch
payments.

**Table of contents**

.. contents::
:local:

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

* Go to *Accounting > Invoicing > Payment Terms*
* Select or create a payment term
* Check the box "Early discount payment"
* Exclude the shipping and/or the tax amount
* Create a line with a discount for early payment, like 2% if paid within 15 days

Usage
=====

* Go to *Accounting > Customers > Invoices* or *Accounting > Vendors > Bills*
* Select various open invoices or bills
* Go to the Action menu
* Select Batch Payments
* Adjust the information
* Click on Make Payments

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_payment_batch_process_discount%0Aversion:%2016.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
~~~~~~~

* Open Source Integrators

Contributors
~~~~~~~~~~~~

* Open Source Integrators <https://www.opensourceintegrators.com>

* Mayank Gosai <[email protected]>
* Balaji Kannan <[email protected]>
* Maxime Chambreuil <[email protected]>

* Camptocamp <https://www.camptocamp.com>
* Denis Leemann <[email protected]>

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-mgosai| image:: https://github.com/mgosai.png?size=40px
:target: https://github.com/mgosai
:alt: mgosai

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

|maintainer-mgosai|

This module is part of the `OCA/account-payment <https://github.com/OCA/account-payment/tree/16.0/account_payment_batch_process_discount>`_ 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_payment_batch_process_discount/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
from . import wizard
18 changes: 18 additions & 0 deletions account_payment_batch_process_discount/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Discount on batch payments",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"category": "Accounting & Finance",
"maintainer": "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-payment",
"depends": ["account_payment_batch_process", "account_payment_term_discount"],
"data": [
"views/account_move.xml",
],
"development_status": "Beta",
"maintainers": ["mgosai"],
"auto_install": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_payment_batch_process_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_payment_batch_process_discount
#: model_terms:ir.ui.view,arch_db:account_payment_batch_process_discount.account_move_search_discount_date
msgid "Discount Invoice"
msgstr ""

#. module: account_payment_batch_process_discount
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_move__display_name
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_payment_register__display_name
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_payment_term_line__display_name
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_invoice_payment_line__display_name
msgid "Display Name"
msgstr ""

#. module: account_payment_batch_process_discount
#: model_terms:ir.ui.view,arch_db:account_payment_batch_process_discount.account_move_search_discount_date
msgid "Filter invoices with early payment discounts"
msgstr ""

#. module: account_payment_batch_process_discount
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_move__id
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_payment_register__id
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_payment_term_line__id
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_invoice_payment_line__id
msgid "ID"
msgstr ""

#. module: account_payment_batch_process_discount
#: model:ir.model,name:account_payment_batch_process_discount.model_invoice_payment_line
msgid "Invoice Payment Line"
msgstr ""

#. module: account_payment_batch_process_discount
#: model:ir.model,name:account_payment_batch_process_discount.model_account_move
msgid "Journal Entry"
msgstr ""

#. module: account_payment_batch_process_discount
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_move____last_update
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_payment_register____last_update
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_payment_term_line____last_update
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_invoice_payment_line____last_update
msgid "Last Modified on"
msgstr ""

#. module: account_payment_batch_process_discount
#: model:ir.model,name:account_payment_batch_process_discount.model_account_payment_term_line
msgid "Payment Terms Line"
msgstr ""

#. module: account_payment_batch_process_discount
#: code:addons/account_payment_batch_process_discount/wizard/account_payment_register.py:0
#, python-format
msgid "Please enter the payment date."
msgstr ""

#. module: account_payment_batch_process_discount
#: model:ir.model,name:account_payment_batch_process_discount.model_account_payment_register
msgid "Register Payment"
msgstr ""

#. module: account_payment_batch_process_discount
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_bank_statement_line__valid_discount_date
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_move__valid_discount_date
#: model:ir.model.fields,field_description:account_payment_batch_process_discount.field_account_payment__valid_discount_date
msgid "Valid Discount Date"
msgstr ""
3 changes: 3 additions & 0 deletions account_payment_batch_process_discount/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account_move, account_payment_term_line
24 changes: 24 additions & 0 deletions account_payment_batch_process_discount/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from dateutil.relativedelta import relativedelta

from odoo import fields, models


class AccountMove(models.Model):
_inherit = "account.move"

valid_discount_date = fields.Date()

def action_post(self):
res = super().action_post()
for rec in self:
if rec.invoice_payment_term_id and rec.invoice_date:
# Check payment date discount validation
invoice_date = fields.Date.from_string(rec.invoice_date)
# Get discount validity days from payment terms
for line in rec.invoice_payment_term_id.line_ids:
rec.valid_discount_date = invoice_date + relativedelta(
days=line.discount_days
)
return res
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from dateutil.relativedelta import relativedelta

from odoo import fields, models


class AccountPaymentTermLine(models.Model):
_inherit = "account.payment.term.line"

def write(self, vals):
res = super().write(vals)

Check warning on line 12 in account_payment_batch_process_discount/models/account_payment_term_line.py

View check run for this annotation

Codecov / codecov/patch

account_payment_batch_process_discount/models/account_payment_term_line.py#L12

Added line #L12 was not covered by tests
if vals.get("discount_days"):
for item in self:
# get all invoice related to this payment term and update
# validity discount date
invoice_ids = self.env["account.move"].search(

Check warning on line 17 in account_payment_batch_process_discount/models/account_payment_term_line.py

View check run for this annotation

Codecov / codecov/patch

account_payment_batch_process_discount/models/account_payment_term_line.py#L17

Added line #L17 was not covered by tests
[
("state", "=", "posted"),
("invoice_payment_term_id", "=", item.payment_id.id),
]
)
for inv in invoice_ids:
# Check payment date discount validation
invoice_date = fields.Date.from_string(inv.invoice_date)

Check warning on line 25 in account_payment_batch_process_discount/models/account_payment_term_line.py

View check run for this annotation

Codecov / codecov/patch

account_payment_batch_process_discount/models/account_payment_term_line.py#L25

Added line #L25 was not covered by tests
# Update discount validity days
for line in inv.invoice_payment_term_id.line_ids:
inv.discount_date = invoice_date + relativedelta(

Check warning on line 28 in account_payment_batch_process_discount/models/account_payment_term_line.py

View check run for this annotation

Codecov / codecov/patch

account_payment_batch_process_discount/models/account_payment_term_line.py#L28

Added line #L28 was not covered by tests
days=line.discount_days
)
return res

Check warning on line 31 in account_payment_batch_process_discount/models/account_payment_term_line.py

View check run for this annotation

Codecov / codecov/patch

account_payment_batch_process_discount/models/account_payment_term_line.py#L31

Added line #L31 was not covered by tests
5 changes: 5 additions & 0 deletions account_payment_batch_process_discount/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* Go to *Accounting > Invoicing > Payment Terms*
* Select or create a payment term
* Check the box "Early discount payment"
* Exclude the shipping and/or the tax amount
* Create a line with a discount for early payment, like 2% if paid within 15 days
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* Open Source Integrators <https://www.opensourceintegrators.com>

* Mayank Gosai <[email protected]>
* Balaji Kannan <[email protected]>
* Maxime Chambreuil <[email protected]>

* Camptocamp <https://www.camptocamp.com>
* Denis Leemann <[email protected]>
2 changes: 2 additions & 0 deletions account_payment_batch_process_discount/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows you to define discounts for early payment and apply them on batch
payments.
6 changes: 6 additions & 0 deletions account_payment_batch_process_discount/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* Go to *Accounting > Customers > Invoices* or *Accounting > Vendors > Bills*
* Select various open invoices or bills
* Go to the Action menu
* Select Batch Payments
* Adjust the information
* Click on Make Payments
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading