Merge pull request #1596 from nabinhait/v4-hotfix

V4 fixes and updates
This commit is contained in:
Nabin Hait
2014-05-06 19:17:13 +05:30
6 changed files with 95 additions and 100 deletions

View File

@@ -2,7 +2,7 @@
"allow_copy": 1, "allow_copy": 1,
"allow_email": 1, "allow_email": 1,
"allow_print": 1, "allow_print": 1,
"creation": "2013-01-10 16:34:05.000000", "creation": "2013-01-10 16:34:05",
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"fields": [ "fields": [
@@ -10,6 +10,7 @@
"description": "Select account head of the bank where cheque was deposited.", "description": "Select account head of the bank where cheque was deposited.",
"fieldname": "bank_account", "fieldname": "bank_account",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1,
"label": "Bank Account", "label": "Bank Account",
"options": "Account", "options": "Account",
"permlevel": 0, "permlevel": 0,
@@ -19,6 +20,7 @@
"fieldname": "company", "fieldname": "company",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1, "hidden": 1,
"in_list_view": 1,
"label": "Company", "label": "Company",
"options": "Company", "options": "Company",
"permlevel": 0, "permlevel": 0,
@@ -28,6 +30,7 @@
{ {
"fieldname": "from_date", "fieldname": "from_date",
"fieldtype": "Date", "fieldtype": "Date",
"in_list_view": 1,
"label": "From Date", "label": "From Date",
"permlevel": 0, "permlevel": 0,
"reqd": 1 "reqd": 1
@@ -35,14 +38,22 @@
{ {
"fieldname": "to_date", "fieldname": "to_date",
"fieldtype": "Date", "fieldtype": "Date",
"in_list_view": 1,
"label": "To Date", "label": "To Date",
"permlevel": 0, "permlevel": 0,
"reqd": 1 "reqd": 1
}, },
{ {
"fieldname": "get_non_reconciled_entries", "fieldname": "include_reconciled_entries",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Include Reconciled Entries",
"permlevel": 0
},
{
"fieldname": "get_relevant_entries",
"fieldtype": "Button", "fieldtype": "Button",
"label": "Get Non Reconciled Entries", "label": "Get Relevant Entries",
"options": "get_details", "options": "get_details",
"permlevel": 0 "permlevel": 0
}, },
@@ -74,7 +85,7 @@
"icon": "icon-check", "icon": "icon-check",
"idx": 1, "idx": 1,
"issingle": 1, "issingle": 1,
"modified": "2013-07-05 14:26:22.000000", "modified": "2014-05-06 16:26:08.984595",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Bank Reconciliation", "name": "Bank Reconciliation",

View File

@@ -3,7 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cstr, flt, getdate, nowdate from frappe.utils import flt, getdate, nowdate
from frappe import msgprint, _ from frappe import msgprint, _
from frappe.model.document import Document from frappe.model.document import Document
@@ -13,29 +13,34 @@ class BankReconciliation(Document):
msgprint("Bank Account, From Date and To Date are Mandatory") msgprint("Bank Account, From Date and To Date are Mandatory")
return return
condition = ""
if not self.include_reconciled_entries:
condition = "and ifnull(clearance_date, '') in ('', '0000-00-00')"
dl = frappe.db.sql("""select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, dl = frappe.db.sql("""select t1.name, t1.cheque_no, t1.cheque_date, t2.debit,
t2.credit, t1.posting_date, t2.against_account t2.credit, t1.posting_date, t2.against_account, t1.clearance_date
from from
`tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2
where where
t2.parent = t1.name and t2.account = %s t2.parent = t1.name and t2.account = %s
and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1 %s""" %
and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1""", ('%s', '%s', '%s', condition), (self.bank_account, self.from_date, self.to_date), as_dict=1)
(self.bank_account, self.from_date, self.to_date))
self.set('entries', []) self.set('entries', [])
self.total_amount = 0.0 self.total_amount = 0.0
for d in dl: for d in dl:
nl = self.append('entries', {}) nl = self.append('entries', {})
nl.posting_date = cstr(d[5]) nl.posting_date = d.posting_date
nl.voucher_id = cstr(d[0]) nl.voucher_id = d.name
nl.cheque_number = cstr(d[1]) nl.cheque_number = d.cheque_no
nl.cheque_date = cstr(d[2]) nl.cheque_date = d.cheque_date
nl.debit = flt(d[3]) nl.debit = d.debit
nl.credit = flt(d[4]) nl.credit = d.credit
nl.against_account = cstr(d[6]) nl.against_account = d.against_account
self.total_amount += flt(flt(d[4]) - flt(d[3])) nl.clearance_date = d.clearance_date
self.total_amount += flt(d.debit) - flt(d.credit)
def update_details(self): def update_details(self):
vouchers = [] vouchers = []

View File

@@ -49,32 +49,6 @@ cur_frm.cscript.replace_abbr = function() {
dialog.show(); dialog.show();
} }
cur_frm.cscript.has_special_chars = function(t) {
var iChars = "!@#$%^*+=-[]\\\';,/{}|\":<>?";
for (var i = 0; i < t.length; i++) {
if (iChars.indexOf(t.charAt(i)) != -1) {
return true;
}
}
return false;
}
cur_frm.cscript.company_name = function(doc){
if(doc.company_name && cur_frm.cscript.has_special_chars(doc.company_name)){
msgprint(__("Special Characters not allowed in Company Name"));
doc.company_name = '';
refresh_field('company_name');
}
}
cur_frm.cscript.abbr = function(doc){
if(doc.abbr && cur_frm.cscript.has_special_chars(doc.abbr)){
msgprint(__("Special Characters not allowed in Abbreviation"));
doc.abbr = '';
refresh_field('abbr');
}
}
cur_frm.fields_dict.default_bank_account.get_query = function(doc) { cur_frm.fields_dict.default_bank_account.get_query = function(doc) {
return{ return{
filters: [ filters: [

View File

@@ -38,6 +38,42 @@ erpnext.support.MaintenanceSchedule = frappe.ui.form.Controller.extend({
}); });
} }
}, },
start_date: function(doc, cdt, cdn) {
this.set_no_of_visits(doc, cdt, cdn);
},
end_date: function(doc, cdt, cdn) {
this.set_no_of_visits(doc, cdt, cdn);
},
periodicity: function(doc, cdt, cdn) {
this.set_no_of_visits(doc, cdt, cdn);
},
set_no_of_visits: function(doc, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn);
if (item.start_date && item.end_date && item.periodicity) {
if(item.start_date > item.end_date) {
msgprint(__("Row {0}:Start Date must be before End Date", [item.idx]));
return;
}
var date_diff = frappe.datetime.get_diff(item.end_date, item.start_date) + 1;
var days_in_period = {
"Weekly": 7,
"Monthly": 30,
"Quarterly": 91,
"Half Yearly": 182,
"Yearly": 365
}
var no_of_visits = cint(date_diff / days_in_period[item.periodicity]);
frappe.model.set_value(item.doctype, item.name, "no_of_visits", no_of_visits);
}
},
}); });
$.extend(cur_frm.cscript, new erpnext.support.MaintenanceSchedule({frm: cur_frm})); $.extend(cur_frm.cscript, new erpnext.support.MaintenanceSchedule({frm: cur_frm}));
@@ -62,7 +98,7 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
} }
} }
//
cur_frm.fields_dict['item_maintenance_detail'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) { cur_frm.fields_dict['item_maintenance_detail'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
return { return {
filters:{ 'is_service_item': "Yes" } filters:{ 'is_service_item': "Yes" }
@@ -78,20 +114,6 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) {
} }
} }
cur_frm.cscript.periodicity = function(doc, cdt, cdn){
var d = locals[cdt][cdn];
if(d.start_date && d.end_date) {
arg = {}
arg.start_date = d.start_date;
arg.end_date = d.end_date;
arg.periodicity = d.periodicity;
return get_server_fields('get_no_of_visits', docstring(arg),
'item_maintenance_detail', doc, cdt, cdn, 1);
} else {
msgprint(__("Please enter Start Date and End Date"));
}
}
cur_frm.cscript.generate_schedule = function(doc, cdt, cdn) { cur_frm.cscript.generate_schedule = function(doc, cdt, cdn) {
if (!doc.__islocal) { if (!doc.__islocal) {
return $c('runserverobj', args={'method':'generate_schedule', 'docs':doc}, return $c('runserverobj', args={'method':'generate_schedule', 'docs':doc},

View File

@@ -133,40 +133,22 @@ class MaintenanceSchedule(TransactionBase):
return schedule_date return schedule_date
def validate_period(self, arg): def validate_dates_with_periodicity(self):
args = eval(arg) for d in self.get("item_maintenance_detail"):
if getdate(args['start_date']) >= getdate(args['end_date']): if d.start_date and d.end_date and d.periodicity:
throw(_("Start date should be less than end date.")) date_diff = (getdate(d.end_date) - getdate(d.start_date)).days + 1
days_in_period = {
"Weekly": 7,
"Monthly": 30,
"Quarterly": 90,
"Half Yearly": 180,
"Yearly": 365
}
period = (getdate(args['end_date']) - getdate(args['start_date'])).days + 1 if date_diff < days_in_period[d.periodicity]:
throw(_("Row {0}: To set {1} periodicity, difference between from and to date \
if (args['periodicity'] == 'Yearly' or args['periodicity'] == 'Half Yearly' or must be greater than or equal to {2}")
args['periodicity'] == 'Quarterly') and period < 90: .format(d.idx, d.periodicity, days_in_period[d.periodicity]))
throw(_("Period is too short"))
elif args['periodicity'] == 'Monthly' and period < 30:
throw(_("Period is too short"))
elif args['periodicity'] == 'Weekly' and period < 7:
throw(_("Period is too short"))
def get_no_of_visits(self, arg):
args = eval(arg)
self.validate_period(arg)
period = (getdate(args['end_date']) - getdate(args['start_date'])).days + 1
count = 0
if args['periodicity'] == 'Weekly':
count = period/7
elif args['periodicity'] == 'Monthly':
count = period/30
elif args['periodicity'] == 'Quarterly':
count = period/91
elif args['periodicity'] == 'Half Yearly':
count = period/182
elif args['periodicity'] == 'Yearly':
count = period/365
ret = {'no_of_visits' : count}
return ret
def validate_maintenance_detail(self): def validate_maintenance_detail(self):
if not self.get('item_maintenance_detail'): if not self.get('item_maintenance_detail'):
@@ -196,6 +178,7 @@ class MaintenanceSchedule(TransactionBase):
def validate(self): def validate(self):
self.validate_maintenance_detail() self.validate_maintenance_detail()
self.validate_dates_with_periodicity()
self.validate_sales_order() self.validate_sales_order()
def on_update(self): def on_update(self):

View File

@@ -27,7 +27,7 @@ cur_frm.cscript.setup_upload = function() {
frappe.upload.make({ frappe.upload.make({
parent: $wrapper, parent: $wrapper,
args: { args: {
method: 'utilities.doctype.rename_tool.rename_tool.upload', method: 'erpnext.utilities.doctype.rename_tool.rename_tool.upload',
select_doctype: cur_frm.doc.select_doctype select_doctype: cur_frm.doc.select_doctype
}, },
sample_url: "e.g. http://example.com/somefile.csv", sample_url: "e.g. http://example.com/somefile.csv",