From fb413661c227e62e63c3fe5046b5248a19bb8f81 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 27 May 2013 19:28:19 +0530 Subject: [PATCH] [utils] added a method to sum an array of numbers --- public/js/wn/misc/utils.js | 4 ++++ webnotes/model/controller.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/public/js/wn/misc/utils.js b/public/js/wn/misc/utils.js index 5b0e204ead..479d98ca0b 100644 --- a/public/js/wn/misc/utils.js +++ b/public/js/wn/misc/utils.js @@ -168,4 +168,8 @@ wn.utils = { } return arr; }, + + sum: function(list) { + return list.reduce(function(previous_value, current_value) { return flt(previous_value) + flt(current_value); }); + }, }; \ No newline at end of file diff --git a/webnotes/model/controller.py b/webnotes/model/controller.py index 7b3d471d99..b4a67a5f37 100644 --- a/webnotes/model/controller.py +++ b/webnotes/model/controller.py @@ -26,7 +26,7 @@ from webnotes import msgprint, _ from webnotes.utils import flt, cint, cstr from webnotes.model.meta import get_field_precision -error_coniditon_map = { +error_condition_map = { "=": "!=", "!=": "=", "<": ">=", @@ -71,7 +71,7 @@ class DocListController(object): msg += _("Row") + (" # %d: " % doc.idx) msg += _(self.meta.get_label(fieldname, parent=doc.doctype)) \ - + " " + error_coniditon_map.get(condition, "") + " " + cstr(val2) + + " " + error_condition_map.get(condition, "") + " " + cstr(val2) # raise passed exception or True msgprint(msg, raise_exception=raise_exception or True)