export default {
    methods: {
        calculateMuhandisinProfit(amount) {
            if (!amount) amount = 0;

            const tiers = this?.$page.props.muhandisin_cut_tiers;

            // figure out which tier the amount falls in
            let tier = tiers.find((tier) => {
                return amount >= tier.min && amount <= tier.max;
            });

            // if no tier is found, use the last tier
            if (!tier) {
                tier = tiers[tiers.length - 1];
            }

            // calculate the profit
            const profit = (amount * Math.abs(1 - tier.profit)).toFixed(2);

            // return the profit

            return profit > 0 ? profit : null;
        },
    },
};
