Skip to content

Instantly share code, notes, and snippets.

@vijaydeepak-tt
Created August 3, 2024 15:04
Show Gist options
  • Save vijaydeepak-tt/0032848ffe163f3aba88b1320f21aa35 to your computer and use it in GitHub Desktop.
Save vijaydeepak-tt/0032848ffe163f3aba88b1320f21aa35 to your computer and use it in GitHub Desktop.
export const RECOIL_DATA = [
{
_id: '68dea6e4-2a95-4fd2-9da2-fa512db840ca',
ratePlan: 'coMe',
rateCodeDesc: 'COMMERCIAL BUSINESS MM SAVINGS',
product: 'product test',
exceptionOccurredDate: '2024-05-10T04:00:02.995+0000',
effectiveDate: ' 2024-05-01',
lqed: {
tierDetails: [
{
ledBalanceValue: 2500000.0,
ledTierValue: 0.0015,
},
{
ledBalanceValue: 99999999999.0,
ledTierValue: 2.1215,
},
],
},
hogan: [
{
exception: "interest rates don't match",
interestCode: 'DH',
localMarketId: 'DFLT',
matrixid: 'AAMMM1',
tierDetails: [
{
hoganBalanceValue: 2500000.0,
hoganTierValue: 2.29,
},
{
hoganBalanceValue: 999999999990,
hoganTierValue: 2.32,
},
{
hoganBalanceValue: 100000000.0,
hoganTierValue: 2.29,
},
],
},
{
exception: "interest rates don't match",
interestCode: 'LS',
localMarketId: 'AA01',
matrixid: 'AAMMMI',
tierDetails: [
{
hoganBalanceValue: 2500000.0,
hoganTierValue: 2.23,
},
{
hoganBalanceValue: 100000000.0,
hoganTierValue: 2.29,
},
],
},
{
exception: "interest rates don't match",
interestCode: 'BB',
localMarketId: 'BBB01',
matrixid: 'BBMMM1',
tierDetails: [
{
hoganBalanceValue: 2500000.0,
hoganTierValue: 2.23,
},
{
hoganBalanceValue: 100000000.0,
hoganTierValue: 2.29,
},
],
},
],
},
{
_id: '68dea6e4-2a95-sd4fd2-9da2-fa512db840ca',
ratePlan: 'coMe',
rateCodeDesc: 'COMMERCIAL BUSINESS MM SAVINGS',
product: 'product test',
exceptionOccurredDate: '2024-05-10T04:00:02.995+0000',
effectiveDate: ' 2024-05-01',
lqed: {
tierDetails: [
{
ledBalanceValue: 2500000.0,
ledTierValue: 0.0015,
},
{
ledBalanceValue: 99999999999.0,
ledTierValue: 2.1215,
},
{
ledBalanceValue: 2500000.0,
ledTierValue: 0.0015,
},
{
ledBalanceValue: 99999999999.0,
ledTierValue: 2.1215,
},
{
ledBalanceValue: 2500000.0,
ledTierValue: 0.0015,
},
{
ledBalanceValue: 99999999999.0,
ledTierValue: 2.1215,
},
{
ledBalanceValue: 2500000.0,
ledTierValue: 0.0015,
},
{
ledBalanceValue: 99999999999.0,
ledTierValue: 2.1215,
},
],
},
hogan: [
{
exception: "interest rates don't match",
interestCode: 'DH',
localMarketId: 'DFLT',
matrixid: 'AAMMM1',
tierDetails: [
{
hoganBalanceValue: 2500000.0,
hoganTierValue: 2.29,
},
{
hoganBalanceValue: 999999999990,
hoganTierValue: 2.32,
},
{
hoganBalanceValue: 100000000.0,
hoganTierValue: 2.29,
},
],
},
{
exception: "interest rates don't match",
interestCode: 'LS',
localMarketId: 'AA01',
matrixid: 'AAMMMI',
tierDetails: [
{
hoganBalanceValue: 2500000.0,
hoganTierValue: 2.23,
},
{
hoganBalanceValue: 100000000.0,
hoganTierValue: 2.29,
},
],
},
{
exception: "interest rates don't match",
interestCode: 'BB',
localMarketId: 'BBB01',
matrixid: 'BBMMM1',
tierDetails: [
{
hoganBalanceValue: 2500000.0,
hoganTierValue: 2.23,
},
{
hoganBalanceValue: 100000000.0,
hoganTierValue: 2.29,
},
],
},
],
},
];
const buildHoganList = (hogans = []) => {
let hoganTiresSize = 0;
const hoganList = hogans
.map((hogan, hoganIdx) => {
const tierDetails = hogan.tierDetails ?? [];
const tierDetailsSize = tierDetails.length;
hoganTiresSize += tierDetailsSize;
return tierDetails.map((tire, idx) => {
const obj = {
idx: `hogan${hoganIdx}-tire(${idx})-${hogan.interestCode}`,
...tire,
hoganTiresSize,
};
if (idx === 0) {
obj['hoganRowSpan'] = tierDetailsSize;
obj['exception'] = hogan.exception;
obj['interestCode'] = hogan.interestCode;
obj['localMarketId'] = hogan.localMarketId;
obj['matrixid'] = hogan.matrixid;
}
return obj;
});
})
.flat();
return {
hoganTiresSize,
hoganList,
};
};
const lqedHoganMapper = (rowObj, largeList, smallList) => {
const resultList = [...largeList];
smallList.forEach((tire, idx) => {
let current = { ...largeList[idx], ...tire };
if (!current.idx) {
current['idx'] = `${idx}-small-list`;
}
if (idx === 0) {
current = {
...current,
...rowObj,
};
}
resultList[idx] = current;
});
return resultList;
};
export const buildTableRow = (row = {}) => {
const {
lqed,
hogan,
_id,
ratePlan,
rateCodeDesc,
exceptionOccurredDate,
effectiveDate,
product,
} = row;
const lqedDetailsList = lqed.tierDetails ?? [];
const lqedDetailsSize = lqedDetailsList.length;
const { hoganTiresSize, hoganList } = buildHoganList(hogan);
const rowObj = {
_id,
rowSpan: Math.max(lqedDetailsSize, hoganTiresSize),
ratePlan,
rateCodeDesc,
exceptionOccurredDate,
product,
effectiveDate,
lqedSize: lqedDetailsSize,
hoganSize: hoganTiresSize,
};
if (lqedDetailsSize > hoganTiresSize) {
return lqedHoganMapper(rowObj, lqedDetailsList, hoganList);
} else {
return lqedHoganMapper(rowObj, hoganList, lqedDetailsList);
}
};
export const LQED_COLUMNS = [
{
key: 'Rate Plan',
value: 'ratePlan',
},
{
key: 'Rate Description',
value: 'rateCodeDesc',
},
{
key: 'Product',
value: 'product',
},
{
key: 'Created Date',
value: 'effectiveDate',
},
];
export const LQED_TIER_DETAILS_COLUMNS = [
{
key: 'LQED Tier Balance',
value: 'ledBalanceValue',
},
{
key: 'LQED Tier Interest Rate',
value: 'ledTierValue',
},
];
export const HOGAN_COLUMNS = [
{
key: 'Hogan Interest Code',
value: 'interestCode',
},
{
key: 'Matrix Id',
value: 'matrixid',
},
{
key: 'Market Id',
value: 'localMarketId',
},
];
export const HOGON_TIER_DETAILS_COLUMNS = [
{
key: 'Hogan Tier Balance',
value: 'hoganBalanceValue',
},
{
key: 'Hogan Tier Interest Rate',
value: 'hoganTierValue',
},
];
export const OTHER_COLUMNS = [
{
key: 'Message',
value: 'exception',
},
];
export const RECOIL_COLUMNS = [
...LQED_COLUMNS,
...LQED_TIER_DETAILS_COLUMNS,
...HOGAN_COLUMNS,
...HOGON_TIER_DETAILS_COLUMNS,
...OTHER_COLUMNS,
];
export const LQED_COLUMNS_SIZE =
LQED_COLUMNS.length + LQED_TIER_DETAILS_COLUMNS.length;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment