car body policy and sales extended

This commit is contained in:
2026-09-05 18:37:42 +03:30
parent eb072ef080
commit eb636bdbdd
10 changed files with 1097 additions and 14 deletions

View File

@@ -251,6 +251,8 @@ export class FanavaranAuthService {
forceRefresh?: boolean;
/** Per-request Location override (does not affect token fingerprint). */
locationOverride?: string;
/** Per-request ContractId override (بدنه vs ثالث). Does not affect token fingerprint. */
contractIdOverride?: string;
},
): Promise<{
authenticationToken: string;
@@ -264,10 +266,11 @@ export class FanavaranAuthService {
options,
);
const locationOverride = options?.locationOverride?.trim();
const contractIdOverride = options?.contractIdOverride?.trim();
return {
authenticationToken,
CorpId: profile.auth.corpId,
ContractId: profile.auth.contractId,
ContractId: contractIdOverride || profile.auth.contractId,
Location: locationOverride || profile.auth.location,
};
}

View File

@@ -95,6 +95,9 @@ export class FanavaranClientConfigService implements OnModuleInit {
password: doc.auth.password,
corpId: doc.auth.corpId,
contractId: doc.auth.contractId,
...(doc.auth.hullContractId
? { hullContractId: doc.auth.hullContractId }
: {}),
location: doc.auth.location,
},
defaults: { ...doc.defaults },

View File

@@ -78,9 +78,13 @@ export class FanavaranLookupService {
async fetchFromFanavaran(
clientKey: FanavaranClientKey,
url: string,
options?: { contractIdOverride?: string },
): Promise<unknown> {
try {
const headers = await this.fanavaranAuthService.getRequestHeaders(clientKey);
const headers = await this.fanavaranAuthService.getRequestHeaders(
clientKey,
{ contractIdOverride: options?.contractIdOverride },
);
this.logger.log(
`[${clientKey}] Calling Fanavaran lookup API: ${url}`,
@@ -236,46 +240,52 @@ export class FanavaranLookupService {
async inquiryByVin(
clientKey: FanavaranClientKey,
vin: string,
options?: { contractIdOverride?: string },
): Promise<unknown> {
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicles/inquiry-by-vin?vin=${encodeURIComponent(vin)}`;
return this.fetchFromFanavaran(clientKey, url);
return this.fetchFromFanavaran(clientKey, url, options);
}
async myPolicies(
clientKey: FanavaranClientKey,
nationalCode: string,
insuranceLineId: number = 5,
options?: { contractIdOverride?: string },
): Promise<unknown> {
const url =
`${FANAVARAN_LOOKUP_BASE_URL}/common/Policies/inquiry-my-policies` +
`?InsuranceLineId=${insuranceLineId}` +
`&NationalCode=${encodeURIComponent(nationalCode)}`;
return this.fetchFromFanavaran(clientKey, url);
return this.fetchFromFanavaran(clientKey, url, options);
}
async thirdPartyPolicyById(
clientKey: FanavaranClientKey,
policyId: number,
options?: { contractIdOverride?: string },
): Promise<unknown> {
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/third-party-car-policies/${policyId}`;
return this.fetchFromFanavaran(clientKey, url);
return this.fetchFromFanavaran(clientKey, url, options);
}
async bodyPolicyById(
clientKey: FanavaranClientKey,
policyId: number,
options?: { contractIdOverride?: string },
): Promise<unknown> {
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicle-hull-policies/${policyId}`;
return this.fetchFromFanavaran(clientKey, url);
return this.fetchFromFanavaran(clientKey, url, options);
}
async vehicleById(
clientKey: FanavaranClientKey,
vehicleId: number,
versionNo: number = 1,
versionNo?: number,
options?: { contractIdOverride?: string },
): Promise<unknown> {
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicles/${vehicleId}?versionno=${versionNo}`;
return this.fetchFromFanavaran(clientKey, url);
const query = versionNo == null ? "" : `?versionno=${versionNo}`;
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicles/${vehicleId}${query}`;
return this.fetchFromFanavaran(clientKey, url, options);
}
async customerById(

View File

@@ -22,6 +22,10 @@ export class FanavaranAuthConfigEmbed {
@Prop({ type: String, required: true })
contractId: string;
/** Vehicle-hull (بدنه) ContractId. Optional until the tenant hull line is configured. */
@Prop({ type: String, required: false })
hullContractId?: string;
@Prop({ type: String, required: true })
location: string;
}