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

Bid

Extends:

eventemitter3~EventEmitterAdvanceEventEmitterBidEntity → Bid

Bids are self assessing classes representing the totality of a bid estimate. A bid contains collections of the following type of BidEntitys: LineItem, Metric, Field, Component, Datatable, Assembly, FieldGroup, ComponentGroup.

Constructor Summary

Public Constructor
public

constructor(bidData: object, bidService: BidService)

Creates an instance of Bid.

Member Summary

Public Members
public get
public set
public get
public set
public get
public set

Overrides bid cost.

public get

Cost including Markup

public get

Cost including Tax

public get
public
public get

Persistent id of the bid.

public get

Determines if the bid is active.

public set

Sets the bid active state.

public get

Determine if the full bid and all its entities are currently loaded.

public get
public get
public set
public get

Markup Property

public set
public get
public set
public
public get
public set
public get

Tax Property

public get

Tax Percent Property

public set
public get

Gets the type of bid entity.

public get
public get

Method Summary

Public Methods
public

async addAssemblies(assemblyMapIds: number[]): Promise<null>

Adds assemblies to bid.

public

Adds a new bid variable to the bid

public

async addDynamicGroup(title: string): Promise<DynamicGroup>

Adds Dynamic Groups to bid.

public

async addField(title: string, type: string): Promise<Field>

Adds a new field to the bid.

public

Adds a new line item to the bid.

public

async addMetric(title: string): Promise<Metric>

Adds a new metric to the bid.

public
this method was deprecated.
public

assess(dependency: BidEntity, forceUpdate: boolean)

Assess bid values.

public

bind()

Binds all interconnected bid entity "update" events

public

Determines if bid can be locked by user.

public

Determines if bid can be unlocked by user.

public

Clear the locally cached values

public

Removes all event listeners for the bid entities in a bid.

public

async clone(): Promise<Bid>

Clones the current bid and returns the cloned bid.

public

async createSnapshot(title: string, description: string): Promise<object>

Creates a snapshot of current Bid data.

public

async delete(): Promise<null>

Deletes bid.

public

Flags all fields, metrics, lineItems, and components as dirty.

public

Exports the bid's data to an object.

public

Exports the bid data along with all of the bid entities included.

public

getIndicativePrice(bidPrice: *, isLow: boolean): number

Gets indicative price

public

Gets the margin of error for indicative pricing.

public

Calculates and returns the Bid Margin Percent.

public

Gets the predicted value of the bid by calculating the sum total of the predicted values for all line items

public
public

getUncategorizedLineItems(componentGroupId: number): {[id: string]}

Gets all the uncategorized Line Items by component group.

public

getWeightedNormalValue(distributionIndex: *): T | null

For each line item, get all of its weightedNormalValues return the sum of all line item's weightedNormalValues at distributionIndex

public

Calculates the weighted normal value given a set of distribution ranges.

public

Determines if a property depends on a null dependency somewhere in it's calculation

public
public

Determines if markup should also be assessed on the tax.

public

Determines if bid is in an "assessable" state.

public

Determines if indicative pricing is enabled.

public

Determines if the bid is locked.

public

isPredicted(property: string): boolean

Determines if a bid property is predicted.

public

Determines if bid can be modified by the user.

public

Determines if is a shell bid.

public
this method was deprecated.

Determines if bid is updatable by the user.

public

Determines if bid has valid dependency references and configurations..

public

async load(options: object)

Fully loads the bid with its entities (if not already loaded).

public

async lock(): Promise<null>

Locks bid, forcing read-only mode for everyone.

public

async moveToProject(project: *): Promise<*>

Moves a bid from its current project to another

public

Analyzes line items and components calculations.

public

Marks bid and all bid entities as clean.

public

reassessAll(forceReassessment: boolean)

Reassess all LineItems, Fieldss, Metricss, and {@ linkComponents}s.

public

async reassessAsync(): Promise<void>

Helper method to re-assess the bid until price converges.

public

async recover(snapshotId: number): Promise<null>

Recovers bid to previous snapshot.

public

async removeAssembly(assemblyId: number): *

Removes assembly from a bid.

public

Globally resets markup on all line items in the bid.

public
this method was deprecated. use isActive property.
public

async unlock(): Promise<null>

Unlocks bid, making it writable for those with permission.

public

Validates bid and returns a resultset of issues, if exists.

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(bidData: object, bidService: BidService) source

Creates an instance of Bid.

Override:

BidEntity#constructor

Params:

NameTypeAttributeDescription
bidData object
bidService BidService

Public Members

public get actualCost: number source

public set actualCost: number source

public get actualHours: number source

public set actualHours: number source

public get cost: number source

public set cost: number source

Overrides bid cost. Overrides are distibuted proportionally to the included line items.

public get costWithMarkup: number source

Cost including Markup

public get costWithTax: number source

Cost including Tax

public get createdAt: number source

public entities: BidEntityRelationsHelper source

public get id: number source

Persistent id of the bid. NOTE: id will soon be in alpha-numerical format

