<?php $__env->startSection('title','Depreciation Runs'); ?>
<?php $__env->startSection('crumbs','<b>Depreciation Runs</b>'); ?>
<?php $__env->startSection('content'); ?>
<div class="card"><div class="card-h"><h2>Monthly depreciation</h2>
<?php if(perm('finance.create')): ?>
<form method="POST" action="<?php echo e(route('depreciation-runs.store')); ?>" class="sp no-print" data-confirm="Post depreciation for this period? This creates a GL journal."><?php echo csrf_field(); ?>
<input type="month" name="period" value="<?php echo e($defaultPeriod); ?>" required>
<button class="btn btn-sm">▶ Run depreciation</button>
</form>
<?php endif; ?>
</div>
<div class="card-b">
<?php if($errors->any()): ?><div class="flash err">✕ <?php echo e($errors->first()); ?></div><?php endif; ?>
<h3 style="margin:0 0 8px">Charge preview — active assets</h3>
<div class="twrap"><table class="tbl">
<thead><tr><th>Asset</th><th>Name</th><th>Cost</th><th>Salvage</th><th>Acc. depn</th><th>NBV</th><th>Monthly charge</th></tr></thead>
<tbody>
<?php $__empty_1 = true; $__currentLoopData = $preview; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
<tr><td><a href="<?php echo e(crud_url('fixed-assets','show',$r['asset']->id)); ?>"><?php echo e($r['asset']->asset_no); ?></a></td>
<td><?php echo e($r['asset']->name); ?></td><td><?php echo e(money($r['asset']->purchase_cost)); ?></td>
<td><?php echo e(money($r['asset']->salvage_value)); ?></td><td><?php echo e(money($r['asset']->accumulated_depreciation)); ?></td>
<td><?php echo e(money($r['asset']->net_book_value)); ?></td><td><b><?php echo e(money($r['charge'])); ?></b></td></tr>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
<tr><td colspan="7" class="muted">No depreciable assets (all fully depreciated or disposed).</td></tr>
<?php endif; ?>
</tbody></table></div>
<p class="muted" style="margin-top:6px">Straight-line · Dr 5260 Depreciation / Cr 1510 Accumulated Depreciation · capped so NBV never falls below salvage.</p>
</div></div>
<div class="card"><div class="card-h"><h2>Run history</h2></div>
<div class="card-b"><div class="twrap"><table class="tbl">
<thead><tr><th>Period</th><th>Run date</th><th>Assets</th><th>Total</th><th>Journal</th><th>By</th></tr></thead>
<tbody>
<?php $__empty_1 = true; $__currentLoopData = $runs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $run): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
<tr><td><a href="<?php echo e(route('depreciation-runs.show',$run->id)); ?>"><?php echo e($run->period); ?></a></td>
<td><?php echo e(fdate($run->run_date)); ?></td><td><?php echo e($run->assets_count); ?></td><td><?php echo e(money($run->total_amount)); ?></td>
<td><?php if($run->journal): ?><a href="<?php echo e(route('journals.show',$run->journal->id)); ?>"><?php echo e($run->journal->journal_no); ?></a><?php else: ?> — <?php endif; ?></td>
<td><?php echo e($run->runner->name ?? '—'); ?></td></tr>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
<tr><td colspan="6" class="muted">No runs posted yet.</td></tr>
<?php endif; ?>
</tbody></table></div>
<?php if($runs->hasPages()): ?><div style="margin-top:10px"><?php echo e($runs->links()); ?></div><?php endif; ?>
</div></div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/user/nowills-sqc-erp/resources/views/depreciation/index.blade.php ENDPATH**/ ?>