[fix] Condition for Payment and Return button visibility

This commit is contained in:
Nabin Hait 2016-02-22 16:16:58 +05:30
parent 68eb689450
commit db746f5bc7
2 changed files with 11 additions and 7 deletions

View File

@ -24,11 +24,13 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
if(!doc.is_return) {
if(doc.docstatus==1) {
if(doc.outstanding_amount != 0) {
if(doc.outstanding_amount < 0) {
this.frm.add_custom_button(__('Payment'), this.make_bank_entry, __("Make"));
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
}
cur_frm.add_custom_button(__('Debit Note'), this.make_debit_note, __("Make"));
if(Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) {
cur_frm.add_custom_button(__('Debit Note'), this.make_debit_note, __("Make"));
}
}
if(doc.docstatus===0) {

View File

@ -57,10 +57,12 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
return item.is_delivered_by_supplier ? true : false;
})
cur_frm.add_custom_button(doc.update_stock ? __('Sales Return') : __('Credit Note'),
this.make_sales_return, __("Make"));
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
if(Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) {
cur_frm.add_custom_button(doc.update_stock ? __('Sales Return') : __('Credit Note'),
this.make_sales_return, __("Make"));
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
}
if(cint(doc.update_stock)!=1) {
// show Make Delivery Note button only if Sales Invoice is not created from Delivery Note
var from_delivery_note = false;
@ -75,7 +77,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
}
}
if(doc.outstanding_amount!=0 && !cint(doc.is_return)) {
if(doc.outstanding_amount>0 && !cint(doc.is_return)) {
cur_frm.add_custom_button(__('Payment Request'), this.make_payment_request, __("Make"));
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry, __("Make"));
}