[enhance] i. facility to send PR email; ii. update cart, item view and order view;
This commit is contained in:
parent
a940b6d149
commit
df2783dbb0
@ -3,11 +3,30 @@ cur_frm.add_fetch("payment_gateway", "gateway", "gateway")
|
||||
cur_frm.add_fetch("payment_gateway", "message", "message")
|
||||
|
||||
frappe.ui.form.on("Payment Request", "onload", function(frm, dt, dn){
|
||||
frappe.call({
|
||||
method:"erpnext.accounts.doctype.payment_request.payment_request.get_print_format_list",
|
||||
args: {"ref_doctype": frm.doc.reference_doctype},
|
||||
callback:function(r){
|
||||
set_field_options("print_format", r.message["print_format"])
|
||||
}
|
||||
if (frm.doc.reference_doctype) {
|
||||
frappe.call({
|
||||
method:"erpnext.accounts.doctype.payment_request.payment_request.get_print_format_list",
|
||||
args: {"ref_doctype": frm.doc.reference_doctype},
|
||||
callback:function(r){
|
||||
set_field_options("print_format", r.message["print_format"])
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
frappe.ui.form.on("Payment Request", "refresh", function(frm) {
|
||||
frm.add_custom_button(__('Resend Payment Email'), function(){
|
||||
frappe.call({
|
||||
method:"erpnext.accounts.doctype.payment_request.payment_request.resend_payment_email",
|
||||
args: {"docname": frm.doc.name},
|
||||
freeze: true,
|
||||
freeze_message: __("Sending"),
|
||||
callback:function(r){
|
||||
if(!r.exc) {
|
||||
frappe.msgprint(__("Message Sent"))
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -37,18 +37,17 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Link",
|
||||
"fieldname": "amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Currency",
|
||||
"label": "Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Currency",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"precision": "2",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
@ -62,17 +61,18 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "amount",
|
||||
"fieldtype": "Currency",
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Amount",
|
||||
"label": "Currency",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Currency",
|
||||
"permlevel": 0,
|
||||
"precision": "2",
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
@ -130,6 +130,55 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"default": "Draft",
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Status",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "\nDraft\nInitiated\nPaid\nFailed\nCancelled",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "section_break_7",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
@ -155,6 +204,29 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "column_break_9",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
@ -205,32 +277,6 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"default": "",
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Status",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "\nInitiated\nPaid\nFailed\nCancelled",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
@ -383,7 +429,7 @@
|
||||
"collapsible": 0,
|
||||
"fieldname": "payment_url",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
@ -509,7 +555,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2015-12-30 17:43:10.626907",
|
||||
"modified": "2016-01-06 03:53:19.686537",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Payment Request",
|
||||
|
@ -15,6 +15,7 @@ from itertools import chain
|
||||
|
||||
class PaymentRequest(Document):
|
||||
def validate(self):
|
||||
self.validate_payment_gateway_account()
|
||||
self.validate_payment_request()
|
||||
self.validate_currency()
|
||||
|
||||
@ -27,6 +28,17 @@ class PaymentRequest(Document):
|
||||
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
|
||||
if ref_doc.currency != frappe.db.get_value("Account", self.payment_account, "account_currency"):
|
||||
frappe.throw(_("Transaction currency is not similar to Gateway Currency"))
|
||||
|
||||
def validate_payment_gateway_account(self):
|
||||
if not self.payment_gateway:
|
||||
frappe.throw(_("Payment Gateway Account is not configured"))
|
||||
|
||||
def validate_payment_gateway(self):
|
||||
if self.gateway == "PayPal":
|
||||
if not frappe.db.get_value("PayPal Settings", None, "api_username"):
|
||||
if not frappe.conf.paypal_username:
|
||||
frappe.throw(_("PayPal Settings missing"))
|
||||
|
||||
|
||||
def on_submit(self):
|
||||
if not self.mute_email:
|
||||
@ -36,8 +48,8 @@ class PaymentRequest(Document):
|
||||
self.make_communication_entry()
|
||||
|
||||
def on_cancel(self):
|
||||
pass
|
||||
|
||||
self.set_cancelled()
|
||||
|
||||
def on_update_after_submit(self):
|
||||
pass
|
||||
|
||||
@ -127,20 +139,20 @@ def make_payment_request(**args):
|
||||
|
||||
args = frappe._dict(args)
|
||||
ref_doc = get_reference_doc_details(args.dt, args.dn)
|
||||
name, gateway, payment_account, message = get_gateway_details(args)
|
||||
gateway_account = get_gateway_details(args)
|
||||
|
||||
pr = frappe.new_doc("Payment Request")
|
||||
pr.update({
|
||||
"payment_gateway": name,
|
||||
"gateway": gateway,
|
||||
"payment_account": payment_account,
|
||||
"payment_gateway": gateway_account.name,
|
||||
"gateway": gateway_account.gateway,
|
||||
"payment_account": gateway_account.payment_account,
|
||||
"currency": ref_doc.currency,
|
||||
"make_sales_invoice": args.cart or 0,
|
||||
"amount": get_amount(ref_doc, args.dt),
|
||||
"mute_email": args.mute_email or 0,
|
||||
"email_to": args.recipient_id or "",
|
||||
"subject": "Payment Request for %s"%args.dn,
|
||||
"message": message,
|
||||
"message": gateway_account.message,
|
||||
"reference_doctype": args.dt,
|
||||
"reference_name": args.dn
|
||||
})
|
||||
@ -181,11 +193,16 @@ def get_amount(ref_doc, dt):
|
||||
def get_gateway_details(args):
|
||||
"""return gateway and payment account of default payment gateway"""
|
||||
if args.payemnt_gateway:
|
||||
return frappe.db.get_value("Payment Gateway Account", args.payemnt_gateway,
|
||||
["name", "gateway", "payment_account", "message"])
|
||||
|
||||
return frappe.db.get_value("Payment Gateway Account", {"is_default": 1},
|
||||
["name", "gateway", "payment_account", "message"])
|
||||
gateway_account = frappe.db.get_value("Payment Gateway Account", args.payemnt_gateway,
|
||||
["name", "gateway", "payment_account", "message"], as_dict=1)
|
||||
|
||||
gateway_account = frappe.db.get_value("Payment Gateway Account", {"is_default": 1},
|
||||
["name", "gateway", "payment_account", "message"], as_dict=1)
|
||||
|
||||
if not gateway_account:
|
||||
frappe.throw(_("Payment Gateway Account is not configured"))
|
||||
|
||||
return gateway_account
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_print_format_list(ref_doctype):
|
||||
@ -213,4 +230,8 @@ def generate_payment_request(name):
|
||||
frappe.respond_as_web_page(_("Invalid Payment Request"),
|
||||
_("Payment Request has been canceled by vendor"), success=False,
|
||||
http_status_code=frappe.ValidationError.http_status_code)
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def resend_payment_email(docname):
|
||||
return frappe.get_doc("Payment Request", docname).send_email()
|
||||
|
@ -0,0 +1,17 @@
|
||||
frappe.listview_settings['Payment Request'] = {
|
||||
add_fields: ["status"],
|
||||
get_indicator: function(doc) {
|
||||
if(doc.status == "Draft") {
|
||||
return [__("Draft"), "darkgrey", "status,=,Draft"];
|
||||
}
|
||||
else if(doc.status == "Initiated") {
|
||||
return [__("Initiated"), "green", "status,=,Initiated"];
|
||||
}
|
||||
else if(doc.status == "Paid") {
|
||||
return [__("Paid"), "blue", "status,=,Paid"];
|
||||
}
|
||||
else if(doc.status == "Cancelled") {
|
||||
return [__("Cancelled"), "orange", "status,=,Cancelled"];
|
||||
}
|
||||
}
|
||||
}
|
@ -44,13 +44,22 @@ $.extend(shopping_cart, {
|
||||
|
||||
set_cart_count: function() {
|
||||
var cart_count = getCookie("cart_count");
|
||||
var $cart = $('.dropdown [data-label="Cart"]');
|
||||
var $badge = $cart.find(".badge");
|
||||
var $cart = $('.cart-icon');
|
||||
var $badge = $cart.find("#cart-count");
|
||||
|
||||
if(cart_count === "0") {
|
||||
$cart.css("display", "none");
|
||||
}
|
||||
else {
|
||||
$cart.css("display", "inline");
|
||||
}
|
||||
|
||||
|
||||
if(cart_count) {
|
||||
if($badge.length === 0) {
|
||||
var $badge = $('<span class="badge pull-right"></span>')
|
||||
.prependTo($cart.find("a").addClass("badge-hover"));
|
||||
}
|
||||
// if($badge.length === 0) {
|
||||
// var $badge = $('<span class="badge"></span>')
|
||||
// .appendTo($cart.find("a").addClass("badge-hover"));
|
||||
// }
|
||||
$badge.html(cart_count);
|
||||
} else {
|
||||
$badge.remove();
|
||||
|
@ -41,46 +41,47 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
||||
}
|
||||
}
|
||||
|
||||
// material request
|
||||
if(!doc.order_type || ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1
|
||||
&& flt(doc.per_delivered, 2) < 100) {
|
||||
cur_frm.add_custom_button(__('Material Request'), this.make_material_request);
|
||||
}
|
||||
|
||||
// make purchase order
|
||||
if(flt(doc.per_delivered, 2) < 100 && allow_purchase) {
|
||||
cur_frm.add_custom_button(__('Purchase Order'), cur_frm.cscript.make_purchase_order);
|
||||
}
|
||||
|
||||
if(flt(doc.per_billed)==0) {
|
||||
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry);
|
||||
cur_frm.add_custom_button(__('Make Payment Request'), this.make_payment_request);
|
||||
}
|
||||
|
||||
if (this.frm.has_perm("submit")) {
|
||||
// stop
|
||||
if(flt(doc.per_delivered, 2) < 100 || flt(doc.per_billed) < 100) {
|
||||
cur_frm.add_custom_button(__('Stop'), this.stop_sales_order)
|
||||
cur_frm.add_custom_button(__('Stop'), this.stop_sales_order, __("Status"))
|
||||
}
|
||||
|
||||
|
||||
cur_frm.add_custom_button(__('Close'), this.close_sales_order)
|
||||
}
|
||||
|
||||
// maintenance
|
||||
if(flt(doc.per_delivered, 2) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)===-1) {
|
||||
cur_frm.add_custom_button(__('Maint. Visit'), this.make_maintenance_visit);
|
||||
cur_frm.add_custom_button(__('Maint. Schedule'), this.make_maintenance_schedule);
|
||||
cur_frm.add_custom_button(__('Close'), this.close_sales_order, __("Status"))
|
||||
}
|
||||
|
||||
// delivery note
|
||||
if(flt(doc.per_delivered, 2) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && allow_delivery) {
|
||||
cur_frm.add_custom_button(__('Delivery'), this.make_delivery_note).addClass("btn-primary");
|
||||
cur_frm.add_custom_button(__('Delivery'), this.make_delivery_note, __("Make"));
|
||||
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
||||
}
|
||||
|
||||
// sales invoice
|
||||
if(flt(doc.per_billed, 2) < 100) {
|
||||
cur_frm.add_custom_button(__('Invoice'), this.make_sales_invoice).addClass("btn-primary");
|
||||
cur_frm.add_custom_button(__('Invoice'), this.make_sales_invoice, __("Make"));
|
||||
}
|
||||
|
||||
// material request
|
||||
if(!doc.order_type || ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1
|
||||
&& flt(doc.per_delivered, 2) < 100) {
|
||||
cur_frm.add_custom_button(__('Material Request'), this.make_material_request, __("Make"));
|
||||
}
|
||||
|
||||
// make purchase order
|
||||
if(flt(doc.per_delivered, 2) < 100 && allow_purchase) {
|
||||
cur_frm.add_custom_button(__('Purchase Order'), cur_frm.cscript.make_purchase_order, __("Make"));
|
||||
}
|
||||
|
||||
if(flt(doc.per_billed)==0) {
|
||||
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"));
|
||||
}
|
||||
|
||||
// maintenance
|
||||
if(flt(doc.per_delivered, 2) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)===-1) {
|
||||
cur_frm.add_custom_button(__('Maintenance Visit'), this.make_maintenance_visit, __("Make"));
|
||||
cur_frm.add_custom_button(__('Maintenance Schedule'), this.make_maintenance_schedule, __("Make"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -288,11 +288,26 @@ class SalesOrder(SellingController):
|
||||
|
||||
frappe.db.set_value("Sales Order", self.name, "per_delivered", flt(delivered_qty/tot_qty) * 100,
|
||||
update_modified=False)
|
||||
|
||||
def set_indicator(self):
|
||||
"""Set indicator for portal"""
|
||||
if self.per_billed < 100 and self.per_delivered < 100:
|
||||
self.indicator_color = "orange"
|
||||
self.indicator_title = _("Not Paid and Not Delivered")
|
||||
|
||||
elif self.per_billed == 100 and self.per_delivered < 100:
|
||||
self.indicator_color = "orange"
|
||||
self.indicator_title = _("Paid and Not Delivered")
|
||||
|
||||
else:
|
||||
self.indicator_color = "green"
|
||||
self.indicator_title = _("Paid")
|
||||
|
||||
def get_list_context(context=None):
|
||||
from erpnext.controllers.website_list_for_contact import get_list_context
|
||||
list_context = get_list_context(context)
|
||||
list_context["title"] = _("My Orders")
|
||||
list_context["parents"] = [{"title": _("My Account"), "name": "me"}]
|
||||
return list_context
|
||||
|
||||
@frappe.whitelist()
|
||||
|
@ -28,12 +28,12 @@ def update_website_context(context):
|
||||
cart_enabled = is_cart_enabled()
|
||||
context["shopping_cart_enabled"] = cart_enabled
|
||||
|
||||
if cart_enabled:
|
||||
post_login = [
|
||||
{"label": _("Cart"), "url": "cart", "class": "cart-count"},
|
||||
{"class": "divider"}
|
||||
]
|
||||
context["post_login"] = post_login + context.get("post_login", [])
|
||||
# if cart_enabled:
|
||||
# post_login = [
|
||||
# {"label": _("Cart"), "url": "cart", "class": "cart-count"},
|
||||
# {"class": "divider"}
|
||||
# ]
|
||||
# context["post_login"] = post_login + context.get("post_login", [])
|
||||
|
||||
def update_my_account_context(context):
|
||||
if is_cart_enabled():
|
||||
|
@ -71,18 +71,8 @@
|
||||
style="display: none;
|
||||
padding-left: 0px; padding-right: 0px;
|
||||
padding-top: 10px;">
|
||||
<div>
|
||||
<input class="form-control"
|
||||
type="text" style="max-width: 140px;">
|
||||
</div>
|
||||
<div style="margin-top: 10px;">
|
||||
<button class="btn btn-default btn-sm">
|
||||
{{ _("Update") }}</button>
|
||||
</div>
|
||||
<div style="margin-top: 5px;">
|
||||
<a href="/cart" class="text-muted small">
|
||||
{{ _("View Cart") }}</a>
|
||||
</div>
|
||||
<div class="btn btn-success">
|
||||
{{ _("Item added to cart") }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,12 +1,14 @@
|
||||
{% extends "templates/web.html" %}
|
||||
|
||||
{% block header %}
|
||||
<h1>
|
||||
{{ doc.name }}
|
||||
</h1>
|
||||
<h1>{{ doc.name }}</h1>
|
||||
<!-- <h6 class="text-muted">{{ doc._title or doc.doctype }}</h6> -->
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{% include "templates/includes/breadcrumbs.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block style %}
|
||||
<style>
|
||||
{% include "templates/includes/order/order.css" %}
|
||||
@ -22,12 +24,6 @@
|
||||
<span class="indicator {{ doc.indicator_color or "darkgrey" }}">
|
||||
{{ doc.indicator_title or doc.status or "Submitted" }}
|
||||
</span>
|
||||
{% if doc.base_net_total == doc.advance_paid and payment_ref%}
|
||||
<div>
|
||||
<span class="indicator green" data-toggle="tooltip" title=" Reference Id: {{payment_ref}}"> Paid</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<div class="col-xs-6 text-muted text-right h6">
|
||||
{{ doc.get_formatted("transaction_date") }}
|
||||
@ -87,7 +83,8 @@
|
||||
<div class="cart-taxes row small">
|
||||
<div class="col-sm-8"><!-- empty --></div>
|
||||
<div class="col-sm-4">
|
||||
{% if doc.per_billed <= 0 %}
|
||||
{% if (doc.doctype=="Sales Order" and doc.per_billed <= 0)
|
||||
or (doc.doctype=="Sales Invoice" and doc.outstanding_amount > 0) %}
|
||||
<div class="page-header-actions-block" data-html-block="header-actions">
|
||||
<p>
|
||||
<a href="/api/method/erpnext.accounts.doctype.payment_request.payment_request.make_payment_request?dn={{ doc.name }}&dt={{ doc.doctype }}&submit_doc=1&mute_email=1&cart=1"
|
||||
|
Loading…
x
Reference in New Issue
Block a user