{% set totalAmt = purchaseInvoice.totalAmount %}
{% set totalAmtWhTax = purchaseInvoice.totalAmountWhTax %}
{% set due = totalAmt - totalAmtWhTax %}
{% set totalAmtRcvd = purchaseInvoice.totalAmountReceived %}
{% set totalAmtRcvdWhTax = purchaseInvoice.totalAmountReceivedWhTax %}
{% set dueRcvd = totalAmtRcvd - totalAmtRcvdWhTax %}
{% set totalPayment = purchaseInvoice.totalPayment %}
{% set balance = dueRcvd - totalPayment %}
<div class="content-detail-container">
    <div class="row max-width-initial">
        <div class="large-3 columns">
            <div class="page-detail-header">Purchase Request Details</div>
            <div class="page-detail">Control No.: <span><a target="_blank" href="{{ path('material_requisition_view', {materialRequisition_id: materialRequisition.idEncoded}) }}">{{ materialRequisition.materialrequisitionno }}</a></span></div>
            <div class="page-detail">Request Date: <span>{{ materialRequisition.requestdateasstring }}</span></div>
            <div class="page-detail">Branch: <span>{{ materialRequisition.healthFacility.description }}</span></div>
            {#<div class="page-detail">Department: <span>{{ materialRequisition.department.description }}</span></div>#}
        </div>
        <div class="large-3 columns">
            <div class="page-detail-header">P.O. Details</div>
            <div class="page-detail">Supplier: <span>{{ purchaseOrder.supplier.description|default('') }}</span></div>
            {#<div class="page-detail">Batch No.: <span>{{ purchaseOrder.batchNo }}</span></div>#}
            <div class="page-detail">P.O. Date: <span>{{ purchaseOrderBreakdown.poDateAsString }}</span></div>
            <div class="page-detail">P.O. No.: <span><a target="_blank" href="{{ path('material_requisition_purchase_order_view', {purchaseOrder_id: purchaseOrder.idEncoded}) }}">{{ purchaseOrderBreakdown.pono }}</a></span></div>
            <div class="page-detail">Payment Mode: <span>{{ purchaseOrder.paymentMode }}</span></div>
            <div class="page-detail">Term: <span>{{ purchaseOrder.term }}</span></div>
            <div class="page-detail">Status: <span>{{ purchaseOrderBreakdown.status }}</span></div>
            {#<div class="page-detail">No. of Items: <span>{{ purchaseOrderBreakdown.purchaseOrderBreakdownItems.count }}</span></div>#}
        </div>
        <div class="large-3 columns">
            <div class="page-detail-header">Total PO Amount</div>
            <div class="page-detail">Total Amount: <span class="to-right">{{ totalAmt|number_format(2, '.', ',') }}</span></div>
            {#<div class="page-detail">W/H Tax: <span class="to-right">{{ totalAmtWhTax|number_format(2, '.', ',') }}</span></div>#}
            <hr class="page-detail-divider">
            <div class="page-detail">Due in P.O.: <span class="to-right">{{ due|number_format(2, '.', ',') }}</span></div>
        </div>
        <div class="large-3 columns">
            <div class="page-detail-header">Amounts of P.O. After Received</div>
            <div class="page-detail">Total Amount: <span class="to-right">{{ totalAmtRcvd|number_format(2, '.', ',') }}</span></div>
            {#<div class="page-detail">W/H Tax: <span class="to-right">{{ totalAmtRcvdWhTax|number_format(2, '.', ',') }}</span></div>#}
            <hr class="page-detail-divider">
            <div class="page-detail">Due: <span class="to-right">{{ dueRcvd|number_format(2, '.', ',') }}</span></div>
            <div class="page-detail">Payment Made: <span class="to-right">{{ totalPayment|number_format(2, '.', ',') }}</span></div>
            <hr class="page-detail-divider">
            <div class="page-detail">Balance: <span class="to-right">{{ balance > 0 ? balance|number_format(2, '.', ',') : '0.00' }}</span></div>
        </div>
    </div>
</div>