Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {%- macro render_field(df, doc) -%}
- {%- if df.fieldtype=="Table" -%}
- {{ render_table(df, doc) }}
- {%- elif df.fieldtype=="HTML" -%}
- <div>{{ df.options or "" }}</div>
- {%- elif df.fieldtype in ("Text", "Text Editor", "Code") -%}
- {{ render_text_field(df, doc) }}
- {%- endif -%}
- {%- endmacro -%}
- {%- macro render_table(df, doc, page_num, max_pages) -%}
- {%- set table_meta = frappe.get_meta(df.options) -%}
- {%- set data = doc.get(df.fieldname)[df.start:df.end] -%}
- {%- if data -%}
- {%- set visible_columns = get_visible_columns(doc.get(df.fieldname),
- table_meta) -%}
- <div>
- {% if doc.doctype == "Sales Invoice" %}
- <table class="table table-bordered table-condensed">
- <thead>
- <tr>
- <th width="5%">Pos.</b></th>
- <th width="10%">Art. Nr.</b></th>
- <th width="54%">Beschreibung</b></th>
- <th width="7%" class="text-right">Menge</th>
- <th width="12%" class="text-right">Preis</th>
- <th width="12%" class="text-right">Gesamt</th>
- </tr>
- </thead>
- <tbody>
- {% for d in data %}
- <tr>
- <td>{{ d.idx }}</td>
- <td>{{ d.item_code }}</td>
- <td>{{ d.item_name }}
- <br>{{ d.description }}</td>
- <td>{{ d.qty }}</td>
- <td>{{ d.get_formatted("price_list_rate") }}{%- if d.discount_percentage -%}<br>- {{ d.discount_percentage }} %{%- endif -%}</td>
- <td>{{ d.get_formatted("amount") }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- {% elif doc.doctype == "Purchase Order" %}
- <table class="table table-bordered table-condensed">
- <thead>
- <tr>
- <th width="5%">Pos.</b></th>
- <th width="10%">Art. Nr.</b></th>
- <th width="54%">Beschreibung</b></th>
- <th width="7%" class="text-right">Menge</th>
- <th width="12%" class="text-right">Preis</th>
- <th width="12%" class="text-right">Gesamt</th>
- </tr>
- </thead>
- <tbody>
- {% for d in data %}
- <tr>
- <td>{{ d.idx }}</td>
- <td>{{ d.item_code }}</td>
- <td>{{ d.item_name }}
- <br>{{ d.description }}</td>
- <td>{{ d.qty }}</td>
- <td>{{ d.get_formatted("price_list_rate") }}{%- if d.discount_percentage -%}<br>- {{ d.discount_percentage }} %{%- endif -%}</td>
- <td>{{ d.get_formatted("amount") }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- {% elif doc.doctype == "Delivery Note" %}
- <table class="table table-bordered table-condensed">
- <thead>
- <tr>
- <th width="7%">Pos.</b></th>
- <th width="13%">Art. Nr.</b></th>
- <th width="65%">Beschreibung</b></th>
- <th width="15%" class="text-right">Menge</th>
- </tr>
- </thead>
- <tbody>
- {% for d in data %}
- <tr>
- <td>{{ d.idx }}</td>
- <td>{{ d.item_code }}</td>
- <td>{{ d.item_name }}
- <br>{{ d.description }}</td>
- <td>{{ d.qty }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- {%- else -%}
- <table class="table table-bordered table-condensed">
- <thead>
- <tr>
- <th width="5%">Pos.</b></th>
- <th width="10%">Art. Nr.</b></th>
- <th width="54%">Beschreibung</b></th>
- <th width="7%" class="text-right">Menge</th>
- <th width="12%" class="text-right">Preis</th>
- <th width="12%" class="text-right">Gesamt</th>
- </tr>
- </thead>
- <tbody>
- {% for d in data %}
- <tr>
- <td>{{ d.idx }}</td>
- <td>{{ d.item_code }}</td>
- <td>{{ d.item_name }}
- <br>{{ d.description }}</td>
- <td>{{ d.qty }}</td>
- <td>{{ d.get_formatted("price_list_rate") }}{%- if d.discount_percentage -%}<br>- {{ d.discount_percentage }} %{%- endif -%}</td>
- <td>{{ d.get_formatted("amount") }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- {%- endif -%}
- </div>
- {%- endif -%}
- {{ max_pages }}<br>
- {{ num_page }}
- {%- endmacro -%}
- {%- macro render_text_field(df, doc) -%}
- {%- if doc.get(df.fieldname) != None -%}
- <div style="padding: 10px 0px">
- {% if doc.doctype == "Customer Issue" %}
- <table>
- <tr>
- <td width="40%">Produkt</td>
- <td width="60%">Reklamation</td>
- </tr>
- <tr>
- <td width="40%">{{ doc.item_name }}</td>
- <td width="60%">{{ doc.complaint }}</td>
- </tr>
- </table>
- {% endif -%}
- {%- if df.fieldtype in ("Text", "Code") %}<label>{{ _(df.label) }}</label>{%- endif %}
- {%- if df.fieldtype=="Code" %}
- <pre>{{ doc.get(df.fieldname) }}</pre>
- {% else -%}
- {{ doc.get_formatted(df.fieldname, parent_doc or doc) }}
- {% endif -%}
- </div>
- {%- endif -%}
- {%- endmacro -%}
- {%- macro print_value(df, doc, parent_doc=None) -%}
- {% if df.fieldtype=="Check" %}
- <i class="{{ 'icon-check' if doc[df.fieldname] else 'icon-check-empty' }}"></i>
- {% elif df.fieldtype=="Image" %}
- <img src="{{ doc[doc.meta.get_field(df.fieldname).options] }}" class="img-responsive">
- {% else %}
- {{ doc.get_formatted(df.fieldname, parent_doc or doc) }}
- {% endif %}
- {%- endmacro %}
- {% macro get_width(df) -%}
- {%- if df.print_width -%}{{ (df.print_width|str).replace("px", "") }}
- {%- elif df.fieldtype in ("Int", "Check", "Float", "Currency") -%}{{ 80 }}
- {%- else -%}{{ 150 }}{% endif -%}
- {%- endmacro %}
- {% macro get_align_class(fieldtype) %}
- {%- if fieldtype in ("Int", "Check", "Float", "Currency") -%}{{ "text-right" }}
- {%- else -%}{{ "" }}
- {%- endif -%}
- {% endmacro %}
- {%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
- {% if letter_head and not no_letterhead %}
- <div class="letter-head">{{ letter_head }}</div>
- {% endif %}
- {% if page_num == 1 %}
- <br><br><br> <table width="100%">
- <tr>
- <td width="60%">
- {% if doc.doctype == "Purchase Order" %}
- <p style="line-height:145%;">{{ doc.supplier_name }}<br>{{ doc.supplier_address.address_line1 }}<br>
- <div id="test" style="display:none;"></div>
- </p>
- {% else %}
- <p style="line-height:145%;">{{ doc.customer_name }}<br>{{ doc.address_display }}<br>
- <div id="test" style="display:none;"></div>
- </p>
- {% endif %}
- </td>
- <td width="40%">
- <!-- Rechnungsnummer und so -->
- <table style="line-height:145%;" width="100%">
- <tr>
- <td width="50%">Belegnummer</td>
- <td width="50%" style="text-align:right;">{{ doc.name }}</td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- <br><br>
- <table width="100%">
- <tr>
- <td width="50%">
- <div id="Rechnung">
- </div>
- {% if doc.doctype == "Sales Invoice" %}
- <big><big><big><big>Rechnung </big></big></big></big>
- {% elif doc.doctype == "Purchase Order" %}
- <big><big><big><big>Bestellung </big></big></big></big>
- {% elif doc.doctype == "Delivery Note" %}
- <big><big><big><big>Lieferschein </big></big></big></big>
- {% elif doc.doctype == "Sales Order" %}
- <big><big><big><big>Auftragsbestätigung </big></big></big></big>
- {% elif doc.doctype == "Customer Issue" %}
- <big><big><big><big>Kundenreklamation </big></big></big></big>
- {% else %}
- <big><big><big><big>{{ doc.doctype }} </big></big></big></big>
- {% endif %}
- </td>
- <td width="50%" style="text-align:right; valign:top;">
- {% if doc.doctype == "Purchase Order" %}
- {% elif doc.doctype == "Customer Issue" %}
- {% else %}
- <b>Datum:</b> {{ doc.get_formatted("posting_date") }}<br>
- {% endif %}
- </td>
- </tr>
- </table>
- <br><br>
- {% endif %}
- {% if max_pages > 1 %}
- {% if page_num == max_pages %}
- <table width="100%">
- <tr>
- <td width="60%">
- <table style="line-height:145%;" width="100%">
- <tr>
- <td width="50%">Rechnungsnr.</td>
- <td width="50%" style="text-align:right;">{{ doc.name }}</td>
- </tr>
- </table>
- </td>
- <td width="40%">
- <!-- Rechnungsnummer und so -->
- <p class="text-right">{{ _("Seite {0} von {1}").format(page_num, max_pages) }}</p>
- </td>
- </tr>
- </table>
- <br>{% endif %}
- {% endif %}
- {%- endmacro -%}
- {%- macro bottom(meta) -%}
- {{ page }}
- <p class="text-right">{{ _("Seite {0} von {1}").format(page_num, max_pages) }}</p>
- {%- endmacro -%}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement