Small factories often ask one question before buying equipment: how many months until this machine pays for itself? It is a nice little problem to code, because the maths is simple but the inputs need care.
In this post we build a tiny, dependency-free payback calculator, using carton sealing machines as the example.
The formula
monthly_value = labour_saved + tape_saved - running_cost
payback_months = machine_price / monthly_value
Labour saved comes from the time difference per carton:
hours_saved_per_month = cartons_per_day * (manual_sec - machine_sec) / 3600 * working_days
labour_saved = hours_saved_per_month * cost_per_hour
The code
function payback({ price, cartonsPerDay, manualSec, machineSec,
workingDays, costPerHour, tapeSavedPerMonth = 0,
runningCostPerMonth = 0 }) {
if (machineSec >= manualSec) throw new Error("Machine must be faster than manual taping");
const hoursSaved = cartonsPerDay * (manualSec - machineSec) / 3600 * workingDays;
const monthlyValue = hoursSaved * costPerHour + tapeSavedPerMonth - runningCostPerMonth;
if (monthlyValue <= 0) return { monthlyValue, months: Infinity };
return { monthlyValue: Math.round(monthlyValue), months: +(price / monthlyValue).toFixed(1) };
}
console.log(payback({
price: 69730, // semi automatic sealer, before GST (INR)
cartonsPerDay: 400,
manualSec: 30,
machineSec: 12,
workingDays: 26,
costPerHour: 100,
runningCostPerMonth: 600
}));
// -> { monthlyValue: 4600, months: 15.2 }
Feeding it real prices
Hard-coding one price is fine for a demo, but a real tool should let the user pick a model. Here is a small price table (INR, before 18% GST) you can drop into a <select>:
const models = [
{ name: "Compact sealer", price: 57500 },
{ name: "Semi automatic top & bottom", price: 69730 },
{ name: "102TUS (small cartons)", price: 98560 },
{ name: "102TU (standard cartons)", price: 107520 },
{ name: "102TR pneumatic, auto size", price: 250880 },
];
const withGst = p => Math.round(p * 1.18);
Things worth handling
-
Guard against zero or negative value. If running costs beat the savings, payback is "never", so return
Infinityinstead of a negative number. - Keep GST separate. Businesses that claim input tax credit usually compare ex-GST prices.
- Be honest in the UI. Savings are only real if the freed staff time is used elsewhere or overtime falls, so label the result as an estimate.
The price figures above come from PackForge's published carton sealing machine price list. Swap in your own numbers and you have a useful little tool for any equipment purchase.
Top comments (0)