FEAT_NON_EB_ADDITIONAL_EXCESS
This commit is contained in:
parent
34ae41cfab
commit
6867e0f5aa
@ -1144,15 +1144,21 @@
|
||||
function registerPolicyData() {
|
||||
|
||||
var policyType;
|
||||
var policyAcronym;
|
||||
|
||||
if (totalSI < 50000000) {
|
||||
if (totalSI <= 50000000) {
|
||||
policyType = "Bharat Sookshma Udyam Suraksha (BSUS)"
|
||||
} else if (totalSI > 50000000 && totalSI < 500000000) {
|
||||
policyAcronym = "bsu"
|
||||
} else if (totalSI > 50000000 && totalSI <= 500000000) {
|
||||
policyType = "Bharat Laghu Udyam Suraksha (BLUS)"
|
||||
policyAcronym = "blu"
|
||||
} else if (totalSI > 500000000) {
|
||||
policyType = "Standard Fire and Special Perils (SFSP)";
|
||||
policyAcronym = "sfsp"
|
||||
}
|
||||
|
||||
modifyExcessTable(policyAcronym);
|
||||
|
||||
// Build the initial JSON object with productSelection and policyDetails
|
||||
var outputData = {
|
||||
policyType: policyType,
|
||||
|
||||
@ -517,6 +517,22 @@
|
||||
|
||||
<script>
|
||||
|
||||
const dynamicExcessJson = {
|
||||
"excess_fire":[
|
||||
{
|
||||
"blu":"5% of claim amount subject to minimum of Rs. 10000/- for each and every claim",
|
||||
"bsu":"5% of claim amount subject to minimum of Rs. 5000/- for each and every claim",
|
||||
"sfsp":"For location having SI upto INR 10Cr: 5% of claim amount subject to a minimum of Rs.10,000/- for each and every claim. For location having SI above INR 10Cr and upto 100 Cr: 5% of claim amount subject to a minimum of Rs.25,000/- For each and every claim .For location having SI above INR 100Cr and upto 1500 Cr: 5% of claim amount subject to a minimum of Rs.500,000/- for each and every claim"
|
||||
}
|
||||
],
|
||||
"excess_burglary":[
|
||||
{
|
||||
"blu":"5% of claim amount subject to minimum of Rs.5,000/-",
|
||||
"bsu": "5% of claim amount subject to minimum of Rs.2,500/- for Burglary & 5,000/- for Theft each and every claim"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
var isSaved = true;
|
||||
// var randomColor = 'hsl(' + Math.random() * 360 + ', 100%, 93%)';
|
||||
var rfq_data = <?= isset($rfq_data['json']) ? json_encode($rfq_data['json'], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) : '""' ?>;
|
||||
@ -1828,6 +1844,8 @@
|
||||
// Add new rows from tableData
|
||||
tableData.table_row_contents.forEach((rowData, index) => {
|
||||
let rowID = Object.keys(rowData)[0];
|
||||
// console.log("rowData: ",rowData);
|
||||
// alert(rowID.answer_type);
|
||||
var question = rowData[rowID].display_value;
|
||||
|
||||
const row = document.createElement('tr');
|
||||
@ -1867,15 +1885,20 @@
|
||||
// Check if subheader is NOT "Sum Insured"
|
||||
let className = !subHeaderText.startsWith("Sum Insured") && subHeaderText != "-" && !subHeaderText.startsWith("Liability Limit")?
|
||||
"insurer_proposal" : ""; // alert(subHeaderText);
|
||||
// console.log("default_answers_array",default_answers_array)
|
||||
let default_answers_array = rowData[rowID].default_answer
|
||||
|
||||
let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
|
||||
let defaul_value = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
|
||||
let default_answer = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
|
||||
|
||||
// // // console.log("defaultJsonString", defaultJsonString);
|
||||
// // // console.log("defaultJsonString type", typeof defaultJsonString);
|
||||
// // // console.log("defaultJsonString string", String(defaultJsonString));
|
||||
// console.log("defaultJsonString", defaultJsonString);
|
||||
// console.log("defaultJsonString type", typeof defaultJsonString);
|
||||
// console.log("defaultJsonString string", String(defaultJsonString));
|
||||
|
||||
|
||||
|
||||
return `<td class="${className}" onblur="setValueForHiddenField(this,'${rowID.answer_type}')"
|
||||
return `<td class="${className}" onblur="setValueForHiddenField(this,'${rowData[rowID].answer_type}')"
|
||||
onclick="getAnswer('${'excess'}','${rowID}')"
|
||||
contenteditable="true">
|
||||
|
||||
@ -5181,4 +5204,85 @@
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
class ExcessHandler {
|
||||
change() {
|
||||
throw new Error("Method 'change()' must be implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
class DefaultExcessHandler extends ExcessHandler {
|
||||
constructor(typeKey) {
|
||||
super();
|
||||
this.typeKey = typeKey;
|
||||
}
|
||||
|
||||
change() {
|
||||
getExcessData(this.typeKey);
|
||||
}
|
||||
}
|
||||
|
||||
const handlerMap = {
|
||||
blu: new DefaultExcessHandler("blu"),
|
||||
bsu: new DefaultExcessHandler("bsu"),
|
||||
sfsp: new DefaultExcessHandler("sfsp"),
|
||||
};
|
||||
|
||||
function modifyExcessTable(policyType) {
|
||||
console.log("Policy Type from register: ", policyType);
|
||||
const handler = handlerMap[policyType];
|
||||
|
||||
if (handler instanceof ExcessHandler) {
|
||||
handler.change();
|
||||
} else {
|
||||
console.error(`No handler found for policyType: ${policyType}`);
|
||||
}
|
||||
}
|
||||
|
||||
function getExcessData(typeKey) {
|
||||
const fire = dynamicExcessJson["excess_fire"][0][typeKey];
|
||||
const burglary = dynamicExcessJson["excess_burglary"]?.[0]?.[typeKey] ?? null;
|
||||
changeExcessTableDynamic(fire, burglary);
|
||||
}
|
||||
|
||||
function changeExcessTableDynamic(fire, burglary = null) {
|
||||
console.log("fire to be changed to: ", fire);
|
||||
setExcessRowValues("fire", fire);
|
||||
|
||||
if (burglary != null) {
|
||||
console.log("Burglary to be changed: ", burglary);
|
||||
setExcessRowValues("burglary", burglary);
|
||||
}
|
||||
}
|
||||
|
||||
function setExcessRowValues(rowId, value) {
|
||||
const table = document.getElementById("excess");
|
||||
if (!table) return;
|
||||
|
||||
const rows = table.querySelectorAll(`tr[data-excess-row-parent="${rowId}"]`);
|
||||
if (!rows.length) return;
|
||||
|
||||
const headerCells = table.querySelectorAll("thead tr:first-child th");
|
||||
const subHeaderCells = table.querySelectorAll("thead tr:nth-child(2) th");
|
||||
|
||||
rows.forEach(row => {
|
||||
const cells = row.querySelectorAll("td");
|
||||
cells.forEach((cell, index) => {
|
||||
const headerText = headerCells[index]?.textContent?.trim() || "";
|
||||
const subHeaderText = subHeaderCells[index]?.textContent?.trim() || "";
|
||||
|
||||
if (
|
||||
(headerText.startsWith("Proposal") || headerText.startsWith("Exi")) &&
|
||||
subHeaderText.toLowerCase() === "sum insured"
|
||||
) {
|
||||
cell.textContent = value;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user