@bisondesk/core-sdk 1.0.677 → 1.0.678
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/apis/exchange-rates.d.ts +0 -3
- package/lib/apis/exchange-rates.d.ts.map +1 -1
- package/lib/apis/exchange-rates.js +0 -29
- package/lib/apis/exchange-rates.js.map +1 -1
- package/lib/apis/organization-bank-accounts.d.ts +11 -0
- package/lib/apis/organization-bank-accounts.d.ts.map +1 -0
- package/lib/apis/organization-bank-accounts.js +47 -0
- package/lib/apis/organization-bank-accounts.js.map +1 -0
- package/lib/types/intercompany-payments.d.ts.map +1 -1
- package/lib/types/intercompany-payments.js.map +1 -1
- package/lib/types/offers.d.ts +1 -2
- package/lib/types/offers.d.ts.map +1 -1
- package/lib/types/offers.js.map +1 -1
- package/lib/types/opportunities.d.ts +0 -8
- package/lib/types/opportunities.d.ts.map +1 -1
- package/lib/types/opportunities.js.map +1 -1
- package/lib/types/opportunity-payments.d.ts +0 -9
- package/lib/types/opportunity-payments.d.ts.map +1 -1
- package/lib/types/opportunity-payments.js.map +1 -1
- package/lib/types/organization-bank-accounts.d.ts +35 -0
- package/lib/types/organization-bank-accounts.d.ts.map +1 -0
- package/lib/types/organization-bank-accounts.js +9 -0
- package/lib/types/organization-bank-accounts.js.map +1 -0
- package/lib/types/payment-exports.d.ts +23 -0
- package/lib/types/payment-exports.d.ts.map +1 -0
- package/lib/types/payment-exports.js +2 -0
- package/lib/types/payment-exports.js.map +1 -0
- package/lib/types/tenants.d.ts +1 -1
- package/lib/types/tenants.d.ts.map +1 -1
- package/lib/types/tenants.js +1 -0
- package/lib/types/tenants.js.map +1 -1
- package/lib/types/vehicle-purchase-payments.d.ts +52 -8
- package/lib/types/vehicle-purchase-payments.d.ts.map +1 -1
- package/lib/types/vehicle-purchase-payments.js +6 -0
- package/lib/types/vehicle-purchase-payments.js.map +1 -1
- package/lib/types/vehicles.d.ts +1 -7
- package/lib/types/vehicles.d.ts.map +1 -1
- package/lib/types/vehicles.js.map +1 -1
- package/lib/utils/organization-bank-accounts.d.ts +3 -0
- package/lib/utils/organization-bank-accounts.d.ts.map +1 -0
- package/lib/utils/organization-bank-accounts.js +9 -0
- package/lib/utils/organization-bank-accounts.js.map +1 -0
- package/lib/utils/tenants.d.ts +0 -3
- package/lib/utils/tenants.d.ts.map +1 -1
- package/lib/utils/tenants.js +0 -3
- package/lib/utils/tenants.js.map +1 -1
- package/lib/utils/tenants.test.js +1 -27
- package/lib/utils/tenants.test.js.map +1 -1
- package/package.json +1 -1
- package/src/apis/exchange-rates.ts +0 -49
- package/src/apis/organization-bank-accounts.ts +123 -0
- package/src/types/intercompany-payments.ts +3 -4
- package/src/types/offers.ts +0 -2
- package/src/types/opportunities.ts +0 -15
- package/src/types/opportunity-payments.ts +0 -23
- package/src/types/organization-bank-accounts.ts +56 -0
- package/src/types/payment-exports.ts +40 -0
- package/src/types/tenants.ts +7 -6
- package/src/types/vehicle-purchase-payments.ts +114 -13
- package/src/types/vehicles.ts +4 -15
- package/src/utils/organization-bank-accounts.ts +19 -0
- package/src/utils/tenants.test.ts +1 -39
- package/src/utils/tenants.ts +0 -17
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/opportunity-payments.d.ts +0 -3
- package/lib/utils/opportunity-payments.d.ts.map +0 -1
- package/lib/utils/opportunity-payments.js +0 -5
- package/lib/utils/opportunity-payments.js.map +0 -1
- package/lib/utils/opportunity-payments.test.d.ts +0 -2
- package/lib/utils/opportunity-payments.test.d.ts.map +0 -1
- package/lib/utils/opportunity-payments.test.js +0 -23
- package/lib/utils/opportunity-payments.test.js.map +0 -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/src/utils/opportunity-payments.test.ts +0 -31
- package/src/utils/opportunity-payments.ts +0 -15
|
@@ -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,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;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 foreign?: VehiclePurchaseDealForeign;\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 /** An own-use vehicle administration can assign to our own transports; read with role OWN_USE. */\n transportFleet?: boolean;\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\n/**\n * The price the supplier asked, in the supplier's currency: one of the payment currencies of the\n * vehicle's branch. The purchase's `deal.purchase` is then `purchase × exchangeRate`, and payments\n * are authorized in `currencyCode`.\n */\nexport type VehiclePurchaseDealForeign = {\n purchase: string; // exclusive VAT\n currencyCode: string;\n /** Branch currency units per 1 unit of `currencyCode`. */\n exchangeRate: string;\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; derived from `foreign` when present\n foreign?: VehiclePurchaseDealForeign;\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"]}
|
|
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,CAA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;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 /** An own-use vehicle administration can assign to our own transports; read with role OWN_USE. */\n transportFleet?: boolean;\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 /** Due date of the supplier purchase invoice; editable from the payments page. */\n invoiceDueDate?: string;\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-bank-accounts.d.ts","sourceRoot":"/","sources":["utils/organization-bank-accounts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AASjF,eAAO,MAAM,iCAAiC,YACnC,uBAAuB,GAAG,SAAS,KAC3C,OAMF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { normalizeIban } from '@bisondesk/commons-sdk/iban';
|
|
2
|
+
export const isOrganizationBankAccountVerified = (account) => {
|
|
3
|
+
const verifiedAccountNumber = account?.verification?.accountNumber;
|
|
4
|
+
if (account == null || verifiedAccountNumber == null) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
return normalizeIban(verifiedAccountNumber) === normalizeIban(account.accountNumber);
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=organization-bank-accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-bank-accounts.js","sourceRoot":"/","sources":["utils/organization-bank-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAU5D,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC/C,OAA4C,EACnC,EAAE;IACX,MAAM,qBAAqB,GAAG,OAAO,EAAE,YAAY,EAAE,aAAa,CAAC;IACnE,IAAI,OAAO,IAAI,IAAI,IAAI,qBAAqB,IAAI,IAAI,EAAE,CAAC;QACrD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,aAAa,CAAC,qBAAqB,CAAC,KAAK,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACvF,CAAC,CAAC","sourcesContent":["import { normalizeIban } from '@bisondesk/commons-sdk/iban';\nimport { OrganizationBankAccount } from '../types/organization-bank-accounts.js';\n\n/**\n * Whether an organisation's bank account can be paid: it carries a verification, and that\n * verification was given for the account number the account holds now. A verification recorded\n * without an account number, or for a different one, does not count.\n *\n * Shared so the export gate and the Processing rows read one rule.\n */\nexport const isOrganizationBankAccountVerified = (\n account: OrganizationBankAccount | undefined,\n): boolean => {\n const verifiedAccountNumber = account?.verification?.accountNumber;\n if (account == null || verifiedAccountNumber == null) {\n return false;\n }\n return normalizeIban(verifiedAccountNumber) === normalizeIban(account.accountNumber);\n};\n"]}
|
package/lib/utils/tenants.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ import { Branch, Tenant } from '../types/tenants.js';
|
|
|
2
2
|
export declare const getBranch: (tenant: Tenant, branchId: string) => Branch;
|
|
3
3
|
export declare const getDefaultBranch: (tenant: Tenant) => Branch;
|
|
4
4
|
export declare const getBranchAskingVies: (tenant: Tenant, branchId?: string) => Branch | undefined;
|
|
5
|
-
export declare const getBranchPaymentCurrencies: (branch: Branch) => string[];
|
|
6
|
-
export declare const isForeignPaymentCurrency: (branch: Branch, currencyCode: string) => boolean;
|
|
7
|
-
export declare const hasForeignPaymentCurrency: (branch: Branch) => boolean;
|
|
8
5
|
export declare const isDropshippingBranch: (branch: Branch) => boolean;
|
|
9
6
|
export declare const getBranchStandardVatRate: (tenant: Tenant, branchId: string) => string;
|
|
10
7
|
export declare const areBranchesQuoteCompatible: (a: Branch, b: Branch) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenants.d.ts","sourceRoot":"/","sources":["utils/tenants.ts"],"names":[],"mappings":"AAGA,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;AAOpF,eAAO,MAAM,mBAAmB,WAAY,MAAM,aAAa,MAAM,KAAG,MAAM,GAAG,SAGhF,CAAC;
|
|
1
|
+
{"version":3,"file":"tenants.d.ts","sourceRoot":"/","sources":["utils/tenants.ts"],"names":[],"mappings":"AAGA,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;AAOpF,eAAO,MAAM,mBAAmB,WAAY,MAAM,aAAa,MAAM,KAAG,MAAM,GAAG,SAGhF,CAAC;AAIF,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,9 +13,6 @@ export const getBranchAskingVies = (tenant, branchId) => {
|
|
|
13
13
|
const europeanBranches = tenant.branches.filter((branch) => isEUCountry(branch.country));
|
|
14
14
|
return europeanBranches.find((branch) => branch.id === branchId) ?? europeanBranches.at(0);
|
|
15
15
|
};
|
|
16
|
-
export const getBranchPaymentCurrencies = (branch) => branch.paymentCurrencies ?? [branch.currency];
|
|
17
|
-
export const isForeignPaymentCurrency = (branch, currencyCode) => currencyCode !== branch.currency && getBranchPaymentCurrencies(branch).includes(currencyCode);
|
|
18
|
-
export const hasForeignPaymentCurrency = (branch) => getBranchPaymentCurrencies(branch).some((currencyCode) => isForeignPaymentCurrency(branch, currencyCode));
|
|
19
16
|
export const isDropshippingBranch = (branch) => branch.dropshipping === true;
|
|
20
17
|
export const getBranchStandardVatRate = (tenant, branchId) => {
|
|
21
18
|
const branch = getBranch(tenant, branchId);
|
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,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGlC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAU,EA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AC,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 { isEUCountry } from '@bisondesk/commons-sdk/locations';\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/**\n * The branch whose VAT number VIES records as the requester of a VAT check, which earns a\n * consultation number: the branch the check is made for when it is European, else the tenant's\n * first European branch. A tenant without a European branch asks VIES anonymously.\n */\nexport const getBranchAskingVies = (tenant: Tenant, branchId?: string): Branch | undefined => {\n const europeanBranches = tenant.branches.filter((branch) => isEUCountry(branch.country));\n return europeanBranches.find((branch) => branch.id === branchId) ?? europeanBranches.at(0);\n};\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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { areBranchesQuoteCompatible, getBranchAskingVies
|
|
1
|
+
import { areBranchesQuoteCompatible, getBranchAskingVies } from './tenants.js';
|
|
2
2
|
const createBranch = (override) => ({
|
|
3
3
|
id: 'TTC',
|
|
4
4
|
name: 'TTC Belgium',
|
|
@@ -53,30 +53,4 @@ describe('getBranchAskingVies', () => {
|
|
|
53
53
|
expect(getBranchAskingVies(tenantOf([bolivia]), 'BO')).toBeUndefined();
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
|
-
describe('payment currencies of a branch', () => {
|
|
57
|
-
const southAmerica = createBranch({
|
|
58
|
-
id: 'HPA South America',
|
|
59
|
-
paymentCurrencies: ['EUR', 'USD'],
|
|
60
|
-
});
|
|
61
|
-
test('a branch without a list is paid in its own currency only', () => {
|
|
62
|
-
expect(getBranchPaymentCurrencies(createBranch())).toEqual(['EUR']);
|
|
63
|
-
});
|
|
64
|
-
test('a branch with a list is paid in the currencies it lists', () => {
|
|
65
|
-
expect(getBranchPaymentCurrencies(southAmerica)).toEqual(['EUR', 'USD']);
|
|
66
|
-
});
|
|
67
|
-
test.each([
|
|
68
|
-
['a listed currency other than its own', 'USD', true],
|
|
69
|
-
['its own currency', 'EUR', false],
|
|
70
|
-
['a currency it does not list', 'BOB', false],
|
|
71
|
-
])('%s is a foreign payment currency: %s', (_label, currencyCode, expected) => {
|
|
72
|
-
expect(isForeignPaymentCurrency(southAmerica, currencyCode)).toBe(expected);
|
|
73
|
-
});
|
|
74
|
-
test('a branch without a list has no foreign payment currency', () => {
|
|
75
|
-
expect(isForeignPaymentCurrency(createBranch(), 'USD')).toBe(false);
|
|
76
|
-
expect(hasForeignPaymentCurrency(createBranch())).toBe(false);
|
|
77
|
-
});
|
|
78
|
-
test('a branch listing another currency has a foreign payment currency', () => {
|
|
79
|
-
expect(hasForeignPaymentCurrency(southAmerica)).toBe(true);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
56
|
//# sourceMappingURL=tenants.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenants.test.js","sourceRoot":"/","sources":["utils/tenants.test.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"tenants.test.js","sourceRoot":"/","sources":["utils/tenants.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE/E,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,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EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;IACrF,MAAM,QAAQ,GAAG,CAAC,QAAkB,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAW,CAAC;IAElE,IAAI,CAAC,IAAI,CAAC;QACR,CAAC,2CAA2C,EAAE,IAAI,EAAE,IAAI,CAAC;QACzD,CAAC,mDAAmD,EAAE,SAAS,EAAE,IAAI,CAAC;QACtE,CAAC,mEAAmE,EAAE,IAAI,EAAE,IAAI,CAAC;QACjF,CAAC,4DAA4D,EAAE,MAAM,EAAE,IAAI,CAAC;KAC7E,CAAC,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;QAC5C,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjG,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACnE,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { Branch, Tenant } from '../types/tenants.js';\nimport { areBranchesQuoteCompatible, getBranchAskingVies } 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\ndescribe('getBranchAskingVies', () => {\n const bolivia = createBranch({ id: 'BO', country: 'bo', vatNumber: '387032026' });\n const belgium = createBranch({ id: 'BE', country: 'be', vatNumber: 'BE0405567886' });\n const france = createBranch({ id: 'FR', country: 'fr', vatNumber: 'FR10821739638' });\n const tenantOf = (branches: Branch[]) => ({ branches }) as Tenant;\n\n test.each([\n ['the European branch the check is made for', 'FR', 'FR'],\n ['the first European branch when no branch is given', undefined, 'BE'],\n ['the first European branch when the given branch is outside the EU', 'BO', 'BE'],\n ['the first European branch when the given branch is unknown', 'GONE', 'BE'],\n ])('picks %s', (_label, branchId, expected) => {\n expect(getBranchAskingVies(tenantOf([bolivia, belgium, france]), branchId)?.id).toBe(expected);\n });\n\n test('asks anonymously for a tenant without a European branch', () => {\n expect(getBranchAskingVies(tenantOf([bolivia]), 'BO')).toBeUndefined();\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { XError } from '@bisondesk/commons-sdk/errors';
|
|
2
2
|
import { getAdminAuth } from '@bisondesk/commons-sdk/fetch';
|
|
3
|
-
import {
|
|
4
|
-
CurrencyConversionRequest,
|
|
5
|
-
CurrencyConversionResponse,
|
|
6
|
-
} from '@bisondesk/commons-sdk/types';
|
|
7
3
|
import fetch, { Response } from 'node-fetch';
|
|
8
4
|
import { ExchangeRate } from '../types/exchange-rates.js';
|
|
9
5
|
|
|
@@ -50,51 +46,6 @@ export const getExchangeRate = async (
|
|
|
50
46
|
throw new XError(response.statusText, { url, body, fromCurrency, toCurrency });
|
|
51
47
|
};
|
|
52
48
|
|
|
53
|
-
/** The daily rates of the rate provider, as the quote and invoice forms get them. */
|
|
54
|
-
export const getCurrencyConversionRates = async (
|
|
55
|
-
request: CurrencyConversionRequest,
|
|
56
|
-
): Promise<CurrencyConversionResponse> => {
|
|
57
|
-
const auth = await getAdminAuth();
|
|
58
|
-
const url = `${process.env.CORE_API_ORIGIN}/api/currency/rates`;
|
|
59
|
-
const response: Response = await fetch(url, {
|
|
60
|
-
method: 'POST',
|
|
61
|
-
headers: {
|
|
62
|
-
Authorization: auth,
|
|
63
|
-
'Content-Type': 'application/json',
|
|
64
|
-
},
|
|
65
|
-
body: JSON.stringify(request),
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
if (response.ok) {
|
|
69
|
-
return response.json() as any;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const body = await response.text();
|
|
73
|
-
throw new XError(response.statusText, { url, body, request });
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The plain daily rate of `date`: how many units of `toCurrency` equal 1 unit of `fromCurrency`,
|
|
78
|
-
* without the bank-fee markup. Undefined when the provider has no rate for the pair.
|
|
79
|
-
*/
|
|
80
|
-
export const getDailyConversionRate = async (
|
|
81
|
-
fromCurrency: string,
|
|
82
|
-
toCurrency: string,
|
|
83
|
-
date?: string,
|
|
84
|
-
): Promise<string | undefined> => {
|
|
85
|
-
if (fromCurrency === toCurrency) {
|
|
86
|
-
return '1';
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const { rates } = await getCurrencyConversionRates({
|
|
90
|
-
sourceCurrency: fromCurrency,
|
|
91
|
-
targetCurrency: toCurrency,
|
|
92
|
-
date,
|
|
93
|
-
bankFeeMarkup: false,
|
|
94
|
-
});
|
|
95
|
-
return rates[toCurrency];
|
|
96
|
-
};
|
|
97
|
-
|
|
98
49
|
/**
|
|
99
50
|
* Direction-agnostic conversion multiplier: how many units of `toCurrency`
|
|
100
51
|
* equal 1 unit of `fromCurrency`. Tries a direct pair first, then falls back
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { SERVICE_ID_ADMIN_HEADER, TENANT_ID_ADMIN_HEADER } from '@bisondesk/commons-sdk/constants';
|
|
2
|
+
import { XError } from '@bisondesk/commons-sdk/errors';
|
|
3
|
+
import { cleanHeaders, getAdminAuth } from '@bisondesk/commons-sdk/fetch';
|
|
4
|
+
import { DataRecord } from '@bisondesk/commons-sdk/utils';
|
|
5
|
+
import fetch, { Response } from 'node-fetch';
|
|
6
|
+
import {
|
|
7
|
+
NewOrganizationBankAccount,
|
|
8
|
+
OrganizationBankAccount,
|
|
9
|
+
OrganizationBankAccountMeta,
|
|
10
|
+
} from '../types/organization-bank-accounts.js';
|
|
11
|
+
|
|
12
|
+
type ServiceOptions = { serviceId?: string };
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Calls an organisation bank-account route as a service. The service id becomes the user core
|
|
16
|
+
* records as having made the change.
|
|
17
|
+
*/
|
|
18
|
+
const callBankAccountsRoute = async (
|
|
19
|
+
tenantId: string,
|
|
20
|
+
path: string,
|
|
21
|
+
init: { method: string; body?: unknown },
|
|
22
|
+
opts?: ServiceOptions,
|
|
23
|
+
): Promise<Response> => {
|
|
24
|
+
const auth = await getAdminAuth();
|
|
25
|
+
const url = `${process.env.CORE_API_ORIGIN}${path}`;
|
|
26
|
+
const response: Response = await fetch(url, {
|
|
27
|
+
method: init.method,
|
|
28
|
+
headers: cleanHeaders({
|
|
29
|
+
Authorization: auth,
|
|
30
|
+
'Content-Type': init.body != null ? 'application/json' : undefined,
|
|
31
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
32
|
+
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
33
|
+
}),
|
|
34
|
+
body: init.body != null ? JSON.stringify(init.body) : undefined,
|
|
35
|
+
});
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
const body = await response.text();
|
|
38
|
+
throw new XError(response.statusText, { method: init.method, url, body, tenantId, opts });
|
|
39
|
+
}
|
|
40
|
+
return response;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const bankAccountsPath = (organizationId: string) =>
|
|
44
|
+
`/api/crm/organizations/${organizationId}/bank-accounts`;
|
|
45
|
+
|
|
46
|
+
/** An organisation's bank accounts, the default first. */
|
|
47
|
+
export const listOrganizationBankAccounts = async (
|
|
48
|
+
tenantId: string,
|
|
49
|
+
organizationId: string,
|
|
50
|
+
opts?: ServiceOptions,
|
|
51
|
+
): Promise<OrganizationBankAccount[]> => {
|
|
52
|
+
const response = await callBankAccountsRoute(
|
|
53
|
+
tenantId,
|
|
54
|
+
bankAccountsPath(organizationId),
|
|
55
|
+
{ method: 'GET' },
|
|
56
|
+
opts,
|
|
57
|
+
);
|
|
58
|
+
const records = (await response.json()) as DataRecord<
|
|
59
|
+
OrganizationBankAccount,
|
|
60
|
+
OrganizationBankAccountMeta
|
|
61
|
+
>[];
|
|
62
|
+
return records.map((entry) => entry.record);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const createOrganizationBankAccount = async (
|
|
66
|
+
tenantId: string,
|
|
67
|
+
input: NewOrganizationBankAccount,
|
|
68
|
+
opts?: ServiceOptions,
|
|
69
|
+
): Promise<OrganizationBankAccount> => {
|
|
70
|
+
const { organizationId, ...details } = input;
|
|
71
|
+
const response = await callBankAccountsRoute(
|
|
72
|
+
tenantId,
|
|
73
|
+
bankAccountsPath(organizationId),
|
|
74
|
+
{ method: 'POST', body: details },
|
|
75
|
+
opts,
|
|
76
|
+
);
|
|
77
|
+
return (await response.json()) as OrganizationBankAccount;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const updateOrganizationBankAccount = async (
|
|
81
|
+
tenantId: string,
|
|
82
|
+
bankAccountId: string,
|
|
83
|
+
input: NewOrganizationBankAccount,
|
|
84
|
+
opts?: ServiceOptions,
|
|
85
|
+
): Promise<OrganizationBankAccount> => {
|
|
86
|
+
const { organizationId, ...details } = input;
|
|
87
|
+
const response = await callBankAccountsRoute(
|
|
88
|
+
tenantId,
|
|
89
|
+
`${bankAccountsPath(organizationId)}/${bankAccountId}`,
|
|
90
|
+
{ method: 'PUT', body: details },
|
|
91
|
+
opts,
|
|
92
|
+
);
|
|
93
|
+
return (await response.json()) as OrganizationBankAccount;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const deleteOrganizationBankAccount = async (
|
|
97
|
+
tenantId: string,
|
|
98
|
+
organizationId: string,
|
|
99
|
+
bankAccountId: string,
|
|
100
|
+
opts?: ServiceOptions,
|
|
101
|
+
): Promise<void> => {
|
|
102
|
+
await callBankAccountsRoute(
|
|
103
|
+
tenantId,
|
|
104
|
+
`${bankAccountsPath(organizationId)}/${bankAccountId}`,
|
|
105
|
+
{ method: 'DELETE' },
|
|
106
|
+
opts,
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const setDefaultOrganizationBankAccount = async (
|
|
111
|
+
tenantId: string,
|
|
112
|
+
organizationId: string,
|
|
113
|
+
bankAccountId: string,
|
|
114
|
+
opts?: ServiceOptions,
|
|
115
|
+
): Promise<OrganizationBankAccount> => {
|
|
116
|
+
const response = await callBankAccountsRoute(
|
|
117
|
+
tenantId,
|
|
118
|
+
`${bankAccountsPath(organizationId)}/${bankAccountId}/default`,
|
|
119
|
+
{ method: 'POST' },
|
|
120
|
+
opts,
|
|
121
|
+
);
|
|
122
|
+
return (await response.json()) as OrganizationBankAccount;
|
|
123
|
+
};
|
|
@@ -13,9 +13,8 @@ export type IntercompanyPaymentHop = {
|
|
|
13
13
|
/** Deep link to the hop opportunity on the target tenant's own subdomain. */
|
|
14
14
|
opportunityUrl: string;
|
|
15
15
|
/**
|
|
16
|
-
* Currency of the amounts: the hop opportunity's quote currency
|
|
17
|
-
*
|
|
18
|
-
* carries a quote; hops missing one (malformed) are skipped.
|
|
16
|
+
* Currency of the amounts: the hop opportunity's quote currency. A reserved-stage
|
|
17
|
+
* opportunity always carries a quote; hops missing one (malformed) are skipped.
|
|
19
18
|
*/
|
|
20
19
|
currency: string;
|
|
21
20
|
vehicle: {
|
|
@@ -33,7 +32,7 @@ export type IntercompanyPaymentHop = {
|
|
|
33
32
|
* total payment before delivery). Absent until that hop's quote is manager-accepted.
|
|
34
33
|
*/
|
|
35
34
|
expectedTotal?: string;
|
|
36
|
-
/** Sum of the hop opportunity's non-deleted payment amounts
|
|
35
|
+
/** Sum of the hop opportunity's non-deleted payment amounts. */
|
|
37
36
|
paid: string;
|
|
38
37
|
};
|
|
39
38
|
|
package/src/types/offers.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
SearchVehicle,
|
|
10
10
|
VehicleExternalInfo,
|
|
11
11
|
VehicleInternalInfo,
|
|
12
|
-
VehiclePurchaseDealForeign,
|
|
13
12
|
VehiclePurchaseDealStatus,
|
|
14
13
|
VehiclePurchaseDeliveryType,
|
|
15
14
|
} from './vehicles.js';
|
|
@@ -331,7 +330,6 @@ export type OfferPurchase = {
|
|
|
331
330
|
| VehiclePurchaseDealStatus.Marketing;
|
|
332
331
|
costs: {
|
|
333
332
|
purchase: string;
|
|
334
|
-
foreign?: VehiclePurchaseDealForeign;
|
|
335
333
|
purchaseVatPercentage: string;
|
|
336
334
|
internalGarage?: string;
|
|
337
335
|
externalGarage?: string;
|
|
@@ -251,23 +251,8 @@ export type OpportunityUpdate = {
|
|
|
251
251
|
};
|
|
252
252
|
|
|
253
253
|
export type OpportunityPaymentSummary = {
|
|
254
|
-
/** Branch currency. */
|
|
255
254
|
total: string;
|
|
256
|
-
/** Sum of `amount` over the payments, in branch currency. */
|
|
257
255
|
paid: string;
|
|
258
|
-
/**
|
|
259
|
-
* The same pair in the quote's alternative currency, present when the branch can be paid in it.
|
|
260
|
-
* `paid` sums the payments that arrived in that currency.
|
|
261
|
-
*/
|
|
262
|
-
foreign?: {
|
|
263
|
-
total: string;
|
|
264
|
-
paid: string;
|
|
265
|
-
currencyCode: string;
|
|
266
|
-
exchangeRate: string;
|
|
267
|
-
};
|
|
268
|
-
/** Fully paid when either currency reaches its total. */
|
|
269
|
-
status: OpportunityPaymentStatus;
|
|
270
|
-
percentagePaid: string;
|
|
271
256
|
entries: DataRecord<OpportunityPayment>[];
|
|
272
257
|
};
|
|
273
258
|
|
|
@@ -7,27 +7,8 @@ export enum OpportunityPaymentActions {
|
|
|
7
7
|
|
|
8
8
|
export const OPPORTUNITY_PAYMENT_NOTIFICATION_ORIGIN = 'opportunity-payment-notification';
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* The money as it arrived, when it arrived in the quote's alternative currency. `amount` then
|
|
12
|
-
* holds its value in branch currency: `foreign.amount × foreign.exchangeRate`.
|
|
13
|
-
*/
|
|
14
|
-
export type OpportunityPaymentForeign = {
|
|
15
|
-
amount: string;
|
|
16
|
-
currencyCode: string;
|
|
17
|
-
/** Branch currency units per 1 unit of `currencyCode`, the quote's rate. */
|
|
18
|
-
exchangeRate: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/** What a user sends for a payment in another currency. The backend takes the rate from the quote
|
|
22
|
-
* and derives `amount`. */
|
|
23
|
-
export type OpportunityPaymentForeignRequest = Pick<
|
|
24
|
-
OpportunityPaymentForeign,
|
|
25
|
-
'amount' | 'currencyCode'
|
|
26
|
-
>;
|
|
27
|
-
|
|
28
10
|
type BaseOpportunityPayment = {
|
|
29
11
|
opportunityId: string;
|
|
30
|
-
/** Branch currency. */
|
|
31
12
|
amount: string;
|
|
32
13
|
description?: string;
|
|
33
14
|
vehicleId: string;
|
|
@@ -43,7 +24,6 @@ export type NewOpportunityPayment = BaseOpportunityPayment & {
|
|
|
43
24
|
deletedAt?: undefined;
|
|
44
25
|
deletedBy?: undefined;
|
|
45
26
|
paidAt: string;
|
|
46
|
-
foreign?: OpportunityPaymentForeignRequest;
|
|
47
27
|
};
|
|
48
28
|
|
|
49
29
|
export type OpportunityPayment = BaseOpportunityPayment & {
|
|
@@ -55,14 +35,11 @@ export type OpportunityPayment = BaseOpportunityPayment & {
|
|
|
55
35
|
deletedAt?: string;
|
|
56
36
|
deletedBy?: string;
|
|
57
37
|
paidAt?: string;
|
|
58
|
-
foreign?: OpportunityPaymentForeign;
|
|
59
38
|
};
|
|
60
39
|
|
|
61
40
|
export type OpportunityPaymentUpdate = {
|
|
62
41
|
description?: string;
|
|
63
42
|
amount?: string;
|
|
64
|
-
/** `null` turns the payment back into a branch currency payment. */
|
|
65
|
-
foreign?: OpportunityPaymentForeignRequest | null;
|
|
66
43
|
paidAt?: string;
|
|
67
44
|
};
|
|
68
45
|
|