@extends('layouts.app') @section('title', 'Selling Rate per KG Management') @section('content')

📦 Selling Rate per KG Management

Upload a Maldives selling rate workbook. A valid file is imported and activated immediately. Previous active rates are deactivated, and every rate is saved exactly as it appears in the Excel file.

@if(session('success')) @endif @if(session('error')) @endif

Upload Excel

@csrf
@error('country_id')
{{ $message }}
@enderror
@error('effective_date')
{{ $message }}
@enderror
.xlsx only. A valid file is saved and activated immediately. Rates are stored exactly as they appear in the Excel file. @error('excel_file')
{{ $message }}
@enderror
Download Template
@if($preview) @php $parsed = $preview['parsed']; $previewErrors = $parsed['errors'] ?? []; @endphp

Upload Result

This file was not imported. Correct every error and upload it again.

{{ !empty($parsed['valid']) ? 'Valid' : 'Invalid' }}
Country: {{ $preview['country_name'] }}
Effective Date: {{ \Carbon\Carbon::parse($preview['effective_date'])->format('d-m-Y') }}
File: {{ $preview['original_name'] }}
Total weight records: {{ $parsed['weight_count'] ?? 0 }}
Total rate records: {{ !empty($parsed['valid']) ? ($parsed['rate_count'] ?? 0) : 0 }}
Validation status: {{ !empty($parsed['valid']) ? 'Imported' : 'Import blocked' }}
@if(!empty($parsed['warnings']))
    @foreach($parsed['warnings'] as $warning)
  • {{ $warning }}
  • @endforeach
@endif @if($previewErrors)
Fix every error in the Excel file and upload it again.
    @foreach(array_slice($previewErrors, 0, 50) as $previewError)
  • {{ $previewError }}
  • @endforeach
@if(count($previewErrors) > 50)

Showing the first 50 of {{ count($previewErrors) }} errors.

@endif
@endif @if(!empty($parsed['rows'])) @include('admin.selling-rates._rates', ['rows' => $parsed['rows'], 'tableId' => 'ratePreviewTable']) @endif
@csrf
@endif

Existing Rate Cards

Clear
@foreach($cards as $card) @endforeach
ID Country Effective Date Version Total Weight Records Status Uploaded By Uploaded Date Actions
{{ $card->id }} {{ optional($card->country)->country_name }} {{ $card->effective_date->format('d-m-Y') }} {{ $card->version ?: '—' }} {{ $card->weightRecordCount() }} {{ $card->statusLabel() }} {{ optional($card->uploader)->name ?: '—' }} {{ $card->created_at->format('d-m-Y') }}
View @if($card->canActivate())
@csrf
@endif @if($card->canDeactivate())
@csrf
@endif
@endsection @push('styles') @endpush @push('scripts') @endpush