@extends('admin.layouts.app') @section('title', 'Reporting') @section('content_header')

Reporting

@stop @section('content') @component('components.card', ['title' => 'Snooker Reporting'])
@csrf
Cr. Customer(s) of Month({{ $mth_name }})
@php $is_record_empty = true; $remaining_credit_amount = $tot_prev_cr_amount = $tot_dr_paid = $tot_new_cr_amount = 0; @endphp @foreach ($_customers as $k => $customer) @if ($customer->balances->isNotEmpty() && $customer->created_at->lte(now()->parse($y . '-' . $m . '-01')->endOfMonth())) @php $is_record_empty = false; @endphp @php // public const PAYMENT_TYPE_NOT_INITIATED = 0; // public const PAYMENT_TYPE_CASH = 1; // public const PAYMENT_TYPE_CREDIT = 2; $customer_balances = $customer->balances; $customer_transactions = $customer->transactions; $day_before_today_customer_balance = $customer_balances->where('created_at', '<', now()->today())->where('type',App\Models\CustomerBalance::TYPE_CREDIT)->first()?->balance ?? 0; //amt to be paid $day_before_today_balance_cleared = $customer_balances->where('created_at', '<', now()->today())->where('type',App\Models\CustomerBalance::TYPE_DEBIT)->sum('amount'); $todays_balances = $customer_balances->whereBetween('created_at', [now()->startOfDay(), now()->endOfDay()]); $today_balances_credit = $todays_balances->where('type', App\Models\CustomerBalance::TYPE_CREDIT)->sum('amount'); $todays_discount = $customer_transactions->where('payment_type', 2)->whereBetween('created_at', [now()->startOfDay(), now()->endOfDay()])->sum('discount'); $todays_transaction = empty($todays_discount) ? $today_balances_credit : "$today_balances_credit (discount(Nrs $todays_discount))"; $today_balances_cleared = $todays_balances->where('type', App\Models\CustomerBalance::TYPE_DEBIT)->sum('amount'); @endphp @php /* $customer_balances = $customer_balances->first(); $dr_amount_paid = $new_cr_amount = 0; if(empty($customer_balances)){ $prev_cr_amount = 0; }elseif ($customer_balances->type == 2) { $prev_cr_amount = $customer_balances->amount + $customer_balances->balance; $dr_amount_paid = $customer_balances->amount; }elseif($customer_balances->type == 1){ $prev_cr_amount = $customer_balances->amount + $customer_balances->balance; $new_cr_amount = $customer_balances->amount; } */ $tot_prev_cr_amount += $customer_balances->first()->balance; $tot_dr_paid += $customer_balances->where('type',2)->sum('amount'); $tot_new_cr_amount += $today_balances_credit; @endphp @endif @endforeach @if ($is_record_empty) @endif {{-- --}}
Sn Customer Previous Cr. Amount Previous Cr. Amount Paid Todays Cr. Amount Remaining Cr. Amount
{{ ++$k }} {{ $customer->name }}Nrs {{ $day_before_today_customer_balance }} Nrs {{ $day_before_today_balance_cleared }} Nrs {{ $todays_transaction }} Nrs {{ $customer_balances->first()->balance }}
No Customer Found
Total Credit Remaining : Nrs {{ $remaining_credit_amount }}
@endcomponent @stop @section('css') @stop @section('js') @stop