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

[16.0] FIX l10n_it_reverse_charge avoiding extra "exchange difference" entry #3879

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
24 changes: 18 additions & 6 deletions l10n_it_reverse_charge/models/account_move.py
Copy link
Contributor

Choose a reason for hiding this comment

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

@eLBati la differenza (secondo me) sostanziale tra la mia e la tua PR è nel metodo compute_rc_amount_tax_main_currency perchè mi tengo da parte il valore della fattura originale per evitare una conversione di un valore già convertito e quindi possibili errori di arrotondamenti:
https://github.com/OCA/l10n-italy/pull/4238/files#diff-3c6a29bf7c09821dd6605e9b9c729ab09d0c83b13505138134c227b0b202ac2dR184

Per il resto sono molto simili e posso pensare di aggiungere un test

Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,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 @@ -221,7 +226,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
Copy link
Contributor

Choose a reason for hiding this comment

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

Qui e sotto, penso sia meglio

Suggested change
account, credit, debit, line_to_reconcile.amount_currency
account, credit, debit, line_amount_currency=line_to_reconcile.amount_currency

Così se vengono aggiunti altri args o kwargs prima di questo non si rischia di assegnare il valore al parametro sbagliato, cosa ne pensi?

)
line_values.update(
{
"partner_id": self.partner_id.id,
Expand All @@ -235,16 +242,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 @@ -269,6 +280,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
Loading