@retaila/shared-types 2.0.11 → 2.0.17

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.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,55 @@ var ChargeStatus = /* @__PURE__ */ ((ChargeStatus2) => {
1085
1092
  return ChargeStatus2;
1086
1093
  })(ChargeStatus || {});
1087
1094
 
1095
+ // src/serviceBilling/billingSchedule.ts
1096
+ function contractTermMonths(contract) {
1097
+ switch (contract) {
1098
+ case "MONTHLY" /* MONTHLY */:
1099
+ return 1;
1100
+ case "SEMIANNUAL" /* SEMIANNUAL */:
1101
+ return 6;
1102
+ case "ANNUAL" /* ANNUAL */:
1103
+ return 12;
1104
+ default:
1105
+ return 1;
1106
+ }
1107
+ }
1108
+ function paymentFrequencyMonths(freq) {
1109
+ switch (freq) {
1110
+ case "MONTHLY" /* MONTHLY */:
1111
+ return 1;
1112
+ case "QUARTERLY" /* QUARTERLY */:
1113
+ return 3;
1114
+ case "SEMIANNUAL" /* SEMIANNUAL */:
1115
+ return 6;
1116
+ case "ANNUAL" /* ANNUAL */:
1117
+ return 12;
1118
+ default:
1119
+ return 1;
1120
+ }
1121
+ }
1122
+ function subscriptionInstallmentCount(contract, payment) {
1123
+ const cm = contractTermMonths(contract);
1124
+ const pm = paymentFrequencyMonths(payment);
1125
+ if (pm > cm) return null;
1126
+ if (cm % pm !== 0) return null;
1127
+ return cm / pm;
1128
+ }
1129
+ function resolveEffectivePaymentFrequency(contract, paymentFrequency) {
1130
+ if (paymentFrequency != null) return paymentFrequency;
1131
+ return contract;
1132
+ }
1133
+ function subscriptionAmountPerInstallment(contractTotalAmount, contract, payment) {
1134
+ const n = subscriptionInstallmentCount(contract, payment);
1135
+ if (n == null || n <= 0) return null;
1136
+ return Math.round(contractTotalAmount / n * 100) / 100;
1137
+ }
1138
+ function aiCreditsPerSubscriptionInstallment(creditsIncludedPerContract, contract, payment) {
1139
+ const n = subscriptionInstallmentCount(contract, payment);
1140
+ if (n == null || n <= 0) return creditsIncludedPerContract;
1141
+ return Math.round(creditsIncludedPerContract / n);
1142
+ }
1143
+
1088
1144
  // src/holiday/types.ts
1089
1145
  var HolidayType = /* @__PURE__ */ ((HolidayType2) => {
1090
1146
  HolidayType2["NON_WORKING"] = "NON_WORKING";
@@ -1169,6 +1225,7 @@ export {
1169
1225
  OrderStatus,
1170
1226
  PageType,
1171
1227
  PaymentCardBrandKey,
1228
+ PaymentFrequency,
1172
1229
  PaymentMethodType,
1173
1230
  PaymentStatus,
1174
1231
  ProductAttributeStatus,
@@ -1199,6 +1256,8 @@ export {
1199
1256
  SupportConversationStatus,
1200
1257
  SupportConversationVisibility,
1201
1258
  TrafficSource,
1259
+ aiCreditsPerSubscriptionInstallment,
1260
+ contractTermMonths,
1202
1261
  getAccountPaymentMethodStatusInfo,
1203
1262
  getCountryDefaults,
1204
1263
  getCurrencySymbol,
@@ -1214,6 +1273,10 @@ export {
1214
1273
  isLegacyLayout,
1215
1274
  isSupportedCountry,
1216
1275
  isZonedLayout,
1217
- parsePriceFormatPattern
1276
+ parsePriceFormatPattern,
1277
+ paymentFrequencyMonths,
1278
+ resolveEffectivePaymentFrequency,
1279
+ subscriptionAmountPerInstallment,
1280
+ subscriptionInstallmentCount
1218
1281
  };
1219
1282
  //# sourceMappingURL=index.mjs.map