Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js
index 82322c8..78956bf 100644
--- a/accounts/doctype/journal_voucher/journal_voucher.js
+++ b/accounts/doctype/journal_voucher/journal_voucher.js
@@ -84,13 +84,13 @@
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']);
}
diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py
index 812ab7d..8b54f0f 100644
--- a/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/accounts/doctype/journal_voucher/journal_voucher.py
@@ -114,8 +114,8 @@
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 @@
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')
diff --git a/accounts/doctype/pos_setting/pos_setting.py b/accounts/doctype/pos_setting/pos_setting.py
index 0e68e2a..a024f6e 100755
--- a/accounts/doctype/pos_setting/pos_setting.py
+++ b/accounts/doctype/pos_setting/pos_setting.py
@@ -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)
\ No newline at end of file
diff --git a/accounts/doctype/pos_setting/pos_setting.txt b/accounts/doctype/pos_setting/pos_setting.txt
index a625ad8..4e30b57 100755
--- a/accounts/doctype/pos_setting/pos_setting.txt
+++ b/accounts/doctype/pos_setting/pos_setting.txt
@@ -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",