Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Rushabh Mehta 2013-03-26 13:02:44 +05:30
commit a5094edbd9
4 changed files with 44 additions and 33 deletions

View File

@ -84,13 +84,13 @@ cur_frm.cscript.update_totals = function(doc) {
var td=0.0; var tc =0.0;
var el = getchildren('Journal Voucher Detail', doc.name, 'entries');
for(var i in el) {
td += flt(el[i].debit);
tc += flt(el[i].credit);
td += flt(el[i].debit, 2);
tc += flt(el[i].credit, 2);
}
var doc = locals[doc.doctype][doc.name];
doc.total_debit = td;
doc.total_credit = tc;
doc.difference = flt(td - tc);
doc.difference = flt((td - tc), 2);
refresh_many(['total_debit','total_credit','difference']);
}

View File

@ -114,8 +114,8 @@ class DocType(AccountsController):
debit, credit = 0.0, 0.0
debit_list, credit_list = [], []
for d in getlist(self.doclist, 'entries'):
debit += flt(d.debit)
credit += flt(d.credit)
debit += flt(d.debit, 2)
credit += flt(d.credit, 2)
if flt(d.debit)>0 and (d.account not in debit_list): debit_list.append(d.account)
if flt(d.credit)>0 and (d.account not in credit_list): credit_list.append(d.account)
@ -289,32 +289,32 @@ class DocType(AccountsController):
if not getlist(self.doclist,'entries'):
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
else:
flag, self.doc.total_debit, self.doc.total_credit = 0,0,0
diff = flt(self.doc.difference)
flag, self.doc.total_debit, self.doc.total_credit = 0, 0, 0
diff = flt(self.doc.difference, 2)
# If any row without amount, set the diff on that row
for d in getlist(self.doclist,'entries'):
if not d.credit and not d.debit and flt(diff) != 0:
if not d.credit and not d.debit and diff != 0:
if diff>0:
d.credit = flt(diff)
d.credit = diff
elif diff<0:
d.debit = flt(diff)
d.debit = diff
flag = 1
# Set the diff in a new row
if flag == 0 and (flt(diff) != 0):
if flag == 0 and diff != 0:
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
if diff>0:
jd.credit = flt(abs(diff))
jd.credit = abs(diff)
elif diff<0:
jd.debit = flt(abs(diff))
jd.debit = abs(diff)
# Set the total debit, total credit and difference
for d in getlist(self.doclist,'entries'):
self.doc.total_debit += flt(d.debit)
self.doc.total_credit += flt(d.credit)
self.doc.total_debit += flt(d.debit, 2)
self.doc.total_credit += flt(d.credit, 2)
self.doc.difference = flt(self.doc.total_debit) - flt(self.doc.total_credit)
self.doc.difference = flt(self.doc.total_debit, 2) - flt(self.doc.total_credit, 2)
def get_outstanding_invoices(self):
self.doclist = self.doc.clear_table(self.doclist, 'entries')

View File

@ -16,30 +16,37 @@
from __future__ import unicode_literals
import webnotes
from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
from webnotes import msgprint
sql = webnotes.conn.sql
from webnotes import msgprint, _
from webnotes.utils import cint
class DocType:
def __init__(self,doc,doclist=[]):
self.doc, self.doclist = doc,doclist
#--------------------get naming series from sales invoice-----------------
def get_series(self):
import webnotes.model.doctype
docfield = webnotes.model.doctype.get('Sales Invoice')
series = [d.options for d in docfield if d.doctype == 'DocField' and d.fieldname == 'naming_series']
series = [d.options for d in docfield
if d.doctype == 'DocField' and d.fieldname == 'naming_series']
return series and series[0] or ''
def validate(self):
res = sql("select name, user from `tabPOS Setting` where ifnull(user, '') = '%s' and name != '%s' and company = '%s'" % (self.doc.user, self.doc.name, self.doc.company))
self.check_for_duplicate()
self.validate_expense_account()
def check_for_duplicate(self):
res = webnotes.conn.sql("""select name, user from `tabPOS Setting`
where ifnull(user, '') = %s and name != %s and company = %s""",
(self.doc.user, self.doc.name, self.doc.company))
if res:
if res[0][1]:
msgprint("POS Setting '%s' already created for user: '%s' and company: '%s'"%(res[0][0], res[0][1], self.doc.company), raise_exception=1)
msgprint("POS Setting '%s' already created for user: '%s' and company: '%s'" %
(res[0][0], res[0][1], self.doc.company), raise_exception=1)
else:
msgprint("Global POS Setting already created - %s for this company: '%s'" % (res[0][0], self.doc.company), raise_exception=1)
msgprint("Global POS Setting already created - %s for this company: '%s'" %
(res[0][0], self.doc.company), raise_exception=1)
def validate_expense_account(self):
if cint(webnotes.defaults.get_global_default("auto_inventory_accounting")) \
and not self.doc.expense_account:
msgprint(_("Expense Account is mandatory"), raise_exception=1)

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-01-24 11:03:29",
"creation": "2013-03-26 11:03:07",
"docstatus": 0,
"modified": "2013-03-25 15:27:52",
"modified": "2013-03-26 12:48:18",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -18,7 +18,8 @@
"parent": "POS Setting",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
"permlevel": 0,
"read_only": 0
},
{
"doctype": "DocPerm",
@ -141,12 +142,15 @@
"reqd": 1
},
{
"depends_on": "eval:sys_defaults.auto_inventory_accounting",
"doctype": "DocField",
"fieldname": "expense_account",
"fieldtype": "Link",
"hidden": 0,
"label": "Expense Account",
"options": "Account",
"reqd": 1
"print_hide": 1,
"reqd": 0
},
{
"doctype": "DocField",