Hello from MCP server
/* TNFR Implied Cost Pricing Formula
*
* This formula calculates prices based on implied hourly rates
* and allows for additional time and material adjustments.
*
* Key difference from legacy: The implied hourly rate is only used
* for ADDITIONAL hours, not the base hours. This ensures the base
* price matches the legacy formula when no adjustments are made.
*/
export default () => {
return {
vars: {
materialCostBase: 0,
timeCostBase: 0,
additionalTime: 0,
additionalMaterial: 0,
hourlyFee: 5.262,
standardDiscount: 0.5,
offerModifier: 1,
salesTax: 1,
serviceCallFee: 0,
saDiscount: 1,
multiplier: 1,
markupScale: [
[6.571805718, 1.65],
[3.943083431, 1.75],
[2.628722287, 2],
[1.577233372, 2.25],
[1.051488915, 2.5],
[0.5257444574, 2.75],
[0.2628722287, 3],
[0.1314361144, 3.5],
[0, 4],
],
},
derivedVars: {
// Steps 1-7: Original calculation up to tier price
materialWithTax: 0,
materialMarkup: 2.75,
materialFee: 0,
timeFee: 0,
combinedFee: 0,
feeWithTrip: 0,
tierPrice: 0,
// Steps 8-9: Implied rate calculation
impliedTimeFee: 0,
impliedHourlyRate: 0,
// Steps 10-12: Additional material calculation
additionalMaterialTaxed: 0,
additionalMaterialMarkup: 2.75,
additionalMaterialFee: 0,
// Steps 13-16: Final calculation
additionalTimeFee: 0,
totalMaterialFee: 0,
tierPlusTime: 0,
leveledPrice: 0,
finalPrice: 0,
},
operations: [
// Step 1: Taxed Material Cost
{
op: "mult",
in1: "materialCostBase",
in2: "salesTax",
out: "materialWithTax",
},
// Step 2: Markup Multiplier
{
op: "scale",
in1: "markupScale",
in2: "materialWithTax",
out: "materialMarkup",
},
// Step 3: Material Fee
{
op: "mult",
in1: "materialMarkup",
in2: "materialWithTax",
out: "materialFee",
},
// Step 4: Time Fee
{
op: "mult",
in1: "timeCostBase",
in2: "hourlyFee",
out: "timeFee",
},
// Step 5: Combined Fee
{
op: "add",
in1: "timeFee",
in2: "materialFee",
out: "combinedFee",
},
// Step 6: Trip Fee Added
{
op: "add",
in1: "combinedFee",
in2: "serviceCallFee",
out: "feeWithTrip",
},
// Step 7: Tier Price
{
op: "mult",
in1: "feeWithTrip",
in2: "multiplier",
out: "tierPrice",
},
// Step 8: Implied Time Fee
{
op: "sub",
in1: "tierPrice",
in2: "materialFee",
out: "impliedTimeFee",
},
// Step 9: Implied Hourly Rate
{
op: "div",
in1: "impliedTimeFee",
in2: "timeCostBase",
out: "impliedHourlyRate",
},
// Step 10: Additional Material Taxed
{
op: "mult",
in1: "additionalMaterial",
in2: "salesTax",
out: "additionalMaterialTaxed",
},
// Step 11: Additional Material Markup
{
op: "scale",
in1: "markupScale",
in2: "additionalMaterialTaxed",
out: "additionalMaterialMarkup",
},
// Step 12: Additional Material Fee
{
op: "mult",
in1: "additionalMaterialMarkup",
in2: "additionalMaterialTaxed",
out: "additionalMaterialFee",
},
// Step 13: Additional Time Fee (only for additional hours)
{
op: "mult",
in1: "additionalTime",
in2: "impliedHourlyRate",
out: "additionalTimeFee",
},
// Step 14: Total Material Fee
{
op: "add",
in1: "materialFee",
in2: "additionalMaterialFee",
out: "totalMaterialFee",
},
// Step 15: Add tier price and additional time fee
{
op: "add",
in1: "tierPrice",
in2: "additionalTimeFee",
out: "tierPlusTime",
},
// Step 16: Leveled Price (tierPlusTime + additionalMaterialFee)
{
op: "add",
in1: "tierPlusTime",
in2: "additionalMaterialFee",
out: "leveledPrice",
},
// Step 17: Final Price (with SA Discount)
{
op: "mult",
in1: "leveledPrice",
in2: "saDiscount",
out: "finalPrice",
},
],
};
};