File size: 46,171 Bytes
32cddc6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
/* Spotlight PQGC inventory data.
   Table names: SAP foundation views as "fdn_<area>_view.<name>" (catalog uc_<env>_snt_fdn_01),
   Databricks tables as "pbus_spotlight.<name>", app database objects as "PQGC_SPOTLIGHT.<name>".
   A trailing "()" marks a stored procedure that the notebook runs. */
window.SPOTLIGHT = {
  stages: [
    {
      id: "check", num: "01", short: "Check freshness", where: "Databricks",
      name: "Check that the SAP data is fresh",
      question: "Is the source data up to date?",
      plain: "Before anything is built, three small notebooks look at about twenty SAP source tables and note when each one last received new data. If a daily source is more than 24 hours old, or a weekly one more than 7 days old, the support contact gets an email.",
      bullets: [
        "Each source has an expected refresh rate, for example orders 144 times a day and planned orders once a week.",
        "Stale data does not stop the run. It only raises an alert.",
        "Stale <b>Customer</b> master data is printed but not emailed."
      ],
      notebooks: ["PQGC_BASE_TABLE_VALIDATION_CEN.py", "PQGC_BASE_TABLE_VALIDATION_DF.py", "PQGC_BASE_TABLE_VALIDATION.py"]
    },
    {
      id: "collect", num: "02", short: "Pull from SAP", where: "SAP β†’ Databricks",
      name: "Pull what changed in SAP",
      question: "What changed since last time?",
      plain: "Seven extract notebooks copy the raw facts out of SAP S/4: customer order lines, deliveries, purchase and transfer orders, truck shipments, planned and actual production, and stock movements. Most of them only take documents that changed since the last successful run. Each run's stopping point is saved as a watermark.",
      bullets: [
        "Quantities are converted to <b>cases</b> and <b>pallets</b> using the material master, so everything downstream uses the same units.",
        "Only the company codes in an approved list, and plants whose code starts with <b>8</b>, are kept for customer orders.",
        "The shipment extract runs last. It merges the change lists into one list of documents to rebuild in the next stage.",
        "Production is a full refresh of the next <b>14 days</b>. Stock on hand is rebuilt from the full movement history."
      ],
      notebooks: [
        "PGT_WHD_ORDR_ITEM_EXTRCT_TBL_SPLTGHT.py", "PGT_WHD_DLVRY_EXTRCT_TBL_SPLTGHT.py", "PGT_WHD_PO_EXTRCT_TBL_SPLTGHT.py",
        "PGT_WHD_SHPMT_EXTRCT_TBL_SPLTGHT.py", "PGT_WHD_PROD_ORDR_EXTRCT_TBL_SPLTGHT.py", "PGT_WHD_PROD_PROCESS_ORDR_EXTRCT_TBL_SPLTGHT.py",
        "MATDOC_INCREMENTAL.py"
      ]
    },
    {
      id: "connect", num: "03", short: "Stitch orders", where: "Databricks",
      name: "Stitch each order to its delivery and truck",
      question: "Where is each order line right now?",
      plain: "The extracts are separate lists. This stage joins them into one row per order line, showing what was ordered, what SAP can promise, the delivery, the truck and carrier, the customer and a simple status. Customer orders and plant-to-plant transfers are handled side by side.",
      bullets: [
        "Status comes from SAP block codes: <b>OPEN</b>, <b>RLSD</b> (released), <b>HOLD</b>, <b>BLKD</b> (blocked), <b>SHPD</b> (shipped) or <b>CNCL</b> (cancelled).",
        "Transfers get a movement stage: <b>SOO</b> on order, <b>SPL</b> truck loading, <b>SIT</b> in transit.",
        "Shortfall is ordered minus promised (ATP), in cases, pallets and dollars.",
        "The new slice is merged into a permanent history table, <code>ord_dely_detl_pgt</code>."
      ],
      notebooks: ["Ord_dely_detl_pgt_cur.py"]
    },
    {
      id: "coverage", num: "04", short: "Score plants", where: "Databricks β†’ app DB",
      name: "Score each plant's coverage for the next 14 days",
      question: "Can each plant cover its demand?",
      plain: "For each plant and product, this stage looks 14 days ahead. It starts with stock on hand, subtracts what must ship out each day, and adds what's due to arrive. Incoming supply is discounted by how reliable that kind of supply usually is. The result is a 0–100% score per day for how much of that day's demand the plant can fill.",
      bullets: [
        "Supply trust weights: in transit <b>80%</b>, truck loading <b>60%</b>, production <b>50%</b>, transfer on order <b>40%</b>.",
        "Stock on quality hold (\"incubation\") counts at <b>75%</b>.",
        "Day 0 also includes anything up to 30 days overdue.",
        "Every run is kept as history. The latest run goes to the app database."
      ],
      notebooks: ["plant_matnr_fcs_dly.py"]
    },
    {
      id: "score", num: "05", short: "Rate orders", where: "Databricks β†’ app DB",
      name: "Rate every order and order line",
      question: "Which orders are at risk?",
      plain: "Order lines are rolled up into one row per order. Each order gets a fill rate, revenue at risk, a confidence score taken from the plant's coverage score on the delivery date, and a traffic light. The changed orders and lines are sent to the app database, where stored procedures merge them in.",
      bullets: [
        "<b>Fill rate</b> = promised Γ· ordered Γ— 100.",
        "<b>Green</b>: fully promised and covered. <b>Yellow</b>: fully promised, coverage under 100%. <b>Orange</b>: short, but within the plant's \"max cut & ship\" tolerance. <b>Red</b>: everything else.",
        "Orders that travel together (same load, <code>GRP_ID</code>) get group totals for pallets short and at risk.",
        "A line's confidence score is frozen once it is released or shipped."
      ],
      notebooks: ["PQGC_FO_CUR.py", "PQGC_FOL_CUR.py"]
    },
    {
      id: "supply", num: "06", short: "Supply & ML", where: "Databricks β†’ app DB",
      name: "List supply and predict transfers",
      question: "What's coming in, and will it arrive?",
      plain: "One notebook builds the supply-and-demand list for each plant and product: transfers, production and customer orders, each with a confidence score and the receiving appointment at the warehouse. Two machine-learning notebooks give every open transfer a probability score.",
      bullets: [
        "Production items get a fixed confidence of 50. Transfer confidence comes from the order lines.",
        "The ML models are pre-trained files (most likely XGBoost). The training code is not in this folder.",
        "Nothing in this folder reads the ML outputs yet. The app's confidence scores still use the fixed weights."
      ],
      notebooks: ["plnt_mtrl_scs_rptng.py", "ML/PQGC_ML_SIT_Predictions.py", "ML/PQGC_ML_SOO_SPL_Predictions.py"]
    },
    {
      id: "publish", num: "07", short: "Publish", where: "App database",
      name: "Publish to the Spotlight app",
      question: "Is the app showing the latest?",
      plain: "The final step runs the app database's own stored procedures and updates the clock the app shows: \"Last Spotlight Refresh\", \"Last SAP Writeback\" and \"SAP Data Pull\". Planners can see how fresh the numbers are.",
      bullets: [
        "The job passes in the list of stored procedures to run.",
        "The SAP data-pull time is the oldest \"last update\" across orders and order lines, so it is a conservative figure."
      ],
      notebooks: ["EXEC_SP_ASQL.py", "writeback/update timer stamp ASQL.py"]
    },
    {
      id: "loop", num: "08", short: "Back to SAP", where: "App β†’ SAP",
      name: "Send planners' changes back to SAP",
      question: "How do decisions reach SAP?",
      plain: "When planners act in Spotlight, their changes wait in a queue table in the app database. The writeback notebook turns the queue into a CSV file in the data-lake folder that feeds SAP S/4, logs the orders it sent, and empties the queue. A separate fast-refresh notebook pushes SAP's updated order status back to the app between full runs.",
      bullets: [
        "Two kinds of writeback: <b>ATP</b> (user changes) and <b>BEAM</b>.",
        "The fields planners can change are defined in the app database's stored procedures, which are not in this folder.",
        "SAP loads the CSV through an integration outside this folder."
      ],
      notebooks: ["writeback/SAPWritebackStatus.py", "writeback/UPDATE_FO.py"]
    },
    {
      id: "kit", num: "Β·Β·", short: "Toolkit", where: "Shared", inTrack: false,
      name: "Shared toolkit",
      question: "What do all the notebooks rely on?",
      plain: "Settings, alerts, merge routines and housekeeping that the other notebooks load with %run.",
      bullets: [],
      notebooks: ["Common/ENV_VARIABLES.py", "Common/Email.py", "Common/Optimize drvd tables.py", "ODD_FO_FOL_MERGE.py", "SP_MERGE.py", "writeback/PBNA_COMMON_PROCESS.py"]
    }
  ],

  notebooks: [
    /* ---------- 01 Check ---------- */
    {
      file: "PQGC_BASE_TABLE_VALIDATION_CEN.py", stage: "check", lines: 136,
      title: "Records when three key SAP sources last changed",
      plain: "Finds the newest update time in three SAP sources (delivery schedule lines, planned orders and stock movements) and saves it next to how often each source is expected to refresh.",
      steps: [
        "For each source, take the latest update time for SAP instance A1P.",
        "Join it to the expected refresh rate (for example \"6/day\" or \"1/week\").",
        "Replace the freshness table with the result."
      ],
      reads: ["fdn_customer_view.XTNSalesOrderDeliveryScheduleLine", "fdn_material_view.XTNPlanOrder", "fdn_material_view.XTNMaterialInventoryDocument", "pbus_spotlight.sptlt_pqgc_base_table_refresh_timings"],
      writes: ["pbus_spotlight.sptlt_pqgc_latest_base_refresh_details"]
    },
    {
      file: "PQGC_BASE_TABLE_VALIDATION_DF.py", stage: "check", lines: 70,
      title: "Records when 17 more SAP sources last changed",
      plain: "Does the same for orders, order lines, deliveries, purchase orders, trucks, customers and materials, and adds the rows to the same freshness table.",
      steps: [
        "Take the latest update time from each of 17 SAP sources.",
        "Join to the expected refresh rates.",
        "Append to the freshness table."
      ],
      reads: [
        "fdn_customer_view.FulfillmentPlan", "fdn_customer_view.XTNFulfillmentPlanLine", "fdn_customer_view.Order", "fdn_customer_view.XTNOrderLine",
        "fdn_customer_view.XTNSalesOrderPartner", "fdn_customer_view.XTNTransportationOrder", "fdn_customer_view.XTNTransportationOrderReference",
        "fdn_customer_view.XTNTransportationOrderEventExecution", "fdn_customer_view.Customer", "fdn_customer_view.XCFCustomerHierarchyGoToMarketUnit",
        "fdn_material_view.XCFMaterialCore", "fdn_material_view.XCFMaterialUnitofMeasure",
        "fdn_supplier_view.PurchaseOrder", "fdn_supplier_view.PurchaseOrderLine", "fdn_supplier_view.XTNPurchaseOrderLineHistory",
        "fdn_supplier_view.XTNPurchaseOrderScheduleLine", "fdn_supplier_view.XTNPurchaseOrderLineStockTransferShipping",
        "pbus_spotlight.sptlt_pqgc_base_table_refresh_timings"
      ],
      writes: ["pbus_spotlight.sptlt_pqgc_latest_base_refresh_details"]
    },
    {
      file: "PQGC_BASE_TABLE_VALIDATION.py", stage: "check", lines: 23,
      title: "Emails an alert when SAP data is stale",
      plain: "Reads the freshness table. If any daily source is more than 24 hours old, or any weekly source more than 7 days old, it emails the list of stale tables to the support contact.",
      steps: [
        "Find sources past their expected refresh window.",
        "If any are found (other than Customer), send the \"SPTLT BASE TABLES VALIDATION\" email."
      ],
      reads: ["pbus_spotlight.sptlt_pqgc_latest_base_refresh_details"],
      writes: []
    },

    /* ---------- 02 Collect ---------- */
    {
      file: "PGT_WHD_ORDR_ITEM_EXTRCT_TBL_SPLTGHT.py", stage: "collect", lines: 834,
      title: "Copies changed customer order lines from SAP",
      plain: "Finds customer orders that changed since the last run and copies each line: product, cases and pallets ordered, how many SAP has confirmed it can ship (ATP), the shortfall and its value. It removes lines that no longer exist in SAP.",
      steps: [
        "Log the run and read the last watermark (default 1 Jan 2025).",
        "List changed orders of type ZOR, ZDOR, ZSOR, ZOSC, ZCM, ZPOC or ZIC in approved company codes.",
        "Keep plants whose code starts with 8.",
        "Convert to cases and pallets; calculate promised quantity (ATP), shortfall, order value and ATP value.",
        "Upsert into the extract table. Remove ZAPA and ZCMS item lines here and in the downstream order tables.",
        "Remove lines that have disappeared from SAP (saved to <code>missing_so</code>), then mark the run complete."
      ],
      reads: [
        "fdn_customer_view.Order", "fdn_customer_view.XTNOrderLine", "fdn_customer_view.XTNSalesOrderDeliveryScheduleLine",
        "fdn_material_view.XCFMaterialCore", "fdn_material_view.XCFMaterialUnitofMeasure",
        "pbus_spotlight.sptlght_pqgc_companycodes_tbl", "pbus_spotlight.pqgc_work_table_run_dtls"
      ],
      writes: [
        "pbus_spotlight.procss_ordrs_tbl_wrk", "pbus_spotlight.pgt_whd_ordr_item_extrct_tbl_temp", "pbus_spotlight.pgt_whd_ordr_item_extrct_tbl",
        "pbus_spotlight.missing_so", "pbus_spotlight.ord_dely_detl_pgt", "pbus_spotlight.fact_order_line_pqgc", "pbus_spotlight.pqgc_work_table_run_dtls"
      ]
    },
    {
      file: "PGT_WHD_DLVRY_EXTRCT_TBL_SPLTGHT.py", stage: "collect", lines: 408,
      title: "Copies changed deliveries from SAP",
      plain: "Copies the delivery documents that changed since the last run. A delivery tells a warehouse what to pick and ship. The copy records delivered quantity, planned and actual ship dates, delivery date, weight and bill of lading.",
      steps: [
        "Log the run and read the watermark.",
        "List changed (order, delivery) pairs with a non-zero delivered quantity.",
        "Keep approved company codes, or deliveries of type ZEL that have no sales org.",
        "Turn placeholder dates (1900-01-01) into blanks and keep one row per delivery item.",
        "Upsert into the delivery extract table and mark the run complete."
      ],
      reads: ["fdn_customer_view.FulfillmentPlan", "fdn_customer_view.XTNFulfillmentPlanLine", "pbus_spotlight.sptlght_pqgc_companycodes_tbl", "pbus_spotlight.pqgc_work_table_run_dtls"],
      writes: ["pbus_spotlight.procss_ordrs_dlvry_tbl_wrk", "pbus_spotlight.pgt_whd_dlvry_extrct_temp", "pbus_spotlight.pgt_whd_dlvry_extrct_tbl", "pbus_spotlight.pqgc_work_table_run_dtls"]
    },
    {
      file: "PGT_WHD_PO_EXTRCT_TBL_SPLTGHT.py", stage: "collect", lines: 392,
      title: "Copies purchase orders and plant-to-plant transfers",
      plain: "Copies purchase orders and stock transport orders, which move product from one plant or warehouse to another. It records quantity ordered against quantity committed, the expected receipt date, quantity received, and whether the last event was a goods issue or a goods receipt.",
      steps: [
        "List changed orders of type ZCC1, ZCC2, ZCC3, ZUB (stock transfer), ZCM or ZNB3.",
        "Find the latest goods movement: 1 = goods receipt, 6 = goods issued for a transfer.",
        "Keep schedule lines with committed quantity above 0.",
        "Mark the line cancelled (CAN) if any SAP deletion flag is set.",
        "Upsert into the PO extract table."
      ],
      reads: [
        "fdn_supplier_view.PurchaseOrder", "fdn_supplier_view.PurchaseOrderLine", "fdn_supplier_view.XTNPurchaseOrderScheduleLine",
        "fdn_supplier_view.XTNPurchaseOrderLineHistory", "fdn_supplier_view.XTNPurchaseOrderLineStockTransferShipping",
        "fdn_material_view.XCFMaterialCore", "fdn_material_view.XCFMaterialUnitofMeasure",
        "pbus_spotlight.sptlght_pqgc_companycodes_tbl", "pbus_spotlight.pqgc_work_table_run_dtls"
      ],
      writes: ["pbus_spotlight.procss_sto_tbl_wrk", "pbus_spotlight.pgt_whd_po_extrct_tbl_spltght", "pbus_spotlight.pqgc_work_table_run_dtls"]
    },
    {
      file: "PGT_WHD_SHPMT_EXTRCT_TBL_SPLTGHT.py", stage: "collect", lines: 496,
      title: "Copies truck shipments and builds the rebuild list",
      plain: "Copies truck shipments from SAP's transport module: carrier, status, trailer numbers and load ID. It links each truck to the deliveries, customer orders and transfers on board. It then combines the change lists from the other extracts into one list of documents to rebuild.",
      steps: [
        "Copy recently changed trailer references (ZTRL1–3 become trailer 1–3).",
        "Reload the shipment-to-document links: type 73 = delivery, 114 = sales order, STO = transfer.",
        "Build the shipment table with each truck's latest event status.",
        "Combine the order, delivery and transfer change lists into <code>procss_ord_dely_dtl_pgt_wrk_tbl</code>."
      ],
      reads: [
        "fdn_customer_view.XTNTransportationOrderReference", "fdn_customer_view.XTNTransportationOrder", "fdn_customer_view.XTNTransportationOrderEventExecution",
        "pbus_spotlight.procss_ordrs_tbl_wrk", "pbus_spotlight.procss_ordrs_dlvry_tbl_wrk", "pbus_spotlight.procss_sto_tbl_wrk", "pbus_spotlight.pqgc_work_table_run_dtls"
      ],
      writes: [
        "pbus_spotlight.pgt_whd_shpmt_ord_ref_trlr_tbl", "pbus_spotlight.pgt_whd_shpmt_ord_reference", "pbus_spotlight.pgt_whd_shpmt_ord_reference_tbl",
        "pbus_spotlight.pgt_whd_shpmt_extrct_temp", "pbus_spotlight.pgt_whd_shpmt_extrct_tbl", "pbus_spotlight.procss_ord_dely_dtl_pgt_wrk_tbl",
        "pbus_spotlight.pqgc_work_table_run_dtls"
      ]
    },
    {
      file: "PGT_WHD_PROD_ORDR_EXTRCT_TBL_SPLTGHT.py", stage: "collect", lines: 272,
      title: "Planned production for the next 14 days",
      plain: "Takes SAP's planned production orders that finish within the next two weeks and spreads each order's quantity evenly across the days it runs, in cases. This is one of the \"supply coming in\" sources.",
      steps: [
        "Keep live planning orders only (not deleted, planning scenario 0).",
        "Keep orders ending between today and 14 days out.",
        "Daily quantity = total Γ· number of days the order runs; convert to cases.",
        "Replace the whole table."
      ],
      reads: ["fdn_material_view.XTNPlanOrder", "fdn_material_view.XCFMaterialCore", "fdn_material_view.XCFMaterialUnitofMeasure", "pbus_spotlight.pqgc_work_table_run_dtls"],
      writes: ["pbus_spotlight.pgt_whd_prod_ordr_extrct_tbl_spltght", "pbus_spotlight.pqgc_work_table_run_dtls"]
    },
    {
      file: "PGT_WHD_PROD_PROCESS_ORDR_EXTRCT_TBL_SPLTGHT.py", stage: "collect", lines: 267,
      title: "Production orders starting in the next 14 days",
      plain: "Lists finished-goods production orders scheduled to start in the next two weeks, with the quantity in cases. It shows what each plant will actually make, and when.",
      steps: [
        "Wait 5 minutes for upstream work to finish.",
        "Keep finished goods (ZFIN) with a start date in the next 14 days.",
        "Convert to cases and replace the whole table."
      ],
      reads: ["fdn_material_view.XTNProductionOrderHeader", "fdn_material_view.XTNProductionOrderItem", "fdn_material_view.XCFMaterialCore", "fdn_material_view.XCFMaterialUnitofMeasure", "pbus_spotlight.pqgc_work_table_run_dtls"],
      writes: ["pbus_spotlight.pgt_whd_prod_process_ordr_extrct_tbl_spltght", "pbus_spotlight.pqgc_work_table_run_dtls"]
    },
    {
      file: "MATDOC_INCREMENTAL.py", stage: "collect", lines: 285,
      title: "Stock on hand per plant and product",
      plain: "Adds up every SAP stock movement to work out how many cases of each product are in each plant's warehouse right now. It keeps two figures: stock that is free to ship, and stock on hold (\"incubation inventory\").",
      steps: [
        "Take stock movements for stock type 01 (free) and 08 (on hold), storage location 3000, approved company codes.",
        "Reload the full movement history. The incremental logic exists but is commented out.",
        "Sum the movements per plant and product and convert to cases."
      ],
      reads: ["fdn_material_view.XTNMaterialInventoryDocument", "fdn_material_view.XCFMaterialUnitofMeasure", "pbus_spotlight.sptlght_pqgc_companycodes_tbl"],
      writes: ["pbus_spotlight.raw_matdoc_hist", "pbus_spotlight.sptlt_plant_mtrl_invntry_pqgc"]
    },

    /* ---------- 03 Connect ---------- */
    {
      file: "Ord_dely_detl_pgt_cur.py", stage: "connect", lines: 1194,
      title: "Stitches each order line to its delivery and truck",
      plain: "Builds one row per order line with the full picture: what was ordered, how much SAP can promise, the delivery, the truck and carrier, where the customer sits in the sales hierarchy, and a simple status. It covers customer orders and plant-to-plant transfers, and labels each transfer as on order, loading or in transit.",
      steps: [
        "Take documents changed in the last 7 days from the rebuild list.",
        "Process customer orders and transfers in two parallel threads.",
        "Ship date = actual, else planned, else requested.",
        "Risk = ordered βˆ’ promised (ATP), in cases, pallets and dollars. Zero if cancelled.",
        "Status from SAP blocks: ZL β†’ OPEN; delivery or ZP β†’ RLSD; Z2 β†’ HOLD; 01–09, Z1, ZA and others β†’ BLKD; shipped β†’ SHPD; cancelled β†’ CNCL.",
        "Transfers: goods issued or truck departed β†’ SIT; checking in or loading β†’ SPL; otherwise SOO.",
        "Save the fresh slice and merge it into the permanent history."
      ],
      params: "none. Passes <code>odd_last_processed_time_stamp</code> to later tasks.",
      reads: [
        "pbus_spotlight.procss_ord_dely_dtl_pgt_wrk_tbl", "pbus_spotlight.pgt_whd_ordr_item_extrct_tbl", "pbus_spotlight.pgt_whd_dlvry_extrct_tbl",
        "pbus_spotlight.pgt_whd_po_extrct_tbl_spltght", "pbus_spotlight.pgt_whd_shpmt_ord_reference_tbl", "pbus_spotlight.pgt_whd_shpmt_extrct_tbl",
        "pbus_spotlight.sptlght_pqgc_companycodes_tbl", "pbus_spotlight.pqgc_work_table_run_odd_dtls",
        "fdn_customer_view.Customer", "fdn_customer_view.XCFCustomerHierarchyGoToMarketUnit", "fdn_customer_view.XCFCustomerHierarchyGoToMarketUnitFlattened"
      ],
      writes: ["pbus_spotlight.ord_dely_detl_pgt_cur_so", "pbus_spotlight.ord_dely_detl_pgt_cur_sto", "pbus_spotlight.ord_dely_detl_pgt_cur", "pbus_spotlight.ord_dely_detl_pgt", "pbus_spotlight.pqgc_work_table_run_odd_dtls"]
    },

    /* ---------- 04 Coverage ---------- */
    {
      file: "plant_matnr_fcs_dly.py", stage: "coverage", lines: 2478,
      title: "Daily coverage score per plant and product, 14 days ahead",
      plain: "For every plant and product, it looks 14 days ahead. It starts with stock on hand, subtracts what must ship out each day (customer orders and transfers to other plants), and adds what is due to arrive (transfers in and production). Incoming supply is discounted by how reliable it usually is. The result is a 0–100% score per day for how much of that day's demand the plant can fill.",
      steps: [
        "Set supply trust weights: in transit 80%, loading 60%, production 50%, on order 40%.",
        "Put incoming supply into daily buckets, Day 0 to Day 13. Day 0 also takes anything up to 30 days overdue.",
        "Stock = free stock + 75% of stock on hold.",
        "Demand per day = customer orders + transfers out, ignoring shipped and cancelled lines.",
        "Track remaining stock day by day and the day it would run out with no new supply.",
        "Fillable quantity = stock + trust-weighted supply that arrives in time.",
        "Score = fillable Γ· demand Γ— 100, capped at 100.",
        "Add the run to history and send the latest scores to the app database."
      ],
      reads: [
        "pbus_spotlight.ord_dely_detl_pgt", "pbus_spotlight.pgt_whd_prod_ordr_extrct_tbl_spltght", "pbus_spotlight.pgt_whd_prod_process_ordr_extrct_tbl_spltght",
        "pbus_spotlight.sptlt_plant_mtrl_invntry_pqgc", "pbus_spotlight.plnt_mtrl_sply_typ_scs_cc",
        "fdn_material_view.XCFMaterialCore", "fdn_material_view.XTNObjectCharacteristicValueData"
      ],
      writes: [
        "pbus_spotlight.plnt_mtrl_sply_typ_scs", "pbus_spotlight.plant_mtrl_spply_wrk", "pbus_spotlight.plant_matnr_dly_demand_wrk",
        "pbus_spotlight.plant_matnr_dly_demand_sply_fcs", "pbus_spotlight.plant_matnr_fcs_dly", "pbus_spotlight.plant_matnr_fcs_dly_vw",
        "PQGC_SPOTLIGHT.plant_matnr_fcs_dly_hist", "PQGC_SPOTLIGHT.plant_matnr_fcs_dly"
      ]
    },

    /* ---------- 05 Score ---------- */
    {
      file: "PQGC_FO_CUR.py", stage: "score", lines: 1158,
      title: "One row per order with fill rate, risk and a traffic light",
      plain: "Rolls order lines up to one row per order. Each order gets ordered and promised quantity, fill rate, revenue at risk, a confidence score from the plant's coverage on the delivery date, and a green, yellow, orange or red light. The changed orders are then sent to the app database.",
      steps: [
        "Take the orders that changed in this run.",
        "Fill rate = promised Γ· ordered Γ— 100.",
        "Confidence = case-weighted average of the plant's coverage score on the requested delivery date.",
        "Transfers also get a fixed score by stage: in transit 80, loading 60, on order 40.",
        "Total pallets short and at risk for orders that ship on the same load (GRP_ID).",
        "Set the light from fill rate, coverage and the plant's \"max cut & ship\" setting.",
        "Label orders Foods, Beverages or Bag-in-box and add the order-processor contacts.",
        "Write changed orders to the app database and run <code>FO_DLT_MRGE</code> to merge them."
      ],
      reads: [
        "pbus_spotlight.ord_dely_detl_pgt_cur", "pbus_spotlight.ord_dely_detl_pgt", "pbus_spotlight.plant_matnr_fcs_dly_vw",
        "pbus_spotlight.config_inter_pgt", "pbus_spotlight.config_feat_pgt", "pbus_spotlight.config_location_pgt", "pbus_spotlight.plants_pgt",
        "pbus_spotlight.fact_order_pqgc_dlt_wrk", "fdn_customer_view.XTNSalesOrderPartner", "fdn_material_view.XCFMaterialCore"
      ],
      writes: ["pbus_spotlight.shp_cond_mapping", "pbus_spotlight.fact_order_pqgc_dlt_wrk", "pbus_spotlight.fact_order_pqgc", "PQGC_SPOTLIGHT.FACT_ORDER_PQGC_DLT", "PQGC_SPOTLIGHT.FO_DLT_MRGE()"]
    },
    {
      file: "PQGC_FOL_CUR.py", stage: "score", lines: 702,
      title: "The line-by-line detail behind each order",
      plain: "Builds the product lines behind each order: ordered and promised quantity, pallets and cases short, value, revenue at risk and line confidence. Once a line is released or shipped, its confidence score is frozen. It also removes cancelled lines and excluded item types from the app.",
      steps: [
        "Line value = quantity Γ— price. Revenue at risk = (ordered βˆ’ promised) Γ— price.",
        "Line confidence = the plant's coverage score on the requested delivery date.",
        "For lines now released or shipped, keep the confidence score saved in the previous run.",
        "Send changed lines to the app database and run <code>FOL_DLT_MRGE</code>.",
        "Send cancelled line keys and run <code>FOL_CNCL_DELT</code>.",
        "Find ZAPA/ZCMS lines in the app and run <code>FOL_ZAPA_ZCMS_DELT</code> to remove them."
      ],
      params: "<code>odd_last_processed_time_stamp</code> (used only when the run fails).",
      reads: [
        "pbus_spotlight.ord_dely_detl_pgt_cur", "pbus_spotlight.ord_dely_detl_pgt", "pbus_spotlight.plant_matnr_fcs_dly_vw", "pbus_spotlight.shp_cond_mapping",
        "pbus_spotlight.config_inter_pgt", "pbus_spotlight.config_feat_pgt", "pbus_spotlight.fol_pqgc_cur_old_conf_score", "pbus_spotlight.fact_order_line_pqgc",
        "fdn_material_view.XCFMaterialCore", "fdn_material_view.XTNObjectCharacteristicValueData", "fdn_customer_view.XTNOrderLine", "PQGC_SPOTLIGHT.FACT_ORDER_LINE_PQGC"
      ],
      writes: [
        "pbus_spotlight.fact_order_line_pqgc_dlt_wrk", "pbus_spotlight.fol_pqgc_cur_old_conf_score_results", "pbus_spotlight.fol_pqgc_cur_old_conf_score_results_new",
        "pbus_spotlight.fol_pqgc_cur_old_conf_score", "pbus_spotlight.fact_order_line_pqgc", "pbus_spotlight.pqgc_work_table_run_odd_dtls",
        "PQGC_SPOTLIGHT.FACT_ORDER_LINE_PQGC_DLT", "PQGC_SPOTLIGHT.FOL_CNCL_ORDSR", "PQGC_SPOTLIGHT.FACT_ORDER_LINE_ZAPA_ORDERS",
        "PQGC_SPOTLIGHT.FOL_DLT_MRGE()", "PQGC_SPOTLIGHT.FOL_CNCL_DELT()", "PQGC_SPOTLIGHT.FOL_ZAPA_ZCMS_DELT()"
      ]
    },

    /* ---------- 06 Supply & ML ---------- */
    {
      file: "plnt_mtrl_scs_rptng.py", stage: "supply", lines: 355,
      title: "Supply-and-demand list with confidence scores",
      plain: "Builds one list per plant and product of everything coming in (transfers on order, loading or in transit, and production) and going out (customer orders). Each item carries a confidence score for how likely it is to arrive, plus the receiving appointment from the warehouse system. The list is sent to the app database.",
      steps: [
        "Gather five kinds of item: transfers, in-transit, customer demand, planned production and production orders.",
        "Order confidence = quantity-weighted line confidence. Production gets a fixed 50.",
        "Keep finished goods (ZFIN). Add brand, region, cases per pallet, and appointment time and yard.",
        "Replace <code>PLANT_MTRL_SCS</code> in the app database.",
        "Every 30 days, refresh the product barcode (GTIN) list in the app."
      ],
      reads: [
        "pbus_spotlight.fact_order_line_pqgc", "pbus_spotlight.pgt_whd_prod_ordr_extrct_tbl_spltght", "pbus_spotlight.pgt_whd_prod_process_ordr_extrct_tbl_spltght",
        "pbus_spotlight.plants_pgt", "pbus_spotlight.pgqc_gtin_run_hist", "fdn_material_view.XCFMaterialCore", "fdn_material_view.XCFMaterialUnitofMeasure",
        "fdn_customer_view.XTNWarehouseManagementTransportationAppointment", "fdn_customer_view.XTNWarehouseManagementTransportEquipmentAssignment"
      ],
      writes: ["pbus_spotlight.plnt_mtrl_scs_rptng", "pbus_spotlight.pgqc_gtin_run_hist", "PQGC_SPOTLIGHT.PLANT_MTRL_SCS", "PQGC_SPOTLIGHT.MTRL_GTIN_PQGC"]
    },
    {
      file: "ML/PQGC_ML_SIT_Predictions.py", stage: "supply", lines: 368,
      title: "Predicts whether in-transit transfers arrive as planned",
      plain: "Uses a pre-trained machine-learning model to give every transfer already on the road a score from 0 to 1. The inputs are route, distance, carrier, shipping condition and the planned dates. The training code is not here, so the meaning of the score is inferred: most likely \"arrives on time\".",
      steps: [
        "Load the model and its preprocessing files from the Unity Catalog volume.",
        "Take open in-transit transfers with a delivery date today or later.",
        "Work out the distance between the origin and destination zip codes.",
        "Scale and encode the inputs, then predict a probability.",
        "Replace the <code>mlpqgcsit</code> table."
      ],
      reads: ["pbus_spotlight.fact_order_pqgc", "pbus_spotlight.plants_pgt", "volume: ml_spotlight_pqgc/SIT model files"],
      writes: ["pbus_spotlight.mlpqgcsit"]
    },
    {
      file: "ML/PQGC_ML_SOO_SPL_Predictions.py", stage: "supply", lines: 248,
      title: "Predicts whether not-yet-shipped transfers leave on time",
      plain: "Does the same for transfers that have not left yet: on order (SOO) or loading (SPL). The inputs are lead time, shipping plant, plant type and carrier. Each prediction is copied to every product line on the order.",
      steps: [
        "Load the model and its preprocessing files.",
        "Take open SOO/SPL transfers with a ship date today or later.",
        "Predict a probability for each order and copy it to its product lines.",
        "Replace the <code>mlpqgcsoospl</code> table."
      ],
      reads: ["pbus_spotlight.fact_order_pqgc", "pbus_spotlight.fact_order_line_pqgc", "pbus_spotlight.plants_pgt", "volume: ml_spotlight_pqgc/SOO-SPL model files"],
      writes: ["pbus_spotlight.mlpqgcsoospl"]
    },

    /* ---------- 07 Publish ---------- */
    {
      file: "EXEC_SP_ASQL.py", stage: "publish", lines: 69,
      title: "Runs a list of app database procedures",
      plain: "Takes a comma-separated list of stored procedure names from the job and runs each one in the app database. If any of them fails, it sends a failure alert.",
      steps: ["Read the list of procedures from the job.", "Run each one in order.", "Email an alert if one fails."],
      params: "<code>sp_list</code>: comma-separated procedure names.",
      reads: [],
      writes: []
    },
    {
      file: "writeback/update timer stamp ASQL.py", stage: "publish", lines: 74,
      title: "Updates the \"last refreshed\" times shown in the app",
      plain: "Keeps the app's status clock current. At the start of a run it notes how fresh the SAP order data is. At the end it records \"Last Spotlight Refresh\" or \"Last SAP Writeback\", and whether the run succeeded.",
      steps: [
        "Start-of-run mode: take the oldest latest-update time across SAP orders and order lines, and pass it on.",
        "End-of-run mode: write success (or failure) and the time to the <code>Timestamp</code> table.",
        "After a full refresh, also record the SAP data-pull time."
      ],
      params: "<code>process</code> (Full / Writeback), <code>success</code> (Success / Failure), <code>sap_data_pull_flg</code>, <code>sap_data_pull_ts</code>.",
      reads: ["fdn_customer_view.Order", "fdn_customer_view.XTNOrderLine"],
      writes: ["PQGC_SPOTLIGHT.Timestamp"]
    },

    /* ---------- 08 Loop ---------- */
    {
      file: "writeback/SAPWritebackStatus.py", stage: "loop", lines: 152,
      title: "Sends planners' changes back to SAP",
      plain: "Collects the changes planners made in Spotlight, saves them as a CSV file in the data-lake folder that feeds SAP S/4, logs which orders were sent, and empties the queue.",
      steps: [
        "Run the preparation procedure: <code>sptl_User_Writeback</code> (ATP) or <code>sptl_Execute_BEAM</code>.",
        "Read the queue table. If it holds any rows, write them to <code>SL_S4_Writeback_&lt;time&gt;.csv</code>.",
        "Log the order numbers sent in <code>wrt_bck_ord_sched</code>.",
        "Empty the queue and report success or failure to the job."
      ],
      params: "<code>write_back_type</code>: ATP or BEAM.",
      reads: ["PQGC_SPOTLIGHT.Writeback", "PQGC_SPOTLIGHT.BEAMWriteback"],
      writes: ["PQGC_SPOTLIGHT.sptl_User_Writeback()", "PQGC_SPOTLIGHT.sptl_Execute_BEAM()", "adls: SAP_S4_ATP/SL_S4_Writeback_<time>.csv", "pbus_spotlight.wrt_bck_ord_sched"]
    },
    {
      file: "writeback/UPDATE_FO.py", stage: "loop", lines: 637,
      title: "Fast refresh of order status between full runs",
      plain: "A near-real-time shortcut. It takes only the orders SAP changed in the latest extract, refreshes their delivery, truck, block and date details, recalculates status, and pushes them to the app immediately. Planners see SAP's response without waiting for the next full rebuild.",
      steps: [
        "Stage the orders changed in the latest extract batch.",
        "Refresh customer-order and transfer details: delivery, truck, carrier, blocks and dates.",
        "Recalculate status (SHPD, CNCL, OPEN, RLSD, HOLD, BLKD).",
        "If the order table is empty, as it is mid-rebuild, wait up to 5 minutes.",
        "Merge into <code>fact_order_pqgc</code>. Cancel an order whose lines are all cancelled.",
        "Send to the app's staging table and run <code>SP_FACT_ORDER_NRT_PQGC</code>."
      ],
      reads: [
        "pbus_spotlight.fact_order_pqgc", "pbus_spotlight.pgt_whd_ordr_item_extrct_tbl", "pbus_spotlight.pgt_whd_po_extrct_tbl_spltght", "pbus_spotlight.pgt_whd_dlvry_extrct_tbl",
        "pbus_spotlight.pgt_whd_shpmt_ord_reference_tbl", "pbus_spotlight.pgt_whd_shpmt_extrct_tbl", "pbus_spotlight.fact_order_line_pqgc",
        "pbus_spotlight.fact_order_pqgc_dlt_wrk", "pbus_spotlight.ord_dely_detl_pgt"
      ],
      writes: ["pbus_spotlight.nrt_fact_order_pqgc", "pbus_spotlight.nrt_fact_order_pqgc_delta", "pbus_spotlight.fact_order_pqgc", "PQGC_SPOTLIGHT.NRT_FACT_ORDER_PQGC_STG", "PQGC_SPOTLIGHT.SP_FACT_ORDER_NRT_PQGC()"]
    },

    /* ---------- Toolkit ---------- */
    {
      file: "Common/ENV_VARIABLES.py", stage: "kit", lines: 31,
      title: "Settings every notebook loads first",
      plain: "Works out the environment (dev, QA, pre-prod or prod) from the workspace address, switches to the matching data catalog, and sets the app database connection details. Every other notebook runs this first.",
      steps: ["Set schema <code>pbus_spotlight</code>, SAP instance A1P and material instance GMP.", "Detect the environment and run <code>USE CATALOG uc_&lt;env&gt;_pbna_mdip_01</code>.", "Set the app database connection. The login is written in plain text; see Things to fix."],
      reads: [], writes: []
    },
    {
      file: "Common/Email.py", stage: "kit", lines: 103,
      title: "Failure alerts",
      plain: "Sends a failure alert through an email web service (an Azure Logic App), with the notebook name, environment and error message. One function covers job failures and the other covers the stale-data check.",
      steps: ["Build the alert: process, environment, notebook, error.", "POST it to the email service, which emails the support contact."],
      reads: [], writes: []
    },
    {
      file: "Common/Optimize drvd tables.py", stage: "kit", lines: 89,
      title: "Keeps the big tables fast",
      plain: "Compacts the largest Databricks tables so queries stay quick. It runs before the extracts (\"pre\") and after the main build (\"post\"), at most once every 6 hours.",
      steps: ["Skip if the last post-stage optimize was under 6 hours ago.", "Pre: order, line, PO, delivery and work tables. Post: stock, inventory and order-delivery tables.", "After the post stage, record the run time."],
      params: "<code>stage</code>: pre or post.",
      reads: ["pbus_spotlight.sptlt_pqgc_optmiz_hist"],
      writes: ["pbus_spotlight.sptlt_pqgc_optmiz_hist"]
    },
    {
      file: "ODD_FO_FOL_MERGE.py", stage: "kit", lines: 1275,
      title: "Shared \"apply changes\" routines",
      plain: "Holds the merge routines that copy each run's fresh slice into the permanent tables: order-delivery detail, order headers and order lines. Each routine updates rows that already exist and inserts new ones. It never deletes.",
      steps: [
        "<code>merge_odd()</code>: current slice β†’ <code>ord_dely_detl_pgt</code>.",
        "<code>merge_fo()</code>: order work table β†’ <code>fact_order_pqgc</code>.",
        "<code>merge_fol()</code>: line work table β†’ <code>fact_order_line_pqgc</code>.",
        "Two history-backfill versions exist but nothing calls them."
      ],
      reads: ["pbus_spotlight.ord_dely_detl_pgt_cur", "pbus_spotlight.fact_order_pqgc_dlt_wrk", "pbus_spotlight.fact_order_line_pqgc_dlt_wrk", "pbus_spotlight.fact_order_pqgc_hist_load", "pbus_spotlight.fact_order_line_pqgc_hist_load"],
      writes: ["pbus_spotlight.ord_dely_detl_pgt", "pbus_spotlight.fact_order_pqgc", "pbus_spotlight.fact_order_line_pqgc"]
    },
    {
      file: "SP_MERGE.py", stage: "kit", lines: 61,
      title: "Runs the app database's merge procedures",
      plain: "Small helpers the order notebooks use to run the stored procedures that merge new orders and lines into the app's tables and delete cancelled or excluded lines.",
      steps: ["FO β†’ <code>FO_DLT_MRGE</code>; FOL β†’ <code>FOL_DLT_MRGE</code>; FOL_DELT β†’ <code>FOL_CNCL_DELT</code>.", "A separate helper runs <code>FOL_ZAPA_ZCMS_DELT</code>."],
      reads: [],
      writes: ["PQGC_SPOTLIGHT.FO_DLT_MRGE()", "PQGC_SPOTLIGHT.FOL_DLT_MRGE()", "PQGC_SPOTLIGHT.FOL_CNCL_DELT()", "PQGC_SPOTLIGHT.FOL_ZAPA_ZCMS_DELT()"]
    },
    {
      file: "writeback/PBNA_COMMON_PROCESS.py", stage: "kit", lines: 285,
      title: "Shared read and write helpers",
      plain: "A toolbox other notebooks load. It reads and writes the app database over JDBC, reads and writes Databricks tables, reads config CSV files and sends SMTP email. It moves no data by itself.",
      steps: [
        "JDBC read and write helpers for the app database.",
        "Delta table read and write helpers. Some swallow errors instead of raising them.",
        "<code>call_sp_switch_schema</code>: a legacy procedure call with its own plain-text login.",
        "<code>send_email_message</code>: plain-text alert through the corporate SMTP relay."
      ],
      reads: [], writes: []
    }
  ],

  /* Lineage board grouping. First matching pattern wins; order sets display order. */
  tableGroups: [
    { label: "Stored procedures it runs", match: "\\(\\)$" },
    { label: "Customer orders & deliveries", match: "^fdn_customer_view\\.(order|xtnorderline|xtnsalesorder|fulfillmentplan|xtnfulfillmentplanline)" },
    { label: "Trucks & warehouse yard", match: "^fdn_customer_view\\.(xtntransportation|xtnwarehouse)" },
    { label: "Customers", match: "^fdn_customer_view\\.(customer|xcfcustomer)" },
    { label: "Purchase & transfer orders", match: "^fdn_supplier_view" },
    { label: "Production", match: "^fdn_material_view\\.(xtnplanorder|xtnproduction)" },
    { label: "Materials & stock", match: "^fdn_material_view" },
    { label: "Run control & checks", match: "(work_table_run|refresh|optmiz|companycodes|gtin_run)" },
    { label: "Change lists", match: "(procss_|missing_so)" },
    { label: "SAP extracts", match: "pgt_whd_" },
    { label: "Stock on hand", match: "(matdoc|invntry)" },
    { label: "Order-delivery detail", match: "ord_dely" },
    { label: "Coverage & supply scores", match: "(plant_m|plnt_mtrl)" },
    { label: "Product barcodes", match: "gtin_pqgc" },
    { label: "Order facts", match: "(fact_order|nrt_fact|fol_pqgc|fol_cncl)" },
    { label: "Config & reference", match: "(config_|plants_pgt|shp_cond)" },
    { label: "ML models & predictions", match: "(mlpqgc|^volume)" },
    { label: "Writeback", match: "(writeback|wrt_bck|^adls)" },
    { label: "App status", match: "timestamp" }
  ],

  glossary: [
    { term: "Spotlight", meaning: "The planner-facing app. Its tables live in the Azure SQL schema PQGC_SPOTLIGHT, and its Databricks tables in pbus_spotlight." },
    { term: "PQGC", meaning: "The name of this Spotlight build. The code never spells it out.", guess: true },
    { term: "PBNA", meaning: "PepsiCo Beverages North America, the business unit in the catalog and service names.", guess: true },
    { term: "SAP S/4 Β· A1P", meaning: "The ERP system that holds orders, deliveries, stock and production. A1P is the SAP instance the code filters on." },
    { term: "GMP", meaning: "The SAP instance that holds the material master (product names, brands, case and pallet conversions)." },
    { term: "Foundation view", meaning: "A curated copy of an SAP table in Databricks (catalog uc_<env>_snt_fdn_01). This is where all the raw data comes from." },
    { term: "Watermark", meaning: "The time up to which changes were already processed. The next run only takes newer changes." },
    { term: "ATP", meaning: "Available to promise: the quantity SAP has confirmed it can ship." },
    { term: "Fill rate", meaning: "Promised Γ· ordered Γ— 100. 100% means the order ships complete." },
    { term: "Revenue at risk", meaning: "(Ordered βˆ’ promised) Γ— net price: the dollar value of the shortfall." },
    { term: "CS Β· PAL", meaning: "Cases and pallets, the two units every quantity is converted to." },
    { term: "SO", meaning: "Sales order: a customer's order." },
    { term: "STO", meaning: "Stock transport order: moving product from one PepsiCo plant or warehouse to another." },
    { term: "SOO", meaning: "STO On Order: a transfer with no truck activity yet. Trusted at 40%." },
    { term: "SPL", meaning: "STO Planned: the truck is checking in or loading. Trusted at 60%." },
    { term: "SIT", meaning: "Stock In Transit: goods issued or the truck has departed. Trusted at 80%." },
    { term: "PO Β· PPO", meaning: "In the coverage maths, PO means planned production order and PPO means production (process) order. Both are trusted at 50%. In the purchase-order extract, PO means purchase order." },
    { term: "Incubation inventory", meaning: "Stock on hold before release (SAP stock type 08), counted at 75% in the coverage score." },
    { term: "FO Β· FOL", meaning: "Fact Order (one row per order) and Fact Order Line (one row per product line)." },
    { term: "ODD", meaning: "Order Delivery Detail: the stitched order-to-delivery-to-truck table." },
    { term: "FCS", meaning: "The daily 0–100% coverage score per plant and product. Probably short for fill (or fulfilment) confidence score.", guess: true },
    { term: "SCS", meaning: "Supply confidence score: how likely a piece of incoming supply is to arrive.", guess: true },
    { term: "OPEN Β· RLSD Β· HOLD Β· BLKD Β· SHPD Β· CNCL", meaning: "Order statuses: open, released to the warehouse, on hold, blocked, shipped, cancelled. TBD means not yet decided." },
    { term: "GRP_ID", meaning: "A load: orders that ship together on one truck or bill of lading." },
    { term: "Cut & ship %", meaning: "A per-plant setting for how short an order can ship and still count as acceptable (orange rather than red)." },
    { term: "ZFIN", meaning: "SAP material type for finished goods." },
    { term: "ZAPA Β· ZCMS", meaning: "SAP item categories excluded from Spotlight and deleted from the app. Their business meaning is not in the code." },
    { term: "BEAM", meaning: "The second writeback type, next to ATP. The code does not say what it stands for.", guess: true },
    { term: "SCAC", meaning: "Standard carrier code: identifies the trucking company." },
    { term: "PGT Β· WHD Β· SPLTGHT", meaning: "Naming parts. SPLTGHT = Spotlight and EXTRCT = extract. PGT and WHD are not spelled out; WHD probably means warehouse data.", guess: true }
  ]
};