Skip to content

Commit 71f8d0e

Browse files
authored
Merge pull request #1346 from frappe/version-14-hotfix
chore: release v14
2 parents eff5365 + fead850 commit 71f8d0e

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

hrms/hr/doctype/employee_advance/employee_advance.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,18 @@ def set_total_advance_paid(self):
103103
if return_amount != 0:
104104
return_amount = flt(return_amount) / flt(self.exchange_rate)
105105

106-
if flt(paid_amount) > self.advance_amount:
106+
precision = self.precision("paid_amount")
107+
paid_amount = flt(paid_amount, precision)
108+
if paid_amount > flt(self.advance_amount, precision):
107109
frappe.throw(
108110
_("Row {0}# Paid Amount cannot be greater than requested advance amount"),
109111
EmployeeAdvanceOverPayment,
110112
)
111113

112-
if flt(return_amount) > 0 and flt(return_amount) > (self.paid_amount - self.claimed_amount):
114+
precision = self.precision("return_amount")
115+
return_amount = flt(return_amount, precision)
116+
117+
if return_amount > 0 and return_amount > flt(self.paid_amount - self.claimed_amount, precision):
113118
frappe.throw(_("Return amount cannot be greater than unclaimed amount"))
114119

115120
self.db_set("paid_amount", paid_amount)

hrms/hr/doctype/employee_advance/test_employee_advance.py

+39
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,45 @@ def test_payment_entry_against_advance(self):
219219
self.assertEqual(advance.status, "Unpaid")
220220
self.assertEqual(advance.paid_amount, 700)
221221

222+
def test_precision(self):
223+
employee_name = make_employee("[email protected]")
224+
advance = make_employee_advance(employee_name)
225+
journal_entry = make_journal_entry_for_advance(advance)
226+
journal_entry.submit()
227+
228+
# PARTLY CLAIMED AND RETURNED
229+
payable_account = get_payable_account("_Test Company")
230+
claim = make_expense_claim(
231+
payable_account, 650.35, 619.34, "_Test Company", "Travel Expenses - _TC", do_not_submit=True
232+
)
233+
234+
claim = get_advances_for_claim(claim, advance.name, amount=619.34)
235+
claim.save()
236+
claim.submit()
237+
238+
advance.reload()
239+
self.assertEqual(advance.status, "Paid")
240+
241+
entry = make_return_entry(
242+
employee=advance.employee,
243+
company=advance.company,
244+
employee_advance_name=advance.name,
245+
return_amount=advance.paid_amount - advance.claimed_amount,
246+
advance_account=advance.advance_account,
247+
mode_of_payment=advance.mode_of_payment,
248+
currency=advance.currency,
249+
exchange_rate=advance.exchange_rate,
250+
)
251+
252+
entry = frappe.get_doc(entry)
253+
entry.insert()
254+
entry.submit()
255+
256+
advance.reload()
257+
# precision is respected
258+
self.assertEqual(advance.return_amount, 380.66)
259+
self.assertEqual(advance.status, "Partly Claimed and Returned")
260+
222261

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

hrms/payroll/doctype/payroll_entry/payroll_entry.js

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ frappe.ui.form.on('Payroll Entry', {
5050
},
5151

5252
refresh: function (frm) {
53+
if (frm.doc.status === "Queued") frm.page.btn_secondary.hide()
54+
5355
if (frm.doc.docstatus === 0 && !frm.is_new()) {
5456
frm.page.clear_primary_action();
5557
frm.add_custom_button(__("Get Employees"),

0 commit comments

Comments
 (0)