Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Visual adjustments to template
Tomasz Szymanski28f5224e7780
diff --git a/saleor/order/utils.py b/saleor/order/utils.pyindex abcb3eb1d0..0eae8b225e 100644--- a/saleor/order/utils.py+++ b/saleor/order/utils.py@@ -1,3 +1,4 @@+import osfrom functools import wrapsfrom uuid import uuid4@@ -367,6 +368,10 @@ def get_product_limit_first_page(products):def generate_invoice_pdf_for_order(invoice):logo_path = static_finders.find("images/logo.svg")+ font_path = os.path.join(+ settings.PROJECT_ROOT, "templates", "invoices", "inter.ttf"+ )+MAX_PRODUCTS_PER_PAGE = 13all_products = invoice.order.lines.all()@@ -378,12 +383,13 @@ def generate_invoice_pdf_for_order(invoice):all_products[product_limit_first_page:], MAX_PRODUCTS_PER_PAGE)- rendered_template = get_template("invoice.html").render(+ rendered_template = get_template("invoices/invoice.html").render({"invoice": invoice,"creation_date": invoice.created.strftime("%d %b %Y"),"order": invoice.order,"logo_path": f"file://{logo_path}",+ "font_path": f"file://{font_path}","products_first_page": products_first_page,"rest_of_products": rest_of_products,}diff --git a/templates/invoice_products_table.html b/templates/invoice_products_table.htmldeleted file mode 100644index 60ed0769da..0000000000--- a/templates/invoice_products_table.html+++ /dev/null@@ -1,40 +0,0 @@-{% load i18n %}-{% load price from taxed_prices %}-<table class="products-table">- <tbody>- <tr class="row-category">- <td class="cell-product">- <span class="header-category">{% trans "Products" context "Invoice PDF table" %}</span>- </td>- <td class="cell-price">- <span class="header-category">{% trans "Price" context "Invoice PDF table" %}</span>- </td>- <td class="cell-quantity">- <span class="header-category">{% trans "Quantity" context "Invoice PDF table" %}</span>- </td>- <td class="cell-total-price">- <span class="header-category">{% trans "Total Price" context "Invoice PDF table" %}</span>- </td>- </tr>- {% for product in products %}- <tr class="row-product">- <td class="cell-product">- <span class="normal-text">- {{ product|truncatechars:35 }}- <br />- SKU: {{ product.product_sku }}- </span>- </td>- <td class="cell-price">- <span class="normal-text">{% price product.unit_price.gross %}</span>- </td>- <td class="cell-quantity">- <span class="normal-text">{{ product.quantity }}</span>- </td>- <td class="cell-total-price">- <span class="normal-text">{% price product.get_total.gross %}</span>- </td>- </tr>- {% endfor %}- </tbody>-</table>diff --git a/templates/invoices/inter.ttf b/templates/invoices/inter.ttfnew file mode 100644index 0000000000..32a79990a5Binary files /dev/null and b/templates/invoices/inter.ttf differdiff --git a/templates/invoice.html b/templates/invoices/invoice.htmlsimilarity index 80%rename from templates/invoice.htmlrename to templates/invoices/invoice.htmlindex 613a05051b..f44eba3bac 100644--- a/templates/invoice.html+++ b/templates/invoices/invoice.html@@ -9,17 +9,21 @@margin: 0.5cm;@bottom-right {content: counter(page) " of " counter(pages);- font-style: normal;- font-weight: normal;- font-size: 13px;+ font-size: 12px;letter-spacing: 0.02em;color: rgba(40, 35, 74, 0.6);margin: -15px 28px 40px 0;}}+ @font-face {+ font-family: Custom;+ font-style: normal;+ src: url({{ font_path }}) format('truetype');+ }+body {- font-family: Inter, sans-serif;+ font-family: Custom;}.section-header,@@ -39,52 +43,64 @@}.header-category {- font-style: normal;- font-weight: normal;- font-size: 13px;- letter-spacing: 0.02em;+ font-size: 14px;+ letter-spacing: 0.05em;color: rgba(40, 35, 74, 0.6);+ line-height: 1.8;+ }+ .header-category-small {+ font-size: 11px;+ letter-spacing: 0.05em;+ color: rgba(40, 35, 74, 0.6);+ line-height: 1.8;}.header-item {- display: block;- color: black;- font-weight: bold;-- font-style: normal;font-weight: bold;- font-size: 13px;- letter-spacing: 0.02em;+ font-size: 14px;color: #28234A;+ display: block;+ padding-bottom: 5px;+ font-family: Inter;+ letter-spacing: 0.05em;+ line-height: 13px;}.header-title {display: block;+ padding-bottom: 5px;+ font-family: Inter;+ letter-spacing: -0.02em;font-style: normal;font-weight: 600;- font-size: 18px;- letter-spacing: 0.02em;- padding-bottom: 5px;+ font-size: 14px;+ line-height: 13px;color: #28234A;}.content-padded {- padding: 20px;+ padding: 27px;}.content-tight-padded {- padding: 0 20px 0 20px;+ padding: 0 27px 0 27px;}.padded-top {- padding-top: 15px;+ padding-top: 30px;}.normal-text {- font-size: 14px;+ font-size: 15px;+ color: #534f6e;+ line-height: 143.52%;+ }++ .normal-text-table {+ font-size: 15px;color: #28234A;- line-height: 1.7;+ line-height: 143.52%;}.summary-row {@@ -92,14 +108,26 @@}.saleor-logo {- height: 40px;- width: 117px;+ height: 30px;+ width: 78px;padding-bottom: 20px;}+ .padded-font {+ margin-top: 10px;+ }++ .padded-font-sm {+ margin-top: 3px;+ }++ .padded-font {+ margin-top: 1px;+ }+.products-table {width: 100%;- line-height: 1.8;+ line-height: 1.4;}.summary-table {@@ -115,7 +143,7 @@}.cell-product {- width: 40%;+ width: 50%;}.cell-price {@@ -123,20 +151,28 @@text-align: right;}- .cell-summary {- width: 70%;- text-align: right;- padding-right: 30px;+ .cell-price-content {+ padding-right: 57px;}.cell-quantity {- width: 20%;+ width: 15%;text-align: right;}+ .cell-quantity-content {+ padding-right: 35px;+ }+.cell-total-price {- width: 20%;+ width: 15%;+ text-align: right;+ }++ .cell-summary {+ width: 80%;text-align: right;+ padding-right: 30px;}.content-separator {@@ -185,21 +221,20 @@<span class="header-category">{% trans "Order:" context "Invoice PDF header: order number" %}</span>- <br />+ <div class="padded-font-sm"></div><span class="header-item">{{ order.id }}</span>- <br />+ <div class="padded-font"></div><span class="header-category">{% trans "Date:" context "Invoice PDF header" %}</span>- <br />+ <div class="padded-font-sm"></div><span class="header-item">{{ creation_date }}</span>- <br />+ <div class="padded-font"></div><span class="header-category">{% trans "Amount:" context "Invoice PDF amount (price)" %}</span>- <br />+ <div class="padded-font-sm"></div><span class="header-item">{% price order.total_gross %}</span>- <br /></div></div><div class="section-left">@@ -284,21 +319,21 @@</div><div class="content-padded"><span class="header-title">{% trans "ITEMS ORDERED" context "Invoice PDF table header" %}</span>- {% include "invoice_products_table.html" with products=products_first_page %}+ {% include "invoices/invoice_products_table.html" with products=products_first_page %}{% if not rest_of_products|length %}{% if products_first_page|length == 4 %}<div class="page-break"></div>{% endif %}- {% include "invoice_summary_table.html" with order=order %}+ {% include "invoices/invoice_summary_table.html" with order=order %}{% else %}{% for product_set in rest_of_products %}<div class="page-break"></div>- {% include "invoice_products_table.html" with products=product_set %}+ {% include "invoices/invoice_products_table.html" with products=product_set %}{% if forloop.last %}{% if product_set|length > 11 %}<div class="page-break"></div>{% endif %}- {% include "invoice_summary_table.html" with order=order %}+ {% include "invoices/invoice_summary_table.html" with order=order %}{% endif %}{% endfor %}{% endif %}diff --git a/templates/invoices/invoice_products_table.html b/templates/invoices/invoice_products_table.htmlnew file mode 100644index 0000000000..1f6ad8cde1--- /dev/null+++ b/templates/invoices/invoice_products_table.html@@ -0,0 +1,40 @@+{% load i18n %}+{% load price from taxed_prices %}+<table class="products-table">+ <tbody>+ <tr class="row-category">+ <td class="cell-product">+ <span class="header-category-small">{% trans "Products" context "Invoice PDF table" %}</span>+ </td>+ <td class="cell-price">+ <span class="header-category-small cell-price-content">{% trans "Price" context "Invoice PDF table" %}</span>+ </td>+ <td class="cell-quantity">+ <span class="header-category-small cell-quantity-content">{% trans "Quantity" context "Invoice PDF table" %}</span>+ </td>+ <td class="cell-total-price">+ <span class="header-category-small">{% trans "Total Price" context "Invoice PDF table" %}</span>+ </td>+ </tr>+ {% for product in products %}+ <tr class="row-product">+ <td class="cell-product">+ <span class="normal-text-table">+ {{ product|truncatechars:46 }}+ <div class="padded-font-small"></div>+ <span class="header-category-small">SKU: {{ product.product_sku }}</span>+ </span>+ </td>+ <td class="cell-price">+ <span class="normal-text-table cell-price-content">{% price product.unit_price.gross %}</span>+ </td>+ <td class="cell-quantity">+ <span class="normal-text-table cell-quantity-content">{{ product.quantity }}</span>+ </td>+ <td class="cell-total-price">+ <span class="normal-text-table">{% price product.get_total.gross %}</span>+ </td>+ </tr>+ {% endfor %}+ </tbody>+</table>diff --git a/templates/invoice_summary_table.html b/templates/invoices/invoice_summary_table.htmlsimilarity index 86%rename from templates/invoice_summary_table.htmlrename to templates/invoices/invoice_summary_table.htmlindex 4d85933c2c..72a2a669e9 100644--- a/templates/invoice_summary_table.html+++ b/templates/invoices/invoice_summary_table.html@@ -4,7 +4,7 @@<tbody><tr class="summary-row"><td class="cell-summary">- <span class="normal-text">+ <span class="normal-text-table">{% trans "Subtotal" context "Invoice PDF summary" %}</span></td>@@ -17,7 +17,7 @@</tr><tr class="summary-row"><td class="cell-summary">- <span class="normal-text">+ <span class="normal-text-table">{% trans "Delivery Cost" context "Invoice PDF summary" %}</span></td>@@ -30,7 +30,7 @@</tr><tr class="summary-row"><td class="cell-summary">- <span class="normal-text">+ <span class="normal-text-table">{% trans "Tax" context "Invoice PDF summary" %}</span></td>@@ -43,8 +43,8 @@</tr><tr class="summary-row"><td class="cell-summary">- <span class="normal-text">- {% trans "Grand Total" context "Invoice PDF summary" %}+ <span class="normal-text-table">+ <b>{% trans "Grand Total" context "Invoice PDF summary" %}</b></span></td><td class="cell-quantity"></td>