mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
Merge branch 'edge' of github.com:webnotes/erpnext into edge
This commit is contained in:
@@ -248,22 +248,23 @@ class DocType(AccountsController):
|
|||||||
from accounts.general_ledger import make_gl_entries
|
from accounts.general_ledger import make_gl_entries
|
||||||
gl_map = []
|
gl_map = []
|
||||||
for d in self.doclist.get({"parentfield": "entries"}):
|
for d in self.doclist.get({"parentfield": "entries"}):
|
||||||
gl_map.append(
|
if d.debit or d.credit:
|
||||||
self.get_gl_dict({
|
gl_map.append(
|
||||||
"account": d.account,
|
self.get_gl_dict({
|
||||||
"against": d.against_account,
|
"account": d.account,
|
||||||
"debit": d.debit,
|
"against": d.against_account,
|
||||||
"credit": d.credit,
|
"debit": d.debit,
|
||||||
"against_voucher_type": ((d.against_voucher and "Purchase Invoice")
|
"credit": d.credit,
|
||||||
or (d.against_invoice and "Sales Invoice")
|
"against_voucher_type": ((d.against_voucher and "Purchase Invoice")
|
||||||
or (d.against_jv and "Journal Voucher")),
|
or (d.against_invoice and "Sales Invoice")
|
||||||
"against_voucher": d.against_voucher or d.against_invoice or d.against_jv,
|
or (d.against_jv and "Journal Voucher")),
|
||||||
"remarks": self.doc.remark,
|
"against_voucher": d.against_voucher or d.against_invoice or d.against_jv,
|
||||||
"cost_center": d.cost_center
|
"remarks": self.doc.remark,
|
||||||
}, cancel)
|
"cost_center": d.cost_center
|
||||||
)
|
}, cancel)
|
||||||
|
)
|
||||||
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
|
if gl_map:
|
||||||
|
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
|
||||||
|
|
||||||
def get_outstanding(self, args):
|
def get_outstanding(self, args):
|
||||||
args = eval(args)
|
args = eval(args)
|
||||||
|
|||||||
@@ -422,16 +422,17 @@ class DocType(BuyingController):
|
|||||||
abbr = self.get_company_abbr()
|
abbr = self.get_company_abbr()
|
||||||
|
|
||||||
# parent's gl entry
|
# parent's gl entry
|
||||||
gl_entries.append(
|
if self.doc.grand_total:
|
||||||
self.get_gl_dict({
|
gl_entries.append(
|
||||||
"account": self.doc.credit_to,
|
self.get_gl_dict({
|
||||||
"against": self.doc.against_expense_account,
|
"account": self.doc.credit_to,
|
||||||
"credit": self.doc.grand_total,
|
"against": self.doc.against_expense_account,
|
||||||
"remarks": self.doc.remarks,
|
"credit": self.doc.grand_total,
|
||||||
"against_voucher": self.doc.name,
|
"remarks": self.doc.remarks,
|
||||||
"against_voucher_type": self.doc.doctype,
|
"against_voucher": self.doc.name,
|
||||||
}, is_cancel)
|
"against_voucher_type": self.doc.doctype,
|
||||||
)
|
}, is_cancel)
|
||||||
|
)
|
||||||
|
|
||||||
# tax table gl entries
|
# tax table gl entries
|
||||||
for tax in getlist(self.doclist, "purchase_tax_details"):
|
for tax in getlist(self.doclist, "purchase_tax_details"):
|
||||||
@@ -506,7 +507,9 @@ class DocType(BuyingController):
|
|||||||
"cost_center": self.doc.write_off_cost_center
|
"cost_center": self.doc.write_off_cost_center
|
||||||
}, is_cancel)
|
}, is_cancel)
|
||||||
)
|
)
|
||||||
make_gl_entries(gl_entries, cancel=is_cancel)
|
|
||||||
|
if gl_entries:
|
||||||
|
make_gl_entries(gl_entries, cancel=is_cancel)
|
||||||
|
|
||||||
|
|
||||||
def check_next_docstatus(self):
|
def check_next_docstatus(self):
|
||||||
|
|||||||
@@ -637,16 +637,17 @@ class DocType(SellingController):
|
|||||||
abbr = self.get_company_abbr()
|
abbr = self.get_company_abbr()
|
||||||
|
|
||||||
# parent's gl entry
|
# parent's gl entry
|
||||||
gl_entries.append(
|
if self.doc.grand_total:
|
||||||
self.get_gl_dict({
|
gl_entries.append(
|
||||||
"account": self.doc.debit_to,
|
self.get_gl_dict({
|
||||||
"against": self.doc.against_income_account,
|
"account": self.doc.debit_to,
|
||||||
"debit": self.doc.grand_total,
|
"against": self.doc.against_income_account,
|
||||||
"remarks": self.doc.remarks,
|
"debit": self.doc.grand_total,
|
||||||
"against_voucher": self.doc.name,
|
"remarks": self.doc.remarks,
|
||||||
"against_voucher_type": self.doc.doctype,
|
"against_voucher": self.doc.name,
|
||||||
}, is_cancel)
|
"against_voucher_type": self.doc.doctype,
|
||||||
)
|
}, is_cancel)
|
||||||
|
)
|
||||||
|
|
||||||
# tax table gl entries
|
# tax table gl entries
|
||||||
for tax in self.doclist.get({"parentfield": "other_charges"}):
|
for tax in self.doclist.get({"parentfield": "other_charges"}):
|
||||||
@@ -745,8 +746,9 @@ class DocType(SellingController):
|
|||||||
|
|
||||||
update_outstanding = self.doc.is_pos and self.doc.write_off_account and 'No' or 'Yes'
|
update_outstanding = self.doc.is_pos and self.doc.write_off_account and 'No' or 'Yes'
|
||||||
merge_entries=cint(self.doc.is_pos)!=1 and 1 or 0
|
merge_entries=cint(self.doc.is_pos)!=1 and 1 or 0
|
||||||
make_gl_entries(gl_entries, cancel=is_cancel,
|
if gl_entries:
|
||||||
update_outstanding=update_outstanding, merge_entries=merge_entries)
|
make_gl_entries(gl_entries, cancel=is_cancel,
|
||||||
|
update_outstanding=update_outstanding, merge_entries=merge_entries)
|
||||||
|
|
||||||
def update_c_form(self):
|
def update_c_form(self):
|
||||||
"""Update amended id in C-form"""
|
"""Update amended id in C-form"""
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ import webnotes
|
|||||||
from webnotes.utils import nowdate, cstr, flt
|
from webnotes.utils import nowdate, cstr, flt
|
||||||
from webnotes.model.doc import addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes import msgprint, _
|
from webnotes import msgprint, _
|
||||||
|
from webnotes.utils import formatdate
|
||||||
|
|
||||||
class FiscalYearError(webnotes.ValidationError): pass
|
class FiscalYearError(webnotes.ValidationError): pass
|
||||||
|
|
||||||
def get_fiscal_year(date, verbose=1):
|
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)
|
# 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,
|
fy = webnotes.conn.sql("""select name, year_start_date,
|
||||||
subdate(adddate(year_start_date, interval 1 year), interval 1 day)
|
subdate(adddate(year_start_date, interval 1 year), interval 1 day)
|
||||||
@@ -39,6 +39,15 @@ def get_fiscal_year(date, verbose=1):
|
|||||||
raise FiscalYearError, error_msg
|
raise FiscalYearError, error_msg
|
||||||
|
|
||||||
return fy[0]
|
return fy[0]
|
||||||
|
|
||||||
|
def validate_fiscal_year(date, fiscal_year, label="Date"):
|
||||||
|
if get_fiscal_year(date)[0] != fiscal_year:
|
||||||
|
webnotes.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()
|
@webnotes.whitelist()
|
||||||
def get_balance_on(account=None, date=None):
|
def get_balance_on(account=None, date=None):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-01-10 16:34:13",
|
"creation": "2013-01-10 16:34:13",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-01-22 14:46:41",
|
"modified": "2013-02-04 15:34:55",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -57,6 +57,14 @@
|
|||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"reqd": 1
|
"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",
|
"doctype": "DocPerm",
|
||||||
"role": "System Manager"
|
"role": "System Manager"
|
||||||
|
|||||||
0
hr/doctype/holiday_block_list/__init__.py
Normal file
0
hr/doctype/holiday_block_list/__init__.py
Normal file
21
hr/doctype/holiday_block_list/holiday_block_list.py
Normal file
21
hr/doctype/holiday_block_list/holiday_block_list.py
Normal file
@@ -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)
|
||||||
66
hr/doctype/holiday_block_list/holiday_block_list.txt
Normal file
66
hr/doctype/holiday_block_list/holiday_block_list.txt
Normal file
@@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
0
hr/doctype/holiday_block_list_date/__init__.py
Normal file
0
hr/doctype/holiday_block_list_date/__init__.py
Normal file
@@ -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
|
||||||
@@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -80,6 +80,11 @@ wn.module_page["HR"] = [
|
|||||||
"description":wn._("List of holidays."),
|
"description":wn._("List of holidays."),
|
||||||
doctype: "Holiday List"
|
doctype: "Holiday List"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label":wn._("Holiday Block List"),
|
||||||
|
"description":wn._("Block leave applications by department."),
|
||||||
|
doctype: "Holiday Block List"
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -599,14 +599,8 @@ class DocType(TransactionBase):
|
|||||||
get_obj('Account',acc_head[0][0]).check_credit_limit(acc_head[0][0], obj.doc.company, exact_outstanding)
|
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):
|
def validate_fiscal_year(self, fiscal_year, transaction_date, label):
|
||||||
from accounts.utils import get_fiscal_year
|
import accounts.utils
|
||||||
if get_fiscal_year(transaction_date)[0] != fiscal_year:
|
accounts.utils.validate_fiscal_year(transaction_date, fiscal_year, label)
|
||||||
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)
|
|
||||||
|
|
||||||
def get_prevdoc_date(self, obj):
|
def get_prevdoc_date(self, obj):
|
||||||
for d in getlist(obj.doclist, obj.fname):
|
for d in getlist(obj.doclist, obj.fname):
|
||||||
|
|||||||
@@ -17,10 +17,9 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import add_days, cstr, date_diff, getdate
|
from webnotes.utils import add_days, cstr, getdate
|
||||||
from webnotes.model import db_exists
|
|
||||||
from webnotes.model.doc import Document, addchild
|
from webnotes.model.doc import Document, addchild
|
||||||
from webnotes.model.wrapper import getlist, copy_doclist
|
from webnotes.model.wrapper import getlist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
@@ -54,7 +53,6 @@ class DocType(TransactionBase):
|
|||||||
# generate maintenance schedule
|
# generate maintenance schedule
|
||||||
#-------------------------------------
|
#-------------------------------------
|
||||||
def generate_schedule(self):
|
def generate_schedule(self):
|
||||||
import datetime
|
|
||||||
self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail')
|
self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail')
|
||||||
count = 0
|
count = 0
|
||||||
sql("delete from `tabMaintenance Schedule Detail` where parent='%s'" %(self.doc.name))
|
sql("delete from `tabMaintenance Schedule Detail` where parent='%s'" %(self.doc.name))
|
||||||
@@ -158,9 +156,7 @@ class DocType(TransactionBase):
|
|||||||
#get count on the basis of periodicity selected
|
#get count on the basis of periodicity selected
|
||||||
#----------------------------------------------------
|
#----------------------------------------------------
|
||||||
def get_no_of_visits(self, arg):
|
def get_no_of_visits(self, arg):
|
||||||
arg1 = eval(arg)
|
arg1 = eval(arg)
|
||||||
start_date = arg1['start_date']
|
|
||||||
|
|
||||||
self.validate_period(arg)
|
self.validate_period(arg)
|
||||||
period = (getdate(arg1['end_date'])-getdate(arg1['start_date'])).days+1
|
period = (getdate(arg1['end_date'])-getdate(arg1['start_date'])).days+1
|
||||||
|
|
||||||
@@ -279,7 +275,7 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
def validate_serial_no_warranty(self):
|
def validate_serial_no_warranty(self):
|
||||||
for d in getlist(self.doclist, 'item_maintenance_detail'):
|
for d in getlist(self.doclist, 'item_maintenance_detail'):
|
||||||
if d.serial_no.strip():
|
if cstr(d.serial_no).strip():
|
||||||
dt = sql("""select warranty_expiry_date, amc_expiry_date
|
dt = sql("""select warranty_expiry_date, amc_expiry_date
|
||||||
from `tabSerial No` where name = %s""", d.serial_no, as_dict=1)
|
from `tabSerial No` where name = %s""", d.serial_no, as_dict=1)
|
||||||
if dt[0]['warranty_expiry_date'] and dt[0]['warranty_expiry_date'] >= d.start_date:
|
if dt[0]['warranty_expiry_date'] and dt[0]['warranty_expiry_date'] >= d.start_date:
|
||||||
@@ -290,7 +286,7 @@ class DocType(TransactionBase):
|
|||||||
if dt[0]['amc_expiry_date'] and dt[0]['amc_expiry_date'] >= d.start_date:
|
if dt[0]['amc_expiry_date'] and dt[0]['amc_expiry_date'] >= d.start_date:
|
||||||
webnotes.msgprint("""Serial No: %s is already under AMC upto %s.
|
webnotes.msgprint("""Serial No: %s is already under AMC upto %s.
|
||||||
Please check AMC Start Date.""" %
|
Please check AMC Start Date.""" %
|
||||||
(d.serial_no, sr[0]["amc_expiry_date"]), raise_exception=1)
|
(d.serial_no, dt[0]["amc_expiry_date"]), raise_exception=1)
|
||||||
|
|
||||||
def validate_schedule(self):
|
def validate_schedule(self):
|
||||||
item_lst1 =[]
|
item_lst1 =[]
|
||||||
|
|||||||
Reference in New Issue
Block a user