<?php foreach($data as $key=>$val){?>
<Records>
    <TransactionDetails>
        <LOCATION_CODE><?= $val['bId']?></LOCATION_CODE>
        <TERMINAL_ID>1</TERMINAL_ID>
        <SHIFT_NO>1</SHIFT_NO>
        <RCPT_NUM><?= $val['tNo']?></RCPT_NUM>
        <RCPT_DT><?= $val['createdDate']?></RCPT_DT>
        <BUSINESS_DT><?= $val['createdDate']?></BUSINESS_DT>
        <RCPT_TM><?= $val['createdTime']?></RCPT_TM>
        <INV_AMT><?= $val['TotalAmount']?></INV_AMT>
        <TAX_AMT><?= $val['TaxAmount']?></TAX_AMT>
        <RET_AMT><?= $val['returnAmount']?></RET_AMT>
        <TRAN_STATUS><?= $val['transStatus']?></TRAN_STATUS>
        <OP_CUR><?= $val['currency']?></OP_CUR>
        <BC_EXCH><?= $val['isExchange']?></BC_EXCH>
        <DISCOUNT><?= $val['totalDiscount']?></DISCOUNT>
    </TransactionDetails>
<?php foreach($val['details'] as $ikey=>$ival){?>
    <ItemDetails>
        <LOCATION_CODE><?= $val['bId']?></LOCATION_CODE>
        <TERMINAL_ID>1</TERMINAL_ID>
        <SHIFT_NO>1</SHIFT_NO>
        <RCPT_NUM><?= $val['tNo']?></RCPT_NUM>
        <ITEM_CODE><?= $ival['itemId']?></ITEM_CODE>
        <ITEM_NAME><?= $ival['itemName']?></ITEM_NAME>
        <ITEM_QTY><?= $ival['qty']?></ITEM_QTY>
        <ITEM_PRICE><?= $ival['rate']?></ITEM_PRICE>
        <ITEM_CAT><?= $ival['catName']?></ITEM_CAT>
        <ITEM_TAX><?= $ival['taxAmount']?></ITEM_TAX>
        <ITEM_TAX_TYPE><?= $val['taxType']?></ITEM_TAX_TYPE>
        <ITEM_NET_AMT><?= $ival['itemTotal']?></ITEM_NET_AMT>
        <OP_CUR><?= $val['currency']?></OP_CUR>
        <BC_EXCH><?= $val['isExchange']?></BC_EXCH>
        <ITEM_STATUS><?= $val['transStatus']?></ITEM_STATUS>
        <ITEM_DISCOUNT><?= $ival['discAmount']?></ITEM_DISCOUNT>
    </ItemDetails>
<?php }?>
<?php 
if(!empty($data['payModes'])){
foreach($data['payModes'] as $pkey=>$pval){
?>
    <PaymentDetails>
        <LOCATION_CODE><?= $val['bId']?></LOCATION_CODE>
        <TERMINAL_ID>1</TERMINAL_ID>
        <SHIFT_NO>1</SHIFT_NO>
        <RCPT_NUM><?= $val['tNo']?></RCPT_NUM>
        <PAYMENT_NAME><?= $pval['pModeName']?></PAYMENT_NAME>
        <CURRENCY_CODE><?= $val['exportCurrencyCode']?></CURRENCY_CODE>
        <EXCHANGE_RATE><?= $val['exchangeRate']?></EXCHANGE_RATE>
        <TENDER_AMOUNT><?= $pval['pAmount']?></TENDER_AMOUNT>
        <OP_CUR><?= $val['currency']?></OP_CUR>
        <BC_EXCH><?= $val['isExchange']?></BC_EXCH>
        <PAYMENT_STATUS><?= $val['transStatus']?></PAYMENT_STATUS>
    </PaymentDetails>
<?php 
}
}else{
?>
    <PaymentDetails>
        <LOCATION_CODE><?= $val['bId']?></LOCATION_CODE>
        <TERMINAL_ID>1</TERMINAL_ID>
        <SHIFT_NO>1</SHIFT_NO>
        <RCPT_NUM><?= $val['tNo']?></RCPT_NUM>
        <PAYMENT_NAME>Cash</PAYMENT_NAME>
        <CURRENCY_CODE><?= $val['exportCurrencyCode']?></CURRENCY_CODE>
        <EXCHANGE_RATE><?= $val['exchangeRate']?></EXCHANGE_RATE>
        <TENDER_AMOUNT><?= $val['TotalAmount']?></TENDER_AMOUNT>
        <OP_CUR><?= $val['currency']?></OP_CUR>
        <BC_EXCH><?= $val['isExchange']?></BC_EXCH>
        <PAYMENT_STATUS><?= $val['transStatus']?></PAYMENT_STATUS>
    </PaymentDetails>
<?php
}
?>
</Records>
<?php
}
?>