fix: format prices in notifications, change partial payment label, and add session holding notify API
This commit is contained in:
@@ -382,13 +382,33 @@ const resolveVariablesList = (def, storedVariables) => {
|
||||
.filter(Boolean);
|
||||
};
|
||||
|
||||
const isPriceSlot = (slot = '', name = '') => {
|
||||
const s = String(slot).toLowerCase();
|
||||
const n = String(name).toLowerCase();
|
||||
return s.includes('amount') || s.includes('price') || s.includes('tuition') || s.includes('fee')
|
||||
|| n.includes('amount') || n.includes('price') || n.includes('tuition') || n.includes('fee') || n.includes('cost');
|
||||
};
|
||||
|
||||
const formatPriceValue = (val) => {
|
||||
if (val === null || val === undefined || val === '') return '';
|
||||
const str = String(val).trim();
|
||||
const rawNum = Number(str.replace(/,/g, ''));
|
||||
if (!Number.isNaN(rawNum) && Number.isFinite(rawNum)) {
|
||||
return rawNum.toLocaleString('en-US');
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
const buildSmsParameters = (variables, valuesBySlot = {}) => {
|
||||
return normalizeVariablesInput(variables, null)
|
||||
.map((item) => {
|
||||
const name = sanitizeVariableName(item?.name);
|
||||
if (!name) return null;
|
||||
const slot = item?.slot;
|
||||
const value = slot ? valuesBySlot?.[slot] : '';
|
||||
let value = slot ? valuesBySlot?.[slot] : '';
|
||||
if (isPriceSlot(slot, name) && value != null && value !== '') {
|
||||
value = formatPriceValue(value);
|
||||
}
|
||||
return {
|
||||
name,
|
||||
value: String(value ?? '')
|
||||
|
||||
Reference in New Issue
Block a user