Skip to content

Commit

Permalink
Merge pull request #853 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal authored Sep 6, 2023
2 parents f041d37 + 43ee8cb commit cfa3d79
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
35 changes: 35 additions & 0 deletions hrms/hr/doctype/expense_claim/test_expense_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,41 @@ def test_expense_claim_gl_entry(self):
self.assertEqual(expected_values[gle.account][1], gle.debit)
self.assertEqual(expected_values[gle.account][2], gle.credit)

def test_invalid_gain_loss_for_expense_claim(self):
payable_account = get_payable_account(company_name)
taxes = generate_taxes()
expense_claim = make_expense_claim(
payable_account,
300,
200,
company_name,
"Travel Expenses - _TC3",
do_not_submit=True,
taxes=taxes,
)
expense_claim.submit()

from hrms.overrides.employee_payment_entry import get_payment_entry_for_employee

pe = get_payment_entry_for_employee(expense_claim.doctype, expense_claim.name)
pe.save()
pe.submit()
self.assertEqual(len(pe.references), 1)
self.assertEqual(pe.references[0].exchange_gain_loss, 0.0)
self.assertEqual(pe.references[0].exchange_rate, 1.0)
# Invalid gain/loss JE shouldn't be created for base currency Expense Claims
self.assertEqual(
frappe.db.get_all(
"Journal Entry Account",
filters={
"reference_type": expense_claim.doctype,
"reference_name": expense_claim.name,
"docstatus": 1,
},
),
[],
)

def test_rejected_expense_claim(self):
payable_account = get_payable_account(company_name)
expense_claim = frappe.get_doc(
Expand Down
1 change: 1 addition & 0 deletions hrms/overrides/employee_payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def get_payment_entry_for_employee(dt, dn, party_amount=None, bank_account=None,

pe.setup_party_account_field()
pe.set_missing_values()
pe.set_missing_ref_details()

if party_account and bank:
reference_doc = None
Expand Down
3 changes: 2 additions & 1 deletion hrms/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ hrms.patches.v14_0.create_custom_field_for_appraisal_template
hrms.patches.post_install.update_performance_module_changes #2023-04-17
hrms.patches.v14_0.update_ess_user_access #2023-08-14
execute:frappe.db.set_default("date_format", frappe.db.get_single_value("System Settings", "date_format"))
hrms.patches.v14_0.create_vehicle_service_item
hrms.patches.v14_0.create_vehicle_service_item
hrms.patches.v14_0.update_repay_from_salary_and_payroll_payable_account_fields
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import frappe


def execute():
if frappe.db.exists("Custom Field", {"name": "Loan Repayment-repay_from_salary"}):
frappe.db.set_value(
"Custom Field", {"name": "Loan Repayment-repay_from_salary"}, "fetch_if_empty", 1
)

if frappe.db.exists("Custom Field", {"name": "Loan Repayment-payroll_payable_account"}):
frappe.db.set_value(
"Custom Field",
{"name": "Loan Repayment-payroll_payable_account"},
"insert_after",
"payment_account",
)
3 changes: 2 additions & 1 deletion hrms/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def get_custom_fields():
{
"default": "0",
"fetch_from": "against_loan.repay_from_salary",
"fetch_if_empty": 1,
"fieldname": "repay_from_salary",
"fieldtype": "Check",
"label": "Repay From Salary",
Expand All @@ -317,7 +318,7 @@ def get_custom_fields():
"label": "Payroll Payable Account",
"mandatory_depends_on": "eval:doc.repay_from_salary",
"options": "Account",
"insert_after": "rate_of_interest",
"insert_after": "payment_account",
},
],
}
Expand Down

0 comments on commit cfa3d79

Please sign in to comment.