43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
|
import { defaultRow } from '@/stores/tables/elt/default-values';
|
|
|
|
export async function getKPData({ quote }: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
|
const elt: NonNullable<GetQuoteProcessData['elt']> = { kasko: undefined, osago: undefined };
|
|
|
|
if (
|
|
quote?.evo_kasko_accountid &&
|
|
((quote?.evo_id_elt_kasko && quote?.evo_id_kasko_calc) ||
|
|
quote.evo_kasko_insurance_rulesidData?.evo_id) &&
|
|
quote?.evo_kasko_price &&
|
|
quote?.evo_franchise !== null
|
|
) {
|
|
elt.kasko = {
|
|
insuranceCondition:
|
|
quote.evo_kasko_insurance_rulesidData?.evo_id ?? defaultRow.insuranceCondition,
|
|
key: quote?.evo_kasko_accountid,
|
|
requestId: quote?.evo_id_elt_kasko ?? defaultRow.requestId,
|
|
skCalcId: quote?.evo_id_kasko_calc ?? defaultRow.skCalcId,
|
|
sum: quote?.evo_kasko_price,
|
|
totalFranchise: quote?.evo_franchise,
|
|
};
|
|
}
|
|
|
|
if (
|
|
quote?.evo_osago_accountid &&
|
|
(quote?.evo_id_elt_osago || quote.evo_osago_insurance_rulesiddData?.evo_id) &&
|
|
quote?.evo_osago_price
|
|
) {
|
|
elt.osago = {
|
|
insuranceCondition:
|
|
quote.evo_osago_insurance_rulesiddData?.evo_id ?? defaultRow.insuranceCondition,
|
|
key: quote?.evo_osago_accountid,
|
|
numCalc: quote?.evo_id_elt_osago ?? defaultRow.numCalc,
|
|
sum: quote?.evo_osago_price,
|
|
};
|
|
}
|
|
|
|
return {
|
|
elt,
|
|
};
|
|
}
|