Skip to content

Commit

Permalink
test: precision in Employee Advance
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal committed Jan 22, 2024
1 parent 5869481 commit 1817dbf
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions hrms/hr/doctype/employee_advance/test_employee_advance.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,45 @@ def test_payment_entry_against_advance(self):
self.assertEqual(advance.status, "Unpaid")
self.assertEqual(advance.paid_amount, 700)

def test_precision(self):
employee_name = make_employee("[email protected]")
advance = make_employee_advance(employee_name)
journal_entry = make_journal_entry_for_advance(advance)
journal_entry.submit()

# PARTLY CLAIMED AND RETURNED
payable_account = get_payable_account("_Test Company")
claim = make_expense_claim(
payable_account, 650.35, 619.34, "_Test Company", "Travel Expenses - _TC", do_not_submit=True
)

claim = get_advances_for_claim(claim, advance.name, amount=619.34)
claim.save()
claim.submit()

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

entry = make_return_entry(
employee=advance.employee,
company=advance.company,
employee_advance_name=advance.name,
return_amount=advance.paid_amount - advance.claimed_amount,
advance_account=advance.advance_account,
mode_of_payment=advance.mode_of_payment,
currency=advance.currency,
exchange_rate=advance.exchange_rate,
)

entry = frappe.get_doc(entry)
entry.insert()
entry.submit()

advance.reload()
# precision is respected
self.assertEqual(advance.return_amount, 380.66)
self.assertEqual(advance.status, "Partly Claimed and Returned")


def make_journal_entry_for_advance(advance):
journal_entry = frappe.get_doc(make_bank_entry("Employee Advance", advance.name))
Expand Down

0 comments on commit 1817dbf

Please sign in to comment.