-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1341 from frappe/mergify/bp/version-14-hotfix/pr-…
…1340 fix(Employee Advance): respect precision for return & paid amount (backport #1340)
- Loading branch information
Showing
2 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) | ||
|