@fleetbase/fleetops-engine 0.6.70 → 0.6.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASE.md +21 -47
- package/addon/components/order/details/activity.hbs +8 -6
- package/addon/components/order/details/activity.js +9 -0
- package/addon/components/order/details.hbs +29 -0
- package/addon/components/order/details.js +26 -0
- package/addon/components/order/form/details.hbs +30 -4
- package/addon/components/order/form/details.js +46 -0
- package/addon/components/order/form/route.hbs +4 -2
- package/addon/components/order/form/route.js +11 -0
- package/addon/components/order/form.hbs +12 -0
- package/addon/components/order/form.js +21 -1
- package/addon/components/order/kanban.js +72 -0
- package/addon/components/order-config-manager/activity-flow.js +45 -10
- package/addon/components/order-config-manager/lifecycle.hbs +250 -0
- package/addon/components/order-config-manager/lifecycle.js +358 -0
- package/addon/components/order-config-manager.js +5 -1
- package/addon/controllers/analytics/reports/index.js +10 -1
- package/addon/controllers/connectivity/devices/index/details.js +1 -0
- package/addon/controllers/connectivity/devices/index.js +8 -2
- package/addon/controllers/connectivity/events/index.js +31 -1
- package/addon/controllers/connectivity/sensors/index/details.js +1 -1
- package/addon/controllers/connectivity/sensors/index.js +37 -1
- package/addon/controllers/maintenance/equipment/index/details.js +2 -2
- package/addon/controllers/maintenance/equipment/index.js +28 -9
- package/addon/controllers/maintenance/inspection-forms/index.js +32 -12
- package/addon/controllers/maintenance/inspection-submissions/index/details.js +2 -1
- package/addon/controllers/maintenance/inspection-submissions/index.js +49 -9
- package/addon/controllers/maintenance/maintenances/index/details.js +2 -0
- package/addon/controllers/maintenance/maintenances/index.js +20 -1
- package/addon/controllers/maintenance/parts/index/details.js +2 -2
- package/addon/controllers/maintenance/parts/index.js +28 -8
- package/addon/controllers/maintenance/schedules/index.js +33 -4
- package/addon/controllers/maintenance/work-orders/index/details.js +3 -3
- package/addon/controllers/maintenance/work-orders/index.js +39 -8
- package/addon/controllers/management/contacts/customers.js +13 -0
- package/addon/controllers/management/contacts/index.js +43 -1
- package/addon/controllers/management/drivers/index/details.js +1 -0
- package/addon/controllers/management/drivers/index.js +32 -2
- package/addon/controllers/management/fleets/index/details.js +1 -0
- package/addon/controllers/management/fleets/index.js +39 -1
- package/addon/controllers/management/fuel-reports/index.js +22 -2
- package/addon/controllers/management/fuel-transactions/index.js +43 -7
- package/addon/controllers/management/issues/index/details.js +1 -0
- package/addon/controllers/management/issues/index.js +22 -2
- package/addon/controllers/management/places/index.js +36 -1
- package/addon/controllers/management/trailers/index/details.js +1 -0
- package/addon/controllers/management/trailers/index.js +50 -2
- package/addon/controllers/management/vehicles/index/details.js +1 -0
- package/addon/controllers/management/vehicles/index.js +33 -2
- package/addon/controllers/management/vendors/index.js +26 -2
- package/addon/controllers/operations/orders/index/details.js +31 -4
- package/addon/controllers/operations/orders/index.js +59 -4
- package/addon/controllers/operations/service-rates/index.js +15 -1
- package/addon/extension.js +32 -0
- package/addon/routes/operations/orders/index/details.js +1 -0
- package/addon/services/contact-actions.js +1 -0
- package/addon/services/customer-actions.js +2 -1
- package/addon/services/device-actions.js +1 -0
- package/addon/services/device-event-actions.js +1 -0
- package/addon/services/driver-actions.js +4 -13
- package/addon/services/equipment-actions.js +1 -0
- package/addon/services/fleet-actions.js +1 -0
- package/addon/services/fuel-report-actions.js +1 -0
- package/addon/services/inspection-form-actions.js +1 -0
- package/addon/services/inspection-submission-actions.js +1 -0
- package/addon/services/integrated-vendor-actions.js +1 -0
- package/addon/services/issue-actions.js +1 -0
- package/addon/services/maintenance-actions.js +1 -0
- package/addon/services/maintenance-schedule-actions.js +2 -1
- package/addon/services/order-actions.js +7 -0
- package/addon/services/order-presentation.js +129 -0
- package/addon/services/part-actions.js +1 -0
- package/addon/services/place-actions.js +1 -0
- package/addon/services/sensor-actions.js +1 -0
- package/addon/services/service-area-actions.js +1 -0
- package/addon/services/service-rate-actions.js +1 -0
- package/addon/services/telematic-actions.js +1 -0
- package/addon/services/trailer-actions.js +4 -14
- package/addon/services/vehicle-actions.js +4 -13
- package/addon/services/vendor-actions.js +1 -0
- package/addon/services/work-order-actions.js +1 -0
- package/addon/services/zone-actions.js +1 -0
- package/addon/templates/analytics/reports/index/details.hbs +1 -0
- package/addon/templates/analytics/reports/index.hbs +1 -0
- package/addon/templates/connectivity/devices/index/details.hbs +1 -0
- package/addon/templates/connectivity/devices/index.hbs +1 -0
- package/addon/templates/connectivity/events/index.hbs +1 -0
- package/addon/templates/connectivity/sensors/index/details.hbs +1 -0
- package/addon/templates/connectivity/sensors/index.hbs +1 -0
- package/addon/templates/maintenance/equipment/index/details.hbs +1 -0
- package/addon/templates/maintenance/equipment/index.hbs +2 -0
- package/addon/templates/maintenance/inspection-forms/index/details.hbs +1 -0
- package/addon/templates/maintenance/inspection-forms/index.hbs +1 -0
- package/addon/templates/maintenance/inspection-submissions/index/details.hbs +1 -0
- package/addon/templates/maintenance/inspection-submissions/index.hbs +1 -0
- package/addon/templates/maintenance/maintenances/index/details.hbs +1 -0
- package/addon/templates/maintenance/maintenances/index.hbs +1 -0
- package/addon/templates/maintenance/parts/index/details.hbs +1 -0
- package/addon/templates/maintenance/parts/index.hbs +2 -0
- package/addon/templates/maintenance/schedules/index/details.hbs +1 -0
- package/addon/templates/maintenance/schedules/index.hbs +2 -0
- package/addon/templates/maintenance/work-orders/index/details.hbs +1 -0
- package/addon/templates/maintenance/work-orders/index.hbs +1 -0
- package/addon/templates/management/contacts/customers/details.hbs +1 -0
- package/addon/templates/management/contacts/customers.hbs +1 -0
- package/addon/templates/management/contacts/index/details.hbs +1 -0
- package/addon/templates/management/contacts/index.hbs +1 -0
- package/addon/templates/management/contacts.hbs +1 -0
- package/addon/templates/management/drivers/index/details.hbs +1 -0
- package/addon/templates/management/drivers/index.hbs +2 -0
- package/addon/templates/management/fleets/index/details.hbs +1 -0
- package/addon/templates/management/fleets/index.hbs +1 -0
- package/addon/templates/management/fuel-reports/index/details.hbs +1 -0
- package/addon/templates/management/fuel-reports/index.hbs +1 -0
- package/addon/templates/management/fuel-transactions/index.hbs +1 -0
- package/addon/templates/management/issues/index/details.hbs +1 -0
- package/addon/templates/management/issues/index.hbs +1 -0
- package/addon/templates/management/places/index/details.hbs +1 -0
- package/addon/templates/management/places/index.hbs +1 -0
- package/addon/templates/management/trailers/index/details.hbs +1 -0
- package/addon/templates/management/trailers/index.hbs +2 -0
- package/addon/templates/management/vehicles/index/details.hbs +1 -0
- package/addon/templates/management/vehicles/index.hbs +2 -0
- package/addon/templates/management/vendors/index/details.hbs +1 -0
- package/addon/templates/management/vendors/index.hbs +2 -0
- package/addon/templates/management/vendors/integrated.hbs +1 -0
- package/addon/templates/operations/orders/index/details.hbs +1 -0
- package/addon/templates/operations/orders/index.hbs +1 -0
- package/addon/templates/operations/service-rates/index/details.hbs +1 -0
- package/addon/templates/operations/service-rates/index.hbs +1 -0
- package/addon/utils/normalize-order-config-flow.js +6 -1
- package/app/services/order-presentation.js +1 -0
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +3 -3
- package/server/src/Http/Controllers/Internal/v1/OrderController.php +34 -4
- package/server/src/Models/Order.php +35 -3
- package/server/src/Models/OrderConfig.php +129 -0
- package/server/src/Models/TrackingNumber.php +8 -4
- package/server/tests/Feature/Http/Internal/OrderControllerActivityFlowsTest.php +72 -0
- package/server/tests/Feature/Http/Internal/OrderControllerCreateRecordTest.php +26 -0
- package/server/tests/OrderConfigLifecycleTest.php +120 -0
- package/server/tests/Unit/Events/OrderDispatchFailedTest.php +2 -1
- package/translations/en-us.yaml +60 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{{#if (eq this.layout "table")}}
|
|
2
2
|
<Layout::Resource::Tabular
|
|
3
|
+
@registry="fleet-ops:equipment:table"
|
|
3
4
|
@resource="equipment"
|
|
4
5
|
@title={{t "resource.equipment"}}
|
|
5
6
|
@searchQuery={{this.query}}
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
{{else}}
|
|
35
36
|
<Layout::Section::Header @title={{t "resource.equipment"}} @actionsWrapperClass="space-x-1">
|
|
36
37
|
<Layout::Resource::TabularActions
|
|
38
|
+
@registry="fleet-ops:equipment:table"
|
|
37
39
|
@searchQuery={{this.query}}
|
|
38
40
|
@onSearch={{perform this.equipmentActions.controllerSearchTask this}}
|
|
39
41
|
@columns={{this.columns}}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<Layout::Resource::Panel
|
|
2
|
+
@registry="fleet-ops:inspection-submission:details"
|
|
2
3
|
@resource={{@model}}
|
|
3
4
|
@controller={{this}}
|
|
4
5
|
@headerTitle={{if (or @model.form.name @model.form_name) (t "inspection.record.submission-title" form=(or @model.form.name @model.form_name)) (or @model.public_id (t "inspection.record.inspection"))}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{{#if (eq this.layout "table")}}
|
|
2
2
|
<Layout::Resource::Tabular
|
|
3
|
+
@registry="fleet-ops:part:table"
|
|
3
4
|
@resource="part"
|
|
4
5
|
@title={{t "resource.parts"}}
|
|
5
6
|
@searchQuery={{this.query}}
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
{{else}}
|
|
35
36
|
<Layout::Section::Header @title={{t "resource.parts"}} @actionsWrapperClass="space-x-1">
|
|
36
37
|
<Layout::Resource::TabularActions
|
|
38
|
+
@registry="fleet-ops:part:table"
|
|
37
39
|
@searchQuery={{this.query}}
|
|
38
40
|
@onSearch={{perform this.partActions.controllerSearchTask this}}
|
|
39
41
|
@columns={{this.columns}}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
{{! FullCalendar v6 calls it automatically on render and navigation. }}
|
|
5
5
|
<Layout::Section::Header @title={{t "resource.maintenance-schedules"}} @actionsWrapperClass="space-x-1">
|
|
6
6
|
<Layout::Resource::TabularActions
|
|
7
|
+
@registry="fleet-ops:schedule:table"
|
|
7
8
|
@searchQuery={{this.query}}
|
|
8
9
|
@onSearch={{perform this.scheduleActions.controllerSearchTask this}}
|
|
9
10
|
@columns={{this.columns}}
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
{{else}}
|
|
25
26
|
{{! ===== LIST VIEW (default) ===== }}
|
|
26
27
|
<Layout::Resource::Tabular
|
|
28
|
+
@registry="fleet-ops:schedule:table"
|
|
27
29
|
@resource="maintenance-schedule"
|
|
28
30
|
@title={{t "resource.maintenance-schedules"}}
|
|
29
31
|
@searchQuery={{this.query}}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<:actions>
|
|
3
3
|
<div class="flex flex-row items-center space-x-1 pr-4">
|
|
4
4
|
<Layout::Resource::TabularActions
|
|
5
|
+
@registry={{this.childController.tableRegistry}}
|
|
5
6
|
@columns={{this.childController.columns}}
|
|
6
7
|
@actionButtons={{this.childController.actionButtons}}
|
|
7
8
|
@bulkActions={{this.childController.bulkActions}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{{#if (eq this.layout "table")}}
|
|
2
2
|
<Layout::Resource::Tabular
|
|
3
|
+
@registry="fleet-ops:driver:table"
|
|
3
4
|
@resource="driver"
|
|
4
5
|
@title={{t "resource.drivers"}}
|
|
5
6
|
@searchQuery={{this.query}}
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
{{else}}
|
|
35
36
|
<Layout::Section::Header @title={{t "resource.drivers"}} @actionsWrapperClass="space-x-1">
|
|
36
37
|
<Layout::Resource::TabularActions
|
|
38
|
+
@registry="fleet-ops:driver:table"
|
|
37
39
|
@searchQuery={{this.query}}
|
|
38
40
|
@onSearch={{perform this.driverActions.controllerSearchTask this}}
|
|
39
41
|
@columns={{this.columns}}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<div class="flex h-full flex-col bg-white dark:bg-gray-900">
|
|
3
3
|
<div class="min-h-0 flex-1 overflow-y-auto">
|
|
4
4
|
<Layout::Resource::Tabular
|
|
5
|
+
@registry="fleet-ops:fuel-transaction:table"
|
|
5
6
|
@resource="fuel-provider-transaction"
|
|
6
7
|
@title={{t "menu.fuel-transactions"}}
|
|
7
8
|
@searchQuery={{this.query}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{{#if (eq this.layout "table")}}
|
|
2
2
|
<Layout::Resource::Tabular
|
|
3
|
+
@registry="fleet-ops:trailer:table"
|
|
3
4
|
@resource="trailer"
|
|
4
5
|
@title={{t "resource.trailers"}}
|
|
5
6
|
@searchQuery={{this.query}}
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
{{else}}
|
|
35
36
|
<Layout::Section::Header @title={{t "resource.trailers"}} @actionsWrapperClass="space-x-1">
|
|
36
37
|
<Layout::Resource::TabularActions
|
|
38
|
+
@registry="fleet-ops:trailer:table"
|
|
37
39
|
@searchQuery={{this.query}}
|
|
38
40
|
@onSearch={{perform this.trailerActions.controllerSearchTask this}}
|
|
39
41
|
@columns={{this.columns}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{{#if (eq this.layout "table")}}
|
|
2
2
|
<Layout::Resource::Tabular
|
|
3
|
+
@registry="fleet-ops:vehicle:table"
|
|
3
4
|
@resource="vehicle"
|
|
4
5
|
@title={{t "resource.vehicles"}}
|
|
5
6
|
@searchQuery={{this.query}}
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
{{else}}
|
|
35
36
|
<Layout::Section::Header @title={{t "resource.vehicles"}} @actionsWrapperClass="space-x-1">
|
|
36
37
|
<Layout::Resource::TabularActions
|
|
38
|
+
@registry="fleet-ops:vehicle:table"
|
|
37
39
|
@searchQuery={{this.query}}
|
|
38
40
|
@onSearch={{perform this.vehicleActions.controllerSearchTask this}}
|
|
39
41
|
@columns={{this.columns}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{{#if (eq this.layout "table")}}
|
|
2
2
|
<Layout::Resource::Tabular
|
|
3
|
+
@registry="fleet-ops:vendor:table"
|
|
3
4
|
@resource="vendor"
|
|
4
5
|
@title={{t "resource.vendors"}}
|
|
5
6
|
@searchQuery={{this.query}}
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
{{else}}
|
|
35
36
|
<Layout::Section::Header @title={{t "resource.vendors"}} @actionsWrapperClass="space-x-1">
|
|
36
37
|
<Layout::Resource::TabularActions
|
|
38
|
+
@registry="fleet-ops:vendor:table"
|
|
37
39
|
@searchQuery={{this.query}}
|
|
38
40
|
@onSearch={{perform this.vendorActions.controllerSearchTask this}}
|
|
39
41
|
@columns={{this.columns}}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { isArray } from '@ember/array';
|
|
2
2
|
|
|
3
|
-
export function getOrderConfigFlowRootCode(flow = {}) {
|
|
3
|
+
export function getOrderConfigFlowRootCode(flow = {}, initialCode = null) {
|
|
4
|
+
// A configured lifecycle (`meta.lifecycle.initial`) names its own root activity.
|
|
5
|
+
if (initialCode && flow[initialCode]) {
|
|
6
|
+
return initialCode;
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
if (flow.created) {
|
|
5
10
|
return 'created';
|
|
6
11
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/services/order-presentation';
|
package/composer.json
CHANGED
package/extension.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fleetbase/fleetops-engine",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.71",
|
|
4
4
|
"description": "Fleet & Transport Management Extension for Fleetbase",
|
|
5
5
|
"fleetbase": {
|
|
6
6
|
"route": "fleet-ops"
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/core": "^7.23.2",
|
|
47
|
-
"@fleetbase/ember-core": "^0.3.
|
|
48
|
-
"@fleetbase/ember-ui": "^0.4.
|
|
47
|
+
"@fleetbase/ember-core": "^0.3.25",
|
|
48
|
+
"@fleetbase/ember-ui": "^0.4.5",
|
|
49
49
|
"@fleetbase/fleetops-data": "^0.2.2",
|
|
50
50
|
"@fleetbase/leaflet-routing-machine": "^3.2.17",
|
|
51
51
|
"@fortawesome/ember-fontawesome": "^2.0.0",
|
|
@@ -163,8 +163,15 @@ class OrderController extends FleetOpsController
|
|
|
163
163
|
$input['type'] = 'transport';
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
// a configured lifecycle always starts at its initial activity; otherwise
|
|
166
167
|
// if no status is set its default to `created`
|
|
167
|
-
if (
|
|
168
|
+
if ($resolvedOrderConfig && $resolvedOrderConfig->hasConfiguredLifecycle()) {
|
|
169
|
+
$input['status'] = $resolvedOrderConfig->getInitialStatusCode();
|
|
170
|
+
if (!$resolvedOrderConfig->allowsDispatch()) {
|
|
171
|
+
$input['dispatched'] = false;
|
|
172
|
+
$input['adhoc'] = false;
|
|
173
|
+
}
|
|
174
|
+
} elseif (!isset($input['status'])) {
|
|
168
175
|
$input['status'] = 'created';
|
|
169
176
|
}
|
|
170
177
|
|
|
@@ -185,11 +192,13 @@ class OrderController extends FleetOpsController
|
|
|
185
192
|
$entities = Utils::get($input, 'payload.entities');
|
|
186
193
|
$uploads = Utils::get($input, 'files', []);
|
|
187
194
|
$customFieldValues = Utils::get($input, 'custom_field_values', []);
|
|
195
|
+
$orderConfig = $order->config();
|
|
196
|
+
$hasLifecycle = $orderConfig && $orderConfig->hasConfiguredLifecycle();
|
|
188
197
|
|
|
189
198
|
// save order route & payload with request input
|
|
190
199
|
$order
|
|
191
200
|
->setRoute($route)
|
|
192
|
-
->setStatus('created', false)
|
|
201
|
+
->setStatus($hasLifecycle ? $orderConfig->getInitialStatusCode() : 'created', false)
|
|
193
202
|
->insertPayload($payload)
|
|
194
203
|
->insertWaypoints($waypoints)
|
|
195
204
|
->insertEntities($entities);
|
|
@@ -212,8 +221,12 @@ class OrderController extends FleetOpsController
|
|
|
212
221
|
);
|
|
213
222
|
}
|
|
214
223
|
|
|
215
|
-
// Check dispatch flag with backward compatibility (default true)
|
|
224
|
+
// Check dispatch flag with backward compatibility (default true).
|
|
225
|
+
// Configs with a lifecycle that disables dispatch are never dispatched.
|
|
216
226
|
$shouldDispatch = isset($input['dispatched']) ? (bool) $input['dispatched'] : true;
|
|
227
|
+
if ($hasLifecycle && !$orderConfig->allowsDispatch()) {
|
|
228
|
+
$shouldDispatch = false;
|
|
229
|
+
}
|
|
217
230
|
|
|
218
231
|
// dispatch if flagged true, otherwise ensure order stays in created state
|
|
219
232
|
if ($shouldDispatch) {
|
|
@@ -483,7 +496,7 @@ class OrderController extends FleetOpsController
|
|
|
483
496
|
$successful = [];
|
|
484
497
|
|
|
485
498
|
foreach ($orders as $order) {
|
|
486
|
-
if ($order->status !== 'created') {
|
|
499
|
+
if ($order->status !== 'created' || $order->config()?->allowsDispatch() === false) {
|
|
487
500
|
$failed[] = $order->uuid;
|
|
488
501
|
continue;
|
|
489
502
|
}
|
|
@@ -615,6 +628,10 @@ class OrderController extends FleetOpsController
|
|
|
615
628
|
return $this->errorResponse('No order config found for dispatch.');
|
|
616
629
|
}
|
|
617
630
|
|
|
631
|
+
if (!$order->config()->allowsDispatch()) {
|
|
632
|
+
return $this->errorResponse('Orders of this type are not dispatched.');
|
|
633
|
+
}
|
|
634
|
+
|
|
618
635
|
if (!$order->hasDriverAssigned && !$order->adhoc) {
|
|
619
636
|
return $this->errorResponse('No driver assigned to dispatch!');
|
|
620
637
|
}
|
|
@@ -900,6 +917,19 @@ class OrderController extends FleetOpsController
|
|
|
900
917
|
$activity = $request->array('activity');
|
|
901
918
|
$activity = new Activity($activity, $order->getConfigFlow());
|
|
902
919
|
|
|
920
|
+
// Configs with strict transitions only accept a configured child of the current
|
|
921
|
+
// activity, and the server-side activity definition replaces the client payload.
|
|
922
|
+
$orderConfig = $order->config();
|
|
923
|
+
if ($orderConfig && $orderConfig->hasStrictTransitions()) {
|
|
924
|
+
$targetCode = $activity->get('code');
|
|
925
|
+
$configured = $targetCode ? $orderConfig->getActivityByCode($targetCode) : null;
|
|
926
|
+
if (!$configured || !$orderConfig->canTransition($order->status, $targetCode)) {
|
|
927
|
+
return response()->error('This activity is not a permitted next step for the order.', 422);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
$activity = $configured;
|
|
931
|
+
}
|
|
932
|
+
|
|
903
933
|
$requiresProof = Utils::isActivity($activity)
|
|
904
934
|
&& ($activity->get('require_pod') || ($activity->completesOrder() && $order->pod_required));
|
|
905
935
|
if ($requiresProof && !$proof && !$bypassProof) {
|
|
@@ -1346,10 +1346,11 @@ class Order extends Model
|
|
|
1346
1346
|
*/
|
|
1347
1347
|
public function cancel()
|
|
1348
1348
|
{
|
|
1349
|
-
|
|
1350
|
-
|
|
1349
|
+
// The canceled activity comes from the order config, which may define its own code.
|
|
1351
1350
|
$this->loadMissing('orderConfig');
|
|
1352
|
-
$
|
|
1351
|
+
$orderConfig = $this->orderConfig ?? $this->config();
|
|
1352
|
+
$canceledActivity = $orderConfig->getCanceledActivity();
|
|
1353
|
+
$this->status = $canceledActivity->code ?? 'canceled';
|
|
1353
1354
|
$this->updateActivity($canceledActivity);
|
|
1354
1355
|
|
|
1355
1356
|
if ($this->isIntegratedVendorOrder()) {
|
|
@@ -1783,6 +1784,37 @@ class Order extends Model
|
|
|
1783
1784
|
return (int) Utils::get($this, 'adhoc_distance', Utils::get($this, 'company.options.fleetops.adhoc_distance', 6000));
|
|
1784
1785
|
}
|
|
1785
1786
|
|
|
1787
|
+
/**
|
|
1788
|
+
* Returns the initial tracking status for a newly created order.
|
|
1789
|
+
*
|
|
1790
|
+
* Used by the tracking number on creation. Orders whose config defines its own
|
|
1791
|
+
* lifecycle start at the configured initial activity instead of `created`.
|
|
1792
|
+
*
|
|
1793
|
+
* @return array|null ['code', 'status', 'details'] or null to use the default created status
|
|
1794
|
+
*/
|
|
1795
|
+
public function getInitialTrackingStatus(): ?array
|
|
1796
|
+
{
|
|
1797
|
+
if (!$this->order_config_uuid) {
|
|
1798
|
+
return null;
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
$orderConfig = OrderConfig::where('uuid', $this->order_config_uuid)->first();
|
|
1802
|
+
if (!$orderConfig || !$orderConfig->hasConfiguredLifecycle()) {
|
|
1803
|
+
return null;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
$activity = $orderConfig->getInitialActivity();
|
|
1807
|
+
if (!$activity) {
|
|
1808
|
+
return null;
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
return [
|
|
1812
|
+
'code' => $activity->code,
|
|
1813
|
+
'status' => $this->resolveActivityTemplateString((string) $activity->get('status', '')),
|
|
1814
|
+
'details' => $this->resolveActivityTemplateString((string) $activity->get('details', '')),
|
|
1815
|
+
];
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1786
1818
|
/**
|
|
1787
1819
|
* Retrieves the OrderConfig associated with this order.
|
|
1788
1820
|
*
|