@extends('layouts.business.pdf.pdf_layout') @section('pdf_title') @endsection @section('pdf_title')
@include('business::print.header')

{{ __('Sales Invoice') }}

{{ __('Invoice') }}
@push('css') @include('business::pdf.fonts-css') @endpush @endsection @section('pdf_content') @php $subtotal = 0; foreach ($sale->details as $detail) { $subtotal += ($detail->price - $detail->discount) * $detail->quantities; } $total_return_amount = 0; foreach ($sale_returns as $return) { foreach ($return->details as $detail) { $total_return_amount += $detail->return_amount; } } @endphp
{{-- Header --}}
@php $defaultLogo = public_path('assets/images/default.svg'); $customLogo = public_path( get_business_option('business-settings')['a4_invoice_logo'] ?? 'assets/images/default.svg', ); $logoPath = file_exists($customLogo) ? $customLogo : $defaultLogo; $logoData = base64_encode(file_get_contents($logoPath)); $logoType = pathinfo($logoPath, PATHINFO_EXTENSION); $src = 'data:image/' . $logoType . ';base64,' . $logoData; @endphp @if ((get_business_option('business-settings')['show_a4_invoice_logo'] ?? 0) == 1) @endif @if (($sale->business->meta['show_address'] ?? 0) == 1)
{{ __('Address') }} : {{ $sale->branch?->address ?? ($sale->business?->address ?? '') }}
@endif @if (($sale->business->meta['show_phone_number'] ?? 0) == 1)
{{ __('Mobile') }} : {{ $sale->branch?->phone ?? ($sale->business?->phoneNumber ?? '') }}
@endif @if (($sale->business->meta['show_email'] ?? 0) == 1)
{{ __('Email') }} : {{ $sale->branch?->email ?? ($sale->business?->email ?? '') }}
@endif
@if (($sale->business->meta['show_vat'] ?? 0) == 1) {{ $sale->business->vat_name }} @endif {{ ($sale->business->meta['show_vat'] ?? 0) == 1 && ($sale->business->meta['show_vat'] ?? 0) == 1 ? ':' : '' }} @if (($sale->business->meta['show_vat'] ?? 0) == 1) {{ $sale->business->vat_no ?? '' }} @endif
{{-- INVOICE BADGE --}}

{{ __('INVOICE') }}

