@extends('layouts.base_pdf') 
  <htmlpageheader name="page-header">
        <br>
        <table width="100%" style="border-bottom: 1px solid black;">
            <tr>
                <td style="text-align: center; color: red; text-transform: uppercase; font-weight: bold; font-size: 18px;  padding-bottom: 5px;">
                    {{ $supplier->name }}
                </td>
            </tr>
        </table>
    </htmlpageheader>
   <table>
        <tr>
            <td class="title">
                <strong>Invoice</strong>
            </td>
            <td class="document-detail">
                PO#: {{$group->reference}} <br>
                Ref#: {{$supplier->reference}} <br>
                Date: {{$group->created_at}}
            </td>
        </tr>
    </table>

    <br>

    <table class="buyer-seller">
        <tr>
            <td width="50%" class="top">
                <span class="buyer-seller-title">
                    Buyer
                </span>
                <br>
                <span class="buyer-company">
                    CIEF Worldwide Sdn Bhd (1134596-M)
                </span>
                <div class="address">
                    No. 72-3, Jalan Jalil 1,<br>
                    The Earth Bukit Jalil,<br>
                    57000 Kuala Lumpur
                </div>
                <div class="contact-no">
                    Tel: 03-8082 1252
                </div>
            </td>
        </tr>
    </table>

    <br>

    <table class="line-table" style="overflow: wrap" autosize="1">
        <thead>
            <tr>
                <th width="5%">No</th>
                <th class="marking" width="10%">Marking</th>
                <th class="description">Description</th>
                <th width="10%">Currency Rate</th>
                <th width="15%">Unit Price (RM)</th>
                <th width="10%">Total Amount<br>(RM)</th>
            </tr>
        </thead>
        
        <tbody>

        @foreach($transactions as $key => $transaction)
            <tr style="margin-bottom: 10px;">
                <td width="5%" class="center top">{{ $key + 1 }}</td>
                <td class="marking top" width="10%">{{$transaction->owner->owner->marking}}</td>
                <td class="description">Please refer to the appedix reference no: {{$transaction->owner->owner->marking}}</td>
                <td width="10%" class="center top">{{$transaction->currency_rate}}</td>
                <td>{{$transaction->currency->short_code}} {{number_format((float)$transaction->amount, 2, '.', '')}}</td>
                @php
                $sub_total_booking_amount = number_format((float)$transactions->sum('original_amount'), 2, '.', '');
                $transfer_fee = number_format((float)$transferFeeTransactions->sum('service_charge'), 2, '.', '');
                $total_booking_amount = number_format((float) ($transactions->sum('original_amount') + $transfer_fee), 2, '.', '');
                $sub_total_amount = number_format((float)$transactions->sum('amount') + ($transfer_fee * 1/$transactions[0]->currency_rate), 2, '.', '');
                $service_charge = number_format((float)$transactions->sum('service_charge'), 2, '.', '');
                $total_amount = number_format((float)$sub_total_amount + $service_charge, 2, '.', '');
                @endphp
                <td>MYR {{$total_amount}}</td>
            </tr>
        @endforeach
        </tbody>

    </table>
