@autologix-engineering/shared 1.2.374 → 1.2.376

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.
Files changed (66) hide show
  1. package/package.json +1 -1
  2. package/src/lib/data-transfer-objects/src/check.vehicle.allocation.conflicts.dto.d.ts +19 -0
  3. package/src/lib/data-transfer-objects/src/check.vehicle.allocation.conflicts.dto.js +38 -0
  4. package/src/lib/data-transfer-objects/src/check.vehicle.allocation.conflicts.dto.js.map +1 -0
  5. package/src/lib/data-transfer-objects/src/index.d.ts +2 -0
  6. package/src/lib/data-transfer-objects/src/index.js +2 -0
  7. package/src/lib/data-transfer-objects/src/index.js.map +1 -1
  8. package/src/lib/data-transfer-objects/src/update.vehicle.allocation.conflict.window.dto.d.ts +15 -0
  9. package/src/lib/data-transfer-objects/src/update.vehicle.allocation.conflict.window.dto.js +29 -0
  10. package/src/lib/data-transfer-objects/src/update.vehicle.allocation.conflict.window.dto.js.map +1 -0
  11. package/src/lib/enums/src/command.type.enum.d.ts +1 -0
  12. package/src/lib/enums/src/command.type.enum.js +1 -0
  13. package/src/lib/enums/src/command.type.enum.js.map +1 -1
  14. package/src/lib/enums/src/index.d.ts +1 -0
  15. package/src/lib/enums/src/index.js +1 -0
  16. package/src/lib/enums/src/index.js.map +1 -1
  17. package/src/lib/enums/src/model.enum.d.ts +1 -0
  18. package/src/lib/enums/src/model.enum.js +1 -0
  19. package/src/lib/enums/src/model.enum.js.map +1 -1
  20. package/src/lib/enums/src/query.type.enum.d.ts +1 -0
  21. package/src/lib/enums/src/query.type.enum.js +1 -0
  22. package/src/lib/enums/src/query.type.enum.js.map +1 -1
  23. package/src/lib/enums/src/report.module.type.enum.d.ts +2 -1
  24. package/src/lib/enums/src/report.module.type.enum.js +1 -0
  25. package/src/lib/enums/src/report.module.type.enum.js.map +1 -1
  26. package/src/lib/enums/src/vehicle.allocation.conflict.enum.d.ts +65 -0
  27. package/src/lib/enums/src/vehicle.allocation.conflict.enum.js +71 -0
  28. package/src/lib/enums/src/vehicle.allocation.conflict.enum.js.map +1 -0
  29. package/src/lib/models/src/ba.payout.row.model.d.ts +24 -0
  30. package/src/lib/models/src/ba.payout.row.model.js.map +1 -1
  31. package/src/lib/models/src/configurations.model.d.ts +12 -0
  32. package/src/lib/models/src/configurations.model.js +11 -0
  33. package/src/lib/models/src/configurations.model.js.map +1 -1
  34. package/src/lib/models/src/index.d.ts +1 -0
  35. package/src/lib/models/src/index.js +1 -0
  36. package/src/lib/models/src/index.js.map +1 -1
  37. package/src/lib/models/src/vehicle.association.file.model.d.ts +34 -1
  38. package/src/lib/models/src/vehicle.association.file.model.js +31 -0
  39. package/src/lib/models/src/vehicle.association.file.model.js.map +1 -1
  40. package/src/lib/models/src/vehicle.verification.log.model.d.ts +81 -0
  41. package/src/lib/models/src/vehicle.verification.log.model.js +51 -0
  42. package/src/lib/models/src/vehicle.verification.log.model.js.map +1 -0
  43. package/src/lib/routes/src/command.registry.routes.d.ts +1 -0
  44. package/src/lib/routes/src/command.registry.routes.js +1 -0
  45. package/src/lib/routes/src/command.registry.routes.js.map +1 -1
  46. package/src/lib/routes/src/query.service.routes.d.ts +1 -0
  47. package/src/lib/routes/src/query.service.routes.js +1 -0
  48. package/src/lib/routes/src/query.service.routes.js.map +1 -1
  49. package/src/lib/utilities/src/ba.payout.workshop.days.d.ts +77 -0
  50. package/src/lib/utilities/src/ba.payout.workshop.days.js +109 -0
  51. package/src/lib/utilities/src/ba.payout.workshop.days.js.map +1 -0
  52. package/src/lib/utilities/src/index.d.ts +2 -0
  53. package/src/lib/utilities/src/index.js +2 -0
  54. package/src/lib/utilities/src/index.js.map +1 -1
  55. package/src/lib/utilities/src/map.compliance.from.rc.d.ts +7 -0
  56. package/src/lib/utilities/src/map.compliance.from.rc.js +7 -0
  57. package/src/lib/utilities/src/map.compliance.from.rc.js.map +1 -1
  58. package/src/lib/utilities/src/spot.placeholder.registration.d.ts +49 -0
  59. package/src/lib/utilities/src/spot.placeholder.registration.js +88 -0
  60. package/src/lib/utilities/src/spot.placeholder.registration.js.map +1 -0
  61. package/src/lib/view-models/src/index.d.ts +1 -0
  62. package/src/lib/view-models/src/index.js +1 -0
  63. package/src/lib/view-models/src/index.js.map +1 -1
  64. package/src/lib/view-models/src/vehicle.allocation.conflict.d.ts +28 -0
  65. package/src/lib/view-models/src/vehicle.allocation.conflict.js +2 -0
  66. package/src/lib/view-models/src/vehicle.allocation.conflict.js.map +1 -0
