@if ($overviewBond['bond'])
@if (!$overviewBond['print'] && $overviewBond['bond']->post_status == false) @can('warehouses-salesInvoices-edit') @lang('general.edit') @endcan @endif
@lang('warehouses/sales-invoices/show.invoice_number') :

{{ $overviewBond['bond']->bond_number }}

@lang('warehouses/sales-invoices/show.invoice_type') :

{{ $overviewBond['bond']->type_as_text }}

@lang('warehouses/sales-invoices/show.branch'):

{{ $overviewBond['bond']->branch->name }}

@lang('warehouses/sales-invoices/show.date'):

{{ $overviewBond['bond']->date }}

@lang('warehouses/sales-invoices/show.client'):

{{ $overviewBond['bond']->client?->name ?? 'نقدي' }}

{{--
@lang('warehouses/sales-invoices/show.client_branch'):

{{ $overviewBond['bond']->client_brnach?->name }}

--}}
@lang('warehouses/sales-invoices/show.required_from') :

{{ $overviewBond['bond']->client_name }}

{{--
@lang('warehouses/sales-invoices/show.client_tax_number') :

{{ $overviewBond['bond']->client?->tax_number }}

--}}
@lang('warehouses/sales-invoices/show.price_type') :

{{ $overviewBond['bond']->price_type?->name }}

@lang('warehouses/sales-invoices/show.payment_method') :

{{ $overviewBond['bond']->selected_payment_way ?? '---' }}

{{--
@lang('warehouses/sales-invoices/show.due_date') :

{{ $overviewBond['bond']->accured_date }}

--}} {{--
@lang('warehouses/sales-invoices/show.delivery_date') :

{{ $overviewBond['bond']->delivered_date }}

--}} {{--
@lang('warehouses/sales-invoices/show.client_phone') :

{{ $overviewBond['bond']->client?->phone_1 ?? '---' }}

--}} {{--
@lang('warehouses/sales-invoices/show.driver') :

{{ $overviewBond['bond']->driver?->name }}

--}} @php $show_cost_centers_on_module = checkIfModuleIsActiveForCostCenters('salesInvoices'); @endphp @if ($show_cost_centers_on_module)
@lang('warehouses/sales-invoices/show.cost_center') :

{{ $overviewBond['bond']->cost_center?->ar_name }}

@endif {{--
@lang('warehouses/sales-invoices/show.client_email') :

{{ $overviewBond['bond']->client?->email ?? '---' }}

--}} {{-- @if ($overviewBond['bond']->client_type == 'receivable')
@lang('warehouses/sales-invoices/show.client_address') : @if ($overviewBond['bond']->client && is_array($overviewBond['bond']->client->address))

@lang('warehouses/sales-invoices/show.city'): {{ $overviewBond['bond']->client->address['city'] ?? '---' }} /

@lang('warehouses/sales-invoices/show.region'):{{ $overviewBond['bond']->client->address['region'] ?? '---' }} /

@lang('warehouses/sales-invoices/show.address'):{{ $overviewBond['bond']->client->address['address'] ?? '---' }}

@else '---' @endif
@endif --}}

@lang('warehouses/sales-invoices/show.items')

