From 61a591944be77a38527cf9dfc69a9c8627f47853 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 12 Sep 2014 14:16:41 +0530 Subject: [PATCH] [minor] ui/ux fixes in Payment Tool --- .../accounts/doctype/payment_tool/__init__.py | 0 .../doctype/payment_tool/payment_tool.js | 64 +++++++++-------- .../doctype/payment_tool/payment_tool.json | 70 +++++++++++-------- .../doctype/payment_tool/payment_tool.py | 3 + .../doctype/payment_tool_detail/__init__.py | 0 .../payment_tool_detail.json | 17 +++-- .../purchase_order/purchase_order.json | 2 +- .../doctype/sales_order/sales_order.json | 10 +-- 8 files changed, 89 insertions(+), 77 deletions(-) create mode 100644 erpnext/accounts/doctype/payment_tool/__init__.py create mode 100644 erpnext/accounts/doctype/payment_tool_detail/__init__.py diff --git a/erpnext/accounts/doctype/payment_tool/__init__.py b/erpnext/accounts/doctype/payment_tool/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.js b/erpnext/accounts/doctype/payment_tool/payment_tool.js index b9f69ef42b..3e0d2eec9f 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 = ' Note:
'+ - ''; - frm.set_value("make_jv_help", help_content); +frappe.ui.form.on("Payment Tool", "onload", function(frm) { + frm.set_value("make_jv_help", ' ' + + __("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 @@ frappe.ui.form.on("Payment Tool", "get_outstanding_vouchers", function(frm) { } }, 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 @@ frappe.ui.form.on("Payment Tool", "get_outstanding_vouchers", function(frm) { 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 @@ frappe.ui.form.on("Payment Tool", "make_journal_voucher", function(frm) { }); }); -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 0528bebd2f..b2949a99a9 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, @@ -111,6 +111,24 @@ "search_index": 0, "set_only_once": 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, "fieldname": "col_break1", @@ -203,34 +221,6 @@ "search_index": 0, "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))", @@ -269,6 +259,13 @@ "search_index": 0, "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", @@ -294,6 +291,19 @@ "search_index": 0, "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", @@ -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 e07f253487..d8d6df3da2 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_party_account(party_type, party_name): 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 0000000000..e69de29bb2 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 de39345608..5f0e7ecb6f 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, @@ -49,6 +48,12 @@ "search_index": 0, "set_only_once": 0 }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, { "allow_on_submit": 0, "fieldname": "total_amount", @@ -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 e41c358079..2224db7ca2 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 672f311026..844e8cd2e0 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -559,14 +559,6 @@ "read_only": 1, "width": "200px" }, - { - "fieldname": "advance_paid", - "fieldtype": "Currency", - "label": "Advance Paid", - "permlevel": 0, - "print_hide": 1, - "read_only": 1 - }, { "fieldname": "view_details", "fieldtype": "Fold", @@ -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",