mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
Merge branch 'develop'
This commit is contained in:
@@ -1 +1 @@
|
|||||||
__version__ = '4.11.0'
|
__version__ = '4.11.1'
|
||||||
|
|||||||
@@ -310,22 +310,19 @@ class JournalVoucher(AccountsController):
|
|||||||
self.total_amount_in_words = money_in_words(amt, company_currency)
|
self.total_amount_in_words = money_in_words(amt, company_currency)
|
||||||
|
|
||||||
def check_credit_days(self):
|
def check_credit_days(self):
|
||||||
date_diff = 0
|
|
||||||
if self.cheque_date:
|
if self.cheque_date:
|
||||||
date_diff = (getdate(self.cheque_date)-getdate(self.posting_date)).days
|
for d in self.get("entries"):
|
||||||
|
if flt(d.credit) > 0 and d.against_invoice \
|
||||||
if date_diff <= 0: return
|
and frappe.db.get_value("Account", d.account, "master_type")=='Customer':
|
||||||
|
posting_date = frappe.db.get_value("Sales Invoice", d.against_invoice, "posting_date")
|
||||||
# Get List of Customer Account
|
credit_days = self.get_credit_days_for(d.account)
|
||||||
acc_list = filter(lambda d: frappe.db.get_value("Account", d.account,
|
if credit_days:
|
||||||
"master_type")=='Customer', self.get('entries'))
|
date_diff = (getdate(self.cheque_date) - getdate(posting_date)).days
|
||||||
|
if date_diff > flt(credit_days):
|
||||||
for d in acc_list:
|
msgprint(_("Note: Reference Date exceeds allowed credit days by {0} days for {1}")
|
||||||
credit_days = self.get_credit_days_for(d.account)
|
.format(date_diff - flt(credit_days), d.account))
|
||||||
# Check credit days
|
if not self.get_authorized_user():
|
||||||
if credit_days > 0 and not self.get_authorized_user() and cint(date_diff) > credit_days:
|
raise frappe.ValidationError
|
||||||
msgprint(_("Maximum allowed credit is {0} days after posting date").format(credit_days),
|
|
||||||
raise_exception=1)
|
|
||||||
|
|
||||||
def get_credit_days_for(self, ac):
|
def get_credit_days_for(self, ac):
|
||||||
if not self.credit_days_for.has_key(ac):
|
if not self.credit_days_for.has_key(ac):
|
||||||
@@ -333,8 +330,7 @@ class JournalVoucher(AccountsController):
|
|||||||
|
|
||||||
if not self.credit_days_for[ac]:
|
if not self.credit_days_for[ac]:
|
||||||
if self.credit_days_global==-1:
|
if self.credit_days_global==-1:
|
||||||
self.credit_days_global = cint(frappe.db.get_value("Company",
|
self.credit_days_global = cint(frappe.db.get_value("Company", self.company, "credit_days"))
|
||||||
self.company, "credit_days"))
|
|
||||||
|
|
||||||
return self.credit_days_global
|
return self.credit_days_global
|
||||||
else:
|
else:
|
||||||
@@ -343,10 +339,7 @@ class JournalVoucher(AccountsController):
|
|||||||
def get_authorized_user(self):
|
def get_authorized_user(self):
|
||||||
if self.is_approving_authority==-1:
|
if self.is_approving_authority==-1:
|
||||||
self.is_approving_authority = 0
|
self.is_approving_authority = 0
|
||||||
|
approving_authority = frappe.db.get_value("Accounts Settings", None, "credit_controller")
|
||||||
# Fetch credit controller role
|
|
||||||
approving_authority = frappe.db.get_value("Accounts Settings", None,
|
|
||||||
"credit_controller")
|
|
||||||
|
|
||||||
# Check logged-in user is authorized
|
# Check logged-in user is authorized
|
||||||
if approving_authority in frappe.user.get_roles():
|
if approving_authority in frappe.user.get_roles():
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, scrub
|
from frappe import _
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
import json
|
import json
|
||||||
@@ -93,7 +93,7 @@ def get_orders_to_be_billed(party_type, party_name):
|
|||||||
and docstatus = 1
|
and docstatus = 1
|
||||||
and ifnull(status, "") != "Stopped"
|
and ifnull(status, "") != "Stopped"
|
||||||
and ifnull(grand_total, 0) > ifnull(advance_paid, 0)
|
and ifnull(grand_total, 0) > ifnull(advance_paid, 0)
|
||||||
and ifnull(per_billed, 0) < 100.0
|
and abs(100 - ifnull(per_billed, 0)) > 0.01
|
||||||
""" % (voucher_type, 'customer' if party_type == "Customer" else 'supplier', '%s'),
|
""" % (voucher_type, 'customer' if party_type == "Customer" else 'supplier', '%s'),
|
||||||
party_name, as_dict = True)
|
party_name, as_dict = True)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ app_publisher = "Web Notes Technologies Pvt. Ltd. and Contributors"
|
|||||||
app_description = "Open Source Enterprise Resource Planning for Small and Midsized Organizations"
|
app_description = "Open Source Enterprise Resource Planning for Small and Midsized Organizations"
|
||||||
app_icon = "icon-th"
|
app_icon = "icon-th"
|
||||||
app_color = "#e74c3c"
|
app_color = "#e74c3c"
|
||||||
app_version = "4.11.0"
|
app_version = "4.11.1"
|
||||||
|
|
||||||
error_report_email = "support@erpnext.com"
|
error_report_email = "support@erpnext.com"
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,15 @@ cur_frm.cscript.calculate_total_days = function(doc, dt, dn) {
|
|||||||
if(cint(doc.half_day) == 1) set_multiple(dt,dn,{total_leave_days:0.5});
|
if(cint(doc.half_day) == 1) set_multiple(dt,dn,{total_leave_days:0.5});
|
||||||
else{
|
else{
|
||||||
// server call is done to include holidays in leave days calculations
|
// server call is done to include holidays in leave days calculations
|
||||||
return get_server_fields('get_total_leave_days', '', '', doc, dt, dn, 1);
|
return frappe.call({
|
||||||
|
method: 'erpnext.hr.doctype.leave_application.leave_application.get_total_leave_days',
|
||||||
|
args: {leave_app: doc},
|
||||||
|
callback: function(response) {
|
||||||
|
if (response && response.message) {
|
||||||
|
cur_frm.set_value('total_leave_days', response.message.total_leave_days);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe, json
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
from frappe.utils import cint, cstr, date_diff, flt, formatdate, getdate, get_url_to_form, \
|
from frappe.utils import cint, cstr, date_diff, flt, formatdate, getdate, get_url_to_form, \
|
||||||
@@ -77,26 +77,10 @@ class LeaveApplication(Document):
|
|||||||
LeaveDayBlockedError)
|
LeaveDayBlockedError)
|
||||||
|
|
||||||
def get_holidays(self):
|
def get_holidays(self):
|
||||||
tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2, `tabEmployee` e1
|
return get_holidays(self)
|
||||||
where e1.name = %s and h1.parent = h2.name and e1.holiday_list = h2.name
|
|
||||||
and h1.holiday_date between %s and %s""", (self.employee, self.from_date, self.to_date))
|
|
||||||
if not tot_hol:
|
|
||||||
tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2
|
|
||||||
where h1.parent = h2.name and h1.holiday_date between %s and %s
|
|
||||||
and ifnull(h2.is_default,0) = 1 and h2.fiscal_year = %s""",
|
|
||||||
(self.from_date, self.to_date, self.fiscal_year))
|
|
||||||
return tot_hol and flt(tot_hol[0][0]) or 0
|
|
||||||
|
|
||||||
def get_total_leave_days(self):
|
def get_total_leave_days(self):
|
||||||
"""Calculates total leave days based on input and holidays"""
|
return get_total_leave_days(self)
|
||||||
ret = {'total_leave_days' : 0.5}
|
|
||||||
if not self.half_day:
|
|
||||||
tot_days = date_diff(self.to_date, self.from_date) + 1
|
|
||||||
holidays = self.get_holidays()
|
|
||||||
ret = {
|
|
||||||
'total_leave_days' : flt(tot_days)-flt(holidays)
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def validate_to_date(self):
|
def validate_to_date(self):
|
||||||
if self.from_date and self.to_date and \
|
if self.from_date and self.to_date and \
|
||||||
@@ -216,6 +200,33 @@ class LeaveApplication(Document):
|
|||||||
post(**{"txt": args.message, "contact": args.message_to, "subject": args.subject,
|
post(**{"txt": args.message, "contact": args.message_to, "subject": args.subject,
|
||||||
"notify": cint(self.follow_via_email)})
|
"notify": cint(self.follow_via_email)})
|
||||||
|
|
||||||
|
def get_holidays(leave_app):
|
||||||
|
tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2, `tabEmployee` e1
|
||||||
|
where e1.name = %s and h1.parent = h2.name and e1.holiday_list = h2.name
|
||||||
|
and h1.holiday_date between %s and %s""", (leave_app.employee, leave_app.from_date, leave_app.to_date))
|
||||||
|
if not tot_hol:
|
||||||
|
tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2
|
||||||
|
where h1.parent = h2.name and h1.holiday_date between %s and %s
|
||||||
|
and ifnull(h2.is_default,0) = 1 and h2.fiscal_year = %s""",
|
||||||
|
(leave_app.from_date, leave_app.to_date, leave_app.fiscal_year))
|
||||||
|
return tot_hol and flt(tot_hol[0][0]) or 0
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_total_leave_days(leave_app):
|
||||||
|
# Parse Leave Application if neccessary
|
||||||
|
if isinstance(leave_app, str) or isinstance(leave_app, unicode):
|
||||||
|
leave_app = frappe.get_doc(json.loads(leave_app))
|
||||||
|
|
||||||
|
"""Calculates total leave days based on input and holidays"""
|
||||||
|
ret = {'total_leave_days' : 0.5}
|
||||||
|
if not leave_app.half_day:
|
||||||
|
tot_days = date_diff(leave_app.to_date, leave_app.from_date) + 1
|
||||||
|
holidays = leave_app.get_holidays()
|
||||||
|
ret = {
|
||||||
|
'total_leave_days' : flt(tot_days)-flt(holidays)
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_leave_balance(employee, leave_type, fiscal_year):
|
def get_leave_balance(employee, leave_type, fiscal_year):
|
||||||
leave_all = frappe.db.sql("""select total_leaves_allocated
|
leave_all = frappe.db.sql("""select total_leaves_allocated
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -1,7 +1,7 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
import os
|
import os
|
||||||
|
|
||||||
version = "4.11.0"
|
version = "4.11.1"
|
||||||
|
|
||||||
with open("requirements.txt", "r") as f:
|
with open("requirements.txt", "r") as f:
|
||||||
install_requires = f.readlines()
|
install_requires = f.readlines()
|
||||||
|
|||||||
Reference in New Issue
Block a user