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

[UPD] ssi_voucher_mixin #140

Merged
merged 1 commit into from
Aug 19, 2024
Merged
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
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
Loading