increment.js

Overview

This file defines the Increment class, which models a discrete time interval within a meeting for the purpose of calculating incremental costs based on attendee count and average wage. Each Increment instance represents a segment of time with fixed parameters, capturing the start and stop timestamps, elapsed time in seconds, number of attendees, average hourly wage, and the computed cost for that interval. It also maintains a running total cost that accumulates all prior increments' costs.

The Increment class is a fundamental building block within the Incremental Cost Calculation strategy of the Real-Time Meeting Cost Tracking module (79640). By encapsulating time slices and cost computations, it enables precise tracking of meeting expenses even as parameters change dynamically throughout the meeting lifecycle.


Class: Increment

Description

The Increment class encapsulates a single time slice of a meeting during which attendee count and average wage are constant. It calculates the elapsed time in seconds and derives the cost for that interval by prorating the hourly wage to a per-second rate.


Properties

Property

Type

Description

startTime

Date or timestamp

The start time of the increment interval.

stopTime

Date or timestamp

The stop time of the increment interval.

elapsedTime

number

The duration of the increment in seconds, computed as (stopTime - startTime) / 1000.

attendeeCount

number

Number of attendees present during this increment.

averageWage

number

Average hourly wage of attendees during this increment.

cost

number

The calculated cost for this increment interval based on attendees, wage, and elapsed time.

totalCost

number

Cumulative total cost up to and including this increment.

purpose

string

Optional description or purpose of the meeting increment.


Constructor

constructor(
  currentIncrementStartTime, 
  currentIncrementStopTime, 
  currentIncrementAttendeeCount, 
  currentIncrementAverageWage, 
  previousIncrementTotalCost = 0.00, 
  purpose = ''
)

Parameters

Name

Type

Description

currentIncrementStartTime

Date or timestamp

The start time of the increment interval.

currentIncrementStopTime

Date or timestamp

The stop time of the increment interval.

currentIncrementAttendeeCount

number

The number of attendees during this increment.

currentIncrementAverageWage

number

The average hourly wage of the attendees during this increment.

previousIncrementTotalCost

number

The cumulative total cost from all prior increments; defaults to 0.

purpose

string

Optional string describing the purpose of the increment or meeting segment.

Behavior


Usage Example

import Increment from './increment.js';
import { SECONDS_PER_HOUR } from '../constants.js';

const startTime = new Date('2024-06-01T10:00:00Z');
const stopTime = new Date('2024-06-01T10:15:00Z');
const attendees = 5;
const avgWage = 60.00; // $60/hr
const previousTotal = 100.00; // prior increments total cost
const purpose = 'Project Planning';

const increment = new Increment(
  startTime,
  stopTime,
  attendees,
  avgWage,
  previousTotal,
  purpose
);

console.log(increment.elapsedTime); // 900 seconds (15 minutes)
console.log(increment.cost);        // cost for this 15-minute increment
console.log(increment.totalCost);  // cumulative cost including this increment

Implementation Details


Interaction with Other System Components


Mermaid Class Diagram

classDiagram
class Increment {
+startTime
+stopTime
+elapsedTime
+attendeeCount
+averageWage
+cost
+totalCost
+purpose
+constructor()
}

This diagram highlights that Increment is a single class with properties related to time, attendees, wage, cost calculation, and purpose.


Summary

The Increment class is a concise, focused data model representing a single timed segment of a meeting for granular cost calculation. It supports the accurate, incremental tracking of meeting expenses by encapsulating elapsed time, attendees, wage, and cost information. This design underpins the cost calculation mechanisms of the broader meeting lifecycle and visualization modules, enabling precise and flexible financial tracking of meetings over time.