Skip to content

Commit

Permalink
fix: use doc.company address in Sales Invoice print (LAN-858)
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Sep 23, 2024
1 parent 039b974 commit d33c04b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"doctype": "Print Format",
"font": "Default",
"font_size": 14,
"html": "<style>\n .print-format {\n margin-left: 0mm;\n margin-right: 0mm;\n margin-top: 10mm;\n margin-bottom: 60mm;\n font-size: 10pt;\n }\n</style>\n\n{% set company = frappe.get_doc(\"Company\", doc.company) %}\n{% set customer = frappe.get_doc(\"Customer\", doc.customer) %}\n{% set company_address_name = frappe.db.get_value(\"Dynamic Link\", filters={\"link_doctype\": \"Company\", \"link_name\": doc.company, \"parenttype\": \"Address\"}, fieldname=\"parent\") %}\n{% set company_address = frappe.get_doc(\"Address\", company_address_name) if company_address_name else None %}\n{% set pay_addr = frappe.get_doc(\"Address\", doc.customer_address) if doc.customer_address else None %}\n\n{% if doc.contact_person %}\n {% set contact = frappe.get_doc(\"Contact\", doc.contact_person) %}\n{% endif %}\n\n{% set serial_nos = [] %}\n{% for n in doc.items %}\n {% if n.serial_no is not none %} {% set temp = serial_nos.append(n.serial_no) %}{% endif %}\n{% endfor %}\n{% set serial_no_set=serial_nos|length > 0 %}\n\n<!-- HEAD -->\n<div id=\"header\">\n {% if company.company_logo %}\n <img id=\"logo\" src=\"{{company.company_logo}}\">\n {% endif %}\n</div>\n\n<div class=\"contact-row\">\n <div id=\"address\">\n <div id=\"sender\">\n <p>{{ company.name }}<br>\n {% if company_address %}\n {{ company_address.address_line1 }} &#183;\n {% if company_address.address_line2 %}{{ company_address.address_line2 }} <br>{% endif %}\n {{ company_address.pincode }} {{ company_address.city }}\n {% if company_address.country and company_address.country != pay_addr.country -%}\n &#183; {{ company_address.country.upper() }}\n {%- endif %}\n {% else %}\n <i>{{ _(\"Address not set!\") }}</i>\n {% endif %}\n </p>\n </div>\n {% if contact %}\n <strong>{{ contact.first_name }}{% if contact.last_name %} {{ contact.last_name }}{% endif %}</strong><br>\n {{ doc.customer_name }}<br />\n {% else %}\n <strong>{{ doc.customer_name }}</strong><br />\n {% endif %}\n {{ doc.address_display if doc.address_display else \"<i>\" + _(\"Address not set!\") + \"</i>\" }}\n </div>\n\n <div id=\"contact\">\n <table>\n <tr>\n <td class=\"text-right\">{{ _(\"Date\") }}:</td>\n <td class=\"text-right\">{{ frappe.utils.formatdate(doc.posting_date, \"dd. MMMM yyyy\") }}</td>\n </tr>\n <tr>\n <td class=\"text-right\">{{ _(\"Phone\") }}:</td>\n <td class=\"text-right\">{{ company.phone_no }}</td>\n </tr>\n <tr>\n <td class=\"text-right\">{{ _(\"Email\") }}:</td>\n <td class=\"text-right\">{{ company.email }}</td>\n </tr>\n <tr>\n <td class=\"text-right\">{{ _(\"Organization ID\") }}:</td>\n <td class=\"text-right\">{{ customer.organization }}</td>\n </tr>\n </table>\n </div>\n</div>\n\n<div class=\"din-mark\" id=\"fold-mark-1\"></div>\n<div class=\"din-mark\" id=\"punch-mark\"></div>\n<div class=\"din-mark\" id=\"fold-mark-2\"></div>\n\n<!-- CONTENT -->\n<div id=\"text\" class=\"\">\n\t<div id=\"subject\">\n\t\t<strong>{% if doc.is_return %}{{ _(\"Retoure\") }}{% else %}{{ _(\"Membership Fee Invoice\") }}{% endif %} {{ doc.name }}</strong>\n </div>\n <div class=\"salutation\">\n </div>\n <br>\n <div class=\"invoice\">\n <table class=\"w-100\">\n <thead class=\"black-border\">\n <tr>\n <th style=\"width: 5%\">{{ _(\"Sr\") }}</th>\n {% if serial_no_set %}\n <th style=\"width: 40%\">{{ _(\"Description\") }}</th>\n <th style=\"width: 10%\">{{ _(\"Ser. No\") }}</th>\n {% else %}\n <th style=\"width: 50%\">{{ _(\"Description\") }}</th>\n {%- endif %}\n <th style=\"width: 10%\">{{ _(\"Qty\") }}</th>\n <th style=\"width: 10%\">{{ _(\"Price\") }}</th>\n <th style=\"width: 15%\" class=\"text-right\">{{ _(\"Amount\") }}</th>\n </tr>\n </thead>\n <tbody>\n {% for n in doc.items %}\n <tr>\n <td>{{ loop.index }}</td>\n <td>\n <strong>{{ _(n.item_name) }}</strong>\n {% if not doc.flags.print_settings.compact_item_print %}<br>{{ n.description }}{% endif %}\n </td>\n {% if serial_no_set %}<td>{{ n.serial_no if n.serial_no is not none }}</td>{%- endif %}\n <td>{{ n.qty|int }}</td>\n <td>{{ n.get_formatted('rate') }}</td>\n <td class=\"text-right\">{{ n.get_formatted('amount') }}</td>\n </tr>\n {% endfor %}\n </tbody>\n </table>\n <p></p>\n <table class=\"w-100 black-border\">\n <tr>\n <td>{{ _(\"Total\") }}</td>\n <td class=\"text-right\">{{ doc.get_formatted('total') }}</td>\n </tr>\n {% if doc.discount_amount %}\n <tr>\n <td>\n {{ _(\"Discount\") }}\n {% if doc.additional_discount_percentage %}\n {{ doc.get_formatted('additional_discount_percentage') }} &percnt;\n {% endif %}\n </td>\n <td class=\"text-right\">\n {{ doc.get_formatted('discount_amount') }}\n </td>\n </tr>\n <tr>\n <td>{{ _(\"Net Total\") }}</td>\n <td class=\"text-right\">{{ doc.get_formatted('net_total') }}</td>\n </tr>\n {% endif %}\n {% if doc.tax_category == \"Reverse Charge\" -%}\n <tr>\n <td>Steuerschuldnerschaft des Leistungsempf\u00e4ngers.</td>\n <td class=\"text-right\"></td>\n </tr>\n {% else %}\n {% for tax_row in doc.taxes -%}\n {% if doc.flags.print_settings.print_taxes_with_zero_amount or tax_row.tax_amount > 0 %}\n <tr>\n <td>\n {{ tax_row.description }}\n </td>\n <td class=\"text-right\">\n {{ tax_row.get_formatted('tax_amount') }}\n </td>\n </tr>\n {% endif %}\n {%- endfor %}\n {%- endif %}\n <tr>\n <td>\n <strong>{{ _(\"Grand Total\") }}</strong></td>\n <td class=\"text-right\"><strong>{{ doc.get_formatted('grand_total') }}</strong>\n </td>\n </tr>\n {% if doc.total_advance %}\n <tr>\n <td>\n {{ _(\"Total Advance\") }}\n </td>\n <td class=\"text-right\">\n {{ doc.get_formatted('total_advance') }}\n </td>\n </tr>\n <tr>\n <td>\n {{ _(\"Outstanding Amount\") }}\n </td>\n <td class=\"text-right\">\n {{ doc.get_formatted('outstanding_amount') }}\n </td>\n </tr>\n {% endif %}\n </table>\n </div>\n <br>\n\n <div class=\"epilogue\">\n {% if doc.terms %}\n {{ doc.terms }}\n <br>\n {% endif %}\n\n {% if doc.is_return and company.retoure_information_text %}\n {{ company.retoure_information_text }}\n {% elif not doc.is_return and company.invoice_information_text %}\n {{ company.invoice_information_text }}\n {% endif %}\n </div>\n</div>\n\n<!-- FOOTER -->\n<div id=\"footer-html\" class=\"visible-pdf\">\n <p id=\"pagenum\">\n {{ _(\"Page {0} of {1}\").format('<span class=\"page\"></span>', '<span class=\"topage\"></span>') }}\n </p>\n <div class=\"print-format-footer\">\n {{ footer }}\n </div>\n</div>",
"html": "<style>\n .print-format {\n margin-left: 0mm;\n margin-right: 0mm;\n margin-top: 10mm;\n margin-bottom: 60mm;\n font-size: 10pt;\n }\n</style>\n\n{% set company = frappe.get_doc(\"Company\", doc.company) %}\n{% set customer = frappe.get_doc(\"Customer\", doc.customer) %}\n{% set company_address = frappe.get_doc(\"Address\", doc.company_address) if doc.company_address else None %}\n{% set pay_addr = frappe.get_doc(\"Address\", doc.customer_address) if doc.customer_address else None %}\n\n{% if doc.contact_person %}\n {% set contact = frappe.get_doc(\"Contact\", doc.contact_person) %}\n{% endif %}\n\n{% set serial_nos = [] %}\n{% for n in doc.items %}\n {% if n.serial_no is not none %} {% set temp = serial_nos.append(n.serial_no) %}{% endif %}\n{% endfor %}\n{% set serial_no_set=serial_nos|length > 0 %}\n\n<!-- HEAD -->\n<div id=\"header\">\n {% if company.company_logo %}\n <img id=\"logo\" src=\"{{company.company_logo}}\">\n {% endif %}\n</div>\n\n<div class=\"contact-row\">\n <div id=\"address\">\n <div id=\"sender\">\n <p>{{ company.name }}<br>\n {% if company_address %}\n {{ company_address.address_line1 }} &#183;\n {% if company_address.address_line2 %}{{ company_address.address_line2 }} <br>{% endif %}\n {{ company_address.pincode }} {{ company_address.city }}\n {% if company_address.country and company_address.country != pay_addr.country -%}\n &#183; {{ company_address.country.upper() }}\n {%- endif %}\n {% else %}\n <i>{{ _(\"Address not set!\") }}</i>\n {% endif %}\n </p>\n </div>\n {% if contact %}\n <strong>{{ contact.first_name }}{% if contact.last_name %} {{ contact.last_name }}{% endif %}</strong><br>\n {{ doc.customer_name }}<br />\n {% else %}\n <strong>{{ doc.customer_name }}</strong><br />\n {% endif %}\n {{ doc.address_display if doc.address_display else \"<i>\" + _(\"Address not set!\") + \"</i>\" }}\n </div>\n\n <div id=\"contact\">\n <table>\n <tr>\n <td class=\"text-right\">{{ _(\"Date\") }}:</td>\n <td class=\"text-right\">{{ frappe.utils.formatdate(doc.posting_date, \"dd. MMMM yyyy\") }}</td>\n </tr>\n <tr>\n <td class=\"text-right\">{{ _(\"Phone\") }}:</td>\n <td class=\"text-right\">{{ company.phone_no }}</td>\n </tr>\n <tr>\n <td class=\"text-right\">{{ _(\"Email\") }}:</td>\n <td class=\"text-right\">{{ company.email }}</td>\n </tr>\n <tr>\n <td class=\"text-right\">{{ _(\"Organization ID\") }}:</td>\n <td class=\"text-right\">{{ customer.organization }}</td>\n </tr>\n </table>\n </div>\n</div>\n\n<div class=\"din-mark\" id=\"fold-mark-1\"></div>\n<div class=\"din-mark\" id=\"punch-mark\"></div>\n<div class=\"din-mark\" id=\"fold-mark-2\"></div>\n\n<!-- CONTENT -->\n<div id=\"text\" class=\"\">\n\t<div id=\"subject\">\n\t\t<strong>{% if doc.is_return %}{{ _(\"Retoure\") }}{% else %}{{ _(\"Membership Fee Invoice\") }}{% endif %} {{ doc.name }}</strong>\n </div>\n <div class=\"salutation\">\n </div>\n <br>\n <div class=\"invoice\">\n <table class=\"w-100\">\n <thead class=\"black-border\">\n <tr>\n <th style=\"width: 5%\">{{ _(\"Sr\") }}</th>\n {% if serial_no_set %}\n <th style=\"width: 40%\">{{ _(\"Description\") }}</th>\n <th style=\"width: 10%\">{{ _(\"Ser. No\") }}</th>\n {% else %}\n <th style=\"width: 50%\">{{ _(\"Description\") }}</th>\n {%- endif %}\n <th style=\"width: 10%\">{{ _(\"Qty\") }}</th>\n <th style=\"width: 10%\">{{ _(\"Price\") }}</th>\n <th style=\"width: 15%\" class=\"text-right\">{{ _(\"Amount\") }}</th>\n </tr>\n </thead>\n <tbody>\n {% for n in doc.items %}\n <tr>\n <td>{{ loop.index }}</td>\n <td>\n <strong>{{ _(n.item_name) }}</strong>\n {% if not doc.flags.print_settings.compact_item_print %}<br>{{ n.description }}{% endif %}\n </td>\n {% if serial_no_set %}<td>{{ n.serial_no if n.serial_no is not none }}</td>{%- endif %}\n <td>{{ n.qty|int }}</td>\n <td>{{ n.get_formatted('rate') }}</td>\n <td class=\"text-right\">{{ n.get_formatted('amount') }}</td>\n </tr>\n {% endfor %}\n </tbody>\n </table>\n <p></p>\n <table class=\"w-100 black-border\">\n <tr>\n <td>{{ _(\"Total\") }}</td>\n <td class=\"text-right\">{{ doc.get_formatted('total') }}</td>\n </tr>\n {% if doc.discount_amount %}\n <tr>\n <td>\n {{ _(\"Discount\") }}\n {% if doc.additional_discount_percentage %}\n {{ doc.get_formatted('additional_discount_percentage') }} &percnt;\n {% endif %}\n </td>\n <td class=\"text-right\">\n {{ doc.get_formatted('discount_amount') }}\n </td>\n </tr>\n <tr>\n <td>{{ _(\"Net Total\") }}</td>\n <td class=\"text-right\">{{ doc.get_formatted('net_total') }}</td>\n </tr>\n {% endif %}\n {% if doc.tax_category == \"Reverse Charge\" -%}\n <tr>\n <td>Steuerschuldnerschaft des Leistungsempf\u00e4ngers.</td>\n <td class=\"text-right\"></td>\n </tr>\n {% else %}\n {% for tax_row in doc.taxes -%}\n {% if doc.flags.print_settings.print_taxes_with_zero_amount or tax_row.tax_amount > 0 %}\n <tr>\n <td>\n {{ tax_row.description }}\n </td>\n <td class=\"text-right\">\n {{ tax_row.get_formatted('tax_amount') }}\n </td>\n </tr>\n {% endif %}\n {%- endfor %}\n {%- endif %}\n <tr>\n <td>\n <strong>{{ _(\"Grand Total\") }}</strong></td>\n <td class=\"text-right\"><strong>{{ doc.get_formatted('grand_total') }}</strong>\n </td>\n </tr>\n {% if doc.total_advance %}\n <tr>\n <td>\n {{ _(\"Total Advance\") }}\n </td>\n <td class=\"text-right\">\n {{ doc.get_formatted('total_advance') }}\n </td>\n </tr>\n <tr>\n <td>\n {{ _(\"Outstanding Amount\") }}\n </td>\n <td class=\"text-right\">\n {{ doc.get_formatted('outstanding_amount') }}\n </td>\n </tr>\n {% endif %}\n </table>\n </div>\n <br>\n\n <div class=\"epilogue\">\n {% if doc.terms %}\n {{ doc.terms }}\n <br>\n {% endif %}\n\n {% if doc.is_return and company.retoure_information_text %}\n {{ company.retoure_information_text }}\n {% elif not doc.is_return and company.invoice_information_text %}\n {{ company.invoice_information_text }}\n {% endif %}\n </div>\n</div>\n\n<!-- FOOTER -->\n<div id=\"footer-html\" class=\"visible-pdf\">\n <p id=\"pagenum\">\n {{ _(\"Page {0} of {1}\").format('<span class=\"page\"></span>', '<span class=\"topage\"></span>') }}\n </p>\n <div class=\"print-format-footer\">\n {{ footer }}\n </div>\n</div>",
"idx": 0,
"line_breaks": 0,
"margin_bottom": 15.0,
"margin_left": 15.0,
"margin_right": 15.0,
"margin_top": 15.0,
"modified": "2024-04-26 18:54:53.559501",
"modified": "2024-09-23 16:13:34.620528",
"modified_by": "Administrator",
"module": "LANDA Sales",
"name": "MF DIN Addressfield",
Expand Down
Loading

0 comments on commit d33c04b

Please sign in to comment.