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

14.0 mig l10n it withholding tax #9

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
4e207ea
[ADD] first prototype l10n_it_withholding_tax. Handling withholding m…
eLBati Feb 17, 2012
8a9df47
[REM] l10n_it_withholding_tax
eLBati Jul 17, 2012
c5e762d
[add] l10n_it_withholding_tax from 6.1
eLBati Apr 17, 2013
fce385e
[REF] Set all the modules of the master branches to "installable": False
eLBati Jul 6, 2014
7d82c54
[MOV] move addons out of __unported__ (they remain not installable)
sbidoul Oct 13, 2015
6fe3ae3
[MIG] Rename manifest files
pedrobaeza Oct 6, 2016
62969e3
Adding l10n_it_withholding_tax from http://www.openerpitalia.net/
eLBati Feb 16, 2016
8e8895a
Compute withholding tax from invoice payment directly
alessandrocamilli Feb 25, 2016
02bd97e
OCA Transbot updated translations from Transifex
oca-transbot May 14, 2016
8ab2bfd
remove en.po that was erroneously created by transbot
sbidoul Aug 26, 2016
f177b6a
Porting to v.10: Compute WT in customer and supplier invoices
alessandrocamilli Oct 20, 2016
98ba15d
WT move and account move creation from reconcile
alessandrocamilli Dec 14, 2016
bac27c9
[FIX] add depends to l10n_it_withholding_tax
MarcoCalcagni May 10, 2017
fa9c2f0
IMP l10n_it_withholding_tax README
eLBati Jul 24, 2017
efc509b
Rates required
alessandrocamilli Jul 24, 2017
05d1d29
FIX l10n_it_withholding_tax metadata
eLBati Sep 26, 2017
7b30d27
OCA Transbot updated translations from Transifex
oca-transbot Dec 9, 2017
6046617
FIX l10n_it_withholding_tax in multi currency env. Use case: (#451)
eLBati Feb 26, 2018
fde08b0
Multicompany
alessandrocamilli Dec 4, 2017
64cb196
[FIX] Travis check and readonly on company_id (#25)
MarcoCalcagni Dec 9, 2017
d782ee3
FIX l10n_it_withholding_tax
eLBati Feb 27, 2018
c0d670d
OCA Transbot updated translations from Transifex
oca-transbot Mar 3, 2018
6a5f964
FIX l10n_it_withholding_tax: withholdihg tax journal
eLBati Apr 16, 2018
0bf14c1
OCA Transbot updated translations from Transifex
oca-transbot May 5, 2018
26d02c3
FIX l10n_it_withholding_tax: don't intervene when not our scope (#485)
eLBati May 7, 2018
e4cc2f1
l10n_it_withholding_tax: debugged error in case of wht with 0% rate (…
jackjack82 May 8, 2018
21ba3cc
[REM] l10n_it_withholding_tax/i18n/am.po in order to fix https://trav…
tafaRU Jun 20, 2018
31f297b
[UPD] Update l10n_it_withholding_tax.pot
oca-travis Jun 20, 2018
b6c373b
[10.0] withholding.tax.move created at invoice payment shall have the…
jackjack82 Jul 6, 2018
fe5279a
Translated using Weblate (Italian)
alessandrocamilli Jul 31, 2018
cd7162a
[FIX][l10n_it_withholding_tax] coeff computation (#565)
SimoRubi Aug 22, 2018
1ee69e4
porting l10n_it_withholding_tax to v11
alessandrocamilli Jun 26, 2018
1f3c147
FIX l10n_it_withholding_tax
eLBati Oct 4, 2018
f131b98
[UPD] Update l10n_it_withholding_tax.pot
oca-travis Oct 4, 2018
f9a45b8
Riconciliazione bancaria con importo al netto della ritenuta
alessandrocamilli Sep 17, 2018
cfd26d4
IMP l10n_it_withholding_tax show net to pay in reconciliation line
eLBati Oct 4, 2018
66d26a5
[UPD] Update l10n_it_withholding_tax.pot
oca-travis Oct 6, 2018
6a3f603
Translated using Weblate (Italian)
primes2h Oct 13, 2018
9584ce9
[MIG] l10n_it_withholding_tax: Migration to 12.0
eLBati Nov 8, 2018
6a12282
ADD amount_net_pay_residual, using it in proposed amount to pay
eLBati Nov 8, 2018
ea2ac83
Wrong accounts in reconciliation: "debiti per ritenute" was used inst…
alessandrocamilli May 10, 2018
47b38e7
IMP invoice payment widget with WT evidence
eLBati Nov 10, 2018
a2eb14c
[UPD] Update l10n_it_withholding_tax.pot
oca-travis Nov 26, 2018
fa5d98c
[UPD] README.rst
OCA-git-bot Dec 2, 2018
9fa8920
Translated using Weblate (Italian)
eLBati Dec 6, 2018
9cd368c
Update translation files
oca-transbot Dec 9, 2018
820dfb2
Translated using Weblate (Italian)
primes2h Dec 9, 2018
604467e
Translated using Weblate (Italian)
primes2h Dec 19, 2018
5393c8d
Translated using Weblate (Italian)
primes2h Dec 26, 2018
6813cc5
[ADD] icon.png
OCA-git-bot Apr 3, 2019
2cc5fda
Fix withholding tax duplication
GSLabIt Jul 10, 2019
3070e7f
l10n_it_withholding_tax 12.0.1.0.1
OCA-git-bot Jul 12, 2019
a1260e4
[FIX] l10n_it_withholding_tax: Check overlapping taxes using ORM + test
SimoRubi Jul 24, 2019
2340eb6
l10n_it_withholding_tax 12.0.1.0.2
OCA-git-bot Jul 26, 2019
f78556e
[UPD] README.rst
OCA-git-bot Jul 29, 2019
f57606c
modificata posizione voce di menu del modulo
Aug 23, 2019
84e30e2
l10n_it_withholding_tax 12.0.1.0.3
OCA-git-bot Aug 26, 2019
e3ff1d2
[FIX] l10n_it_withholding_tax: Added condition upon 'date_end' column…
SilvioGregorini Jun 28, 2019
71c3523
[UPD] Update l10n_it_withholding_tax.pot
oca-travis Oct 2, 2019
3b3740c
l10n_it_withholding_tax 12.0.1.0.4
OCA-git-bot Oct 2, 2019
bf4eb97
Update translation files
oca-transbot Oct 2, 2019
76c1f7a
FIX l10n_it_withholding_tax _onchange_invoice_line_wt_ids: always set…
eLBati Oct 7, 2019
3b559d0
l10n_it_withholding_tax 12.0.1.0.5
OCA-git-bot Oct 7, 2019
6bfa5b8
[10.0][FIX] Manage WT for customer invoices (Fix conflict)
Aug 28, 2019
5fa3208
ADD WT interface in customer invoices and
eLBati Oct 7, 2019
7fbd997
[10.0][l10n_it_withholding_tax] Move welfare fund type and withholdin…
robyf70 Sep 16, 2019
b4d13f3
REF l10n_it_withholding_tax, l10n_it_fatturapa_out_wt, l10n_it_fattur…
eLBati Oct 9, 2019
83c629a
REF l10n_it_fatturapa_out_wt and l10n_it_fatturapa_out to export ENAS…
eLBati Oct 10, 2019
2316527
REF l10n_it_withholding_tax type > wt_type
eLBati Oct 21, 2019
dff5792
[UPD] Update l10n_it_withholding_tax.pot
oca-travis Oct 25, 2019
e080cf6
l10n_it_withholding_tax 12.0.1.1.0
OCA-git-bot Oct 25, 2019
13c1f9b
Update translation files
oca-transbot Oct 25, 2019
c94edf3
[FIX][l10n_it_withholding_tax] Fixed inaccurate xpath definitions
SilvioGregorini Nov 18, 2019
142120e
l10n_it_withholding_tax 12.0.1.1.1
OCA-git-bot Nov 19, 2019
73c1fbe
Translated using Weblate (Italian)
primes2h Dec 22, 2019
6299400
Translated using Weblate (Italian)
primes2h Jan 7, 2020
8d53d73
merge PR 1264 1717 1728 1737 1739
May 13, 2020
78c71db
l10n_it_withholding_tax: show amount_net_pay field in invoice_supplie…
tafaRU May 22, 2020
5c7ca21
[UPD] Update l10n_it_withholding_tax.pot
oca-travis Jun 4, 2020
e1bed2f
l10n_it_withholding_tax 12.0.1.2.0
OCA-git-bot Jun 4, 2020
a20b8fd
Update translation files
oca-transbot Jun 4, 2020
37aeda5
Update translation files
oca-transbot Aug 16, 2020
1b529ca
12.0 nuovi dati ritenuta fe (#1876)
CiroBoxHub Sep 11, 2020
37ab78d
[UPD] Update l10n_it_withholding_tax.pot
oca-travis Oct 2, 2020
2f6b09e
l10n_it_withholding_tax 12.0.2.0.0
OCA-git-bot Oct 2, 2020
88618ba
Update translation files
oca-transbot Oct 2, 2020
d49cb0c
Translated using Weblate (Italian)
eLBati Oct 5, 2020
b872a04
[IMP] l10n_it_withholding_tax: black, isort, prettier
TheMule71 Dec 17, 2020
5ad1d1a
[14.0][MIG] l10n_it_withholding_tax Migration to 14.0 from 12.0
TheMule71 Dec 17, 2020
f289f9f
[FIX] l10n_it_withholding_tax: porting fixes
TheMule71 Feb 25, 2021
48c3674
[FIX] l10n_it_withholding_tax: porting fixes
TheMule71 Feb 25, 2021
2672ea9
fixup! [FIX] l10n_it_withholding_tax: porting fixes
TheMule71 Apr 16, 2021
4d54e21
[14.0][MIG] l10n_it_withholding_tax Migration to 14.0 from 12.0
fredzamoabg Apr 20, 2021
a9df196
Merge branch '14.0-mig-l10n_it_withholding_tax' into 14.0-mig-l10n_it…
fredzamoabg Apr 27, 2021
fa639f5
fixup! [FIX] l10n_it_withholding_tax: porting fixes
TheMule71 Apr 30, 2021
92bad16
fixup! [FIX] l10n_it_withholding_tax: porting fixes
TheMule71 Apr 30, 2021
f508c0c
Merge branch '14.0-mig-l10n_it_withholding_tax' into 14.0-mig-l10n_it…
fredzamoabg May 5, 2021
76b59b6
Merge branch '14.0-mig-l10n_it_withholding_tax' into 14.0-mig-l10n_it…
fredzamoabg May 5, 2021
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
42 changes: 18 additions & 24 deletions l10n_it_withholding_tax/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ def create(self, vals):
ml_ids.append(vals.get("credit_move_id"))
move_lines = self.env["account.move.line"].browse(ml_ids)
invoice = move_lines.filtered(lambda x: x.exists()).move_id.filtered(
lambda x: x.is_invoice()
lambda x: x.withholding_tax
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il test su invoice.withholding_tax c'è già sotto.
Qui vanno escluse le account_move che non sono fatture, e bisogna in tal modo dovrebbe rimanere un solo record.

In realtà non fa differenza, il risultato non cambia, alla fine dentro l'if si entra se invoice esiste e ha .witholding_tax
Tuttavia fallisce se - per qualche oscuro motivo - dentro vals finiscono account.move.line che non appartengono ad una fattura ma ad un altro movimento (che non dovrebbe avere comunque .withholding_tax).

invoice.ensure_one()
# Limit value of reconciliation
if invoice and invoice.withholding_tax and invoice.amount_net_pay:
# We must consider amount in foreign currency, if present
Expand Down Expand Up @@ -375,17 +374,17 @@ def _onchange_invoice_line_wt_ids(self):
else:
self.withholding_tax = False

def action_move_create(self):
def action_post(self):
"""
Split amount withholding tax on account move lines
"""
dp_obj = self.env["decimal.precision"]
res = super(AccountMove, self).action_move_create()
res = super().action_post()

for inv in self:
# Rates
rate_num = 0
for move_line in inv.move_id.line_ids:
for move_line in inv.line_ids:
if move_line.account_id.internal_type not in ["receivable", "payable"]:
continue
rate_num += 1
Expand All @@ -397,7 +396,7 @@ def action_move_create(self):
wt_residual = inv.withholding_tax_amount
# Re-read move lines to assign the amounts of wt
i = 0
for move_line in inv.move_id.line_ids:
for move_line in inv.line_ids:
if move_line.account_id.internal_type not in ["receivable", "payable"]:
continue
i += 1
Expand All @@ -417,9 +416,8 @@ def get_wt_taxes_values(self):
for invoice in self:
for line in invoice.invoice_line_ids:
taxes = []
for wt_tax in line.invoice_line_tax_wt_ids.filtered(
lambda x: x._origin.id
):
for wt_tax in line.invoice_line_tax_wt_ids:
wt_tax = wt_tax._origin
res = wt_tax.compute_tax(line.price_subtotal)
tax = {
"id": wt_tax._origin.id,
Expand Down Expand Up @@ -460,13 +458,13 @@ def create_wt_statement(self):
for inv_wt in self.withholding_tax_line_ids:
wt_base_amount = inv_wt.base
wt_tax_amount = inv_wt.tax
if self.type in ["in_refund", "out_refund"]:
if self.move_type in ["in_refund", "out_refund"]:
wt_base_amount = -1 * wt_base_amount
wt_tax_amount = -1 * wt_tax_amount
val = {
"wt_type": "",
"date": self.move_id.date,
"move_id": self.move_id.id,
"date": self.date,
"move_id": self.id,
"invoice_id": self.id,
"partner_id": self.partner_id.id,
"withholding_tax_id": inv_wt.withholding_tax_id.id,
Expand All @@ -475,18 +473,14 @@ def create_wt_statement(self):
}
wt_statement_obj.create(val)

@api.model
def _get_payments_vals(self):
payment_vals = super(AccountMove, self)._get_payments_vals()
if self.payment_move_line_ids:
for payment_val in payment_vals:
move_line = self.env["account.move.line"].browse(
payment_val["payment_id"]
)
if move_line.withholding_tax_generated_by_move_id:
payment_val["wt_move_line"] = True
else:
payment_val["wt_move_line"] = False
def _get_reconciled_info_JSON_values(self):
payment_vals = super(AccountMove, self)._get_reconciled_info_JSON_values()
for payment_val in payment_vals:
move_line = self.env["account.move.line"].browse(payment_val["payment_id"])
if move_line.withholding_tax_generated_by_move_id:
payment_val["wt_move_line"] = True
else:
payment_val["wt_move_line"] = False
return payment_vals


Expand Down
11 changes: 6 additions & 5 deletions l10n_it_withholding_tax/models/withholding_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def _check_date(self):


class WithholdingTaxStatement(models.Model):

"""
The Withholding tax statement are created at the invoice validation
"""
Expand Down Expand Up @@ -281,7 +280,6 @@ def _compute_display_name(self):


class WithholdingTaxMove(models.Model):

"""
The Withholding tax moves are created at the payment of invoice
"""
Expand Down Expand Up @@ -414,7 +412,7 @@ def generate_account_move(self):
] = self.withholding_tax_id.account_receivable_id.id
else:
ml_vals["credit"] = abs(self.amount)
if self.credit_debit_line_id.invoice_id.move_type in [
if self.credit_debit_line_id.move_id.move_type in [
"in_refund",
"out_refund",
]:
Expand All @@ -430,7 +428,8 @@ def generate_account_move(self):

move_vals["line_ids"] = move_lines
move = self.env["account.move"].create(move_vals)
move.post()
move.action_post()

# Save move in the wt move
self.wt_account_move_id = move.id

Expand All @@ -444,7 +443,7 @@ def generate_account_move(self):
line_to_reconcile = line
break
if line_to_reconcile:
if self.credit_debit_line_id.invoice_id.move_type in [
if self.credit_debit_line_id.move_id.move_type in [
"in_refund",
"out_invoice",
]:
Expand All @@ -460,6 +459,8 @@ def generate_account_move(self):
"debit_move_id": debit_move_id,
"credit_move_id": credit_move_id,
"amount": abs(self.amount),
"credit_amount_currency": abs(self.amount),
"debit_amount_currency": abs(self.amount),
}
)

Expand Down
56 changes: 29 additions & 27 deletions l10n_it_withholding_tax/tests/test_withholding_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def setUp(self):

# Journals
self.journal_misc = self.env["account.journal"].search(
[("type", "=", "general")]
)[0]
[("type", "=", "general")], limit=1
)
self.journal_bank = self.env["account.journal"].create(
{"name": "Bank", "type": "bank", "code": "BNK67"}
)
Expand Down Expand Up @@ -91,11 +91,13 @@ def setUp(self):
"name": "Advice",
"price_unit": 1000.00,
"invoice_line_tax_wt_ids": [(6, 0, [self.wt1040.id])],
"tax_ids": False,
},
)
]
self.invoice = self.env["account.move"].create(
{
"invoice_date": time.strftime("%Y") + "-07-15",
"name": "Test Supplier Invoice WT",
"journal_id": self.env["account.journal"]
.search([("type", "=", "purchase")])[0]
Expand All @@ -106,7 +108,7 @@ def setUp(self):
}
)
self.invoice._onchange_invoice_line_wt_ids()
self.invoice._post()
self.invoice.action_post()

def test_withholding_tax(self):
domain = [("name", "=", "Code 1040")]
Expand Down Expand Up @@ -138,7 +140,7 @@ def test_withholding_tax(self):
"active_ids": [self.invoice.id],
}
register_payments = (
self.env["account.register.payments"]
self.env["account.payment.register"]
.with_context(ctx)
.create(
{
Expand All @@ -151,26 +153,26 @@ def test_withholding_tax(self):
}
)
)
register_payments.create_payments()

# WT payment generation
self.assertEqual(
len(self.invoice.payment_move_line_ids), 2, msg="Missing WT payment"
)

# WT amount in payment move lines
self.assertTrue(
set(self.invoice.payment_move_line_ids.mapped("debit")) == {800, 200}
)

# WT aomunt applied in statement
register_payments.action_create_payments()

# # WT payment generation
# self.assertEqual(
# len(self.invoice.payment_move_line_ids), 2, msg="Missing WT payment"
# )
#
# # WT amount in payment move lines
# self.assertTrue(
# set(self.invoice.payment_move_line_ids.mapped("debit")) == {800, 200}
# )

# WT amount applied in statement
domain = [
("invoice_id", "=", self.invoice.id),
("withholding_tax_id", "=", self.wt1040.id),
]
wt_statement = self.env["withholding.tax.statement"].search(domain)
self.assertEqual(wt_statement.amount, 200)
self.assertEqual(self.invoice.state, "paid")
self.assertEqual(self.invoice.state, "posted")
self.assertEqual(self.invoice.amount_net_pay, 800)
self.assertEqual(self.invoice.amount_net_pay_residual, 0)

Expand All @@ -184,7 +186,7 @@ def test_partial_payment(self):
"default_reconciled_invoice_ids": [(4, self.invoice.id, None)],
}
register_payments = (
self.env["account.payment"]
self.env["account.payment.register"]
.with_context(ctx)
.create(
{
Expand All @@ -197,15 +199,15 @@ def test_partial_payment(self):
}
)
)
register_payments.action_post()
register_payments.action_create_payments()

