mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 04:09:11 +00:00
Merge branch 'version-11-hotfix' into quality-inspection-fix
This commit is contained in:
@@ -719,9 +719,23 @@ def get_party_details(company, party_type, party, date, cost_center=None):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_account_details(account, date, cost_center=None):
|
def get_account_details(account, date, cost_center=None):
|
||||||
frappe.has_permission('Payment Entry', throw=True)
|
frappe.has_permission('Payment Entry', throw=True)
|
||||||
|
|
||||||
|
# to check if the passed account is accessible if the reference doctype is Payment Entry
|
||||||
|
account_list = frappe.get_list('Account', {
|
||||||
|
'name': account
|
||||||
|
}, reference_doctype='Payment Entry', limit=1)
|
||||||
|
|
||||||
|
# There might be some user permissions which will allow account under certain doctypes
|
||||||
|
# except for Payment Entry, only in such case we should throw permission error
|
||||||
|
if not account_list:
|
||||||
|
frappe.throw(_('Account: {0} is not permitted under Payment Entry').format(account))
|
||||||
|
|
||||||
|
account_balance = get_balance_on(account, date, cost_center=cost_center,
|
||||||
|
ignore_account_permission=True)
|
||||||
|
|
||||||
return frappe._dict({
|
return frappe._dict({
|
||||||
"account_currency": get_account_currency(account),
|
"account_currency": get_account_currency(account),
|
||||||
"account_balance": get_balance_on(account, date, cost_center=cost_center),
|
"account_balance": account_balance,
|
||||||
"account_type": frappe.db.get_value("Account", account, "account_type")
|
"account_type": frappe.db.get_value("Account", account, "account_type")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ def validate_fiscal_year(date, fiscal_year, company, label="Date", doc=None):
|
|||||||
throw(_("{0} '{1}' not in Fiscal Year {2}").format(label, formatdate(date), fiscal_year))
|
throw(_("{0} '{1}' not in Fiscal Year {2}").format(label, formatdate(date), fiscal_year))
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_balance_on(account=None, date=None, party_type=None, party=None, company=None, in_account_currency=True, cost_center=None):
|
def get_balance_on(account=None, date=None, party_type=None, party=None, company=None,
|
||||||
|
in_account_currency=True, cost_center=None, ignore_account_permission=False):
|
||||||
if not account and frappe.form_dict.get("account"):
|
if not account and frappe.form_dict.get("account"):
|
||||||
account = frappe.form_dict.get("account")
|
account = frappe.form_dict.get("account")
|
||||||
if not date and frappe.form_dict.get("date"):
|
if not date and frappe.form_dict.get("date"):
|
||||||
@@ -140,7 +141,8 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company
|
|||||||
|
|
||||||
if account:
|
if account:
|
||||||
|
|
||||||
if not frappe.flags.ignore_account_permission:
|
if not (frappe.flags.ignore_account_permission
|
||||||
|
or ignore_account_permission):
|
||||||
acc.check_permission("read")
|
acc.check_permission("read")
|
||||||
|
|
||||||
if report_type == 'Profit and Loss':
|
if report_type == 'Profit and Loss':
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ frappe.ui.form.on('Payroll Entry', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
add_context_buttons: function(frm) {
|
add_context_buttons: function(frm) {
|
||||||
if(frm.doc.salary_slips_submitted) {
|
if(frm.doc.salary_slips_submitted || (frm.doc.__onload && frm.doc.__onload.submitted_ss)) {
|
||||||
frm.events.add_bank_entry_button(frm);
|
frm.events.add_bank_entry_button(frm);
|
||||||
} else if(frm.doc.salary_slips_created) {
|
} else if(frm.doc.salary_slips_created) {
|
||||||
frm.add_custom_button(__("Submit Salary Slip"), function() {
|
frm.add_custom_button(__("Submit Salary Slip"), function() {
|
||||||
|
|||||||
@@ -13,14 +13,13 @@ from erpnext.hr.doctype.employee.employee import get_holiday_list_for_employee
|
|||||||
|
|
||||||
class PayrollEntry(Document):
|
class PayrollEntry(Document):
|
||||||
def onload(self):
|
def onload(self):
|
||||||
if not self.docstatus==1:
|
if not self.docstatus==1 or self.salary_slips_submitted:
|
||||||
return
|
return
|
||||||
|
|
||||||
# check if salary slips were manually submitted
|
# check if salary slips were manually submitted
|
||||||
entries = frappe.db.count("Salary Slip", {'payroll_entry': self.name, 'docstatus': 1}, ['name'])
|
entries = frappe.db.count("Salary Slip", {'payroll_entry': self.name, 'docstatus': 1}, ['name'])
|
||||||
if cint(entries) == len(self.employees) and not self.salary_slips_submitted:
|
if cint(entries) == len(self.employees):
|
||||||
self.db_set("salary_slips_submitted", 1)
|
self.set_onload("submitted_ss", True)
|
||||||
self.reload()
|
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.create_salary_slips()
|
self.create_salary_slips()
|
||||||
@@ -423,7 +422,6 @@ def get_start_end_dates(payroll_frequency, start_date=None, company=None):
|
|||||||
'start_date': start_date, 'end_date': end_date
|
'start_date': start_date, 'end_date': end_date
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def get_frequency_kwargs(frequency_name):
|
def get_frequency_kwargs(frequency_name):
|
||||||
frequency_dict = {
|
frequency_dict = {
|
||||||
'monthly': {'months': 1},
|
'monthly': {'months': 1},
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ class Company(NestedSet):
|
|||||||
def set_mode_of_payment_account(self):
|
def set_mode_of_payment_account(self):
|
||||||
cash = frappe.db.get_value('Mode of Payment', {'type': 'Cash'}, 'name')
|
cash = frappe.db.get_value('Mode of Payment', {'type': 'Cash'}, 'name')
|
||||||
if cash and self.default_cash_account \
|
if cash and self.default_cash_account \
|
||||||
and not frappe.db.get_value('Mode of Payment Account', {'company': self.name}):
|
and not frappe.db.get_value('Mode of Payment Account', {'company': self.name, 'parent': cash}):
|
||||||
mode_of_payment = frappe.get_doc('Mode of Payment', cash)
|
mode_of_payment = frappe.get_doc('Mode of Payment', cash)
|
||||||
mode_of_payment.append('accounts', {
|
mode_of_payment.append('accounts', {
|
||||||
'company': self.name,
|
'company': self.name,
|
||||||
|
|||||||
Reference in New Issue
Block a user