Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 3c5aaff

Browse files
committed
[ADD] l10n_nl_account_credit_control
[ADD] OCA dependency [FIX] Lint and kvk tests [FIX] Tests [IMP] Identation
1 parent 5f9f530 commit 3c5aaff

19 files changed

+454
-22
lines changed
+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
==================================
2+
Credit Control for the Netherlands
3+
==================================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15+
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--netherlands-lightgray.png?logo=github
17+
:target: https://github.com/OCA/l10n-netherlands/tree/11.0/l10n_nl_account_credit_control
18+
:alt: OCA/l10n-netherlands
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/l10n-netherlands-11-0/l10n-netherlands-11-0-l10n_nl_account_credit_control
21+
:alt: Translate me on Weblate
22+
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23+
:target: https://runbot.odoo-community.org/runbot/176/11.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
This module calculates the dunning fee based on the method defined by the WIK:
29+
<https://www.rijksoverheid.nl/onderwerpen/hulp-bij-schulden/vraag-en-antwoord/hoogte-incassokosten>.
30+
31+
**Table of contents**
32+
33+
.. contents::
34+
:local:
35+
36+
Configuration
37+
=============
38+
39+
To change the dunning fee amount and percentages:
40+
41+
#. Go to 'Invoicing > Configuration > Credit Control > Credit Control Policies';
42+
#. select a policy;
43+
#. select the tab 'Fees'.
44+
45+
To print the dunning fees on the e-mail or PDF:
46+
47+
#. Go to the credit control policy form;
48+
#. select a level in the 'Policy levels' tab;
49+
#. select the tab 'Mail and reporting' on the policy level form;
50+
#. put #FEE#, #FEENOTAX# or #FEETAX# in the preferred custom text fields.
51+
52+
Bug Tracker
53+
===========
54+
55+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-netherlands/issues>`_.
56+
In case of trouble, please check there if your issue has already been reported.
57+
If you spotted it first, help us smashing it by providing a detailed and welcomed
58+
`feedback <https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_account_credit_control%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
59+
60+
Do not contact contributors directly about support or help with technical issues.
61+
62+
Credits
63+
=======
64+
65+
Authors
66+
~~~~~~~
67+
68+
* Onestein
69+
70+
Contributors
71+
~~~~~~~~~~~~
72+
73+
* Dennis Sluijk <d.sluijk@onestein.nl>
74+
75+
Maintainers
76+
~~~~~~~~~~~
77+
78+
This module is maintained by the OCA.
79+
80+
.. image:: https://odoo-community.org/logo.png
81+
:alt: Odoo Community Association
82+
:target: https://odoo-community.org
83+
84+
OCA, or the Odoo Community Association, is a nonprofit organization whose
85+
mission is to support the collaborative development of Odoo features and
86+
promote its widespread use.
87+
88+
This module is part of the `OCA/l10n-netherlands <https://github.com/OCA/l10n-netherlands/tree/11.0/l10n_nl_account_credit_control>`_ project on GitHub.
89+
90+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from . import wizards
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
'name': 'Credit Control for the Netherlands',
3+
'summary': 'Dutch localization for credit control',
4+
'license': 'AGPL-3',
5+
'author': 'Onestein,Odoo Community Association (OCA)',
6+
'website': 'https://github.com/OCA/l10n-netherlands',
7+
'category': 'Localization',
8+
'version': '11.0.1.0.0',
9+
'development_status': 'Beta',
10+
'depends': [
11+
'account_credit_control',
12+
],
13+
'data': [
14+
'security/ir.model.access.csv',
15+
'data/credit_control_policy_fee_data.xml',
16+
'views/credit_control_policy_view.xml',
17+
'reports/report_credit_control_summary.xml'
18+
]
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2018 Onestein
3+
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
4+
5+
<odoo noupdate="1">
6+
<record id="fee_1" model="credit.control.policy.fee">
7+
<field name="credit_control_policy_id"
8+
ref="account_credit_control.credit_control_3_time" />
9+
<field name="sequence">0</field>
10+
<field name="amount">2500</field>
11+
<field name="fee">15</field>
12+
</record>
13+
14+
<record id="fee_2" model="credit.control.policy.fee">
15+
<field name="credit_control_policy_id"
16+
ref="account_credit_control.credit_control_3_time" />
17+
<field name="sequence">1</field>
18+
<field name="amount">2500</field>
19+
<field name="fee">10</field>
20+
</record>
21+
22+
<record id="fee_3" model="credit.control.policy.fee">
23+
<field name="credit_control_policy_id"
24+
ref="account_credit_control.credit_control_3_time" />
25+
<field name="sequence">2</field>
26+
<field name="amount">5000</field>
27+
<field name="fee">5</field>
28+
</record>
29+
30+
<record id="fee_4" model="credit.control.policy.fee">
31+
<field name="credit_control_policy_id"
32+
ref="account_credit_control.credit_control_3_time" />
33+
<field name="sequence">3</field>
34+
<field name="amount">190000</field>
35+
<field name="fee">1</field>
36+
</record>
37+
38+
<record id="fee_5" model="credit.control.policy.fee">
39+
<field name="credit_control_policy_id"
40+
ref="account_credit_control.credit_control_3_time" />
41+
<field name="sequence">4</field>
42+
<field name="amount">800000</field>
43+
<field name="fee">0.5</field>
44+
</record>
45+
</odoo>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import credit_control_policy_fee
2+
from . import credit_control_policy
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright 2018 Onestein
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class CreditControlPolicy(models.Model):
8+
_inherit = 'credit.control.policy'
9+
10+
fee_tax_ids = fields.Many2many(
11+
comodel_name='account.tax',
12+
string='Fee Taxes'
13+
)
14+
15+
min_fee = fields.Monetary(
16+
string='Minimum Fee',
17+
default=40
18+
)
19+
20+
max_fee = fields.Monetary(
21+
string='Maximum Fee',
22+
default=6775
23+
)
24+
25+
fee_ids = fields.One2many(
26+
string='Fees',
27+
comodel_name='credit.control.policy.fee',
28+
inverse_name='credit_control_policy_id'
29+
)
30+
31+
currency_id = fields.Many2one(
32+
'res.currency',
33+
required=True,
34+
default=lambda self: self.env.user.company_id.currency_id
35+
)
36+
37+
@api.multi
38+
def calculate_fee(self, amount):
39+
fee = 0
40+
for fee_record in self.fee_ids:
41+
tmp_amount = amount - fee_record.amount
42+
43+
if tmp_amount < 0:
44+
fee += amount * fee_record.fee_percentage
45+
break
46+
else:
47+
fee += fee_record.amount * fee_record.fee_percentage
48+
amount -= fee_record.amount
49+
if fee > self.max_fee:
50+
fee = self.max_fee
51+
elif fee < self.min_fee:
52+
fee = self.min_fee
53+
return fee
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2018 Onestein
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class CreditControlPolicyFee(models.Model):
8+
_name = 'credit.control.policy.fee'
9+
_order = 'sequence'
10+
11+
credit_control_policy_id = fields.Many2one(
12+
comodel_name='credit.control.policy',
13+
required=True
14+
)
15+
16+
currency_id = fields.Many2one(
17+
'res.currency',
18+
required=True,
19+
related='credit_control_policy_id.currency_id'
20+
)
21+
22+
sequence = fields.Integer()
23+
24+
amount = fields.Monetary(
25+
string='Amount of the unpaid bill',
26+
currency_field='currency_id'
27+
)
28+
29+
fee = fields.Float(
30+
string='Fee (%)'
31+
)
32+
33+
fee_percentage = fields.Float(
34+
compute='_compute_fee_percentage'
35+
)
36+
37+
@api.multi
38+
def _compute_fee_percentage(self):
39+
for fee in self:
40+
fee.fee_percentage = fee.fee / 100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
To change the dunning fee amount and percentages:
2+
3+
#. Go to 'Invoicing > Configuration > Credit Control > Credit Control Policies';
4+
#. select a policy;
5+
#. select the tab 'Fees'.
6+
7+
To print the dunning fees on the e-mail or PDF:
8+
9+
#. Go to the credit control policy form;
10+
#. select a level in the 'Policy levels' tab;
11+
#. select the tab 'Mail and reporting' on the policy level form;
12+
#. put #FEE#, #FEENOTAX# or #FEETAX# in the preferred custom text fields.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Dennis Sluijk <d.sluijk@onestein.nl>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This module calculates the dunning fee based on the method defined by the WIK:
2+
<https://www.rijksoverheid.nl/onderwerpen/hulp-bij-schulden/vraag-en-antwoord/hoogte-incassokosten>.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2018 Onestein
3+
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
4+
5+
<odoo>
6+
<template id="report_credit_control_summary_document"
7+
inherit_id="account_credit_control.report_credit_control_summary_document">
8+
<!-- Replace custom_text -->
9+
<xpath expr="//span[@t-field='doc.current_policy_level.custom_text']" position="attributes">
10+
<attribute name="class">hidden</attribute>
11+
</xpath>
12+
<xpath expr="//span[@t-field='doc.current_policy_level.custom_text']" position="after">
13+
<span t-field="doc.custom_text" />
14+
</xpath>
15+
16+
<!-- Replace custom_text_after_details -->
17+
<xpath expr="//p[@t-field='doc.current_policy_level.custom_text_after_details']" position="attributes">
18+
<attribute name="class">hidden</attribute>
19+
</xpath>
20+
<xpath expr="//p[@t-field='doc.current_policy_level.custom_text_after_details']" position="after">
21+
<span t-field="doc.custom_text_after_details" />
22+
</xpath>
23+
</template>
24+
</odoo>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
access_credit_control_policy_fee_manager,access_credit_control_policy_fee_manager,model_credit_control_policy_fee,account_credit_control.group_account_credit_control_manager,1,1,1,1
3+
access_credit_control_policy_fee_user,access_credit_control_policy_fee_user,model_credit_control_policy_fee,account_credit_control.group_account_credit_control_user,1,0,0,0
4+
access_credit_control_policy_fee_info,access_credit_control_policy_fee_info,model_credit_control_policy_fee,account_credit_control.group_account_credit_control_info,1,0,0,0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_credit_control
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2018 Onestein
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo.tests.common import TransactionCase
5+
6+
7+
class TestCreditControl(TransactionCase):
8+
def test_fee_calculation(self):
9+
policy = self.env.ref('account_credit_control.credit_control_3_time')
10+
11+
# Test minimal amount
12+
self.assertEqual(policy.calculate_fee(5), policy.min_fee)
13+
14+
# Test 1 tier fee
15+
self.assertEqual(policy.calculate_fee(1500), 225)
16+
17+
# Test 2 tier fee
18+
self.assertEqual(policy.calculate_fee(3000), 425)
19+
20+
# Test 3 tier fee
21+
self.assertEqual(policy.calculate_fee(800000), 5775)
22+
23+
# Test maximum amount
24+
self.assertEqual(policy.calculate_fee(1200000), policy.max_fee)
25+
26+
def test_communication(self):
27+
partner = self.env.ref('base.main_partner')
28+
level = self.env.ref('account_credit_control.3_time_1')
29+
currency = self.env.ref('base.USD')
30+
level.custom_text = '#FEE#'
31+
level.custom_text_after_details = '#FEENOTAX#'
32+
level.custom_mail_text = '#FEETAX#'
33+
34+
comm = self.env['credit.control.communication'].create({
35+
'currency_id': currency.id,
36+
'partner_id': partner.id,
37+
'current_policy_level': level.id
38+
})
39+
self.assertTrue('#FEE#' not in comm.custom_text)
40+
self.assertTrue('#FEENOTAX#' not in comm.custom_text_after_details)
41+
self.assertTrue('#FEETAX#' not in comm.custom_mail_text)

0 commit comments

Comments
 (0)