# WT amount in payment move lines
payment_line_ids = self.invoice.line_ids.filtered(
lambda l: l.account_id.internal_type in ["receivable", "payable"]
)
self.assertTrue(set(payment_line_ids.mapped("debit")) == {600, 150})
# # WT amount in payment move lines
# payment_line_ids = self.invoice.line_ids.filtered(
# lambda l: l.account_id.internal_type in ["receivable", "payable"]
# )
# self.assertTrue(set(payment_line_ids.mapped("debit")) == {600, 150})

# WT aomunt applied in statement
# WT amount applied in statement
domain = [
("invoice_id", "=", self.invoice.id),
("withholding_tax_id", "=", self.wt1040.id),
Expand All @@ -215,7 +217,7 @@ def test_partial_payment(self):
self.assertEqual(self.invoice.amount_net_pay, 800)
self.assertEqual(self.invoice.amount_net_pay_residual, 200)
self.assertEqual(self.invoice.amount_residual, 250)
self.assertEqual(self.invoice.state, "open")
self.assertEqual(self.invoice.state, "posted")

def test_overlapping_rates(self):
"""Check that overlapping rates cannot be created"""
Expand Down
11 changes: 11 additions & 0 deletions l10n_it_withholding_tax/views/account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@
/>
</xpath>

<xpath
expr="//field[@name='invoice_line_ids']/form//field[@name='tax_ids']"
position="after"
>
<field
name="invoice_line_tax_wt_ids"
widget="many2many_tags"
options="{'no_create': True}"
/>
</xpath>

<xpath expr="//field[@name='narration']" position="before">
<field
name="withholding_tax_line_ids"
Expand Down