Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@
<shortDescription>Total Premium</shortDescription>
<value>Total Premium</value>
</labels>
<labels>
<fullName>PRODUCT_CONFIG_TAXES_FEES_SURCHARGE</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>Taxes Fees Surcharge</shortDescription>
<value>Taxes, Fees and Surcharge</value>
</labels>
<labels>
<fullName>PRODUCT_CONFIG_PREMIUM</fullName>
<language>en_US</language>
Expand Down Expand Up @@ -196,5 +189,12 @@
<shortDescription>Tax Amount</shortDescription>
<value>Tax Amount</value>
</labels>
<labels>
<fullName>PRODUCT_CONFIG_FEE_AMOUNT</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>Fee Amount</shortDescription>
<value>Fee Amount</value>
</labels>
</CustomLabels>

Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function buildTreeNode(salesTransactionItem, productDetailsMap, instanceKeysPath
attributes: getAttributesWithDetails(childNode, coverageProductDetail),
netUnitPrice: childData.NetUnitPrice,
proratedQLITaxAmount: childData.ProratedQLITaxAmount,
proratedQLIFeeAmount: childData.ProratedQLIFeeAmount__std,
instanceKeys: coverageInstanceKeys,
instanceKeysString: coverageInstanceKeys.join(',')
});
Expand All @@ -106,7 +107,8 @@ function buildTreeNode(salesTransactionItem, productDetailsMap, instanceKeysPath
attributes: getAttributesWithDetails(salesTransactionItem, productDetail),
coverages,
netUnitPrice: itemData.NetUnitPrice,
proratedQLITaxAmount: itemData.ProratedQLITaxAmount
proratedQLITaxAmount: itemData.ProratedQLITaxAmount,
proratedQLIFeeAmount: itemData.ProratedQLIFeeAmount__std
};

// Step 3: Add unselected coverages from product details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import MULTI_VALUE_DECODER_MESSAGE from '@salesforce/label/c.PRODUCT_CONFIG_MULT
import NEXT from '@salesforce/label/c.PRODUCT_CONFIG_NEXT';
import PREVIOUS from '@salesforce/label/c.PRODUCT_CONFIG_PREVIOUS';
import TAX_AMOUNT from '@salesforce/label/c.PRODUCT_CONFIG_TAX_AMOUNT';
import FEE_AMOUNT from '@salesforce/label/c.PRODUCT_CONFIG_FEE_AMOUNT';

