@extends('admin.layouts.app') @section('title', 'Reporting') @section('content_header')
Sn | Customer | Previous Cr. Amount | Previous Cr. Amount Paid | Todays Cr. Amount | Remaining Cr. Amount |
---|---|---|---|---|---|
{{ ++$k }} | {{ $customer->name }} | @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'); @endphpNrs {{ $day_before_today_customer_balance }} | Nrs {{ $day_before_today_balance_cleared }} | Nrs {{ $todays_transaction }} | Nrs {{ $customer_balances->first()->balance }} |
No Customer Found |