Compare commits

...

2 Commits

Author SHA1 Message Date
Jia Sheng Lee acfd16a4b1 export unclaim for arrived parcel 2023-10-05 22:53:32 +08:00
edmondlang c493b3786c update credit_note pdf 2023-09-25 22:34:13 +08:00
2 changed files with 25 additions and 17 deletions
@@ -45,14 +45,14 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
public function query()
{
$query = PackingList::with([
'owner.companyModule.inviters',
'owner.orderRoles',
// 'owner.companyModule.inviters',
// 'owner.orderRoles',
'packages',
'transports'
])
->where('type', '=', 1)
->where('status', '=', 2)
->where('owner_type', Order::class);
->where('type', '=', 1);
// ->where('status', '=', 2)
// ->where('owner_type', Order::class);
if (!is_null($this->start_date) && !is_null($this->end_date)) {
$query->whereHas('transports', function ($q) {
@@ -68,9 +68,14 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
public function map($packingList): array
{
$order = $packingList->owner;
$marking = $order->companyModule->getMarking();
$warehouse = $order->orderRoles->firstWhere('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->appointee;
$order = null;
$marking = null;
$warehouse = null;
if ($packingList->owner instanceof Order) {
$order = $packingList->owner;
$marking = $order->companyModule->getMarking();
$warehouse = $order->orderRoles->firstWhere('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->appointee;
}
$cbm = $packingList->packages->sum(function ($package) {
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
});
@@ -79,9 +84,9 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
$days_to_record = Carbon::parse($arrival_date)->diffInDays(Carbon::parse($recorded_on));
return [
$packingList->owner->reference,
$marking,
$warehouse->reference,
$order ? $order->reference : 'Unclaimed',
$marking ? $marking : 'Unclaimed',
$warehouse ? $warehouse->reference : 'Unclaimed',
$cbm,
$packingList->packages->implode('description', ', '),
$packingList->packages->sum('quantity'),
@@ -49,12 +49,15 @@
@php
$addresses = $supplier->addresses()->where('type', 1)->first();
@endphp
{{ $addresses->street_one }}
{{ $addresses->street_two }} ,
{{ $addresses->district()->first()->name }},
{{ $addresses->postcode }}
{{ $addresses->state()->first()->name }},
{{ $addresses->country()->first()->name }}
@if($addresses)
{{ $addresses->street_one }}
{{ $addresses->street_two }} ,
{{ $addresses->district()->first()->name }},
{{ $addresses->postcode }}
{{ $addresses->state()->first()->name }},
{{ $addresses->country()->first()->name }}
@endif
</div>
<div>
@php