@php $logoDataUri = null; $faDigits = static fn (int|float|string|null $value): string => \App\Support\PersianTextNormalizer::digits($value); $faNumber = static fn (int|float|string|null $value, int $decimals = 0): string => \App\Support\PersianTextNormalizer::number($value, $decimals); $faMoneyWords = static fn (int|float|string|null $value): string => \App\Support\PersianTextNormalizer::moneyInWords($value); if ($workspace->logo_path && \Illuminate\Support\Facades\Storage::disk('public')->exists($workspace->logo_path)) { $logoFullPath = \Illuminate\Support\Facades\Storage::disk('public')->path($workspace->logo_path); $logoMime = mime_content_type($logoFullPath) ?: 'image/png'; $logoDataUri = 'data:'.$logoMime.';base64,'.base64_encode(file_get_contents($logoFullPath)); } @endphp
@fa('پیش‌فاکتور شماره') {{ $faDigits($quotation->number) }}
@fa('نسخه') {{ $faDigits($quotation->version_no) }}
@fa('تاریخ صدور') :{{ $faDigits(jdate($quotation->issue_date)->format('Y/m/d')) }}
@if ($quotation->valid_until) @fa('اعتبار تا') :{{ $faDigits(jdate($quotation->valid_until)->format('Y/m/d')) }} @endif
{{-- Seller (our own workspace/company) --}}
@if ($logoDataUri) @endif
@fa('مشخصات فروشنده') logo
@fa('نام'): @fa($workspace->name) @fa('شهر'): @fa($workspace->city) @fa('تلفن/نمابر'): {{ $faDigits($workspace->phone) }}
@fa('کدپستی'): {{ $faDigits($workspace->postal_code) }} @fa('شماره اقتصادی'): {{ $faDigits($workspace->economic_code) }} @fa('شماره ثبت'): {{ $faDigits($workspace->registration_number) }}
@fa('نشانی'): @fa($workspace->address) @fa('شناسه ملی'): {{ $faDigits($workspace->national_id) }}
{{-- Buyer: the customer, or the organization itself when the quotation was issued to one with no individual contact. data_get() because the two models share only some columns (an organization has no mobile/postal code/registration number). --}} @php $buyer = $quotation->customer ?? $quotation->partnerCompany; @endphp
@fa('مشخصات خریدار')
@fa('نام'): @fa(data_get($buyer, 'company_name') ?: data_get($buyer, 'name')) @fa('شهر'): @fa(data_get($buyer, 'city')) @fa('تلفن/موبایل'): {{ $faDigits(data_get($buyer, 'phone') ?: data_get($buyer, 'mobile')) }}
@fa('کدپستی'): {{ $faDigits(data_get($buyer, 'postal_code')) }} @fa('شماره اقتصادی'): {{ $faDigits(data_get($buyer, 'economic_code')) }} @fa('شماره ثبت'): {{ $faDigits(data_get($buyer, 'registration_number')) }}
@fa('نشانی'): @fa(data_get($buyer, 'address')) @fa('شناسه/شماره ملی'): {{ $faDigits(data_get($buyer, 'national_id')) }}
@foreach ($quotation->items as $index => $item) @php $afterDiscount = bcsub($item->line_total, $item->tax_amount, 2); $rawTotal = bcadd($afterDiscount, $item->discount_amount, 2); @endphp @endforeach @if ((float) $quotation->other_cost_total > 0) @endif
@fa('ردیف') @fa('کدکالا') @fa('شرح کالا یا خدمت') @fa('تعداد') @fa('واحد') @fa('مبلغ واحد') @fa('مبلغ کل') @fa('مبلغ تخفیف') @fa('مبلغ پس از تخفیف') @fa('جمع مالیات') @fa('مبلغ نهایی')
{{ $faDigits($index + 1) }} {{ $faDigits($item->sku ?: '-') }} @fa($item->name) {{ $faNumber($item->qty, 0) }} @fa($item->unit) {{ $faNumber($item->unit_price, 0) }} {{ $faNumber($rawTotal, 0) }} {{ $faNumber($item->discount_amount, 0) }} {{ $faNumber($afterDiscount, 0) }} {{ $faNumber($item->tax_amount, 0) }} {{ $faNumber($item->line_total, 0) }}
@fa('جمع کل') {{ $faNumber(bcadd($quotation->subtotal, $quotation->discount_total, 2), 0) }} {{ $faNumber($quotation->discount_total, 0) }} {{ $faNumber($quotation->subtotal, 0) }} {{ $faNumber($quotation->tax_total, 0) }} {{ $faNumber($quotation->total_amount, 0) }} @fa('ریال')
@fa('سایر هزینه‌ها') {{ $faNumber($quotation->other_cost_total, 0) }}
@fa('مبلغ به حروف:') @fa($faMoneyWords($quotation->total_amount))
@if ($quotation->notes->isNotEmpty() || $quotation->custom_note)
@fa('توضیحات') @if ($quotation->notes->isNotEmpty()) @foreach ($quotation->notes as $note) @endforeach
• @fa($note->text)
@endif @if ($quotation->custom_note)

@fa($quotation->custom_note)

@endif
@endif
@fa('مهر و امضاء فروشنده') @fa('مهر و امضاء خریدار')