Skip to content

Commit

Permalink
FIX l10n_it_reverse_charge avoiding extra "exchange difference" entry
Browse files Browse the repository at this point in the history
  • Loading branch information
eLBati committed Jan 22, 2024
1 parent ee9f282 commit fda33bc
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions l10n_it_reverse_charge/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,20 @@ def rc_payment_vals(self, rc_type):
"date": self.date,
}

def _rc_line_values(self, account, credit, debit):
def _rc_line_values(self, account, credit, debit, line_amount_currency=None):
"""Base Values for the RC Payment Move lines."""
return {
values = {
"name": self.name,
"credit": credit,
"debit": debit,
"account_id": account.id,
"currency_id": self.currency_id.id,
}
if line_amount_currency:
sign = 1 if debit else -1
amount_currency = abs(line_amount_currency) * sign
values["amount_currency"] = amount_currency
return values

def _rc_credit_line_amounts(self, amount):
if self.is_inbound():
Expand All @@ -218,7 +223,9 @@ def rc_payment_credit_line_vals(self, line_to_reconcile):
)
account = line_to_reconcile.account_id

line_values = self._rc_line_values(account, credit, debit)
line_values = self._rc_line_values(
account, credit, debit, line_to_reconcile.amount_currency
)
line_values.update(
{
"partner_id": self.partner_id.id,
Expand All @@ -232,16 +239,20 @@ def rc_payment_debit_line_vals(self, line_to_reconcile, account):
abs(line_to_reconcile.balance),
)

line_values = self._rc_line_values(account, credit, debit)
line_values = self._rc_line_values(
account, credit, debit, line_to_reconcile.amount_currency
)
return line_values

def rc_credit_line_vals(self, account, amount):
credit, debit = self._rc_credit_line_amounts(amount)
return self._rc_line_values(account, credit, debit)

def rc_debit_line_vals(self, account, amount):
def rc_debit_line_vals(self, account, amount, line_amount_currency=None):
credit, debit = self._rc_debit_line_amounts(amount)
line_values = self._rc_line_values(account, credit, debit)
line_values = self._rc_line_values(
account, credit, debit, line_amount_currency=line_amount_currency
)
line_values.update(
{
"partner_id": self.partner_id.id,
Expand All @@ -266,6 +277,7 @@ def _prepare_rc_supplier_invoice_payment(self, rc_invoice, rc_type):
payment_debit_line_data = self.rc_debit_line_vals(
line_to_reconcile.account_id,
payment_credit_line_data["credit"],
payment_credit_line_data.get("amount_currency"),
)
rc_payment_data["line_ids"] = [
(0, 0, payment_debit_line_data),
Expand Down

0 comments on commit fda33bc

Please sign in to comment.