Merge pull request #1659 from nabinhait/v4-hotfix
translation and fraction issue fixes
diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js
index 25a6557..bc0108e 100644
--- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js
+++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js
@@ -140,13 +140,13 @@
var td=0.0; var tc =0.0;
var el = doc.entries || [];
for(var i in el) {
- td += flt(el[i].debit, 2);
- tc += flt(el[i].credit, 2);
+ td += flt(el[i].debit, precision("debit", el[i]));
+ tc += flt(el[i].credit, precision("credit", el[i]));
}
var doc = locals[doc.doctype][doc.name];
doc.total_debit = td;
doc.total_credit = tc;
- doc.difference = flt((td - tc), 2);
+ doc.difference = flt((td - tc), precision("difference"));
refresh_many(['total_debit','total_credit','difference']);
}
diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
index 62758c6..70bee90 100644
--- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
@@ -120,18 +120,21 @@
if flt(d.credit > 0): d.against_account = ", ".join(list(set(accounts_debited)))
def validate_debit_and_credit(self):
- self.total_debit, self.total_credit = 0, 0
+ self.total_debit, self.total_credit, self.difference = 0, 0, 0
for d in self.get("entries"):
if d.debit and d.credit:
frappe.throw(_("You cannot credit and debit same account at the same time"))
- self.total_debit = flt(self.total_debit) + flt(d.debit)
- self.total_credit = flt(self.total_credit) + flt(d.credit)
+ self.total_debit = flt(self.total_debit) + flt(d.debit, self.precision("debit", "entries"))
+ self.total_credit = flt(self.total_credit) + flt(d.credit, self.precision("credit", "entries"))
- if abs(self.total_debit-self.total_credit) > 0.001:
+ self.difference = flt(self.total_debit, self.precision("total_debit")) - \
+ flt(self.total_credit, self.precision("total_credit"))
+
+ if self.difference:
frappe.throw(_("Total Debit must be equal to Total Credit. The difference is {0}")
- .format(self.total_debit - self.total_credit))
+ .format(self.difference))
def create_remarks(self):
r = []
@@ -254,8 +257,8 @@
self.get_gl_dict({
"account": d.account,
"against": d.against_account,
- "debit": d.debit,
- "credit": d.credit,
+ "debit": flt(d.debit, self.precision("debit", "entries")),
+ "credit": flt(d.credit, self.precision("credit", "entries")),
"against_voucher_type": ((d.against_voucher and "Purchase Invoice")
or (d.against_invoice and "Sales Invoice")
or (d.against_jv and "Journal Voucher")),
@@ -279,7 +282,7 @@
msgprint(_("'Entries' cannot be empty"), raise_exception=True)
else:
flag, self.total_debit, self.total_credit = 0, 0, 0
- diff = flt(self.difference, 2)
+ diff = flt(self.difference, self.precision("difference"))
# If any row without amount, set the diff on that row
for d in self.get('entries'):
@@ -298,45 +301,44 @@
elif diff<0:
jd.debit = abs(diff)
- # Set the total debit, total credit and difference
- for d in self.get('entries'):
- self.total_debit += flt(d.debit, 2)
- self.total_credit += flt(d.credit, 2)
-
- self.difference = flt(self.total_debit, 2) - flt(self.total_credit, 2)
+ self.validate_debit_and_credit()
def get_outstanding_invoices(self):
self.set('entries', [])
total = 0
for d in self.get_values():
- total += flt(d[2])
- jd = self.append('entries', {})
- jd.account = cstr(d[1])
+ total += flt(d.outstanding_amount, self.precision("credit", "entries"))
+ jd1 = self.append('entries', {})
+ jd1.account = d.account
+
if self.write_off_based_on == 'Accounts Receivable':
- jd.credit = flt(d[2])
- jd.against_invoice = cstr(d[0])
+ jd1.credit = flt(d.outstanding_amount, self.precision("credit", "entries"))
+ jd1.against_invoice = cstr(d.name)
elif self.write_off_based_on == 'Accounts Payable':
- jd.debit = flt(d[2])
- jd.against_voucher = cstr(d[0])
- jd.save(1)
- jd = self.append('entries', {})
+ jd1.debit = flt(d.outstanding_amount, self.precision("debit", "entries"))
+ jd1.against_voucher = cstr(d.name)
+
+ jd2 = self.append('entries', {})
if self.write_off_based_on == 'Accounts Receivable':
- jd.debit = total
+ jd2.debit = total
elif self.write_off_based_on == 'Accounts Payable':
- jd.credit = total
- jd.save(1)
+ jd2.credit = total
+
+ self.validate_debit_and_credit()
+
def get_values(self):
- cond = (flt(self.write_off_amount) > 0) and \
- ' and outstanding_amount <= '+ self.write_off_amount or ''
+ cond = " and outstanding_amount <= {0}".format(self.write_off_amount) \
+ if flt(self.write_off_amount) > 0 else ""
+
if self.write_off_based_on == 'Accounts Receivable':
- return frappe.db.sql("""select name, debit_to, outstanding_amount
+ return frappe.db.sql("""select name, debit_to as account, outstanding_amount
from `tabSales Invoice` where docstatus = 1 and company = %s
- and outstanding_amount > 0 %s""" % ('%s', cond), self.company)
+ and outstanding_amount > 0 %s""" % ('%s', cond), self.company, as_dict=True)
elif self.write_off_based_on == 'Accounts Payable':
- return frappe.db.sql("""select name, credit_to, outstanding_amount
+ return frappe.db.sql("""select name, credit_to as account, outstanding_amount
from `tabPurchase Invoice` where docstatus = 1 and company = %s
- and outstanding_amount > 0 %s""" % ('%s', cond), self.company)
+ and outstanding_amount > 0 %s""" % ('%s', cond), self.company, as_dict=True)
@frappe.whitelist()
def get_default_bank_cash_account(company, voucher_type):
diff --git a/erpnext/config/desktop.py b/erpnext/config/desktop.py
index 700013f..4b9f8f8 100644
--- a/erpnext/config/desktop.py
+++ b/erpnext/config/desktop.py
@@ -1,60 +1,61 @@
from frappe import _
-data = {
- "Accounts": {
- "color": "#3498db",
- "icon": "icon-money",
- "type": "module"
- },
- "Activity": {
- "color": "#e67e22",
- "icon": "icon-play",
- "label": _("Activity"),
- "link": "activity",
- "type": "page"
- },
- "Buying": {
- "color": "#c0392b",
- "icon": "icon-shopping-cart",
- "type": "module"
- },
- "HR": {
- "color": "#2ecc71",
- "icon": "icon-group",
- "label": _("Human Resources"),
- "type": "module"
- },
- "Manufacturing": {
- "color": "#7f8c8d",
- "icon": "icon-cogs",
- "type": "module"
- },
- "Notes": {
- "color": "#95a5a6",
- "doctype": "Note",
- "icon": "icon-file-alt",
- "label": _("Notes"),
- "link": "List/Note",
- "type": "list"
- },
- "Projects": {
- "color": "#8e44ad",
- "icon": "icon-puzzle-piece",
- "type": "module"
- },
- "Selling": {
- "color": "#1abc9c",
- "icon": "icon-tag",
- "type": "module"
- },
- "Stock": {
- "color": "#f39c12",
- "icon": "icon-truck",
- "type": "module"
- },
- "Support": {
- "color": "#2c3e50",
- "icon": "icon-phone",
- "type": "module"
+def get_data():
+ return {
+ "Accounts": {
+ "color": "#3498db",
+ "icon": "icon-money",
+ "type": "module"
+ },
+ "Activity": {
+ "color": "#e67e22",
+ "icon": "icon-play",
+ "label": _("Activity"),
+ "link": "activity",
+ "type": "page"
+ },
+ "Buying": {
+ "color": "#c0392b",
+ "icon": "icon-shopping-cart",
+ "type": "module"
+ },
+ "HR": {
+ "color": "#2ecc71",
+ "icon": "icon-group",
+ "label": _("Human Resources"),
+ "type": "module"
+ },
+ "Manufacturing": {
+ "color": "#7f8c8d",
+ "icon": "icon-cogs",
+ "type": "module"
+ },
+ "Notes": {
+ "color": "#95a5a6",
+ "doctype": "Note",
+ "icon": "icon-file-alt",
+ "label": _("Notes"),
+ "link": "List/Note",
+ "type": "list"
+ },
+ "Projects": {
+ "color": "#8e44ad",
+ "icon": "icon-puzzle-piece",
+ "type": "module"
+ },
+ "Selling": {
+ "color": "#1abc9c",
+ "icon": "icon-tag",
+ "type": "module"
+ },
+ "Stock": {
+ "color": "#f39c12",
+ "icon": "icon-truck",
+ "type": "module"
+ },
+ "Support": {
+ "color": "#2c3e50",
+ "icon": "icon-phone",
+ "type": "module"
+ }
}
-}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.json b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.json
index c0cb78d..0302bc9 100644
--- a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.json
+++ b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.json
@@ -1,7 +1,7 @@
{
"allow_import": 0,
"autoname": "LAPPR-/.#####",
- "creation": "2013-04-12 06:56:15.000000",
+ "creation": "2013-04-12 06:56:15",
"description": "Users who can approve a specific employee's leave applications",
"docstatus": 0,
"doctype": "DocType",
@@ -11,6 +11,7 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "Leave Approver",
+ "options": "[Select]",
"permlevel": 0,
"print_hide": 1,
"reqd": 1,
@@ -19,9 +20,12 @@
],
"idx": 1,
"istable": 1,
- "modified": "2013-12-20 19:23:12.000000",
+ "modified": "2014-05-15 19:32:14.134420",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Leave Approver",
- "owner": "Administrator"
+ "owner": "Administrator",
+ "permissions": [],
+ "sort_field": "modified",
+ "sort_order": "DESC"
}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js
index 3ce7a5b..acb91c6 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.js
+++ b/erpnext/hr/doctype/leave_application/leave_application.js
@@ -19,7 +19,9 @@
function(user) {
return {value: user, label: frappe.user_info(user).fullname};
}));
+
if(leave_approver) cur_frm.set_value("leave_approver", leave_approver);
+
cur_frm.cscript.get_leave_balance(cur_frm.doc);
}
});
diff --git a/erpnext/hr/doctype/leave_application/leave_application.json b/erpnext/hr/doctype/leave_application/leave_application.json
index 581ee2a..eb9b239 100644
--- a/erpnext/hr/doctype/leave_application/leave_application.json
+++ b/erpnext/hr/doctype/leave_application/leave_application.json
@@ -20,9 +20,9 @@
{
"description": "Leave can be approved by users with Role, \"Leave Approver\"",
"fieldname": "leave_approver",
- "fieldtype": "Link",
+ "fieldtype": "Select",
"label": "Leave Approver",
- "options": "User",
+ "options": "[Select]",
"permlevel": 0
},
{
@@ -182,7 +182,7 @@
"idx": 1,
"is_submittable": 1,
"max_attachments": 3,
- "modified": "2014-05-09 02:17:13.936705",
+ "modified": "2014-05-15 19:30:47.331357",
"modified_by": "Administrator",
"module": "HR",
"name": "Leave Application",
diff --git a/erpnext/setup/doctype/item_group/item_group.json b/erpnext/setup/doctype/item_group/item_group.json
index 8ab7262..a77978e 100644
--- a/erpnext/setup/doctype/item_group/item_group.json
+++ b/erpnext/setup/doctype/item_group/item_group.json
@@ -32,7 +32,7 @@
{
"fieldname": "cb0",
"fieldtype": "Column Break",
- "in_list_view": 1,
+ "in_list_view": 0,
"permlevel": 0
},
{
@@ -162,7 +162,7 @@
"in_create": 1,
"issingle": 0,
"max_attachments": 3,
- "modified": "2014-05-04 00:06:26.075492",
+ "modified": "2014-05-16 15:26:47.322787",
"modified_by": "Administrator",
"module": "Setup",
"name": "Item Group",
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.js b/erpnext/setup/page/setup_wizard/setup_wizard.js
index ee1daa1..cf16656 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.js
+++ b/erpnext/setup/page/setup_wizard/setup_wizard.js
@@ -68,6 +68,7 @@
onload: function(slide) {
slide.get_input("language").on("change", function() {
var lang = $(this).val();
+ frappe._messages = {};
frappe.call({
method: "erpnext.setup.page.setup_wizard.setup_wizard.load_messages",
args: {
@@ -240,6 +241,7 @@
"help": __("List your tax heads (e.g. VAT, Excise; they should have unique names) and their standard rates. This will create a standard template, which you can edit and add more later."),
"fields": [],
before_load: function(slide) {
+ slide.fields = [];
for(var i=1; i<4; i++) {
slide.fields = slide.fields.concat([
{fieldtype:"Data", fieldname:"tax_"+ i, label:__("Tax") + " " + i,
@@ -259,6 +261,7 @@
"help": __("List a few of your customers. They could be organizations or individuals."),
"fields": [],
before_load: function(slide) {
+ slide.fields = [];
for(var i=1; i<6; i++) {
slide.fields = slide.fields.concat([
{fieldtype:"Data", fieldname:"customer_" + i, label:__("Customer") + " " + i,
@@ -279,6 +282,7 @@
"help": __("List a few of your suppliers. They could be organizations or individuals."),
"fields": [],
before_load: function(slide) {
+ slide.fields = [];
for(var i=1; i<6; i++) {
slide.fields = slide.fields.concat([
{fieldtype:"Data", fieldname:"supplier_" + i, label:__("Supplier")+" " + i,
@@ -299,6 +303,7 @@
"help": __("List your products or services that you buy or sell. Make sure to check the Item Group, Unit of Measure and other properties when you start."),
"fields": [],
before_load: function(slide) {
+ slide.fields = [];
for(var i=1; i<6; i++) {
slide.fields = slide.fields.concat([
{fieldtype:"Section Break", show_section_border: true},
@@ -307,10 +312,10 @@
{fieldtype: "Check", fieldname: "is_sales_item_" + i, label:__("We sell this Item")},
{fieldtype: "Check", fieldname: "is_purchase_item_" + i, label:__("We buy this Item")},
{fieldtype:"Column Break"},
- {fieldtype:"Select", label:"Group", fieldname:"item_group_" + i,
+ {fieldtype:"Select", label:__("Group"), fieldname:"item_group_" + i,
options:[__("Products"), __("Services"),
__("Raw Material"), __("Consumable"), __("Sub Assemblies")]},
- {fieldtype:"Select", fieldname:"item_uom_" + i, label:"UOM",
+ {fieldtype:"Select", fieldname:"item_uom_" + i, label:__("UOM"),
options:[__("Unit"), __("Nos"), __("Box"), __("Pair"), __("Kg"), __("Set"),
__("Hour"), __("Minute")]},
{fieldtype:"Attach", fieldname:"item_img_" + i, label:__("Attach Image")},