Skip to content

Commit

Permalink
Merge pull request frappe#31121 from frappe/mergify/bp/version-13-hot…
Browse files Browse the repository at this point in the history
…fix/pr-31077

fix: Loan repayment entries for payroll payable account (backport frappe#31077)
  • Loading branch information
deepeshgarg007 authored May 25, 2022
2 parents 2ae085d + ea6d754 commit 3528d6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,6 @@ def make_gl_entries(self, cancel=0, adv_adj=0):
"remarks": remarks,
"cost_center": self.cost_center,
"posting_date": getdate(self.posting_date),
"party_type": self.applicant_type if self.repay_from_salary else "",
"party": self.applicant if self.repay_from_salary else "",
}
)
)
Expand Down
10 changes: 10 additions & 0 deletions erpnext/payroll/doctype/payroll_entry/payroll_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
comma_and,
date_diff,
flt,
get_link_to_form,
getdate,
)

Expand Down Expand Up @@ -44,6 +45,7 @@ def on_submit(self):

def before_submit(self):
self.validate_employee_details()
self.validate_payroll_payable_account()
if self.validate_attendance:
if self.validate_employee_attendance():
frappe.throw(_("Cannot Submit, Employees left to mark attendance"))
Expand All @@ -65,6 +67,14 @@ def validate_employee_details(self):
if len(emp_with_sal_slip):
frappe.throw(_("Salary Slip already exists for {0}").format(comma_and(emp_with_sal_slip)))

def validate_payroll_payable_account(self):
if frappe.db.get_value("Account", self.payroll_payable_account, "account_type"):
frappe.throw(
_(
"Account type cannot be set for payroll payable account {0}, please remove and try again"
).format(frappe.bold(get_link_to_form("Account", self.payroll_payable_account)))
)

def on_cancel(self):
frappe.delete_doc(
"Salary Slip",
Expand Down

0 comments on commit 3528d6f

Please sign in to comment.