@can('warehouses-salesInvoices-showSalesPrice') @endcan @can('warehouses-salesInvoices-showSalesPrice') @endcan @can('warehouses-salesInvoices-showSalesPrice') @endcan @php $total_amount_before_normal_discounts = 0; $total_extra_discounts = 0; $tax_amounts_total = 0; $client_discount = 0; @endphp @foreach ($overviewBond['bond']->items as $item) @php $total_amount_before_normal_discounts += $item->price_after_discount * $item->quantity; $total_extra_discounts += $item->extra_discount_amount ? $item->extra_discount_amount * $item->quantity : 0; $client_discount_value = ($overviewBond['bond']->client_discount_ratio / 100) * $item->total_final_price; $client_discount += $client_discount_value; $tax_amount = $item->tax_ratio ? ($item->total_final_price - $client_discount_value) * ($item->tax_ratio / 100) : 0; $tax_amounts_total += $tax_amount; @endphp @can('warehouses-salesInvoices-showSalesPrice') @endcan @can('warehouses-salesInvoices-showSalesPrice') @endcan @can('warehouses-salesInvoices-showSalesPrice') @endcan @if ($item->bonus) @can('warehouses-salesInvoices-showSalesPrice') @endcan @can('warehouses-salesInvoices-showSalesPrice') @endcan @can('warehouses-salesInvoices-showSalesPrice') @endcan @endif @endforeach
@lang('warehouses/sales-invoices/show.unit_code') @lang('warehouses/sales-invoices/show.item_description') @lang('warehouses/sales-invoices/show.unit') @lang('warehouses/sales-invoices/show.quantity') @lang('warehouses/sales-invoices/show.unit_price')@lang('warehouses/sales-invoices/show.discount_value') @lang('warehouses/sales-invoices/show.total_price') @lang('warehouses/sales-invoices/show.tax_percentage') @lang('warehouses/sales-invoices/show.total') @lang('warehouses/sales-invoices/show.expiration_date') @lang('warehouses/sales-invoices/show.serial_numbers') @lang('warehouses/sales-invoices/show.comments')
{{ $item->barcode->number }} {{ $item->print_name ?: $item->barcode->ar_name }} {{ $item->barcode->unit->name }} {{ dn($item->quantity) }}{{ dn($item->price) }}{{ dn($item->total_discounts) }}{{ dn($item->total_final_price) }}{{isset($item->tax_ratio) ? $item->tax_ratio . '%' : '---' }} {{ dn($item->total_final_price + $tax_amount) }} {{ $item->expire_date }} @if (is_array($item->serial_items) && count($item->serial_items))
@csrf
@else --- @endif
{{ $item->notice }}
{{ $item->barcode->number }} {{ $item->barcode->ar_name }} {{ $item->barcode->unit->name }} {{ dn($item->bonus) }}{{ dn(0) }}{{ dn(0) }}{{ dn(0) }}{{ dn(0) }}{{ dn(0) }}{{ $item->expire_date }} --- {{ $item->notice }}
@if ($overviewBond['bond']->expenses->isNotEmpty())

@lang('warehouses/sales-invoices/show.expenses')

@php $total = 0; @endphp @foreach ($overviewBond['bond']->expenses as $item) @php $total+= $item->amount; @endphp @endforeach
@lang('warehouses/sales-invoices/show.expense') @lang('warehouses/sales-invoices/show.value') @lang('warehouses/sales-invoices/show.account')
{{ $item->standard_expenses->name }} {{ dn($item->amount) }} {{ $item->standard_expenses->account->name }}
@lang('warehouses/sales-invoices/show.total') {{ dn($total) }}
@endif
@lang('warehouses/sales-invoices/show.cash_invoice')
@lang('warehouses/sales-invoices/show.invoice_number') :

{{ $overviewBond['bond']->bond_number }}

@lang('warehouses/sales-invoices/show.branch') :

{{ $overviewBond['bond']->branch->name }}

@lang('warehouses/sales-invoices/show.date') :

{{ $overviewBond['bond']->date }}

@lang('warehouses/sales-invoices/show.client') :

{{ $overviewBond['bond']->client?->name }}

@lang('warehouses/sales-invoices/show.customer_tax_number') :

{{ $overviewBond['bond']->client?->tax_number }}

@php $debit_sum = 0; $credit_sum = 0; $salesInvoiceService = new App\Services\Tenant\Warehouses\SalesInvoiceService(); $entry_accounts = null; $entry_error_message = ''; $automated_receipt_entry = null; try { $entry_accounts = $salesInvoiceService->buildBondAsEntry($overviewBond['bond']); $automated_receipt_entry = App\Models\Accounting\AutomatedEntry::with( 'items', 'items.account', 'items.receivable_account', ) ->where('builder_model', 'SalesInvoice') ->where('builder_model_id', $overviewBond['bond']->id) ->first(); } catch (\Throwable $th) { $entry_error_message = 'لا يمكن بناء القيد, قد يكون عائلات المواد غير مرتبطة بحسابات على الشجرة !'; } @endphp @if ($entry_accounts) @if ($entry_accounts['debit_accounts']) @foreach ($entry_accounts['debit_accounts'] as $debit_key => $accounts_list) @foreach ($accounts_list as $debit_item_id => $account_info) @php $debit_sum+= $account_info['amount']; @endphp @endforeach @endforeach @endif @if ($entry_accounts['credit_accounts']) @foreach ($entry_accounts['credit_accounts'] as $credit_key => $accounts_list) @foreach ($accounts_list as $credit_item_id => $account_info) @php $credit_sum+= $account_info['amount']; @endphp @endforeach @endforeach @endif @if ($automated_receipt_entry) @foreach ($automated_receipt_entry->items as $automated_item) @endforeach @php $credit_sum += $automated_receipt_entry->amount; $debit_sum += $automated_receipt_entry->amount; @endphp @endif @else @endif
@lang('warehouses/sales-invoices/show.account_receivable') @lang('warehouses/sales-invoices/show.debtor') @lang('warehouses/sales-invoices/show.creditor') @lang('warehouses/sales-invoices/show.cost_center') @lang('warehouses/sales-invoices/show.description')
{{ $account_info['account']->name }} {{ dn($account_info['amount']) }} --- ---
{{ $account_info['account']->name }} --- {{ dn($account_info['amount']) }} ---
{{ $automated_item->account ? $automated_item->account->name : $automated_item->receivable_account->name }} {{ $automated_item->debit ? dn($automated_item->debit) : '---' }} {{ $automated_item->credit ? dn($automated_item->credit) : '---' }} --- {{ $automated_receipt_entry->notice }}
{{ $entry_error_message }}
{{ dn($debit_sum) }} {{ dn($credit_sum) }}

