You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frappe.ui.form.on('Project',{refresh(frm){if(frm.doc.expected_end_date==frappe.datetime.now_date())frm.set_intro("<b>End date has arrived</b>","red")elsefrm.set_intro("Take it east","green")}})
Customer SI Client Script
frappe.ui.form.on('Customer',{refresh: function(frm){letparams={'customer': frm.doc.name}frappe.call('customer_sales_invoice_details',params).then((r)=>{letsi=r.message;letname=si.name;letamount=si.grand_total;letsize=name.length;if(size>0){// Set up the desired HTML content with a table and bordersvarhtmlContent='<table style="border-collapse: collapse; width: 100%;">';htmlContent+='<thead>';htmlContent+='<tr>';htmlContent+='<th style="border: 1px solid #ddd; padding: 8px;">Sales Invoice</th>';htmlContent+='<th style="border: 1px solid #ddd; padding: 8px;">Amount</th>';htmlContent+='</tr>';htmlContent+='</thead>';htmlContent+='<tbody>';for(leti=0;i<size;i++){if(!frm.is_new()){htmlContent+='<tr>';htmlContent+='<td style="border: 1px solid #ddd; padding: 8px;">'+name[i]+'</td>';htmlContent+='<td style="border: 1px solid #ddd; padding: 8px;">'+amount[i]+'</td>';htmlContent+='</tr>';}}htmlContent+='</tbody>';htmlContent+='</table>';frm.dashboard.add_section(htmlContent,"Open Sales Invoices");}})}});
Automatic Payment Req creation Server Script
text="This is a payment request created against Sales Invoice: "+doc.name+" for an amount of "+str(doc.grand_total) +" ."ifdoc.custom_payment_request==1:
new_doc=frappe.get_doc({
'doctype':'Payment Request',
'party_type': 'Customer',
'party': doc.customer,
'reference_doctype': 'Sales Invoice',
'reference_name': doc.name,
'subject': text
})
new_doc.insert()
frappe.msgprint(
msg=f'New <a href=" https://tesla-india.frappe.cloud/app/payment-request/{new_doc.name}"> Payment Request </a> has been created',
title='Amazing work!',
indicator='orange'
)
Unpaid SI Server Script (API Type)
customer=frappe.form_dict.get('customer')
a= []
b= []
unpaid_si=frappe.get_all('Sales Invoice', filters={'customer':customer,'status':'Overdue'})
#a = [frappe.get_doc('Sales Invoice', i).name for i in unpaid_si]a= [frappe.get_doc('Sales Invoice', i).nameforiinunpaid_si]
b= [frappe.get_doc('Sales Invoice', i).grand_totalforiinunpaid_si]
result= {
"name":a,
"grand_total":b
}
frappe.response.message=result