@bisondesk/core-sdk 1.0.666 → 1.0.668
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/types/opportunities.d.ts +3 -3
- package/lib/types/opportunities.d.ts.map +1 -1
- package/lib/types/opportunities.js.map +1 -1
- package/lib/types/quotes.d.ts +10 -0
- package/lib/types/quotes.d.ts.map +1 -1
- package/lib/types/quotes.js +7 -0
- package/lib/types/quotes.js.map +1 -1
- package/lib/types/vehicles.d.ts +85 -1
- package/lib/types/vehicles.d.ts.map +1 -1
- package/lib/types/vehicles.js +35 -0
- package/lib/types/vehicles.js.map +1 -1
- package/lib/utils/tenants.d.ts +1 -0
- package/lib/utils/tenants.d.ts.map +1 -1
- package/lib/utils/tenants.js +4 -0
- package/lib/utils/tenants.js.map +1 -1
- package/lib/utils/tenants.test.d.ts +2 -0
- package/lib/utils/tenants.test.d.ts.map +1 -0
- package/lib/utils/tenants.test.js +39 -0
- package/lib/utils/tenants.test.js.map +1 -0
- package/package.json +1 -1
- package/src/types/opportunities.ts +4 -3
- package/src/types/quotes.ts +23 -0
- package/src/types/vehicles.ts +105 -0
- package/src/utils/tenants.test.ts +47 -0
- package/src/utils/tenants.ts +11 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/types/activities.js +0 -13
- package/src/types/activities.js.map +0 -1
- package/src/types/comparables.js +0 -2
- package/src/types/comparables.js.map +0 -1
- package/src/types/crm.js +0 -58
- package/src/types/crm.js.map +0 -1
- package/src/types/dashboard.js +0 -2
- package/src/types/dashboard.js.map +0 -1
- package/src/types/definitions.js +0 -2
- package/src/types/definitions.js.map +0 -1
- package/src/types/fields.js +0 -2
- package/src/types/fields.js.map +0 -1
- package/src/types/insights.js +0 -2
- package/src/types/insights.js.map +0 -1
- package/src/types/interests.js +0 -6
- package/src/types/interests.js.map +0 -1
- package/src/types/internal-events.js +0 -18
- package/src/types/internal-events.js.map +0 -1
- package/src/types/internet-opportunities.js +0 -2
- package/src/types/internet-opportunities.js.map +0 -1
- package/src/types/internet-vehicles.js +0 -2
- package/src/types/internet-vehicles.js.map +0 -1
- package/src/types/leasing-administration.js +0 -2
- package/src/types/leasing-administration.js.map +0 -1
- package/src/types/leasing-debtors.js +0 -2
- package/src/types/leasing-debtors.js.map +0 -1
- package/src/types/leasing-search.js +0 -2
- package/src/types/leasing-search.js.map +0 -1
- package/src/types/leasing-settings.js +0 -7
- package/src/types/leasing-settings.js.map +0 -1
- package/src/types/leasing.js +0 -38
- package/src/types/leasing.js.map +0 -1
- package/src/types/marketing.js +0 -35
- package/src/types/marketing.js.map +0 -1
- package/src/types/offers.js +0 -56
- package/src/types/opportunities.js +0 -107
- package/src/types/opportunities.js.map +0 -1
- package/src/types/payments.js +0 -7
- package/src/types/picklists.js +0 -2
- package/src/types/picklists.js.map +0 -1
- package/src/types/quotes.js +0 -42
- package/src/types/recently-viewed.js +0 -2
- package/src/types/recently-viewed.js.map +0 -1
- package/src/types/reservations.js +0 -5
- package/src/types/reservations.js.map +0 -1
- package/src/types/roi-ratings.js +0 -5
- package/src/types/roi-ratings.js.map +0 -1
- package/src/types/saved-filters.js +0 -9
- package/src/types/saved-filters.js.map +0 -1
- package/src/types/search.js +0 -2
- package/src/types/search.js.map +0 -1
- package/src/types/settings.js +0 -2
- package/src/types/settings.js.map +0 -1
- package/src/types/templates.js +0 -2
- package/src/types/templates.js.map +0 -1
- package/src/types/tenants.js +0 -21
- package/src/types/tenants.js.map +0 -1
- package/src/types/user-performance.js +0 -7
- package/src/types/user-performance.js.map +0 -1
- package/src/types/utils.js +0 -2
- package/src/types/validation.js +0 -2
- package/src/types/validation.js.map +0 -1
- package/src/types/vehicle-sales.js +0 -6
- package/src/types/vehicle-sales.js.map +0 -1
- package/src/types/vehicles.js +0 -98
- package/src/types/vehicles.js.map +0 -1
- package/src/utils/leasing.js +0 -6
- package/src/utils/leasing.js.map +0 -1
- package/src/utils/opportunities.js +0 -48
- package/src/utils/opportunities.js.map +0 -1
package/lib/types/vehicles.js
CHANGED
|
@@ -87,7 +87,42 @@ export var VehicleActions;
|
|
|
87
87
|
VehicleActions["ViewPurchase"] = "view_purchase";
|
|
88
88
|
VehicleActions["ViewPriceHistory"] = "view_price_history";
|
|
89
89
|
VehicleActions["DeleteVehicle"] = "delete_vehicle";
|
|
90
|
+
VehicleActions["ChangeBranch"] = "change_branch";
|
|
90
91
|
})(VehicleActions || (VehicleActions = {}));
|
|
92
|
+
export var VehicleBranchChangeBlockerCode;
|
|
93
|
+
(function (VehicleBranchChangeBlockerCode) {
|
|
94
|
+
VehicleBranchChangeBlockerCode["SameBranch"] = "same_branch";
|
|
95
|
+
VehicleBranchChangeBlockerCode["VehicleDeleted"] = "vehicle_deleted";
|
|
96
|
+
VehicleBranchChangeBlockerCode["CurrencyMismatch"] = "currency_mismatch";
|
|
97
|
+
VehicleBranchChangeBlockerCode["FinanceDocumentsExist"] = "finance_documents_exist";
|
|
98
|
+
VehicleBranchChangeBlockerCode["PurchasePaymentsExist"] = "purchase_payments_exist";
|
|
99
|
+
VehicleBranchChangeBlockerCode["DealCommitted"] = "deal_committed";
|
|
100
|
+
VehicleBranchChangeBlockerCode["VehicleSold"] = "vehicle_sold";
|
|
101
|
+
VehicleBranchChangeBlockerCode["LeasingContractExists"] = "leasing_contract_exists";
|
|
102
|
+
VehicleBranchChangeBlockerCode["RelatedVehicles"] = "related_vehicles";
|
|
103
|
+
VehicleBranchChangeBlockerCode["InternalDealQuote"] = "internal_deal_quote";
|
|
104
|
+
VehicleBranchChangeBlockerCode["IntercompanyLinkLive"] = "intercompany_link_live";
|
|
105
|
+
VehicleBranchChangeBlockerCode["HyperdmsOrganisationChange"] = "hyperdms_organisation_change";
|
|
106
|
+
VehicleBranchChangeBlockerCode["StockNumberTaken"] = "stock_number_taken";
|
|
107
|
+
})(VehicleBranchChangeBlockerCode || (VehicleBranchChangeBlockerCode = {}));
|
|
108
|
+
export var VehicleBranchChangeWarningCode;
|
|
109
|
+
(function (VehicleBranchChangeWarningCode) {
|
|
110
|
+
VehicleBranchChangeWarningCode["DealsLoseQuotes"] = "deals_lose_quotes";
|
|
111
|
+
VehicleBranchChangeWarningCode["DealPaymentsExist"] = "deal_payments_exist";
|
|
112
|
+
VehicleBranchChangeWarningCode["OpenTransports"] = "open_transports";
|
|
113
|
+
VehicleBranchChangeWarningCode["CopiesWithdrawn"] = "copies_withdrawn";
|
|
114
|
+
VehicleBranchChangeWarningCode["CopiesCreated"] = "copies_created";
|
|
115
|
+
VehicleBranchChangeWarningCode["TargetWithoutAccounting"] = "target_without_accounting";
|
|
116
|
+
VehicleBranchChangeWarningCode["TargetWithoutStorecove"] = "target_without_storecove";
|
|
117
|
+
})(VehicleBranchChangeWarningCode || (VehicleBranchChangeWarningCode = {}));
|
|
118
|
+
export var VehicleBranchChangeDealOutcome;
|
|
119
|
+
(function (VehicleBranchChangeDealOutcome) {
|
|
120
|
+
VehicleBranchChangeDealOutcome["FollowsWithQuotes"] = "follows_with_quotes";
|
|
121
|
+
VehicleBranchChangeDealOutcome["FollowsNeedsRequote"] = "follows_needs_requote";
|
|
122
|
+
VehicleBranchChangeDealOutcome["AlreadyOnTarget"] = "already_on_target";
|
|
123
|
+
VehicleBranchChangeDealOutcome["StaysClosed"] = "stays_closed";
|
|
124
|
+
VehicleBranchChangeDealOutcome["Committed"] = "committed";
|
|
125
|
+
})(VehicleBranchChangeDealOutcome || (VehicleBranchChangeDealOutcome = {}));
|
|
91
126
|
export var PurchaseActions;
|
|
92
127
|
(function (PurchaseActions) {
|
|
93
128
|
PurchaseActions["ViewDeal"] = "view_deal";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vehicles.js","sourceRoot":"/","sources":["types/vehicles.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,iCAAiB,CAAA;IACjB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,6CAA6B,CAAA;AAC/B,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AAED,MAAM,CAAN,IAAY,eAoBX;AApBD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,8BAAW,CAAA;IACX,oCAAiB,CAAA;IACjB,wCAAqB,CAAA;IACrB,8BAAW,CAAA;IACX,wCAAqB,CAAA;IACrB,6CAA0B,CAAA;IAC1B,2CAAwB,CAAA;IACxB,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,4CAAyB,CAAA;IACzB,4CAAyB,CAAA;IACzB,kDAA+B,CAAA;IAC/B,kDAA+B,CAAA;IAC/B,sDAAmC,CAAA;IACnC,sDAAmC,CAAA;IACnC,oCAAiB,CAAA;IACjB,kCAAe,CAAA;AACjB,CAAC,EApBW,eAAe,KAAf,eAAe,QAoB1B;AAED,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;IACnB,kDAA6B,CAAA;IAC7B,kDAA6B,CAAA;AAC/B,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AAKD,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,+CAA4B,CAAA;IAC5B,+CAA4B,CAAA;AAC9B,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAqLD,MAAM,CAAN,IAAY,2BAIX;AAJD,WAAY,2BAA2B;IACrC,mDAAoB,CAAA;IACpB,oDAAqB,CAAA;IACrB,4CAAa,CAAA;AACf,CAAC,EAJW,2BAA2B,KAA3B,2BAA2B,QAItC;AAqeD,MAAM,CAAN,IAAY,yBAQX;AARD,WAAY,yBAAyB;IACnC,oDAAuB,CAAA;IACvB,uEAA0C,CAAA;IAC1C,+DAAkC,CAAA;IAClC,0EAA6C,CAAA;IAC7C,oEAAuC,CAAA;IACvC,wEAA2C,CAAA;IAC3C,kEAAqC,CAAA;AACvC,CAAC,EARW,yBAAyB,KAAzB,yBAAyB,QAQpC;AAED,MAAM,CAAN,IAAY,8BAKX;AALD,WAAY,8BAA8B;IACxC,wDAAsB,CAAA;IACtB,qDAAmB,CAAA;IACnB,0DAAwB,CAAA;IACxB,kEAAgC,CAAA;AAClC,CAAC,EALW,8BAA8B,KAA9B,8BAA8B,QAKzC;AAED,MAAM,CAAN,IAAY,2BAGX;AAHD,WAAY,2BAA2B;IACrC,iDAAkB,CAAA;IAClB,mDAAoB,CAAA;AACtB,CAAC,EAHW,2BAA2B,KAA3B,2BAA2B,QAGtC;AAyHD,MAAM,CAAN,IAAY,cAiBX;AAjBD,WAAY,cAAc;IACxB,mDAAiC,CAAA;IACjC,+DAA6C,CAAA;IAC7C,kDAAgC,CAAA;IAChC,0CAAwB,CAAA;IACxB,gDAA8B,CAAA;IAC9B,4CAA0B,CAAA;IAC1B,yDAAuC,CAAA;IACvC,mEAAiD,CAAA;IACjD,0CAAwB,CAAA;IACxB,4CAA0B,CAAA;IAC1B,0CAAwB,CAAA;IACxB,iEAA+C,CAAA;IAC/C,2DAAyC,CAAA;IACzC,gDAA8B,CAAA;IAC9B,yDAAuC,CAAA;IACvC,kDAAgC,CAAA;AAClC,CAAC,EAjBW,cAAc,KAAd,cAAc,QAiBzB;AAED,MAAM,CAAN,IAAY,eAYX;AAZD,WAAY,eAAe;IACzB,yCAAsB,CAAA;IACtB,0EAAuD,CAAA;IACvD,+CAA4B,CAAA;IAC5B,0DAAuC,CAAA;IACvC,4DAAyC,CAAA;IACzC,8DAA2C,CAAA;IAC3C,kEAA+C,CAAA;IAC/C,6CAA0B,CAAA;IAC1B,+CAA4B,CAAA;IAC5B,wDAAqC,CAAA;IACrC,6CAA0B,CAAA;AAC5B,CAAC,EAZW,eAAe,KAAf,eAAe,QAY1B;AAED,MAAM,CAAN,IAAY,8BAEX;AAFD,WAAY,8BAA8B;IACxC,iEAA+B,CAAA;AACjC,CAAC,EAFW,8BAA8B,KAA9B,8BAA8B,QAEzC","sourcesContent":["import {\n AttachmentValue,\n Document,\n LocationValue,\n MultiLangValue,\n PaginatedRequest,\n SearchPermissions,\n ShareEmailRequest,\n ShareWhatsappRequest,\n} from '@bisondesk/commons-sdk/types';\nimport { ReferenceData } from '@bisondesk/commons-sdk/utils';\nimport { BaseEvent } from './internal-events.js';\nimport { VehicleSaleLogisticsStatus } from './opportunities.js';\nimport { OpportunityReservation } from './reservations.js';\nimport { ComplexFilter, Filter } from './search.js';\nimport { Transport } from './transports.js';\nimport { DataRecord } from './utils.js';\nimport { VehicleBusinessOverviewXL } from './vehicle-performance.js';\nimport { VehicleSaleInfo } from './vehicle-sales.js';\n\nexport enum VehicleRoles {\n SALE = 'SALE',\n OWN_USE = 'OWN_USE',\n RENTAL = 'RENTAL',\n BUILD = 'BUILD',\n UNKNOWN = 'UNKNOWN',\n BANK_FINANCE = 'BANK_FINANCE',\n}\n\nexport enum VehicleFuelType {\n Petrol = 'PETROL',\n Diesel = 'DIESEL',\n LPG = 'LPG',\n LPG_G3 = 'LPG_G3',\n Electric = 'ELECTRIC',\n CNG = 'CNG',\n Hydrogen = 'HYDROGEN',\n BioEthanol = 'BIO_ETHANOL',\n BioDiesel = 'BIO_DIESEL',\n E85 = 'E85',\n HCNG = 'HCNG',\n LPG_Petrol = 'LPG_PETROL',\n LPG_Diesel = 'LPG_DIESEL',\n LPG_G3_Petrol = 'LPG_G3_PETROL',\n LPG_G3_Diesel = 'LPG_G3_DIESEL',\n Electric_Diesel = 'ELECTRIC_DIESEL',\n Electric_Petrol = 'ELECTRIC_PETROL',\n Hybrid = 'HYBRID',\n Other = 'OTHER',\n}\n\nexport enum VehicleTachoTypes {\n Analog = 'ANALOG',\n Digital = 'DIGITAL',\n SmartTacho1 = 'SMART_TACHO_1',\n SmartTacho2 = 'SMART_TACHO_2',\n}\n\n/**\n * Official manufacturer warranty programs offered\n * */\nexport enum WarrantyProgram {\n OfficialDaf = 'OFFICIAL_DAF',\n OfficialMan = 'OFFICIAL_MAN',\n}\n\ntype BaseVehicleEvent = BaseEvent & {\n id: string;\n actionAt: string;\n userId: string;\n tenantId: string;\n};\n\ntype VehicleSuperstructure = {\n carCapacity?: number;\n compartmentCount?: number;\n counter?: boolean;\n crane?: {\n make?: string;\n model?: string;\n position?: 'Behind the cabin' | 'Rear';\n present?: boolean;\n year?: number;\n };\n dimensions?: {\n height?: number;\n length?: number;\n width?: number;\n extended?: string; // L1, L2, ...\n heightened?: string; // H1, H2, ...\n };\n baseVehicle?: SuperstructureBaseVehicle;\n extendable?: boolean;\n highPressurePump?: boolean;\n loadingPlatformHeight?: number;\n pump?: boolean;\n slidingRoof?: boolean;\n tailgate?: {\n capacity?: number;\n make?: string;\n model?: string;\n present?: boolean;\n type?: 'slider_lift' | 'cantilever' | 'column_lift';\n };\n tank?: {\n capacity: number; //litters\n volume?: number; //m3\n };\n temperatureControl?: {\n engineType?: 'diesel' | 'electric' | 'diesel+electric' | 'engine';\n make?: string;\n runningHours?: {\n diesel?: number;\n electric?: number;\n };\n };\n tipper?: {\n tipsBack?: boolean;\n tipsLeft?: boolean;\n tipsRight?: boolean;\n };\n};\n\nexport type NewVehicleRequest = {\n branch: string;\n count: number;\n specs: VehicleExternalInfo;\n description: {\n remarks?: string;\n technicalRemarks?: string;\n };\n salesConditions?: {\n marginScheme?: boolean;\n manufacturerWarranty?: {\n remarks?: string;\n available?: boolean;\n program?: WarrantyProgram;\n };\n };\n logistics: {\n parking?: string;\n deliveryType?: VehiclePurchaseDeliveryType;\n pickupAddress?: LocationValue;\n status: VehiclePurchaseLogisticsStatus;\n transportWithoutPayment?: boolean;\n };\n prices: {\n minimum?: string;\n premium?: string;\n internet?: string;\n };\n media: {\n internalPictures: AttachmentValue[];\n pictures: AttachmentValue[];\n videos: AttachmentValue[];\n docs: Document[];\n engineeringDocs: Document[];\n };\n vinList?: string;\n /** Bulk only: derive every stock number from a single base number (B49397A, B49397B, ...). */\n relatedStockNumbers?: boolean;\n deal: {\n offerId?: string;\n stockNumber?: string;\n contactId: string;\n orgId: string;\n purchasedBy: string;\n purchaseAssistedBy?: string;\n readyToDeliver?: boolean;\n dealStatus: VehiclePurchaseDealStatus;\n costs: {\n purchase: string;\n purchaseVatPercentage: string;\n commission?: string;\n externalTransport?: string;\n internalTransport?: string;\n externalGarage?: string;\n internalGarage?: string;\n other?: string;\n bonus?: string;\n };\n logistics: {\n availableDate?: string;\n vehicleRole: VehicleRoles;\n };\n };\n};\n\nexport type VehicleCreateEvent = BaseVehicleEvent & {\n action: 'create';\n vehicle: Vehicle;\n previousVehicle?: undefined;\n};\n\nexport type VehicleUpdateEvent = BaseVehicleEvent & {\n action: 'update';\n vehicle: Vehicle;\n previousVehicle: Vehicle;\n};\n\nexport type VehicleDeleteEvent = BaseVehicleEvent & {\n action: 'delete';\n vehicle?: undefined;\n previousVehicle: Vehicle;\n};\n\nexport type VehicleEvent = VehicleCreateEvent | VehicleUpdateEvent | VehicleDeleteEvent;\n\ntype BaseVehiclePurchaseEvent = {\n actionAt: string;\n userId: string;\n tenantId: string;\n branchId: string;\n vehicleId: string;\n};\n\nexport type VehiclePurchaseCreateEvent = BaseVehiclePurchaseEvent & {\n action: 'create';\n data: VehiclePurchase;\n previousData?: undefined;\n};\n\nexport type VehiclePurchaseUpdateEvent = BaseVehiclePurchaseEvent & {\n action: 'update';\n data: VehiclePurchase;\n previousData: VehiclePurchase;\n};\n\nexport type VehiclePurchaseEvent = BaseEvent &\n (VehiclePurchaseCreateEvent | VehiclePurchaseUpdateEvent);\n\nexport type UpdateVehiclesPricesEvent = {\n id: string;\n actionAt: string;\n userId: string;\n tenantId: string;\n priceList: AttachmentValue;\n};\n\nexport type PublicVehicle = Pick<Vehicle, 'external' | 'id'>;\n\nexport type PublicSearchVehicle = {\n vehicle: PublicVehicle;\n};\n\nexport enum SearchVehicleSaleDealStatus {\n NotSold = 'NOT_SOLD',\n Reserved = 'RESERVED',\n Sold = 'SOLD',\n}\n\nexport type SearchVehicle = {\n custom: {\n features: string[];\n sold: boolean;\n isReserved: boolean;\n hasPayments: boolean;\n listedOnWebsite: boolean;\n publishedOnWebsiteAt?: string;\n originalBranchId: string;\n };\n customSortableFields: {\n priceChangedAt?: string;\n checkedInAt?: string;\n saleAgreementAt?: string;\n /** Date the vehicle entered virtual inventory (marketing ?? evaluation ?? purchase-agreed). */\n virtualInventoryStartedAt?: string;\n };\n purchase?: {\n supplierStockNumber?: string;\n readyToDeliver: boolean;\n dealStatus?: VehiclePurchaseDealStatus;\n logisticsStatus?: VehiclePurchaseLogisticsStatus;\n purchasedBy?: string;\n purchaseAgreedAt?: string;\n parkingName?: string;\n organizationId: string;\n organizationExternalId?: number;\n fullPaymentSentAt?: string;\n marketingStartedAt?: string;\n arrivedAt?: string;\n };\n reservation?: Pick<OpportunityReservation, 'expiresAt' | 'opportunityId' | 'createdBy'>;\n transports: Transport[];\n vehicle: Vehicle;\n sale: {\n opportunityId?: string;\n externalSaleId?: string;\n soldAt?: string;\n soldBy?: string;\n sellers?: string[]; // opportunity account manager [+ assistant]\n dealStatus: SearchVehicleSaleDealStatus;\n logisticStatus?: VehicleSaleLogisticsStatus;\n };\n};\n\nexport type InputSearchVehicle = SearchVehicle & {\n permissions?: SearchPermissions;\n};\n\nexport type VehicleSearchMeta = ReferenceData & {\n matchingOffers?: {\n count: number;\n filters: {\n conditions: Array<Filter | ComplexFilter>;\n fullText?: string;\n };\n };\n};\n\nexport type PriceChangeEvent = BaseEvent & {\n tenantId: string;\n userId: string;\n vehicleId: string;\n input: {\n previousPrices: VehiclePricingHistoryInput;\n currentPrices: VehiclePricingHistoryInput;\n };\n};\n\nexport type VehiclePricingHistory = {\n pricing: VehiclePricingHistoryInput;\n createdAt: string;\n createdBy: string;\n};\n\nexport type VehiclePricingHistoryInput = VehiclePricing & { internet?: string };\n\nexport type VehiclePricing = {\n premium?: string;\n minimum?: string;\n currency?: string;\n};\n\nexport type RelatedVehicle = {\n vehicleId: string;\n description: string;\n stockNumber: string;\n};\n\nexport type VehicleInternalInfo = {\n createdAt: string;\n description: {\n title: string;\n remarks?: string;\n technicalRemarks?: string;\n };\n identification: {\n administrativeNumber?: string;\n stockNumber: string;\n branch: string;\n customerStockNumber?: string;\n offerId?: string;\n licensePlateHistory?: {\n licensePlate: string;\n changedAt: string;\n }[];\n\n /**\n * This ID is used to link different vehicle objects that represent the same real world asset.\n * Ideally the chassis number could be used, but in some cases it is not available yet.\n */\n metaId: string;\n };\n documents: Document[];\n pictures: AttachmentValue[];\n engineeringDocs: Document[];\n pricing: VehiclePricing;\n /**\n * Set when a target-tenant operator edits the retail price on a cross-tenant\n * copy (`original` set) that is still source-mastered. From that moment,\n * cross-tenant sync stops overwriting `external.salesConditions` from the\n * source. ISO timestamp + user id of the first takeover.\n */\n sourcePriceOverride?: { at: string; by: string };\n role: VehicleRoles;\n status: VehicleStatus;\n updatedAt: string;\n /* use this property to store additional terms that you want the vehicle to be found with when doing a full text search */\n keywords?: string[];\n relatedVehicles: RelatedVehicle[];\n};\n\nexport type VehicleOriginalInfo = {\n /** IMMEDIATE source tenant (the predecessor in a sync chain). */\n tenantId: string;\n tenantChain?: string[];\n identification: {\n id: string;\n branchId: string;\n stockNumber: string;\n metaId?: string;\n country: string;\n };\n salesConditions: {\n leasing?: boolean;\n price?: string;\n currency?: string;\n marginScheme?: boolean;\n manufacturerWarranty?: {\n remarks?: string;\n available?: boolean;\n };\n /**\n * The immediate source's sellability at the last sync hop: true when the source was not\n * sellable — not in `SALE` role, had an active reservation or external sale, or was itself\n * unavailable. Derived (never set by a human) and refreshed on every cross-tenant update so\n * it cascades down the whole chain.\n */\n unavailable?: boolean;\n };\n /**\n * Deepest-origin tenant/branch in a multi-hop sync chain. Carries forward\n * verbatim across hops so consumers can answer \"where did this vehicle\n * actually originate?\" without walking the chain.\n */\n owner: {\n tenantId: string;\n branchId: string;\n country: string;\n };\n};\n\nexport type VehicleAxlesInfo = {\n details?: VehicleAxle[];\n configuration?: string;\n count?: number;\n poweredAxlesCount?: number;\n wheelbase?: number;\n suspension?: 'Air' | 'Air/Steel' | 'Steel';\n loadCapacity?: number;\n};\n\nexport type SuperstructureBaseVehicle = {\n category: string;\n make: string;\n model?: string;\n type?: string;\n axlesConfiguration?: string;\n emissionsClass?: string;\n transmissionType?: 'Automatic' | 'Manual' | 'Semi-Automatic';\n vin?: string;\n currentRegistration?: {\n country?: string;\n };\n suspension?: 'Air' | 'Air/Steel' | 'Steel';\n constructionYear?: number;\n firstRegistration?: string;\n odometerKm?: number;\n powerHp?: number;\n bodystyle?: string;\n accessories: VehicleExternalInfo['accessories'];\n superstructure?: Pick<VehicleSuperstructure, 'crane' | 'tailgate'>;\n};\n\n// mostly inspired by the Hexon data model\nexport type VehicleExternalInfo = {\n body?: {\n cabin?: {\n type: 'Day' | 'Sleep / Small' | 'Sleep / Medium' | 'Sleep / Large';\n model?: string;\n };\n colour?: string;\n dimensions?: {\n height?: number;\n length?: number;\n width?: number;\n };\n doorCount?: number;\n interior?: {\n bedCount?: number;\n seatCount?: number;\n };\n internalDimensions?: {\n //for Trailers/Semi-trailers of type reefers, box, curtainsides\n height?: number;\n length?: number;\n width?: number;\n };\n kingpin?: {\n //for Trailers/Semi-trailers\n size?: number; // in inches\n capacity?: number; // in kg\n };\n fifthWheelHeight?: number; //for new trailers in mm\n };\n mainPicture?: AttachmentValue;\n pictures?: AttachmentValue[];\n videos?: AttachmentValue[];\n condition?: {\n damaged?: boolean;\n odometer?: {\n km?: number;\n };\n used?: boolean;\n };\n general: {\n bodystyle?: string;\n category: string;\n make?: string;\n model?: string;\n modelName?: string;\n type?: string;\n typeName?: string;\n tacho?: VehicleTachoTypes;\n color?: {\n mainColorHex?: string; //Hex color code\n chassisColorReferenceCode?: string; //Maker reference code. For now, mainly relevant for new trailers\n upperStructureColorReferenceCode?: string; //Maker reference code. For now, mainly relevant for new trailers\n };\n };\n history?: {\n advertisingYear?: number;\n constructionYear?: number;\n currentRegistration?: {\n country?: string;\n technicalInspectionEndDate?: string;\n carpassUrl?: string;\n carpassAvailable?: boolean;\n };\n firstRegistration?: string;\n cocPvg?: string;\n };\n identification: {\n licensePlate?: string;\n stockNumber?: string;\n vin?: string;\n buildStockNumber?: string;\n engineNumber?: string;\n };\n trailers?: {\n cooler?: {\n hasCooler?: boolean;\n make?: string;\n };\n };\n powertrain?: {\n axles?: VehicleAxlesInfo;\n emissions?: {\n class?: string;\n subclass?: string;\n };\n engine?: {\n cylinderCount?: number;\n energy?: { type?: VehicleFuelType };\n power?: {\n hp?: number;\n };\n displacement?: number;\n };\n transmission?: {\n gearCount?: number;\n make?: string;\n model?: string;\n type?: 'Automatic' | 'Manual' | 'Semi-Automatic';\n };\n };\n salesConditions: {\n leasing?: boolean;\n price?: string | undefined;\n currency?: string | undefined;\n /**\n * Read-only field maintained by `fillReadOnlyFields` on every vehicle save:\n * the value of `price` immediately before the most recent price change. Stays\n * unchanged when `price` does not change between saves. Same currency as\n * `price`. Useful for storefront \"was/now\" price-drop labels and for the AI\n * assistant's negotiation context.\n */\n previousPrice?: string;\n marginScheme?: boolean;\n manufacturerWarranty?: {\n remarks?: string;\n available?: boolean;\n included?: boolean;\n remarksIncluded?: string;\n program?: WarrantyProgram;\n };\n /**\n * Per-country snapshot computed by the owning tenant's `fillReadOnlyFields`.\n * Every field on this snapshot is public — `vehicle.external` rides through\n * to the storefront via cross-tenant sync, so internal-only values (e.g. the\n * owner's freight cost) must not appear here. Cross-tenant sync derives the\n * internal `externalTransport` figure directly from the owner's country-\n * delivery rule at sync time.\n *\n * Each entry exposes:\n * - `price` — bare currency conversion for the rule's country.\n * - `previousPrice` — bare conversion of `salesConditions.previousPrice`\n * when set.\n * - `deliveryPrice` — customer-facing delivery fee (when the rule covers\n * the vehicle's category). Storefront consumers sum\n * `price + (deliveryPrice ?? 0)` at the display layer.\n * - `deliveryLocation` — human-readable label, present whenever the rule\n * declared a location for this country.\n *\n * Only the original owner recomputes on save; cross-tenant copies preserve\n * the array. One exception: the target operator may edit the branch-country\n * entry's `deliveryPrice`. The first such edit is a price takeover\n * (`internal.sourcePriceOverride`), after which the snapshot collapses to the\n * branch-country row and the sync stops rebuilding sales conditions.\n */\n localizedPricing?: Array<{\n countryCode: string;\n currency: string;\n price: number;\n previousPrice?: number;\n deliveryPrice?: number;\n deliveryLocation?: string;\n }>;\n };\n superstructure?: VehicleSuperstructure;\n weights?: {\n gvw?: number;\n massEmpty?: number;\n };\n accessories: {\n abs?: boolean;\n jumbo?: boolean;\n adr?: boolean;\n airco?: boolean;\n alloyWheels?: boolean;\n aluminiumFuelTank?: boolean;\n cdPlayer?: boolean;\n coil?: boolean;\n doubleStock?: boolean;\n centralLocking?: boolean;\n centralLubrication?: boolean;\n cruiseControl?: boolean;\n electricDoorMirrors?: boolean;\n electricWindows?: boolean;\n engineBrake?: boolean;\n forklift?: boolean;\n navigationSystem?: boolean;\n hydraulicTipperKit?: boolean;\n lowDeck?: boolean;\n lowNoise?: boolean;\n mega?: boolean;\n parkingHeater?: boolean;\n particleFilter?: boolean;\n powerTakeOff?: boolean;\n refrigerator?: boolean;\n retarderIntarder?: boolean;\n reversingCamera?: boolean;\n roofSpoiler?: boolean;\n sideSkirts?: boolean;\n spareKey?: boolean;\n spareWheel?: boolean;\n speedLimiter?: boolean;\n spoilers?: boolean;\n spotlights?: boolean;\n stabilityControl?: boolean;\n standardAirco?: boolean;\n television?: boolean;\n toolbox?: boolean;\n trailerCoupling?: boolean;\n twinFuelTank?: boolean;\n visor?: boolean;\n xenonLights?: boolean;\n };\n publicLink?: string;\n};\n\ntype BaseVehicle<I = VehicleInternalInfo, E = VehicleExternalInfo> = {\n internal: I;\n external: E;\n original?: VehicleOriginalInfo;\n};\n\nexport type NewVehicle<I = VehicleInternalInfo, E = VehicleExternalInfo> = BaseVehicle<I, E> & {\n id?: undefined;\n};\n\nexport type Vehicle<I = VehicleInternalInfo, E = VehicleExternalInfo> = BaseVehicle<I, E> & {\n id: string;\n};\n\nexport type VehicleBffMetadata = {\n openOpportunities: number;\n};\n\nexport type VehicleBff = {\n vehicle: DataRecord<Vehicle, VehicleBffMetadata>;\n sale?: VehicleSaleInfo;\n purchase?: VehiclePurchase;\n overview?: VehicleBusinessOverviewXL;\n marketing?: {\n titles?: MultiLangValue;\n listed: boolean;\n sharable: boolean;\n publishedOnWebsiteAt?: string;\n numPlatformsPublished: number;\n };\n};\n\nexport type VehiclesByChassisNumberRequest = {\n tenantIds: string[];\n chassisNumber: string;\n};\n\nexport type VehiclesByMetaIdRequest = {\n tenantIds: string[];\n metaId: string;\n};\n\nexport type VehicleAxle = {\n make?: string;\n alloyWheels?: boolean;\n brakes?: 'Disc' | 'Drum';\n differentialLock?: boolean;\n liftAxle?: boolean;\n maxLoad?: number;\n nr: number;\n position?: string;\n powered?: boolean;\n reduction?: string;\n steering?: boolean;\n suspension?: 'Steel' | 'Air' | 'Hydraulic';\n twinWheels?: boolean;\n tyreSize?: string;\n tyreConditionType?: 'mm' | '%';\n\n tyreConditionMmLeftInside?: number;\n tyreConditionMmLeftOutside?: number;\n tyreConditionMmRightInside?: number;\n tyreConditionMmRightOutside?: number;\n\n tyreConditionPercLeftInside?: number;\n tyreConditionPercLeftOutside?: number;\n tyreConditionPercRightInside?: number;\n tyreConditionPercRightOutside?: number;\n\n steeringType?: 'fixed' | 'self_steering' | 'hydraulic';\n};\n\nexport enum VehiclePurchaseDealStatus {\n Marketing = 'MARKETING',\n PurchaseEvaluation = 'PURCHASE_EVALUATION', // used for vehicle consignation\n PurchaseAgreed = 'PURCHASE_AGREED',\n FirstPaymentAllowed = 'FIRST_PAYMENT_ALLOWED',\n FirstPaymentSent = 'FIRST_PAYMENT_SENT',\n FullPaymentAllowed = 'FULL_PAYMENT_ALLOWED',\n FullPaymentSent = 'FULL_PAYMENT_SENT',\n}\n\nexport enum VehiclePurchaseLogisticsStatus {\n AtOrigin = 'AT_ORIGIN',\n Arrived = 'ARRIVED',\n CheckedIn = 'CHECKED_IN',\n NotApplicable = 'NOT_APPLICABLE',\n}\n\nexport enum VehiclePurchaseDeliveryType {\n PickUp = 'PICK_UP',\n DropOff = 'DROP_OFF',\n}\n\nexport type VehicleStatus = {\n deleted?: boolean;\n deletedReason?: string;\n};\n\nexport type VehiclePriceList = {\n uploadedAt: string;\n uploadedBy: string;\n priceList: AttachmentValue;\n id: string;\n};\n\nexport type UpdateVehiclesPricesRequest = {\n priceList: AttachmentValue;\n};\n\nexport type VehiclePriceListLine = {\n reference: string;\n internet?: string;\n premium?: string;\n minimum?: string;\n};\n\nexport type VehiclePriceUpdateError = {\n data: VehiclePriceListLine;\n line: number;\n error: {\n fieldId: keyof VehiclePriceListLine;\n msg: string;\n };\n};\n\nexport type VehiclePriceUpdateResponse =\n | {\n success: true;\n }\n | {\n success: false;\n errors: VehiclePriceUpdateError[];\n };\n\nexport type VehiclePurchase = {\n organizationId: string;\n contactId: string;\n supplierStockNumber?: string;\n purchasedBy: string;\n purchaseAssistedBy?: string;\n\n log: {\n // computed automatically by the backend\n marketingStartedAt?: string;\n marketingStartedBy?: string;\n\n evaluationStartedAt?: string;\n evaluationStartedBy?: string;\n\n purchaseAgreedAt?: string;\n purchaseAgreedBy?: string;\n\n firstPaymentAllowedAt?: string;\n firstPaymentAllowedBy?: string;\n firstPaymentSentAt?: string;\n firstPaymentSentBy?: string;\n\n fullPaymentAllowedAt?: string;\n fullPaymentAllowedBy?: string;\n fullPaymentSentAt?: string;\n fullPaymentSentBy?: string;\n\n arrivedAt?: string;\n arrivedBy?: string;\n\n checkedInAt?: string;\n checkedInBy?: string;\n };\n\n deal: {\n status: VehiclePurchaseDealStatus; // partially set by the user, if there are payments then it is set automatically by the backend\n readyToDeliver?: boolean;\n\n purchaseVatRate?: string;\n purchase?: string; // exclusive VAT\n\n bonus?: string; // sometimes manufacturers pay us a bonus when we reach a target\n\n // estimated costs, real costs come from actual invoices\n commission?: string;\n externalTransport?: string;\n internalTransport?: string;\n externalGarage?: string;\n internalGarage?: string;\n other?: string;\n\n totalCosts?: string; // exclusive VAT\n };\n\n logistics: {\n parkingName?: string;\n status: VehiclePurchaseLogisticsStatus; // manually set by the user\n deliveryType?: VehiclePurchaseDeliveryType;\n pickupAddress?: LocationValue;\n availableWeek?: string; // ISOWEEK, e.g. 2016-W02\n transportWithoutPayment?: boolean;\n };\n};\n\nexport type PurchaseRecordMeta = ReferenceData & {\n allowedLogisticsTransitions?: VehiclePurchaseLogisticsStatus[];\n};\n\nexport type SaveVehiclePurchaseOpts = {\n skipTransportValidation?: boolean;\n /**\n * Save only while the purchase still stands at this version, as read alongside it. The save\n * fails with `vehicles.purchase.changed-since-read` when it has moved on.\n */\n atVersion?: string;\n};\n\nexport enum VehicleActions {\n EditAdminDocs = 'edit_admin_docs',\n EditEngineeringDocs = 'edit_engineering_docs',\n EditMarketing = 'edit_marketing',\n EditMedia = 'edit_media',\n EditPictures = 'edit_pictures',\n EditPrices = 'edit_prices',\n EditPurchaseDeal = 'edit_purchase_deal',\n EditPurchaseLogistics = 'edit_purchase_logistics',\n EditSpecs = 'edit_specs',\n EditVideos = 'edit_videos',\n ViewLeads = 'view_leads',\n ViewBusinessOverview = 'view_business_overview',\n ViewSimilarOnline = 'view_similar_online',\n ViewPurchase = 'view_purchase',\n ViewPriceHistory = 'view_price_history',\n DeleteVehicle = 'delete_vehicle',\n}\n\nexport enum PurchaseActions {\n ViewDeal = 'view_deal',\n ViewSupplierOrganization = 'view_supplier_organization',\n ViewContact = 'view_contact',\n ViewLegalAddress = 'view_legal_address',\n ViewPickupAddress = 'view_pickup_address',\n ViewEstimatedCosts = 'view_estimated_costs',\n ViewFinanceDocuments = 'view_finance_documents',\n AddPayment = 'add_payment',\n EditPayment = 'edit_payment',\n MarkPaymentDone = 'mark_payment_done',\n AddRemarks = 'add_remarks',\n}\n\nexport enum VehicleBusinessOverviewActions {\n View = 'view_business_overview',\n}\n\nexport type VehicleShareEmailRequest = ShareEmailRequest & {\n pictures: AttachmentValue[];\n};\n\nexport type VehicleShareData = {\n title: string;\n mainPicture?: string;\n pictures: {\n picture: string;\n }[];\n message: string;\n specs: {\n name: string;\n value: string;\n }[];\n features: {\n name: string;\n }[];\n stockNumber: string;\n price?: string;\n description?: string;\n publicLink?: string;\n};\n\nexport type MarketingEmailData = {\n message: string;\n vehicles: VehicleShareData[];\n vehiclePairs: { first: VehicleShareData; second?: VehicleShareData }[];\n lastVehicle?: VehicleShareData;\n unsubscribeUrl?: string;\n};\n\nexport type VehicleReservationCreateEvent = BaseVehicleEvent & {\n action: 'create';\n reservation: OpportunityReservation;\n previousReservation?: undefined;\n};\n\nexport type VehicleReservationUpdateEvent = BaseVehicleEvent & {\n action: 'update';\n reservation: OpportunityReservation;\n previousReservation: OpportunityReservation;\n};\n\nexport type VehicleReservationDeleteEvent = BaseVehicleEvent & {\n action: 'delete';\n reservation?: undefined;\n previousReservation: OpportunityReservation;\n};\n\nexport type VehicleReservationEvent =\n | VehicleReservationCreateEvent\n | VehicleReservationUpdateEvent\n | VehicleReservationDeleteEvent;\n\nexport type ShareVehicleViaWahtsappRequest = {\n data: ShareWhatsappRequest;\n vehicleId: string;\n};\n\ntype RecordChange = {\n modifiedAt: string;\n modifiedBy: string;\n};\n\nexport type VehicleChange = RecordChange & {\n vehicle: Vehicle;\n};\n\nexport type PurchaseChange = RecordChange & {\n purchase: VehiclePurchase;\n};\n\nexport type RecordChangeRequest = PaginatedRequest & {\n fieldPath?: string;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"vehicles.js","sourceRoot":"/","sources":["types/vehicles.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,iCAAiB,CAAA;IACjB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,6CAA6B,CAAA;AAC/B,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AAED,MAAM,CAAN,IAAY,eAoBX;AApBD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,8BAAW,CAAA;IACX,oCAAiB,CAAA;IACjB,wCAAqB,CAAA;IACrB,8BAAW,CAAA;IACX,wCAAqB,CAAA;IACrB,6CAA0B,CAAA;IAC1B,2CAAwB,CAAA;IACxB,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,4CAAyB,CAAA;IACzB,4CAAyB,CAAA;IACzB,kDAA+B,CAAA;IAC/B,kDAA+B,CAAA;IAC/B,sDAAmC,CAAA;IACnC,sDAAmC,CAAA;IACnC,oCAAiB,CAAA;IACjB,kCAAe,CAAA;AACjB,CAAC,EApBW,eAAe,KAAf,eAAe,QAoB1B;AAED,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;IACnB,kDAA6B,CAAA;IAC7B,kDAA6B,CAAA;AAC/B,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AAKD,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,+CAA4B,CAAA;IAC5B,+CAA4B,CAAA;AAC9B,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAqLD,MAAM,CAAN,IAAY,2BAIX;AAJD,WAAY,2BAA2B;IACrC,mDAAoB,CAAA;IACpB,oDAAqB,CAAA;IACrB,4CAAa,CAAA;AACf,CAAC,EAJW,2BAA2B,KAA3B,2BAA2B,QAItC;AAmfD,MAAM,CAAN,IAAY,yBAQX;AARD,WAAY,yBAAyB;IACnC,oDAAuB,CAAA;IACvB,uEAA0C,CAAA;IAC1C,+DAAkC,CAAA;IAClC,0EAA6C,CAAA;IAC7C,oEAAuC,CAAA;IACvC,wEAA2C,CAAA;IAC3C,kEAAqC,CAAA;AACvC,CAAC,EARW,yBAAyB,KAAzB,yBAAyB,QAQpC;AAED,MAAM,CAAN,IAAY,8BAKX;AALD,WAAY,8BAA8B;IACxC,wDAAsB,CAAA;IACtB,qDAAmB,CAAA;IACnB,0DAAwB,CAAA;IACxB,kEAAgC,CAAA;AAClC,CAAC,EALW,8BAA8B,KAA9B,8BAA8B,QAKzC;AAED,MAAM,CAAN,IAAY,2BAGX;AAHD,WAAY,2BAA2B;IACrC,iDAAkB,CAAA;IAClB,mDAAoB,CAAA;AACtB,CAAC,EAHW,2BAA2B,KAA3B,2BAA2B,QAGtC;AAyHD,MAAM,CAAN,IAAY,cAkBX;AAlBD,WAAY,cAAc;IACxB,mDAAiC,CAAA;IACjC,+DAA6C,CAAA;IAC7C,kDAAgC,CAAA;IAChC,0CAAwB,CAAA;IACxB,gDAA8B,CAAA;IAC9B,4CAA0B,CAAA;IAC1B,yDAAuC,CAAA;IACvC,mEAAiD,CAAA;IACjD,0CAAwB,CAAA;IACxB,4CAA0B,CAAA;IAC1B,0CAAwB,CAAA;IACxB,iEAA+C,CAAA;IAC/C,2DAAyC,CAAA;IACzC,gDAA8B,CAAA;IAC9B,yDAAuC,CAAA;IACvC,kDAAgC,CAAA;IAChC,gDAA8B,CAAA;AAChC,CAAC,EAlBW,cAAc,KAAd,cAAc,QAkBzB;AASD,MAAM,CAAN,IAAY,8BAcX;AAdD,WAAY,8BAA8B;IACxC,4DAA0B,CAAA;IAC1B,oEAAkC,CAAA;IAClC,wEAAsC,CAAA;IACtC,mFAAiD,CAAA;IACjD,mFAAiD,CAAA;IACjD,kEAAgC,CAAA;IAChC,8DAA4B,CAAA;IAC5B,mFAAiD,CAAA;IACjD,sEAAoC,CAAA;IACpC,2EAAyC,CAAA;IACzC,iFAA+C,CAAA;IAC/C,6FAA2D,CAAA;IAC3D,yEAAuC,CAAA;AACzC,CAAC,EAdW,8BAA8B,KAA9B,8BAA8B,QAczC;AAED,MAAM,CAAN,IAAY,8BAQX;AARD,WAAY,8BAA8B;IACxC,uEAAqC,CAAA;IACrC,2EAAyC,CAAA;IACzC,oEAAkC,CAAA;IAClC,sEAAoC,CAAA;IACpC,kEAAgC,CAAA;IAChC,uFAAqD,CAAA;IACrD,qFAAmD,CAAA;AACrD,CAAC,EARW,8BAA8B,KAA9B,8BAA8B,QAQzC;AAcD,MAAM,CAAN,IAAY,8BASX;AATD,WAAY,8BAA8B;IAExC,2EAAyC,CAAA;IAEzC,+EAA6C,CAAA;IAC7C,uEAAqC,CAAA;IACrC,8DAA4B,CAAA;IAE5B,yDAAuB,CAAA;AACzB,CAAC,EATW,8BAA8B,KAA9B,8BAA8B,QASzC;AAoCD,MAAM,CAAN,IAAY,eAYX;AAZD,WAAY,eAAe;IACzB,yCAAsB,CAAA;IACtB,0EAAuD,CAAA;IACvD,+CAA4B,CAAA;IAC5B,0DAAuC,CAAA;IACvC,4DAAyC,CAAA;IACzC,8DAA2C,CAAA;IAC3C,kEAA+C,CAAA;IAC/C,6CAA0B,CAAA;IAC1B,+CAA4B,CAAA;IAC5B,wDAAqC,CAAA;IACrC,6CAA0B,CAAA;AAC5B,CAAC,EAZW,eAAe,KAAf,eAAe,QAY1B;AAED,MAAM,CAAN,IAAY,8BAEX;AAFD,WAAY,8BAA8B;IACxC,iEAA+B,CAAA;AACjC,CAAC,EAFW,8BAA8B,KAA9B,8BAA8B,QAEzC","sourcesContent":["import {\n AttachmentValue,\n Document,\n LocationValue,\n MultiLangValue,\n PaginatedRequest,\n SearchPermissions,\n ShareEmailRequest,\n ShareWhatsappRequest,\n} from '@bisondesk/commons-sdk/types';\nimport { ReferenceData } from '@bisondesk/commons-sdk/utils';\nimport { BaseEvent } from './internal-events.js';\nimport { VehicleSaleLogisticsStatus } from './opportunities.js';\nimport { OpportunityReservation } from './reservations.js';\nimport { ComplexFilter, Filter } from './search.js';\nimport { Transport } from './transports.js';\nimport { DataRecord } from './utils.js';\nimport { VehicleBusinessOverviewXL } from './vehicle-performance.js';\nimport { VehicleSaleInfo } from './vehicle-sales.js';\n\nexport enum VehicleRoles {\n SALE = 'SALE',\n OWN_USE = 'OWN_USE',\n RENTAL = 'RENTAL',\n BUILD = 'BUILD',\n UNKNOWN = 'UNKNOWN',\n BANK_FINANCE = 'BANK_FINANCE',\n}\n\nexport enum VehicleFuelType {\n Petrol = 'PETROL',\n Diesel = 'DIESEL',\n LPG = 'LPG',\n LPG_G3 = 'LPG_G3',\n Electric = 'ELECTRIC',\n CNG = 'CNG',\n Hydrogen = 'HYDROGEN',\n BioEthanol = 'BIO_ETHANOL',\n BioDiesel = 'BIO_DIESEL',\n E85 = 'E85',\n HCNG = 'HCNG',\n LPG_Petrol = 'LPG_PETROL',\n LPG_Diesel = 'LPG_DIESEL',\n LPG_G3_Petrol = 'LPG_G3_PETROL',\n LPG_G3_Diesel = 'LPG_G3_DIESEL',\n Electric_Diesel = 'ELECTRIC_DIESEL',\n Electric_Petrol = 'ELECTRIC_PETROL',\n Hybrid = 'HYBRID',\n Other = 'OTHER',\n}\n\nexport enum VehicleTachoTypes {\n Analog = 'ANALOG',\n Digital = 'DIGITAL',\n SmartTacho1 = 'SMART_TACHO_1',\n SmartTacho2 = 'SMART_TACHO_2',\n}\n\n/**\n * Official manufacturer warranty programs offered\n * */\nexport enum WarrantyProgram {\n OfficialDaf = 'OFFICIAL_DAF',\n OfficialMan = 'OFFICIAL_MAN',\n}\n\ntype BaseVehicleEvent = BaseEvent & {\n id: string;\n actionAt: string;\n userId: string;\n tenantId: string;\n};\n\ntype VehicleSuperstructure = {\n carCapacity?: number;\n compartmentCount?: number;\n counter?: boolean;\n crane?: {\n make?: string;\n model?: string;\n position?: 'Behind the cabin' | 'Rear';\n present?: boolean;\n year?: number;\n };\n dimensions?: {\n height?: number;\n length?: number;\n width?: number;\n extended?: string; // L1, L2, ...\n heightened?: string; // H1, H2, ...\n };\n baseVehicle?: SuperstructureBaseVehicle;\n extendable?: boolean;\n highPressurePump?: boolean;\n loadingPlatformHeight?: number;\n pump?: boolean;\n slidingRoof?: boolean;\n tailgate?: {\n capacity?: number;\n make?: string;\n model?: string;\n present?: boolean;\n type?: 'slider_lift' | 'cantilever' | 'column_lift';\n };\n tank?: {\n capacity: number; //litters\n volume?: number; //m3\n };\n temperatureControl?: {\n engineType?: 'diesel' | 'electric' | 'diesel+electric' | 'engine';\n make?: string;\n runningHours?: {\n diesel?: number;\n electric?: number;\n };\n };\n tipper?: {\n tipsBack?: boolean;\n tipsLeft?: boolean;\n tipsRight?: boolean;\n };\n};\n\nexport type NewVehicleRequest = {\n branch: string;\n count: number;\n specs: VehicleExternalInfo;\n description: {\n remarks?: string;\n technicalRemarks?: string;\n };\n salesConditions?: {\n marginScheme?: boolean;\n manufacturerWarranty?: {\n remarks?: string;\n available?: boolean;\n program?: WarrantyProgram;\n };\n };\n logistics: {\n parking?: string;\n deliveryType?: VehiclePurchaseDeliveryType;\n pickupAddress?: LocationValue;\n status: VehiclePurchaseLogisticsStatus;\n transportWithoutPayment?: boolean;\n };\n prices: {\n minimum?: string;\n premium?: string;\n internet?: string;\n };\n media: {\n internalPictures: AttachmentValue[];\n pictures: AttachmentValue[];\n videos: AttachmentValue[];\n docs: Document[];\n engineeringDocs: Document[];\n };\n vinList?: string;\n /** Bulk only: derive every stock number from a single base number (B49397A, B49397B, ...). */\n relatedStockNumbers?: boolean;\n deal: {\n offerId?: string;\n stockNumber?: string;\n contactId: string;\n orgId: string;\n purchasedBy: string;\n purchaseAssistedBy?: string;\n readyToDeliver?: boolean;\n dealStatus: VehiclePurchaseDealStatus;\n costs: {\n purchase: string;\n purchaseVatPercentage: string;\n commission?: string;\n externalTransport?: string;\n internalTransport?: string;\n externalGarage?: string;\n internalGarage?: string;\n other?: string;\n bonus?: string;\n };\n logistics: {\n availableDate?: string;\n vehicleRole: VehicleRoles;\n };\n };\n};\n\nexport type VehicleCreateEvent = BaseVehicleEvent & {\n action: 'create';\n vehicle: Vehicle;\n previousVehicle?: undefined;\n};\n\nexport type VehicleUpdateEvent = BaseVehicleEvent & {\n action: 'update';\n vehicle: Vehicle;\n previousVehicle: Vehicle;\n};\n\nexport type VehicleDeleteEvent = BaseVehicleEvent & {\n action: 'delete';\n vehicle?: undefined;\n previousVehicle: Vehicle;\n};\n\nexport type VehicleEvent = VehicleCreateEvent | VehicleUpdateEvent | VehicleDeleteEvent;\n\ntype BaseVehiclePurchaseEvent = {\n actionAt: string;\n userId: string;\n tenantId: string;\n branchId: string;\n vehicleId: string;\n};\n\nexport type VehiclePurchaseCreateEvent = BaseVehiclePurchaseEvent & {\n action: 'create';\n data: VehiclePurchase;\n previousData?: undefined;\n};\n\nexport type VehiclePurchaseUpdateEvent = BaseVehiclePurchaseEvent & {\n action: 'update';\n data: VehiclePurchase;\n previousData: VehiclePurchase;\n};\n\nexport type VehiclePurchaseEvent = BaseEvent &\n (VehiclePurchaseCreateEvent | VehiclePurchaseUpdateEvent);\n\nexport type UpdateVehiclesPricesEvent = {\n id: string;\n actionAt: string;\n userId: string;\n tenantId: string;\n priceList: AttachmentValue;\n};\n\nexport type PublicVehicle = Pick<Vehicle, 'external' | 'id'>;\n\nexport type PublicSearchVehicle = {\n vehicle: PublicVehicle;\n};\n\nexport enum SearchVehicleSaleDealStatus {\n NotSold = 'NOT_SOLD',\n Reserved = 'RESERVED',\n Sold = 'SOLD',\n}\n\nexport type SearchVehicle = {\n custom: {\n features: string[];\n sold: boolean;\n isReserved: boolean;\n hasPayments: boolean;\n listedOnWebsite: boolean;\n publishedOnWebsiteAt?: string;\n originalBranchId: string;\n };\n customSortableFields: {\n priceChangedAt?: string;\n checkedInAt?: string;\n saleAgreementAt?: string;\n /** Date the vehicle entered virtual inventory (marketing ?? evaluation ?? purchase-agreed). */\n virtualInventoryStartedAt?: string;\n };\n purchase?: {\n supplierStockNumber?: string;\n readyToDeliver: boolean;\n dealStatus?: VehiclePurchaseDealStatus;\n logisticsStatus?: VehiclePurchaseLogisticsStatus;\n purchasedBy?: string;\n purchaseAgreedAt?: string;\n parkingName?: string;\n organizationId: string;\n organizationExternalId?: number;\n fullPaymentSentAt?: string;\n marketingStartedAt?: string;\n arrivedAt?: string;\n };\n reservation?: Pick<OpportunityReservation, 'expiresAt' | 'opportunityId' | 'createdBy'>;\n transports: Transport[];\n vehicle: Vehicle;\n sale: {\n opportunityId?: string;\n externalSaleId?: string;\n soldAt?: string;\n soldBy?: string;\n sellers?: string[]; // opportunity account manager [+ assistant]\n dealStatus: SearchVehicleSaleDealStatus;\n logisticStatus?: VehicleSaleLogisticsStatus;\n };\n};\n\nexport type InputSearchVehicle = SearchVehicle & {\n permissions?: SearchPermissions;\n};\n\nexport type VehicleSearchMeta = ReferenceData & {\n matchingOffers?: {\n count: number;\n filters: {\n conditions: Array<Filter | ComplexFilter>;\n fullText?: string;\n };\n };\n};\n\nexport type PriceChangeEvent = BaseEvent & {\n tenantId: string;\n userId: string;\n vehicleId: string;\n input: {\n previousPrices: VehiclePricingHistoryInput;\n currentPrices: VehiclePricingHistoryInput;\n };\n};\n\nexport type VehiclePricingHistory = {\n pricing: VehiclePricingHistoryInput;\n createdAt: string;\n createdBy: string;\n};\n\nexport type VehiclePricingHistoryInput = VehiclePricing & { internet?: string };\n\nexport type VehiclePricing = {\n premium?: string;\n minimum?: string;\n currency?: string;\n};\n\nexport type RelatedVehicle = {\n vehicleId: string;\n description: string;\n stockNumber: string;\n};\n\nexport type VehicleBranchHistoryEntry = {\n branch: string;\n stockNumber: string;\n administrativeNumber?: string;\n changedAt: string;\n changedBy: string;\n reason?: string;\n};\n\nexport type VehicleInternalInfo = {\n createdAt: string;\n description: {\n title: string;\n remarks?: string;\n technicalRemarks?: string;\n };\n identification: {\n administrativeNumber?: string;\n stockNumber: string;\n branch: string;\n customerStockNumber?: string;\n offerId?: string;\n licensePlateHistory?: {\n licensePlate: string;\n changedAt: string;\n }[];\n /**\n * One entry per branch the vehicle has left, oldest first. Records the identity it carried\n * there (stock and administrative numbers are redrawn on a move) and who moved it.\n */\n branchHistory?: VehicleBranchHistoryEntry[];\n\n /**\n * This ID is used to link different vehicle objects that represent the same real world asset.\n * Ideally the chassis number could be used, but in some cases it is not available yet.\n */\n metaId: string;\n };\n documents: Document[];\n pictures: AttachmentValue[];\n engineeringDocs: Document[];\n pricing: VehiclePricing;\n /**\n * Set when a target-tenant operator edits the retail price on a cross-tenant\n * copy (`original` set) that is still source-mastered. From that moment,\n * cross-tenant sync stops overwriting `external.salesConditions` from the\n * source. ISO timestamp + user id of the first takeover.\n */\n sourcePriceOverride?: { at: string; by: string };\n role: VehicleRoles;\n status: VehicleStatus;\n updatedAt: string;\n /* use this property to store additional terms that you want the vehicle to be found with when doing a full text search */\n keywords?: string[];\n relatedVehicles: RelatedVehicle[];\n};\n\nexport type VehicleOriginalInfo = {\n /** IMMEDIATE source tenant (the predecessor in a sync chain). */\n tenantId: string;\n tenantChain?: string[];\n identification: {\n id: string;\n branchId: string;\n stockNumber: string;\n metaId?: string;\n country: string;\n };\n salesConditions: {\n leasing?: boolean;\n price?: string;\n currency?: string;\n marginScheme?: boolean;\n manufacturerWarranty?: {\n remarks?: string;\n available?: boolean;\n };\n /**\n * The immediate source's sellability at the last sync hop: true when the source was not\n * sellable — not in `SALE` role, had an active reservation or external sale, or was itself\n * unavailable. Derived (never set by a human) and refreshed on every cross-tenant update so\n * it cascades down the whole chain.\n */\n unavailable?: boolean;\n };\n /**\n * Deepest-origin tenant/branch in a multi-hop sync chain. Carries forward\n * verbatim across hops so consumers can answer \"where did this vehicle\n * actually originate?\" without walking the chain.\n */\n owner: {\n tenantId: string;\n branchId: string;\n country: string;\n };\n};\n\nexport type VehicleAxlesInfo = {\n details?: VehicleAxle[];\n configuration?: string;\n count?: number;\n poweredAxlesCount?: number;\n wheelbase?: number;\n suspension?: 'Air' | 'Air/Steel' | 'Steel';\n loadCapacity?: number;\n};\n\nexport type SuperstructureBaseVehicle = {\n category: string;\n make: string;\n model?: string;\n type?: string;\n axlesConfiguration?: string;\n emissionsClass?: string;\n transmissionType?: 'Automatic' | 'Manual' | 'Semi-Automatic';\n vin?: string;\n currentRegistration?: {\n country?: string;\n };\n suspension?: 'Air' | 'Air/Steel' | 'Steel';\n constructionYear?: number;\n firstRegistration?: string;\n odometerKm?: number;\n powerHp?: number;\n bodystyle?: string;\n accessories: VehicleExternalInfo['accessories'];\n superstructure?: Pick<VehicleSuperstructure, 'crane' | 'tailgate'>;\n};\n\n// mostly inspired by the Hexon data model\nexport type VehicleExternalInfo = {\n body?: {\n cabin?: {\n type: 'Day' | 'Sleep / Small' | 'Sleep / Medium' | 'Sleep / Large';\n model?: string;\n };\n colour?: string;\n dimensions?: {\n height?: number;\n length?: number;\n width?: number;\n };\n doorCount?: number;\n interior?: {\n bedCount?: number;\n seatCount?: number;\n };\n internalDimensions?: {\n //for Trailers/Semi-trailers of type reefers, box, curtainsides\n height?: number;\n length?: number;\n width?: number;\n };\n kingpin?: {\n //for Trailers/Semi-trailers\n size?: number; // in inches\n capacity?: number; // in kg\n };\n fifthWheelHeight?: number; //for new trailers in mm\n };\n mainPicture?: AttachmentValue;\n pictures?: AttachmentValue[];\n videos?: AttachmentValue[];\n condition?: {\n damaged?: boolean;\n odometer?: {\n km?: number;\n };\n used?: boolean;\n };\n general: {\n bodystyle?: string;\n category: string;\n make?: string;\n model?: string;\n modelName?: string;\n type?: string;\n typeName?: string;\n tacho?: VehicleTachoTypes;\n color?: {\n mainColorHex?: string; //Hex color code\n chassisColorReferenceCode?: string; //Maker reference code. For now, mainly relevant for new trailers\n upperStructureColorReferenceCode?: string; //Maker reference code. For now, mainly relevant for new trailers\n };\n };\n history?: {\n advertisingYear?: number;\n constructionYear?: number;\n currentRegistration?: {\n country?: string;\n technicalInspectionEndDate?: string;\n carpassUrl?: string;\n carpassAvailable?: boolean;\n };\n firstRegistration?: string;\n cocPvg?: string;\n };\n identification: {\n licensePlate?: string;\n stockNumber?: string;\n vin?: string;\n buildStockNumber?: string;\n engineNumber?: string;\n };\n trailers?: {\n cooler?: {\n hasCooler?: boolean;\n make?: string;\n };\n };\n powertrain?: {\n axles?: VehicleAxlesInfo;\n emissions?: {\n class?: string;\n subclass?: string;\n };\n engine?: {\n cylinderCount?: number;\n energy?: { type?: VehicleFuelType };\n power?: {\n hp?: number;\n };\n displacement?: number;\n };\n transmission?: {\n gearCount?: number;\n make?: string;\n model?: string;\n type?: 'Automatic' | 'Manual' | 'Semi-Automatic';\n };\n };\n salesConditions: {\n leasing?: boolean;\n price?: string | undefined;\n currency?: string | undefined;\n /**\n * Read-only field maintained by `fillReadOnlyFields` on every vehicle save:\n * the value of `price` immediately before the most recent price change. Stays\n * unchanged when `price` does not change between saves. Same currency as\n * `price`. Useful for storefront \"was/now\" price-drop labels and for the AI\n * assistant's negotiation context.\n */\n previousPrice?: string;\n marginScheme?: boolean;\n manufacturerWarranty?: {\n remarks?: string;\n available?: boolean;\n included?: boolean;\n remarksIncluded?: string;\n program?: WarrantyProgram;\n };\n /**\n * Per-country snapshot computed by the owning tenant's `fillReadOnlyFields`.\n * Every field on this snapshot is public — `vehicle.external` rides through\n * to the storefront via cross-tenant sync, so internal-only values (e.g. the\n * owner's freight cost) must not appear here. Cross-tenant sync derives the\n * internal `externalTransport` figure directly from the owner's country-\n * delivery rule at sync time.\n *\n * Each entry exposes:\n * - `price` — bare currency conversion for the rule's country.\n * - `previousPrice` — bare conversion of `salesConditions.previousPrice`\n * when set.\n * - `deliveryPrice` — customer-facing delivery fee (when the rule covers\n * the vehicle's category). Storefront consumers sum\n * `price + (deliveryPrice ?? 0)` at the display layer.\n * - `deliveryLocation` — human-readable label, present whenever the rule\n * declared a location for this country.\n *\n * Only the original owner recomputes on save; cross-tenant copies preserve\n * the array. One exception: the target operator may edit the branch-country\n * entry's `deliveryPrice`. The first such edit is a price takeover\n * (`internal.sourcePriceOverride`), after which the snapshot collapses to the\n * branch-country row and the sync stops rebuilding sales conditions.\n */\n localizedPricing?: Array<{\n countryCode: string;\n currency: string;\n price: number;\n previousPrice?: number;\n deliveryPrice?: number;\n deliveryLocation?: string;\n }>;\n };\n superstructure?: VehicleSuperstructure;\n weights?: {\n gvw?: number;\n massEmpty?: number;\n };\n accessories: {\n abs?: boolean;\n jumbo?: boolean;\n adr?: boolean;\n airco?: boolean;\n alloyWheels?: boolean;\n aluminiumFuelTank?: boolean;\n cdPlayer?: boolean;\n coil?: boolean;\n doubleStock?: boolean;\n centralLocking?: boolean;\n centralLubrication?: boolean;\n cruiseControl?: boolean;\n electricDoorMirrors?: boolean;\n electricWindows?: boolean;\n engineBrake?: boolean;\n forklift?: boolean;\n navigationSystem?: boolean;\n hydraulicTipperKit?: boolean;\n lowDeck?: boolean;\n lowNoise?: boolean;\n mega?: boolean;\n parkingHeater?: boolean;\n particleFilter?: boolean;\n powerTakeOff?: boolean;\n refrigerator?: boolean;\n retarderIntarder?: boolean;\n reversingCamera?: boolean;\n roofSpoiler?: boolean;\n sideSkirts?: boolean;\n spareKey?: boolean;\n spareWheel?: boolean;\n speedLimiter?: boolean;\n spoilers?: boolean;\n spotlights?: boolean;\n stabilityControl?: boolean;\n standardAirco?: boolean;\n television?: boolean;\n toolbox?: boolean;\n trailerCoupling?: boolean;\n twinFuelTank?: boolean;\n visor?: boolean;\n xenonLights?: boolean;\n };\n publicLink?: string;\n};\n\ntype BaseVehicle<I = VehicleInternalInfo, E = VehicleExternalInfo> = {\n internal: I;\n external: E;\n original?: VehicleOriginalInfo;\n};\n\nexport type NewVehicle<I = VehicleInternalInfo, E = VehicleExternalInfo> = BaseVehicle<I, E> & {\n id?: undefined;\n};\n\nexport type Vehicle<I = VehicleInternalInfo, E = VehicleExternalInfo> = BaseVehicle<I, E> & {\n id: string;\n};\n\nexport type VehicleBffMetadata = {\n openOpportunities: number;\n};\n\nexport type VehicleBff = {\n vehicle: DataRecord<Vehicle, VehicleBffMetadata>;\n sale?: VehicleSaleInfo;\n purchase?: VehiclePurchase;\n overview?: VehicleBusinessOverviewXL;\n marketing?: {\n titles?: MultiLangValue;\n listed: boolean;\n sharable: boolean;\n publishedOnWebsiteAt?: string;\n numPlatformsPublished: number;\n };\n};\n\nexport type VehiclesByChassisNumberRequest = {\n tenantIds: string[];\n chassisNumber: string;\n};\n\nexport type VehiclesByMetaIdRequest = {\n tenantIds: string[];\n metaId: string;\n};\n\nexport type VehicleAxle = {\n make?: string;\n alloyWheels?: boolean;\n brakes?: 'Disc' | 'Drum';\n differentialLock?: boolean;\n liftAxle?: boolean;\n maxLoad?: number;\n nr: number;\n position?: string;\n powered?: boolean;\n reduction?: string;\n steering?: boolean;\n suspension?: 'Steel' | 'Air' | 'Hydraulic';\n twinWheels?: boolean;\n tyreSize?: string;\n tyreConditionType?: 'mm' | '%';\n\n tyreConditionMmLeftInside?: number;\n tyreConditionMmLeftOutside?: number;\n tyreConditionMmRightInside?: number;\n tyreConditionMmRightOutside?: number;\n\n tyreConditionPercLeftInside?: number;\n tyreConditionPercLeftOutside?: number;\n tyreConditionPercRightInside?: number;\n tyreConditionPercRightOutside?: number;\n\n steeringType?: 'fixed' | 'self_steering' | 'hydraulic';\n};\n\nexport enum VehiclePurchaseDealStatus {\n Marketing = 'MARKETING',\n PurchaseEvaluation = 'PURCHASE_EVALUATION', // used for vehicle consignation\n PurchaseAgreed = 'PURCHASE_AGREED',\n FirstPaymentAllowed = 'FIRST_PAYMENT_ALLOWED',\n FirstPaymentSent = 'FIRST_PAYMENT_SENT',\n FullPaymentAllowed = 'FULL_PAYMENT_ALLOWED',\n FullPaymentSent = 'FULL_PAYMENT_SENT',\n}\n\nexport enum VehiclePurchaseLogisticsStatus {\n AtOrigin = 'AT_ORIGIN',\n Arrived = 'ARRIVED',\n CheckedIn = 'CHECKED_IN',\n NotApplicable = 'NOT_APPLICABLE',\n}\n\nexport enum VehiclePurchaseDeliveryType {\n PickUp = 'PICK_UP',\n DropOff = 'DROP_OFF',\n}\n\nexport type VehicleStatus = {\n deleted?: boolean;\n deletedReason?: string;\n};\n\nexport type VehiclePriceList = {\n uploadedAt: string;\n uploadedBy: string;\n priceList: AttachmentValue;\n id: string;\n};\n\nexport type UpdateVehiclesPricesRequest = {\n priceList: AttachmentValue;\n};\n\nexport type VehiclePriceListLine = {\n reference: string;\n internet?: string;\n premium?: string;\n minimum?: string;\n};\n\nexport type VehiclePriceUpdateError = {\n data: VehiclePriceListLine;\n line: number;\n error: {\n fieldId: keyof VehiclePriceListLine;\n msg: string;\n };\n};\n\nexport type VehiclePriceUpdateResponse =\n | {\n success: true;\n }\n | {\n success: false;\n errors: VehiclePriceUpdateError[];\n };\n\nexport type VehiclePurchase = {\n organizationId: string;\n contactId: string;\n supplierStockNumber?: string;\n purchasedBy: string;\n purchaseAssistedBy?: string;\n\n log: {\n // computed automatically by the backend\n marketingStartedAt?: string;\n marketingStartedBy?: string;\n\n evaluationStartedAt?: string;\n evaluationStartedBy?: string;\n\n purchaseAgreedAt?: string;\n purchaseAgreedBy?: string;\n\n firstPaymentAllowedAt?: string;\n firstPaymentAllowedBy?: string;\n firstPaymentSentAt?: string;\n firstPaymentSentBy?: string;\n\n fullPaymentAllowedAt?: string;\n fullPaymentAllowedBy?: string;\n fullPaymentSentAt?: string;\n fullPaymentSentBy?: string;\n\n arrivedAt?: string;\n arrivedBy?: string;\n\n checkedInAt?: string;\n checkedInBy?: string;\n };\n\n deal: {\n status: VehiclePurchaseDealStatus; // partially set by the user, if there are payments then it is set automatically by the backend\n readyToDeliver?: boolean;\n\n purchaseVatRate?: string;\n purchase?: string; // exclusive VAT\n\n bonus?: string; // sometimes manufacturers pay us a bonus when we reach a target\n\n // estimated costs, real costs come from actual invoices\n commission?: string;\n externalTransport?: string;\n internalTransport?: string;\n externalGarage?: string;\n internalGarage?: string;\n other?: string;\n\n totalCosts?: string; // exclusive VAT\n };\n\n logistics: {\n parkingName?: string;\n status: VehiclePurchaseLogisticsStatus; // manually set by the user\n deliveryType?: VehiclePurchaseDeliveryType;\n pickupAddress?: LocationValue;\n availableWeek?: string; // ISOWEEK, e.g. 2016-W02\n transportWithoutPayment?: boolean;\n };\n};\n\nexport type PurchaseRecordMeta = ReferenceData & {\n allowedLogisticsTransitions?: VehiclePurchaseLogisticsStatus[];\n};\n\nexport type SaveVehiclePurchaseOpts = {\n skipTransportValidation?: boolean;\n /**\n * Save only while the purchase still stands at this version, as read alongside it. The save\n * fails with `vehicles.purchase.changed-since-read` when it has moved on.\n */\n atVersion?: string;\n};\n\nexport enum VehicleActions {\n EditAdminDocs = 'edit_admin_docs',\n EditEngineeringDocs = 'edit_engineering_docs',\n EditMarketing = 'edit_marketing',\n EditMedia = 'edit_media',\n EditPictures = 'edit_pictures',\n EditPrices = 'edit_prices',\n EditPurchaseDeal = 'edit_purchase_deal',\n EditPurchaseLogistics = 'edit_purchase_logistics',\n EditSpecs = 'edit_specs',\n EditVideos = 'edit_videos',\n ViewLeads = 'view_leads',\n ViewBusinessOverview = 'view_business_overview',\n ViewSimilarOnline = 'view_similar_online',\n ViewPurchase = 'view_purchase',\n ViewPriceHistory = 'view_price_history',\n DeleteVehicle = 'delete_vehicle',\n ChangeBranch = 'change_branch',\n}\n\nexport type VehicleBranchChangeRequest = {\n branch: string;\n reason?: string;\n /** Required when the preview carries a warning that needs acknowledgement. */\n acknowledged?: boolean;\n};\n\nexport enum VehicleBranchChangeBlockerCode {\n SameBranch = 'same_branch',\n VehicleDeleted = 'vehicle_deleted',\n CurrencyMismatch = 'currency_mismatch',\n FinanceDocumentsExist = 'finance_documents_exist',\n PurchasePaymentsExist = 'purchase_payments_exist',\n DealCommitted = 'deal_committed',\n VehicleSold = 'vehicle_sold',\n LeasingContractExists = 'leasing_contract_exists',\n RelatedVehicles = 'related_vehicles',\n InternalDealQuote = 'internal_deal_quote',\n IntercompanyLinkLive = 'intercompany_link_live',\n HyperdmsOrganisationChange = 'hyperdms_organisation_change',\n StockNumberTaken = 'stock_number_taken',\n}\n\nexport enum VehicleBranchChangeWarningCode {\n DealsLoseQuotes = 'deals_lose_quotes',\n DealPaymentsExist = 'deal_payments_exist',\n OpenTransports = 'open_transports',\n CopiesWithdrawn = 'copies_withdrawn',\n CopiesCreated = 'copies_created',\n TargetWithoutAccounting = 'target_without_accounting',\n TargetWithoutStorecove = 'target_without_storecove',\n}\n\nexport type VehicleBranchChangeBlocker = {\n code: VehicleBranchChangeBlockerCode;\n data?: Record<string, unknown>;\n};\n\nexport type VehicleBranchChangeWarning = {\n code: VehicleBranchChangeWarningCode;\n /** The write refuses unless the request says `acknowledged: true`. */\n requiresAcknowledgement: boolean;\n data?: Record<string, unknown>;\n};\n\nexport enum VehicleBranchChangeDealOutcome {\n /** Branches are quote-compatible: the deal and its quotes move together. */\n FollowsWithQuotes = 'follows_with_quotes',\n /** The deal moves; its quotes stay archived on the old branch and it needs a new one. */\n FollowsNeedsRequote = 'follows_needs_requote',\n AlreadyOnTarget = 'already_on_target',\n StaysClosed = 'stays_closed',\n /** In Preparation or later: contracts and paperwork exist, so this deal blocks the move. */\n Committed = 'committed',\n}\n\nexport type VehicleBranchChangeDealImpact = {\n opportunityId: string;\n status: string;\n branch: string;\n outcome: VehicleBranchChangeDealOutcome;\n hasActiveQuote: boolean;\n paymentsCount: number;\n};\n\nexport type VehicleBranchChangeIdentity = {\n branch: string;\n stockNumber: string;\n administrativeNumber?: string;\n};\n\nexport type VehicleBranchChangePreview = {\n from: VehicleBranchChangeIdentity;\n /** The administrative number is only known once drawn, so the preview leaves it out. */\n to: Omit<VehicleBranchChangeIdentity, 'administrativeNumber'>;\n blockers: VehicleBranchChangeBlocker[];\n warnings: VehicleBranchChangeWarning[];\n /** Counts of the records that follow are not reported: the warnings above already name them. */\n impact: { deals: VehicleBranchChangeDealImpact[] };\n};\n\nexport type VehicleBranchChangeResult = {\n vehicle: Vehicle;\n from: VehicleBranchChangeIdentity;\n to: VehicleBranchChangeIdentity;\n deals: VehicleBranchChangeDealImpact[];\n /** Repair steps that failed after the vehicle moved; running the move again retries them. */\n failedSteps: string[];\n};\n\nexport enum PurchaseActions {\n ViewDeal = 'view_deal',\n ViewSupplierOrganization = 'view_supplier_organization',\n ViewContact = 'view_contact',\n ViewLegalAddress = 'view_legal_address',\n ViewPickupAddress = 'view_pickup_address',\n ViewEstimatedCosts = 'view_estimated_costs',\n ViewFinanceDocuments = 'view_finance_documents',\n AddPayment = 'add_payment',\n EditPayment = 'edit_payment',\n MarkPaymentDone = 'mark_payment_done',\n AddRemarks = 'add_remarks',\n}\n\nexport enum VehicleBusinessOverviewActions {\n View = 'view_business_overview',\n}\n\nexport type VehicleShareEmailRequest = ShareEmailRequest & {\n pictures: AttachmentValue[];\n};\n\nexport type VehicleShareData = {\n title: string;\n mainPicture?: string;\n pictures: {\n picture: string;\n }[];\n message: string;\n specs: {\n name: string;\n value: string;\n }[];\n features: {\n name: string;\n }[];\n stockNumber: string;\n price?: string;\n description?: string;\n publicLink?: string;\n};\n\nexport type MarketingEmailData = {\n message: string;\n vehicles: VehicleShareData[];\n vehiclePairs: { first: VehicleShareData; second?: VehicleShareData }[];\n lastVehicle?: VehicleShareData;\n unsubscribeUrl?: string;\n};\n\nexport type VehicleReservationCreateEvent = BaseVehicleEvent & {\n action: 'create';\n reservation: OpportunityReservation;\n previousReservation?: undefined;\n};\n\nexport type VehicleReservationUpdateEvent = BaseVehicleEvent & {\n action: 'update';\n reservation: OpportunityReservation;\n previousReservation: OpportunityReservation;\n};\n\nexport type VehicleReservationDeleteEvent = BaseVehicleEvent & {\n action: 'delete';\n reservation?: undefined;\n previousReservation: OpportunityReservation;\n};\n\nexport type VehicleReservationEvent =\n | VehicleReservationCreateEvent\n | VehicleReservationUpdateEvent\n | VehicleReservationDeleteEvent;\n\nexport type ShareVehicleViaWahtsappRequest = {\n data: ShareWhatsappRequest;\n vehicleId: string;\n};\n\ntype RecordChange = {\n modifiedAt: string;\n modifiedBy: string;\n};\n\nexport type VehicleChange = RecordChange & {\n vehicle: Vehicle;\n};\n\nexport type PurchaseChange = RecordChange & {\n purchase: VehiclePurchase;\n};\n\nexport type RecordChangeRequest = PaginatedRequest & {\n fieldPath?: string;\n};\n"]}
|
package/lib/utils/tenants.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export declare const getBranch: (tenant: Tenant, branchId: string) => Branch;
|
|
|
3
3
|
export declare const getDefaultBranch: (tenant: Tenant) => Branch;
|
|
4
4
|
export declare const isDropshippingBranch: (branch: Branch) => boolean;
|
|
5
5
|
export declare const getBranchStandardVatRate: (tenant: Tenant, branchId: string) => string;
|
|
6
|
+
export declare const areBranchesQuoteCompatible: (a: Branch, b: Branch) => boolean;
|
|
6
7
|
//# sourceMappingURL=tenants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenants.d.ts","sourceRoot":"/","sources":["utils/tenants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAErD,eAAO,MAAM,SAAS,WAAY,MAAM,YAAY,MAAM,KAAG,MAO5D,CAAC;AAEF,eAAO,MAAM,gBAAgB,WAAY,MAAM,KAAG,MAAiC,CAAC;AAIpF,eAAO,MAAM,oBAAoB,WAAY,MAAM,KAAG,OAAuC,CAAC;AAE9F,eAAO,MAAM,wBAAwB,WAAY,MAAM,YAAY,MAAM,KAAG,MAG3E,CAAC"}
|
|
1
|
+
{"version":3,"file":"tenants.d.ts","sourceRoot":"/","sources":["utils/tenants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAErD,eAAO,MAAM,SAAS,WAAY,MAAM,YAAY,MAAM,KAAG,MAO5D,CAAC;AAEF,eAAO,MAAM,gBAAgB,WAAY,MAAM,KAAG,MAAiC,CAAC;AAIpF,eAAO,MAAM,oBAAoB,WAAY,MAAM,KAAG,OAAuC,CAAC;AAE9F,eAAO,MAAM,wBAAwB,WAAY,MAAM,YAAY,MAAM,KAAG,MAG3E,CAAC;AAOF,eAAO,MAAM,0BAA0B,MAAO,MAAM,KAAK,MAAM,KAAG,OAIP,CAAC"}
|
package/lib/utils/tenants.js
CHANGED
|
@@ -13,4 +13,8 @@ export const getBranchStandardVatRate = (tenant, branchId) => {
|
|
|
13
13
|
const branch = getBranch(tenant, branchId);
|
|
14
14
|
return branch.vatRates.standard;
|
|
15
15
|
};
|
|
16
|
+
export const areBranchesQuoteCompatible = (a, b) => a.country === b.country &&
|
|
17
|
+
a.currency === b.currency &&
|
|
18
|
+
a.vatRates.standard === b.vatRates.standard &&
|
|
19
|
+
(a.externalQuote ?? false) === (b.externalQuote ?? false);
|
|
16
20
|
//# sourceMappingURL=tenants.js.map
|
package/lib/utils/tenants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenants.js","sourceRoot":"/","sources":["utils/tenants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGlC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAU,EAAE;IACpE,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;IAChF,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,MAAM,CAAC,0BAA0B,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAE,CAAC;AAIpF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,MAAM,CAAC,YAAY,KAAK,IAAI,CAAC;AAE9F,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAU,EAAE;IACnF,MAAM,MAAM,GAAW,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;AAClC,CAAC,CAAC","sourcesContent":["import { XError } from '@bisondesk/commons-sdk/errors';\nimport { first } from 'lodash-es';\nimport { Branch, Tenant } from '../types/tenants.js';\n\nexport const getBranch = (tenant: Tenant, branchId: string): Branch => {\n const branch = tenant.branches.find((branch: Branch) => branch.id === branchId);\n if (branch == null) {\n throw new XError('tenants.branch-not-found', { tenantId: tenant.id, branchId });\n }\n\n return branch;\n};\n\nexport const getDefaultBranch = (tenant: Tenant): Branch => first(tenant.branches)!;\n\n/** The source invoices the end customer directly; this branch collects payment and earns\n * commission (see {@link Branch.dropshipping}). */\nexport const isDropshippingBranch = (branch: Branch): boolean => branch.dropshipping === true;\n\nexport const getBranchStandardVatRate = (tenant: Tenant, branchId: string): string => {\n const branch: Branch = getBranch(tenant, branchId);\n return branch.vatRates.standard;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"tenants.js","sourceRoot":"/","sources":["utils/tenants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGlC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAU,EAAE;IACpE,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;IAChF,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,MAAM,CAAC,0BAA0B,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAE,CAAC;AAIpF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,MAAM,CAAC,YAAY,KAAK,IAAI,CAAC;AAE9F,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAU,EAAE;IACnF,MAAM,MAAM,GAAW,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;AAClC,CAAC,CAAC;AAOF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAS,EAAE,CAAS,EAAW,EAAE,CAC1E,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO;IACvB,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ;IACzB,CAAC,CAAC,QAAQ,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ;IAC3C,CAAC,CAAC,CAAC,aAAa,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,IAAI,KAAK,CAAC,CAAC","sourcesContent":["import { XError } from '@bisondesk/commons-sdk/errors';\nimport { first } from 'lodash-es';\nimport { Branch, Tenant } from '../types/tenants.js';\n\nexport const getBranch = (tenant: Tenant, branchId: string): Branch => {\n const branch = tenant.branches.find((branch: Branch) => branch.id === branchId);\n if (branch == null) {\n throw new XError('tenants.branch-not-found', { tenantId: tenant.id, branchId });\n }\n\n return branch;\n};\n\nexport const getDefaultBranch = (tenant: Tenant): Branch => first(tenant.branches)!;\n\n/** The source invoices the end customer directly; this branch collects payment and earns\n * commission (see {@link Branch.dropshipping}). */\nexport const isDropshippingBranch = (branch: Branch): boolean => branch.dropshipping === true;\n\nexport const getBranchStandardVatRate = (tenant: Tenant, branchId: string): string => {\n const branch: Branch = getBranch(tenant, branchId);\n return branch.vatRates.standard;\n};\n\n/**\n * Whether a quote computed for one branch is still right for the other. A quote's VAT regime,\n * currency, calculator strategy and conditions all come from these four fields, so when they\n * agree the quote can move with its deal; otherwise the deal needs a new one.\n */\nexport const areBranchesQuoteCompatible = (a: Branch, b: Branch): boolean =>\n a.country === b.country &&\n a.currency === b.currency &&\n a.vatRates.standard === b.vatRates.standard &&\n (a.externalQuote ?? false) === (b.externalQuote ?? false);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenants.test.d.ts","sourceRoot":"/","sources":["utils/tenants.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { areBranchesQuoteCompatible } from './tenants.js';
|
|
2
|
+
const createBranch = (override) => ({
|
|
3
|
+
id: 'TTC',
|
|
4
|
+
name: 'TTC Belgium',
|
|
5
|
+
country: 'be',
|
|
6
|
+
language: 'nl',
|
|
7
|
+
currency: 'EUR',
|
|
8
|
+
adminNumberPrefix: 'AT',
|
|
9
|
+
stockNumberPrefix: 'TC',
|
|
10
|
+
vatNumber: 'BE0123456789',
|
|
11
|
+
vatRates: { standard: '21' },
|
|
12
|
+
location: { country: 'be' },
|
|
13
|
+
...override,
|
|
14
|
+
});
|
|
15
|
+
describe('areBranchesQuoteCompatible', () => {
|
|
16
|
+
it('accepts two branches that agree on country, currency, vat rate and quote mode', () => {
|
|
17
|
+
const a = createBranch();
|
|
18
|
+
const b = createBranch({ id: 'TTC2', name: 'TTC Antwerp', stockNumberPrefix: 'TA' });
|
|
19
|
+
expect(areBranchesQuoteCompatible(a, b)).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
it('is true for a branch compared with itself', () => {
|
|
22
|
+
const branch = createBranch();
|
|
23
|
+
expect(areBranchesQuoteCompatible(branch, branch)).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
it.each([
|
|
26
|
+
['country', { country: 'fr' }],
|
|
27
|
+
['currency', { currency: 'USD' }],
|
|
28
|
+
['vat rate', { vatRates: { standard: '20' } }],
|
|
29
|
+
['external quote mode', { externalQuote: true }],
|
|
30
|
+
])('rejects branches that differ in %s', (_label, override) => {
|
|
31
|
+
expect(areBranchesQuoteCompatible(createBranch(), createBranch(override))).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
it('treats a missing externalQuote as false rather than as a difference', () => {
|
|
34
|
+
const implicit = createBranch();
|
|
35
|
+
const explicit = createBranch({ externalQuote: false });
|
|
36
|
+
expect(areBranchesQuoteCompatible(implicit, explicit)).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=tenants.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenants.test.js","sourceRoot":"/","sources":["utils/tenants.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,YAAY,GAAG,CAAC,QAA0B,EAAU,EAAE,CAAC,CAAC;IAC5D,EAAE,EAAE,KAAK;IACT,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAK;IACf,iBAAiB,EAAE,IAAI;IACvB,iBAAiB,EAAE,IAAI;IACvB,SAAS,EAAE,cAAc;IACzB,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC5B,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;IAC3B,GAAG,QAAQ;CACZ,CAAC,CAAC;AAEH,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,+EAA+E,EAAE,GAAG,EAAE;QACvF,MAAM,CAAC,GAAG,YAAY,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,YAAY,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QAErF,MAAM,CAAC,0BAA0B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,IAAI,CAAC;QACN,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC9B,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACjC,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;QAC9C,CAAC,qBAAqB,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;KACjD,CAAC,CAAC,oCAAoC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;QAC5D,MAAM,CAAC,0BAA0B,CAAC,YAAY,EAAE,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qEAAqE,EAAE,GAAG,EAAE;QAC7E,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,YAAY,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;QAExD,MAAM,CAAC,0BAA0B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { Branch } from '../types/tenants.js';\nimport { areBranchesQuoteCompatible } from './tenants.js';\n\nconst createBranch = (override?: Partial<Branch>): Branch => ({\n id: 'TTC',\n name: 'TTC Belgium',\n country: 'be',\n language: 'nl',\n currency: 'EUR',\n adminNumberPrefix: 'AT',\n stockNumberPrefix: 'TC',\n vatNumber: 'BE0123456789',\n vatRates: { standard: '21' },\n location: { country: 'be' },\n ...override,\n});\n\ndescribe('areBranchesQuoteCompatible', () => {\n it('accepts two branches that agree on country, currency, vat rate and quote mode', () => {\n const a = createBranch();\n const b = createBranch({ id: 'TTC2', name: 'TTC Antwerp', stockNumberPrefix: 'TA' });\n\n expect(areBranchesQuoteCompatible(a, b)).toBe(true);\n });\n\n it('is true for a branch compared with itself', () => {\n const branch = createBranch();\n\n expect(areBranchesQuoteCompatible(branch, branch)).toBe(true);\n });\n\n it.each([\n ['country', { country: 'fr' }],\n ['currency', { currency: 'USD' }],\n ['vat rate', { vatRates: { standard: '20' } }],\n ['external quote mode', { externalQuote: true }],\n ])('rejects branches that differ in %s', (_label, override) => {\n expect(areBranchesQuoteCompatible(createBranch(), createBranch(override))).toBe(false);\n });\n\n it('treats a missing externalQuote as false rather than as a difference', () => {\n const implicit = createBranch();\n const explicit = createBranch({ externalQuote: false });\n\n expect(areBranchesQuoteCompatible(implicit, explicit)).toBe(true);\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { Contact, Organization } from './crm.js';
|
|
|
5
5
|
import type { Interest, InterestBffMeta } from './interests.js';
|
|
6
6
|
import { BaseEvent } from './internal-events.js';
|
|
7
7
|
import { OpportunityPayment } from './opportunity-payments.js';
|
|
8
|
-
import { Quote, QuoteStatus } from './quotes.js';
|
|
8
|
+
import { Quote, QuoteRecordMeta, QuoteStatus } from './quotes.js';
|
|
9
9
|
import { OpportunityReservation } from './reservations.js';
|
|
10
10
|
import { BaseSearchRequest } from './search.js';
|
|
11
11
|
import { Transport } from './transports.js';
|
|
@@ -325,8 +325,9 @@ export type OpportunityBFF = {
|
|
|
325
325
|
vehicle?: DataRecord<Vehicle, VehicleBffMetadata>;
|
|
326
326
|
interest?: DataRecord<Interest, InterestBffMeta>;
|
|
327
327
|
bids: DataRecord<Bid>[];
|
|
328
|
-
|
|
329
|
-
|
|
328
|
+
/** Every quote the deal has ever had; the ones it has left carry `meta.archived`. */
|
|
329
|
+
quotes: DataRecord<Quote, QuoteRecordMeta>[];
|
|
330
|
+
activeQuote?: DataRecord<Quote, QuoteRecordMeta>;
|
|
330
331
|
payments: OpportunityPaymentSummary | undefined;
|
|
331
332
|
reservation?: DataRecord<OpportunityReservation>;
|
|
332
333
|
tasks: DataRecord<Task>[];
|
package/src/types/quotes.ts
CHANGED
|
@@ -310,6 +310,29 @@ export type NewQuote = BaseQuote & {
|
|
|
310
310
|
active: true;
|
|
311
311
|
};
|
|
312
312
|
|
|
313
|
+
/**
|
|
314
|
+
* A field of the linkage a quote is written against — opportunity, vehicle, contact, type and
|
|
315
|
+
* branch. When one of them is edited on the deal, the deal moves to a new linkage and its
|
|
316
|
+
* earlier quotes stay behind on the old one rather than following.
|
|
317
|
+
*/
|
|
318
|
+
export enum QuoteLinkageField {
|
|
319
|
+
Vehicle = 'vehicle',
|
|
320
|
+
Contact = 'contact',
|
|
321
|
+
Type = 'type',
|
|
322
|
+
Branch = 'branch',
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export type QuoteRecordMeta = {
|
|
326
|
+
/**
|
|
327
|
+
* The quote was computed for a linkage the deal has since left. Kept visible as history: its
|
|
328
|
+
* figures were right for the vehicle, customer and branch of the day, and are not right now,
|
|
329
|
+
* so the only thing left to do with it is read the PDF that was sent.
|
|
330
|
+
*/
|
|
331
|
+
archived?: boolean;
|
|
332
|
+
/** Why: the linkage fields edited on the deal since this quote was written. */
|
|
333
|
+
archivedReason?: QuoteLinkageField[];
|
|
334
|
+
};
|
|
335
|
+
|
|
313
336
|
export type Quote = BaseQuote & {
|
|
314
337
|
id: string;
|
|
315
338
|
createdAt: string;
|
package/src/types/vehicles.ts
CHANGED
|
@@ -338,6 +338,15 @@ export type RelatedVehicle = {
|
|
|
338
338
|
stockNumber: string;
|
|
339
339
|
};
|
|
340
340
|
|
|
341
|
+
export type VehicleBranchHistoryEntry = {
|
|
342
|
+
branch: string;
|
|
343
|
+
stockNumber: string;
|
|
344
|
+
administrativeNumber?: string;
|
|
345
|
+
changedAt: string;
|
|
346
|
+
changedBy: string;
|
|
347
|
+
reason?: string;
|
|
348
|
+
};
|
|
349
|
+
|
|
341
350
|
export type VehicleInternalInfo = {
|
|
342
351
|
createdAt: string;
|
|
343
352
|
description: {
|
|
@@ -355,6 +364,11 @@ export type VehicleInternalInfo = {
|
|
|
355
364
|
licensePlate: string;
|
|
356
365
|
changedAt: string;
|
|
357
366
|
}[];
|
|
367
|
+
/**
|
|
368
|
+
* One entry per branch the vehicle has left, oldest first. Records the identity it carried
|
|
369
|
+
* there (stock and administrative numbers are redrawn on a move) and who moved it.
|
|
370
|
+
*/
|
|
371
|
+
branchHistory?: VehicleBranchHistoryEntry[];
|
|
358
372
|
|
|
359
373
|
/**
|
|
360
374
|
* This ID is used to link different vehicle objects that represent the same real world asset.
|
|
@@ -890,8 +904,99 @@ export enum VehicleActions {
|
|
|
890
904
|
ViewPurchase = 'view_purchase',
|
|
891
905
|
ViewPriceHistory = 'view_price_history',
|
|
892
906
|
DeleteVehicle = 'delete_vehicle',
|
|
907
|
+
ChangeBranch = 'change_branch',
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
export type VehicleBranchChangeRequest = {
|
|
911
|
+
branch: string;
|
|
912
|
+
reason?: string;
|
|
913
|
+
/** Required when the preview carries a warning that needs acknowledgement. */
|
|
914
|
+
acknowledged?: boolean;
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
export enum VehicleBranchChangeBlockerCode {
|
|
918
|
+
SameBranch = 'same_branch',
|
|
919
|
+
VehicleDeleted = 'vehicle_deleted',
|
|
920
|
+
CurrencyMismatch = 'currency_mismatch',
|
|
921
|
+
FinanceDocumentsExist = 'finance_documents_exist',
|
|
922
|
+
PurchasePaymentsExist = 'purchase_payments_exist',
|
|
923
|
+
DealCommitted = 'deal_committed',
|
|
924
|
+
VehicleSold = 'vehicle_sold',
|
|
925
|
+
LeasingContractExists = 'leasing_contract_exists',
|
|
926
|
+
RelatedVehicles = 'related_vehicles',
|
|
927
|
+
InternalDealQuote = 'internal_deal_quote',
|
|
928
|
+
IntercompanyLinkLive = 'intercompany_link_live',
|
|
929
|
+
HyperdmsOrganisationChange = 'hyperdms_organisation_change',
|
|
930
|
+
StockNumberTaken = 'stock_number_taken',
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
export enum VehicleBranchChangeWarningCode {
|
|
934
|
+
DealsLoseQuotes = 'deals_lose_quotes',
|
|
935
|
+
DealPaymentsExist = 'deal_payments_exist',
|
|
936
|
+
OpenTransports = 'open_transports',
|
|
937
|
+
CopiesWithdrawn = 'copies_withdrawn',
|
|
938
|
+
CopiesCreated = 'copies_created',
|
|
939
|
+
TargetWithoutAccounting = 'target_without_accounting',
|
|
940
|
+
TargetWithoutStorecove = 'target_without_storecove',
|
|
893
941
|
}
|
|
894
942
|
|
|
943
|
+
export type VehicleBranchChangeBlocker = {
|
|
944
|
+
code: VehicleBranchChangeBlockerCode;
|
|
945
|
+
data?: Record<string, unknown>;
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
export type VehicleBranchChangeWarning = {
|
|
949
|
+
code: VehicleBranchChangeWarningCode;
|
|
950
|
+
/** The write refuses unless the request says `acknowledged: true`. */
|
|
951
|
+
requiresAcknowledgement: boolean;
|
|
952
|
+
data?: Record<string, unknown>;
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
export enum VehicleBranchChangeDealOutcome {
|
|
956
|
+
/** Branches are quote-compatible: the deal and its quotes move together. */
|
|
957
|
+
FollowsWithQuotes = 'follows_with_quotes',
|
|
958
|
+
/** The deal moves; its quotes stay archived on the old branch and it needs a new one. */
|
|
959
|
+
FollowsNeedsRequote = 'follows_needs_requote',
|
|
960
|
+
AlreadyOnTarget = 'already_on_target',
|
|
961
|
+
StaysClosed = 'stays_closed',
|
|
962
|
+
/** In Preparation or later: contracts and paperwork exist, so this deal blocks the move. */
|
|
963
|
+
Committed = 'committed',
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
export type VehicleBranchChangeDealImpact = {
|
|
967
|
+
opportunityId: string;
|
|
968
|
+
status: string;
|
|
969
|
+
branch: string;
|
|
970
|
+
outcome: VehicleBranchChangeDealOutcome;
|
|
971
|
+
hasActiveQuote: boolean;
|
|
972
|
+
paymentsCount: number;
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
export type VehicleBranchChangeIdentity = {
|
|
976
|
+
branch: string;
|
|
977
|
+
stockNumber: string;
|
|
978
|
+
administrativeNumber?: string;
|
|
979
|
+
};
|
|
980
|
+
|
|
981
|
+
export type VehicleBranchChangePreview = {
|
|
982
|
+
from: VehicleBranchChangeIdentity;
|
|
983
|
+
/** The administrative number is only known once drawn, so the preview leaves it out. */
|
|
984
|
+
to: Omit<VehicleBranchChangeIdentity, 'administrativeNumber'>;
|
|
985
|
+
blockers: VehicleBranchChangeBlocker[];
|
|
986
|
+
warnings: VehicleBranchChangeWarning[];
|
|
987
|
+
/** Counts of the records that follow are not reported: the warnings above already name them. */
|
|
988
|
+
impact: { deals: VehicleBranchChangeDealImpact[] };
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
export type VehicleBranchChangeResult = {
|
|
992
|
+
vehicle: Vehicle;
|
|
993
|
+
from: VehicleBranchChangeIdentity;
|
|
994
|
+
to: VehicleBranchChangeIdentity;
|
|
995
|
+
deals: VehicleBranchChangeDealImpact[];
|
|
996
|
+
/** Repair steps that failed after the vehicle moved; running the move again retries them. */
|
|
997
|
+
failedSteps: string[];
|
|
998
|
+
};
|
|
999
|
+
|
|
895
1000
|
export enum PurchaseActions {
|
|
896
1001
|
ViewDeal = 'view_deal',
|
|
897
1002
|
ViewSupplierOrganization = 'view_supplier_organization',
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Branch } from '../types/tenants.js';
|
|
2
|
+
import { areBranchesQuoteCompatible } from './tenants.js';
|
|
3
|
+
|
|
4
|
+
const createBranch = (override?: Partial<Branch>): Branch => ({
|
|
5
|
+
id: 'TTC',
|
|
6
|
+
name: 'TTC Belgium',
|
|
7
|
+
country: 'be',
|
|
8
|
+
language: 'nl',
|
|
9
|
+
currency: 'EUR',
|
|
10
|
+
adminNumberPrefix: 'AT',
|
|
11
|
+
stockNumberPrefix: 'TC',
|
|
12
|
+
vatNumber: 'BE0123456789',
|
|
13
|
+
vatRates: { standard: '21' },
|
|
14
|
+
location: { country: 'be' },
|
|
15
|
+
...override,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('areBranchesQuoteCompatible', () => {
|
|
19
|
+
it('accepts two branches that agree on country, currency, vat rate and quote mode', () => {
|
|
20
|
+
const a = createBranch();
|
|
21
|
+
const b = createBranch({ id: 'TTC2', name: 'TTC Antwerp', stockNumberPrefix: 'TA' });
|
|
22
|
+
|
|
23
|
+
expect(areBranchesQuoteCompatible(a, b)).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('is true for a branch compared with itself', () => {
|
|
27
|
+
const branch = createBranch();
|
|
28
|
+
|
|
29
|
+
expect(areBranchesQuoteCompatible(branch, branch)).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it.each([
|
|
33
|
+
['country', { country: 'fr' }],
|
|
34
|
+
['currency', { currency: 'USD' }],
|
|
35
|
+
['vat rate', { vatRates: { standard: '20' } }],
|
|
36
|
+
['external quote mode', { externalQuote: true }],
|
|
37
|
+
])('rejects branches that differ in %s', (_label, override) => {
|
|
38
|
+
expect(areBranchesQuoteCompatible(createBranch(), createBranch(override))).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('treats a missing externalQuote as false rather than as a difference', () => {
|
|
42
|
+
const implicit = createBranch();
|
|
43
|
+
const explicit = createBranch({ externalQuote: false });
|
|
44
|
+
|
|
45
|
+
expect(areBranchesQuoteCompatible(implicit, explicit)).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
});
|
package/src/utils/tenants.ts
CHANGED
|
@@ -21,3 +21,14 @@ export const getBranchStandardVatRate = (tenant: Tenant, branchId: string): stri
|
|
|
21
21
|
const branch: Branch = getBranch(tenant, branchId);
|
|
22
22
|
return branch.vatRates.standard;
|
|
23
23
|
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Whether a quote computed for one branch is still right for the other. A quote's VAT regime,
|
|
27
|
+
* currency, calculator strategy and conditions all come from these four fields, so when they
|
|
28
|
+
* agree the quote can move with its deal; otherwise the deal needs a new one.
|
|
29
|
+
*/
|
|
30
|
+
export const areBranchesQuoteCompatible = (a: Branch, b: Branch): boolean =>
|
|
31
|
+
a.country === b.country &&
|
|
32
|
+
a.currency === b.currency &&
|
|
33
|
+
a.vatRates.standard === b.vatRates.standard &&
|
|
34
|
+
(a.externalQuote ?? false) === (b.externalQuote ?? false);
|