@retaila/shared-types 2.0.11 → 2.0.14
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.d.mts +34 -3
- package/dist/index.d.ts +34 -3
- package/dist/index.js +82 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1065,6 +1065,13 @@ var BillingInterval = /* @__PURE__ */ ((BillingInterval2) => {
|
|
|
1065
1065
|
BillingInterval2["ANNUAL"] = "ANNUAL";
|
|
1066
1066
|
return BillingInterval2;
|
|
1067
1067
|
})(BillingInterval || {});
|
|
1068
|
+
var PaymentFrequency = /* @__PURE__ */ ((PaymentFrequency2) => {
|
|
1069
|
+
PaymentFrequency2["MONTHLY"] = "MONTHLY";
|
|
1070
|
+
PaymentFrequency2["QUARTERLY"] = "QUARTERLY";
|
|
1071
|
+
PaymentFrequency2["SEMIANNUAL"] = "SEMIANNUAL";
|
|
1072
|
+
PaymentFrequency2["ANNUAL"] = "ANNUAL";
|
|
1073
|
+
return PaymentFrequency2;
|
|
1074
|
+
})(PaymentFrequency || {});
|
|
1068
1075
|
var AccountServicePlanStatus = /* @__PURE__ */ ((AccountServicePlanStatus2) => {
|
|
1069
1076
|
AccountServicePlanStatus2["ACTIVE"] = "ACTIVE";
|
|
1070
1077
|
AccountServicePlanStatus2["ENDED"] = "ENDED";
|
|
@@ -1085,6 +1092,61 @@ var ChargeStatus = /* @__PURE__ */ ((ChargeStatus2) => {
|
|
|
1085
1092
|
return ChargeStatus2;
|
|
1086
1093
|
})(ChargeStatus || {});
|
|
1087
1094
|
|
|
1095
|
+
// src/serviceBilling/billingSchedule.ts
|
|
1096
|
+
var SERVICE_BILLING_FREE_DAYS_VALUES = [0, 7, 15, 30, 60];
|
|
1097
|
+
function normalizeServiceBillingFreeDays(value) {
|
|
1098
|
+
const n = value == null || value === "" ? 0 : Number(value);
|
|
1099
|
+
if (!Number.isFinite(n)) return 0;
|
|
1100
|
+
return SERVICE_BILLING_FREE_DAYS_VALUES.includes(n) ? n : 0;
|
|
1101
|
+
}
|
|
1102
|
+
function contractTermMonths(contract) {
|
|
1103
|
+
switch (contract) {
|
|
1104
|
+
case "MONTHLY" /* MONTHLY */:
|
|
1105
|
+
return 1;
|
|
1106
|
+
case "SEMIANNUAL" /* SEMIANNUAL */:
|
|
1107
|
+
return 6;
|
|
1108
|
+
case "ANNUAL" /* ANNUAL */:
|
|
1109
|
+
return 12;
|
|
1110
|
+
default:
|
|
1111
|
+
return 1;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
function paymentFrequencyMonths(freq) {
|
|
1115
|
+
switch (freq) {
|
|
1116
|
+
case "MONTHLY" /* MONTHLY */:
|
|
1117
|
+
return 1;
|
|
1118
|
+
case "QUARTERLY" /* QUARTERLY */:
|
|
1119
|
+
return 3;
|
|
1120
|
+
case "SEMIANNUAL" /* SEMIANNUAL */:
|
|
1121
|
+
return 6;
|
|
1122
|
+
case "ANNUAL" /* ANNUAL */:
|
|
1123
|
+
return 12;
|
|
1124
|
+
default:
|
|
1125
|
+
return 1;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
function subscriptionInstallmentCount(contract, payment) {
|
|
1129
|
+
const cm = contractTermMonths(contract);
|
|
1130
|
+
const pm = paymentFrequencyMonths(payment);
|
|
1131
|
+
if (pm > cm) return null;
|
|
1132
|
+
if (cm % pm !== 0) return null;
|
|
1133
|
+
return cm / pm;
|
|
1134
|
+
}
|
|
1135
|
+
function resolveEffectivePaymentFrequency(contract, paymentFrequency) {
|
|
1136
|
+
if (paymentFrequency != null) return paymentFrequency;
|
|
1137
|
+
return contract;
|
|
1138
|
+
}
|
|
1139
|
+
function subscriptionAmountPerInstallment(contractTotalAmount, contract, payment) {
|
|
1140
|
+
const n = subscriptionInstallmentCount(contract, payment);
|
|
1141
|
+
if (n == null || n <= 0) return null;
|
|
1142
|
+
return Math.round(contractTotalAmount / n * 100) / 100;
|
|
1143
|
+
}
|
|
1144
|
+
function aiCreditsPerSubscriptionInstallment(creditsIncludedPerContract, contract, payment) {
|
|
1145
|
+
const n = subscriptionInstallmentCount(contract, payment);
|
|
1146
|
+
if (n == null || n <= 0) return creditsIncludedPerContract;
|
|
1147
|
+
return Math.round(creditsIncludedPerContract / n);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1088
1150
|
// src/holiday/types.ts
|
|
1089
1151
|
var HolidayType = /* @__PURE__ */ ((HolidayType2) => {
|
|
1090
1152
|
HolidayType2["NON_WORKING"] = "NON_WORKING";
|
|
@@ -1169,6 +1231,7 @@ export {
|
|
|
1169
1231
|
OrderStatus,
|
|
1170
1232
|
PageType,
|
|
1171
1233
|
PaymentCardBrandKey,
|
|
1234
|
+
PaymentFrequency,
|
|
1172
1235
|
PaymentMethodType,
|
|
1173
1236
|
PaymentStatus,
|
|
1174
1237
|
ProductAttributeStatus,
|
|
@@ -1185,6 +1248,7 @@ export {
|
|
|
1185
1248
|
PubSubTopics,
|
|
1186
1249
|
RoundingMethod,
|
|
1187
1250
|
RoundingRule,
|
|
1251
|
+
SERVICE_BILLING_FREE_DAYS_VALUES,
|
|
1188
1252
|
SUPPORTED_COUNTRIES,
|
|
1189
1253
|
StandardCategoryStatus,
|
|
1190
1254
|
StoreBannerStatus,
|
|
@@ -1199,6 +1263,8 @@ export {
|
|
|
1199
1263
|
SupportConversationStatus,
|
|
1200
1264
|
SupportConversationVisibility,
|
|
1201
1265
|
TrafficSource,
|
|
1266
|
+
aiCreditsPerSubscriptionInstallment,
|
|
1267
|
+
contractTermMonths,
|
|
1202
1268
|
getAccountPaymentMethodStatusInfo,
|
|
1203
1269
|
getCountryDefaults,
|
|
1204
1270
|
getCurrencySymbol,
|
|
@@ -1214,6 +1280,11 @@ export {
|
|
|
1214
1280
|
isLegacyLayout,
|
|
1215
1281
|
isSupportedCountry,
|
|
1216
1282
|
isZonedLayout,
|
|
1217
|
-
|
|
1283
|
+
normalizeServiceBillingFreeDays,
|
|
1284
|
+
parsePriceFormatPattern,
|
|
1285
|
+
paymentFrequencyMonths,
|
|
1286
|
+
resolveEffectivePaymentFrequency,
|
|
1287
|
+
subscriptionAmountPerInstallment,
|
|
1288
|
+
subscriptionInstallmentCount
|
|
1218
1289
|
};
|
|
1219
1290
|
//# sourceMappingURL=index.mjs.map
|