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
- | - My Account | + | {% if shopping_cart_enabled -%} | diff --git a/website/templates/pages/account.html b/website/templates/pages/account.html index 539e014ae2a..6dcc497a565 100644 --- a/website/templates/pages/account.html +++ b/website/templates/pages/account.html @@ -8,12 +8,23 @@
  • Home
  • My Account
  • -

    My Account

    -

    Change my name, password

    -

    My Addresses

    -

    My Orders

    -

    My Tickets

    -

    Logout

    + +
    {% 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 @@
  • Home
  • My Account
  • My Addresses
  • -
  • {{ title }}
  • +
  • {{ title }}
  • -

    {{ title }}

    +

    {{ title }}

    diff --git a/website/templates/pages/addresses.html b/website/templates/pages/addresses.html index 90d0d138450..04fc47ba733 100644 --- a/website/templates/pages/addresses.html +++ b/website/templates/pages/addresses.html @@ -7,10 +7,8 @@ -

    My Addresses

    -

    New Address


    diff --git a/website/templates/pages/order.html b/website/templates/pages/order.html index 1893575358f..c70dcb11242 100644 --- a/website/templates/pages/order.html +++ b/website/templates/pages/order.html @@ -8,9 +8,9 @@
  • Home
  • My Account
  • My Orders
  • -
  • {{ doc.name }}
  • +
  • {{ doc.name }}
  • -

    {{ doc.name }}

    +

    {{ doc.name }}


    {%- if doc.status -%}
    diff --git a/website/templates/pages/orders.html b/website/templates/pages/orders.html deleted file mode 100644 index e0bf4d7ad8d..00000000000 --- a/website/templates/pages/orders.html +++ /dev/null @@ -1,70 +0,0 @@ -{% extends "app/website/templates/html/page.html" %} - -{% set title="My Orders" %} - -{% block content %} - -
    - -

    My Orders

    -
    -
    -
    -
    -
    -
    -
    - -{% endblock %} \ No newline at end of file diff --git a/website/templates/pages/profile.html b/website/templates/pages/profile.html index ea2433bae57..4c03b400b9b 100644 --- a/website/templates/pages/profile.html +++ b/website/templates/pages/profile.html @@ -5,12 +5,10 @@ {% block content %}
    -

    My Profile

    -
    diff --git a/website/templates/pages/ticket.html b/website/templates/pages/ticket.html index 1ae2e88dbb6..2f85ac0bbc5 100644 --- a/website/templates/pages/ticket.html +++ b/website/templates/pages/ticket.html @@ -5,12 +5,12 @@ {% block content %}
    -

    {{ doc.name }}

    +

    {{ doc.name }}


    {%- if doc.status -%}
    diff --git a/website/templates/pages/tickets.html b/website/templates/pages/tickets.html index 3d5cf21d5dd..9c476ffa00a 100644 --- a/website/templates/pages/tickets.html +++ b/website/templates/pages/tickets.html @@ -7,10 +7,8 @@ -

    My Tickets

    -
    diff --git a/website/templates/pages/transaction_list.html b/website/templates/pages/transaction_list.html new file mode 100644 index 00000000000..e92764a5ff0 --- /dev/null +++ b/website/templates/pages/transaction_list.html @@ -0,0 +1,69 @@ +{% extends "app/website/templates/html/page.html" %} + +{% block content %} +
    + +
    +
    +
    +
    +
    +
    + + +{% endblock %} \ No newline at end of file