Skip to content

Commit fc16fa5

Browse files
committed
Merge PR #5191 into 14.0
Signed-off-by francesco-ooops
2 parents 0d7b685 + 943a933 commit fc16fa5

5 files changed

Lines changed: 35 additions & 7 deletions

File tree

l10n_it_withholding_tax/README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ Contributors
131131
* `Aion Tech <https://aiontech.company/>`_:
132132

133133
* Simone Rubino <simone.rubino@aion-tech.it>
134+
* `PyTech <https://www.pytech.it>`_:
135+
136+
* Simone Rubino <simone.rubino@pytech.it>
134137

135138
Maintainers
136139
~~~~~~~~~~~

l10n_it_withholding_tax/models/withholding_tax.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,20 +279,29 @@ def get_wt_competence(self, amount_reconcile=None):
279279
if wt_inv:
280280
# Compute how much has been already paid
281281
# but has no corresponding Withholding Tax move
282-
payment_moves = self.env["account.move"].browse()
282+
payment_moves_to_amount = {}
283283
for (
284284
_partial,
285-
_amount,
285+
amount,
286286
counterpart_line,
287287
) in st.invoice_id._get_reconciled_invoices_partials():
288-
payment_moves |= counterpart_line.move_id
288+
payment_move = counterpart_line.move_id
289+
payment_moves_to_amount.setdefault(
290+
payment_move,
291+
payment_moves_to_amount.get(payment_move, 0) + amount,
292+
)
293+
payment_moves = self.env["account.move"].browse(
294+
[move.id for move in payment_moves_to_amount.keys()]
295+
)
289296
# Exclude payments created for Withholding Taxes
290297
wt_moves = self.env["withholding.tax.move"].search(
291298
[("account_move_id", "in", payment_moves.ids)]
292299
)
293300
wt_payment_moves = wt_moves.wt_account_move_id
294301
no_wt_payment_moves = payment_moves - wt_payment_moves
295-
no_wt_paid_amount = sum(no_wt_payment_moves.mapped("amount_total"))
302+
no_wt_paid_amount = sum(
303+
[payment_moves_to_amount[move] for move in no_wt_payment_moves]
304+
)
296305

297306
amount_base = st.invoice_id.amount_untaxed * (
298307
no_wt_paid_amount / st.invoice_id.amount_net_pay

l10n_it_withholding_tax/readme/CONTRIBUTORS.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
* `Aion Tech <https://aiontech.company/>`_:
99

1010
* Simone Rubino <simone.rubino@aion-tech.it>
11+
* `PyTech <https://www.pytech.it>`_:
12+
13+
* Simone Rubino <simone.rubino@pytech.it>

l10n_it_withholding_tax/static/description/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ <h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
461461
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;aion-tech.it">simone.rubino&#64;aion-tech.it</a>&gt;</li>
462462
</ul>
463463
</li>
464+
<li><a class="reference external" href="https://www.pytech.it">PyTech</a>:<ul>
465+
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;pytech.it">simone.rubino&#64;pytech.it</a>&gt;</li>
466+
</ul>
467+
</li>
464468
</ul>
465469
</div>
466470
<div class="section" id="maintainers">

l10n_it_withholding_tax/tests/test_withholding_tax.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,15 @@ def test_multi_invoice_with_payment(self):
626626
],
627627
)
628628
self.assertEqual(len(statements), len(invoices))
629-
self.assertAlmostEqual(
630-
sum(x.tax for x in statements), 95.44 + 2.62 + 20 + 9.68 + 9.68
629+
self.assertRecordValues(
630+
statements.sorted("tax"),
631+
[
632+
{
633+
"amount": amount,
634+
"tax": amount,
635+
}
636+
for amount in (2.62, 9.68, 9.68, 20, 95.44)
637+
],
631638
)
632639
wh_move_ids = statements.mapped("move_ids.wt_account_move_id")
633640
self.assertEqual(len(wh_move_ids), len(statements))
@@ -734,15 +741,17 @@ def test_no_generate_wt_move(self):
734741
"""
735742
# Arrange
736743
amount = 2000
737-
wt_amount = 500
738744
bill = self._create_bill(price_unit=amount)
745+
w_tax = bill.line_ids.invoice_line_tax_wt_ids
746+
wt_amount = amount * w_tax.rate_ids.tax / 100
739747
bill.withholding_tax_no_generate_move = True
740748
wt_statement = self.env["withholding.tax.statement"].search(
741749
[
742750
("invoice_id", "=", bill.id),
743751
]
744752
)
745753
# pre-condition
754+
self.assertEqual(wt_amount, 400)
746755
self.assertTrue(bill.withholding_tax_no_generate_move)
747756

748757
# Act 1: Partial payment generating no move

0 commit comments

Comments
 (0)