[minor] ui/ux fixes in Payment Tool
diff --git a/erpnext/accounts/doctype/payment_tool/__init__.py b/erpnext/accounts/doctype/payment_tool/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/accounts/doctype/payment_tool/__init__.py
diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.js b/erpnext/accounts/doctype/payment_tool/payment_tool.js
index b9f69ef..3e0d2ee 100644
--- a/erpnext/accounts/doctype/payment_tool/payment_tool.js
+++ b/erpnext/accounts/doctype/payment_tool/payment_tool.js
@@ -4,12 +4,34 @@
frappe.provide("erpnext.payment_tool");
// Help content
-frappe.ui.form.on("Payment Tool", "onload", function(frm) {
- var help_content = '<i class="icon-hand-right"></i> Note:<br>'+
- '<ul>If payment is not made against any reference, make Journal Voucher manually.</ul>';
- frm.set_value("make_jv_help", help_content);
+frappe.ui.form.on("Payment Tool", "onload", function(frm) {
+ frm.set_value("make_jv_help", '<i class="icon-hand-right"></i> '
+ + __("Note: If payment is not made against any reference, make Journal Voucher manually."));
- frm.set_value("party_type", "Customer");
+ frm.set_query("payment_account", function() {
+ return {
+ filters: [
+ ['Account', 'account_type', 'in', 'Bank, Cash'],
+ ['Account', 'group_or_ledger', '=', 'Ledger'],
+ ['Account', 'company', '=', frm.doc.company]
+ ]
+ }
+ });
+
+ frm.set_query("against_voucher_type", "payment_tool_details", function() {
+ return {
+ filters: {"name": ["in", ["Sales Invoice", "Purchase Invoice", "Journal Voucher", "Sales Order", "Purchase Order"]]}
+ };
+ });
+});
+
+frappe.ui.form.on("Payment Tool", "refresh", function(frm) {
+ frappe.ui.form.trigger("Payment Tool", "party_type");
+});
+
+frappe.ui.form.on("Payment Tool", "party_type", function(frm) {
+ frm.toggle_reqd("customer", frm.doc.party_type == "Customer");
+ frm.toggle_reqd("supplier", frm.doc.party_type == "Supplier");
});
frappe.ui.form.on("Payment Tool", "company", function(frm) {
@@ -79,9 +101,11 @@
}
},
callback: function(r, rt) {
- frm.fields_dict.get_outstanding_vouchers.$input.removeClass("btn-primary");
- frm.fields_dict.make_journal_voucher.$input.addClass("btn-primary");
if(r.message) {
+ frm.fields_dict.get_outstanding_vouchers.$input.removeClass("btn-primary");
+ frm.fields_dict.make_journal_voucher.$input.addClass("btn-primary");
+
+ frappe.model.clear_table(frm.doc, "payment_tool_details");
$.each(r.message, function(i, d) {
var invoice_detail = frappe.model.add_child(frm.doc, "Payment Tool Detail", "payment_tool_details");
invoice_detail.against_voucher_type = d.voucher_type;
@@ -89,10 +113,9 @@
invoice_detail.total_amount = d.invoice_amount;
invoice_detail.outstanding_amount = d.outstanding_amount;
});
- refresh_field("payment_tool_details");
- frm.refresh_dependency();
}
-
+ refresh_field("payment_tool_details");
+ erpnext.payment_tool.set_total_payment_amount(frm);
}
});
});
@@ -180,27 +203,6 @@
});
});
-cur_frm.fields_dict['payment_tool_details'].grid.get_field('against_voucher_no').get_query = function(doc, cdt, cdn) {
- var c = locals[cdt][cdn];
-
- erpnext.payment_tool.check_mandatory_to_fetch(doc);
-
- args = { "docstatus": 1 };
-
- if (c.against_voucher_type) {
- if (in_list(["Sales Order", "Sales Invoice", "Purchase Order", "Purchase Invoice"], c.against_voucher_type)) {
- var party_type = doc.party_type.toLowerCase();
- args[party_type] = doc[party_type];
- }
- return {
- doctype: c.against_voucher_type,
- filters: args
- }
- } else {
- frappe.throw(__("Row {0}: Please specify the Against Voucher Type", [c.idx]));
- }
-}
-
erpnext.payment_tool.check_mandatory_to_fetch = function(doc) {
var check_fields = [
['Company', doc.company],
diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.json b/erpnext/accounts/doctype/payment_tool/payment_tool.json
index 0528beb..b2949a9 100644
--- a/erpnext/accounts/doctype/payment_tool/payment_tool.json
+++ b/erpnext/accounts/doctype/payment_tool/payment_tool.json
@@ -1,5 +1,4 @@
{
- "allow_attach": 0,
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 0,
@@ -25,6 +24,7 @@
},
{
"allow_on_submit": 0,
+ "default": "Customer",
"fieldname": "party_type",
"fieldtype": "Select",
"hidden": 0,
@@ -113,6 +113,24 @@
},
{
"allow_on_submit": 0,
+ "fieldname": "get_outstanding_vouchers",
+ "fieldtype": "Button",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Get Outstanding Vouchers",
+ "no_copy": 0,
+ "permlevel": 0,
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0
+ },
+ {
+ "allow_on_submit": 0,
"fieldname": "col_break1",
"fieldtype": "Column Break",
"hidden": 0,
@@ -204,34 +222,6 @@
"set_only_once": 0
},
{
- "fieldname": "sec_break2",
- "fieldtype": "Section Break",
- "permlevel": 0
- },
- {
- "fieldname": "column_break_14",
- "fieldtype": "Column Break",
- "permlevel": 0
- },
- {
- "allow_on_submit": 0,
- "fieldname": "get_outstanding_vouchers",
- "fieldtype": "Button",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Get Outstanding Vouchers",
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0
- },
- {
"allow_on_submit": 0,
"depends_on": "eval:(doc.company && doc.party_type && doc.received_or_paid && (doc.customer || doc.supplier))",
"fieldname": "sec_break3",
@@ -270,6 +260,13 @@
"set_only_once": 0
},
{
+ "depends_on": "eval:(doc.company && doc.party_type && doc.received_or_paid && (doc.customer || doc.supplier))",
+ "fieldname": "section_break_19",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
"fieldname": "total_payment_amount",
"fieldtype": "Currency",
"label": "Total Payment Amount",
@@ -295,6 +292,19 @@
"set_only_once": 0
},
{
+ "fieldname": "data_22",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "depends_on": "eval:(doc.company && doc.party_type && doc.received_or_paid && (doc.customer || doc.supplier))",
+ "fieldname": "section_break_21",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
"allow_on_submit": 0,
"fieldname": "make_jv_help",
"fieldtype": "Small Text",
@@ -320,7 +330,7 @@
"is_submittable": 0,
"issingle": 1,
"istable": 0,
- "modified": "2014-09-05 11:15:55.484916",
+ "modified": "2014-09-12 04:43:05.963218",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Tool",
diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.py b/erpnext/accounts/doctype/payment_tool/payment_tool.py
index e07f253..d8d6df3 100644
--- a/erpnext/accounts/doctype/payment_tool/payment_tool.py
+++ b/erpnext/accounts/doctype/payment_tool/payment_tool.py
@@ -59,6 +59,9 @@
def get_outstanding_vouchers(args):
from erpnext.accounts.utils import get_outstanding_invoices
+ if not frappe.has_permission("Payment Tool"):
+ frappe.throw(_("No permission to use Payment Tool"), frappe.PermissionError)
+
args = json.loads(args)
if args.get("party_type") == "Customer" and args.get("received_or_paid") == "Received":
diff --git a/erpnext/accounts/doctype/payment_tool_detail/__init__.py b/erpnext/accounts/doctype/payment_tool_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/accounts/doctype/payment_tool_detail/__init__.py
diff --git a/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json b/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json
index de39345..5f0e7ec 100644
--- a/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json
+++ b/erpnext/accounts/doctype/payment_tool_detail/payment_tool_detail.json
@@ -1,5 +1,4 @@
{
- "allow_attach": 0,
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 0,
@@ -12,14 +11,14 @@
{
"allow_on_submit": 0,
"fieldname": "against_voucher_type",
- "fieldtype": "Select",
+ "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 1,
"label": "Against Voucher Type",
"no_copy": 0,
- "options": "\nSales Invoice\nPurchase Invoice\nJournal Voucher\nSales Order\nPurchase Order",
+ "options": "DocType",
"permlevel": 0,
"print_hide": 0,
"print_width": "",
@@ -33,14 +32,14 @@
{
"allow_on_submit": 0,
"fieldname": "against_voucher_no",
- "fieldtype": "Link",
+ "fieldtype": "Dynamic Link",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 1,
"label": "Against Voucher No",
"no_copy": 0,
- "options": "[Select]",
+ "options": "against_voucher_type",
"permlevel": 0,
"print_hide": 0,
"read_only": 0,
@@ -50,6 +49,12 @@
"set_only_once": 0
},
{
+ "fieldname": "column_break_3",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
"allow_on_submit": 0,
"fieldname": "total_amount",
"fieldtype": "Currency",
@@ -111,7 +116,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 1,
- "modified": "2014-08-20 12:32:29.842215",
+ "modified": "2014-09-11 08:55:34.384017",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Tool Detail",
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json
index e41c358..2224db7 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.json
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.json
@@ -657,7 +657,7 @@
"icon": "icon-file-text",
"idx": 1,
"is_submittable": 1,
- "modified": "2014-09-09 05:35:32.583024",
+ "modified": "2014-09-10 05:35:32.583024",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order",
diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json
index 672f311..844e8cd 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.json
+++ b/erpnext/selling/doctype/sales_order/sales_order.json
@@ -560,14 +560,6 @@
"width": "200px"
},
{
- "fieldname": "advance_paid",
- "fieldtype": "Currency",
- "label": "Advance Paid",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 1
- },
- {
"fieldname": "view_details",
"fieldtype": "Fold",
"label": "View Details",
@@ -1036,7 +1028,7 @@
"idx": 1,
"is_submittable": 1,
"issingle": 0,
- "modified": "2014-09-09 05:35:34.761247",
+ "modified": "2014-09-10 05:35:34.761247",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order",