{{-- Customer & Invoice Info --}}
{{ __('Customer') }} : {{ $sale->party->name ?? __('Guest') }}
{{ __('Address') }} : {{ $sale->party->address ?? '' }}
{{ __('Phone') }} : {{ $sale->party->phone ?? __('Guest') }}
{{ __('Remarks') }} : {{ $sale->meta['note'] ?? 'N/A' }}
{{ __('Invoice No') }} : {{ $sale->invoiceNumber ?? '' }}
{{ __('Date') }} : {{ formatted_date($sale->saleDate ?? '') }}
{{ __('Time') }} : {{ formatted_time($sale->saleDate ?? '') }}
{{ __('Sales By') }} : {{ $sale->user->role != 'staff' ? __('Admin') : $sale->user->name }}
{{-- Sale Items --}} @if ($hasWarranty) @endif @if ($hasGuarantee) @endif @foreach ($sale->details as $detail) @php $price = $detail->price ?? 0; $discount = $detail->discount ?? 0; $qty = $detail->quantities ?? 0; $productTotal = ($price - $discount) * $qty; $info = $detail->warranty_guarantee_info ?? []; @endphp @if ($hasWarranty) @endif @if ($hasGuarantee) @endif @endforeach
{{ __('SL') }} {{ __('Item') }} {{ __('Quantity') }}{{ __('Warranty') }}{{ __('Guarantee') }}{{ __('Unit Price') }} {{ __('Discount') }} {{ __('Total Price') }}
{{ $loop->iteration }} {{ $detail->product->productName ?? '' }} {{ !empty($detail->stock?->batch_no) ? ' (' . $detail->stock->batch_no . ')' : '' }} {{ $qty }}{{ $info['warranty_duration'] ?? '' }} {{ $info['warranty_unit'] ?? '' }}{{ $info['guarantee_duration'] ?? '' }} {{ $info['guarantee_unit'] ?? '' }}{{ currency_format($price, currency: business_currency()) }} {{ currency_format($discount, currency: business_currency()) }} {{ currency_format($productTotal, currency: business_currency()) }}
{{ amountInWords($subtotal) }}
@if (get_business_option('business-settings')['show_note'] ?? 0 == 1) {{ get_business_option('business-settings')['note_label'] ?? '' }} : @endif @if (get_business_option('business-settings')['show_note'] ?? 0 == 1) {{ get_business_option('business-settings')['note'] ?? '' }} @endif
{{ __('Paid by') }} : {{ $transactionTypes ?? ($due_collect->payment_type_id ? $due_collect->payment_type->name ?? '' : $due_collect->paymentType ?? '') }}
{{-- BANK DETAILS --}} @if (($bank_detail->show_in_invoice ?? 0) == 1)
{{ __('Bank Details') }}
{{ __('Name') }} : {{ $bank_detail->name }}
{{ __('Account No') }} : {{ $bank_detail->meta['account_number'] ?? '' }}
{{ __('UPI ID') }} : {{ $bank_detail->meta['upi_id'] ?? '' }}
{{ __('Holder’s Name') }} : {{ $bank_detail->meta['account_holder'] ?? '' }}
@endif
{{ __('Subtotal') }} : {{ currency_format($subtotal, currency: business_currency()) }}
{{ __('Vat') }} : {{ currency_format($sale->vat_amount, currency: business_currency()) }}
{{ __('Shipping Charge') }} : {{ currency_format($sale->shipping_charge, currency: business_currency()) }}
{{ __('Discount') }} : {{ currency_format($sale->discountAmount + $total_discount, currency: business_currency()) }}
{{ __('Total Amount') }} : {{ currency_format( $subtotal + $sale->vat_amount - ($sale->discountAmount + $total_discount) + $sale->shipping_charge + $sale->rounding_amount, currency: business_currency(), ) }}
{{ __('Rounding (+/-)') }} : {{ currency_format(abs($sale->rounding_amount), currency: business_currency()) }}
{{ __('Total Payable') }} : {{ currency_format($sale->totalAmount, currency: business_currency()) }}
{{-- Sale Returns --}} @if (!$sale_returns->isEmpty()) @php $total_return_amount = 0; $row_counter = 0; @endphp @foreach ($sale_returns as $return) @foreach ($return->details as $detail) @php $total_return_amount += $detail->return_amount ?? 0; $row_counter++; @endphp @endforeach @endforeach
{{ __('SL') }} {{ __('Date') }} {{ __('Returned Item') }} {{ __('Quantity') }} {{ __('Total Amount') }}
{{ $row_counter }} {{ formatted_date($return->return_date) }} {{ $detail->saleDetail->product->productName ?? '' }} {{ $detail->saleDetail?->stock?->batch_no ? '(' . $detail->saleDetail?->stock?->batch_no . ')' : '' }} {{ $detail->return_qty }} {{ currency_format($detail->return_amount, currency: business_currency()) }}
{{ amountInWords($total_return_amount) }}
{{ __('Paid by') }} : {{ $returnTransactionType ?? ($sale->paymentType ?? '') }}
{{ __('Total Return Amount') }} : {{ currency_format($total_return_amount, currency: business_currency()) }}
{{ __('Payable Amount') }} : {{ currency_format($sale->totalAmount, currency: business_currency()) }}
{{ __('Paid Amount') }} : {{ currency_format($sale->paidAmount, currency: business_currency()) }}
{{ __('Due') }} : {{ currency_format($sale->dueAmount, currency: business_currency()) }}
@endif {{-- Payment Info & Signature --}} {{-- SIGNATURE --}} {{-- Warranty Box --}} @if ((get_business_option('business-settings')['show_warranty'] ?? 0) == 1)
@if ((get_business_option('business-settings')['show_warranty'] ?? 0) == 1) {{ get_business_option('business-settings')['warranty_void_label'] ?? '' }} - @endif {{ get_business_option('business-settings')['warranty_void'] ?? '' }}
@endif
@endsection