@extends('layouts.app') @section('title', __('report.receipt_payment_summary')) @section('content')

{{ __('report.receipt_payment_summary')}}

@component('components.filters', ['title' => __('report.filters')]) {!! Form::open(['url' => '#','method' => 'get','id' => 'sell_payment_report_form']) !!}
{!! Form::label('location_id', __('purchase.business_location').':') !!}
{!! Form::select('location_id',$business_locations,request()->location_id, ['class'=>'form-control select2','style'=>'width:100%','placeholder'=>__('messages.all')]) !!}
{!! Form::label('spr_date_filter', __('report.date_range') . ':') !!} {!! Form::text('date_range',request()->date_range, ['placeholder'=>__('lang_v1.select_a_date_range'), 'class'=>'form-control', 'id'=>'sell_list_filter_date_range', 'readonly']) !!}
{!! Form::close() !!} @endcomponent
@component('components.widget',['class'=>'box-primary']) @php $totalsIncome = []; $totalsExpense = []; $grandTotalIncome = 0; $grandTotalExpense = 0; foreach($used_payment_types as $method_label){ $totalsIncome[$method_label]=0; $totalsExpense[$method_label]=0; } $incomeRows=[]; $openingRow=['Opening Balance']; foreach($used_payment_types as $method_label){ $opening=openingBalance($business_id,$location_id,$method_label,$start_date,['sell']) - openingBalance($business_id,$location_id,$method_label,$start_date,['expense','purchanse']); $totalsIncome[$method_label]+=$opening; $grandTotalIncome+=$opening; $openingRow[]=$opening; } $incomeRows[]=$openingRow; foreach($customers as $customer){ $row_total=0; $row=[]; foreach($used_payment_types as $method_label){ $amount=getPaymentSum($business_id, $start_date, $end_date, $customer->id, $location_id, $method_label, ['sell'] ) ?? 0; $row[]=$amount; $row_total+=$amount; } if($row_total>0){ foreach($row as $k=>$val){ $totalsIncome[$used_payment_types[$k]] += $val; $grandTotalIncome += $val; } $incomeRows[]=[ $customer->contact_type=='business' ? $customer->supplier_business_name : $customer->name, ...$row]; } } $expenseRows=[]; foreach($suppliers as $supplier){ $row_total=0; $row=[]; foreach($used_payment_types as $method_label){ $amount = getPaymentSum( $business_id, $start_date, $end_date, $supplier->id, $location_id, $method_label, ['purchase']) ?? 0; $row[] = $amount; $row_total += $amount; } if($row_total>0){ foreach($row as $k=>$val){ $totalsExpense[$used_payment_types[$k]] += $val; $grandTotalExpense += $val; } $expenseRows[]=[$supplier->contact_type=='business'? $supplier->supplier_business_name: $supplier->name,...$row]; } } foreach($categories as $cat){ $row_total=0; $row=[]; foreach($used_payment_types as $method_label){ $amount=getPaymentSum( $business_id, $start_date, $end_date, '', $location_id, $method_label, ['expense'], $cat->id) ?? 0; $row[]=$amount; $row_total+=$amount; } if($row_total>0){ foreach($row as $k=>$val){ $totalsExpense[$used_payment_types[$k]] += $val; $grandTotalExpense += $val; } $expenseRows[]=[$cat->name, ...$row]; } } $closingRow=['Closing Balance']; foreach($used_payment_types as $method_label){ $closing = $totalsIncome[$method_label]-$totalsExpense[$method_label]; $totalsExpense[$method_label] += $closing; $grandTotalExpense += $closing; $closingRow[] = $closing; } //$expenseRows[] = $closingRow; $maxRows = max(count($incomeRows),count($expenseRows)); @endphp

{{ Session::get('business.name') }}

Receipt & Payment Report

@if(!empty($start_date) && !empty($end_date)) From: {{ \Carbon\Carbon::parse($start_date)->format('m/d/Y') }}   To: {{ \Carbon\Carbon::parse($end_date)->format('m/d/Y') }} @else Date: {{ \Carbon\Carbon::today()->format('m/d/Y') }} @endif



@foreach($used_payment_types as $method_label) @endforeach @foreach($used_payment_types as $method_label) @endforeach @for($i=0;$i<$maxRows;$i++) @if(isset($incomeRows[$i])) @foreach(array_slice($incomeRows[$i],1) as $val) @endforeach @else @foreach($used_payment_types as $m) @endforeach @endif @if(isset($expenseRows[$i])) @foreach(array_slice($expenseRows[$i],1) as $val) @endforeach @else @foreach($used_payment_types as $m) @endforeach @endif @endfor @foreach($used_payment_types as $method_label) @endforeach @foreach(array_slice($closingRow,1) as $val) @endforeach @foreach($used_payment_types as $method_label) @endforeach @foreach($used_payment_types as $method_label) @endforeach
Income Expense
Receipt Detail{{ $payment_types[$method_label] ?? '' }}@lang('report.particular'){{ $payment_types[$method_label] ?? '' }}
{{ $incomeRows[$i][0] }}{{ $val?number_format($val,2):'-' }}{{ $expenseRows[$i][0] }}{{ $val?number_format($val,2):'-' }}
Closing Balance{{ $val?number_format($val,2):'-' }}
Total{{ number_format($totalsIncome[$method_label],2) }}Total{{ number_format($totalsExpense[$method_label],2) }}
Sub Total {{ number_format($grandTotalIncome,2) }} Sub Total {{ $grandTotalExpense }}
@endcomponent
@endsection @section('javascript') @endsection