{{-- Başarı Mesajı --}}

{{ $successMessage }}

{{-- Hata Mesajı --}} @if (session()->has('error'))

{{ session('error') }}

@endif
@foreach ($invoiceLines as $line)
{{-- Satır Başlığı --}}

{{ $line['name'] }}

Toplam Miktar: {{ number_format($line['quantity'], 4, ',', '.') }}
Birim Fiyat: {{ number_format($line['unit_price'], 4, ',', '.') }} {{ $invoice->currency }}
Dağıtılan: {{ number_format($line['total_allocated'], 4, ',', '.') }}
Kalan: {{ number_format($line['remaining_quantity'], 4, ',', '.') }}
{{-- Mevcut Dağıtımlar --}} @if (count($line['existing_allocations']) > 0)

Yapılmış Dağıtımlar:

@foreach ($line['existing_allocations'] as $existingAllocation)
{{-- Hedef Hesap --}}
Hedef Hesap: {{ $existingAllocation->targetAccount ? $existingAllocation->targetAccount->title : 'Hesap Bilgisi Yok' }}
{{-- Depo --}}
Depo: {{ $existingAllocation->warehouse ? $existingAllocation->warehouse->name : 'ANA DEPO' }}
{{-- Miktar & Fiyat --}}
Miktar: {{ number_format($existingAllocation->allocated_quantity, 2) }} birim
Birim Fiyat: {{ number_format($existingAllocation->unit_cost, 2) }} {{ $invoice->currency }}
{{-- Dağıtım Tarihi --}}
Dağıtım Bilgileri: {{ $existingAllocation->created_at ? $existingAllocation->created_at->format('d.m.Y H:i') : 'N/A' }} - ID:{{ $existingAllocation->id }}
{{-- Durum & İşlemler --}}
@if (in_array($existingAllocation->status, ['sent', 'completed']))
@csrf
@endif {{-- Durum Badge'leri --}} @if ($existingAllocation->status === 'completed') ✓ Tamamlandı @elseif ($existingAllocation->status === 'sent') ↗ Gönderildi @elseif ($existingAllocation->status === 'rollback') ↶ Geri Alındı @elseif ($existingAllocation->status === 'failed') ✗ Başarısız @elseif ($existingAllocation->status === 'planned') ⏳ Bekliyor @endif
@endforeach
@endif {{-- Yeni Dağıtımlar --}} @if (isset($allocations[$line['id']]) && count($allocations[$line['id']]) > 0)
@foreach ($allocations[$line['id']] as $index => $allocation)
{{-- Hedef Hesap --}}
@if ($targetAccounts->count() === 1) @else @endif @error("allocations.{$line['id']}.{$index}.target_account_id")

{{ $message }}

@enderror
{{-- Depo Seçimi --}}
@php $accountId = $allocation['target_account_id'] ?? ''; $warehouseCount = $accountId && isset($warehousesByAccount[$accountId]) ? count($warehousesByAccount[$accountId]) : 0; @endphp @error("allocations.{$line['id']}.{$index}.warehouse_id")

{{ $message }}

@enderror
{{-- Posmanager Ürünü --}}
@error("allocations.{$line['id']}.{$index}.remote_stock_item_id")

{{ $message }}

@enderror {{-- Partial Match Uyarısı --}} @if (isset($partialMatches["{$line['id']}_{$index}"])) @php $matchInfo = $partialMatches["{$line['id']}_{$index}"]; @endphp

DİKKAT: Ürün tam olarak eşleşmiyor.
"{{ $matchInfo['original_name'] }}" --> "{{ $matchInfo['matched_name'] }}" stok kartı eşleştirildi.
Bu dağıtım için belki yeni bir stok kartı oluşturmak isteyebilirsiniz.

@endif
{{-- Yeni Ürün Checkbox --}}
{{-- Miktar --}}
@error("allocations.{$line['id']}.{$index}.allocated_quantity")

{{ $message }}

@enderror
{{-- Birim Fiyat --}}
{{-- Sil Butonu --}}
{{-- Yeni Ürün Bilgi Notu --}} @if ($allocation['create_new_item'] ?? false)

Posmanager'da yeni bir stok kartı oluşturulacak.

{{-- Özel Stok Kartı Adı Input --}}
@endif @endforeach {{-- Kalan Miktar Uyarısı --}} @php $remaining = $this->getRemainingQuantity($line['id']); @endphp @if ($remaining < 0)

⚠️ Toplam dağıtım miktarı stok miktarını {{ number_format(abs($remaining), 4, ',', '.') }} birim aşıyor!

@elseif ($remaining > 0)

ℹ️ Dağıtılabilir kalan miktar: {{ number_format($remaining, 4, ',', '.') }} birim

@endif
@endif
@php $remainingQty = $this->getRemainingQuantity($line['id']); @endphp @if ($line['remaining_quantity'] > 0) @else ✓ DAĞITIM TAMAMLANDI @endif
@endforeach {{-- Kaydet Butonu --}} @if (count($allocations) > 0)

Dağıtımları Onayla

Toplam {{ collect($allocations)->flatten(1)->count() }} dağıtım kaydı oluşturulacak ve Posmanager'a gönderilecek.

@endif