Home Manual Reference Source
import Project from 'pvbid-sdk/src/domain/Project.js'
public class | source

Project

Extends:

eventemitter3~EventEmitterAdvanceEventEmitterBidEntity → Project

A Project contains multiple Bids and summations of the bid results. Projects also have statuses (ie. open/closed/win/loss), and can have assigned users

Constructor Summary

Public Constructor
public

constructor(entityData: object, projectService: ProjectService)

Creates an instance of Project.

Member Summary

Public Members
public get
public get
public get
public get

Cost Property

public get
public
public
public get

Labor Hours Property

public get

Margin Property

public get

Markup Property

public get

Markup Percent Property

public get

Price Property

public get

ProjectStatus Property

public set

projectStatus: {id: number, title: string, core_status: string, is_won: boolean}

public get
public get

Tax Property

public get

Tax Percent Property

public get

title: *

public set
public get
public get
public get
public get

Method Summary

Public Methods
public

assess()

Assess project values by summing all active bids.

public

attachBid(bid: Bid)

Attaches a Bid to the project and binds necessary events.

public

async attachUser(user: object): Promise<null>

Adds user to project.

public

bind()

Binds the "updated" event for all dependant bids.

public

async clone(): Promise<object>

Clones project and underlying bids.

public

async createBid(title: string): Promise<Bid>

Creates a new bid and attaches and attaches it to the project.

public

detachBid(bid: Bid)

Removes a Bid from the project and removes all bid event listeners.

public

async detachUser(userId: number): Promise<null>

Removes user from project

public

Disables auto saving when project or bid changes occur.

public
public

Enables auto saving after project or bid changes occur.

public
public

Exports the project's data to an object.

public

hasUser(userId: number): boolean

Determines if user is assigned to project

public

Determines if project is closed.

public

Determines if project is reconciled

public

async logChanges(entityChangeData: *)

public

async save(options: object): Promise<null>

Saves project and underlying bids.

Inherited Summary

From class AdvanceEventEmitter
public

Maximum number of events fired for the requester before events stop.

public

on(eventName: string, requesterId: string, callback: function)

public

onDelay(eventName: string, ms: number, requesterId: string, callback: function)

public

removeListenerByRequester(eventName: string, requesterId: string)

Removes event listeners by event and requesterId.

From class BidEntity
public get

Determine if the entity is in an assembly

public get

Gets the id of the bid entity.

public get

Gets the bid entity title.

public set

Sets the bid entity title.

public get

Gets the bid entity type.

public abstract

assess(dependency: BidEntity)

Assesses bid entity.

public

Gets an array of depndants that rely on the bid entity.

public

Gets all the dependencies that the bid entity relies on.

public

dirty()

Flags the bid entity as dirty and to be saved.

public

Exports the internal data for the bid entity.

public

Determines if bid entity relies on a null or undefined dependency value

public

async initSaveChangeLog(originalValue: *, newValue: *, valueType: *, entityProperty: *, metaData: *): *

public

Determines of bid entity is dirty.

public

Marks the bid entity as clean.

Public Constructors

public constructor(entityData: object, projectService: ProjectService) source

Creates an instance of Project.

Override:

BidEntity#constructor

Params:

NameTypeAttributeDescription
entityData object
projectService ProjectService

Public Members

public get bids: object source

public get closedAt: string source

public get context: PVBidContext source

public get cost: number source

Cost Property

public get createdAt: string source

public isAutoSaveOn: boolean source

public isChangeLoggerOn: boolean source

public get laborHours: number source

Labor Hours Property

public get marginPercent: number source

Margin Property

public get markup: number source

Markup Property

public get markupPercent: number source

Markup Percent Property

public get price: number source

Price Property

public get projectStatus: object source

ProjectStatus Property

Properties:

NameTypeAttributeDescription
title string
core_status string
is_won boolean

public set projectStatus: {id: number, title: string, core_status: string, is_won: boolean} source

public get reconciledAt: string source

public get tax: number source

Tax Property

public get taxPercent: number source

Tax Percent Property

public get title: * source

Gets the bid entity title.

Override:

BidEntity#title

public set title source

Gets the bid entity title.

Override:

BidEntity#title

public get type: string source

Gets the bid entity type.

Override:

BidEntity#type

public get updatedAt: string source

public get users: Object[] source

Properties:

NameTypeAttributeDescription
id number
name string
timezone string

public get watts: number source

Public Methods

public assess() source

Assess project values by summing all active bids.

Override:

BidEntity#assess

Emit:

assessing

assessed

updated

public attachBid(bid: Bid) source

Attaches a Bid to the project and binds necessary events.

Params:

NameTypeAttributeDescription
bid Bid

public async attachUser(user: object): Promise<null> source

Adds user to project.

Params:

NameTypeAttributeDescription
user object

Return:

Promise<null>

public bind() source

Binds the "updated" event for all dependant bids.

public async clone(): Promise<object> source

Clones project and underlying bids.

Return:

Promise<object>

Return Properties:

NameTypeAttributeDescription
id number

The id of the new project.

public async createBid(title: string): Promise<Bid> source

Creates a new bid and attaches and attaches it to the project. This is a wrapper function for ProjectService.createBid

Params:

NameTypeAttributeDescription
title string

Return:

Promise<Bid>

public detachBid(bid: Bid) source

Removes a Bid from the project and removes all bid event listeners.

Params:

NameTypeAttributeDescription
bid Bid

public async detachUser(userId: number): Promise<null> source

Removes user from project

Params:

NameTypeAttributeDescription
userId number

Return:

Promise<null>

public disableAutoSave() source

Disables auto saving when project or bid changes occur.

public disableLoggingChanges() source

public enableAutoSave(delay: number) source

Enables auto saving after project or bid changes occur.

Params:

NameTypeAttributeDescription
delay number
  • optional
  • default: 5000

The number of milliseconds to delay auto save. Minimum is 1000ms.

Emit:

*

saving

*

saved

public enableLoggingChanges() source

public exportData(): object source

Exports the project's data to an object.

Override:

BidEntity#exportData

Return:

object

Return Properties:

NameTypeAttributeDescription
id number
title string
cost number
taxable_cost number
labor_cost number
labor_hours number
price number
margin_percent number
markup number
markup_percent number
tax number
tax_percent number
price number
actual_cost number
actual_hours number
watts number
created_at string
updated_at string
closed_at string
reconciled_at string

public hasUser(userId: number): boolean source

Determines if user is assigned to project

Params:

NameTypeAttributeDescription
userId number

Return:

boolean

public isClosed(): boolean source

Determines if project is closed.

Return:

boolean

public isReconciled(): boolean source

Determines if project is reconciled

Return:

boolean

public async logChanges(entityChangeData: *) source

Params:

NameTypeAttributeDescription
entityChangeData *

public async save(options: object): Promise<null> source

Saves project and underlying bids.

Params:

NameTypeAttributeDescription
options object
options.isAutoSave boolean

Indicate if this save is the result of an auto-save

Return:

Promise<null>

Emit:

*

saving

*

saved