@fleetbase/fleetops-engine 0.4.17 → 0.4.19
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/addon/components/activity-form-panel.hbs +19 -0
- package/addon/components/activity-form-panel.js +18 -0
- package/addon/components/live-map.js +14 -7
- package/addon/components/order-config-manager/details.js +15 -6
- package/addon/components/order-config-manager.js +20 -7
- package/addon/controllers/operations/order-config.js +2 -1
- package/addon/controllers/operations/orders/index/new.js +5 -0
- package/addon/controllers/operations/service-rates/index/new.js +23 -2
- package/addon/routes/operations/service-rates/index/edit.js +14 -5
- package/addon/routes/operations/service-rates/index/new.js +2 -6
- package/addon/services/location.js +54 -44
- package/addon/templates/operations/service-rates/index/new.hbs +10 -1
- package/composer.json +3 -3
- package/extension.json +1 -1
- package/package.json +3 -3
- package/server/config/api.php +3 -650
- package/server/config/fleetops.php +127 -4
- package/server/migrations/2024_03_12_033527_add_public_id_column_to_order_configs_table.php +34 -0
- package/server/migrations/2024_03_13_061249_add_order_config_uuid_column_to_service_rates_table.php +28 -0
- package/server/seeders/OrderConfigSeeder.php +2 -130
- package/server/src/Console/Commands/FixLegacyOrderConfigs.php +17 -11
- package/server/src/Http/Controllers/Api/v1/OrderController.php +25 -3
- package/server/src/Http/Controllers/Api/v1/ServiceQuoteController.php +10 -5
- package/server/src/Http/Controllers/Internal/v1/OrderConfigController.php +61 -0
- package/server/src/Http/Controllers/Internal/v1/OrderController.php +12 -2
- package/server/src/Http/Controllers/Internal/v1/ServiceRateController.php +3 -0
- package/server/src/Http/Requests/CreateOrderRequest.php +32 -13
- package/server/src/Http/Requests/Internal/CreateOrderConfigRequest.php +40 -0
- package/server/src/Http/Requests/Internal/CreateOrderRequest.php +97 -0
- package/server/src/Http/Requests/Internal/DeleteOrderConfigRequest.php +0 -0
- package/server/src/Http/Resources/v1/Order.php +1 -1
- package/server/src/Http/Resources/v1/ServiceRate.php +34 -31
- package/server/src/Models/OrderConfig.php +48 -0
- package/server/src/Models/ServiceRate.php +9 -0
- package/server/src/Observers/CompanyObserver.php +20 -0
- package/server/src/Providers/FleetOpsServiceProvider.php +1 -0
- package/server/src/Support/FleetOps.php +137 -0
- package/translations/en-us.yaml +6 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Http\Requests;
|
|
4
4
|
|
|
5
|
+
use Fleetbase\FleetOps\Support\Utils;
|
|
5
6
|
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
7
|
use Fleetbase\Rules\ExistsInAny;
|
|
7
8
|
|
|
@@ -25,21 +26,26 @@ class CreateOrderRequest extends FleetbaseRequest
|
|
|
25
26
|
public function rules()
|
|
26
27
|
{
|
|
27
28
|
$validations = [
|
|
28
|
-
'adhoc'
|
|
29
|
-
'dispatch'
|
|
30
|
-
'adhoc_distance'
|
|
31
|
-
'pod_required'
|
|
32
|
-
'pod_method'
|
|
33
|
-
'scheduled_at'
|
|
34
|
-
'driver'
|
|
35
|
-
'service_quote'
|
|
36
|
-
'purchase_rate'
|
|
37
|
-
'facilitator'
|
|
38
|
-
'customer'
|
|
39
|
-
'status'
|
|
40
|
-
'type'
|
|
29
|
+
'adhoc' => ['nullable', 'boolean'],
|
|
30
|
+
'dispatch' => ['nullable', 'boolean'],
|
|
31
|
+
'adhoc_distance' => ['nullable', 'numeric'],
|
|
32
|
+
'pod_required' => ['nullable', 'boolean'],
|
|
33
|
+
'pod_method' => ['nullable', 'in:' . config('fleetops.pod_methods')],
|
|
34
|
+
'scheduled_at' => ['nullable', 'date'],
|
|
35
|
+
'driver' => ['nullable', 'exists:drivers,public_id'],
|
|
36
|
+
'service_quote' => ['nullable', 'exists:service_quotes,public_id'],
|
|
37
|
+
'purchase_rate' => ['nullable', 'exists:purchase_rates,public_id'],
|
|
38
|
+
'facilitator' => ['nullable', new ExistsInAny(['vendors', 'contacts', 'integrated_vendors'], ['public_id', 'provider'])],
|
|
39
|
+
'customer' => ['nullable', new ExistsInAny(['vendors', 'contacts'], 'public_id')],
|
|
40
|
+
'status' => ['nullable', 'string'],
|
|
41
|
+
'type' => ['string'],
|
|
41
42
|
];
|
|
42
43
|
|
|
44
|
+
// Conditionally require 'pod_method' if 'pod_required' is truthy
|
|
45
|
+
if (Utils::isTrue($this->input('pod_required'))) {
|
|
46
|
+
$validations['pod_method'] = ['required', 'in:' . implode(',', config('fleetops.pod_methods'))];
|
|
47
|
+
}
|
|
48
|
+
|
|
43
49
|
if ($this->has('payload')) {
|
|
44
50
|
$validations['payload.entities'] = 'array';
|
|
45
51
|
$validations['payload.waypoints'] = 'array';
|
|
@@ -77,4 +83,17 @@ class CreateOrderRequest extends FleetbaseRequest
|
|
|
77
83
|
|
|
78
84
|
return $validations;
|
|
79
85
|
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get custom attributes for validator errors.
|
|
89
|
+
*
|
|
90
|
+
* @return array<string, string>
|
|
91
|
+
*/
|
|
92
|
+
public function attributes(): array
|
|
93
|
+
{
|
|
94
|
+
return [
|
|
95
|
+
'pod_required' => 'proof of delivery required',
|
|
96
|
+
'pod_method' => 'proof of delivery method',
|
|
97
|
+
];
|
|
98
|
+
}
|
|
80
99
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Requests\Internal;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
|
+
use Illuminate\Validation\Rule;
|
|
7
|
+
|
|
8
|
+
class CreateOrderConfigRequest extends FleetbaseRequest
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Determine if the user is authorized to make this request.
|
|
12
|
+
*
|
|
13
|
+
* @return bool
|
|
14
|
+
*/
|
|
15
|
+
public function authorize()
|
|
16
|
+
{
|
|
17
|
+
return request()->session()->has('company');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get the validation rules that apply to the request.
|
|
22
|
+
*
|
|
23
|
+
* @return array
|
|
24
|
+
*/
|
|
25
|
+
public function rules()
|
|
26
|
+
{
|
|
27
|
+
return [
|
|
28
|
+
'name' => [
|
|
29
|
+
'required',
|
|
30
|
+
Rule::unique('order_configs', 'name')
|
|
31
|
+
->where('company_uuid', request()->session()->get('company'))->whereNull('deleted_at'),
|
|
32
|
+
],
|
|
33
|
+
'key' => [
|
|
34
|
+
'required',
|
|
35
|
+
Rule::unique('order_configs', 'key')
|
|
36
|
+
->where('company_uuid', request()->session()->get('company'))->whereNull('deleted_at'),
|
|
37
|
+
],
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Requests\Internal;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Support\Utils;
|
|
6
|
+
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
7
|
+
use Fleetbase\Rules\ExistsInAny;
|
|
8
|
+
|
|
9
|
+
class CreateOrderRequest extends FleetbaseRequest
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Determine if the user is authorized to make this request.
|
|
13
|
+
*
|
|
14
|
+
* @return bool
|
|
15
|
+
*/
|
|
16
|
+
public function authorize()
|
|
17
|
+
{
|
|
18
|
+
return request()->session()->has('company');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get the validation rules that apply to the request.
|
|
23
|
+
*
|
|
24
|
+
* @return array
|
|
25
|
+
*/
|
|
26
|
+
public function rules()
|
|
27
|
+
{
|
|
28
|
+
$validations = [
|
|
29
|
+
'order_config_uuid' => ['required'],
|
|
30
|
+
'adhoc' => ['nullable', 'boolean'],
|
|
31
|
+
'dispatch' => ['nullable', 'boolean'],
|
|
32
|
+
'adhoc_distance' => ['nullable', 'numeric'],
|
|
33
|
+
'pod_required' => ['nullable', 'boolean'],
|
|
34
|
+
'pod_method' => ['nullable', 'in:' . config('fleetops.pod_methods')],
|
|
35
|
+
'scheduled_at' => ['nullable', 'date'],
|
|
36
|
+
'driver' => ['nullable', 'exists:drivers,uuid'],
|
|
37
|
+
'service_quote' => ['nullable', 'exists:service_quotes,uuid'],
|
|
38
|
+
'purchase_rate' => ['nullable', 'exists:purchase_rates,uuid'],
|
|
39
|
+
'facilitator' => ['nullable', new ExistsInAny(['vendors', 'contacts', 'integrated_vendors'], ['uuid', 'provider'])],
|
|
40
|
+
'customer' => ['nullable', new ExistsInAny(['vendors', 'contacts'], 'uuid')],
|
|
41
|
+
'status' => ['nullable', 'string'],
|
|
42
|
+
'type' => ['string'],
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
// Conditionally require 'pod_method' if 'pod_required' is truthy
|
|
46
|
+
if (Utils::isTrue($this->input('order.pod_required'))) {
|
|
47
|
+
$validations['pod_method'] = ['required', 'in:' . config('fleetops.pod_methods')];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if ($this->has('payload')) {
|
|
51
|
+
$validations['payload.entities'] = 'array';
|
|
52
|
+
$validations['payload.waypoints'] = 'array';
|
|
53
|
+
|
|
54
|
+
if ($this->isArray('payload')) {
|
|
55
|
+
$validations['payload'] = 'required';
|
|
56
|
+
|
|
57
|
+
if ($this->missing('payload.waypoints')) {
|
|
58
|
+
$validations['payload.pickup_uuid'] = 'required';
|
|
59
|
+
$validations['payload.dropoff_uuid'] = 'required';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if ($this->missing(['payload.pickup', 'payload.dropoff'])) {
|
|
63
|
+
$validations['payload.waypoints'] = 'required|array|min:2';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
$validations['payload.return_uuid'] = 'nullable';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return $validations;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get the error messages for the defined validation rules.
|
|
75
|
+
*
|
|
76
|
+
* @return array<string, string>
|
|
77
|
+
*/
|
|
78
|
+
public function messages(): array
|
|
79
|
+
{
|
|
80
|
+
return [
|
|
81
|
+
'pod_method.required' => 'A proof of delivery method is required.',
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get custom attributes for validator errors.
|
|
87
|
+
*
|
|
88
|
+
* @return array<string, string>
|
|
89
|
+
*/
|
|
90
|
+
public function attributes(): array
|
|
91
|
+
{
|
|
92
|
+
return [
|
|
93
|
+
'pod_required' => 'proof of delivery required',
|
|
94
|
+
'pod_method' => 'proof of delivery method',
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
File without changes
|
|
@@ -39,7 +39,7 @@ class Order extends FleetbaseResource
|
|
|
39
39
|
'service_quote_uuid' => $this->when(Http::isInternalRequest(), $this->service_quote_uuid),
|
|
40
40
|
'has_driver_assigned' => $this->when(Http::isInternalRequest(), $this->has_driver_assigned),
|
|
41
41
|
'is_scheduled' => $this->when(Http::isInternalRequest(), $this->is_scheduled),
|
|
42
|
-
'order_config' => $this->when(Http::isInternalRequest(), $this->whenLoaded('orderConfig', $this->orderConfig)),
|
|
42
|
+
'order_config' => $this->when(Http::isInternalRequest(), $this->whenLoaded('orderConfig', $this->orderConfig), data_get($this->orderConfig, 'public_id')),
|
|
43
43
|
'custom_field_values' => $this->when(Http::isInternalRequest(), $this->customFieldValues),
|
|
44
44
|
'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
|
|
45
45
|
'payload' => new Payload($this->payload),
|
|
@@ -18,37 +18,40 @@ class ServiceRate extends FleetbaseResource
|
|
|
18
18
|
public function toArray($request)
|
|
19
19
|
{
|
|
20
20
|
return [
|
|
21
|
-
'id'
|
|
22
|
-
'uuid'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'
|
|
51
|
-
'
|
|
21
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
22
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
23
|
+
'service_area_uuid' => $this->when(Http::isInternalRequest(), $this->service_area_uuid),
|
|
24
|
+
'zone_uuid' => $this->when(Http::isInternalRequest(), $this->zone_uuid),
|
|
25
|
+
'order_config_uuid' => $this->when(Http::isInternalRequest(), $this->order_config_uuid),
|
|
26
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
27
|
+
'service_area' => $this->whenLoaded('serviceArea', new ServiceArea($this->serviceArea)),
|
|
28
|
+
'service_area_name' => $this->when(Http::isInternalRequest(), data_get($this, 'serviceArea.name')),
|
|
29
|
+
'zone' => $this->whenLoaded('zone', new Zone($this->zone)),
|
|
30
|
+
'zone_name' => $this->when(Http::isInternalRequest(), data_get($this, 'zone.name')),
|
|
31
|
+
'service_name' => $this->service_name,
|
|
32
|
+
'service_type' => $this->service_type,
|
|
33
|
+
'base_fee' => $this->base_fee,
|
|
34
|
+
'rate_calculation_method' => $this->rate_calculation_method,
|
|
35
|
+
'per_meter_flat_rate_fee' => $this->per_meter_flat_rate_fee,
|
|
36
|
+
'per_meter_unit' => $this->per_meter_unit,
|
|
37
|
+
'meter_fees' => ServiceRateFee::collection($this->rateFees ?? []),
|
|
38
|
+
'parcel_fees' => ServiceRateParcelFee::collection($this->rateFees ?? []),
|
|
39
|
+
'algorithm' => $this->algorithm,
|
|
40
|
+
'has_cod_fee' => Utils::castBoolean($this->has_cod_fee),
|
|
41
|
+
'cod_calculation_method' => $this->cod_calculation_method,
|
|
42
|
+
'cod_flat_fee' => $this->cod_flat_fee,
|
|
43
|
+
'cod_percent' => $this->cod_percent,
|
|
44
|
+
'has_peak_hours_fee' => Utils::castBoolean($this->has_peak_hours_fee),
|
|
45
|
+
'peak_hours_calculation_method' => $this->peak_hours_calculation_method,
|
|
46
|
+
'peak_hours_flat_fee' => $this->peak_hours_flat_fee,
|
|
47
|
+
'peak_hours_percent' => $this->peak_hours_percent,
|
|
48
|
+
'peak_hours_start' => $this->peak_hours_start,
|
|
49
|
+
'peak_hours_end' => $this->peak_hours_end,
|
|
50
|
+
'currency' => $this->currency,
|
|
51
|
+
'duration_terms' => $this->duration_terms,
|
|
52
|
+
'estimated_days' => $this->estimated_days,
|
|
53
|
+
'updated_at' => $this->updated_at,
|
|
54
|
+
'created_at' => $this->created_at,
|
|
52
55
|
];
|
|
53
56
|
}
|
|
54
57
|
|
|
@@ -5,10 +5,12 @@ namespace Fleetbase\FleetOps\Models;
|
|
|
5
5
|
use Fleetbase\Casts\Json;
|
|
6
6
|
use Fleetbase\FleetOps\Casts\OrderConfigEntities;
|
|
7
7
|
use Fleetbase\FleetOps\Flow\Activity;
|
|
8
|
+
use Fleetbase\Models\Company;
|
|
8
9
|
use Fleetbase\Models\Model;
|
|
9
10
|
use Fleetbase\Support\Auth;
|
|
10
11
|
use Fleetbase\Traits\HasApiModelBehavior;
|
|
11
12
|
use Fleetbase\Traits\HasMetaAttributes;
|
|
13
|
+
use Fleetbase\Traits\HasPublicId;
|
|
12
14
|
use Fleetbase\Traits\HasUuid;
|
|
13
15
|
use Fleetbase\Traits\Searchable;
|
|
14
16
|
use Illuminate\Support\Collection;
|
|
@@ -17,6 +19,7 @@ use Illuminate\Support\Str;
|
|
|
17
19
|
class OrderConfig extends Model
|
|
18
20
|
{
|
|
19
21
|
use HasUuid;
|
|
22
|
+
use HasPublicId;
|
|
20
23
|
use Searchable;
|
|
21
24
|
use HasMetaAttributes;
|
|
22
25
|
use HasApiModelBehavior;
|
|
@@ -28,6 +31,13 @@ class OrderConfig extends Model
|
|
|
28
31
|
*/
|
|
29
32
|
protected $table = 'order_configs';
|
|
30
33
|
|
|
34
|
+
/**
|
|
35
|
+
* The type of public Id to generate.
|
|
36
|
+
*
|
|
37
|
+
* @var string
|
|
38
|
+
*/
|
|
39
|
+
protected $publicIdType = 'order_config';
|
|
40
|
+
|
|
31
41
|
/**
|
|
32
42
|
* These attributes that can be queried.
|
|
33
43
|
*
|
|
@@ -41,6 +51,7 @@ class OrderConfig extends Model
|
|
|
41
51
|
* @var array
|
|
42
52
|
*/
|
|
43
53
|
protected $fillable = [
|
|
54
|
+
'public_id',
|
|
44
55
|
'company_uuid',
|
|
45
56
|
'author_uuid',
|
|
46
57
|
'category_uuid',
|
|
@@ -416,4 +427,41 @@ class OrderConfig extends Model
|
|
|
416
427
|
'complete' => false,
|
|
417
428
|
], $this->flow);
|
|
418
429
|
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Resolves an OrderConfig from a given identifier or an array of identifiers within an optional company context.
|
|
433
|
+
*
|
|
434
|
+
* @param string|array $orderConfigIdentifier the identifier(s) for the OrderConfig (namespace, public_id, or key)
|
|
435
|
+
* @param Company|null $company the company context, if any, to narrow down the search
|
|
436
|
+
*
|
|
437
|
+
* @return OrderConfig|null the found OrderConfig or null if none found
|
|
438
|
+
*/
|
|
439
|
+
public static function resolveFromIdentifier($orderConfigIdentifier, ?Company $company = null): ?OrderConfig
|
|
440
|
+
{
|
|
441
|
+
$query = static::query();
|
|
442
|
+
|
|
443
|
+
if ($company instanceof Company) {
|
|
444
|
+
$query->where('company_uuid', $company->uuid);
|
|
445
|
+
} else {
|
|
446
|
+
$companyUuid = session('company');
|
|
447
|
+
if ($companyUuid) {
|
|
448
|
+
$query->where('company_uuid', $companyUuid);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
$identifiers = is_array($orderConfigIdentifier) ? $orderConfigIdentifier : [$orderConfigIdentifier];
|
|
453
|
+
foreach ($identifiers as $identifier) {
|
|
454
|
+
$orderConfig = $query->where(function ($query) use ($identifier) {
|
|
455
|
+
$query->where('namespace', $identifier)
|
|
456
|
+
->orWhere('public_id', $identifier)
|
|
457
|
+
->orWhere('key', $identifier);
|
|
458
|
+
})->first();
|
|
459
|
+
|
|
460
|
+
if ($orderConfig) {
|
|
461
|
+
return $orderConfig;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
419
467
|
}
|
|
@@ -53,6 +53,7 @@ class ServiceRate extends Model
|
|
|
53
53
|
'company_uuid',
|
|
54
54
|
'service_area_uuid',
|
|
55
55
|
'zone_uuid',
|
|
56
|
+
'order_config_uuid',
|
|
56
57
|
'service_name',
|
|
57
58
|
'service_type',
|
|
58
59
|
'per_meter_flat_rate_fee',
|
|
@@ -124,6 +125,14 @@ class ServiceRate extends Model
|
|
|
124
125
|
return $this->hasMany(ServiceRateParcelFee::class);
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
/**
|
|
129
|
+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
130
|
+
*/
|
|
131
|
+
public function orderConfig()
|
|
132
|
+
{
|
|
133
|
+
return $this->belongsTo(OrderConfig::class)->withTrashed();
|
|
134
|
+
}
|
|
135
|
+
|
|
127
136
|
/**
|
|
128
137
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
129
138
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Observers;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Support\FleetOps;
|
|
6
|
+
use Fleetbase\Models\Company;
|
|
7
|
+
|
|
8
|
+
class CompanyObserver
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Handle the Company "created" event.
|
|
12
|
+
*
|
|
13
|
+
* @return void
|
|
14
|
+
*/
|
|
15
|
+
public function created(Company $company)
|
|
16
|
+
{
|
|
17
|
+
// Add the default transport order config
|
|
18
|
+
FleetOps::createTransportConfig($company);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -34,6 +34,7 @@ class FleetOpsServiceProvider extends CoreServiceProvider
|
|
|
34
34
|
\Fleetbase\FleetOps\Models\Vehicle::class => \Fleetbase\FleetOps\Observers\VehicleObserver::class,
|
|
35
35
|
\Fleetbase\FleetOps\Models\Fleet::class => \Fleetbase\FleetOps\Observers\FleetObserver::class,
|
|
36
36
|
\Fleetbase\Models\User::class => \Fleetbase\FleetOps\Observers\UserObserver::class,
|
|
37
|
+
\Fleetbase\Models\Company::class => \Fleetbase\FleetOps\Observers\CompanyObserver::class,
|
|
37
38
|
];
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Support;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Models\OrderConfig;
|
|
6
|
+
use Fleetbase\Models\Company;
|
|
7
|
+
use Illuminate\Support\Str;
|
|
8
|
+
|
|
9
|
+
class FleetOps
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Creates or retrieves an existing transport configuration for a given company.
|
|
13
|
+
*
|
|
14
|
+
* This method attempts to find a transport configuration (`OrderConfig`) for the specified company.
|
|
15
|
+
* If such a configuration exists, it's returned. Otherwise, a new configuration is created with default values,
|
|
16
|
+
* such as the company UUID, key, core service flag, status, version, tags, and predefined workflow steps.
|
|
17
|
+
* These steps include 'created', 'enroute', 'started', 'completed', and 'dispatched', each with specific attributes.
|
|
18
|
+
*
|
|
19
|
+
* @param Company $company the company for which the transport configuration is being created or retrieved
|
|
20
|
+
*
|
|
21
|
+
* @return OrderConfig the transport configuration associated with the specified company
|
|
22
|
+
*/
|
|
23
|
+
public static function createTransportConfig(Company $company): OrderConfig
|
|
24
|
+
{
|
|
25
|
+
return OrderConfig::firstOrCreate(
|
|
26
|
+
[
|
|
27
|
+
'company_uuid' => $company->uuid,
|
|
28
|
+
'key' => 'transport',
|
|
29
|
+
'namespace' => 'system:order-config:transport',
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
'name' => 'Transport',
|
|
33
|
+
'key' => 'transport',
|
|
34
|
+
'namespace' => 'system:order-config:transport',
|
|
35
|
+
'description' => 'Default order configuration for transport',
|
|
36
|
+
'core_service' => 1,
|
|
37
|
+
'status' => 'private',
|
|
38
|
+
'version' => '0.0.1',
|
|
39
|
+
'tags' => ['transport', 'delivery'],
|
|
40
|
+
'entities' => [],
|
|
41
|
+
'meta' => [],
|
|
42
|
+
'flow' => [
|
|
43
|
+
'created' => [
|
|
44
|
+
'key' => 'created',
|
|
45
|
+
'code' => 'created',
|
|
46
|
+
'color' => '#1f2937',
|
|
47
|
+
'logic' => [],
|
|
48
|
+
'events' => [],
|
|
49
|
+
'status' => 'Order Created',
|
|
50
|
+
'actions' => [],
|
|
51
|
+
'details' => 'New order was created.',
|
|
52
|
+
'options' => [],
|
|
53
|
+
'complete' => false,
|
|
54
|
+
'entities' => [],
|
|
55
|
+
'sequence' => 0,
|
|
56
|
+
'activities' => ['dispatched'],
|
|
57
|
+
'internalId' => Str::uuid(),
|
|
58
|
+
'pod_method' => 'scan',
|
|
59
|
+
'require_pod' => false,
|
|
60
|
+
],
|
|
61
|
+
'enroute' => [
|
|
62
|
+
'key' => 'enroute',
|
|
63
|
+
'code' => 'enroute',
|
|
64
|
+
'color' => '#1f2937',
|
|
65
|
+
'logic' => [],
|
|
66
|
+
'events' => [],
|
|
67
|
+
'status' => 'Driver Enroute',
|
|
68
|
+
'actions' => [],
|
|
69
|
+
'details' => 'Driver is en-route.',
|
|
70
|
+
'options' => [],
|
|
71
|
+
'complete' => false,
|
|
72
|
+
'entities' => [],
|
|
73
|
+
'sequence' => 0,
|
|
74
|
+
'activities' => ['completed'],
|
|
75
|
+
'internalId' => Str::uuid(),
|
|
76
|
+
'pod_method' => 'scan',
|
|
77
|
+
'require_pod' => false,
|
|
78
|
+
],
|
|
79
|
+
'started' => [
|
|
80
|
+
'key' => 'started',
|
|
81
|
+
'code' => 'started',
|
|
82
|
+
'color' => '#1f2937',
|
|
83
|
+
'logic' => [],
|
|
84
|
+
'events' => [],
|
|
85
|
+
'status' => 'Order Started',
|
|
86
|
+
'actions' => [],
|
|
87
|
+
'details' => 'Order has been started',
|
|
88
|
+
'options' => [],
|
|
89
|
+
'complete' => false,
|
|
90
|
+
'entities' => [],
|
|
91
|
+
'sequence' => 0,
|
|
92
|
+
'activities' => ['enroute'],
|
|
93
|
+
'internalId' => Str::uuid(),
|
|
94
|
+
'pod_method' => 'scan',
|
|
95
|
+
'require_pod' => false,
|
|
96
|
+
],
|
|
97
|
+
'completed' => [
|
|
98
|
+
'key' => 'completed',
|
|
99
|
+
'code' => 'completed',
|
|
100
|
+
'color' => '#1f2937',
|
|
101
|
+
'logic' => [],
|
|
102
|
+
'events' => [],
|
|
103
|
+
'status' => 'Order Completed',
|
|
104
|
+
'actions' => [],
|
|
105
|
+
'details' => 'Order has been completed.',
|
|
106
|
+
'options' => [],
|
|
107
|
+
'complete' => true,
|
|
108
|
+
'entities' => [],
|
|
109
|
+
'sequence' => 0,
|
|
110
|
+
'activities' => [],
|
|
111
|
+
'internalId' => Str::uuid(),
|
|
112
|
+
'pod_method' => 'scan',
|
|
113
|
+
'require_pod' => false,
|
|
114
|
+
],
|
|
115
|
+
'dispatched' => [
|
|
116
|
+
'key' => 'dispatched',
|
|
117
|
+
'code' => 'dispatched',
|
|
118
|
+
'color' => '#1f2937',
|
|
119
|
+
'logic' => [],
|
|
120
|
+
'events' => [],
|
|
121
|
+
'status' => 'Order Dispatched',
|
|
122
|
+
'actions' => [],
|
|
123
|
+
'details' => 'Order has been dispatched.',
|
|
124
|
+
'options' => [],
|
|
125
|
+
'complete' => false,
|
|
126
|
+
'entities' => [],
|
|
127
|
+
'sequence' => 0,
|
|
128
|
+
'activities' => ['started'],
|
|
129
|
+
'internalId' => Str::uuid(),
|
|
130
|
+
'pod_method' => 'scan',
|
|
131
|
+
'require_pod' => false,
|
|
132
|
+
],
|
|
133
|
+
],
|
|
134
|
+
]
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
package/translations/en-us.yaml
CHANGED
|
@@ -139,6 +139,11 @@ fleet-ops:
|
|
|
139
139
|
code: Code
|
|
140
140
|
status: Status
|
|
141
141
|
details: Details
|
|
142
|
+
proof-of-delivery: Proof of Delivery
|
|
143
|
+
require-pod: Requires Proof of Delivery
|
|
144
|
+
require-pod-help-text: This activity requires a proof to be created before it can be applied to the order.
|
|
145
|
+
select-pod-method: Proof of Delivery Method
|
|
146
|
+
pod-method-placeholder: Select Proof of Delivery Method
|
|
142
147
|
completes-order: Completes Order
|
|
143
148
|
complete: Complete
|
|
144
149
|
key-help: "Enter a key used for programmatic decision-making. This key can represent one or several activities with the same identifier. Note: This key is not required to be unique."
|
|
@@ -1406,7 +1411,7 @@ fleet-ops:
|
|
|
1406
1411
|
service-name: Service Name
|
|
1407
1412
|
service-name-help-text: Display name for this service.
|
|
1408
1413
|
service-order-label: Service Order Type
|
|
1409
|
-
service-order-help-text:
|
|
1414
|
+
service-order-help-text: Select an order configuration to which this service rate will be exclusively applied. This ensures that only orders created with the selected order configuration can utilize this specific service rate.
|
|
1410
1415
|
service-order-placeholder: Select order type to restrict service to
|
|
1411
1416
|
base-fee-label: Base Fee
|
|
1412
1417
|
base-fee-help-text: Set a base fee which represents the minimum cost for this serice.
|