Fixed POS and Sales Invoice paid amount display, when invoice not submitted. Fixes #1573

This commit is contained in:
Anand Doshi
2014-05-04 19:37:45 +05:30
parent 2af558598c
commit 69e0cb5d6f
5 changed files with 36 additions and 27 deletions

View File

@@ -1,15 +1,20 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
cur_frm.cscript.onload = function(doc,cdt,cdn){ frappe.ui.form.on("POS Setting", "onload", function(frm) {
return $c_obj(cur_frm.doc, 'get_series','',function(r,rt){ frm.set_query("selling_price_list", function() {
if(r.message) set_field_options('naming_series', r.message); return { filter: { selling: 1 } };
}); });
cur_frm.set_query("selling_price_list", function() { frm.call({
return { filters: { selling: 1 } }; 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 //cash bank account
//------------------------------------ //------------------------------------
@@ -20,10 +25,10 @@ cur_frm.fields_dict['cash_bank_account'].get_query = function(doc,cdt,cdn) {
'group_or_ledger': "Ledger", 'group_or_ledger': "Ledger",
'company': doc.company 'company': doc.company
} }
} }
} }
// Income Account // Income Account
// -------------------------------- // --------------------------------
cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) { cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) {
return{ return{
@@ -32,11 +37,11 @@ cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) {
'company': doc.company, 'company': doc.company,
'account_type': "Income Account" 'account_type': "Income Account"
} }
} }
} }
// Cost Center // Cost Center
// ----------------------------- // -----------------------------
cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) { cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) {
return{ return{
@@ -44,11 +49,11 @@ cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) {
'company': doc.company, 'company': doc.company,
'group_or_ledger': "Ledger" 'group_or_ledger': "Ledger"
} }
} }
} }
// Expense Account // Expense Account
// ----------------------------- // -----------------------------
cur_frm.fields_dict["expense_account"].get_query = function(doc) { cur_frm.fields_dict["expense_account"].get_query = function(doc) {
return { return {
@@ -65,8 +70,8 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn)
return{ return{
filters:[ filters:[
['Print Heading', 'docstatus', '!=', 2] ['Print Heading', 'docstatus', '!=', 2]
] ]
} }
} }

View File

@@ -1,5 +1,5 @@
{ {
"autoname": "naming_series:", "autoname": "POS/.####",
"creation": "2013-05-24 12:15:51", "creation": "2013-05-24 12:15:51",
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
@@ -19,6 +19,7 @@
"description": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>", "description": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>",
"fieldname": "territory", "fieldname": "territory",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1,
"label": "Territory", "label": "Territory",
"oldfieldname": "territory", "oldfieldname": "territory",
"oldfieldtype": "Link", "oldfieldtype": "Link",
@@ -30,11 +31,12 @@
{ {
"fieldname": "naming_series", "fieldname": "naming_series",
"fieldtype": "Select", "fieldtype": "Select",
"in_list_view": 1,
"label": "Series", "label": "Series",
"no_copy": 1, "no_copy": 1,
"oldfieldname": "naming_series", "oldfieldname": "naming_series",
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "POS-Setting-.#", "options": "[Select]",
"permlevel": 0, "permlevel": 0,
"read_only": 0, "read_only": 0,
"reqd": 1 "reqd": 1
@@ -42,6 +44,7 @@
{ {
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 0,
"label": "Currency", "label": "Currency",
"oldfieldname": "currency", "oldfieldname": "currency",
"oldfieldtype": "Select", "oldfieldtype": "Select",
@@ -92,6 +95,7 @@
{ {
"fieldname": "customer", "fieldname": "customer",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 0,
"label": "Customer", "label": "Customer",
"oldfieldname": "customer_account", "oldfieldname": "customer_account",
"oldfieldtype": "Link", "oldfieldtype": "Link",
@@ -201,7 +205,7 @@
], ],
"icon": "icon-cog", "icon": "icon-cog",
"idx": 1, "idx": 1,
"modified": "2014-04-27 03:11:44.969097", "modified": "2014-05-04 08:47:33.250720",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "POS Setting", "name": "POS Setting",
@@ -210,7 +214,7 @@
{ {
"cancel": 0, "cancel": 0,
"create": 1, "create": 1,
"delete": 0, "delete": 1,
"email": 1, "email": 1,
"permlevel": 0, "permlevel": 0,
"print": 1, "print": 1,

View File

@@ -9,9 +9,6 @@ from frappe.utils import cint
from frappe.model.document import Document from frappe.model.document import Document
class POSSetting(Document): class POSSetting(Document):
def get_series(self):
frappe.get_meta("Sales Invoice").get_field("naming_series").options or ""
def validate(self): def validate(self):
self.check_for_duplicate() self.check_for_duplicate()
self.validate_expense_account() self.validate_expense_account()
@@ -67,3 +64,7 @@ class POSSetting(Document):
frappe.defaults.set_user_default("is_pos", 1, user) frappe.defaults.set_user_default("is_pos", 1, user)
else: else:
frappe.defaults.set_global_default("is_pos", 1) 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 ""

View File

@@ -7,7 +7,8 @@ frappe.listview_settings['Sales Invoice'] = {
add_columns: [{"content":"Percent Paid", width:"10%", type:"bar-graph", add_columns: [{"content":"Percent Paid", width:"10%", type:"bar-graph",
label: "Payment Received"}], label: "Payment Received"}],
prepare_data: function(data) { prepare_data: function(data) {
data["Percent Paid"] = flt(data.grand_total) ? (((flt(data.grand_total) - data["Percent Paid"] = (data.docstatus===1 && flt(data.grand_total))
flt(data.outstanding_amount)) / flt(data.grand_total)) * 100) : 0; ? (((flt(data.grand_total) - flt(data.outstanding_amount)) / flt(data.grand_total)) * 100)
: 0;
} }
}; };

View File

@@ -120,10 +120,8 @@ class AccountsController(TransactionBase):
if not tax_master_doctype: if not tax_master_doctype:
tax_master_doctype = self.meta.get_field(tax_master_field).options tax_master_doctype = self.meta.get_field(tax_master_field).options
tax_doctype = self.meta.get_field(tax_parentfield).options
self.extend(tax_parentfield, 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): def set_other_charges(self):
self.set("other_charges", []) self.set("other_charges", [])