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
// 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]
]
}
]
}
}

View File

@ -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": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>",
"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,

View File

@ -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 ""

View File

@ -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;
}
};

View File

@ -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", [])