kamau1 commited on
Commit
fd7c25c
·
1 Parent(s): 938ea18

feat: add completion data to the ticket detail endpoint

Browse files
docs/devlogs/browser/response.json CHANGED
@@ -1,48 +1,290 @@
1
  {
2
- "invoice_title": "Invoice for 1 tickets",
3
- "billing_period_start": "2025-12-10",
4
- "billing_period_end": "2025-12-10",
5
- "issue_date": "2025-12-10",
6
- "due_date": "2026-01-09",
7
- "tax_rate": "0.00",
8
- "discount_amount": "0.00",
9
- "currency": "KES",
10
- "notes": null,
11
- "terms_and_conditions": null,
12
- "id": "81c96213-485f-4170-92a0-23c08332923b",
13
- "contractor_id": "1af9fb24-e5bb-40ac-a748-0997580b4c32",
14
- "client_id": "a2455244-d87e-4279-9fca-dc067f06b5c3",
15
- "project_id": "0ade6bd1-e492-4e25-b681-59f42058d29a",
16
- "invoice_number": "INV-TEL-2025-00001",
17
- "subtotal": "0.00",
18
- "tax_amount": "0.00",
19
- "total_amount": "0.00",
20
- "amount_paid": "0.00",
21
- "amount_due": "0.00",
22
- "line_items": [
23
- {
24
- "id": "uqtB0XJIJAviIUWq-Ez7dA",
25
- "type": "ticket",
26
- "ticket_id": "2de41ce7-dff1-4151-9710-87958d18b5c4",
27
- "description": "Installation - Elizabeth Muthoni",
28
- "quantity": "1",
29
- "unit_price": "0.0",
30
- "total": "0.0"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
  ],
33
- "status": "draft",
34
- "sent_date": null,
35
- "paid_date": null,
36
- "payment_method": null,
37
- "payment_reference": null,
38
- "payment_notes": null,
39
- "version": 1,
40
- "previous_version_id": null,
41
- "is_latest_version": true,
42
- "revision_notes": "Initial version - Proof of work invoice",
43
- "created_by_user_id": "c5cf92be-4172-4fe2-af5c-f05d83b3a938",
44
- "created_at": "2025-12-10T20:08:01.056478Z",
45
- "updated_at": "2025-12-10T20:08:01.100142Z",
46
- "deleted_at": null,
47
- "additional_metadata": {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
 
1
  {
2
+ "ticket": {
3
+ "id": "2de41ce7-dff1-4151-9710-87958d18b5c4",
4
+ "project_id": "0ade6bd1-e492-4e25-b681-59f42058d29a",
5
+ "source": "sales_order",
6
+ "source_id": "a1d04741-b1b5-4a9e-baf6-d1e186886122",
7
+ "ticket_name": "Elizabeth Muthoni",
8
+ "ticket_type": "installation",
9
+ "service_type": "ftth",
10
+ "work_description": "Install Premium Fiber 100Mbps for Elizabeth Muthoni",
11
+ "status": "completed",
12
+ "priority": "normal",
13
+ "scheduled_date": "2025-12-11",
14
+ "scheduled_time_slot": "Anytime",
15
+ "due_date": "2025-11-29T09:33:10.216625Z",
16
+ "sla_target_date": "2025-11-29T09:33:10.216625Z",
17
+ "sla_violated": true,
18
+ "started_at": "2025-12-03T11:26:46.746725Z",
19
+ "completed_at": "2025-12-10T12:36:25.444896Z",
20
+ "is_invoiced": true,
21
+ "invoiced_at": "2025-12-10T20:08:01.097828Z",
22
+ "project_region_id": "4cd27765-5720-4cc0-872e-bf0da3cd1898",
23
+ "work_location_latitude": "-1.2198880",
24
+ "work_location_longitude": "36.8770130",
25
+ "work_location_verified": true,
26
+ "notes": "[COMPLETION] done",
27
+ "version": 1,
28
+ "created_at": "2025-11-26T09:33:10.216625Z",
29
+ "updated_at": "2025-12-10T20:08:01.113908Z",
30
+ "project_title": null,
31
+ "region_name": null,
32
+ "customer_name": null,
33
+ "is_open": false,
34
+ "is_assigned": false,
35
+ "is_in_progress": false,
36
+ "is_completed": true,
37
+ "is_cancelled": false,
38
+ "is_active": false,
39
+ "is_overdue": false,
40
+ "has_region": true,
41
+ "has_schedule": true,
42
+ "can_be_assigned": false,
43
+ "can_be_started": false,
44
+ "can_be_completed": false,
45
+ "can_be_cancelled": false
46
+ },
47
+ "available_actions": [],
48
+ "current_assignment": null,
49
+ "team_info": {
50
+ "required_size": 1,
51
+ "assigned_size": 0,
52
+ "is_full": false,
53
+ "assigned_agents": []
54
+ },
55
+ "message": "Ticket TicketStatus.COMPLETED",
56
+ "source_data": {
57
+ "type": "sales_order",
58
+ "id": "a1d04741-b1b5-4a9e-baf6-d1e186886122",
59
+ "order_number": "ORD-2025-015",
60
+ "customer_preferred_package": "Premium Fiber 100Mbps",
61
+ "package_price": 8000.0,
62
+ "installation_address": "1313 Ridgeways Close, Gate 5",
63
+ "installation_latitude": -1.215,
64
+ "installation_longitude": 36.815,
65
+ "preferred_visit_date": "2025-12-11",
66
+ "status": "processed"
67
+ },
68
+ "customer": {
69
+ "id": "a9bccac9-1513-412c-be40-71ea7be24e9a",
70
+ "name": "Elizabeth Muthoni",
71
+ "phone": "+254756789013",
72
+ "email": "elizabeth.muthoni@email.com",
73
+ "address": null,
74
+ "location_latitude": null,
75
+ "location_longitude": null
76
+ },
77
+ "expenses": [
78
+ {
79
+ "id": "35db9201-3c05-4853-be91-5eb6f30782d1",
80
+ "ticket_assignment_id": "34c2a077-5630-4af8-843d-e125c2497267",
81
+ "incurred_by_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
82
+ "incurred_by_user_name": "Viyisa Sasa",
83
+ "category": "transport",
84
+ "description": "nganya",
85
+ "expense_date": "2025-12-10",
86
+ "quantity": 1.0,
87
+ "unit": "unit",
88
+ "unit_cost": 60.0,
89
+ "total_cost": 60.0,
90
+ "receipt_document_id": null,
91
+ "location_verified": false,
92
+ "verification_notes": "Not verified: No GPS location found for 2025-12-10. Manual review required.",
93
+ "is_approved": true,
94
+ "approved_by_user_id": "c5cf92be-4172-4fe2-af5c-f05d83b3a938",
95
+ "approved_by_user_name": "Project Manager",
96
+ "approved_at": "2025-12-10T12:49:31.240803+00:00",
97
+ "rejection_reason": null,
98
+ "is_paid": true,
99
+ "paid_to_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
100
+ "paid_to_user_name": "Viyisa Sasa",
101
+ "paid_at": "2025-12-10T13:23:41.579606+00:00",
102
+ "payment_reference": "CSV_EXPORT_20251210_132341_c5cf92be-4172-4fe2-af5c-f05d83b3a938",
103
+ "payment_recipient_type": "agent",
104
+ "payment_method": "send_money",
105
+ "payment_details": {
106
+ "phone_number": "+254799459782",
107
+ "recipient_name": "Viyisa"
108
+ },
109
+ "notes": "",
110
+ "created_at": "2025-12-10T12:48:01.978430+00:00",
111
+ "updated_at": "2025-12-10T13:23:41.581979+00:00"
112
+ },
113
+ {
114
+ "id": "d73cb843-e4fb-4200-aa3e-243887714422",
115
+ "ticket_assignment_id": "34c2a077-5630-4af8-843d-e125c2497267",
116
+ "incurred_by_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
117
+ "incurred_by_user_name": "Viyisa Sasa",
118
+ "category": "transport",
119
+ "description": "matatu",
120
+ "expense_date": "2025-12-10",
121
+ "quantity": 1.0,
122
+ "unit": "unit",
123
+ "unit_cost": 30.0,
124
+ "total_cost": 30.0,
125
+ "receipt_document_id": null,
126
+ "location_verified": false,
127
+ "verification_notes": "Not verified: No GPS location found for 2025-12-10. Manual review required.",
128
+ "is_approved": true,
129
+ "approved_by_user_id": "c5cf92be-4172-4fe2-af5c-f05d83b3a938",
130
+ "approved_by_user_name": "Project Manager",
131
+ "approved_at": "2025-12-10T12:49:31.240794+00:00",
132
+ "rejection_reason": null,
133
+ "is_paid": true,
134
+ "paid_to_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
135
+ "paid_to_user_name": "Viyisa Sasa",
136
+ "paid_at": "2025-12-10T13:23:41.579593+00:00",
137
+ "payment_reference": "CSV_EXPORT_20251210_132341_c5cf92be-4172-4fe2-af5c-f05d83b3a938",
138
+ "payment_recipient_type": "agent",
139
+ "payment_method": "send_money",
140
+ "payment_details": {
141
+ "phone_number": "+254799459782",
142
+ "recipient_name": "Viyisa"
143
+ },
144
+ "notes": "",
145
+ "created_at": "2025-12-10T12:47:37.968268+00:00",
146
+ "updated_at": "2025-12-10T13:23:41.581981+00:00"
147
+ },
148
+ {
149
+ "id": "b8a0bac2-69c0-4218-a565-e1e2b6ce0d4d",
150
+ "ticket_assignment_id": "34c2a077-5630-4af8-843d-e125c2497267",
151
+ "incurred_by_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
152
+ "incurred_by_user_name": "Viyisa Sasa",
153
+ "category": "transport",
154
+ "description": "boda boda",
155
+ "expense_date": "2025-12-10",
156
+ "quantity": 1.0,
157
+ "unit": "unit",
158
+ "unit_cost": 100.0,
159
+ "total_cost": 100.0,
160
+ "receipt_document_id": null,
161
+ "location_verified": false,
162
+ "verification_notes": "Not verified: No GPS location found for 2025-12-10. Manual review required.",
163
+ "is_approved": true,
164
+ "approved_by_user_id": "c5cf92be-4172-4fe2-af5c-f05d83b3a938",
165
+ "approved_by_user_name": "Project Manager",
166
+ "approved_at": "2025-12-10T12:49:31.240785+00:00",
167
+ "rejection_reason": null,
168
+ "is_paid": true,
169
+ "paid_to_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
170
+ "paid_to_user_name": "Viyisa Sasa",
171
+ "paid_at": "2025-12-10T13:48:43.261303+00:00",
172
+ "payment_reference": "CSV_EXPORT_20251210_134843_c5cf92be-4172-4fe2-af5c-f05d83b3a938",
173
+ "payment_recipient_type": "agent",
174
+ "payment_method": "send_money",
175
+ "payment_details": {
176
+ "phone_number": "+254799459782",
177
+ "recipient_name": "Viyisa"
178
+ },
179
+ "notes": "",
180
+ "created_at": "2025-12-10T12:32:23.362852+00:00",
181
+ "updated_at": "2025-12-10T13:48:43.265156+00:00"
182
+ }
183
+ ],
184
+ "images": [
185
+ {
186
+ "id": "e37b665d-fd6d-4c77-b39e-a6064cb49d64",
187
+ "image_url": "https://res.cloudinary.com/dnhajmziu/image/upload/v1765370174/ticket_2de41ce7_ticket_photo_jcc_jcc_20251210_123614_screenshot_2025-09-04_093459.webp",
188
+ "image_type": "completion",
189
+ "description": "[JCC] Completion photo for ticket",
190
+ "captured_at": "2025-12-10T12:36:14.781724+00:00",
191
+ "uploaded_by_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
192
+ "created_at": "2025-12-10T12:36:14.782564+00:00"
193
+ },
194
+ {
195
+ "id": "ecfc24fc-6be0-4888-a65e-7acf83088c2e",
196
+ "image_url": "https://res.cloudinary.com/dnhajmziu/image/upload/v1765370173/ticket_2de41ce7_ticket_photo_odu_outdoor_image_odu_outdoor_image_20251210_123613_screenshot_2025-09-01_163321.webp",
197
+ "image_type": "completion",
198
+ "description": "[ODU outdoor image] Completion photo for ticket",
199
+ "captured_at": "2025-12-10T12:36:14.128316+00:00",
200
+ "uploaded_by_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
201
+ "created_at": "2025-12-10T12:36:14.129146+00:00"
202
+ },
203
+ {
204
+ "id": "cbbec871-af75-4364-ab34-55272764a415",
205
+ "image_url": "https://res.cloudinary.com/dnhajmziu/image/upload/v1765370172/ticket_2de41ce7_ticket_photo_speedtest_speedtest_20251210_123611_screenshot_2025-08-19_155834.webp",
206
+ "image_type": "completion",
207
+ "description": "[Speedtest] Completion photo for ticket",
208
+ "captured_at": "2025-12-10T12:36:13.395865+00:00",
209
+ "uploaded_by_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
210
+ "created_at": "2025-12-10T12:36:13.396676+00:00"
211
+ },
212
+ {
213
+ "id": "07674999-1fcd-46e9-86ad-8dae1846a218",
214
+ "image_url": "https://res.cloudinary.com/dnhajmziu/image/upload/v1765370171/ticket_2de41ce7_ticket_photo_airtel_network_airtel_network_20251210_123610_screenshot_2025-08-25_090418.webp",
215
+ "image_type": "completion",
216
+ "description": "[Airtel network] Completion photo for ticket",
217
+ "captured_at": "2025-12-10T12:36:11.763055+00:00",
218
+ "uploaded_by_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
219
+ "created_at": "2025-12-10T12:36:11.814756+00:00"
220
+ }
221
+ ],
222
+ "comments": [],
223
+ "assignments": [
224
+ {
225
+ "id": "34c2a077-5630-4af8-843d-e125c2497267",
226
+ "user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
227
+ "user_name": "Viyisa Sasa",
228
+ "action": "completed",
229
+ "status": "CLOSED",
230
+ "assigned_at": "2025-12-03T11:26:09.556998+00:00",
231
+ "responded_at": "2025-12-03T11:26:09.557001+00:00",
232
+ "journey_started_at": "2025-12-03T11:26:46.746692+00:00",
233
+ "arrived_at": "2025-12-03T12:18:09.241003+00:00",
234
+ "ended_at": "2025-12-10T12:36:25.458584+00:00"
235
  }
236
  ],
237
+ "status_history": [
238
+ {
239
+ "id": "faf96f42-b676-4c03-bf71-895aaace1ca4",
240
+ "old_status": "in_progress",
241
+ "new_status": "completed",
242
+ "changed_at": "2025-12-10T12:36:25.466040+00:00",
243
+ "changed_by_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
244
+ "changed_by_user_name": "viya",
245
+ "assignment_id": "34c2a077-5630-4af8-843d-e125c2497267",
246
+ "change_reason": "Ticket completed with all requirements satisfied",
247
+ "notes": "done",
248
+ "location_latitude": null,
249
+ "location_longitude": null,
250
+ "location_accuracy": null,
251
+ "location_verified": false,
252
+ "communication_method": "app",
253
+ "additional_metadata": {}
254
+ },
255
+ {
256
+ "id": "df7dc5a2-273a-4256-8203-5b42ef347da3",
257
+ "old_status": "assigned",
258
+ "new_status": "in_progress",
259
+ "changed_at": "2025-12-03T11:26:46.747547+00:00",
260
+ "changed_by_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
261
+ "changed_by_user_name": "viya",
262
+ "assignment_id": "34c2a077-5630-4af8-843d-e125c2497267",
263
+ "change_reason": "Agent started journey to site",
264
+ "notes": null,
265
+ "location_latitude": -1.219959,
266
+ "location_longitude": 36.8769753,
267
+ "location_accuracy": null,
268
+ "location_verified": false,
269
+ "communication_method": "app",
270
+ "additional_metadata": {}
271
+ },
272
+ {
273
+ "id": "2920a339-4a41-4806-bdc4-2a4d846fefb9",
274
+ "old_status": "open",
275
+ "new_status": "assigned",
276
+ "changed_at": "2025-12-03T11:26:09.599984+00:00",
277
+ "changed_by_user_id": "43b778b0-2062-4724-abbb-916a4835a9b0",
278
+ "changed_by_user_name": "viya",
279
+ "assignment_id": "34c2a077-5630-4af8-843d-e125c2497267",
280
+ "change_reason": "Self-assigned by agent",
281
+ "notes": null,
282
+ "location_latitude": null,
283
+ "location_longitude": null,
284
+ "location_accuracy": null,
285
+ "location_verified": false,
286
+ "communication_method": "app",
287
+ "additional_metadata": {}
288
+ }
289
+ ]
290
  }
docs/devlogs/db/logs.sql CHANGED
@@ -1 +1 @@
1
- [{"idx":0,"id":"01d2c337-3104-4723-87cf-7d1de66be823","ticket_assignment_id":"f5b40f0c-bc9c-4904-9ec1-7e570bda34eb","ticket_id":"169eec08-654d-4ffe-bdb3-45fad1101637","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"meals","description":"kwa mathe ","quantity":"1.00","unit":"unit","unit_cost":"70.00","total_cost":"70.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":false,"approved_by_user_id":null,"approved_at":null,"rejection_reason":null,"is_paid":false,"paid_to_user_id":null,"paid_at":null,"payment_reference":null,"notes":"","additional_metadata":"{}","created_at":"2025-12-10 11:39:05.973838+00","updated_at":"2025-12-10 11:39:05.97384+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":1,"id":"053dbe58-919c-4a11-9ca5-eb2a8384bf66","ticket_assignment_id":"4fe9d28c-b657-4672-9138-78edabb9749b","ticket_id":"1e622599-1909-49b9-9d8b-4c5cb483b29e","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"uber ","quantity":"1.00","unit":"unit","unit_cost":"340.00","total_cost":"340.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":false,"approved_by_user_id":null,"approved_at":null,"rejection_reason":null,"is_paid":false,"paid_to_user_id":null,"paid_at":null,"payment_reference":null,"notes":"","additional_metadata":"{}","created_at":"2025-12-10 12:25:27.373978+00","updated_at":"2025-12-10 12:25:27.373982+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":2,"id":"0bf05fe1-ea66-4391-9d93-0059164b247a","ticket_assignment_id":"20772cb1-ec31-41dc-9cb0-73649dc6ac55","ticket_id":"70090c47-e9c1-4b0a-add4-69bec53d92f9","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"uber boda","quantity":"1.00","unit":"unit","unit_cost":"70.00","total_cost":"70.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-09. Manual review required.","is_approved":true,"approved_by_user_id":"c5cf92be-4172-4fe2-af5c-f05d83b3a938","approved_at":"2025-12-09 08:36:43.568628+00","rejection_reason":null,"is_paid":true,"paid_to_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","paid_at":"2025-12-09 10:17:50.227495+00","payment_reference":"CSV_EXPORT_20251209_101750_c5cf92be-4172-4fe2-af5c-f05d83b3a938","notes":"long jorney","additional_metadata":"{}","created_at":"2025-12-09 07:36:51.915415+00","updated_at":"2025-12-09 10:17:50.232336+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-09"},{"idx":3,"id":"2e21e94f-400e-4ab3-8a0a-b26724227e60","ticket_assignment_id":"4fe9d28c-b657-4672-9138-78edabb9749b","ticket_id":"1e622599-1909-49b9-9d8b-4c5cb483b29e","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"other","description":"Toa chai","quantity":"1.00","unit":"unit","unit_cost":"50.00","total_cost":"50.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":false,"approved_by_user_id":null,"approved_at":null,"rejection_reason":null,"is_paid":false,"paid_to_user_id":null,"paid_at":null,"payment_reference":null,"notes":"","additional_metadata":"{}","created_at":"2025-12-10 12:22:02.788205+00","updated_at":"2025-12-10 12:22:02.788207+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":4,"id":"35db9201-3c05-4853-be91-5eb6f30782d1","ticket_assignment_id":"34c2a077-5630-4af8-843d-e125c2497267","ticket_id":"2de41ce7-dff1-4151-9710-87958d18b5c4","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"nganya","quantity":"1.00","unit":"unit","unit_cost":"60.00","total_cost":"60.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":true,"approved_by_user_id":"c5cf92be-4172-4fe2-af5c-f05d83b3a938","approved_at":"2025-12-10 12:49:31.240803+00","rejection_reason":null,"is_paid":true,"paid_to_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","paid_at":"2025-12-10 13:23:41.579606+00","payment_reference":"CSV_EXPORT_20251210_132341_c5cf92be-4172-4fe2-af5c-f05d83b3a938","notes":"","additional_metadata":"{}","created_at":"2025-12-10 12:48:01.97843+00","updated_at":"2025-12-10 13:23:41.581979+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":5,"id":"5d0a1d44-0eb4-4b32-90ec-5cbdda883238","ticket_assignment_id":"4fe9d28c-b657-4672-9138-78edabb9749b","ticket_id":"1e622599-1909-49b9-9d8b-4c5cb483b29e","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"boda to road","quantity":"1.00","unit":"unit","unit_cost":"150.00","total_cost":"150.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":false,"approved_by_user_id":null,"approved_at":null,"rejection_reason":null,"is_paid":false,"paid_to_user_id":null,"paid_at":null,"payment_reference":null,"notes":"","additional_metadata":"{}","created_at":"2025-12-10 12:02:36.66789+00","updated_at":"2025-12-10 12:02:36.667892+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":6,"id":"6d64a8fc-219c-465b-b1a1-7e710b391a70","ticket_assignment_id":"4fe9d28c-b657-4672-9138-78edabb9749b","ticket_id":"1e622599-1909-49b9-9d8b-4c5cb483b29e","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"accommodation","description":"Slept","quantity":"1.00","unit":"unit","unit_cost":"2000.00","total_cost":"2000.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":false,"approved_by_user_id":null,"approved_at":null,"rejection_reason":null,"is_paid":false,"paid_to_user_id":null,"paid_at":null,"payment_reference":null,"notes":"","additional_metadata":"{}","created_at":"2025-12-10 11:53:42.062175+00","updated_at":"2025-12-10 11:53:42.062179+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":7,"id":"6ec9e645-e4ff-4408-ac9f-de41b37e64dc","ticket_assignment_id":"f5b40f0c-bc9c-4904-9ec1-7e570bda34eb","ticket_id":"169eec08-654d-4ffe-bdb3-45fad1101637","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"we move","quantity":"1.00","unit":"unit","unit_cost":"50.00","total_cost":"50.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":false,"approved_by_user_id":null,"approved_at":null,"rejection_reason":null,"is_paid":false,"paid_to_user_id":null,"paid_at":null,"payment_reference":null,"notes":"","additional_metadata":"{}","created_at":"2025-12-10 11:30:03.835226+00","updated_at":"2025-12-10 11:30:03.835228+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":8,"id":"754be718-8834-4b99-804b-01a3f1974e07","ticket_assignment_id":"a82a3824-f4f1-4283-a2e3-8c348dbb28ce","ticket_id":"f59b29fc-d0b9-4618-b0d1-889e340da612","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"boda boda","quantity":"1.00","unit":"unit","unit_cost":"5000.00","total_cost":"5000.00","receipt_document_id":null,"location_verified":true,"verification_notes":"Verified: Agent arrived at site on 2025-11-30 with GPS location","is_approved":false,"approved_by_user_id":"c5cf92be-4172-4fe2-af5c-f05d83b3a938","approved_at":"2025-12-09 08:51:10.572232+00","rejection_reason":"this is exergrated for the short distance travelled","is_paid":false,"paid_to_user_id":null,"paid_at":null,"payment_reference":null,"notes":"mpesa message","additional_metadata":"{}","created_at":"2025-11-30 20:52:12.047667+00","updated_at":"2025-12-09 08:51:10.572648+00","deleted_at":null,"payment_recipient_type":null,"payment_method":null,"payment_details":null,"expense_date":"2025-11-30"},{"idx":9,"id":"7b697e88-c4c1-4366-b05e-c0689a90451c","ticket_assignment_id":"4fe9d28c-b657-4672-9138-78edabb9749b","ticket_id":"1e622599-1909-49b9-9d8b-4c5cb483b29e","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"bolt","quantity":"1.00","unit":"unit","unit_cost":"210.00","total_cost":"210.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":true,"approved_by_user_id":"c5cf92be-4172-4fe2-af5c-f05d83b3a938","approved_at":"2025-12-10 12:49:31.240768+00","rejection_reason":null,"is_paid":false,"paid_to_user_id":null,"paid_at":null,"payment_reference":null,"notes":"","additional_metadata":"{}","created_at":"2025-12-10 12:31:04.554338+00","updated_at":"2025-12-10 12:49:31.240777+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":10,"id":"b8a0bac2-69c0-4218-a565-e1e2b6ce0d4d","ticket_assignment_id":"34c2a077-5630-4af8-843d-e125c2497267","ticket_id":"2de41ce7-dff1-4151-9710-87958d18b5c4","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"boda boda","quantity":"1.00","unit":"unit","unit_cost":"100.00","total_cost":"100.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":true,"approved_by_user_id":"c5cf92be-4172-4fe2-af5c-f05d83b3a938","approved_at":"2025-12-10 12:49:31.240785+00","rejection_reason":null,"is_paid":false,"paid_to_user_id":null,"paid_at":null,"payment_reference":null,"notes":"","additional_metadata":"{}","created_at":"2025-12-10 12:32:23.362852+00","updated_at":"2025-12-10 12:49:31.240788+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":11,"id":"c466510a-96d8-48e1-82cf-9c6d4ff51fff","ticket_assignment_id":"d6f25868-5117-4b85-8bb3-44314144ef6e","ticket_id":"0fd3ee15-5e7d-465a-b377-155f9bdb7e70","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"boda","quantity":"1.00","unit":"unit","unit_cost":"9.97","total_cost":"9.97","receipt_document_id":null,"location_verified":true,"verification_notes":"Verified: Agent changed ticket status on 2025-12-01 with GPS location","is_approved":true,"approved_by_user_id":"c5cf92be-4172-4fe2-af5c-f05d83b3a938","approved_at":"2025-12-08 20:37:52.435561+00","rejection_reason":null,"is_paid":true,"paid_to_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","paid_at":"2025-12-09 10:17:50.227511+00","payment_reference":"CSV_EXPORT_20251209_101750_c5cf92be-4172-4fe2-af5c-f05d83b3a938","notes":"aZfghji","additional_metadata":"{}","created_at":"2025-12-01 09:15:39.988606+00","updated_at":"2025-12-09 10:17:50.232338+00","deleted_at":null,"payment_recipient_type":null,"payment_method":null,"payment_details":null,"expense_date":"2025-12-01"},{"idx":12,"id":"d73cb843-e4fb-4200-aa3e-243887714422","ticket_assignment_id":"34c2a077-5630-4af8-843d-e125c2497267","ticket_id":"2de41ce7-dff1-4151-9710-87958d18b5c4","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"matatu","quantity":"1.00","unit":"unit","unit_cost":"30.00","total_cost":"30.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":true,"approved_by_user_id":"c5cf92be-4172-4fe2-af5c-f05d83b3a938","approved_at":"2025-12-10 12:49:31.240794+00","rejection_reason":null,"is_paid":true,"paid_to_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","paid_at":"2025-12-10 13:23:41.579593+00","payment_reference":"CSV_EXPORT_20251210_132341_c5cf92be-4172-4fe2-af5c-f05d83b3a938","notes":"","additional_metadata":"{}","created_at":"2025-12-10 12:47:37.968268+00","updated_at":"2025-12-10 13:23:41.581981+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":13,"id":"db836b45-5d6b-4e67-a12a-4619c0fb3f38","ticket_assignment_id":"4fe9d28c-b657-4672-9138-78edabb9749b","ticket_id":"1e622599-1909-49b9-9d8b-4c5cb483b29e","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"meals","description":"rice beans na chapo","quantity":"1.00","unit":"unit","unit_cost":"80.00","total_cost":"80.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":false,"approved_by_user_id":null,"approved_at":null,"rejection_reason":null,"is_paid":false,"paid_to_user_id":null,"paid_at":null,"payment_reference":null,"notes":"","additional_metadata":"{}","created_at":"2025-12-10 11:54:30.892742+00","updated_at":"2025-12-10 12:02:07.865311+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":14,"id":"e5a609ec-eb74-43f0-a7f4-f031accb08fb","ticket_assignment_id":"69a2a4f6-f72a-425c-9f90-4088e074c13b","ticket_id":"1f807cf8-f139-421b-86e3-38c2f8bc7070","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"Boda to trm","quantity":"1.00","unit":"unit","unit_cost":"100.00","total_cost":"100.00","receipt_document_id":null,"location_verified":true,"verification_notes":"Verified: Agent changed ticket status on 2025-12-02 with GPS location","is_approved":true,"approved_by_user_id":"c5cf92be-4172-4fe2-af5c-f05d83b3a938","approved_at":"2025-12-09 10:33:11.622869+00","rejection_reason":null,"is_paid":true,"paid_to_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","paid_at":"2025-12-09 10:33:18.098152+00","payment_reference":"CSV_EXPORT_20251209_103318_c5cf92be-4172-4fe2-af5c-f05d83b3a938","notes":"","additional_metadata":"{}","created_at":"2025-12-02 14:48:16.142758+00","updated_at":"2025-12-09 10:33:18.099276+00","deleted_at":null,"payment_recipient_type":null,"payment_method":null,"payment_details":null,"expense_date":"2025-12-02"},{"idx":15,"id":"fac7e155-a8a7-48bd-86f0-d74d8bb21b2a","ticket_assignment_id":"f5b40f0c-bc9c-4904-9ec1-7e570bda34eb","ticket_id":"169eec08-654d-4ffe-bdb3-45fad1101637","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"materials","description":"bought nails","quantity":"1.00","unit":"unit","unit_cost":"200.00","total_cost":"200.00","receipt_document_id":null,"location_verified":false,"verification_notes":"Not verified: No GPS location found for 2025-12-10. Manual review required.","is_approved":false,"approved_by_user_id":null,"approved_at":null,"rejection_reason":null,"is_paid":false,"paid_to_user_id":null,"paid_at":null,"payment_reference":null,"notes":"","additional_metadata":"{}","created_at":"2025-12-10 11:48:49.793431+00","updated_at":"2025-12-10 11:48:49.793435+00","deleted_at":null,"payment_recipient_type":"agent","payment_method":"send_money","payment_details":"{\"phone_number\": \"+2547994597823\", \"recipient_name\": \"Viyisa\"}","expense_date":"2025-12-10"},{"idx":16,"id":"fce5d718-86d5-489e-88cd-f3385f487849","ticket_assignment_id":"f5b40f0c-bc9c-4904-9ec1-7e570bda34eb","ticket_id":"169eec08-654d-4ffe-bdb3-45fad1101637","incurred_by_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","category":"transport","description":"Boda to home ","quantity":"1.00","unit":"unit","unit_cost":"100.00","total_cost":"100.00","receipt_document_id":null,"location_verified":true,"verification_notes":"Verified: Agent changed ticket status on 2025-12-03 with GPS location","is_approved":true,"approved_by_user_id":"c5cf92be-4172-4fe2-af5c-f05d83b3a938","approved_at":"2025-12-08 20:36:14.289213+00","rejection_reason":null,"is_paid":true,"paid_to_user_id":"43b778b0-2062-4724-abbb-916a4835a9b0","paid_at":"2025-12-08 20:58:34.466326+00","payment_reference":"CSV_EXPORT_20251208_205834_c5cf92be-4172-4fe2-af5c-f05d83b3a938","notes":"","additional_metadata":"{}","created_at":"2025-12-03 13:33:10.63594+00","updated_at":"2025-12-08 20:58:34.469281+00","deleted_at":null,"payment_recipient_type":null,"payment_method":null,"payment_details":null,"expense_date":"2025-12-03"}]
 
1
+ [{"idx":0,"id":"0fd3ee15-5e7d-465a-b377-155f9bdb7e70","project_id":"0ade6bd1-e492-4e25-b681-59f42058d29a","source":"sales_order","source_id":"f40b7d15-01f3-4dbc-9fd5-3f9114db5439","ticket_name":"John Kamau","ticket_type":"installation","service_type":"ftth","work_description":"Install Premium Fiber 50Mbps for John Kamau","status":"completed","priority":"normal","scheduled_date":"2025-12-01","scheduled_time_slot":"Morning 9AM-12PM","due_date":"2025-12-01 07:52:17.445636+00","sla_target_date":"2025-12-01 07:52:17.445636+00","sla_violated":false,"started_at":"2025-12-01 05:52:03.358706+00","completed_at":"2025-12-01 05:54:37.178415+00","is_invoiced":false,"invoiced_at":null,"contractor_invoice_id":null,"project_region_id":"4cd27765-5720-4cc0-872e-bf0da3cd1898","work_location_latitude":-1.2200285,"work_location_longitude":36.8770248,"work_location_accuracy":null,"work_location_verified":true,"dedup_key":null,"notes":"[COMPLETION] Hhhdg","additional_metadata":"{}","version":1,"created_at":"2025-11-28 07:52:17.445636+00","updated_at":"2025-12-01 05:54:37.233167+00","deleted_at":null,"required_team_size":1,"completion_data":"{\"odu_serial\": \"55673883987998\", \"ont_serial\": \"87655457889987\"}","completion_photos_verified":true,"completion_data_verified":true},{"idx":1,"id":"113e2c5d-80f3-41fc-98c0-6e16b1a1b049","project_id":"0ade6bd1-e492-4e25-b681-59f42058d29a","source":"sales_order","source_id":"dfd0b969-ca77-4433-9791-9339a79a1807","ticket_name":"Anne Njeri","ticket_type":"installation","service_type":"ftth","work_description":"Install Premium Fiber 100Mbps for Anne Njeri","status":"open","priority":"normal","scheduled_date":null,"scheduled_time_slot":null,"due_date":"2025-11-29 08:33:01.362984+00","sla_target_date":"2025-11-29 08:33:01.362984+00","sla_violated":false,"started_at":null,"completed_at":null,"is_invoiced":false,"invoiced_at":null,"contractor_invoice_id":null,"project_region_id":"4cd27765-5720-4cc0-872e-bf0da3cd1898","work_location_latitude":null,"work_location_longitude":null,"work_location_accuracy":null,"work_location_verified":false,"dedup_key":"548cc2a6d10f83467be48711c77e0c19","notes":null,"additional_metadata":"{}","version":1,"created_at":"2025-11-26 08:33:01.362984+00","updated_at":"2025-11-26 08:33:01.362986+00","deleted_at":null,"required_team_size":1,"completion_data":"{}","completion_photos_verified":false,"completion_data_verified":false},{"idx":2,"id":"169eec08-654d-4ffe-bdb3-45fad1101637","project_id":"0ade6bd1-e492-4e25-b681-59f42058d29a","source":"sales_order","source_id":"16155120-da0c-42c8-99b2-fc2362d7969f","ticket_name":"James Kipchoge","ticket_type":"installation","service_type":"ftth","work_description":"Install Premium Fiber 50Mbps for James Kipchoge","status":"completed","priority":"normal","scheduled_date":"2025-12-12","scheduled_time_slot":"Morning","due_date":"2025-12-06 13:18:49.776345+00","sla_target_date":"2025-12-06 13:18:49.776345+00","sla_violated":true,"started_at":"2025-12-03 13:21:46.868347+00","completed_at":"2025-12-10 11:25:21.683931+00","is_invoiced":false,"invoiced_at":null,"contractor_invoice_id":null,"project_region_id":"4cd27765-5720-4cc0-872e-bf0da3cd1898","work_location_latitude":-1.2200712,"work_location_longitude":36.8770138,"work_location_accuracy":null,"work_location_verified":true,"dedup_key":null,"notes":"[COMPLETION] work was done","additional_metadata":"{}","version":1,"created_at":"2025-12-03 13:18:49.776345+00","updated_at":"2025-12-10 11:25:21.725296+00","deleted_at":null,"required_team_size":1,"completion_data":"{\"odu_serial\": \"etewqyethfds\", \"ont_serial\": \"eter\", \"odu_imei_number\": \"ateywejhthbvrqtewgw\", \"activated_number\": \"999999999\"}","completion_photos_verified":true,"completion_data_verified":true},{"idx":3,"id":"1e622599-1909-49b9-9d8b-4c5cb483b29e","project_id":"0ade6bd1-e492-4e25-b681-59f42058d29a","source":"sales_order","source_id":"b2a47ac2-e779-4479-846b-f350f041dd43","ticket_name":"Nnacy Wanjiru","ticket_type":"installation","service_type":"ftth","work_description":"Install 100 for Nnacy Wanjiru","status":"assigned","priority":"normal","scheduled_date":"2026-01-01","scheduled_time_slot":null,"due_date":"2025-11-28 13:03:13.104571+00","sla_target_date":"2025-11-28 13:03:13.104571+00","sla_violated":true,"started_at":null,"completed_at":null,"is_invoiced":false,"invoiced_at":null,"contractor_invoice_id":null,"project_region_id":"24510a5a-13a6-4334-9055-b4d476aa9e0a","work_location_latitude":null,"work_location_longitude":null,"work_location_accuracy":null,"work_location_verified":false,"dedup_key":"1599426e83e347f0b0a00a1ddef5bcdb","notes":null,"additional_metadata":"{}","version":1,"created_at":"2025-11-25 13:03:13.104571+00","updated_at":"2025-12-10 11:05:29.251274+00","deleted_at":null,"required_team_size":1,"completion_data":"{}","completion_photos_verified":false,"completion_data_verified":false},{"idx":4,"id":"1f807cf8-f139-421b-86e3-38c2f8bc7070","project_id":"0ade6bd1-e492-4e25-b681-59f42058d29a","source":"sales_order","source_id":"7ad1e823-9c68-448c-8d7c-7fdefbf640cb","ticket_name":"Peter Otieno","ticket_type":"installation","service_type":"ftth","work_description":"Install Standard 20Mbps for Peter Otieno","status":"pending_review","priority":"normal","scheduled_date":"2025-12-10","scheduled_time_slot":"10:00-14:00","due_date":"2025-11-30 11:41:47.990551+00","sla_target_date":"2025-11-30 11:41:47.990551+00","sla_violated":true,"started_at":"2025-12-02 14:12:27.929751+00","completed_at":null,"is_invoiced":false,"invoiced_at":null,"contractor_invoice_id":null,"project_region_id":"4cd27765-5720-4cc0-872e-bf0da3cd1898","work_location_latitude":null,"work_location_longitude":null,"work_location_accuracy":null,"work_location_verified":false,"dedup_key":"a5f81226688e1cc667e106d4a52b4838","notes":"Needs router configuration assistance","additional_metadata":"{}","version":1,"created_at":"2025-11-27 11:41:47.990551+00","updated_at":"2025-12-03 11:59:40.306579+00","deleted_at":null,"required_team_size":1,"completion_data":"{}","completion_photos_verified":false,"completion_data_verified":false}]
src/app/api/v1/contractor_invoices.py CHANGED
@@ -183,7 +183,11 @@ def get_invoice(
183
  ):
184
  """
185
  Get invoice by ID.
186
- Returns latest version by default with enriched data (names, viewing link).
 
 
 
 
187
  """
188
  import os
189
  from app.models.contractor import Contractor
 
183
  ):
184
  """
185
  Get invoice by ID.
186
+ Returns latest version with enriched data (names, viewing link).
187
+
188
+ For ticket details with completion data, use:
189
+ - Public viewing: GET /api/v1/invoices/view?token={token}
190
+ - Individual tickets: GET /api/v1/tickets/{id}/detail
191
  """
192
  import os
193
  from app.models.contractor import Contractor
src/app/schemas/ticket.py CHANGED
@@ -8,7 +8,7 @@ Request/response schemas for ticket management including:
8
  - Ticket list/filter/analytics
9
  """
10
  from pydantic import BaseModel, Field, field_validator, ConfigDict
11
- from typing import Optional, List
12
  from datetime import datetime, date
13
  from uuid import UUID
14
  from decimal import Decimal
@@ -150,6 +150,11 @@ class TicketResponse(BaseModel):
150
  work_location_longitude: Optional[Decimal]
151
  work_location_verified: bool
152
 
 
 
 
 
 
153
  # Metadata
154
  notes: Optional[str]
155
  version: int
 
8
  - Ticket list/filter/analytics
9
  """
10
  from pydantic import BaseModel, Field, field_validator, ConfigDict
11
+ from typing import Optional, List, Dict, Any
12
  from datetime import datetime, date
13
  from uuid import UUID
14
  from decimal import Decimal
 
150
  work_location_longitude: Optional[Decimal]
151
  work_location_verified: bool
152
 
153
+ # Completion data
154
+ completion_data: Optional[Dict[str, Any]] = Field(default_factory=dict, description="Completion data (ONT serial, ODU serial, etc.)")
155
+ completion_photos_verified: bool = False
156
+ completion_data_verified: bool = False
157
+
158
  # Metadata
159
  notes: Optional[str]
160
  version: int