Feat: Updates to fullfilment services, shipping views, timezones, and elta labels
This commit is contained in:
@@ -123,4 +123,40 @@ class Shipment extends Model
|
||||
{
|
||||
return in_array($this->source, [self::SOURCE_MANUAL, self::SOURCE_MANUAL_VOUCHER, self::SOURCE_SYNCED], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This parcel's place in a multi-parcel send, for display — e.g.
|
||||
* "Main voucher · parcel 1 of 3" or "Parcel 2 of 3 · of NZ000987399GR".
|
||||
* Null for a single-parcel shipment.
|
||||
*
|
||||
* Read from what's already stored: the piece numbers in meta (sends
|
||||
* created as multi-parcel), else parent_reference (the main voucher's
|
||||
* number, set on issued extra parcels — also ACS multi-part vouchers).
|
||||
*/
|
||||
public function parcelDescription(): ?string
|
||||
{
|
||||
$piece = $this->meta['piece'] ?? null;
|
||||
$pieces = $this->meta['pieces'] ?? null;
|
||||
|
||||
if ($piece && $pieces > 1) {
|
||||
if ((int) $piece === 1) {
|
||||
return "Main voucher · parcel 1 of {$pieces}";
|
||||
}
|
||||
|
||||
$main = $this->parent_reference ?? 'the main voucher (not issued yet)';
|
||||
|
||||
return "Parcel {$piece} of {$pieces} · of {$main}";
|
||||
}
|
||||
|
||||
if (filled($this->parent_reference)) {
|
||||
return "Extra parcel · of {$this->parent_reference}";
|
||||
}
|
||||
|
||||
if (filled($this->tracking_reference)
|
||||
&& static::where('parent_reference', $this->tracking_reference)->exists()) {
|
||||
return 'Main voucher';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user