From c449025a9fdaae38d987faa6897b4645e1648392 Mon Sep 17 00:00:00 2001 From: Corentin Forler <8860073-cforler_dokos@users.noreply.gitlab.com> Date: Wed, 31 Jan 2024 17:25:39 +0100 Subject: [PATCH] fix(web): Fix orders page when webshop is not installed --- .../includes/order/order_macros.html | 27 +++++ .../templates/includes/order/order_taxes.html | 112 ++++++++++++++++++ erpnext/templates/pages/order.html | 26 +--- 3 files changed, 140 insertions(+), 25 deletions(-) create mode 100644 erpnext/templates/includes/order/order_macros.html create mode 100644 erpnext/templates/includes/order/order_taxes.html diff --git a/erpnext/templates/includes/order/order_macros.html b/erpnext/templates/includes/order/order_macros.html new file mode 100644 index 00000000000..21fb489e2de --- /dev/null +++ b/erpnext/templates/includes/order/order_macros.html @@ -0,0 +1,27 @@ +{# Legacy macros without Item Booking #} +{% from "erpnext/templates/includes/macros.html" import product_image %} + +{% macro item_name_and_description(d) %} +
+
+
+ {% if d.thumbnail or d.image %} + {{ product_image(d.thumbnail or d.image, no_border=True) }} + {% else %} +
+ {{ frappe.utils.get_abbr(d.item_name) or "NA" }} +
+ {% endif %} +
+
+
+ {{ d.item_code }} +
+ {{ html2text(d.description) | truncate(140) }} +
+ + {{ _("Qty ") }}({{ d.get_formatted("qty") }}) + +
+
+{% endmacro %} diff --git a/erpnext/templates/includes/order/order_taxes.html b/erpnext/templates/includes/order/order_taxes.html new file mode 100644 index 00000000000..62dc6532524 --- /dev/null +++ b/erpnext/templates/includes/order/order_taxes.html @@ -0,0 +1,112 @@ +{% if doc.taxes %} +
+
+
+ {{ _("Net Total") }} +
+
+ {{ doc.get_formatted("net_total") }} +
+
+
+{% endif %} + +{% for d in doc.taxes %} + {% if d.base_tax_amount %} +
+
+
+ {{ d.description }} +
+
+ {{ d.get_formatted("base_tax_amount") }} +
+
+
+ + {% endif %} +{% endfor %} + +{% if doc.doctype == 'Quotation' %} + {% if doc.coupon_code %} +
+
+
+ {{ _("Savings") }} +
+
+ {% set tot_quotation_discount = [] %} + {%- for item in doc.items -%} + {% if tot_quotation_discount.append((((item.price_list_rate * item.qty) + * item.discount_percentage) / 100)) %} + {% endif %} + {% endfor %} + {{ frappe.utils.fmt_money((tot_quotation_discount | sum),currency=doc.currency) }}
+
+
+ {% endif %} +{% endif %} + +{% if doc.doctype == 'Sales Order' %} + {% if doc.coupon_code %} +
+
+
+ {{ _("Total Amount") }} +
+
+ + {% set total_amount = [] %} + {%- for item in doc.items -%} + {% if total_amount.append((item.price_list_rate * item.qty)) %}{% endif %} + {% endfor %} + {{ frappe.utils.fmt_money((total_amount | sum),currency=doc.currency) }} + +
+
+
+
+
+
+ {{ _("Applied Coupon Code") }} +
+
+ + {%- for row in frappe.get_all(doctype="Coupon Code", + fields=["coupon_code"], filters={ "name":doc.coupon_code}) -%} + {{ row.coupon_code }} + {% endfor %} + +
+
+
+
+
+
+ {{ _("Savings") }} +
+
+ + {% set tot_SO_discount = [] %} + {%- for item in doc.items -%} + {% if tot_SO_discount.append((((item.price_list_rate * item.qty) + * item.discount_percentage) / 100)) %}{% endif %} + {% endfor %} + {{ frappe.utils.fmt_money((tot_SO_discount | sum),currency=doc.currency) }} + +
+
+
+ {% endif %} +{% endif %} + +
+
+
+ {{ _("Grand Total") }} +
+
+ {{ doc.get_formatted("grand_total") }} +
+
+
diff --git a/erpnext/templates/pages/order.html b/erpnext/templates/pages/order.html index 038a72f2711..b3af2bc9e43 100644 --- a/erpnext/templates/pages/order.html +++ b/erpnext/templates/pages/order.html @@ -1,5 +1,6 @@ {% extends "templates/web.html" %} {% from "erpnext/templates/includes/macros.html" import product_image %} +{% from "erpnext/templates/includes/order/order_macros.html" import item_name_and_description %} {% block breadcrumbs %} {% include "templates/includes/breadcrumbs.html" %} @@ -144,28 +145,3 @@ {% endif %} {% endblock %} - -{% macro item_name_and_description(d) %} -
-
-
- {% if d.thumbnail or d.image %} - {{ product_image(d.thumbnail or d.image, no_border=True) }} - {% else %} -
- {{ frappe.utils.get_abbr(d.item_name) or "NA" }} -
- {% endif %} -
-
-
- {{ d.item_code }} -
- {{ html2text(d.description) | truncate(140) }} -
- - {{ _("Qty ") }}({{ d.get_formatted("qty") }}) - -
-
-{% endmacro %} \ No newline at end of file -- GitLab