Merge branch 'master' of github.com:webnotes/erpnext into edge
diff --git a/accounts/utils.py b/accounts/utils.py
index b2a2b2c..effc906 100644
--- a/accounts/utils.py
+++ b/accounts/utils.py
@@ -20,11 +20,11 @@
from webnotes.utils import nowdate, cstr, flt
from webnotes.model.doc import addchild
from webnotes import msgprint, _
+from webnotes.utils import formatdate
class FiscalYearError(webnotes.ValidationError): pass
def get_fiscal_year(date, verbose=1):
- from webnotes.utils import formatdate
# if year start date is 2012-04-01, year end date should be 2013-03-31 (hence subdate)
fy = webnotes.conn.sql("""select name, year_start_date,
subdate(adddate(year_start_date, interval 1 year), interval 1 day)
@@ -39,6 +39,15 @@
raise FiscalYearError, error_msg
return fy[0]
+
+def validate_fiscal_year(date, fiscal_year, label="Date"):
+ if get_fiscal_year(date)[0] != fiscal_year:
+ msgprint(("%(label)s '%(posting_date)s': " + _("not within Fiscal Year") + \
+ ": '%(fiscal_year)s'") % {
+ "label": label,
+ "posting_date": formatdate(date),
+ "fiscal_year": fiscal_year
+ }, raise_exception=1)
@webnotes.whitelist()
def get_balance_on(account=None, date=None):
diff --git a/hr/doctype/department/department.txt b/hr/doctype/department/department.txt
index a4730cc..34b6bc7 100644
--- a/hr/doctype/department/department.txt
+++ b/hr/doctype/department/department.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:13",
"docstatus": 0,
- "modified": "2013-01-22 14:46:41",
+ "modified": "2013-02-04 15:34:55",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -58,6 +58,14 @@
"reqd": 1
},
{
+ "description": "Days for which Holidays are blocked for this department.",
+ "doctype": "DocField",
+ "fieldname": "holiday_block_list",
+ "fieldtype": "Link",
+ "label": "Holiday Block List",
+ "options": "Holiday Block List"
+ },
+ {
"doctype": "DocPerm",
"role": "System Manager"
},
diff --git a/hr/doctype/holiday_block_list/__init__.py b/hr/doctype/holiday_block_list/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hr/doctype/holiday_block_list/__init__.py
diff --git a/hr/doctype/holiday_block_list/holiday_block_list.py b/hr/doctype/holiday_block_list/holiday_block_list.py
new file mode 100644
index 0000000..5dcf88e
--- /dev/null
+++ b/hr/doctype/holiday_block_list/holiday_block_list.py
@@ -0,0 +1,21 @@
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import webnotes
+from accounts.utils import validate_fiscal_year
+from webnotes import _
+
+class DocType:
+ def __init__(self, d, dl):
+ self.doc, self.doclist = d, dl
+
+ def validate(self):
+ dates = []
+ for d in self.doclist.get({"doctype":"Holiday Block List Date"}):
+ # validate fiscal year
+ validate_fiscal_year(d.block_date, self.doc.year, _("Block Date"))
+
+ # date is not repeated
+ if d.block_date in dates:
+ webnotes.msgprint(_("Date is repeated") + ":" + d.block_date, raise_exception=1)
+ dates.append(d.block_date)
diff --git a/hr/doctype/holiday_block_list/holiday_block_list.txt b/hr/doctype/holiday_block_list/holiday_block_list.txt
new file mode 100644
index 0000000..732e783
--- /dev/null
+++ b/hr/doctype/holiday_block_list/holiday_block_list.txt
@@ -0,0 +1,66 @@
+[
+ {
+ "creation": "2013-02-04 15:31:29",
+ "docstatus": 0,
+ "modified": "2013-02-04 15:38:57",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "autoname": "field:holiday_block_list_name",
+ "description": "Block Holidays on important days.",
+ "doctype": "DocType",
+ "document_type": "Master",
+ "module": "HR",
+ "name": "__common__"
+ },
+ {
+ "doctype": "DocField",
+ "name": "__common__",
+ "parent": "Holiday Block List",
+ "parentfield": "fields",
+ "parenttype": "DocType",
+ "permlevel": 0
+ },
+ {
+ "create": 1,
+ "doctype": "DocPerm",
+ "name": "__common__",
+ "parent": "Holiday Block List",
+ "parentfield": "permissions",
+ "parenttype": "DocType",
+ "permlevel": 0,
+ "read": 1,
+ "role": "HR User",
+ "write": 1
+ },
+ {
+ "doctype": "DocType",
+ "name": "Holiday Block List"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "holiday_block_list_name",
+ "fieldtype": "Data",
+ "label": "Holiday Block List Name",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "year",
+ "fieldtype": "Link",
+ "label": "Year",
+ "options": "Fiscal Year",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "holiday_block_list_dates",
+ "fieldtype": "Table",
+ "label": "Holiday Block List Dates",
+ "options": "Holiday Block List Date"
+ },
+ {
+ "doctype": "DocPerm"
+ }
+]
\ No newline at end of file
diff --git a/hr/doctype/holiday_block_list_date/__init__.py b/hr/doctype/holiday_block_list_date/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hr/doctype/holiday_block_list_date/__init__.py
diff --git a/hr/doctype/holiday_block_list_date/holiday_block_list_date.py b/hr/doctype/holiday_block_list_date/holiday_block_list_date.py
new file mode 100644
index 0000000..928aa9f
--- /dev/null
+++ b/hr/doctype/holiday_block_list_date/holiday_block_list_date.py
@@ -0,0 +1,8 @@
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+class DocType:
+ def __init__(self, d, dl):
+ self.doc, self.doclist = d, dl
\ No newline at end of file
diff --git a/hr/doctype/holiday_block_list_date/holiday_block_list_date.txt b/hr/doctype/holiday_block_list_date/holiday_block_list_date.txt
new file mode 100644
index 0000000..69375fe
--- /dev/null
+++ b/hr/doctype/holiday_block_list_date/holiday_block_list_date.txt
@@ -0,0 +1,40 @@
+[
+ {
+ "creation": "2013-02-04 15:33:14",
+ "docstatus": 0,
+ "modified": "2013-02-04 15:36:10",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "DocType",
+ "istable": 1,
+ "module": "HR",
+ "name": "__common__"
+ },
+ {
+ "doctype": "DocField",
+ "name": "__common__",
+ "parent": "Holiday Block List Date",
+ "parentfield": "fields",
+ "parenttype": "DocType",
+ "permlevel": 0,
+ "width": "200px"
+ },
+ {
+ "doctype": "DocType",
+ "name": "Holiday Block List Date"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "block_date",
+ "fieldtype": "Date",
+ "label": "Block Date"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "reason",
+ "fieldtype": "Text",
+ "label": "Reason"
+ }
+]
\ No newline at end of file
diff --git a/hr/page/hr_home/hr_home.js b/hr/page/hr_home/hr_home.js
index fe2c5d4..8c52e0e 100644
--- a/hr/page/hr_home/hr_home.js
+++ b/hr/page/hr_home/hr_home.js
@@ -80,6 +80,11 @@
"description":wn._("List of holidays."),
doctype: "Holiday List"
},
+ {
+ "label":wn._("Holiday Block List"),
+ "description":wn._("Block leave applications by department."),
+ doctype: "Holiday Block List"
+ },
]
},
{
diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py
index 4f883b2..21287b0 100644
--- a/selling/doctype/sales_common/sales_common.py
+++ b/selling/doctype/sales_common/sales_common.py
@@ -599,14 +599,8 @@
get_obj('Account',acc_head[0][0]).check_credit_limit(acc_head[0][0], obj.doc.company, exact_outstanding)
def validate_fiscal_year(self, fiscal_year, transaction_date, label):
- from accounts.utils import get_fiscal_year
- if get_fiscal_year(transaction_date)[0] != fiscal_year:
- msgprint(("%(label)s '%(posting_date)s': " + _("not within Fiscal Year") + \
- ": '%(fiscal_year)s'") % {
- "label": label,
- "posting_date": formatdate(transaction_date),
- "fiscal_year": fiscal_year
- }, raise_exception=1)
+ import accounts.utils
+ accounts.utils.validate_fiscal_year(transaction_date, fiscal_year, label)
def get_prevdoc_date(self, obj):
for d in getlist(obj.doclist, obj.fname):