<?php $__env->startSection('content'); ?>
<div class="row justify-content-center">
    <div class="col-lg-6">
        <div class="card">
            <div class="card-header">
                <h5 class="card-title mb-0">Settle Borrow Transaction</h5>
            </div>
            <div class="card-body">
                <div class="alert alert-info">
                    <strong>Borrow Details:</strong><br>
                    Date: <?php echo e($borrow->created_at->format('Y-m-d H:i')); ?><br>
                    Agent: <?php echo e(optional($borrow->agent)->name); ?><br>
                    Currency: <?php echo e(optional($borrow->currency)->code); ?><br>
                    Quantity: <?php echo e(number_format($borrow->quantity, 4)); ?><br>
                    Initial Agreed Rate: <?php echo e(number_format($borrow->rate, 4)); ?>

                </div>
                
                <form method="POST" action="<?php echo e(route('borrows.process-settlement', $borrow)); ?>">
                    <?php echo csrf_field(); ?>
                    <div class="row g-3">
                        <div class="col-md-12">
                            <label class="form-label" for="payment_account_id">Payment Account (To pay the agent)</label>
                            <select class="form-select" id="payment_account_id" name="payment_account_id" required>
                                <option value="">Select payment account</option>
                                <?php $__currentLoopData = $accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($account->id); ?>" <?php if(old('payment_account_id') == $account->id): echo 'selected'; endif; ?>>
                                        <?php echo e($account->name); ?> - <?php echo e(number_format((float) $account->balance, 2)); ?> <?php echo e($account->currency->code); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="col-md-12">
                            <label class="form-label" for="rate">Final Settlement Rate</label>
                            <input class="form-control text-end atm-decimal" id="rate" name="rate" inputmode="numeric" placeholder="0.00" value="<?php echo e(old('rate', $borrow->rate)); ?>" required>
                            <small class="text-muted">If this rate differs from the initial rate, past profits will be recalculated automatically.</small>
                        </div>
                    </div>
                    <div class="d-flex justify-content-end gap-2 mt-4">
                        <a href="<?php echo e(route('borrows.index')); ?>" class="btn btn-outline-secondary">Cancel</a>
                        <button class="btn btn-success" type="submit">Settle and Pay Agent</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH F:\christopher\currencychangerui\resources\views/borrows/settle.blade.php ENDPATH**/ ?>