    import Project from 'pvbid-sdk/src/domain/Project.js'

public class | source

# Project

#### Extends:

eventemitter3~EventEmitter → AdvanceEventEmitter → BidEntity → 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 | bids: object |
public get | closedAt: string |
public get | context: PVBidContext |
public get | cost: number Cost Property |
public get | createdAt: string |
public get | laborHours: number Labor Hours Property |
public get | marginPercent: number Margin Property |
public get | markup: number Markup Property |
public get | markupPercent: number Markup Percent Property |
public get | predictionModels: * |
public get | price: number Price Property |
public set | projectStatus: {id: number, title: string, core_status: string, is_won: boolean} |
public get | projectStatus: object ProjectStatus Property |
public get | reconciledAt: string |
public get | tax: number Tax Property |
public get | taxPercent: number Tax Percent Property |
public set | title |
public get | title: * |
public get | type: string |
public get | updatedAt: string |
public get | users: Object[] |
public get | watts: number |

## 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 | enableAutoSave(delay: number) Enables auto saving after project or bid changes occur. |
public | exportData(): object Exports the project's data to an object. |
public | hasUser(userId: number): boolean Determines if user is assigned to project |
public | isClosed(): boolean Determines if project is closed. |
public | isReconciled(): boolean Determines if project is reconciled |
public | async save(): Promise<null> Saves project and underlying bids. |

## Inherited Summary

From class AdvanceEventEmitter
public | maxEvents: number 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 | id: number Gets the id of the bid entity. |
public get | title: string Gets the bid entity title. |
public set | title: string Sets the bid entity title. |
public get | type: string Gets the bid entity type. |
public abstract | assess(dependency: BidEntity) Assesses bid entity. |
public | dependants(): BidEntity[] Gets an array of depndants that rely on the bid entity. |
public | dependencies(): BidEntity[] Gets all the dependencies that the bid entity relies on. |
public | dirty() Flags the bid entity as dirty and to be saved. |
public | exportData(): object Exports the internal data for the bid entity. |
public | hasNullDependency(field: string): boolean Determines if bid entity relies on a null or undefined dependency value |
public | isDirty(): boolean Determines of bid entity is dirty. |
public | pristine() Marks the bid entity as clean. |

## Public Constructors

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

Creates an instance of Project.

#### Override:

BidEntity#constructor

#### Params:

Name | Type | Attribute | Description
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 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 predictionModels: * source

### public get price: number source

Price Property

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

### public get projectStatus: object source

ProjectStatus Property

#### Properties:

Name | Type | Attribute | Description
title | string |  |
core_status | string |  |
is_won | boolean |  |

### public get reconciledAt: string source

### public get tax: number source

Tax Property

### public get taxPercent: number source

Tax Percent Property

### public set title source

Gets the bid entity title.

#### Override:

BidEntity#title

### public get 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:

Name | Type | Attribute | Description
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:

Name | Type | Attribute | Description
bid | Bid |  |

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

Adds user to project.

#### Params:

Name | Type | Attribute | Description
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:

Name | Type | Attribute | Description
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:

Name | Type | Attribute | Description
title | string |  |

#### Return:

Promise<Bid>

### public detachBid(bid: Bid) source

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

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |

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

Removes user from project

#### Params:

Name | Type | Attribute | Description
userId | number |  |

#### Return:

Promise<null>

### public enableAutoSave(delay: number) source

Enables auto saving after project or bid changes occur.

#### Params:

Name | Type | Attribute | Description

delay

number

- optional
- default: 5000

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

#### Emit:

* | saving
* | saved

### public exportData(): object source

Exports the project's data to an object.

#### Override:

BidEntity#exportData

#### Return:

object

#### Return Properties:

Name | Type | Attribute | Description
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:

Name | Type | Attribute | Description
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 save(): Promise<null> source

Saves project and underlying bids.

#### Return:

Promise<null>

#### Emit:

* | saving
* | saved