@extends('layouts.app') @section('content')

Branch Sync and Stock Controls

@if(session('success'))

{{ session('success') }}

@endif @if($errors->any())

{{ $errors->first() }}

@endif

{{ $node ? 'Last received: '.($node->synced_at ?: 'Waiting for first sync') : 'No registered branches available.' }}

@if($node)

Stock Controls

@permission('inventory.stock_period_open')
@csrf
@endpermission @if(auth()->user()->hasPermission('inventory.stock_period_open') && auth()->user()->hasPermission('inventory.stock_period_close'))
@csrf
@endif @foreach($commands as $command) @php($result = json_decode($command->result ?? '{}', true))

{{ ucfirst($command->action) }} requested {{ $command->created_at }} · {{ ucfirst($result['status'] ?? 'Pending') }} {{ $result['captured_at'] ?? $result['message'] ?? '' }}

@endforeach @foreach(array_reverse($data['periods'] ?? []) as $row) @endforeach
PeriodOpenedClosedActions
{{ $row['name'] ?? '' }}{{ $row['opened_at'] ?? '' }}{{ $row['closed_at'] ?? 'Open' }} View Report @permission('inventory.stock_period_close') @if(($row['status'] ?? '') === 'open')
@csrf
@endif @endpermission
@if($period)

{{ $node->name }} · {{ $period['name'] }}

{{ $period['opened_at'] }} to {{ $period['closed_at'] ?? 'Open' }}

Export CSV @foreach($period['rows'] as $row) @foreach(['opening', 'purchased', 'added', 'sold', 'other', 'closing', 'count_expected', 'actual', 'difference'] as $column) @endforeach @endforeach
ProductOpeningPurchasedAddedSoldOtherExpected ClosingExpected at CountActual CountDifference
{{ $row['product_name'] }}{{ isset($row[$column]) ? number_format((float) $row[$column], 2) : '–' }}
@endif @foreach(['sales' => ['Sales', 'invoice_no', 'sale_date', 'customer_name'], 'purchases' => ['Purchases', 'purchase_no', 'purchase_date', 'supplier_name']] as $key => [$heading, $reference, $date, $party])

Recent {{ $heading }}

@foreach(array_slice(array_reverse($data[$key] ?? []), 0, 30) as $row) @if(empty($row['deleted_at'])) @endif @endforeach
ReferenceDateNameTotalBalance
{{ $row[$reference] }}{{ $row[$date] }}{{ $row[$party] }}{{ $row['total_amount'] }}{{ $row['balance_amount'] }}
@endforeach

Current Stock

@foreach($data['stock'] ?? [] as $row) @endforeach
BarcodeProductQuantity
{{ $row['barcode'] }}{{ $row['name'] }}{{ $row['stock_quantity'] }}
@endif
@endsection