@extends('backend.layouts.master') @section('section-title', 'Purchase') @section('page-title', 'Purchase List') @if (check_permission('purchase.create')) @section('action-button') Add Purchase @endsection @endif @push('css') @endpush @section('content')
@php $products = App\Models\Product::get(); @endphp
Reset Print
{{-- --}} @php $total_paid = 0; $total_amt = 0; $total_due = 0; $total_stock = 0; @endphp @forelse($purchases as $data) @php $total_paid += $data->total_paid; $total_amt += $data->total_amount; $total_due += $data->total_due; // dd($data); // if($data->status == 2){ $purchase_item = App\Models\PurchaseItem::where( 'purchase_id', $data->id, )->first(); $purchase_items = App\Models\PurchaseItem::where( 'purchase_id', $data->id, )->get(); $total_stock += App\Models\PurchaseItem::where('purchase_id', $data->id)->sum( 'main_qty', ); $pur_qty = App\Models\PurchaseItem::where('purchase_id', $data->id)->sum( 'main_qty', ); $total_qty = 0; foreach ($purchase_items as $item) { $item = App\Models\PurchaseItem::where('id', $item->id)->first(); $product = App\Models\Product::where('id', $item->product_id) ->with('unit.related_unit') ->first(); $sub_qty = $item->sub_qty ?? 0; $related_value = $product->unit->related_value; // main_qty + sub_qty convert to main unit $total_main = $item->main_qty * $related_value + $sub_qty; $total_qty += $total_main; } $sto_qty = App\Models\PurchaseItem::where('purchase_id', $data->id)->sum( 'stock_qty', ); $stock_in = (float) $total_qty; $available = (float) $sto_qty; @endphp {{-- @if (env('APP_IMEI') == 'yes') @else --}} {{-- @endif --}} {{-- --}} {{-- delete modal --}} @csrf @method('DELETE') @empty @endforelse
Purchase Date Purchase No Branch Product Supplier Creator Total Amount Total Paid Total Due Return Amount Status Action
{{ $data->date }} {{ $data->purchase_no }} {{ $data->branch?->name }}{{ $purchase_item->product?->name }} @foreach ($purchase_items as $item) @php $product = App\Models\Product::where('id', $item->product_id) ->with('unit.related_unit') ->first(); if ($product->unit->related_unit == null) { $qty = $item->actual_main . ' ' . $product->unit->name; } else { $sub_qty = $item->actual_sub == null ? 0 : $item->actual_sub; $qty = $item->actual_main . ' ' . $product->unit->name . ' ' . $sub_qty . ' ' . $product->unit->related_unit->name; } @endphp
  • @if ($data->status == 2) {{ $item->product?->name }} @if (env('APP_SC') == 'yes') @if ($item->product_variation_id != null) ({{ $item->product_variation?->size?->size }}-{{ $item->product_variation?->color?->color }}) @endif @endif @else {{ $item->product?->name }} @if ($item->is_return == 1) Return @endif @if (env('APP_SC') == 'yes') @if ($item->product_variation_id != null) ({{ $item->product_variation?->size?->size }}-{{ $item->product_variation?->color?->color }}) @endif @endif @endif ({{ $qty }})
@endforeach
{{ $data->supplier?->name }} {{ $data->user->name }} {{ $data->total_amount }} {{ $data->total_paid }} {{ $data->total_due }}{{ $data->return_amount }} @if ($data->status == 0) Due @elseif($data->status == 1) Paid @elseif($data->status == 2) Returned @endif
No Purchase Found
Total: {{ number_format($total_stock, 0) }}pcs {{ number_format($total_amt, 2) }} {{ number_format($total_paid, 2) }} {{ number_format($total_due, 2) }}
{{ $purchases->onEachSide(1)->links() }}
@endsection