mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
Merge pull request #32620 from rtdany10/psa_pdf_issue
feat: page break in SoA pdf
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import copy
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from frappe.desk.reportview import get_match_cond
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import add_days, add_months, format_date, getdate, today
|
from frappe.utils import add_days, add_months, format_date, getdate, today
|
||||||
from frappe.utils.jinja import validate_template
|
from frappe.utils.jinja import validate_template
|
||||||
@@ -128,7 +129,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 +242,6 @@ 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 == ""):
|
|
||||||
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}
|
||||||
@@ -273,8 +273,12 @@ def get_customer_emails(customer_name, primary_mandatory, billing_and_primary=Tr
|
|||||||
link.link_doctype='Customer'
|
link.link_doctype='Customer'
|
||||||
and link.link_name=%s
|
and link.link_name=%s
|
||||||
and contact.is_billing_contact=1
|
and contact.is_billing_contact=1
|
||||||
|
{mcond}
|
||||||
ORDER BY
|
ORDER BY
|
||||||
contact.creation desc""",
|
contact.creation desc
|
||||||
|
""".format(
|
||||||
|
mcond=get_match_cond("Contact")
|
||||||
|
),
|
||||||
customer_name,
|
customer_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -313,6 +317,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)
|
||||||
|
|||||||
Reference in New Issue
Block a user