Merge pull request #1659 from nabinhait/v4-hotfix

translation and fraction issue fixes
This commit is contained in:
Nabin Hait 2014-05-16 20:11:26 +05:30
commit 097227d5ea
8 changed files with 116 additions and 102 deletions

View File

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

View File

@ -120,18 +120,21 @@ class JournalVoucher(AccountsController):
if flt(d.credit > 0): d.against_account = ", ".join(list(set(accounts_debited))) if flt(d.credit > 0): d.against_account = ", ".join(list(set(accounts_debited)))
def validate_debit_and_credit(self): 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"): for d in self.get("entries"):
if d.debit and d.credit: if d.debit and d.credit:
frappe.throw(_("You cannot credit and debit same account at the same time")) 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_debit = flt(self.total_debit) + flt(d.debit, self.precision("debit", "entries"))
self.total_credit = flt(self.total_credit) + flt(d.credit) 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}") 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): def create_remarks(self):
r = [] r = []
@ -254,8 +257,8 @@ class JournalVoucher(AccountsController):
self.get_gl_dict({ self.get_gl_dict({
"account": d.account, "account": d.account,
"against": d.against_account, "against": d.against_account,
"debit": d.debit, "debit": flt(d.debit, self.precision("debit", "entries")),
"credit": d.credit, "credit": flt(d.credit, self.precision("credit", "entries")),
"against_voucher_type": ((d.against_voucher and "Purchase Invoice") "against_voucher_type": ((d.against_voucher and "Purchase Invoice")
or (d.against_invoice and "Sales Invoice") or (d.against_invoice and "Sales Invoice")
or (d.against_jv and "Journal Voucher")), or (d.against_jv and "Journal Voucher")),
@ -279,7 +282,7 @@ class JournalVoucher(AccountsController):
msgprint(_("'Entries' cannot be empty"), raise_exception=True) msgprint(_("'Entries' cannot be empty"), raise_exception=True)
else: else:
flag, self.total_debit, self.total_credit = 0, 0, 0 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 # If any row without amount, set the diff on that row
for d in self.get('entries'): for d in self.get('entries'):
@ -298,45 +301,44 @@ class JournalVoucher(AccountsController):
elif diff<0: elif diff<0:
jd.debit = abs(diff) jd.debit = abs(diff)
# Set the total debit, total credit and difference self.validate_debit_and_credit()
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)
def get_outstanding_invoices(self): def get_outstanding_invoices(self):
self.set('entries', []) self.set('entries', [])
total = 0 total = 0
for d in self.get_values(): for d in self.get_values():
total += flt(d[2]) total += flt(d.outstanding_amount, self.precision("credit", "entries"))
jd = self.append('entries', {}) jd1 = self.append('entries', {})
jd.account = cstr(d[1]) jd1.account = d.account
if self.write_off_based_on == 'Accounts Receivable': if self.write_off_based_on == 'Accounts Receivable':
jd.credit = flt(d[2]) jd1.credit = flt(d.outstanding_amount, self.precision("credit", "entries"))
jd.against_invoice = cstr(d[0]) jd1.against_invoice = cstr(d.name)
elif self.write_off_based_on == 'Accounts Payable': elif self.write_off_based_on == 'Accounts Payable':
jd.debit = flt(d[2]) jd1.debit = flt(d.outstanding_amount, self.precision("debit", "entries"))
jd.against_voucher = cstr(d[0]) jd1.against_voucher = cstr(d.name)
jd.save(1)
jd = self.append('entries', {}) jd2 = self.append('entries', {})
if self.write_off_based_on == 'Accounts Receivable': if self.write_off_based_on == 'Accounts Receivable':
jd.debit = total jd2.debit = total
elif self.write_off_based_on == 'Accounts Payable': elif self.write_off_based_on == 'Accounts Payable':
jd.credit = total jd2.credit = total
jd.save(1)
self.validate_debit_and_credit()
def get_values(self): def get_values(self):
cond = (flt(self.write_off_amount) > 0) and \ cond = " and outstanding_amount <= {0}".format(self.write_off_amount) \
' and outstanding_amount <= '+ self.write_off_amount or '' if flt(self.write_off_amount) > 0 else ""
if self.write_off_based_on == 'Accounts Receivable': 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 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': 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 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() @frappe.whitelist()
def get_default_bank_cash_account(company, voucher_type): def get_default_bank_cash_account(company, voucher_type):

View File

@ -1,6 +1,7 @@
from frappe import _ from frappe import _
data = { def get_data():
return {
"Accounts": { "Accounts": {
"color": "#3498db", "color": "#3498db",
"icon": "icon-money", "icon": "icon-money",
@ -57,4 +58,4 @@ data = {
"icon": "icon-phone", "icon": "icon-phone",
"type": "module" "type": "module"
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"allow_import": 0, "allow_import": 0,
"autoname": "LAPPR-/.#####", "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", "description": "Users who can approve a specific employee's leave applications",
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
@ -11,6 +11,7 @@
"fieldtype": "Select", "fieldtype": "Select",
"in_list_view": 1, "in_list_view": 1,
"label": "Leave Approver", "label": "Leave Approver",
"options": "[Select]",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"reqd": 1, "reqd": 1,
@ -19,9 +20,12 @@
], ],
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"modified": "2013-12-20 19:23:12.000000", "modified": "2014-05-15 19:32:14.134420",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Employee Leave Approver", "name": "Employee Leave Approver",
"owner": "Administrator" "owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
} }

View File

@ -19,7 +19,9 @@ cur_frm.cscript.onload = function(doc, dt, dn) {
function(user) { function(user) {
return {value: user, label: frappe.user_info(user).fullname}; return {value: user, label: frappe.user_info(user).fullname};
})); }));
if(leave_approver) cur_frm.set_value("leave_approver", leave_approver); if(leave_approver) cur_frm.set_value("leave_approver", leave_approver);
cur_frm.cscript.get_leave_balance(cur_frm.doc); cur_frm.cscript.get_leave_balance(cur_frm.doc);
} }
}); });

