net-profit-calculator
v1.0.1
Published
A simple profit calculator utility function for financial analysis.
Readme
💰 Profit Calculator
A simple and lightweight Node.js utility to calculate business profitability, including Revenue, COGS, Gross Profit, EBIT, EBITDA, Tax, and Net Profit — all in one function.
Perfect for startups, finance dashboards, or anyone analyzing product-level profit margins.
🚀 Installation
npm install net-profit-calculator
const { calculateProfit } = require('net-profit-calculator');
// Example Input
const input = {
sellingPrice: 1000, // ₹ per product
quantity: 100, // total products sold
costPerUnit: 350, // cost to make one product
adExpense: 15000,
salary: 20000,
rent: 10000,
otherExpense: 5000,
interest: 1000,
depreciation: 2000,
amortization: 1000,
taxRate: 30 // in %
};
// Calculation
const result = calculateProfit(input);
console.log("📊 Profit Analysis Report:");
console.table(result);
🧮 Example Output
📊 Profit Analysis Report:
┌────────────────────┬─────────────┐
│ (index) │ Values │
├────────────────────┼─────────────┤
│ revenue │ 100000 │
│ cogs │ 35000 │
│ grossProfit │ 65000 │
│ operatingExpense │ 50000 │
│ EBIT │ 15000 │
│ EBITDA │ 18000 │
│ tax │ 4200 │
│ netProfit │ 9800 │
│ profitMargin │ '9.80%' │
└────────────────────┴─────────────┘
🧠 Formula Reference
Term Formula Description
Revenue sellingPrice × quantity Total money from sales
COGS costPerUnit × quantity Cost of making the products
Gross Profit Revenue - COGS Profit before expenses
OPEX adExpense + salary + rent + otherExpense Operating costs
EBIT Gross Profit - OPEX Earnings before interest & tax
EBITDA EBIT + depreciation + amortization Profit before depreciation & amortization
Tax (EBIT - interest) × (taxRate / 100) Corporate tax calculation
Net Profit EBIT - interest - tax Final profit after all expenses
Profit Margin (Net Profit / Revenue) × 100 Percentage of revenue retained as profit
⚙️ Features
📈 Calculates complete business profitability chain
💼 Ideal for product, startup, and finance analysis
🧩 Works with Node.js projects easily
🪶 Lightweight and dependency-free
🧮 Easy to customize and extend
🧑💻 Author
Hemant Sharma