Compare commits

..

8 Commits

Author SHA1 Message Date
sharifcse57 4b9c411c3d Working for replicate support as like exchage 2.0 2023-02-24 22:05:13 +06:00
edmondlang 6b5ae9b0b7 export invoice for PAID INVOICE and PENDING PAYMENT 2023-02-24 18:06:39 +08:00
edmondlang eb92a76a0b update invoice search function 2023-02-23 14:53:21 +08:00
edmondlang a1bc3aa652 update PAYMENT AND BILLING invoice per_page to 5 2023-02-21 23:53:49 +08:00
edmondlang e5af2bf171 Merge branch 'auto-generate-invoice' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal 2023-02-21 23:42:58 +08:00
edmondlang 864bbc70b6 update invoice search function 2023-02-21 23:40:02 +08:00
edmondlang c439bb5d61 invoice search function 2023-02-21 23:31:20 +08:00
edmondlang 82b99a40cf update admin payments billing section component 2023-02-21 19:57:08 +08:00
9 changed files with 487 additions and 53 deletions
@@ -0,0 +1,21 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use App\Models\Order;
use Illuminate\Database\Eloquent\Builder;
class OrderMarkingIn implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereHas('owner', function($query) use ($value) {
$query->where('reference', 'LIKE', '%' . $value . '%');
});
}
}
@@ -60,7 +60,15 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
$query = Transaction::query();
$query->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::COMPLETED]);
// paidInvoiceSection
$approvalStatus = ApprovalStatus::COMPLETED;
if ($this->request->route('section') == 'pendingPaymentSection') {
// pendingPaymentSection
$approvalStatus = ApprovalStatus::APPROVED;
}
$query->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [$approvalStatus]);
if($start_date && $end_date) {
$query->whereBetween('updated_at', [
+120
View File
@@ -0,0 +1,120 @@
<?php
namespace App\Models;
use App\Classes\General\Interfaces\Documentable;
use App\Classes\General\Interfaces\Transactionable;
use App\Classes\General\Traits\LogData;
use App\Classes\ValueObjects\Constants\RoleTypes;
use App\Scopes\CustomerBookingsScope;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
/**
* Class Booking
* @package App\Models
*
* @property \App\Models\Company company_id
* @property \App\Models\Bank transferable_bank_id
* @property string marking
* @property string reference
* @property float fix_amount
* @property int convertible_currency_id
* @property int conversion_currency_id
*/
class Booking extends AbstractModel implements Documentable, Transactionable
{
use HasRelationships;
use SoftDeletes;
use LogData;
protected $table = 'bookings';
protected $dates = ['deleted_at'];
/**
* @return BelongsTo
*/
public function company(): BelongsTo
{
return $this->BelongsTo(Company::class, 'company_id')->withTrashed();
}
/**
* @return BelongsTo
*/
public function service(): BelongsTo
{
return $this->BelongsTo(ServiceType::class, 'service_id');
}
/**
* @return BelongsTo
*/
public function bank(): BelongsTo
{
return $this->BelongsTo(Bank::class, 'bank_id')->withTrashed();
}
/**
* @return BelongsTo
*/
public function fixedCurrency(): BelongsTo
{
return $this->BelongsTo(Currency::class, 'fix_currency_id');
}
/**
* @return BelongsTo
*/
public function convertibleCurrency(): BelongsTo
{
return $this->BelongsTo(Currency::class, 'convertible_currency_id');
}
/**
* @return BelongsTo
*/
public function conversionCurrency(): BelongsTo
{
return $this->BelongsTo(Currency::class, 'conversion_currency_id');
}
/**
* @return MorphMany
*/
public function documents(): MorphMany
{
return $this->MorphMany(Document::class, 'owner');
}
/**
* @return MorphMany
*/
public function transactions(): MorphMany
{
return $this->MorphMany(Transaction::class, 'owner');
}
/**
* @return hasManyDeep
*/
public function bills(): hasManyDeep
{
return $this->hasManyDeep(Transaction::class, [Transaction::class.' as alias'], [['owner_type', 'owner_id'], ['owner_type', 'owner_id']], [null, null]);
}
protected static function booted()
{
if (auth()->user()) {
if (auth()->user()->type === RoleTypes::USER) {
static::addGlobalScope(new CustomerBookingsScope);
}
}
}
}
@@ -120,7 +120,7 @@
<modal-component class="animate__animated animate__fast animate__fadeIn" size="extra-large" styleType="fill-in" type="editBillingAddress">
<div class="row">
<div class="col bg-white">
<address-form-component :data="item.order.company_module.billingAddress" section="editBillingAddress"></address-form-component>
<address-form-component :id="item.order.company_module.id" :data="item.order.company_module.billingAddress" section="editBillingAddress"></address-form-component>
</div>
</div>
</modal-component>
@@ -0,0 +1,84 @@
<template>
<div class="row m-t-20" @keyup.enter="search">
<div class="col">
<div class="row">
<div class="col-12 col-md">
<div class="row m-b-15">
<div class="col">
<div class="row">
<div class="col p-r-0">
<div class="form-group no-margin form-group-default b-rad-none">
<label class="text-primary">Order Number Like</label>
<input type="text" class="form-control" v-model="marking" />
</div>
</div>
</div>
</div>
<div class="col-auto p-l-0 p-r-0">
<div class="btn btn-primary b-rad-none" @click="search">
<i class="fa fa-search lh-40"></i>
</div>
</div>
<div class="col-auto p-l-0">
<div class="btn btn-secondary b-rad-none" @click="reset">
<i class="fa fa-remove lh-40"></i>
</div>
</div>
</div>
</div>
<div class="col-12 col-md">
<div class="row" v-if="with_export">
<div class="col">
<download-billing-with-dates-component :section="section"></download-billing-with-dates-component>
</div>
</div>
</div>
</div>
<list-component :key="currentKey" :section="section" :endpoint="route('api.packing_list.list')" :options="options">
<template slot="list" slot-scope="{data}">
<admin-payments-billing-component :data="data" :invoice_status="invoice_status" :section="section" ></admin-payments-billing-component>
</template>
</list-component>
</div>
</div>
</template>
<script>
export default {
props: {
invoice_status: {
type: String,
required: true
},
options: {
default () {
return {}
}
},
section:{
type: String,
required: true
},
with_export:{
type: Boolean,
default: false
}
},
data(){
return {
marking: '',
currentKey: 1,
}
},
methods: {
search() {
this.options['order_marking_in'] = this.marking;
this.currentKey+=1;
},
reset() {
this.marking = '';
delete(this.options['order_marking_in']);
this.currentKey+=1;
},
},
}
</script>
@@ -1,28 +1,24 @@
<template>
<div class="row m-b-20">
<div class="row m-b-20" @keyup.enter="downloadReport()">
<div class="col">
<div class="row">
<div class="col">
<div class="row m-l-0 m-r-0">
<div class="col-12 col-md mb-2 mb-md-0 p-l-3 p-r-3 p-md-0">
<validation-wrapper-component :validator="$v.parameters.startDate">
<label class="all-caps">Start Date</label>
<date-picker-component :parameters="parameters" v-model.lazy="parameters.startDate"></date-picker-component>
</validation-wrapper-component>
</div>
<div class="col-12 col-md mb-2 mb-md-0 p-l-3 p-r-3 p-md-0">
<validation-wrapper-component :validator="$v.parameters.endDate">
<label class="all-caps">End Date</label>
<date-picker-component :parameters="parameters" v-model.lazy="parameters.endDate"></date-picker-component>
</validation-wrapper-component>
</div>
<div class="col-12 col-md-auto p-l-3 p-r-3 p-md-0">
<div class="btn btn-lg btn-primary fs-11 w-100 h-100 d-flex justify-content-center align-items-center" @click="downloadReport()">
<span>
Export
</span>
</div>
</div>
<div class="row m-l-0 m-r-0">
<div class="col p-l-0 p-r-0">
<validation-wrapper-component :validator="$v.parameters.startDate">
<label class="all-caps">Start Date</label>
<date-picker-component :parameters="parameters" v-model.lazy="parameters.startDate"></date-picker-component>
</validation-wrapper-component>
</div>
<div class="col p-l-0 p-r-0">
<validation-wrapper-component :validator="$v.parameters.endDate">
<label class="all-caps">End Date</label>
<date-picker-component :parameters="parameters" v-model.lazy="parameters.endDate"></date-picker-component>
</validation-wrapper-component>
</div>
<div class="col-auto p-l-0 p-r-0">
<div class="btn btn-lg btn-primary fs-11 w-100 h-100 d-flex justify-content-center align-items-center" @click="downloadReport()">
<span>
Export
</span>
</div>
</div>
</div>
@@ -64,8 +60,11 @@ export default {
var apiRoute = '';
if(!this.validate()){ return; }
switch(this.section) {
case 'paymentsReportSection':
apiRoute = route('paymentTransactions.export');
case 'pendingPaymentSection':
apiRoute = route('paymentTransactions.export', 'pendingPaymentSection');
break;
case 'paidInvoiceSection':
apiRoute = route('paymentTransactions.export', 'paidInvoiceSection');
break;
case 'walletsReportSection':
apiRoute = route('walletTransactions.export');
@@ -102,44 +102,23 @@
<div class="col bg-master-lightest p-1 p-sm-4">
<div class="row tabsContainer tabContent" tab-name="pendingInvoice">
<div class="col">
<list-component section="pendingInvoiceSection" :endpoint="route('api.packing_list.list')" :options="{does_not_have_transaction_type: 1, type: 2}">
<template slot="list" slot-scope="{data}">
<admin-payments-billing-component :data="data" invoice_status="Pending Invoice" section="pendingInvoiceSection" ></admin-payments-billing-component>
</template>
</list-component>
<admin-payments-billing-with-search-component :options="{does_not_have_transaction_type: 1, type: 2, per_page: 5}" section="pendingInvoiceSection" invoice_status="Pending Invoice"></admin-payments-billing-with-search-component>
</div>
</div>
<div class="row tabsContainer tabContent hide" tab-name="pendingApproval">
<div class="col">
<list-component section="pendingApprovalSection" :endpoint="route('api.packing_list.list')" :options="{has_invoice_status_in: [0, 1]}">
<template slot="list" slot-scope="{data}">
<admin-payments-billing-component :data="data" invoice_status="Pending Approval" section="pendingApprovalSection" ></admin-payments-billing-component>
</template>
</list-component>
<admin-payments-billing-with-search-component :options="{has_invoice_status_in: [0, 1], per_page: 5}" section="pendingApprovalSection" invoice_status="Pending Approval"></admin-payments-billing-with-search-component>
</div>
</div>
<div class="row tabsContainer tabContent hide" tab-name="pendingPayment">
<div class="col">
<payment-filter-component :endpoint="route('api.packing_list.list')" :data="data"></payment-filter-component>
<list-component section="pendingPaymentSection" :endpoint="route('api.packing_list.list')" :options="{has_invoice_status_in: [2], packing_list_ordered_by_invoice_date: true}">
<template slot="list" slot-scope="{data}">
<admin-payments-billing-component :data="data" invoice_status="Pending Payment" section="pendingPaymentSection" ></admin-payments-billing-component>
</template>
</list-component>
<admin-payments-billing-with-search-component :options="{has_invoice_status_in: [2], packing_list_ordered_by_invoice_date: true, per_page: 5}" section="pendingPaymentSection" invoice_status="Pending Payment" :with_export="true"></admin-payments-billing-with-search-component>
</div>
</div>
<div class="row tabsContainer tabContent hide" tab-name="paidInvoice">
<div class="col">
<div class="row">
<div class="col-12 col-md-6 no-padding">
<download-billing-with-dates-component section="paymentsReportSection" ></download-billing-with-dates-component>
</div>
</div>
<list-component section="paidInvoiceSection" :endpoint="route('api.packing_list.list')" :options="{has_invoice_status_in: [3]}">
<template slot="list" slot-scope="{data}">
<admin-payments-billing-component :data="data" invoice_status="Paid Invoice" section="paidInvoiceSection" ></admin-payments-billing-component>
</template>
</list-component>
<admin-payments-billing-with-search-component :options="{has_invoice_status_in: [3], per_page: 5}" section="paidInvoiceSection" invoice_status="Paid Invoice" :with_export="true"></admin-payments-billing-with-search-component>
</div>
</div>
</div>
@@ -0,0 +1,179 @@
@extends('layouts.base_portal')
@section('inner_content')
<div class="row">
<div class="col bg-white p-t-15 p-b-15">
<div class="row no-margin">
<div class="col-12">
<form method="post" >
@csrf
<div class="row">
<div class="col">
<input class="form-control" type="text" name="marking" placeholder="Marking" value="{{$marking}}">
</div>
<div class="col">
<input class="form-control" type="text" name="customer_email" placeholder="Email" value="{{$email}}">
</div>
<div class="col">
<input class="form-control" type="text" name="booking_reference" placeholder="Booking Reference" value="{{$bookingReference}}">
</div>
<div class="col-auto">
<button class="btn btn-complete" type="submit">Search</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<main>
@if($company)
@php
$employees = $company->employees;
$primaryEmployee = $employees->first();
$identification = $company->documents->whereIn('document_type', \App\Classes\ValueObjects\Constants\DocumentType::IDENTIFICATION_DOCUMENTS)->first()
@endphp
<section id="customer-account" class="m-b-50">
<h3>Customer Account</h3>
<p>Marking: <span><a href="{{route('customer.profile', $company->reference)}}" target="_blank">{{$company->reference}}</a></span></p>
<p>Account Type: <span>{{$company->type === 1 ? 'Business' : 'Personal'}}</span></p>
@if($company->type === 1)<p>Company's Name: <span>{{$company->name}}</span></p>@endif
<p>Customer's Name: <span>{{$employees->pluck('name')->implode(', ')}}</span></p>
<p>Email: <span>{{$employees->pluck('email')->implode(', ')}}</span></p>
<p>Phone: <span>{{$company->contacts->pluck('phone')->implode(', ')}}</span></p>
<p>Registration Date: <span>{{$company->created_at->format('d-m-Y')}}</span></p>
</section>
<section id="customer-verification" class="m-b-50">
<h3>Customer Verification</h3>
<p>Email Verification Status: <span>{{ $primaryEmployee->status === 2 ? 'Verified' : 'Pending Verification'}}</span></p>
<p>Identification Verification Status: <span>{{$identification ? ($identification->status === 2 ? 'Verified' : 'Pending Verification') : 'Not Submitted'}}</span></p>
</section>
@if(!$booking)
<section>
<h3>Customer Bookings</h3>
@php
$bookings = $company->bookings()->whereIn('status', [2, 3])->get();
@endphp
<section>
@foreach($bookings as $booking)
@php
$payments = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PAYMENT)->get();
$purchaseOrder = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->first();
@endphp
<section class="m-b-50">
<h5 class="bold">Booking Reference: {{$booking->marking}}</h5>
<p>Amount: <span>{{$booking->fix_amount.' '.$booking->fixedCurrency->short_code}}</span></p>
<p>Status: <span>{{$booking->status === 3 ? 'Complete' : 'In Progress'}}</span></p>
<p>Purchase Order Status: <span>{{$purchaseOrder ? ($purchaseOrder->status === 3 ? 'Approved' : ($purchaseOrder->status === 1 ? 'Pending Approval' : 'Incomplete Submission')) : 'Pending Submission'}}</span></p>
@if($payments)<p class="m-t-35 bold">Payment History:</p>@endif
@php $i = 1; @endphp
@foreach($payments as $payment)
@php
$bill = $payment->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::BILL)->first();
$transferProof = null;
$status = 'Pending Submission';
if($payment->status === 1) {
$status = 'Pending Approval';
}
if($payment->status === 2) {
$status = 'Pending Confirmation';
}
if(in_array($payment->status, [4, 5])) {
$status = 'Rejected/Failed Payment';
}
if($bill) {
if($bill->status === 1) {
$status = 'Pending Transfer Proof';
}
if(in_array($bill->status, [2, 3])) {
$status = 'Transfer Complete';
$transferProof = $bill->documents()->first();
}
}
@endphp
<section class="m-b-35">
<p>{{$i++}}.</p>
<p>Amount: <span>{{$payment->original_amount.' '.$payment->original_currency->short_code}}</span></p>
<p>Status: <span>{{$status}}</span></p>
<p>Payment Date: <span>{{$payment->created_at->format('d-m-Y')}}</span></p>
@if($bill)
<p>Supplier: <span>{{$bill->issuerCompany->name}}</span></p>
<p>Supplier Order Date: <span>{{$bill->created_at->format('d-m-Y')}}</span></p>
@if($transferProof)<p>Transfer Proof Upload Date: <span>{{$transferProof->created_at->format('d-m-Y')}}</span></p>@endif
@endif
</section>
@endforeach
</section>
@endforeach
</section>
</section>
@endif
@endif
@if($booking)
@php
$payments = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PAYMENT)->get();
$purchaseOrder = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->first();
@endphp
<section>
<h5 class="bold">Booking Reference: {{$booking->marking}}</h5>
<p>Amount: <span>{{$booking->fix_amount.' '.$booking->fixedCurrency->short_code}}</span></p>
<p>Status: <span>{{$booking->status === 3 ? 'Complete' : 'In Progress'}}</span></p>
<p>Purchase Order Status: <span>{{$purchaseOrder ? ($purchaseOrder->status === 3 ? 'Approved' : ($purchaseOrder->status === 1 ? 'Pending Approval' : 'Incomplete Submission')) : 'Pending Submission'}}</span></p>
@if($payments)<p class="m-t-35 bold">Payment History:</p>@endif
@php $i = 1; @endphp
@foreach($payments as $payment)
@php
$bill = $payment->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::BILL)->first();
$transferProof = null;
$status = 'Pending Submission';
if($payment->status === 1) {
$status = 'Pending Approval';
}
if($payment->status === 2) {
$status = 'Pending Confirmation';
}
if(in_array($payment->status, [4, 5])) {
$status = 'Rejected/Failed Payment';
}
if($bill) {
if($bill->status === 1) {
$status = 'Pending Transfer Proof';
}
if(in_array($bill->status, [2, 3])) {
$status = 'Transfer Complete';
$transferProof = $bill->documents()->first();
}
}
@endphp
<section class="m-b-35">
<p>{{$i++}}.</p>
<p>Amount: <span>{{$payment->original_amount.' '.$payment->original_currency->short_code}}</span></p>
<p>Status: <span>{{$status}}</span></p>
<p>Payment Date: <span>{{$payment->created_at->format('d-m-Y')}}</span></p>
@if($bill)
<p>Supplier: <span>{{$bill->issuerCompany->name}}</span></p>
<p>Supplier Order Date: <span>{{$bill->created_at->format('d-m-Y')}}</span></p>
@if($transferProof)<p>Transfer Proof Upload Date: <span>{{$transferProof->created_at->format('d-m-Y')}}</span></p>@endif
@endif
</section>
@endforeach
</section>
@endif
</main>
</div>
</div>
@endsection
+45 -1
View File
@@ -44,6 +44,8 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Route;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
use App\Models\Company;
use App\Models\Booking;
/*
|--------------------------------------------------------------------------
@@ -488,7 +490,7 @@ Route::get('billplz/bills/{bill_no}', function($bill_no){
})->name('billplz.bill');
Route::get('/export/null-debtor/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@nullDebtor')->name('newDebtor.export');
Route::get('/export/payment-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@paymentTransactions')->name('paymentTransactions.export');
Route::get('/export/payment-transactions/{section}/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@paymentTransactions')->name('paymentTransactions.export');
Route::get('/delayed_container/customers', function(){
$containers = Container::whereHas('transports', function($query){
@@ -795,4 +797,46 @@ Route::get('/invoices/approve', function(Request $request){
})->name('invoices.approve');
Route::get('/support', function () {
return view('pages.customer_support', [
'marking' => null,
'email' => null,
'bookingReference' => null,
'company' => null,
'booking' => null
]);
})->name('support');
Route::post('/support', function (Request $request) {
$marking = $request->input('marking');
$email = $request->input('customer_email');
$bookingReference = $request->input('booking_reference');
$company = null;
$booking = null;
if($email) {
$company = Company::whereHas('Employees', function($user) use($email) {
return $user->where('email', $email);
})->first();
}
if($marking) {
$company = Company::where('reference', $marking)->first();
}
if($bookingReference) {
$booking = Booking::where('marking', $bookingReference)->first();
$company = $booking->company;
}
return view('pages.customer_support', [
'marking' => $marking,
'email' => $email,
'bookingReference' => $bookingReference,
'company' => $company,
'booking' => $booking,
]);
})->name('support');