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

handle cases when currency diff occurs #229

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions account_offbalance_sponsorship/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@
"depends": [
"base",
"sponsorship_compassion",
#'account_reconcile_compassion',
],
# always loaded
"data": [
# 'security/ir.model.access.csv',
"views/res_config_view.xml",
],
}
16 changes: 16 additions & 0 deletions account_offbalance_sponsorship/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,23 @@ def get_account_offbalance(self, company):
)

def reconcile(self):
#check if there is a currency diff and relaod the invoice with the rate received
total = total_curr = 0
for l in self:
total=l.debit-l.credit+total
total_curr=l.amount_currency+total_curr
if total != 0 and total_curr == 0:
inv_to_refresh=self.filtered(lambda l:l.move_id.journal_id.type == 'sale').move_id
nr = self.filtered(lambda l: l.move_id.journal_id.type != 'sale')
new_rate=sum(n.amount_currency for n in nr)/sum(n.debit-n.credit for n in nr)
inv_to_refresh.button_draft()
for line in inv_to_refresh.line_ids:
line.debit = abs(line.amount_currency/new_rate) if line.amount_currency>0 else 0
line.credit = abs(line.amount_currency/new_rate) if line.amount_currency<0 else 0
inv_to_refresh.action_post()
#reconcile
res = super().reconcile()
#check if the reconcile is regarding off balance moves
(
account_offbalance_receivable,
account_offbalance_asset,
Expand Down
Loading