<pdf>
    <dynamic-page page-size="a4">
        <placeholders>
            <header>
                <div height="120px" text-align="center">
                    <h1 padding="5px" margin="0px">MHP Food Enterprise Corp.</h1>
                    <p padding="0">189 Maginhawa st.,</p>
                    <p padding="0" margin-bottom="10px">Quezon City, Metro Manila</p>
                    <p padding="0" margin="0" margin-top="3px" font-style="bold">Receiving Report</p>
                </div>
            </header>
            <footer>
                   <div height="120" text-align="center">
                      <div margin-bottom='20px' width='200px' float="left" margin-right="25px">
                          <div text-align='center' border.type='none' padding='5px'>Jimmy Lichangco</div>
                          <div text-align='center' border.type='top'  padding='5px'>Preferred By</div>
                     </div>
                     <div margin-bottom='20px' width='200px' float="left" margin-right="25px">
                         <div text-align='center' border.type='none' padding='5px'>Cecille Pagdanganan</div>
                         <div text-align='center' border.type='top' padding='5px'>Checked By</div>
                      </div>
                      <div margin-bottom='20px' width='200px' float="left">
                         <div text-align='center' border.type='none' padding='5px'>Joseph Hizon</div>
                         <div text-align='center' border.type='top' padding='5px'>Approved By</div>
                      </div>
                  </div>
            </footer>
        </placeholders>
        <table border.type="none">
            <tr border.type="none">
                <td width="90px" border.type="none">Po No. :</td>
                <td border.type="none">{{ purchaseInvoice.purchaseorderbreakdown.purchaseorderno }}</td>
                <td width="90px" border.type="none">Supplier :</td>
                <td border.type="none">{{ purchaseInvoice.purchaseorderbreakdown.purchaseorder.supplier.description }}</td>
            </tr>
             <tr border.type="none">
                <td width="90px" border.type="none">Batch No. :</td>
                <td border.type="none">{{ purchaseInvoice.purchaseorderbreakdown.purchaseorder.batchno }}</td>
                <td width="90px" border.type="none">Status</td>
                <td border.type="none">{{ purchaseInvoice.purchaseorderbreakdown.status }}</td>
            </tr>
        </table>

        <table margin-top="20px">
            <tr height="40px">
                <td height="20px" text-align="center"  padding-top="5px">Quantity</td>
                <td text-align="center"  padding-top="5px">U / M</td>
                <td text-align="center"  padding-top="5px">Item</td>
                <td text-align="center"  padding-top="5px">Invoice No.</td>
                <td text-align="center"  padding-top="5px">Invoice Date</td>
                <td text-align="center"  padding-top="5px">Price</td>
                <td text-align="center"  padding-top="5px">Amount</td>
            </tr>

            {% set amount = 0 %}
            {% set totalAmount = 0 %}

            {% for item in purchaseInvoice.purchaseorderbreakdown.purchaseorderbreakdownitems %}
                {% for itemdelivery in item.purchaseorderbreakdownitemdeliveries %}
                 {% set amount = itemdelivery.getQuantityConversion * item.purchaseorderitem.price %}
                 {% set totalAmount = totalAmount + amount %}
                  <tr margin-top="3px">
                      <td text-align="center"  {% if loop.last %} border.type="bottom" {% else %} border.type="none" {% endif %}>{{ itemdelivery.quantity }}</td>
                      <td text-align="center" {% if loop.last %} border.type="bottom" {% else %} border.type="none" {% endif %}>{{ itemdelivery.itemunitmeasurement.description }}</td>
                      <td text-align="center" {% if loop.last %} border.type="bottom" {% else %} border.type="none" {% endif %}>{{ item.purchaseorderitem.materialrequisitionitem.item.description }}</td>
                      <td text-align="center" {% if loop.last %} border.type="bottom" {% else %} border.type="none" {% endif %}>{{ itemdelivery.invoiceno }}</td>
                      <td text-align="center" {% if loop.last %} border.type="bottom" {% else %} border.type="none" {% endif %}>{{ itemdelivery.invoicedateasstring }}</td>
                      <td text-align="center" {% if loop.last %} border.type="bottom" {% else %} border.type="none" {% endif %}>{{ item.purchaseorderitem.price }}</td>
                      <td text-align="center" {% if loop.last %} border.type="bottom" padding-bottom="5px" {% else %} border.type="none" {% endif %}>{{ amount|number_format(2, '.', ',') }}</td>
                  </tr>
                {% endfor %}
            {% endfor %}
             <tr height="40px">
                <td text-align="right" colspan="6" border.type="none">Total</td>
                <td text-align="center" border.type="none"> 
                    {{ totalAmount|number_format(2, '.', ',') }}
                </td>
            </tr>
        </table>

    </dynamic-page>
</pdf>