diff --git a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.js b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.js index ef011f2e122..2a4dec13a6b 100644 --- a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.js +++ b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.js @@ -6,14 +6,15 @@ frappe.provide("erpnext.cheque_print"); frappe.ui.form.on('Cheque Print Template', { refresh: function(frm) { if(!frm.doc.__islocal) { - frm.add_custom_button(__("Cheque Print Preview"), function() { + frm.add_custom_button(frm.doc.has_print_format?__("Update Print Format"):__("Create Print Format"), + function() { erpnext.cheque_print.view_cheque_print(frm); - }); + }).addClass("btn-primary"); $(frm.fields_dict.cheque_print_preview.wrapper).empty() $("
\ -
\ - "+ frappe.datetime.obj_to_user() +" \ - 1234567890 \ - Saurabh Palande \ - One Crore One Lakh Forty One Thousand Six hundred And Sixty Six Only \ - 1,01,41666.00 \ - Frappe Technologies Pvt Ltd \ -
") - - } + frappe.call({ + method: "erpnext.accounts.doctype.cheque_print_template.cheque_print_template.create_or_update_cheque_print_format", + args:{ + "template_name": frm.doc.name + }, + callback: function(r) { + if (!r.exe && !frm.doc.has_print_format) { + var doc = frappe.model.sync(r.message); + frappe.set_route("Form", r.message.doctype, r.message.name); + } + else { + frappe.msgprint(__("Print settings updated in respective print format")) + } + } + }) +} diff --git a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.json b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.json index 77dae361c9e..19b5a93fd35 100644 --- a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.json +++ b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.json @@ -25,7 +25,7 @@ "label": "", "length": 0, "no_copy": 0, - "options": "
\n

All dimensions in CM only

\n
", + "options": "
\n

All dimensions in centimeter only

\n
", "permlevel": 0, "precision": "", "print_hide": 0, @@ -41,14 +41,39 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "cheque_details", + "fieldname": "has_print_format", + "fieldtype": "Check", + "hidden": 1, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Has Print Format", + "length": 0, + "no_copy": 1, + "permlevel": 0, + "precision": "", + "print_hide": 1, + "print_hide_if_no_value": 0, + "read_only": 1, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "primary_settings", "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Cheque Details", + "label": "Primary Settings", "length": 0, "no_copy": 0, "permlevel": 0, @@ -75,7 +100,33 @@ "in_list_view": 0, "label": "Bank Name", "length": 0, + "no_copy": 1, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "cheque_size", + "fieldtype": "Select", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Cheque Size", + "length": 0, "no_copy": 0, + "options": "\nRegular\nA4", "permlevel": 0, "precision": "", "print_hide": 0, @@ -91,42 +142,19 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "scanned_cheque", - "fieldtype": "Attach", + "depends_on": "eval:doc.cheque_size==\"A4\"", + "fieldname": "starting_position_from_top_edge", + "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Scanned Cheque", + "label": "Starting position from top edge", "length": 0, "no_copy": 0, "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "fieldname": "column_break_5", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", + "precision": "2", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -190,16 +218,91 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "date_settings", + "fieldname": "column_break_5", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "scanned_cheque", + "fieldtype": "Attach", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Scanned Cheque", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "date_and_payer_settings", "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "label": "", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "date_settings", + "fieldtype": "HTML", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, "label": "Date Settings", "length": 0, "no_copy": 0, + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -266,7 +369,7 @@ "bold": 0, "collapsible": 0, "fieldname": "payer_settings", - "fieldtype": "Section Break", + "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -340,14 +443,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "amount_in_words", + "fieldname": "amount_in_words_and_figure_settings", "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Amount In Words", + "label": "", "length": 0, "no_copy": 0, "permlevel": 0, @@ -361,6 +464,31 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "html_19", + "fieldtype": "HTML", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "length": 0, + "no_copy": 0, + "options": "", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -466,7 +594,7 @@ "bold": 0, "collapsible": 0, "fieldname": "amount_in_figure", - "fieldtype": "Section Break", + "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -540,14 +668,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "account_number_dimensions", + "fieldname": "account_number_and_signatory_settings", "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Account Number Dimensions", + "label": "", "length": 0, "no_copy": 0, "permlevel": 0, @@ -561,6 +689,31 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "account_no_settings", + "fieldtype": "HTML", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "length": 0, + "no_copy": 0, + "options": "", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -616,7 +769,7 @@ "bold": 0, "collapsible": 0, "fieldname": "signatory_position", - "fieldtype": "Section Break", + "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -745,7 +898,7 @@ "issingle": 0, "istable": 0, "max_attachments": 1, - "modified": "2016-05-11 19:50:25.554911", + "modified": "2016-05-16 12:32:26.649060", "modified_by": "Administrator", "module": "Accounts", "name": "Cheque Print Template", diff --git a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py index 0524bf9329d..eb3e3d5e4a8 100644 --- a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py +++ b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py @@ -5,54 +5,77 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document -from frappe.utils import flt, cstr class ChequePrintTemplate(Document): - def on_update(self): - if not frappe.db.exists("Print Format", self.name): - cheque_print = frappe.new_doc("Print Format") - cheque_print.update({ - "doc_type": "Journal Entry", - "standard": "Yes", - "custom_format": 1, - "print_format_type": "Server", - "name": self.name - }) - else: - cheque_print = frappe.get_doc("Print Format", self.name) - - - cheque_print.html = """ -
-
- + pass + +@frappe.whitelist() +def create_or_update_cheque_print_format(template_name): + if not frappe.db.exists("Print Format", template_name): + cheque_print = frappe.new_doc("Print Format") + cheque_print.update({ + "doc_type": "Journal Entry", + "standard": "No", + "custom_format": 1, + "print_format_type": "Server", + "name": template_name + }) + else: + cheque_print = frappe.get_doc("Print Format", template_name) + + doc = frappe.get_doc("Cheque Print Template", template_name) + + cheque_print.html = """ +
+
+ {{doc.cheque_date or '' }} - - 1234567890 + + {{ doc.account_no or "Account No" }} - + {{doc.pay_to_recd_from}} - + {{doc.total_amount_in_words}} - + {{doc.get_formatted("total_amount")}} - + {{doc.company}} -
"""%(self.cheque_width, self.cheque_height, - self.date_dist_from_top_edge, self.date_dist_from_left_edge, - self.acc_no_dist_from_top_edge, self.acc_no_dist_from_left_edge, - self.payer_name_from_top_edge, self.payer_name_from_left_edge, - self.amt_in_words_from_top_edge, self.amt_in_words_from_left_edge, - self.amt_in_word_width, self.amt_in_words_line_spacing, - self.amt_in_figures_from_top_edge, self.amt_in_figures_from_left_edge, - self.signatory_from_top_edge, self.signatory_from_left_edge) - - cheque_print.save(ignore_permissions=True) +
+
"""%{ + "starting_position_from_top_edge": doc.starting_position_from_top_edge \ + if doc.cheque_size == "A4" else 0.0, + "cheque_width": doc.cheque_width, "cheque_height": doc.cheque_height, + "date_dist_from_top_edge": doc.date_dist_from_top_edge, + "date_dist_from_left_edge": doc.date_dist_from_left_edge, + "acc_no_dist_from_top_edge": doc.acc_no_dist_from_top_edge, + "acc_no_dist_from_left_edge": doc.acc_no_dist_from_left_edge, + "payer_name_from_top_edge": doc.payer_name_from_top_edge, + "payer_name_from_left_edge": doc.payer_name_from_left_edge, + "amt_in_words_from_top_edge": doc.amt_in_words_from_top_edge, + "amt_in_words_from_left_edge": doc.amt_in_words_from_left_edge, + "amt_in_word_width": doc.amt_in_word_width, + "amt_in_words_line_spacing": doc.amt_in_words_line_spacing, + "amt_in_figures_from_top_edge": doc.amt_in_figures_from_top_edge, + "amt_in_figures_from_left_edge": doc.amt_in_figures_from_left_edge, + "signatory_from_top_edge": doc.signatory_from_top_edge, + "signatory_from_left_edge": doc.signatory_from_left_edge + } - + cheque_print.save(ignore_permissions=True) + + frappe.db.set_value("Cheque Print Template", template_name, "has_print_format", 1) + + return cheque_print