Override:

BidEntity#id

public get isActive: boolean source

Determines if the bid is active.

public set isActive: boolean source

Sets the bid active state.

public get isLoaded: boolean source

Determine if the full bid and all its entities are currently loaded. A bid cannot be edited or assessed until it is loaded. Bid can be loaded with bid.load().

public get laborHours: number source

public get marginPercent: number source

public set marginPercent: number source

public get markup: number source

Markup Property

public set markup: number source

public get markupPercent: number source

public set markupPercent: number source

public maxEvents: number source

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

Override:

AdvanceEventEmitter#maxEvents

public get price: number source

public set price: number source

public get tax: number source

Tax Property

public get taxPercent: number source

Tax Percent Property

public set taxPercent: number source

public get type: string source

Gets the type of bid entity.

Override:

BidEntity#type

public get updatedAt: number source

public get watts: number source

Public Methods

public async addAssemblies(assemblyMapIds: number[]): Promise<null> source

Adds assemblies to bid. A wrapper function for BidService.addAssemblies

Params:

NameTypeAttributeDescription
assemblyMapIds number[]

An array of assembly mapping ids to add.

Return:

Promise<null>

public addBidVariable() source

Adds a new bid variable to the bid

Throw:

Error

If bid is read only

public async addDynamicGroup(title: string): Promise<DynamicGroup> source

Adds Dynamic Groups to bid. A wrapper function for BidService.addDynamicGroup

Params:

NameTypeAttributeDescription
title string

The title of the Dynamic Group to add

Return:

Promise<DynamicGroup>

public async addField(title: string, type: string): Promise<Field> source

Adds a new field to the bid. This is a wrapper function for BidService.addField

Params:

NameTypeAttributeDescription
title string
  • optional
  • default: New Field
type string
  • optional
  • default: number

Return:

Promise<Field>

Throw:

Error

If bid is read only

public async addLineItem(title: string): Promise<LineItem> source

Adds a new line item to the bid. The added line item is uncategorized in all component groups. This is a wrapper function for BidService.addLineItem

Params:

NameTypeAttributeDescription
title string
  • optional
  • default: New Line Item

Return:

Promise<LineItem>

Throw:

Error

If bid is read only

public async addMetric(title: string): Promise<Metric> source

Adds a new metric to the bid. This is a wrapper function for BidService.addMetric

Params:

NameTypeAttributeDescription
title string
  • optional
  • default: New Metric

Return:

Promise<Metric>

Throw:

Error

If bid is read only

public applySubMarginChange() source

this method was deprecated.

public assess(dependency: BidEntity, forceUpdate: boolean) source

Assess bid values. If bid values changes, the bid will be flagged as dirty and an "updated" event will fire.

Override:

BidEntity#assess

Params:

NameTypeAttributeDescription
dependency BidEntity
  • nullable: true

The calling dependency.

forceUpdate boolean
  • optional
  • nullable: true

Force fires "update" event and flags bid as dirty.

Emit:

assessing

assessed

updated

public bind() source

Binds all interconnected bid entity "update" events

public canLock(): boolean source

Determines if bid can be locked by user.

Return:

boolean

public canUnlock(): boolean source

Determines if bid can be unlocked by user.

Return:

boolean

public clearCachedValues() source

Clear the locally cached values

public clearEntityBindings() source

Removes all event listeners for the bid entities in a bid. It does not remove any event listeners for the bid itself.

public async clone(): Promise<Bid> source

Clones the current bid and returns the cloned bid. The cloned bid is also added to the project automatically.

Return:

Promise<Bid>

public async createSnapshot(title: string, description: string): Promise<object> source

Creates a snapshot of current Bid data.

Params:

NameTypeAttributeDescription
title string
  • nullable: true
description string
  • nullable: true

Return:

Promise<object>

Returns a data object of the snapshot.

Return Properties:

NameTypeAttributeDescription
id number

The snapshot id.

title string
bid_id number
description string
is_auto boolean

A flag to indicate the snapshot was generated automatically by the PVBid system.

created_at string

Example format: 2016-04-11T21:08:05+00:00

public async delete(): Promise<null> source

Deletes bid. Wrapper function for BidService.deleteBid

Return:

Promise<null>

public dirtyAll() source

Flags all fields, metrics, lineItems, and components as dirty.

public exportData(): object source

Exports the bid's data to an object.

Override:

BidEntity#exportData

Return:

object

Return Properties:

NameTypeAttributeDescription
id number

NOTE: id will soon be in UUID format.

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
is_active boolean
is_locked boolean
created_at string
updated_at string

public exportDataWithEntities(): object source

Exports the bid data along with all of the bid entities included.

Return:

object

Exported bid data with all its entities and their config objects.

public getIndicativePrice(bidPrice: *, isLow: boolean): number source

Gets indicative price

Params:

NameTypeAttributeDescription
bidPrice *
isLow boolean

The lower or upper bounds (low | high)

Return:

number

public getMarginOfError(): number source

Gets the margin of error for indicative pricing.

