From bb95d362188e5ffed5a20f7109c85dca3fd8e5bd Mon Sep 17 00:00:00 2001 From: Saurabh Date: Thu, 12 May 2016 11:48:36 +0530 Subject: [PATCH] [fixes] field re-structuring --- .../cheque_print_template.js | 57 ++- .../cheque_print_template.json | 342 +++++++++++++++--- .../cheque_print_template.py | 50 ++- 3 files changed, 384 insertions(+), 65 deletions(-) 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 2625fd67b1..ef011f2e12 100644 --- a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.js +++ b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.js @@ -9,14 +9,45 @@ frappe.ui.form.on('Cheque Print Template', { frm.add_custom_button(__("Cheque Print Preview"), function() { erpnext.cheque_print.view_cheque_print(frm); }); + + $(frm.fields_dict.cheque_print_preview.wrapper).empty() + + $("
\ +
\ + "+ frappe.datetime.obj_to_user() +" \ + Acc. No. \ + Payer Name \ + Amount in Words \ + 1000 \ + Signatory Name \ +
\ +
").appendTo(frm.fields_dict.cheque_print_preview.wrapper) } } }); erpnext.cheque_print.view_cheque_print = function(frm) { - console.log("here") - console.log(frm.doc) var dialog = new frappe.ui.Dialog({ title: 'Cheque Print Preview' }); @@ -28,21 +59,31 @@ erpnext.cheque_print.view_cheque_print = function(frm) { $(body).html("
\ "+ frappe.datetime.obj_to_user() +" \ + 1234567890 \ saurabh Palnde \ + position: absolute;'> Saurabh Palande \ Forty One Thousand Six hundred And Sixty Six Only \ + position: absolute;\ + display: block;\ + width: "+frm.doc.ln_width+"cm;\ + line-height: "+frm.doc.ln_spacing+"cm;\ + word-wrap: break-word;'>One Crore One Lakh Forty One Thousand Six hundred And Sixty Six Only \ 41666.00 \ + left: "+ flt(frm.doc.data_16) +"cm;\ + position: absolute;'> 1,01,41666.00 \ Frappe Technologies Pvt Ltd \
") 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 a700543902..77dae361c9 100644 --- a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.json +++ b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.json @@ -14,16 +14,18 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "description": "", "fieldname": "settings", - "fieldtype": "Section Break", + "fieldtype": "HTML", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Settings", + "label": "", "length": 0, "no_copy": 0, + "options": "
\n

All dimensions in CM only

\n
", "permlevel": 0, "precision": "", "print_hide": 0, @@ -39,16 +41,16 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "html_2", - "fieldtype": "HTML", + "fieldname": "cheque_details", + "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "label": "Cheque Details", "length": 0, "no_copy": 0, - "options": "
\n(All dimensions in CM only)\n
", "permlevel": 0, "precision": "", "print_hide": 0, @@ -85,6 +87,55 @@ "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": "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, @@ -139,13 +190,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "section_break_6", + "fieldname": "date_settings", "fieldtype": "Section Break", "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, "permlevel": 0, @@ -163,14 +215,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "data_7", + "fieldname": "date_dist_from_top_edge", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Distance of date line from top edge", + "label": "Distance from top edge", "length": 0, "no_copy": 0, "permlevel": 0, @@ -188,14 +240,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "data_8", + "fieldname": "date_dist_from_left_edge", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Starting location of Date from left edge", + "label": "Starting location from left edge", "length": 0, "no_copy": 0, "permlevel": 0, @@ -213,13 +265,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "section_break_9", + "fieldname": "payer_settings", "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "label": "Payer Settings", "length": 0, "no_copy": 0, "permlevel": 0, @@ -237,14 +290,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "data_9", + "fieldname": "payer_name_from_top_edge", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Distance of Party name line from top edge", + "label": "Distance from top edge", "length": 0, "no_copy": 0, "permlevel": 0, @@ -262,18 +315,18 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "data_10", + "fieldname": "payer_name_from_left_edge", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Starting location of name from left edge", + "label": "Starting location from left edge", "length": 0, "no_copy": 0, "permlevel": 0, - "precision": "", + "precision": "2", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -287,13 +340,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "section_break_12", + "fieldname": "amount_in_words", "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "label": "Amount In Words", "length": 0, "no_copy": 0, "permlevel": 0, @@ -311,14 +365,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "data_11", + "fieldname": "amt_in_words_from_top_edge", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Distance of amount in word line from top edge", + "label": "Distance from top edge", "length": 0, "no_copy": 0, "permlevel": 0, @@ -336,14 +390,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "data_13", + "fieldname": "amt_in_words_from_left_edge", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Starting location of amount in words from left edge", + "label": "Starting location from left edge", "length": 0, "no_copy": 0, "permlevel": 0, @@ -361,38 +415,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "column_break_6", - "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": "data_15", + "fieldname": "amt_in_word_width", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Distance of amount in figures line from top edge", + "label": "Width of amount in word", "length": 0, "no_copy": 0, "permlevel": 0, @@ -410,14 +440,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "data_16", + "fieldname": "amt_in_words_line_spacing", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Starting location of amount in figures from left edge", + "label": "Line spacing for amount in words", "length": 0, "no_copy": 0, "permlevel": 0, @@ -435,13 +465,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "section_break_17", + "fieldname": "amount_in_figure", "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "label": "Amount In Figure", "length": 0, "no_copy": 0, "permlevel": 0, @@ -459,14 +490,14 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "data_17", + "fieldname": "amt_in_figures_from_top_edge", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Distance of company signature from top edge", + "label": "Distance from top edge", "length": 0, "no_copy": 0, "permlevel": 0, @@ -484,14 +515,213 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "data_18", + "fieldname": "amt_in_figures_from_left_edge", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Starting location of company signature from left edge", + "label": "Starting location from left edge", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "2", + "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": "account_number_dimensions", + "fieldtype": "Section Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Account Number Dimensions", + "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": "acc_no_dist_from_top_edge", + "fieldtype": "Float", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Distance from top edge", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "2", + "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": "acc_no_dist_from_left_edge", + "fieldtype": "Float", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Starting location from left edge", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "2", + "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": "signatory_position", + "fieldtype": "Section Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Signatory Position", + "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": "signatory_from_top_edge", + "fieldtype": "Float", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Distance from top edge", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "2", + "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": "signatory_from_left_edge", + "fieldtype": "Float", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Starting location from left edge", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "2", + "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": "preview", + "fieldtype": "Section Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Preview", + "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": "cheque_print_preview", + "fieldtype": "HTML", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, "length": 0, "no_copy": 0, "permlevel": 0, @@ -514,8 +744,8 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "max_attachments": 0, - "modified": "2016-05-04 17:07:43.700169", + "max_attachments": 1, + "modified": "2016-05-11 19:50:25.554911", "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 64e47b0b98..0524bf9329 100644 --- a/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py +++ b/erpnext/accounts/doctype/cheque_print_template/cheque_print_template.py @@ -5,6 +5,54 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document +from frappe.utils import flt, cstr class ChequePrintTemplate(Document): - pass + 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 = """ +
+
+ + {{doc.cheque_date or '' }} + + + 1234567890 + + + {{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) + +