Compare commits

..

3 Commits

Author SHA1 Message Date
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
6 changed files with 96 additions and 107 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 . '%');
});
}
}
@@ -1,82 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Models\Order;
use Carbon\Carbon;
use Exception;
use Illuminate\Console\Command;
class AutoGenerateInvoice extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'invoice:generate';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Auto generate invoice';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$packingLists = (App()->make(ListsPackingLists::class))->execute(['does_not_have_transaction_type' => 1, 'type' => 2]);
if (count($packingLists)) {
$this->info(Carbon::now() . ' : Auto generate invoice cron started.');
$start = new Carbon();
foreach ($packingLists as $packingList) {
$order = $packingList->owner;
if (!($order instanceof Order)) {
$this->info('Failed to generate invoice for reference' . $order->reference . '. It is not an instance of Order.');
continue;
}
$companyModule = $order->companyModule;
$billingAddress = $companyModule->addresses()->where('type', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
$deliveryAddress = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
$postCodes = \App\Models\SegmentConstant::whereIn('reference', ['CENTER_POSTCODE', 'OUTSTATION_POSTCODE'])->get()->pluck('value')->flatten();
if (!!$billingAddress && in_array($deliveryAddress->postcode, $postCodes->toArray())) {
try {
(App()->make(CreateInvoiceTransactionProcessor::class))->execute($packingList);
$this->info('Invoice generated for reference ' . $order->reference . '.');
} catch (Exception $exception) {
$this->info('Failed to generate invoice for reference ' . $order->reference . '. Exception: ' . $exception->getMessage());
}
}
$this->info('Failed to generate invoice for reference ' . $order->reference . '. Billing Address is not defined / Postcode area is not defined.');
}
$end = new Carbon();
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
$this->info(Carbon::now() . ' : Done generating invoice. ElapsedTime: ' . $elapsedTime . '.');
}
}
}
+1 -4
View File
@@ -43,10 +43,7 @@ class Kernel extends ConsoleKernel
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/departure_email.log');
$schedule->command('invoice:generate')
->hourly()
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/auto_generate_invoice.log');
}
/**
@@ -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,69 @@
<template>
<div class="row">
<div class="col">
<div class="row m-b-15">
<div class="col-md-6 col-7 p-r-0">
<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>
<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
}
},
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>
@@ -102,30 +102,18 @@
<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}" 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]}" 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}" section="pendingPaymentSection" invoice_status="Pending Payment"></admin-payments-billing-with-search-component>
</div>
</div>
<div class="row tabsContainer tabContent hide" tab-name="paidInvoice">
@@ -135,11 +123,7 @@
<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]}" section="paidInvoiceSection" invoice_status="Paid Invoice"></admin-payments-billing-with-search-component>
</div>
</div>
</div>