I am trying to build an application that automatically calculates costs given specific values. But for some reason, the output is off. Thank you in advance for any help.
profit margin and total cost is wrong
Here is the code for my profit margin and total cost:
const plancredit = 5;
const alignercredit = 5;
const plancost = 7000;
const max = Math.max(upalign, lowalign);
const planningCostA = plancredit * 1400;
const planningCostB = plancredit * 1300;
const planningCostC = plancredit * 1200;
const planningCostD = plancredit * 1000;
const totalaligner = upalign + lowalign;
const treatmentduration = max * 14;
const alignercost = (totalaligner * 1500);
const alignercosta = (totalaligner * 1400);
const alignercostb = (totalaligner * 1300);
const alignercostc = (totalaligner * 1200);
const alignercostd = (totalaligner * 1000);
const totalcost = (plancost + alignercost + other + scanfee);
const totalcosta = (plancost + alignercosta + other + scanfee);
const totalcostb = (plancost + alignercostb + other + scanfee);
const totalcostc = (plancost + alignercostc + other + scanfee);
const totalcostd = (plancost + alignercostd + other + scanfee);
<tr>
<td>Profit Margin (%)</td>
<td>${(((patcharge-totalcost) / patcharge)*100).toFixed(1)}</td>
<td>${(((patcharge-totalcosta) / patcharge)*100).toFixed(1)}</td>
<td>${(((patcharge-totalcostb) / patcharge)*100).toFixed(1)}</td>
<td>${(((patcharge-totalcostc) / patcharge)*100).toFixed(1)}</td>
<td>${(((patcharge-totalcostd) / patcharge)*100).toFixed(1)}</td>
</tr>
The total cost are off by either 500, 1000, and 2000.