From 0b97a7473513eb6b78ba05644a95d238eb928070 Mon Sep 17 00:00:00 2001 From: sergiocorato Date: Wed, 26 Jun 2024 22:32:05 +0200 Subject: [PATCH] [14.0][FIX] l10n_it_withholding_tax pagamento con spese --- .../wizards/account_payment_register.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/l10n_it_withholding_tax/wizards/account_payment_register.py b/l10n_it_withholding_tax/wizards/account_payment_register.py index 30182c051bd1..98f05c50f878 100644 --- a/l10n_it_withholding_tax/wizards/account_payment_register.py +++ b/l10n_it_withholding_tax/wizards/account_payment_register.py @@ -38,3 +38,28 @@ def _inject_withholding_net_pay_residual(self, wizard_values_from_batch): "source_amount_currency" ] = net_pay_residual_amount return wizard_values_from_batch + + @api.depends("amount") + def _compute_payment_difference(self): + super()._compute_payment_difference() + for wizard in self: + withholding_amount = sum( + wizard.mapped("line_ids.withholding_tax_amount") or [] + ) + if withholding_amount: + if wizard.source_currency_id == wizard.currency_id: + # Same currency, probably the only needed here. + wizard.payment_difference = ( + wizard.source_amount_currency + - withholding_amount + - wizard.amount + ) + elif wizard.currency_id == wizard.company_id.currency_id: + # probably not needed as withholding amount does not know currency + # Payment expressed on the company's currency. + wizard.payment_difference = ( + wizard.source_amount - withholding_amount - wizard.amount + ) + # not supported from withholding: + # Foreign currency on payment different from the one set on the journal + # entries.