Feat: Updates to fullfilment services, shipping views, timezones, and elta labels
This commit is contained in:
@@ -11,7 +11,9 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Lunar\Shipping\Facades\Shipping;
|
||||
use Modules\Core\Shipping\Contracts\CarrierFulfillmentInterface;
|
||||
use Modules\Core\Shipping\Contracts\IssuesVoucherOnPrint;
|
||||
use Modules\Core\Shipping\Contracts\SupportsBatchLabels;
|
||||
use Modules\Core\Shipping\Contracts\SupportsManifestBatching;
|
||||
use Modules\Core\Shipping\Filament\Resources\ShipmentResource\Pages\ListShipments;
|
||||
@@ -25,9 +27,10 @@ use Throwable;
|
||||
* scoped to ListRecords), so carrier-by-carrier separation
|
||||
* (ListShipments::getTabs()) needed a real Resource to attach to.
|
||||
*
|
||||
* Shows only shipments created through a carrier's API that are NOT yet on
|
||||
* an issued manifest — see Modules\Core\Shipping\Filament\Resources\
|
||||
* ManifestResource for shipments that already are. Manual carriers, manual
|
||||
* Shows only shipments created through a carrier's API that still need
|
||||
* their hand-over step: not yet on an issued manifest (see Modules\Core\
|
||||
* Shipping\Filament\Resources\ManifestResource for those that are), or
|
||||
* for carriers that issue vouchers on print, not yet printed. Manual carriers, manual
|
||||
* vouchers and carrier-reported (synced) vouchers have no label to print
|
||||
* or manifest to join, so they never show here.
|
||||
*
|
||||
@@ -49,13 +52,27 @@ class ShipmentResource extends Resource
|
||||
|
||||
protected static ?int $navigationSort = 100;
|
||||
|
||||
/**
|
||||
* A voucher leaves this queue once its carrier's hand-over step is
|
||||
* done: on a manifest for carriers that batch (ACS), printed for
|
||||
* carriers that issue the voucher on print (ELTA — every parcel of a
|
||||
* multi-parcel send is printed together, so they leave together).
|
||||
*/
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
$issuedOnPrint = collect(Shipping::getSupportedDrivers())->keys()
|
||||
->filter(fn (string $carrier) => self::fulfillmentService($carrier) instanceof IssuesVoucherOnPrint)
|
||||
->values()
|
||||
->all();
|
||||
|
||||
return parent::getEloquentQuery()
|
||||
->where('source', Shipment::SOURCE_CREATED)
|
||||
->whereNotNull('order_id')
|
||||
->whereNull('manifest_id')
|
||||
->whereNull('cancelled_at');
|
||||
->whereNull('cancelled_at')
|
||||
->where(fn (Builder $query) => $query
|
||||
->whereNotIn('carrier', $issuedOnPrint)
|
||||
->orWhereNull('label_printed_at'));
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
@@ -69,6 +86,7 @@ class ShipmentResource extends Resource
|
||||
TextColumn::make('tracking_reference')
|
||||
->label('Tracking #')
|
||||
->placeholder('Not issued yet')
|
||||
->description(fn (Shipment $record) => $record->parcelDescription())
|
||||
->copyable(),
|
||||
TextColumn::make('order.reference')->label('Order'),
|
||||
TextColumn::make('created_at')->label('Created')->dateTime(),
|
||||
|
||||
Reference in New Issue
Block a user