wip, built cycle utils

This commit is contained in:
John Yeo
2025-12-13 12:18:06 +00:00
parent 5888dc4994
commit 3d604a9043
102 changed files with 4854 additions and 960 deletions

View File

@@ -0,0 +1,38 @@
import { BillingType } from "../../../models/productModels/priceModels/priceEnums";
import type { Price } from "../../../models/productModels/priceModels/priceModels";
import { getBillingType } from "../priceUtils";
export const isUsagePrice = ({
price,
featureId,
}: {
price: Price;
featureId?: string;
}) => {
const billingType = getBillingType(price.config);
const isUsage =
billingType === BillingType.UsageInArrear ||
billingType === BillingType.InArrearProrated ||
billingType === BillingType.UsageInAdvance;
if (featureId) {
return isUsage && price.config.feature_id === featureId;
}
return isUsage;
};
export const isPayPerUsePrice = ({ price }: { price: Price }) => {
const billingType = getBillingType(price.config);
return (
billingType === BillingType.UsageInArrear ||
billingType === BillingType.InArrearProrated
);
};
export const isConsumablePayPerUsePrice = ({ price }: { price?: Price }) => {
if (!price) return false;
const billingType = getBillingType(price.config);
return billingType === BillingType.UsageInArrear;
};