Merge pull request #33350 from deepeshgarg007/payment_request_flow
fix: Payment Request flow fixes from Order to Payment Entry
This commit is contained in:
commit
925387550e
@ -1640,7 +1640,7 @@ def get_payment_entry(
|
|||||||
):
|
):
|
||||||
reference_doc = None
|
reference_doc = None
|
||||||
doc = frappe.get_doc(dt, dn)
|
doc = frappe.get_doc(dt, dn)
|
||||||
if dt in ("Sales Order", "Purchase Order") and flt(doc.per_billed, 2) > 0:
|
if dt in ("Sales Order", "Purchase Order") and flt(doc.per_billed, 2) >= 99.99:
|
||||||
frappe.throw(_("Can only make payment against unbilled {0}").format(dt))
|
frappe.throw(_("Can only make payment against unbilled {0}").format(dt))
|
||||||
|
|
||||||
if not party_type:
|
if not party_type:
|
||||||
|
@ -42,7 +42,7 @@ frappe.ui.form.on("Payment Request", "refresh", function(frm) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!frm.doc.payment_gateway_account && frm.doc.status == "Initiated") {
|
if((!frm.doc.payment_gateway_account || frm.doc.payment_request_type == "Outward") && frm.doc.status == "Initiated") {
|
||||||
frm.add_custom_button(__('Create Payment Entry'), function(){
|
frm.add_custom_button(__('Create Payment Entry'), function(){
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.doctype.payment_request.payment_request.make_payment_entry",
|
method: "erpnext.accounts.doctype.payment_request.payment_request.make_payment_entry",
|
||||||
|
@ -261,6 +261,7 @@ class PaymentRequest(Document):
|
|||||||
|
|
||||||
payment_entry.update(
|
payment_entry.update(
|
||||||
{
|
{
|
||||||
|
"mode_of_payment": self.mode_of_payment,
|
||||||
"reference_no": self.name,
|
"reference_no": self.name,
|
||||||
"reference_date": nowdate(),
|
"reference_date": nowdate(),
|
||||||
"remarks": "Payment Entry against {0} {1} via Payment Request {2}".format(
|
"remarks": "Payment Entry against {0} {1} via Payment Request {2}".format(
|
||||||
@ -410,25 +411,22 @@ def make_payment_request(**args):
|
|||||||
else ""
|
else ""
|
||||||
)
|
)
|
||||||
|
|
||||||
existing_payment_request = None
|
draft_payment_request = frappe.db.get_value(
|
||||||
if args.order_type == "Shopping Cart":
|
"Payment Request",
|
||||||
existing_payment_request = frappe.db.get_value(
|
{"reference_doctype": args.dt, "reference_name": args.dn, "docstatus": 0},
|
||||||
"Payment Request",
|
)
|
||||||
{"reference_doctype": args.dt, "reference_name": args.dn, "docstatus": ("!=", 2)},
|
|
||||||
)
|
|
||||||
|
|
||||||
if existing_payment_request:
|
existing_payment_request_amount = get_existing_payment_request_amount(args.dt, args.dn)
|
||||||
|
|
||||||
|
if existing_payment_request_amount:
|
||||||
|
grand_total -= existing_payment_request_amount
|
||||||
|
|
||||||
|
if draft_payment_request:
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
"Payment Request", existing_payment_request, "grand_total", grand_total, update_modified=False
|
"Payment Request", draft_payment_request, "grand_total", grand_total, update_modified=False
|
||||||
)
|
)
|
||||||
pr = frappe.get_doc("Payment Request", existing_payment_request)
|
pr = frappe.get_doc("Payment Request", draft_payment_request)
|
||||||
else:
|
else:
|
||||||
if args.order_type != "Shopping Cart":
|
|
||||||
existing_payment_request_amount = get_existing_payment_request_amount(args.dt, args.dn)
|
|
||||||
|
|
||||||
if existing_payment_request_amount:
|
|
||||||
grand_total -= existing_payment_request_amount
|
|
||||||
|
|
||||||
pr = frappe.new_doc("Payment Request")
|
pr = frappe.new_doc("Payment Request")
|
||||||
pr.update(
|
pr.update(
|
||||||
{
|
{
|
||||||
|
@ -235,11 +235,11 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
|
|||||||
cur_frm.add_custom_button(__('Purchase Invoice'),
|
cur_frm.add_custom_button(__('Purchase Invoice'),
|
||||||
this.make_purchase_invoice, __('Create'));
|
this.make_purchase_invoice, __('Create'));
|
||||||
|
|
||||||
if(flt(doc.per_billed)==0 && doc.status != "Delivered") {
|
if(flt(doc.per_billed) < 100 && doc.status != "Delivered") {
|
||||||
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_payment_entry, __('Create'));
|
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_payment_entry, __('Create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flt(doc.per_billed)==0) {
|
if(flt(doc.per_billed) < 100) {
|
||||||
this.frm.add_custom_button(__('Payment Request'),
|
this.frm.add_custom_button(__('Payment Request'),
|
||||||
function() { me.make_payment_request() }, __('Create'));
|
function() { me.make_payment_request() }, __('Create'));
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
}
|
}
|
||||||
|
|
||||||
make_payment_request() {
|
make_payment_request() {
|
||||||
var me = this;
|
let me = this;
|
||||||
const payment_request_type = (in_list(['Sales Order', 'Sales Invoice'], this.frm.doc.doctype))
|
const payment_request_type = (in_list(['Sales Order', 'Sales Invoice'], this.frm.doc.doctype))
|
||||||
? "Inward" : "Outward";
|
? "Inward" : "Outward";
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(!r.exc){
|
if(!r.exc){
|
||||||
var doc = frappe.model.sync(r.message);
|
frappe.model.sync(r.message);
|
||||||
frappe.set_route("Form", r.message.doctype, r.message.name);
|
frappe.set_route("Form", r.message.doctype, r.message.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user