av6-core 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -6
- package/dist/index.mjs +9 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1131,6 +1131,9 @@ var maybeStep = (v, stepwise, fmt, p) => stepwise ? applyRound(v, fmt, p) : v;
|
|
|
1131
1131
|
function clamp(n, min, max) {
|
|
1132
1132
|
return Math.max(min, Math.min(max, n));
|
|
1133
1133
|
}
|
|
1134
|
+
var percentage = (amount, percentage2) => {
|
|
1135
|
+
return amount * percentage2 / 100;
|
|
1136
|
+
};
|
|
1134
1137
|
function calculateBillingFromChildren(inputs, masterExtra, options = {}) {
|
|
1135
1138
|
const stepwise = options.calculationMethod === "STEP_WISE";
|
|
1136
1139
|
const lineFmt = options.lineRound ?? RoundFormat.TO_FIXED;
|
|
@@ -1139,7 +1142,7 @@ function calculateBillingFromChildren(inputs, masterExtra, options = {}) {
|
|
|
1139
1142
|
const children = inputs.map((it) => {
|
|
1140
1143
|
let baseRate = it.rate;
|
|
1141
1144
|
if (it.addonPercentage) {
|
|
1142
|
-
baseRate = baseRate + baseRate
|
|
1145
|
+
baseRate = baseRate + percentage(baseRate, it.addonPercentage);
|
|
1143
1146
|
baseRate = maybeStep(baseRate, stepwise, lineFmt, precision);
|
|
1144
1147
|
}
|
|
1145
1148
|
const subtotal = applyRound(it.qty * baseRate, lineFmt, precision);
|
|
@@ -1149,13 +1152,13 @@ function calculateBillingFromChildren(inputs, masterExtra, options = {}) {
|
|
|
1149
1152
|
if (masterExtra.coPayMode === "PERCENTAGE-AMOUNT") {
|
|
1150
1153
|
const copayType = it.coPaymentType ?? "AMOUNT";
|
|
1151
1154
|
const copayValue = it.coPayValue ?? 0;
|
|
1152
|
-
copayAmount2 = copayType === "PERCENTAGE" ? basePreTax
|
|
1155
|
+
copayAmount2 = copayType === "PERCENTAGE" ? percentage(basePreTax, copayValue) : Math.min(copayValue, basePreTax);
|
|
1153
1156
|
}
|
|
1154
1157
|
const dMode = it.discountMode ?? "AMOUNT";
|
|
1155
1158
|
const dVal = it.discountValue ?? 0;
|
|
1156
1159
|
const tMethod = it.taxMethod ?? "NONE";
|
|
1157
1160
|
const tVal = Math.max(0, it.taxValue ?? 0);
|
|
1158
|
-
let baseAfterTaxDisc =
|
|
1161
|
+
let baseAfterTaxDisc = basePreTax;
|
|
1159
1162
|
let discountValue = 0;
|
|
1160
1163
|
if (tMethod === "INCLUSIVE") {
|
|
1161
1164
|
const inclusiveTaxMultiplier = (100 + tVal) / 100;
|
|
@@ -1165,12 +1168,12 @@ function calculateBillingFromChildren(inputs, masterExtra, options = {}) {
|
|
|
1165
1168
|
if (dMode === "AMOUNT") {
|
|
1166
1169
|
discountValue = dVal;
|
|
1167
1170
|
} else if (dMode === "PERCENTAGE") {
|
|
1168
|
-
discountValue = baseAfterTaxDisc
|
|
1171
|
+
discountValue = percentage(baseAfterTaxDisc, dVal);
|
|
1169
1172
|
}
|
|
1170
1173
|
discountValue = maybeStep(discountValue, stepwise, lineFmt, precision);
|
|
1171
1174
|
let afterDisc = Math.max(0, baseAfterTaxDisc - discountValue);
|
|
1172
1175
|
afterDisc = maybeStep(afterDisc, stepwise, lineFmt, precision);
|
|
1173
|
-
let calculatedTax =
|
|
1176
|
+
let calculatedTax = percentage(afterDisc, tVal);
|
|
1174
1177
|
calculatedTax = maybeStep(calculatedTax, stepwise, lineFmt, precision);
|
|
1175
1178
|
let grossAmount2 = afterDisc + calculatedTax;
|
|
1176
1179
|
grossAmount2 = maybeStep(grossAmount2, stepwise, lineFmt, precision);
|
|
@@ -1211,7 +1214,7 @@ function calculateBillingFromChildren(inputs, masterExtra, options = {}) {
|
|
|
1211
1214
|
const patientRawTotal = grossAmount - copayAmount;
|
|
1212
1215
|
let masterExtraApplied = 0;
|
|
1213
1216
|
if (masterExtra.mode === "PERCENTAGE") {
|
|
1214
|
-
masterExtraApplied = patientRawTotal
|
|
1217
|
+
masterExtraApplied = percentage(patientRawTotal, masterExtra.value);
|
|
1215
1218
|
} else if (masterExtra.mode === "AMOUNT") {
|
|
1216
1219
|
masterExtraApplied = Math.min(masterExtra.value, patientRawTotal);
|
|
1217
1220
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1083,6 +1083,9 @@ var maybeStep = (v, stepwise, fmt, p) => stepwise ? applyRound(v, fmt, p) : v;
|
|
|
1083
1083
|
function clamp(n, min, max) {
|
|
1084
1084
|
return Math.max(min, Math.min(max, n));
|
|
1085
1085
|
}
|
|
1086
|
+
var percentage = (amount, percentage2) => {
|
|
1087
|
+
return amount * percentage2 / 100;
|
|
1088
|
+
};
|
|
1086
1089
|
function calculateBillingFromChildren(inputs, masterExtra, options = {}) {
|
|
1087
1090
|
const stepwise = options.calculationMethod === "STEP_WISE";
|
|
1088
1091
|
const lineFmt = options.lineRound ?? RoundFormat.TO_FIXED;
|
|
@@ -1091,7 +1094,7 @@ function calculateBillingFromChildren(inputs, masterExtra, options = {}) {
|
|
|
1091
1094
|
const children = inputs.map((it) => {
|
|
1092
1095
|
let baseRate = it.rate;
|
|
1093
1096
|
if (it.addonPercentage) {
|
|
1094
|
-
baseRate = baseRate + baseRate
|
|
1097
|
+
baseRate = baseRate + percentage(baseRate, it.addonPercentage);
|
|
1095
1098
|
baseRate = maybeStep(baseRate, stepwise, lineFmt, precision);
|
|
1096
1099
|
}
|
|
1097
1100
|
const subtotal = applyRound(it.qty * baseRate, lineFmt, precision);
|
|
@@ -1101,13 +1104,13 @@ function calculateBillingFromChildren(inputs, masterExtra, options = {}) {
|
|
|
1101
1104
|
if (masterExtra.coPayMode === "PERCENTAGE-AMOUNT") {
|
|
1102
1105
|
const copayType = it.coPaymentType ?? "AMOUNT";
|
|
1103
1106
|
const copayValue = it.coPayValue ?? 0;
|
|
1104
|
-
copayAmount2 = copayType === "PERCENTAGE" ? basePreTax
|
|
1107
|
+
copayAmount2 = copayType === "PERCENTAGE" ? percentage(basePreTax, copayValue) : Math.min(copayValue, basePreTax);
|
|
1105
1108
|
}
|
|
1106
1109
|
const dMode = it.discountMode ?? "AMOUNT";
|
|
1107
1110
|
const dVal = it.discountValue ?? 0;
|
|
1108
1111
|
const tMethod = it.taxMethod ?? "NONE";
|
|
1109
1112
|
const tVal = Math.max(0, it.taxValue ?? 0);
|
|
1110
|
-
let baseAfterTaxDisc =
|
|
1113
|
+
let baseAfterTaxDisc = basePreTax;
|
|
1111
1114
|
let discountValue = 0;
|
|
1112
1115
|
if (tMethod === "INCLUSIVE") {
|
|
1113
1116
|
const inclusiveTaxMultiplier = (100 + tVal) / 100;
|
|
@@ -1117,12 +1120,12 @@ function calculateBillingFromChildren(inputs, masterExtra, options = {}) {
|
|
|
1117
1120
|
if (dMode === "AMOUNT") {
|
|
1118
1121
|
discountValue = dVal;
|
|
1119
1122
|
} else if (dMode === "PERCENTAGE") {
|
|
1120
|
-
discountValue = baseAfterTaxDisc
|
|
1123
|
+
discountValue = percentage(baseAfterTaxDisc, dVal);
|
|
1121
1124
|
}
|
|
1122
1125
|
discountValue = maybeStep(discountValue, stepwise, lineFmt, precision);
|
|
1123
1126
|
let afterDisc = Math.max(0, baseAfterTaxDisc - discountValue);
|
|
1124
1127
|
afterDisc = maybeStep(afterDisc, stepwise, lineFmt, precision);
|
|
1125
|
-
let calculatedTax =
|
|
1128
|
+
let calculatedTax = percentage(afterDisc, tVal);
|
|
1126
1129
|
calculatedTax = maybeStep(calculatedTax, stepwise, lineFmt, precision);
|
|
1127
1130
|
let grossAmount2 = afterDisc + calculatedTax;
|
|
1128
1131
|
grossAmount2 = maybeStep(grossAmount2, stepwise, lineFmt, precision);
|
|
@@ -1163,7 +1166,7 @@ function calculateBillingFromChildren(inputs, masterExtra, options = {}) {
|
|
|
1163
1166
|
const patientRawTotal = grossAmount - copayAmount;
|
|
1164
1167
|
let masterExtraApplied = 0;
|
|
1165
1168
|
if (masterExtra.mode === "PERCENTAGE") {
|
|
1166
|
-
masterExtraApplied = patientRawTotal
|
|
1169
|
+
masterExtraApplied = percentage(patientRawTotal, masterExtra.value);
|
|
1167
1170
|
} else if (masterExtra.mode === "AMOUNT") {
|
|
1168
1171
|
masterExtraApplied = Math.min(masterExtra.value, patientRawTotal);
|
|
1169
1172
|
}
|