@extends('layouts.app') @section('title') {{ __('lang.schedule_manage') }} @stop @section('top-bar') @include('includes.top-bar') @stop @section('left-sidebar') @include('includes.left-sidebar') @stop @php $sell = App\Models\Sell::find($items['sells_id']); $common_helper = \App\Helpers\CommonHelper::class; $breadcrumbMainIcon = 'fas fa-dolly'; $currency_symbol = config('settings.is_code') == 'code' ? config('settings.currency_code') : config('settings.currency_symbol'); $general_letters = $common_helper::generalLetterBranchWiseList($items['sell']->branch_id,'schedule',$items['sell']->is_transfered); $surchargeCheck = $sell->branch->enable_surcharges; $fileMergeCheck = $sell->branch->file_merge; $isTransfered = $sell->is_transfered; $all = config('role_manage.Sell.All'); $create = config('role_manage.Sell.Create'); $delete = config('role_manage.Sell.Delete'); $edit = config('role_manage.Sell.Edit'); $CreateVoidReceipt = config('role_manage.ReceiptVoided.Create'); $pdf = config('role_manage.Sell.Pdf'); $permanently_delete = config('role_manage.Sell.PermanentlyDelete'); $restore = config('role_manage.Sell.Restore'); $show = config('role_manage.Sell.Show'); $trash_show = config('role_manage.Sell.TrashShow'); $transfer = config('role_manage.SellTransfer.Create'); $company_settings_info = \App\Models\Setting::where('settings_name', 'Company Setting Module')->first(); $company_setting = json_decode($company_settings_info->content, true); $possession= in_array('maintenance_module', $company_setting ?? []) ; $statementExcel = config('role_manage.StatementExcel.Show'); $is_file_Receiving_create = config('role_manage.FileReceiving.Create'); $is_receipt_create = config('role_manage.Receipts.Create'); $common = new App\Models\Common(); $system_settings = CommonHelper::getSystemPermissions(); $cheaque_no = $system_settings['statement_booking_pdf']['show_cheque_no'] ?? '1'; $sell =$items['sell']; $is_official = CommonHelper::getBranchSettings($items['branch']->id,'is_unofficial'); if(isUnofficialNewStructure($sell->branch_id)){ $is_official = 0; } $is_unofficial_schedule = CommonHelper::getBranchSettings($items['branch']->id, 'is_unofficial_schedule') == 'on' ? 'checked' : '' ; function check_permission($branch_id) { $official_setting = CommonHelper::getBranchSettings($branch_id, 'is_unofficial'); return $official_setting; } function surchargeAmount($earlier_date = null, $schedule_date, $payable_amount, $sell_id) { // $earlier = new DateTime(! empty(explode(',', $earlier_date)[0]) && explode(',', $earlier_date)[0] != ' - ' ? explode(',', $earlier_date)[0] : 'today'); $earlier = new DateTime('today'); $later = new DateTime($schedule_date); if ($earlier > $later) { $abs_diff = $later->diff($earlier)->format('%a'); $dayCount = intval($abs_diff); $percentage = App\Models\Sell::find($sell_id)->branch->percentage; $fixedAmount = App\Models\Sell::find($sell_id)->branch->fixed_amount; return !empty($percentage) && $percentage != 0.0 ? ($payable_amount * $percentage * $dayCount) / 100 : $dayCount * $fixedAmount; } return 0; } function showPaidSurchargeAmount($schedule_id) { $paidSurchargeAmount = 0; $actualPaidAmount = App\Models\ActualReceivedItem::where('schedule_receivable_id', $schedule_id)->first()->surcharge_amount; $outStandingSurcharge = App\Models\Surcharge::where('schedule_receivable_id', $schedule_id) ->select(DB::raw('Sum(paid_amount) as paid_amount')) ->groupBy('schedule_receivable_id') ->first(); // dd($outStandingSurcharge->paid_amount); // if($actualPaidAmount->surcharge_amount > 0) { // $paidSurchargeAmount = $actualPaidAmount; // } else if ($outStandingSurcharge->paid_amount > 0) { // $paidSurchargeAmount = $outStandingSurcharge; // } return $outStandingSurcharge->paid_amount; } function receipt_no($id, $receipt_id) { $receipt_items = App\Models\ActualReceivedItem::where(['schedule_receivable_id' => $id, 'id' => $receipt_id])->first(); $receipt = App\Models\ActualReceived::find($receipt_items->actual_received_id)->receipt_no; return $receipt; } function count_days($earlier_date, $schedule_date) { // dd($earlier_date,$schedule_date); $earlier = new DateTime($earlier_date); $later = new DateTime($schedule_date); if ($earlier > $later) { $abs_diff = $later->diff($earlier)->format('%a'); $dayCount = intval($abs_diff); } return $dayCount; } @endphp @section('content')
@php $customerDetail = App\Models\CustomerDetail::where('customer_id', $items['customer']->id)->get(); @endphp

Receivable Schedule Payments ( {{ $items['branch']->name ?? '-' }} || {{ $items['customer']->name ?? '-' }} @php if (!empty($customerDetail)) { foreach ($customerDetail as $key => $value) { echo ' / ' . $value->name; } } @endphp || {{ $items['sell']->registration_no ?? '-' }} || {{ $items['product']->flat_size . ' ' . $items['product']->size_in ?? '-' }} )

@if ($items['sell']->is_transfered == null) add Add Schedule @endif @if($items['sell']->is_possession && $possession && $items['sell']->status=='FULL PAID') Marked Possession @elseif(!$items['sell']->is_possession && $possession && $items['sell']->status=='FULL PAID') Mark Possession @endif @if (!count($items['ScheduleReceivable']) > 0 && count($items['sell']->branch->paymentPlans) > 0)
@endif @if(count($general_letters) > 0 && ($items['sell']->status!= 'BUY BACK' && $items['sell']->status != 'REFUNDED'))
    @include('admin.partials.general-letters-list',['general_letters'=>$general_letters])
@endif
    @include('admin.partials.sell-print-list',['item'=>$item])
@if (count($items['ScheduleReceivable']) == 0) add Add Payment Schedule @endif @if ($surchargeCheck) Manage Surcharge payment @endif @if (count($items['ScheduleReceivable']) > 0) @if ($isTransfered != 1) mode_edit Edit Payment Schedule @endif @endif  Back
@if($sell->is_transfered == 1)

TRANSFERED

@elseif($sell->status == 'CANCELLED' || $sell->status == 'BLOCKED')

{{ $sell->status }}

@endif
@if ($items['sell']->is_transfered == null)
@endif
@if ($is_official) @endif @if ($is_official) @endif @if ($surchargeCheck) @endif @php $id = 1; $comulative_payable_amount = 0; $total_due_amount = 0; $total_payable_amount = 0; $total_receieved_amount = 0; $total_unofficial_receieved_amount = 0; $total_comulative_payable_amount = 0; $total_unofficial_payable_amount = 0 @endphp @if (count($items['ScheduleReceivable']) > 0) {{-- Down Payment --}} @foreach ($items['ScheduleReceivable'] as $ScheduleReceivable) @php $receivedDate = reset(explode(',', $ScheduleReceivable->received_date)); $total_payable_amount = ($ScheduleReceivable->payable_amount +$ScheduleReceivable->unofficial_payable_amount); $total_received_amount = ($ScheduleReceivable->payment_received_amount + $ScheduleReceivable->unofficial_payment_received_amount); $comulative_payable_amount = $total_payable_amount - $total_received_amount; $total_due_amount += $comulative_payable_amount; $is_term_paid = $common->isTermPaid($ScheduleReceivable); $is_unofficial_term_paid = $common->isTermUnofficialPaid($ScheduleReceivable); @endphp @if ($is_official) @endif @if($ScheduleReceivable->show_date == 1) @else @endif @php $received_amount = $ScheduleReceivable->payment_received_amount; if(isUnofficialNewStructure($sell->branch_id)){ $received_amount= $ScheduleReceivable->payment_received_amount + $ScheduleReceivable->unofficial_payment_received_amount; } @endphp @if ($is_official) @endif @if ($surchargeCheck) @php $surcharge_amount = ''; $surcharge_paid_amount = ''; $total_diffDays = 0; $fixed_amount = App\Models\Sell::find($items['sells_id'])->branch->fixed_amount; $percentage = App\Models\Sell::find($items['sells_id'])->branch->percentage; $grace_surcharge_days = CommonHelper::getBranchSettings($items['branch']->id, 'surcharge_grace_days') ?? 0; $doc = date_create(date('Y-m-d')); $schedule_date = date_create($common->db_date_formatter($ScheduleReceivable->schedule_date)); $a=date_diff($schedule_date,$doc); $total_diffDays = $a->format("%R%a"); $total_diffDays = $total_diffDays - $grace_surcharge_days ; if ($percentage != '' && $percentage != 0.00) { $total_remaining_surcharge = round($comulative_payable_amount * $percentage * $total_diffDays / 100); }else { $total_remaining_surcharge = round($fixed_amount * $total_diffDays); } // dd($total_remaining_surcharge); foreach ($ScheduleReceivable->actualReceivedItems as $key => $sucrcharge_amount) { $surcharge_amount .= $sucrcharge_amount->actual_surcharge_amount . ',' . "\r\n"; $surcharge_paid_amount .= $sucrcharge_amount->surcharge_amount . ',' . "\r\n"; } @endphp @endif @php $id++; $total_payable_amount += $ScheduleReceivable->payable_amount; $total_unofficial_payable_amount += $ScheduleReceivable->unofficial_payable_amount; $total_receieved_amount += $ScheduleReceivable->receivable_amount; $total_comulative_payable_amount += $comulative_payable_amount; @endphp @endforeach {{-- Down Payment End --}} {{-- Schedule Receivable NoDate Start --}} @if(count($items['ScheduleReceivableNoDate']) > 0 && $items['date_permission'] == 0) @foreach ($items['ScheduleReceivableNoDate'] as $ScheduleReceivable) @php $total_payable_amount = ($ScheduleReceivable->payable_amount +$ScheduleReceivable->unofficial_payable_amount); $total_received_amount = ($ScheduleReceivable->payment_received_amount + $ScheduleReceivable->unofficial_payment_received_amount); $comulative_payable_amount = $total_payable_amount - $total_received_amount; $total_due_amount += $comulative_payable_amount; @endphp @php $received_amount = $ScheduleReceivable->payment_received_amount; if(isUnofficialNewStructure($sell->branch_id)){ $received_amount= $ScheduleReceivable->payment_received_amount + $ScheduleReceivable->unofficial_payment_received_amount; } @endphp @if ($surchargeCheck) @php $surcharge_amount = ''; $surcharge_paid_amount = ''; $total_diffDays = 0; $fixed_amount = App\Models\Sell::find($items['sells_id'])->branch->fixed_amount; $percentage = App\Models\Sell::find($items['sells_id'])->branch->percentage; $grace_surcharge_days = CommonHelper::getBranchSettings($items['branch']->id , 'surcharge_grace_days') ?? 0; $doc = date_create(date('Y-m-d')); $schedule_date = date_create($common->db_date_formatter($ScheduleReceivable->schedule_date)); $a=date_diff($schedule_date,$doc); $total_diffDays = $a->format("%R%a"); $total_diffDays = $total_diffDays - $grace_surcharge_days; if ($percentage != '' && $percentage != 0.00) { $total_remaining_surcharge = round($comulative_payable_amount * $percentage * $total_diffDays / 100); }else { $total_remaining_surcharge = round($fixed_amount * $total_diffDays); } // dd($total_remaining_surcharge); foreach ($ScheduleReceivable->actualReceivedItems as $key => $sucrcharge_amount) { $surcharge_amount .= $sucrcharge_amount->actual_surcharge_amount . ',' . "\r\n"; $surcharge_paid_amount .= $sucrcharge_amount->surcharge_amount . ',' . "\r\n"; } @endphp @php $id++; $total_payable_amount += $ScheduleReceivable->payable_amount; $total_receieved_amount += $ScheduleReceivable->receivable_amount; $total_comulative_payable_amount += $comulative_payable_amount; @endphp @endif @endforeach @endif {{-- Schedule Receivable NoDate End --}} @php $total_payable_amount = $sell->ScheduleReceivableWithoutDiscount->sum('payable_amount'); $total_receieved_amount = $sell->ScheduleReceivableWithoutDiscount->sum('payment_received_amount'); if(isUnofficialNewStructure($sell->branch_id)){ $total_receieved_amount += $sell->ScheduleReceivableWithoutDiscount->sum('unofficial_payment_received_amount'); } elseif($is_unofficial_schedule) { $total_receieved_amount += $sell->ScheduleReceivableWithoutDiscount->sum('payment_received_amount') + $sell->ScheduleReceivableWithoutDiscount->sum('unofficial_payment_received_amount'); } @endphp @if ($is_official) @endif @if ($is_official) @endif @else @endif @if ($is_official) @endif @if ($is_official) @endif @if ($surchargeCheck) @endif
# Payment {{$is_official ? 'Official': '' }} Payable Amount {{$transaction->systemSettingCurrency()}}Unofficial Payable Amount {{$transaction->systemSettingCurrency()}}Installment Type Schedule Date Received {{$transaction->systemSettingCurrency()}}Unofficial Received {{$transaction->systemSettingCurrency()}}Received Date Outstanding Amount {{$transaction->systemSettingCurrency()}}Surcharge {{$transaction->systemSettingCurrency()}} Surcharge Paid Amount {{$transaction->systemSettingCurrency()}}Reference Action
status == 'BUY BACK' || $item->status == 'REFUNDED') disabled @endif @else @if (App\Models\Common::isTermPaid($ScheduleReceivable) && App\Models\Common::isTermUnofficialPaid($ScheduleReceivable)) disabled @endif @endif /> {{ $id }} {{ $ScheduleReceivable->term }} {{ $transaction->convert_money_format($ScheduleReceivable->payable_amount) }} {{ $transaction->convert_money_format($ScheduleReceivable->unofficial_payable_amount) }} {{ $ScheduleReceivable->installment_repeat ?? ' - ' }} {{ $transaction->date_format($ScheduleReceivable->schedule_date) }} - {{ $transaction->convert_money_format($received_amount) }} {{ $transaction->convert_money_format($ScheduleReceivable->unofficial_payment_received_amount) }} {{ $ScheduleReceivable->already_received_date?? ($transaction->date_format($ScheduleReceivable->payment_last_date) ?? '-') }} {{ $transaction->convert_money_format(abs($comulative_payable_amount)) == '0.0' ? 0 : $transaction->convert_money_format(abs($comulative_payable_amount)) }} @if($total_remaining_surcharge >= 0) @endif @php $ref = ''; if (!empty($ScheduleReceivable->already_received_ref)) { $ref .= $ScheduleReceivable->already_received_ref . ',' . "\r\n"; } if ($ScheduleReceivable->actualReceivedItems->count() > 0) { foreach ($ScheduleReceivable->actualReceivedItems as $key => $value) { if ($value->actualReceived->cheque_no != '' && $value->actualReceived->cheque_no != '0') { $ref .= $value->actualReceived->cheque_no . ',' . "\r\n"; } if ($value->actualReceived->made_of_payment == 'Cash' || $value->actualReceived->made_of_payment == 'cash') { $ref .= 'CASH' . ',' . "\r\n"; } } } $ref = substr($ref, 0, -3); @endphp -
payable_amount == $ScheduleReceivable->receivable_amount || ($ScheduleReceivable->already_received > 0 && $ScheduleReceivable->receivable_amount > 0 && $ScheduleReceivable->already_received == $ScheduleReceivable->receivable_amount)) disabled @endif /> {{ $id }} {{ $ScheduleReceivable->term }} {{ $transaction->convert_money_format($ScheduleReceivable->payable_amount) }} {{ $ScheduleReceivable->installment_repeat ?? ' - ' }} @php if($ScheduleReceivable->schedule_date != '0000-00-00' && $ScheduleReceivable->schedule_date != NULL) { $date = $ScheduleReceivable->show_date ? date(config('settings.date_format'), strtotime($ScheduleReceivable->schedule_date)) : '-' ; } else { $date = '-'; } @endphp {{ $date }} {{ $transaction->convert_money_format($received_amount) }} {{ $ScheduleReceivable->received_date }} {{ $transaction->convert_money_format(abs($comulative_payable_amount)) == '0.0' ? 0 : $transaction->convert_money_format(abs($comulative_payable_amount)) }} @if($total_remaining_surcharge >= 0) @endif @php $ref = ''; if ($ScheduleReceivable->already_received == 1) { $ref .= $ScheduleReceivable->already_received_ref . ',' . "\r\n"; } if ($ScheduleReceivable->actualReceivedItems->count() > 0) { foreach ($ScheduleReceivable->actualReceivedItems as $key => $value) { if ($value->actualReceived->cheque_no != '' && $value->actualReceived->cheque_no != '0') { $ref .= $value->actualReceived->cheque_no . ',' . "\r\n"; } else { $ref .= $value->actualReceived->reference_no . ',' . "\r\n"; } } } $ref = substr($ref, 0, -3); @endphp -
Total {{ $transaction->convert_money_format($total_payable_amount) }} {{ $transaction->convert_money_format($total_unofficial_payable_amount) }} {{ $transaction->convert_money_format($total_receieved_amount) }} {{ $transaction->convert_money_format($total_unofficial_receieved_amount) }} {{ $transaction->convert_money_format($total_comulative_payable_amount) }}
There Has No Received Schedule
# Payment Payable Amount ({{ $currency_symbol }})Unofficial Payable Amount ({{ $currency_symbol }})Installment Type Schedule Date Received Amount ({{ $currency_symbol }})Unofficial Received Amount ({{ $currency_symbol }})Received Date Outstanding Amount ({{ $currency_symbol }})Surcharge {{$transaction->systemSettingCurrency()}} Surcharge Paid {{$transaction->systemSettingCurrency()}}Reference Option

