There should be a button to check Customer Credit Balance which opens the report in sales and i have to built it inside the doctype of name Order Book.
any idea, how to do it ?
thanks
There should be a button to check Customer Credit Balance which opens the report in sales and i have to built it inside the doctype of name Order Book.
any idea, how to do it ?
thanks
Try this on order book js
frm.add_custom_button(__(āCustomer Credit Balanceā), function() {
frappe.set_route(āFormā,āReportā,āCustomer Credit Balanceā);
})
Hi ,
While solution given is perfect and you may implement it , However , I am keen to know what is the use case ? Do you want to restrict or allow booking of orders when the customer credit balance is not adequate ? If you want to allow the order booking to continue even when credit limit is breached , there is an option at customer master "
Bypass credit limit check at Sales Order" , you may safely use this , If you want to allow order booking even when credit limit is in sufficient but with an approval then you will need to configure erpnext accordingly, Please let me know your use case for further discussions
Rgds
O
this opens the report and then i have to click on the show report inorder to get the balance, after that i have to choose the customer.
what i want is that it should automatically generate it based on the current customer(customer is a field in the doctype).
nothing of that sort. no such conditons applicable as now. just want the customer credit balance.
If you just want to see the outstanding balance of the customer while creating sales order/invoice, then create a custom field āoutstanding balanceā and use the following custom script:
customer: function(frm) {
frappe.call({
method: āerpnext.accounts.utils.get_balance_onā,
args: {date: frm.doc.posting_date, party_type: āCustomerā, party: frm.doc.customer},
callback: function(r) {
frm.doc.outstanding_balance = format_currency(r.message, erpnext.get_currency(frm.doc.company));
refresh_field(āoutstanding_balanceā, āaccountsā);
}
});
THis will autopopulate outstanding balance for the selected customer.
Try this
frm.add_custom_button(__(āCustomer Credit Balanceā), function() {
frappe.set_route(āquery-reportā, ā Customer Credit Balanceā,
{Customer:frm.doc.name});
});
my client needs a button for it.
so that on clicking the button the customer credit balance report opens in sales for the customer which was selected in the field.
@Nakul_Sharma - thanks for sharing the script. This indeed useful.
If itās not too much trouble, may you repost the script as I think it did not paste the right way.
If you check , you will see your script has this āĀ®ā
Here is the script
customer: function(frm) {
frappe.call({
method: "erpnext.accounts.utils.get_balance_on",
args: {date: frm.doc.posting_date, party_type: 'Customer', party: frm.doc.customer},
callback: function(r) {
frm.doc.outstanding_balance = format_currency(r.message, erpnext.get_currency(frm.doc.company));
refresh_field('outstanding_balance', 'accounts');
}
});
This code only fetches the outstanding balance after the document has been saved.
My use case is as below.
Can you help on this?
Hello,
thanks for your sharing.
How could I get it printed in the invoice?
Thanks