Skip to content
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: 2 additions & 0 deletions hrms/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@

bank_reconciliation_doctypes = ["Expense Claim"]

audit_trail_doctypes = ["Expense Claim", "Payroll Entry", "Salary Slip", "Leave Encashment", "Gratuity"]

# Testing
# -------

Expand Down
2 changes: 1 addition & 1 deletion hrms/hr/doctype/expense_claim/expense_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def create_exchange_gain_loss_je(self):
per_advance_gain_loss = 0
total_advance_exchange_gain_loss = 0
for advance in self.advances:
if advance.base_allocated_amount and self.base_total_advance_amount:
if advance.exchange_rate and advance.base_allocated_amount and self.base_total_advance_amount:
allocated_amount_in_adv_exchange_rate = flt(advance.allocated_amount) * flt(
advance.exchange_rate
)
Expand Down
37 changes: 37 additions & 0 deletions hrms/hr/doctype/expense_claim/test_expense_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,43 @@ def test_advance_claim_multicurrency_gain_loss(self):
self.assertEqual(gain_loss_jv.total_debit, 2100)
self.assertEqual(gain_loss_jv.total_credit, 2100)

def test_no_exchange_gain_loss_when_advance_exchange_rate_missing(self):
from hrms.hr.doctype.employee_advance.test_employee_advance import (
get_advances_for_claim,
make_employee_advance,
make_payment_entry,
)

employee = make_employee("test_advance_claim_missing_exchange_rate@example.com", "_Test Company")
advance = make_employee_advance(employee)
self.assertEqual(advance.status, "Unpaid")

make_payment_entry(advance, advance.advance_amount)
advance.reload()
self.assertEqual(advance.status, "Paid")

claim = make_expense_claim(
get_payable_account("_Test Company"),
advance.advance_amount,
advance.advance_amount,
"_Test Company",
"Travel Expenses - _TC",
employee=employee,
do_not_submit=True,
)

claim = get_advances_for_claim(claim, advance.name)
for claim_advance in claim.advances:
claim_advance.exchange_rate = 0

claim.save().submit()
claim.reload()

for claim_advance in claim.advances:
self.assertEqual(claim_advance.exchange_gain_loss, 0)
self.assertEqual(claim.total_exchange_gain_loss, 0)
self.assertFalse(claim.gain_loss_account)

def test_expense_claim_status_as_payment_after_unreconciliation(self):
from hrms.hr.doctype.employee_advance.test_employee_advance import make_payment_entry

Expand Down
Loading
Loading