@@ -0,0 +1,88 @@
1
+ import { GenericStatus, VehicleOwnershipType } from '@autologix/shared/enums';
2
+ /**
3
+ * Registration formats the RTO actually issues.
4
+ *
5
+ * Two shapes cover the fleet:
6
+ *
7
+ * STANDARD `KA05QR3436` — 2-letter state, 1-2 digit RTO, 0-3 letter series,
8
+ * 4 digits. The series is optional because older plates omit it
9
+ * (`KA079715`), and a 1-letter series is normal (`MH58B1199`).
10
+ * BH `22BH1299ZA` — Bharat series: 2-digit year, BH, 4 digits, 1-2
11
+ * letters.
12
+ *
13
+ * Calibrated against UAT rather than assumed. It matches 359/359 Company Owned
14
+ * + BA, 83/83 Hotel Managed and 29/29 MMG registrations, so it is not
15
+ * rejecting real plates — which is the failure mode that would matter, since a
16
+ * false positive here stops a real vehicle being checked.
17
+ */
18
+ const STANDARD_PLATE = /^[A-Z]{2}\d{1,2}[A-Z]{0,3}\d{4}$/;
19
+ const BH_SERIES_PLATE = /^\d{2}BH\d{4}[A-Z]{1,2}$/;
20
+ /** Uppercased, with the separators people type stripped out. */
21
+ export const normaliseRegistration = (value) => (value ?? '').toUpperCase().replace(/[\s.-]/g, '');
22
+ /** Whether a registration could plausibly be a real Indian number plate. */
23
+ export const looksLikeRealRegistration = (value) => {
24
+ const plate = normaliseRegistration(value);
25
+ if (!plate)
26
+ return false;
27
+ return STANDARD_PLATE.test(plate) || BH_SERIES_PLATE.test(plate);
28
+ };
29
+ /**
30
+ * A spot-hire row that stands in for a vehicle rather than naming one.
31
+ *
32
+ * Spot hire books capacity from a supplier before anyone knows which car will
33
+ * turn up, so the vehicle master row carries the supplier's own code — UAT
34
+ * holds `TBS03`, `SWIFT1`, `MYCITI5`, `WINGS22`, `STATE05`. The real plate is
35
+ * captured separately at allocation as the Actual Vehicle Number.
36
+ *
37
+ * 793 of UAT's 2490 spot rows are like this. Every provider hit against one is
38
+ * a billable call that can only ever return "RC number is invalid" — precisely
39
+ * the 400 QA reported — and every compliance verdict derived from one judges a
40
+ * vehicle that does not exist.
41
+ *
42
+ * Deliberately narrowed to spot hire. The same regex would also flag test rows
43
+ * in other business types (`TEST123`, `SANJOG9`), but those are meant to name a
44
+ * real vehicle, so a bad registration there is a data-quality problem someone
45
+ * should see and fix — not a reason to stop checking compliance. Exempting them
46
+ * would quietly turn a typo into a hole in the allocation block.
47
+ */
48
+ export const isSpotPlaceholderRegistration = (registration, businessType) => {
49
+ if (businessType !== VehicleOwnershipType.HiredCarSpot)
50
+ return false;
51
+ return !looksLikeRealRegistration(registration);
52
+ };
53
+ /**
54
+ * The business type a vehicle's compliance should be judged against.
55
+ *
56
+ * The ACTIVE contract wins, then the most recently created one, then the
57
+ * vehicle's own ownership field. That ordering matters: `Vehicle.ownershipType`
58
+ * goes stale when a vehicle moves vendors, so reading it directly applies the
59
+ * PREVIOUS business type's rules — a vehicle showing "Company Owned" was still
60
+ * being judged as "Company Owned + BA" (AD-3140, QA round 2 finding M).
61
+ *
62
+ * Falls back rather than returning undefined when no contract is loaded: a
63
+ * caller that omits the relation should degrade to the old behaviour, not to
64
+ * "no compliance is mandatory", which would silently disable the block.
65
+ *
66
+ * Pure and shared because three places need this answer — the allocation
67
+ * block, the §8 report, and the provider-hit filter — and three copies is
68
+ * three places for it to drift. The evaluation service and the report service
69
+ * had already drifted once, which is what finding M was.
70
+ */
71
+ export const resolveVehicleBusinessType = (contracts, fallbackOwnershipType, now = new Date()) => {
72
+ const rows = contracts ?? [];
73
+ const active = rows.find((contract) => {
74
+ const from = contract.bizTypeEffectiveFrom
75
+ ? new Date(contract.bizTypeEffectiveFrom)
76
+ : undefined;
77
+ const end = contract.endDate ? new Date(contract.endDate) : undefined;
78
+ return ((!from || from <= now) &&
79
+ (!end || end >= now) &&
80
+ contract.status === GenericStatus.Active);
81
+ });
82
+ const latest = rows.length
83
+ ? [...rows].sort((a, b) => new Date(b.crdAt ?? 0).getTime() -
84
+ new Date(a.crdAt ?? 0).getTime())[0]
85
+ : undefined;
86
+ return (active?.bizType ?? latest?.bizType ?? fallbackOwnershipType ?? undefined);
87
+ };
88
+ //# sourceMappingURL=spot.placeholder.registration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spot.placeholder.registration.js","sourceRoot":"","sources":["../../../../../../../libs/shared/src/lib/utilities/src/spot.placeholder.registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAC1D,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAEnD,gEAAgE;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAqB,EAAU,EAAE,CACtE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAEpD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,KAAqB,EAAW,EAAE;IAC3E,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,OAAO,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC5C,YAA4B,EAC5B,YAA4B,EAClB,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AAO,CACN,MAAM,EAAE,OAAO,IAAI,MAAM,EAAE,OAAO,IAAI,qBAAqB,IAAI,SAAS,CACxE,CAAC;AACH,CAAC,CAAC"}
@@ -27,3 +27,4 @@ export * from './process.vehicle.rates.upload.progress';
27
27
  export * from './process.ba.payout.upload.progress';
