diff --git a/config.json b/config.json index 5412b017b24..f9c71b4b19d 100644 --- a/config.json +++ b/config.json @@ -106,8 +106,13 @@ }, "orders": { "no_cache": true, - "template": "app/website/templates/pages/orders", - "args_method": "selling.doctype.sales_order.sales_order.get_currency_and_number_format" + "template": "app/website/templates/pages/transaction_list", + "args_method": "website.helpers.transaction.order_list_args" + }, + "invoices": { + "no_cache": true, + "template": "app/website/templates/pages/transaction_list", + "args_method": "website.helpers.transaction.invoice_list_args" }, "product_search": { "template": "app/website/templates/pages/product_search" diff --git a/public/build.json b/public/build.json index 24abde20b2b..b8d7dd44525 100644 --- a/public/build.json +++ b/public/build.json @@ -7,8 +7,7 @@ "app/public/js/startup.css" ], "public/js/all-web.min.js": [ - "app/public/js/website_utils.js", - "lib/public/js/wn/misc/number_format.js" + "app/public/js/website_utils.js" ], "public/js/all-app.min.js": [ "app/public/js/startup.js", diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py index 8e3ed701ff3..604c5eb7c93 100644 --- a/selling/doctype/sales_order/sales_order.py +++ b/selling/doctype/sales_order/sales_order.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals import webnotes import webnotes.utils -import json from webnotes.utils import cstr, flt, getdate from webnotes.model.bean import getlist @@ -287,31 +286,6 @@ class DocType(SellingController): def on_update(self): pass -@webnotes.whitelist() -def get_orders(): - # find customer id - customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, - "customer") - - if customer: - orders = webnotes.conn.sql("""select - name, creation, currency from `tabSales Order` - where customer=%s - and docstatus=1 - order by creation desc - limit 20 - """, customer, as_dict=1) - for order in orders: - order.items = webnotes.conn.sql("""select - item_name, qty, export_rate, export_amount, delivered_qty, stock_uom - from `tabSales Order Item` - where parent=%s - order by idx""", order.name, as_dict=1) - - return orders - else: - return [] - def get_website_args(): customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, "customer") @@ -325,17 +299,9 @@ def get_website_args(): "doc": bean.doc, "doclist": bean.doclist, "webnotes": webnotes, - "utils": webnotes.utils + "utils": webnotes.utils, } -def get_currency_and_number_format(): - return { - "global_number_format": webnotes.conn.get_default("number_format") or "#,###.##", - "currency": webnotes.conn.get_default("currency"), - "currency_symbols": json.dumps(dict(webnotes.conn.sql("""select name, symbol - from tabCurrency where ifnull(enabled,0)=1"""))) - } - def set_missing_values(source, target): bean = webnotes.bean(target) bean.run_method("onload_post_render") diff --git a/website/helpers/transaction.py b/website/helpers/transaction.py new file mode 100644 index 00000000000..336be2a1e28 --- /dev/null +++ b/website/helpers/transaction.py @@ -0,0 +1,63 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cint, formatdate +import json + +def get_transaction_list(doctype, start): + # 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 + from `tab%s` where customer=%s and docstatus=1 + order by creation desc + limit %s, 20""" % (doctype, "%s", "%s"), (customer, cint(start)), as_dict=1) + 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)) + doc.creation = formatdate(doc.creation) + return transactions + else: + return [] + +def get_common_args(): + return { + "global_number_format": webnotes.conn.get_default("number_format") or "#,###.##", + "currency": webnotes.conn.get_default("currency"), + "currency_symbols": json.dumps(dict(webnotes.conn.sql("""select name, symbol + from tabCurrency where ifnull(enabled,0)=1"""))) + } + +@webnotes.whitelist() +def get_orders(start=0): + return get_transaction_list("Sales Order", start) + +def order_list_args(): + args = get_common_args() + args.update({ + "title": "My Orders", + "method": "website.helpers.transaction.get_orders", + "icon": "icon-list", + "empty_list_message": "No Orders Yet", + "page": "order", + }) + return args + +@webnotes.whitelist() +def get_invoices(start=0): + return get_transaction_list("Sales Invoice", start) + +def invoice_list_args(): + args = get_common_args() + args.update({ + "title": "Invoices", + "method": "website.helpers.transaction.get_invoices", + "icon": "icon-file-text", + "empty_list_message": "No Invoices Found", + "page": "invoice" + }) + return args \ No newline at end of file diff --git a/website/templates/html/outer.html b/website/templates/html/outer.html index 0f0f4002ea1..8e26f0962f8 100644 --- a/website/templates/html/outer.html +++ b/website/templates/html/outer.html @@ -10,8 +10,7 @@ Login
{% endblock %} \ No newline at end of file diff --git a/website/templates/pages/address.html b/website/templates/pages/address.html index faf7bb04ece..6544b1225d0 100644 --- a/website/templates/pages/address.html +++ b/website/templates/pages/address.html @@ -42,9 +42,9 @@