# @kebs/project-metrics

> > Nodejs library for calculating the metrics for Project Governance

Latest version **1.0.10** (published 2021-10-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install @kebs/project-metrics
pnpm add @kebs/project-metrics
yarn add @kebs/project-metrics
bun add @kebs/project-metrics
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.10 |
| Published | 2021-10-01 |
| First published | 2021-09-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 26.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | iamgokulnath |
| Maintainers | iamgokulnath |

## Links

- npm: https://www.npmjs.com/package/@kebs/project-metrics
- npm.io page: https://npm.io/package/@kebs/project-metrics

## Dependencies (3)

- [moment](https://npm.io/package/moment.md) ^2.29.1
- [fast-sort](https://npm.io/package/fast-sort.md) ^3.0.2
- [underscore](https://npm.io/package/underscore.md) ^1.13.1

## Recent versions

- 1.0.10 (latest) — 2021-10-01
- 1.0.9 — 2021-10-01
- 1.0.8 — 2021-10-01
- 1.0.7 — 2021-10-01
- 1.0.6 — 2021-09-30
- 1.0.5 — 2021-09-30
- 1.0.4 — 2021-09-30
- 1.0.3 — 2021-09-30
- 1.0.2 — 2021-09-30
- 1.0.1 — 2021-09-30

## README

# [Project Metrics: Node.js Client](#)

> Nodejs library for calculating the metrics for Project Governance

### @kebs/project-metrics allows you to calculate the following metrics:

- [Planned Value](#) - Budgeted cost for the work scheduled to be done.
- [Earned Value](#) - Budgeted cost for the work done in the project.
- [Cost Performance Index](#) - A measure of cost efficiency, expressed as the ratio of earned value to actual cost.
- [Cost Variance](#) - Process of evaluating the financial performance of your project.
- [Schedule Performance Index](#) - A measure of schedule efficiency, expressed as the ratio of earned value to planned value.
- [Schedule Variance](#) - Indicates how much a project is ahead or behind schedule.

### Installing the library

```bash
$ npm install @kebs/project-metrics
```

## Calculate the project progress

```javascript
// Imports the library
const projectmetric = require("@kebs/project-metrics");

/**
 * --------------------------- SAMPLE INPUT ---------------------------- 
    const "plan": [
        {
            "id": "1",
            "wbs": "1",
            "title": "Prepare",
            "plannedduration": "",
            "plannedweightage": 30,
            "actualweightage": "",
            "plannedfrom": "",
            "plannedto": "",
            "status": "",
            "assignedto": ""
        },
        {
            "id": "2",
            "wbs": "1.1",
            "title": "System Preparation",
            "plannedduration": "40",
            "plannedweightage": 10,
            "actualweightage": "",
            "plannedfrom": "2021-09-27",
            "plannedto": "2021-10-01",
            "status": "Completed",
            "assignedto": "101"
        },
        {
            "id": "3",
            "wbs": "1.1.1",
            "title": "System Creation",
            "plannedduration": "24",
            "plannedweightage": 10,
            "actualweightage": 10,
            "plannedfrom": "2021-09-23",
            "plannedto": "2021-09-25",
            "status": "Completed",
            "assignedto": "101"
        },
        {
            "id": "4",
            "wbs": "1.2",
            "title": "Stakeholder Onboarding",
            "plannedduration": "40",
            "plannedweightage": 20,
            "actualweightage": "",
            "plannedfrom": "2021-09-27",
            "plannedto": "2021-10-01",
            "status": "New",
            "assignedto": "103"
        },
        {
            "id": "5",
            "wbs": "2",
            "title": "Explore",
            "plannedduration": "",
            "plannedweightage": 70,
            "actualweightage": "",
            "plannedfrom": "",
            "plannedto": "",
            "status": "",
            "assignedto": ""
        },
        {
            "id": "6",
            "wbs": "2.1",
            "title": "Unit Testing",
            "plannedduration": "80",  
            "plannedweightage": 70,
            "actualweightage": "",
            "plannedfrom": "2021-09-19",
            "plannedto": "2021-09-28",
            "status": "Active",
            "assignedto": "102"
        }
    ];

    var configurations = {
      completedstatus: "",              
      activestatus: "Active",           // Status value which indicates that the item is currently in progress
      durationunit: "",                 
      activepercentagecompletion: 20,   // Percentage of completion to be considered for "Active" items
      progresstype: ""                  // Specify which attribute to consider for calculating the overall project progress
    };
*/

// To calculate the planned value
const projectprogress = projectmetric.calculateProjectProgress(plan, configurations);
```

**'progresstype'** can be either one of the following:
- weightage (default)
- duration
- storypoint
- cost

Also note that, planned and actual fields for the specified progress metric must be available in the 'plan' data. **For example, if the progresstype is 'weightage', then 'plan' data must contain 'plannedweightage' and 'actualweightage' fields**

## Calculate the project metrics

```javascript
// Imports the library
const projectmetric = require("@kebs/project-metrics");

/**
 * --------------------------- SAMPLE INPUT ---------------------------- 
    const users = [
        {
            "id": "101",
            "fullname": "Andrew Strauss",
            "salary": "100"
        },
        {
            "id": "102",
            "fullname": "Peter Roddick",
            "salary": "150"
        },
        {
            "id": "103",
            "fullname": "Mark Forest",
            "salary": "175"
        }
    ];
    const plan = [
        {
            "id": "1",
            "wbs": "1",
            "title": "Prepare",
            "plannedduration": "",
            "plannedfrom": "",
            "plannedto": "",
            "status": "",
            "assignedto": ""
        },
        {
            "id": "2",
            "wbs": "1.1",
            "title": "System Preparation",
            "plannedduration": "40",
            "plannedfrom": "2021-09-27",
            "plannedto": "2021-10-01",
            "status": "Completed",
            "assignedto": "101"
        },
        {
            "id": "3",
            "wbs": "1.1.1",
            "title": "System Creation",
            "plannedduration": "24",
            "plannedfrom": "2021-09-23",
            "plannedto": "2021-09-25",
            "status": "Completed",
            "assignedto": "101"
        },
        {
            "id": "4",
            "wbs": "1.2",
            "title": "Stakeholder Onboarding",
            "plannedduration": "40",
            "plannedfrom": "2021-09-27",
            "plannedto": "2021-10-01",
            "status": "New",
            "assignedto": "103"
        },
        {
            "id": "5",
            "wbs": "2",
            "title": "Explore",
            "plannedduration": "",
            "plannedfrom": "",
            "plannedto": "",
            "status": "",
            "assignedto": ""
        },
        {
            "id": "6",
            "wbs": "2.1",
            "title": "Unit Testing",
            "plannedduration": "80",  
            "plannedfrom": "2021-09-19",
            "plannedto": "2021-09-28",
            "status": "Active",
            "assignedto": "102"
        }
    ];
    var configurations = {
      completedstatus: "Completed",     // Status value which indicates the completion of an item
      activestatus: "Active",           // Status value which indicates that the item is currently in progress
      durationunit: "hours",            // Unit of the plannedduration field ("hours" or "days")
      activepercentagecompletion: 20,   // Percentage of completion to be considered for "Active" items
      progresstype: ""
    };
*/

// To calculate the planned value
const plannedvalue = projectmetric.calculatePV(plan, users, configurations);

// To calculate the earned value
const earnedvalue = projectmetric.calculateEV(plan, users, configurations);

// To calculate the cost performance index
const costperformanceindex = projectmetric.calculateCPI(earnedvalue, actualcost);

// To calculate the cost variance
const costvariance = projectmetric.calculateCV(earnedvalue, actualcost);

// To calculate the schedule performance index
const scheduleperformanceindex = projectmetric.calculateSPI(earnedvalue, plannedvalue);

// To calculate the schedule variance
const schedulevariance = projectmetric.calculateSV(earnedvalue, plannedvalue);
```

Key points to be noted
- Status values present in the "configurations" key must be present in the "status" key of the "plan" data
- Actual cost must be of number type

## License

Apache Version 2.0

---
_Source: https://npm.io/package/@kebs/project-metrics · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
