Skip to content

Commit

Permalink
[UPD] ssi_voucher_mixin
Browse files Browse the repository at this point in the history
* Memperbaiki perhitungan realized gain/loss
  • Loading branch information
andhit-r committed Aug 19, 2024
1 parent 240966b commit e05983d
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions ssi_voucher_mixin/models/voucher_line_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,15 @@ def _compute_amount(self):
def _get_debit_credit(self):
self.ensure_one()
debit = credit = 0.0
if self.move_line_id:
amount = self.amount_company_currency_move_date
else:
amount = self.amount_company_currency_voucher_date

# TODO:
# if self.move_line_id:
# amount = self.amount_company_currency_move_date
# else:
# amount = self.amount_company_currency_voucher_date

amount = self.amount_company_currency_voucher_date

if self.type == "dr":
if amount > 0:
debit = abs(amount)
Expand All @@ -194,18 +199,32 @@ def _get_currency_exchange_information(self):
debit = credit = 0.0
amount = self.amount_diff_in_company_currency
company = self.env.user.company_id
if (self.type == "dr" and amount > 0.0) or (self.type == "cr" and amount < 0.0):
if self.type == "dr" and amount > 0.0:
credit = abs(amount)
account_id = (
company.expense_currency_exchange_account_id
and company.expense_currency_exchange_account_id.id
or False
)
elif self.type == "dr" and amount < 0.0:
debit = abs(amount)
account_id = (
company.expense_currency_exchange_account_id
and company.expense_currency_exchange_account_id.id
or False
)
else:
elif self.type == "cr" and amount < 0.0:
credit = abs(amount)
account_id = (
company.income_currency_exchange_account_id
and company.income_currency_exchange_account_id.id
company.expense_currency_exchange_account_id
and company.expense_currency_exchange_account_id.id
or False
)
elif self.type == "cr" and amount > 0.0:
debit = abs(amount)
account_id = (
company.expense_currency_exchange_account_id
and company.expense_currency_exchange_account_id.id
or False
)
return (debit, credit, account_id)
Expand Down

0 comments on commit e05983d

Please sign in to comment.