// Product Configuration Labels
export const LABELS = {
Expand All @@ -42,7 +43,6 @@ export const LABELS = {
INSTANT_PRICING,
UPDATE_PRICES,
TOTAL_PREMIUM,
TAXES_FEES_SURCHARGE,
PREMIUM,
ERROR_OCCURRED,
INVALID_DATA_RECEIVED,
Expand All @@ -57,7 +57,8 @@ export const LABELS = {
MULTI_VALUE_DECODER_MESSAGE,
NEXT,
PREVIOUS,
TAX_AMOUNT
TAX_AMOUNT,
FEE_AMOUNT
};

export const CONSTANTS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,13 @@ <h3 class="slds-text-heading_small slds-text-align_left slds-m-bottom_medium">{l
<span class="slds-text-body_regular">{labels.PREMIUM}</span>
<lightning-formatted-number value={priceSummary.premium} format-style="currency" currency-code={currencyCode} class="slds-text-body_regular"></lightning-formatted-number>
</div>
<div class="slds-grid slds-grid_align-spread slds-m-bottom_x-small">
<span class="slds-text-body_small slds-text-color_weak">{labels.TAX_AMOUNT}</span>
<lightning-formatted-number value={priceSummary.taxes} format-style="currency" currency-code={currencyCode} class="slds-text-body_small slds-text-color_weak"></lightning-formatted-number>
</div>
<div class="slds-grid slds-grid_align-spread slds-m-bottom_small">
<span class="slds-text-body_small slds-text-color_weak">{labels.TAXES_FEES_SURCHARGE}</span>
<lightning-formatted-number value={priceSummary.taxesFees} format-style="currency" currency-code={currencyCode} class="slds-text-body_small slds-text-color_weak"></lightning-formatted-number>
<span class="slds-text-body_small slds-text-color_weak">{labels.FEE_AMOUNT}</span>
<lightning-formatted-number value={priceSummary.fees} format-style="currency" currency-code={currencyCode} class="slds-text-body_small slds-text-color_weak"></lightning-formatted-number>
</div>
<div class="slds-grid slds-grid_align-spread slds-border_top slds-p-top_small">
<span class="slds-text-heading_small">{labels.TOTAL_PREMIUM}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,28 @@ export default class ProdCfg extends OmniscriptBaseMixin(LightningElement) {
? 'slds-box slds-box_x-small slds-m-bottom_small slds-is-disabled'
: 'slds-box slds-box_x-small slds-m-bottom_small';

// Pass raw price and formatted tax for coverage
// Pass raw price and formatted tax and fee for coverage
const currency = this.getCurrencyForPriceSummary();
preparedCoverage.price = coverage.netUnitPrice;
preparedCoverage.tax = (coverage.proratedQLITaxAmount !== null && coverage.proratedQLITaxAmount !== undefined)

// Build tooltip content with tax and fee information
const taxInfo = (coverage.proratedQLITaxAmount !== null && coverage.proratedQLITaxAmount !== undefined)
? `${LABELS.TAX_AMOUNT} ` + this.formatCurrency(coverage.proratedQLITaxAmount, currency)
: null;
const feeInfo = (coverage.proratedQLIFeeAmount !== null && coverage.proratedQLIFeeAmount !== undefined)
? `${LABELS.FEE_AMOUNT} ` + this.formatCurrency(coverage.proratedQLIFeeAmount, currency)
: null;

// Combine tax and fee info for tooltip
if (taxInfo && feeInfo) {
preparedCoverage.tax = `${taxInfo} | ${feeInfo}`;
} else if (taxInfo) {
preparedCoverage.tax = taxInfo;
} else if (feeInfo) {
preparedCoverage.tax = feeInfo;
} else {
preparedCoverage.tax = null;
}

if (coverage.attributes) {
// Use coverage's stiId for attribute treatments (not parent node's id)
Expand Down Expand Up @@ -1038,12 +1054,28 @@ export default class ProdCfg extends OmniscriptBaseMixin(LightningElement) {
}

get selectedNodeTax() {
if (!this.selectedNode || this.selectedNode.proratedQLITaxAmount === null || this.selectedNode.proratedQLITaxAmount === undefined) {
if (!this.selectedNode) {
return '';
}

const currency = this.getCurrencyForPriceSummary();
const formattedCurrency = this.formatCurrency(this.selectedNode.proratedQLITaxAmount, currency);
return `${LABELS.TAX_AMOUNT} ${formattedCurrency}`;
const hasTax = this.selectedNode.proratedQLITaxAmount !== null && this.selectedNode.proratedQLITaxAmount !== undefined;
const hasFee = this.selectedNode.proratedQLIFeeAmount !== null && this.selectedNode.proratedQLIFeeAmount !== undefined;

if (!hasTax && !hasFee) {
return '';
}

const taxInfo = hasTax ? `${LABELS.TAX_AMOUNT} ${this.formatCurrency(this.selectedNode.proratedQLITaxAmount, currency)}` : null;
const feeInfo = hasFee ? `${LABELS.FEE_AMOUNT} ${this.formatCurrency(this.selectedNode.proratedQLIFeeAmount, currency)}` : null;

if (taxInfo && feeInfo) {
return `${taxInfo} | ${feeInfo}`;
}
if (feeInfo) {
return feeInfo;
}
return taxInfo;
}

get currencyCode() {
Expand Down Expand Up @@ -1270,10 +1302,10 @@ export default class ProdCfg extends OmniscriptBaseMixin(LightningElement) {

// Pricing getter methods
getCurrencyForPriceSummary() {
if (!this.apiResponse?.contextJSON?.salesTransactions?.[0]?.salesTransactionItems) {
if (!this.apiResponse?.productRatingOutput?.contextJSON?.salesTransactions?.[0]?.salesTransactionItems) {
return CURRENCY; // Fall back to org's default currency
}
const firstItem = this.apiResponse.contextJSON.salesTransactions[0].salesTransactionItems[0];
const firstItem = this.apiResponse.productRatingOutput.contextJSON.salesTransactions[0].salesTransactionItems[0];
const currency = firstItem?.fields?.STICurrencyIsoCode__std || CURRENCY;
return currency;
}
Expand All @@ -1288,10 +1320,10 @@ export default class ProdCfg extends OmniscriptBaseMixin(LightningElement) {
}

getPriceValue(fieldName) {
if (!this.apiResponse?.contextJSON?.salesTransactions?.[0]?.salesTransactionItems) {
if (!this.apiResponse?.productRatingOutput?.contextJSON?.salesTransactions?.[0]?.salesTransactionItems) {
return 0;
}
const firstItem = this.apiResponse.contextJSON.salesTransactions[0].salesTransactionItems[0];
const firstItem = this.apiResponse.productRatingOutput.contextJSON.salesTransactions[0].salesTransactionItems[0];
return firstItem?.fields?.[fieldName] || 0;
}

Expand All @@ -1301,7 +1333,8 @@ export default class ProdCfg extends OmniscriptBaseMixin(LightningElement) {
}
return {
premium: this.getPriceValue('NetUnitPrice'),
taxesFees: this.getPriceValue('ProratedQLITaxAmount'),
taxes: this.getPriceValue('ProratedQLITaxAmount'),
fees: this.getPriceValue('ProratedQLIFeeAmount__std'),
totalPremium: this.getPriceValue('NetTotalPrice')
};
}
Expand Down
14 changes: 14 additions & 0 deletions osComponents/ProductSelection/labels/ProductSelectionLabels.labels
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,18 @@
<shortDescription>Cancel button label</shortDescription>
<value>Cancel</value>
</labels>
<labels>
<fullName>ProdSelTaxAmount</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>Tax Amount</shortDescription>
<value>Tax Amount</value>
</labels>
<labels>
<fullName>ProdSelFeeAmount</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>Fee Amount</shortDescription>
<value>Fee Amount</value>
</labels>
</CustomLabels>
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ function buildTreeNode(item, itemKey, productDetails, treatments) {
productCode: childData.ProductCode,
isSelected: true,
price: childData.NetUnitPrice,
taxAmount: childData.ProratedQLITaxAmount,
feeAmount: childData.ProratedQLIFeeAmount__std,
attributes: getAttributesWithDetails(childNode, coverageProductDetail, treatments),
id: childData.id,
prcId
Expand Down Expand Up @@ -88,6 +90,8 @@ function buildTreeNode(item, itemKey, productDetails, treatments) {
description: productDetail.description,
customProductName: itemData.CustomProductName,
price: itemData.NetUnitPrice,
taxAmount: itemData.ProratedQLITaxAmount,
feeAmount: itemData.ProratedQLIFeeAmount__std,
hasEmptyPrice: itemData.NetUnitPrice === null || itemData.NetUnitPrice === undefined,
name: itemKey,
expanded: false,
Expand Down Expand Up @@ -340,13 +344,21 @@ function _processNode(node, planName, currentLevelMap) {
label: nodeLabel,
productCode: node.productCode,
prices: new Map(),
taxAmounts: new Map(),
feeAmounts: new Map(),
children: new Map(),
};
currentLevelMap.set(nodeKey, entry);
}
if (node.price !== undefined) {
entry.prices.set(planName, node.price);
}
if (node.taxAmount !== undefined) {
entry.taxAmounts.set(planName, node.taxAmount);
}
if (node.feeAmount !== undefined) {
entry.feeAmounts.set(planName, node.feeAmount);
}

if (node.attributes && node.attributes.length > 0) {
_processAttributes(node.attributes, planName, entry.children);
Expand Down Expand Up @@ -400,14 +412,58 @@ function _buildGridRowsRecursive(map, parentId, planNames, currencyCode, parentV
}
});

// Create tax and fee rows for products/coverages (not attributes)
const additionalRows = [];
if (value.type === 'product') {
// Create Tax Amount row
const taxRow = {
id: `${id}-tax`,
Product: '',
Details: LABELS.TaxAmount,
};
planNames.forEach(planName => {
const taxAmount = value.taxAmounts.get(planName);
taxRow[planName] = {
value: typeof taxAmount === 'number' ? taxAmount : '--',
type: typeof taxAmount === 'number' ? 'currency' : 'text',
currencyIsoCode: currencyCode,
};
});
additionalRows.push(taxRow);

// Create Fee Amount row
const feeRow = {
id: `${id}-fee`,
Product: '',
Details: LABELS.FeeAmount,
};
planNames.forEach(planName => {
const feeAmount = value.feeAmounts.get(planName);
feeRow[planName] = {
value: typeof feeAmount === 'number' ? feeAmount : '--',
type: typeof feeAmount === 'number' ? 'currency' : 'text',
currencyIsoCode: currencyCode,
};
});
additionalRows.push(feeRow);
}

if (value.children && value.children.size > 0) {
row._children = _buildGridRowsRecursive(value.children, id, planNames, currencyCode, value);
// Add tax and fee rows to children
if (additionalRows.length > 0) {
row._children = [...additionalRows, ...row._children];
}
if (row._children.length === 0 && value.type === 'product' && !_hasAnyPriceForPlans(value, planNames)) {
} else {
rows.push(row);
index++;
}
} else {
// Add tax and fee rows as children even if no other children exist
if (additionalRows.length > 0) {
row._children = additionalRows;
}
rows.push(row);
index++;
}
Expand Down Expand Up @@ -485,9 +541,41 @@ export function transformTreeToGrid(enhancedTree, currencyIsoCode) {
};
});

// Create a row for tax amount of each plan
const totalTaxRow = {
id: '0-tax',
Product: '',
Details: LABELS.TaxAmount
};
planNames.forEach(planName => {
const rootProduct = enhancedTree.find(p => p.name === planName);
const taxAmount = rootProduct ? rootProduct.taxAmount : undefined;
totalTaxRow[planName] = {
value: typeof taxAmount === 'number' ? taxAmount : '--',
type: typeof taxAmount === 'number' ? 'currency' : 'text',
currencyIsoCode
};
});

// Create a row for fee amount of each plan
const totalFeeRow = {
id: '0-fee',
Product: '',
Details: LABELS.FeeAmount
};
planNames.forEach(planName => {
const rootProduct = enhancedTree.find(p => p.name === planName);
const feeAmount = rootProduct ? rootProduct.feeAmount : undefined;
totalFeeRow[planName] = {
value: typeof feeAmount === 'number' ? feeAmount : '--',
type: typeof feeAmount === 'number' ? 'currency' : 'text',
currencyIsoCode
};
});

const rootAttributeRows = _buildGridRowsRecursive(rootAttributesMap, '0', planNames, currencyIsoCode, null);

const gridData = [totalPriceRow, ...rootAttributeRows, ...productRows];
const gridData = [totalPriceRow, totalTaxRow, totalFeeRow, ...rootAttributeRows, ...productRows];

return { gridColumns, gridData };
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import ProdSelPrevious from '@salesforce/label/c.ProdSelPrevious';
import ProdSelProduct from '@salesforce/label/c.ProdSelProduct';
import ProdSelLoading from '@salesforce/label/c.ProdSelLoading';
import ProdSelCheckbox from '@salesforce/label/c.ProdSelCheckbox';
import ProdSelTaxAmount from '@salesforce/label/c.ProdSelTaxAmount';
import ProdSelFeeAmount from '@salesforce/label/c.ProdSelFeeAmount';

// Product Selection validation messages
export const VALIDATION_MESSAGES = {
Expand All @@ -32,7 +34,9 @@ export const LABELS = {
Previous: ProdSelPrevious,
Product: ProdSelProduct,
Loading: ProdSelLoading,
Checkbox: ProdSelCheckbox
Checkbox: ProdSelCheckbox,
TaxAmount: ProdSelTaxAmount,
FeeAmount: ProdSelFeeAmount
};

export const CONSTANTS = {
Expand Down