diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index a0efac5318..a4f8232280 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -37,10 +37,11 @@ class PaymentRequest(Document): self.make_communication_entry() ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name) - if hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart": + if (hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart") \ + or self.flags.mute_email: send_mail = False - if send_mail and not self.flags.mute_email: + if send_mail: self.set_payment_request_url() self.send_email() @@ -50,7 +51,7 @@ class PaymentRequest(Document): def make_invoice(self): ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name) - if hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart": + if (hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart"): from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice si = make_sales_invoice(self.reference_name, ignore_permissions=True) si = si.insert(ignore_permissions=True) @@ -216,12 +217,9 @@ def make_payment_request(**args): """Make payment request""" args = frappe._dict(args) - ref_doc = frappe.get_doc(args.dt, args.dn) - - gateway_account = get_gateway_details(args) or frappe._dict() - grand_total = get_amount(ref_doc, args.dt) + gateway_account = get_gateway_details(args) or frappe._dict() existing_payment_request = frappe.db.get_value("Payment Request", {"reference_doctype": args.dt, "reference_name": args.dn, "docstatus": ["!=", 2]}) @@ -244,22 +242,19 @@ def make_payment_request(**args): "reference_name": args.dn }) - if args.return_doc: - return pr - - if args.mute_email: + if args.order_type == "Shopping Cart" or args.mute_email: pr.flags.mute_email = True if args.submit_doc: pr.insert(ignore_permissions=True) pr.submit() - if hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart": + if args.order_type == "Shopping Cart": frappe.db.commit() frappe.local.response["type"] = "redirect" frappe.local.response["location"] = pr.get_payment_url() - if not args.cart: + if args.return_doc: return pr return pr.as_dict() diff --git a/erpnext/accounts/doctype/payment_request/test_payment_request.py b/erpnext/accounts/doctype/payment_request/test_payment_request.py index 06231ebbd3..8d43950102 100644 --- a/erpnext/accounts/doctype/payment_request/test_payment_request.py +++ b/erpnext/accounts/doctype/payment_request/test_payment_request.py @@ -70,7 +70,7 @@ class TestPaymentRequest(unittest.TestCase): so_inr = make_sales_order(currency="INR") pr = make_payment_request(dt="Sales Order", dn=so_inr.name, recipient_id="saurabh@erpnext.com", - mute_email=1, submit_doc=1) + mute_email=1, submit_doc=1, return_doc=1) pe = pr.set_as_paid() so_inr = frappe.get_doc("Sales Order", so_inr.name) @@ -81,7 +81,7 @@ class TestPaymentRequest(unittest.TestCase): currency="USD", conversion_rate=50) pr = make_payment_request(dt="Sales Invoice", dn=si_usd.name, recipient_id="saurabh@erpnext.com", - mute_email=1, payment_gateway="_Test Gateway - USD", submit_doc=1) + mute_email=1, payment_gateway="_Test Gateway - USD", submit_doc=1, return_doc=1) pe = pr.set_as_paid() diff --git a/erpnext/shopping_cart/product.py b/erpnext/shopping_cart/product.py index 912467ff2a..0d6eccd62b 100644 --- a/erpnext/shopping_cart/product.py +++ b/erpnext/shopping_cart/product.py @@ -46,6 +46,7 @@ def get_product_info(item_code): } def get_qty_in_stock(item_code, template_item_code): + in_stock, stock_qty = 0, '' warehouse = frappe.db.get_value("Item", item_code, "website_warehouse") if not warehouse and template_item_code and template_item_code != item_code: warehouse = frappe.db.get_value("Item", template_item_code, "website_warehouse") @@ -55,8 +56,6 @@ def get_qty_in_stock(item_code, template_item_code): item_code=%s and warehouse=%s""", (item_code, warehouse)) if stock_qty: in_stock = stock_qty[0][0] > 0 and 1 or 0 - else: - in_stock = 0 return frappe._dict({"in_stock": in_stock, "stock_qty": stock_qty}) diff --git a/erpnext/templates/pages/order.html b/erpnext/templates/pages/order.html index 3e4eca3a98..2481808b4f 100644 --- a/erpnext/templates/pages/order.html +++ b/erpnext/templates/pages/order.html @@ -79,7 +79,7 @@ or (doc.doctype=="Sales Invoice" and doc.outstanding_amount > 0) %}

- {{ _("Pay") }} {{ doc.get_formatted("grand_total") }}