View File

@ -20,9 +20,9 @@
{ {
"description": "Leave can be approved by users with Role, \"Leave Approver\"", "description": "Leave can be approved by users with Role, \"Leave Approver\"",
"fieldname": "leave_approver", "fieldname": "leave_approver",
"fieldtype": "Link", "fieldtype": "Select",
"label": "Leave Approver", "label": "Leave Approver",
"options": "User", "options": "[Select]",
"permlevel": 0 "permlevel": 0
}, },
{ {
@ -182,7 +182,7 @@
"idx": 1, "idx": 1,
"is_submittable": 1, "is_submittable": 1,
"max_attachments": 3, "max_attachments": 3,
"modified": "2014-05-09 02:17:13.936705", "modified": "2014-05-15 19:30:47.331357",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Leave Application", "name": "Leave Application",

View File

@ -32,7 +32,7 @@
{ {
"fieldname": "cb0", "fieldname": "cb0",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"in_list_view": 1, "in_list_view": 0,
"permlevel": 0 "permlevel": 0
}, },
{ {
@ -162,7 +162,7 @@
"in_create": 1, "in_create": 1,
"issingle": 0, "issingle": 0,
"max_attachments": 3, "max_attachments": 3,
"modified": "2014-05-04 00:06:26.075492", "modified": "2014-05-16 15:26:47.322787",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Setup", "module": "Setup",
"name": "Item Group", "name": "Item Group",

View File

@ -68,6 +68,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
onload: function(slide) { onload: function(slide) {
slide.get_input("language").on("change", function() { slide.get_input("language").on("change", function() {
var lang = $(this).val(); var lang = $(this).val();
frappe._messages = {};
frappe.call({ frappe.call({
method: "erpnext.setup.page.setup_wizard.setup_wizard.load_messages", method: "erpnext.setup.page.setup_wizard.setup_wizard.load_messages",
args: { args: {
@ -240,6 +241,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
"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."), "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": [], "fields": [],
before_load: function(slide) { before_load: function(slide) {
slide.fields = [];
for(var i=1; i<4; i++) { for(var i=1; i<4; i++) {
slide.fields = slide.fields.concat([ slide.fields = slide.fields.concat([
{fieldtype:"Data", fieldname:"tax_"+ i, label:__("Tax") + " " + i, {fieldtype:"Data", fieldname:"tax_"+ i, label:__("Tax") + " " + i,
@ -259,6 +261,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
"help": __("List a few of your customers. They could be organizations or individuals."), "help": __("List a few of your customers. They could be organizations or individuals."),
"fields": [], "fields": [],
before_load: function(slide) { before_load: function(slide) {
slide.fields = [];
for(var i=1; i<6; i++) { for(var i=1; i<6; i++) {
slide.fields = slide.fields.concat([ slide.fields = slide.fields.concat([
{fieldtype:"Data", fieldname:"customer_" + i, label:__("Customer") + " " + i, {fieldtype:"Data", fieldname:"customer_" + i, label:__("Customer") + " " + i,
@ -279,6 +282,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
"help": __("List a few of your suppliers. They could be organizations or individuals."), "help": __("List a few of your suppliers. They could be organizations or individuals."),
"fields": [], "fields": [],
before_load: function(slide) { before_load: function(slide) {
slide.fields = [];
for(var i=1; i<6; i++) { for(var i=1; i<6; i++) {
slide.fields = slide.fields.concat([ slide.fields = slide.fields.concat([
{fieldtype:"Data", fieldname:"supplier_" + i, label:__("Supplier")+" " + i, {fieldtype:"Data", fieldname:"supplier_" + i, label:__("Supplier")+" " + i,
@ -299,6 +303,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
"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."), "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": [], "fields": [],
before_load: function(slide) { before_load: function(slide) {
slide.fields = [];
for(var i=1; i<6; i++) { for(var i=1; i<6; i++) {
slide.fields = slide.fields.concat([ slide.fields = slide.fields.concat([
{fieldtype:"Section Break", show_section_border: true}, {fieldtype:"Section Break", show_section_border: true},
@ -307,10 +312,10 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
{fieldtype: "Check", fieldname: "is_sales_item_" + i, label:__("We sell this Item")}, {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: "Check", fieldname: "is_purchase_item_" + i, label:__("We buy this Item")},
{fieldtype:"Column Break"}, {fieldtype:"Column Break"},
{fieldtype:"Select", label:"Group", fieldname:"item_group_" + i, {fieldtype:"Select", label:__("Group"), fieldname:"item_group_" + i,
options:[__("Products"), __("Services"), options:[__("Products"), __("Services"),
__("Raw Material"), __("Consumable"), __("Sub Assemblies")]}, __("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"), options:[__("Unit"), __("Nos"), __("Box"), __("Pair"), __("Kg"), __("Set"),
__("Hour"), __("Minute")]}, __("Hour"), __("Minute")]},
{fieldtype:"Attach", fieldname:"item_img_" + i, label:__("Attach Image")}, {fieldtype:"Attach", fieldname:"item_img_" + i, label:__("Attach Image")},