Receipts ( {{ $items['branch']->name }} || {{ $items['customer']->name }} || {{ $items['sell']->registration_no ?? '-' }} )

@if ($surchargeCheck) @endif @php $g_total_received = 0; @endphp @if(count($sell->ActualReceivedItem)>0) @foreach ($sell->ActualReceived as $actual_received ) @php $mode_of_payment = $actual_received->made_of_payment; $schedules = $actual_received->getReceiptSchedules($actual_received->id); $received_amount = $actual_received->actualReceivedItem->sum('received_amount'); $surcharge_amount = $actual_received->actualReceivedItem->sum('surcharge_amount'); $terms = $schedules->implode('term',' , '); if($actual_received->references) { $ref_no = $actual_received->references ?? collect([]); $references = $ref_no->implode('reference', ' , '); } if($cheaque_no){ $reference_no = $references; } else{ $reference_no = $actual_received->cheque_no; $reference_no = (empty($references)) ? $actual_received->cheque_no : $actual_received->cheque_no; } $reference_no .= " ($mode_of_payment) "; $reference_no .= $actual_received->file_received->file_number ??'' ; $g_total_received += ($actual_received->status != 'Void') ? $received_amount : 0; @endphp @if ($surchargeCheck) @endif @endforeach @else @endif @if ($surchargeCheck) @endif
# Receipt No. Payment Received Amount ({{ $currency_symbol }})Surcharge {{$transaction->systemSettingCurrency()}}Date of Collection Mode of Payment Reference No. Head Name Option
{{ $loop->iteration }} {{ $actual_received->receipt_no }} @if($actual_received->status == 'Void') Voided @endif @if($actual_received->is_official ==0)
(Unofficial) @endif @if($actual_received->file_received_returned)
(File Returned) @endif
{{ $terms }} {{ $transaction->convert_money_format($received_amount) }}{{ $transaction->convert_money_format($surcharge_amount) }}{{ $transaction->date_format($actual_received->date_of_collection_new) }} {{ $mode_of_payment }} {{ $reference_no }} {{ $actual_received->dr_head->name }}
{{ $transaction->convert_money_format($g_total_received) }}
There Is No Actual Payment
# Receipt No. Payment Received Amount ({{ $currency_symbol }})Surcharge {{$transaction->systemSettingCurrency()}}Date of Collection Mode of Payment Reference No. Head Name Option
{{-- Status Log Modal --}} @include('admin.sell.partials.status_log_details',['sell'=>$sell]) {{-- Letters Log Modal --}} @include('admin.sell.partials.letters_log_details',['sell'=>$sell])
@stop @push('include-css') @endpush @push('include-js') {{-- All datagrid --}}