mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a701242646 | |||
| 4bdeae997d | |||
| 36809f34cc | |||
| 032171bb18 | |||
| d41bd3db39 | |||
| 04af87f640 |
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithAgingColumn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
$today = Carbon::now();
|
||||
return $builder->select('packing_lists.*')
|
||||
->addSelect(DB::raw("DATEDIFF('$today', transactions.updated_at) as days_over_duedate"))
|
||||
->addSelect(DB::raw("CASE
|
||||
WHEN DATEDIFF('$today', transactions.updated_at) <= 0 THEN 0
|
||||
WHEN DATEDIFF('$today', transactions.updated_at) > 0 AND DATEDIFF('$today', transactions.updated_at) <= 30 THEN 1
|
||||
WHEN DATEDIFF('$today', transactions.updated_at) > 30 AND DATEDIFF('$today', transactions.updated_at) <= 60 THEN 2
|
||||
WHEN DATEDIFF('$today', transactions.updated_at) > 60 AND DATEDIFF('$today', transactions.updated_at) <= 90 THEN 3
|
||||
ELSE 4
|
||||
END AS due_date_number"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use App\Classes\General\Eloquent\ApplyFiltersToQuery;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use DateTime;
|
||||
|
||||
class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $filters;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->filters = [
|
||||
"has_invoice_status_in" => [2],
|
||||
"packing_list_ordered_by_invoice_date" => true,
|
||||
"with_aging_column" => true
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Company Name',
|
||||
'Customer Marking',
|
||||
'Order Number',
|
||||
'Invoice No',
|
||||
'Invoice Date',
|
||||
'Days',
|
||||
'Amount',
|
||||
];
|
||||
}
|
||||
|
||||
public function query()
|
||||
{
|
||||
return (new ApplyFiltersToQuery())->execute(PackingList::query(), $this->filters);
|
||||
}
|
||||
|
||||
public function map($list): array
|
||||
{
|
||||
$marking = null;
|
||||
$orderNo = null;
|
||||
$name = null;
|
||||
$invDate = 'n/a';
|
||||
$invNo = 'n/a';
|
||||
$days = 'n/a';
|
||||
|
||||
if ($list->owner instanceof Order) {
|
||||
$inviterPivotInviteeReference = $list->owner->companyModule->inviters()->withPivot('invitee_reference')->first();
|
||||
|
||||
if ($inviterPivotInviteeReference) {
|
||||
$marking = $inviterPivotInviteeReference->pivot->invitee_reference;
|
||||
$orderNo = $list->owner->reference;
|
||||
}
|
||||
$name = $list->owner->companyModule->company->name;
|
||||
}
|
||||
|
||||
$transaction = $list->transactions()->whereIn('status', [ApprovalStatus::APPROVED])->first();
|
||||
if ($transaction) {
|
||||
|
||||
$invoiceDate = $transaction->created_at;
|
||||
$invDate = date_format($invoiceDate, 'd-m-Y');
|
||||
$invNo = $transaction->bill_no;
|
||||
$amt = number_format($transaction->amount, 2);
|
||||
|
||||
$currentDate = new DateTime();
|
||||
$interval = $currentDate->diff($invoiceDate);
|
||||
$days = $interval->format('%a');
|
||||
}
|
||||
|
||||
return [
|
||||
$name,
|
||||
$marking,
|
||||
$orderNo,
|
||||
$invNo,
|
||||
$invDate,
|
||||
$days,
|
||||
$amt,
|
||||
];
|
||||
}
|
||||
|
||||
private function dueDateColumn($colNum, $dueDateNumber, $amt)
|
||||
{
|
||||
if ($colNum == $dueDateNumber) return $amt;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,25 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
// $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]);
|
||||
$invoices = Transaction::whereIn('id', $invoice_ids)->get();
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
$order = null;
|
||||
if ($invoice->owner instanceof Transaction) {
|
||||
if ($invoice->owner) {
|
||||
if ($invoice->owner->owner) {
|
||||
$order = $invoice->owner->owner->owner;
|
||||
}
|
||||
}
|
||||
} else if (!($invoice->owner instanceof Transaction) && !($invoice->owner instanceof Wallet)) {
|
||||
if ($invoice->owner) {
|
||||
$order = $invoice->owner->owner;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$order) {
|
||||
throw new MalformedRequestException("There is an error while paying for invoice {$invoice->bill_no}");
|
||||
}
|
||||
}
|
||||
|
||||
if ($payment_method == PaymentMethodType::WALLET) {
|
||||
|
||||
$companyModuleId = $invoices->first()->receiver;
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use App\Classes\Modules\Exports\Services\ExportsAgingList;
|
||||
|
||||
class ExportArrivedParcelController
|
||||
{
|
||||
@@ -46,4 +47,11 @@ class ExportArrivedParcelController
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function aging(Request $request) {
|
||||
$data = new ExportsAgingList();
|
||||
$response = $data->download('aging_report.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,15 @@ class TransactionResource extends JsonResource
|
||||
$groupTransactions = null;
|
||||
|
||||
if ($this->owner instanceof Transaction) {
|
||||
$order = new OrderResource($this->owner->owner->owner);
|
||||
if ($this->owner) {
|
||||
if ($this->owner->owner) {
|
||||
$order = new OrderResource($this->owner->owner->owner);
|
||||
}
|
||||
}
|
||||
} else if (!($this->owner instanceof Transaction) && !($this->owner instanceof Wallet)) {
|
||||
$order = new OrderResource($this->owner->owner);
|
||||
if ($this->owner) {
|
||||
$order = new OrderResource($this->owner->owner);
|
||||
}
|
||||
} else {
|
||||
$group = Group::where('reference', $this->payment_reference)->first();
|
||||
if ($group) {
|
||||
|
||||
@@ -28,8 +28,13 @@ class WalletTransactionResource extends JsonResource
|
||||
$description = 'Credit Voucher for '.$this->payment_reference;
|
||||
break;
|
||||
case TransactionType::PAYMENT:
|
||||
$order = Transaction::where('payment_reference', $this->bill_no)->first()->owner->owner->owner;
|
||||
$invoice = Transaction::where('payment_reference', $this->bill_no)->first();
|
||||
if(!$invoice) {
|
||||
$description = 'Payment for unknown invoice, please contact tech support.';
|
||||
break;
|
||||
}
|
||||
|
||||
$order = $invoice->owner->owner->owner;
|
||||
if(!$order) {
|
||||
$description = 'Payment for unknown order, please contact tech support.';
|
||||
break;
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="row m-b-15 m-l-5 m-r-10">
|
||||
<div class="row m-b-15 m-l-5 m-r-10" v-if="$store.getters.isAdmin || item.order">
|
||||
<div class="col bg-white rounded b-a" :class="{'b-white': !selected, 'b-primary': selected, 'bg-primary-lighter': selected}">
|
||||
<div class="row">
|
||||
<div class="col padding-20">
|
||||
@@ -13,7 +13,8 @@
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="no-margin fs-10 all-caps">Order</p>
|
||||
<div><a :href="route('order.show', item.order.reference)">{{item.order.reference}}</a></div>
|
||||
<div v-if="item.order"><a :href="route('order.show', item.order.reference)">{{item.order.reference}}</a></div>
|
||||
<div class="text-danger" v-else>Error in retrieving order</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="no-margin fs-10 all-caps">Invoice Date</p>
|
||||
|
||||
@@ -440,6 +440,7 @@ Route::get('/export/pending-arrangement-delivery-list', 'Exports\ExportPendingAr
|
||||
Route::get('/export/on-hold-packing-list', 'Exports\ExportPendingArrangementPackingListController@onHold')->name('packaging_list.on_hold.export');
|
||||
Route::get('/export/arrived-parcel', 'Exports\ExportArrivedParcelController@export')->name('packing_list.arrived_parcel.export');
|
||||
Route::get('/export/parcel-summary', 'Exports\ExportArrivedParcelController@summary');
|
||||
Route::get('/export/aging-list', 'Exports\ExportArrivedParcelController@aging')->name('aging-listing.export');
|
||||
Route::get('/export/parcel-postcode', 'Exports\ExportParcelPostcodesController@export');
|
||||
Route::get('/export/{year}/customer-total-order', 'Exports\ExportCustomersToExcelController@totalOrders');
|
||||
Route::get('/export/packing-list-warehouse/guangzhou2-to-johor', 'Exports\ExportArrivedParcelController@guangZhou2ToJohor');
|
||||
|
||||
Reference in New Issue
Block a user