Return:

number

public getMarginPercent(): number source

Calculates and returns the Bid Margin Percent.

Return:

number

public getPredictedValue(): sum | null source

Gets the predicted value of the bid by calculating the sum total of the predicted values for all line items

Return:

sum | null

public getStoplightIndicator(): * source

Return:

*

public getUncategorizedLineItems(componentGroupId: number): {[id: string]} source

Gets all the uncategorized Line Items by component group.

Params:

NameTypeAttributeDescription
componentGroupId number

The component group id.

Return:

{[id: string]}

Uncategorized Line Items keyed by ID.

public getWeightedNormalValue(distributionIndex: *): T | null source

For each line item, get all of its weightedNormalValues return the sum of all line item's weightedNormalValues at distributionIndex

Params:

NameTypeAttributeDescription
distributionIndex *

Return:

T | null

weighted normal value

public getWeightedNormalValues(): array source

Calculates the weighted normal value given a set of distribution ranges.

Return:

array

Array of weighted normal values

public hasNullDependency(property: string): boolean source

Determines if a property depends on a null dependency somewhere in it's calculation

Override:

BidEntity#hasNullDependency

Params:

NameTypeAttributeDescription
property string

The bid property name

Return:

boolean

public includeMarkupInTax(): * source

Return:

*

public includeTaxInMarkup(): boolean source

Determines if markup should also be assessed on the tax.

Return:

boolean

public isAssessable(): boolean source

Determines if bid is in an "assessable" state. Factors include if the bid is as shell bid, if the bid is in read only mode, and if the bid has no validation issues.

Return:

boolean

public isIndicativePricing(): boolean source

Determines if indicative pricing is enabled.

Return:

boolean

public isLocked(): boolean source

Determines if the bid is locked.

Return:

boolean

public isPredicted(property: string): boolean source

Determines if a bid property is predicted.

Params:

NameTypeAttributeDescription
property string

The bid property

Return:

boolean

public isReadOnly(): boolean source

Determines if bid can be modified by the user. Considers if the bid is locked, if the project is closed, and the user permissions.

Return:

boolean

public isShell(): boolean source

Determines if is a shell bid. Shell bids are simple data stores for past bids that can not be assesed. Shell bids do not have line items. Typically shell bids are created to import old bid data prior a companies using PVBid.

Return:

boolean

public isUpdateable(): boolean source

this method was deprecated.

Determines if bid is updatable by the user. This method is deprecated. Use Bid.isReadOnly instead.

Return:

boolean

public isValid(): boolean source

Determines if bid has valid dependency references and configurations..

Return:

boolean

public async load(options: object) source

Fully loads the bid with its entities (if not already loaded).

Params:

NameTypeAttributeDescription
options object
options.forceReload boolean
  • optional
  • default: false

Force the bid to reload even if the entities are already loaded.

options.skipSave boolean
  • optional
  • default: false

Saves the current project state before loading by default. Set this flag to skip.

public async lock(): Promise<null> source

Locks bid, forcing read-only mode for everyone. Bid must be unlocked before it can be modified again. This function immediately saves the bid. Will return a rejected promise if the bid cannot be locked.

Return:

Promise<null>

public async moveToProject(project: *): Promise<*> source

Moves a bid from its current project to another

Params:

NameTypeAttributeDescription
project *

Return:

Promise<*>

public needsReassessment(): boolean source

Analyzes line items and components calculations. If the sum up correctly to match the bid, reassessment is considered unnecessary.

Return:

boolean

public pristine() source

Marks bid and all bid entities as clean.

Override:

BidEntity#pristine

public reassessAll(forceReassessment: boolean) source

Reassess all LineItems, Fieldss, Metricss, and {@ linkComponents}s. This function checks Bid.needsReassessment first, to determine if reassessment is necessary. Use the force flag to reasses reguardless of necessity.

Params:

NameTypeAttributeDescription
forceReassessment boolean

public async reassessAsync(): Promise<void> source

Helper method to re-assess the bid until price converges. Returns a promise that will resolve once the price has stabilized.

Return:

Promise<void>

Resolves once the bid has been assessed twice in a row with the same price. Rejects if the price does not stabilize.

public async recover(snapshotId: number): Promise<null> source

Recovers bid to previous snapshot. An auto snapshot of the current state will be created. This is a wrapper function for BidService.recoverBid

Params:

NameTypeAttributeDescription
snapshotId number

Return:

Promise<null>

public async removeAssembly(assemblyId: number): * source

Removes assembly from a bid. A wrapper function for BidService.removeAssembly

Params:

NameTypeAttributeDescription
assemblyId number

Return:

*

public resetMarkup() source

Globally resets markup on all line items in the bid.

public toggleActive() source

this method was deprecated. use isActive property.

public async unlock(): Promise<null> source

Unlocks bid, making it writable for those with permission. This function immediately saves the bid.

Return:

Promise<null>

public validate(): object[] source

Validates bid and returns a resultset of issues, if exists.

Return:

object[]