@lang('warehouses/sales-invoices/show.comments') :
{{ $overviewBond['bond']->notice }}


@lang('warehouses/sales-invoices/show.goods_received')

@php $signatures = App\Models\Warehouses\WarehousesSignature::byType('sales_invoice') ->active() ->get(); @endphp @if (count($signatures))

@lang('warehouses/sales-invoices/show.signature')

@foreach ($signatures as $signature)

{{ $signature->label }}

----------------------------

@endforeach
@endif
@php $total_after_extra_discount = $total_amount_before_normal_discounts - $total_extra_discounts - $client_discount; @endphp
@can('warehouses-salesInvoices-showSalesPrice')
@lang('warehouses/sales-invoices/show.total_before_additional_discount') : {{ dn($total_amount_before_normal_discounts) }}
@endcan
@lang('warehouses/sales-invoices/show.additional_discount') : {{ dn($total_extra_discounts) }}
@lang('warehouses/sales-invoices/show.client_discount') : {{ dn($client_discount) }}
@can('warehouses-salesInvoices-showSalesPrice')
@lang('warehouses/sales-invoices/show.total_after_additional_discount'): {{ dn($total_after_extra_discount) }}
@endcan
@lang('warehouses/sales-invoices/show.tax') {{ dn($tax_amounts_total) }}
@php $expenses_amount = $overviewBond['bond']->expenses->sum('amount'); @endphp @lang('warehouses/sales-invoices/show.expenses_amount') {{ dn($expenses_amount) }}
@can('warehouses-salesInvoices-showSalesPrice')
@php $the_total_number = $total_amount_before_normal_discounts - $total_extra_discounts - $client_discount + $tax_amounts_total + $expenses_amount; @endphp @lang('warehouses/sales-invoices/show._total') {{ dn($the_total_number) }}
@endcan

@lang('warehouses/sales-invoices/show.recipient_name')

@lang('warehouses/sales-invoices/show.recipient_signature')

@php if (! function_exists('arabicTafqeet')) { function arabicTafqeet($value) { return \Tafqeet::inArabic( number_format((float) str_replace(',', '', $value), 3, '.', ''), 'jod' ); } } @endphp
{{ arabicTafqeet(dn($the_total_number)) }}
{{--
{!! QrCode::size(80)->generate( route('tenant.show-document', ['type' => 'sales-invoice', 'id' => $overviewBond['bond']->id]), ) !!}
Misk
--}}
@php $svgPath = storage_path( 'app/fotara/images/sales_invoice_' . $overviewBond['bond']->id . '_qr.svg', ); @endphp @if (file_exists($svgPath))
{!! file_get_contents($svgPath) !!}
Posted To Fotara
@else
{!! QrCode::size(80)->generate( route('tenant.show-document', ['type' => 'sales-invoice', 'id' => $overviewBond['bond']->id]), ) !!}
Misk
@endif

@lang('accounting/show.attachments')

@foreach ($overviewBond['bond']->attachments as $attachment)

{{ $attachment->file }}

@csrf
@endforeach
@if (Session::get('print_data')['under_tax']) @lang('warehouses/sales-invoices/show.all_prices_above_subject_to_general_tax') @endif
@endif @push('script') @endpush