Merge branch 'edge' of github.com:webnotes/erpnext into edge

This commit is contained in:
Rushabh Mehta 2013-02-05 07:16:29 +01:00
commit c03fc3d17c
14 changed files with 211 additions and 58 deletions

View File

@ -248,22 +248,23 @@ class DocType(AccountsController):
from accounts.general_ledger import make_gl_entries
gl_map = []
for d in self.doclist.get({"parentfield": "entries"}):
gl_map.append(
self.get_gl_dict({
"account": d.account,
"against": d.against_account,
"debit": d.debit,
"credit": d.credit,
"against_voucher_type": ((d.against_voucher and "Purchase Invoice")
or (d.against_invoice and "Sales Invoice")
or (d.against_jv and "Journal Voucher")),
"against_voucher": d.against_voucher or d.against_invoice or d.against_jv,
"remarks": self.doc.remark,
"cost_center": d.cost_center
}, cancel)
)
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
if d.debit or d.credit:
gl_map.append(
self.get_gl_dict({
"account": d.account,
"against": d.against_account,
"debit": d.debit,
"credit": d.credit,
"against_voucher_type": ((d.against_voucher and "Purchase Invoice")
or (d.against_invoice and "Sales Invoice")
or (d.against_jv and "Journal Voucher")),
"against_voucher": d.against_voucher or d.against_invoice or d.against_jv,
"remarks": self.doc.remark,
"cost_center": d.cost_center
}, cancel)
)
if gl_map:
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
def get_outstanding(self, args):
args = eval(args)

View File

@ -422,16 +422,17 @@ class DocType(BuyingController):
abbr = self.get_company_abbr()
# parent's gl entry
gl_entries.append(
self.get_gl_dict({
"account": self.doc.credit_to,
"against": self.doc.against_expense_account,
"credit": self.doc.grand_total,
"remarks": self.doc.remarks,
"against_voucher": self.doc.name,
"against_voucher_type": self.doc.doctype,
}, is_cancel)
)
if self.doc.grand_total:
gl_entries.append(
self.get_gl_dict({
"account": self.doc.credit_to,
"against": self.doc.against_expense_account,
"credit": self.doc.grand_total,
"remarks": self.doc.remarks,
"against_voucher": self.doc.name,
"against_voucher_type": self.doc.doctype,
}, is_cancel)
)
# tax table gl entries
for tax in getlist(self.doclist, "purchase_tax_details"):
@ -506,7 +507,9 @@ class DocType(BuyingController):
"cost_center": self.doc.write_off_cost_center
}, 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):

View File

@ -637,16 +637,17 @@ class DocType(SellingController):
abbr = self.get_company_abbr()
# parent's gl entry
gl_entries.append(
self.get_gl_dict({
"account": self.doc.debit_to,
"against": self.doc.against_income_account,
"debit": self.doc.grand_total,
"remarks": self.doc.remarks,
"against_voucher": self.doc.name,
"against_voucher_type": self.doc.doctype,
}, is_cancel)
)
if self.doc.grand_total:
gl_entries.append(
self.get_gl_dict({
"account": self.doc.debit_to,
"against": self.doc.against_income_account,
"debit": self.doc.grand_total,
"remarks": self.doc.remarks,
"against_voucher": self.doc.name,
"against_voucher_type": self.doc.doctype,
}, is_cancel)
)
# tax table gl entries
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'
merge_entries=cint(self.doc.is_pos)!=1 and 1 or 0
make_gl_entries(gl_entries, cancel=is_cancel,
update_outstanding=update_outstanding, merge_entries=merge_entries)
if gl_entries:
make_gl_entries(gl_entries, cancel=is_cancel,
update_outstanding=update_outstanding, merge_entries=merge_entries)
def update_c_form(self):
"""Update amended id in C-form"""

View File

@ -20,11 +20,11 @@ import webnotes
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 @@ def get_fiscal_year(date, verbose=1):
raise FiscalYearError, error_msg
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()
def get_balance_on(account=None, date=None):

View File

@ -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"
},
@ -57,6 +57,14 @@
"oldfieldtype": "Data",
"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"

View 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)

View 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"
}
]

View 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

View File

@ -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"
}
]

View File

@ -80,6 +80,11 @@ wn.module_page["HR"] = [
"description":wn._("List of holidays."),
doctype: "Holiday List"
},
{
"label":wn._("Holiday Block List"),
"description":wn._("Block leave applications by department."),
doctype: "Holiday Block List"
},
]
},
{

View File

@ -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)
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):

View File

@ -17,10 +17,9 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, cstr, date_diff, getdate
from webnotes.model import db_exists
from webnotes.utils import add_days, cstr, getdate
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 import msgprint
@ -54,7 +53,6 @@ class DocType(TransactionBase):
# generate maintenance schedule
#-------------------------------------
def generate_schedule(self):
import datetime
self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail')
count = 0
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
#----------------------------------------------------
def get_no_of_visits(self, arg):
arg1 = eval(arg)
start_date = arg1['start_date']
arg1 = eval(arg)
self.validate_period(arg)
period = (getdate(arg1['end_date'])-getdate(arg1['start_date'])).days+1
@ -279,7 +275,7 @@ class DocType(TransactionBase):
def validate_serial_no_warranty(self):
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
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:
@ -290,7 +286,7 @@ class DocType(TransactionBase):
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.
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):
item_lst1 =[]