28
28
  export * from './concurrent.users';
29
29
  export * from './ext.rate.card';
30
+ export * from './vehicle.allocation.conflict';
@@ -27,4 +27,5 @@ export * from './process.vehicle.rates.upload.progress';
27
27
  export * from './process.ba.payout.upload.progress';
28
28
  export * from './concurrent.users';
29
29
  export * from './ext.rate.card';
30
+ export * from './vehicle.allocation.conflict';
30
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/shared/src/lib/view-models/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/shared/src/lib/view-models/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { VehicleAllocationConflictReason } from '../../enums/src/index';
2
+ /** AD-3373 — one duty that clashes with the allocation being attempted. */
3
+ export interface IVehicleAllocationConflict {
4
+ requestId: string;
5
+ /** Booking number of the clashing duty, for the dispatcher to look up. */
6
+ bookingNumber: string | null;
7
+ /** Pickup of the clashing duty, as a UTC instant. Render it in IST. */
8
+ pickupTime: string | null;
9
+ /** Booking status of the clashing duty (Booked / Allotted / Dispatched). */
10
+ status: string | null;
11
+ /** Trip status, present when the clashing duty has a trip. */
12
+ tripStatus: string | null;
13
+ reason: VehicleAllocationConflictReason;
14
+ /** True when the clash is on the very booking the user is working from. */
15
+ isSameBooking: boolean;
16
+ }
17
+ /**
18
+ * AD-3373 — result of the allocation conflict check.
19
+ *
20
+ * `windowMinutes` is echoed back so the client can name the window in the
21
+ * warning without holding its own copy of the config, which would drift.
22
+ */
23
+ export interface IVehicleAllocationConflictResult {
24
+ windowMinutes: number;
25
+ /** Server clock at evaluation, UTC. The window is measured from here. */
26
+ evaluatedAt: string;
27
+ conflicts: IVehicleAllocationConflict[];
28
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=vehicle.allocation.conflict.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vehicle.allocation.conflict.js","sourceRoot":"","sources":["../../../../../../../libs/shared/src/lib/view-models/src/vehicle.allocation.conflict.ts"],"names":[],"mappings":""}