@props(['user', 'whatsappGatewayDisabled']) @php /* $userCustomer = $user->user_customer; $paymentWithPartialStatus = $userCustomer->payments->where('reconciliation_status', 'partial'); $totalCustomerPaid = $paymentWithPartialStatus->sum('amount'); $totalCustomerTax = $paymentWithPartialStatus->sum('tax'); $totalCustomerDiscount = $paymentWithPartialStatus->sum('discount'); $totalCustomerRefunded = $paymentWithPartialStatus->sum('refunded_amount'); $netCustomerPaid = $totalCustomerPaid - $totalCustomerRefunded; $totalCustomerBill = ($user->invoices->where('status', '!=', 'paid')->sum('amount') + $totalCustomerTax) - $totalCustomerDiscount - $netCustomerPaid; */ $userCustomer = $user->user_customer; $userPayments = \App\Models\Billings\Payment::where('user_customer_id', $userCustomer->id)->get(); $totalCustomerPaid = $userPayments->sum('amount'); $totalCustomerRefunded = $userPayments->sum('refunded_amount'); $netCustomerPaid = $totalCustomerPaid - $totalCustomerRefunded; $totalCustomerTax = $userCustomer->invoices->sum('tax'); $totalCustomerDiscount = $userCustomer->invoices->sum('discount'); $totalCustomerAmount = $userCustomer->invoices->sum('amount'); $totalCustomerBill = (($totalCustomerAmount - $totalCustomerDiscount) + $totalCustomerTax) - $netCustomerPaid; @endphp {!! trans('billing.total-bills') !!}: @moneyIDR($totalCustomerBill) @php $invoices = \App\Models\Billings\Invoice::where('status', '!=','unpaid')->latest()->get(); $dayReminder = \Carbon\Carbon::parse($invoices->first()->due_date)->subDays(\App\Models\WhatsappGateway\WhatsappGatewayGeneral::first()->remaining_day); @endphp @if(!$whatsappGatewayDisabled && $invoices->count() && \Carbon\Carbon::now()->gte($dayReminder) && $user->user_address->phone) @endif