From 69e0cb5d6f175919fae81b5dd60d963b6abf96fe Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Sun, 4 May 2014 19:37:45 +0530 Subject: [PATCH] Fixed POS and Sales Invoice paid amount display, when invoice not submitted. Fixes #1573 --- .../doctype/pos_setting/pos_setting.js | 35 +++++++++++-------- .../doctype/pos_setting/pos_setting.json | 12 ++++--- .../doctype/pos_setting/pos_setting.py | 7 ++-- .../sales_invoice/sales_invoice_list.js | 5 +-- erpnext/controllers/accounts_controller.py | 4 +-- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.js b/erpnext/accounts/doctype/pos_setting/pos_setting.js index 61c64c2839..e2fe88896e 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.js +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.js @@ -1,15 +1,20 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.cscript.onload = function(doc,cdt,cdn){ - return $c_obj(cur_frm.doc, 'get_series','',function(r,rt){ - if(r.message) set_field_options('naming_series', r.message); +frappe.ui.form.on("POS Setting", "onload", function(frm) { + frm.set_query("selling_price_list", function() { + return { filter: { selling: 1 } }; }); - - cur_frm.set_query("selling_price_list", function() { - return { filters: { selling: 1 } }; + + frm.call({ + method: "erpnext.accounts.doctype.pos_setting.pos_setting.get_series", + callback: function(r) { + if(!r.exc) { + set_field_options("naming_series", r.message); + } + } }); -} +}); //cash bank account //------------------------------------ @@ -20,10 +25,10 @@ cur_frm.fields_dict['cash_bank_account'].get_query = function(doc,cdt,cdn) { 'group_or_ledger': "Ledger", 'company': doc.company } - } + } } -// Income Account +// Income Account // -------------------------------- cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) { return{ @@ -32,11 +37,11 @@ cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) { 'company': doc.company, 'account_type': "Income Account" } - } + } } -// Cost Center +// Cost Center // ----------------------------- cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) { return{ @@ -44,11 +49,11 @@ cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) { 'company': doc.company, 'group_or_ledger': "Ledger" } - } + } } -// Expense Account +// Expense Account // ----------------------------- cur_frm.fields_dict["expense_account"].get_query = function(doc) { return { @@ -65,8 +70,8 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) return{ filters:[ ['Print Heading', 'docstatus', '!=', 2] - ] - } + ] + } } diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.json b/erpnext/accounts/doctype/pos_setting/pos_setting.json index 20082771f1..a4f7fe3e9d 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.json +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.json @@ -1,5 +1,5 @@ { - "autoname": "naming_series:", + "autoname": "POS/.####", "creation": "2013-05-24 12:15:51", "docstatus": 0, "doctype": "DocType", @@ -19,6 +19,7 @@ "description": "Add / Edit", "fieldname": "territory", "fieldtype": "Link", + "in_list_view": 1, "label": "Territory", "oldfieldname": "territory", "oldfieldtype": "Link", @@ -30,11 +31,12 @@ { "fieldname": "naming_series", "fieldtype": "Select", + "in_list_view": 1, "label": "Series", "no_copy": 1, "oldfieldname": "naming_series", "oldfieldtype": "Select", - "options": "POS-Setting-.#", + "options": "[Select]", "permlevel": 0, "read_only": 0, "reqd": 1 @@ -42,6 +44,7 @@ { "fieldname": "currency", "fieldtype": "Link", + "in_list_view": 0, "label": "Currency", "oldfieldname": "currency", "oldfieldtype": "Select", @@ -92,6 +95,7 @@ { "fieldname": "customer", "fieldtype": "Link", + "in_list_view": 0, "label": "Customer", "oldfieldname": "customer_account", "oldfieldtype": "Link", @@ -201,7 +205,7 @@ ], "icon": "icon-cog", "idx": 1, - "modified": "2014-04-27 03:11:44.969097", + "modified": "2014-05-04 08:47:33.250720", "modified_by": "Administrator", "module": "Accounts", "name": "POS Setting", @@ -210,7 +214,7 @@ { "cancel": 0, "create": 1, - "delete": 0, + "delete": 1, "email": 1, "permlevel": 0, "print": 1, diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.py b/erpnext/accounts/doctype/pos_setting/pos_setting.py index ba592b0020..e17cd91a75 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.py +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.py @@ -9,9 +9,6 @@ from frappe.utils import cint from frappe.model.document import Document class POSSetting(Document): - def get_series(self): - frappe.get_meta("Sales Invoice").get_field("naming_series").options or "" - def validate(self): self.check_for_duplicate() self.validate_expense_account() @@ -67,3 +64,7 @@ class POSSetting(Document): frappe.defaults.set_user_default("is_pos", 1, user) else: frappe.defaults.set_global_default("is_pos", 1) + +@frappe.whitelist() +def get_series(): + return frappe.get_meta("Sales Invoice").get_field("naming_series").options or "" diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js index 2f7727e90b..5592bc5220 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js @@ -7,7 +7,8 @@ frappe.listview_settings['Sales Invoice'] = { add_columns: [{"content":"Percent Paid", width:"10%", type:"bar-graph", label: "Payment Received"}], prepare_data: function(data) { - data["Percent Paid"] = flt(data.grand_total) ? (((flt(data.grand_total) - - flt(data.outstanding_amount)) / flt(data.grand_total)) * 100) : 0; + data["Percent Paid"] = (data.docstatus===1 && flt(data.grand_total)) + ? (((flt(data.grand_total) - flt(data.outstanding_amount)) / flt(data.grand_total)) * 100) + : 0; } }; diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 404dfa741b..c088042864 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -120,10 +120,8 @@ class AccountsController(TransactionBase): if not tax_master_doctype: tax_master_doctype = self.meta.get_field(tax_master_field).options - tax_doctype = self.meta.get_field(tax_parentfield).options - self.extend(tax_parentfield, - get_taxes_and_charges(tax_doctype, self.get(tax_master_field)), tax_parentfield) + get_taxes_and_charges(tax_master_doctype, self.get(tax_master_field), tax_parentfield)) def set_other_charges(self): self.set("other_charges", [])