expenses_calculator
v1.0.0
Published
This package calculates monthly expenses and rent, including per-person payable amounts and balance payments.
Downloads
81
Readme
Monthly Room Rent Calculator
This package calculates monthly expenses and rent, including per-person payable amounts and balance payments.
Installation
Run the following command to install the package:
'npm i expenses_calculator'
## Functions and Usage
## 1. Calculate Total Payable
import { calculateTotalPayable } from 'expenses_calculator';
const result = calculateTotalPayable(expense, rent);
console.log(result);
* Parameters:
* expense (default 0): Monthly expenses.
* rent (default 0): Monthly rent.
* Output: Total payable amount (expenses + rent).
## 2. Calculate Per-Person Pay
import { calculateBalancePay } from 'expenses_calculator';
const result = calculateBalancePay(totalPayable, noOfPersons);
console.log(result);
* Parameters:
* totalPayable (default 0): Total payable amount.
* noOfPersons (default 1): Total number of persons.
* Output: Amount each person should pay.
## 3. Calculate Per-Person Paid Balance
import { perPersonPaidblace } from 'expenses_calculator';
const result = perPersonPaidblace(paid, balance, name);
console.log(result);
* Parameters:
* paid (default 0): Amount the person has already paid.
* balance (default 0): Total balance the person should pay.
* name (default 'person'): Name of the person.
* Output: An object with:
* name: Name of the person.
* paid: Amount paid by the person.
* balanceToPay: Balance left to pay.
## Example Usage
import { calculateTotalPayable, calculateBalancePay, perPersonPaidblace } from "expenses_calculator";
const expense = 4000;
const rent = 16000;
const totalPayable = calculateTotalPayable(expense, rent);
console.log("Total Payable:", totalPayable);
const perPersonPay = calculateBalancePay(totalPayable, 4);
console.log("Per-Person Pay:", perPersonPay);
const result = perPersonPaidblace(5000, perPersonPay, "Alice");
console.log(`${result.name} has paid ${result.paid} and has ${result.balanceToPay} left to pay.`);
## Parameters Summary
Parameter Description Default Value
expense Monthly expenses 0
rent Monthly rent 0
totalPayable Total payable (expenses + rent) 0
noOfPersons Total number of persons 1
paid Amount already paid by person 0
balance Balance person needs to pay 0
name Name of the person 'person'