27 lines
714 B
TypeScript
27 lines
714 B
TypeScript
import type { FullCusEntWithFullCusProduct } from "../../../models/cusProductModels/cusEntModels/cusEntWithProduct";
|
|
import {
|
|
cusEntToCusPrice,
|
|
entToOptions,
|
|
} from "../../productUtils/convertUtils";
|
|
import { getStartingBalance } from "../getStartingBalance";
|
|
|
|
export const cusEntToStartingBalance = ({
|
|
cusEnt,
|
|
}: {
|
|
cusEnt: FullCusEntWithFullCusProduct;
|
|
}) => {
|
|
const cusPrice = cusEntToCusPrice({ cusEnt });
|
|
const price = cusPrice?.price;
|
|
const options = entToOptions({
|
|
ent: cusEnt.entitlement,
|
|
options: cusEnt.customer_product.options,
|
|
});
|
|
|
|
return getStartingBalance({
|
|
entitlement: cusEnt.entitlement,
|
|
options,
|
|
relatedPrice: price,
|
|
productQuantity: cusEnt.customer_product.quantity,
|
|
});
|
|
};
|