[portal] [minor] show status for order and invoice
This commit is contained in:
parent
8a4b21ab8e
commit
1be5bb7e6a
@ -1 +1,5 @@
|
||||
{% extends "app/portal/templates/sale.html" %}
|
||||
{% extends "app/portal/templates/sale.html" %}
|
||||
|
||||
{% block status -%}
|
||||
{% if doc.status %}{{ doc.status }}{% endif %}
|
||||
{%- endblock %}
|
@ -3,14 +3,28 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
from webnotes.utils import flt, fmt_money
|
||||
|
||||
no_cache = True
|
||||
|
||||
def get_context():
|
||||
from portal.utils import get_transaction_context
|
||||
context = get_transaction_context("Sales Invoice", webnotes.form_dict.name)
|
||||
modify_status(context.get("doc"))
|
||||
context.update({
|
||||
"parent_link": "invoices",
|
||||
"parent_title": "Invoices"
|
||||
})
|
||||
return context
|
||||
return context
|
||||
|
||||
def modify_status(doc):
|
||||
doc.status = ""
|
||||
if flt(doc.outstanding_amount):
|
||||
doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
|
||||
("label-warning", "icon-exclamation-sign",
|
||||
_("To Pay") + " = " + fmt_money(doc.outstanding_amount, currency=doc.currency))
|
||||
else:
|
||||
doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
|
||||
("label-success", "icon-ok", _("Paid"))
|
||||
|
@ -11,7 +11,7 @@ def get_context():
|
||||
context = get_currency_context()
|
||||
context.update({
|
||||
"title": "Invoices",
|
||||
"method": "portal.templates.pages.invoices.get_invoices",
|
||||
"method": "accounts.doctype.sales_invoice.templates.pages.invoices.get_invoices",
|
||||
"icon": "icon-file-text",
|
||||
"empty_list_message": "No Invoices Found",
|
||||
"page": "invoice"
|
||||
@ -21,4 +21,8 @@ def get_context():
|
||||
@webnotes.whitelist()
|
||||
def get_invoices(start=0):
|
||||
from portal.utils import get_transaction_list
|
||||
return get_transaction_list("Sales Invoice", start)
|
||||
from accounts.doctype.sales_invoice.templates.pages.invoice import modify_status
|
||||
invoices = get_transaction_list("Sales Invoice", start, ["outstanding_amount"])
|
||||
for d in invoices:
|
||||
modify_status(d)
|
||||
return invoices
|
@ -17,7 +17,7 @@
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
{% if doc.status -%}<div class="label label-default">{{ doc.status }}</div>{%- endif %}
|
||||
{% block status -%}{%- endblock %}
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<span class="pull-right">{{ utils.formatdate(doc.posting_date or doc.transaction_date) }}</span>
|
||||
|
@ -12,12 +12,14 @@
|
||||
<script>
|
||||
var render = function(doc) {
|
||||
doc.grand_total_export = format_currency(doc.grand_total_export, doc.currency);
|
||||
|
||||
if(!doc.status) doc.status = "";
|
||||
|
||||
$(repl('<a href="{{ page }}?name=%(name)s" class="list-group-item">\
|
||||
<div class="row">\
|
||||
<div class="col-md-6">\
|
||||
<div class="row col-md-12">%(name)s</div>\
|
||||
<div class="row col-md-12 text-muted">%(items)s...</div>\
|
||||
<div class="row col-md-12 text-muted">%(items)s</div>\
|
||||
<div class="row col-md-12">%(status)s</div>\
|
||||
</div>\
|
||||
<div class="col-md-3 text-right">%(grand_total_export)s</div>\
|
||||
<div class="col-md-3 text-right text-muted">%(creation)s</div>\
|
||||
|
@ -6,19 +6,27 @@ import webnotes
|
||||
from webnotes.utils import cint, formatdate
|
||||
import json
|
||||
|
||||
def get_transaction_list(doctype, start):
|
||||
def get_transaction_list(doctype, start, additional_fields=None):
|
||||
# find customer id
|
||||
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
|
||||
"customer")
|
||||
|
||||
|
||||
if customer:
|
||||
transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export
|
||||
if additional_fields:
|
||||
additional_fields = ", " + ", ".join(("`%s`" % f for f in additional_fields))
|
||||
else:
|
||||
additional_fields = ""
|
||||
|
||||
transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export
|
||||
%s
|
||||
from `tab%s` where customer=%s and docstatus=1
|
||||
order by creation desc
|
||||
limit %s, 20""" % (doctype, "%s", "%s"), (customer, cint(start)), as_dict=True)
|
||||
limit %s, 20""" % (additional_fields, doctype, "%s", "%s"),
|
||||
(customer, cint(start)), as_dict=True)
|
||||
for doc in transactions:
|
||||
doc.items = ", ".join(webnotes.conn.sql_list("""select item_name
|
||||
from `tab%s Item` where parent=%s limit 5""" % (doctype, "%s"), doc.name))
|
||||
items = webnotes.conn.sql_list("""select item_name
|
||||
from `tab%s Item` where parent=%s limit 6""" % (doctype, "%s"), doc.name)
|
||||
doc.items = ", ".join(items[:5]) + ("..." if (len(items) > 5) else "")
|
||||
doc.creation = formatdate(doc.creation)
|
||||
return transactions
|
||||
else:
|
||||
|
@ -1 +1,5 @@
|
||||
{% extends "app/portal/templates/sale.html" %}
|
||||
{% extends "app/portal/templates/sale.html" %}
|
||||
|
||||
{% block status -%}
|
||||
{% if doc.status %}{{ doc.status }}{% endif %}
|
||||
{%- endblock %}
|
@ -3,14 +3,30 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
|
||||
no_cache = True
|
||||
|
||||
def get_context():
|
||||
from portal.utils import get_transaction_context
|
||||
context = get_transaction_context("Sales Order", webnotes.form_dict.name)
|
||||
modify_status(context.get("doc"))
|
||||
context.update({
|
||||
"parent_link": "orders",
|
||||
"parent_title": "My Orders"
|
||||
})
|
||||
return context
|
||||
return context
|
||||
|
||||
def modify_status(doc):
|
||||
doc.status = []
|
||||
if 0 < doc.per_billed < 100:
|
||||
doc.status.append(("label-warning", "icon-ok", _("Partially Billed")))
|
||||
elif doc.per_billed == 100:
|
||||
doc.status.append(("label-success", "icon-ok", _("Billed")))
|
||||
|
||||
if 0 < doc.per_delivered < 100:
|
||||
doc.status.append(("label-warning", "icon-truck", _("Partially Delivered")))
|
||||
elif doc.per_delivered == 100:
|
||||
doc.status.append(("label-success", "icon-truck", _("Delivered")))
|
||||
doc.status = " " + " ".join(('<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % s
|
||||
for s in doc.status))
|
||||
|
@ -11,7 +11,7 @@ def get_context():
|
||||
context = get_currency_context()
|
||||
context.update({
|
||||
"title": "My Orders",
|
||||
"method": "portal.templates.pages.orders.get_orders",
|
||||
"method": "selling.doctype.sales_order.templates.pages.orders.get_orders",
|
||||
"icon": "icon-list",
|
||||
"empty_list_message": "No Orders Yet",
|
||||
"page": "order",
|
||||
@ -21,5 +21,10 @@ def get_context():
|
||||
@webnotes.whitelist()
|
||||
def get_orders(start=0):
|
||||
from portal.utils import get_transaction_list
|
||||
return get_transaction_list("Sales Order", start)
|
||||
from selling.doctype.sales_order.templates.pages.order import modify_status
|
||||
orders = get_transaction_list("Sales Order", start, ["per_billed", "per_delivered"])
|
||||
for d in orders:
|
||||
modify_status(d)
|
||||
|
||||
return orders
|
||||
|
Loading…
Reference in New Issue
Block a user