Skip to content

Commit

Permalink
Merge PR #636 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Mar 12, 2024
2 parents a7ee6de + 50a8b92 commit 7d871ba
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions account_reconcile_oca/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,16 @@ def _onchange_add_account_move_line_id(self):
new_data,
self.reconcile_data_info["reconcile_auxiliary_id"],
self.manual_reference,
exchange_recompute=True,
)
self.can_reconcile = self.reconcile_data_info.get("can_reconcile", False)
self.add_account_move_line_id = False

def _recompute_suspense_line(self, data, reconcile_auxiliary_id, manual_reference):
def _recompute_suspense_line(
self, data, reconcile_auxiliary_id, manual_reference, exchange_recompute=False
):
reconcile_auxiliary_id = self._compute_exchange_rate(
data, reconcile_auxiliary_id
data, reconcile_auxiliary_id, exchange_recompute=exchange_recompute
)
can_reconcile = True
total_amount = 0
Expand Down Expand Up @@ -393,7 +396,11 @@ def _reconcile_data_by_model(self, data, reconcile_model, reconcile_auxiliary_id
new_data.append(new_line)
return new_data, reconcile_auxiliary_id

def _compute_exchange_rate(self, data, reconcile_auxiliary_id):
def _compute_exchange_rate(
self, data, reconcile_auxiliary_id, exchange_recompute=False
):
if not exchange_recompute:
return reconcile_auxiliary_id
foreign_currency = (
self.currency_id != self.company_id.currency_id
or self.foreign_currency_id
Expand All @@ -416,6 +423,7 @@ def _compute_exchange_rate(self, data, reconcile_auxiliary_id):
"date": fields.Date.to_string(self.date),
"name": self.payment_ref or self.name,
"amount": -amount,
"net_amount": -amount,
"credit": amount if amount > 0 else 0.0,
"debit": -amount if amount < 0 else 0.0,
"kind": "other",
Expand Down Expand Up @@ -444,7 +452,8 @@ def _default_reconcile_data(self, from_unreconcile=False):
*self._reconcile_data_by_model(
data, res["model"], reconcile_auxiliary_id
),
self.manual_reference
self.manual_reference,
exchange_recompute=True
)
elif res and res.get("amls"):
amount = self.amount_total_signed
Expand All @@ -455,7 +464,10 @@ def _default_reconcile_data(self, from_unreconcile=False):
amount -= line_data.get("amount")
data.append(line_data)
return self._recompute_suspense_line(
data, reconcile_auxiliary_id, self.manual_reference
data,
reconcile_auxiliary_id,
self.manual_reference,
exchange_recompute=True,
)
return self._recompute_suspense_line(
data
Expand Down Expand Up @@ -643,7 +655,8 @@ def create(self, mvals):
*record._reconcile_data_by_model(
data, res["model"], reconcile_auxiliary_id
),
self.manual_reference
self.manual_reference,
exchange_recompute=True
)
elif res.get("amls"):
amount = self.amount
Expand All @@ -654,7 +667,10 @@ def create(self, mvals):
amount -= line_data.get("amount")
data.append(line_data)
data = record._recompute_suspense_line(
data, reconcile_auxiliary_id, self.manual_reference
data,
reconcile_auxiliary_id,
self.manual_reference,
exchange_recompute=True,
)
if not data.get("can_reconcile"):
continue
Expand Down Expand Up @@ -704,7 +720,10 @@ def button_manual_reference_full_paid(self):
else:
new_data.append(line)
self.reconcile_data_info = self._recompute_suspense_line(
new_data, reconcile_auxiliary_id, self.manual_reference
new_data,
reconcile_auxiliary_id,
self.manual_reference,
exchange_recompute=True,
)
self.can_reconcile = self.reconcile_data_info.get("can_reconcile", False)

Expand Down

0 comments on commit 7d871ba

Please sign in to comment.