feat: page break in SoA pdf
This commit is contained in:
parent
38b34f2a45
commit
2665d7d293
@ -9,6 +9,7 @@ frappe.ui.form.on('Process Statement Of Accounts', {
|
|||||||
refresh: function(frm){
|
refresh: function(frm){
|
||||||
if(!frm.doc.__islocal) {
|
if(!frm.doc.__islocal) {
|
||||||
frm.add_custom_button(__('Send Emails'), function(){
|
frm.add_custom_button(__('Send Emails'), function(){
|
||||||
|
if (frm.is_dirty()) frappe.throw(__("Please save before proceeding."))
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.send_emails",
|
method: "erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.send_emails",
|
||||||
args: {
|
args: {
|
||||||
@ -25,7 +26,8 @@ frappe.ui.form.on('Process Statement Of Accounts', {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
frm.add_custom_button(__('Download'), function(){
|
frm.add_custom_button(__('Download'), function(){
|
||||||
var url = frappe.urllib.get_full_url(
|
if (frm.is_dirty()) frappe.throw(__("Please save before proceeding."))
|
||||||
|
let url = frappe.urllib.get_full_url(
|
||||||
'/api/method/erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.download_statements?'
|
'/api/method/erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.download_statements?'
|
||||||
+ 'document_name='+encodeURIComponent(frm.doc.name))
|
+ 'document_name='+encodeURIComponent(frm.doc.name))
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
"customers",
|
"customers",
|
||||||
"preferences",
|
"preferences",
|
||||||
"orientation",
|
"orientation",
|
||||||
|
"include_break",
|
||||||
"include_ageing",
|
"include_ageing",
|
||||||
"ageing_based_on",
|
"ageing_based_on",
|
||||||
"section_break_14",
|
"section_break_14",
|
||||||
@ -284,10 +285,16 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Terms and Conditions",
|
"label": "Terms and Conditions",
|
||||||
"options": "Terms and Conditions"
|
"options": "Terms and Conditions"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "include_break",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Page Break After Each SoA"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-09-06 21:00:45.732505",
|
"modified": "2022-10-17 17:47:08.662475",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Process Statement Of Accounts",
|
"name": "Process Statement Of Accounts",
|
||||||
@ -321,5 +328,6 @@
|
|||||||
],
|
],
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
|
"states": [],
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
@ -128,7 +128,8 @@ def get_report_pdf(doc, consolidated=True):
|
|||||||
if not bool(statement_dict):
|
if not bool(statement_dict):
|
||||||
return False
|
return False
|
||||||
elif consolidated:
|
elif consolidated:
|
||||||
result = "".join(list(statement_dict.values()))
|
delimiter = '<div style="page-break-before: always;"></div>' if doc.include_break else ""
|
||||||
|
result = delimiter.join(list(statement_dict.values()))
|
||||||
return get_pdf(result, {"orientation": doc.orientation})
|
return get_pdf(result, {"orientation": doc.orientation})
|
||||||
else:
|
else:
|
||||||
for customer, statement_html in statement_dict.items():
|
for customer, statement_html in statement_dict.items():
|
||||||
@ -240,8 +241,8 @@ def fetch_customers(customer_collection, collection_name, primary_mandatory):
|
|||||||
if int(primary_mandatory):
|
if int(primary_mandatory):
|
||||||
if primary_email == "":
|
if primary_email == "":
|
||||||
continue
|
continue
|
||||||
elif (billing_email == "") and (primary_email == ""):
|
# elif (billing_email == "") and (primary_email == ""):
|
||||||
continue
|
# continue
|
||||||
|
|
||||||
customer_list.append(
|
customer_list.append(
|
||||||
{"name": customer.name, "primary_email": primary_email, "billing_email": billing_email}
|
{"name": customer.name, "primary_email": primary_email, "billing_email": billing_email}
|
||||||
@ -313,6 +314,8 @@ def send_emails(document_name, from_scheduler=False):
|
|||||||
attachments = [{"fname": customer + ".pdf", "fcontent": report_pdf}]
|
attachments = [{"fname": customer + ".pdf", "fcontent": report_pdf}]
|
||||||
|
|
||||||
recipients, cc = get_recipients_and_cc(customer, doc)
|
recipients, cc = get_recipients_and_cc(customer, doc)
|
||||||
|
if not recipients:
|
||||||
|
continue
|
||||||
context = get_context(customer, doc)
|
context = get_context(customer, doc)
|
||||||
subject = frappe.render_template(doc.subject, context)
|
subject = frappe.render_template(doc.subject, context)
|
||||||
message = frappe.render_template(doc.body, context)
|
message = frappe.render_template(doc.body, context)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user