@fleetbase/fleetops-engine 0.4.17 → 0.4.18

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.
@@ -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
+ }