1.0.3 • Published 9 months ago

bdt-comm-api v1.0.3

Weekly downloads
-
License
-
Repository
-
Last release
9 months ago

BDT-COMM-API

This library is meant to be used as a communication layer between Bid Day Tool and a custom plugin. It is not an API that can be used in a standalone application like a typical API where the API is called via HTTP requests.

To use it, install it into your custom plugin.

Installation

 npm install bdt-comm-api

Import

...
import { BDTCOMMAPIService } from "bdt-comm-api";

Usage

Getting Data from Bid Day Tool Estimate

To get data from Bid Day Tool, the BDT-COMM-API library exposes an Observable called BDT_DATA that can be subscribed to. Once subscribed, the Observable will emit its last value for use in a custom plugin.

BDT_DATA- Observable that returns an object with data from Bid Day Tool estimate. An estimate must be open in Bid Day Tool before this can be called.

Attributes of object returned by subscribing to BDT_DATA


  • User_Info : object Object containing info about the user currently logged in user

    - **name** : *string*<br>

    First & Last name of logged in user - username : string Email address of logged in user - is_admin : boolean Value indicating whether user has admin privileges - profile : string Value indicating the profile associated with the user


  • Job_Info : object Object containing general info about the estimate being worked on

    - **estimate_name** : *string*<br>

    Name of the estimate being worked on

    - **market** : *string*<br>

    Market in which the job is being done (used to determine labor rates if they change across markets) - labor_type : string Type of labor that is being estimated (these are user defined values) - taxes : object Object containing tax info.

        - **tax_type** : *string*<br>

    Type of taxes being applied to the job - tax_amount : number Amount to use as tax multiplier - misc : object Object containing miscellaneous info about the estimate being worked on

        - **price_of_job** : *number*<br>

    Value used to set the final price of the job. (is used to work backwards and calculate margin when user knows final price of job) - percent_retention : number Retention as a percentage (i.e 27=27%) - percent_gross_margin : number Gross margin as a percentage (i.e 27=27%) - percent_subcontract_gross_margin : number Gross margin for subcontracting, when seperate margin for subcontracted systems is desired, as a percentage (i.e 27=27%) - seperate_subcontract_gross_margin : boolean Value Indicating whether user wants to use seperate margin for subcontracted systems - percent_warranty : number Warranty as a percentage (i.e 27=27%) - percent_material_contingency : number Material contingency as a percentage (i.e 27=27%) - percent_freight : number Freight as a percentage (i.e 27=27%) - percent_labor_factor : number Labor factor as a percentage (i.e 27=27%) - percent_team_leader_factor : number Team leader factor as a percentage (this value only applies to users who use the TEAM profile) (i.e 0.07=0.07%) - labor_rates : array Array of objects containing info about the labor rates used in the estimate being worked on

        - **category** : *string*<br>

    Labor category code - description : string Description of labor category - wage : number Wage (used when certified payroll is needed on certain labor) - fringe : number Fringe (used when certified payroll is needed on certain labor) - labor_rate : number Labor rate - final_labor_rate : number Final labor rate (calculated based on a combination of labor_rate, wage/fringe set and certified payroll values set in database)


  • Summary : object Object containing a summary of values for the estimate being worked on

    - **estimated_final_price_with_fees** : *number*<br>

    vfinal price of estimate including fees - estimated_final_price_without_fees : number final price of estimate excluding fees - estimated_job_costs : number total estimated job costs - estimated_other_costs : number costs from the "Others" section - percent_gross_margin : number gross margin as a percentage (i.e 27=27%) - gross_margin : number gross margin as a dollar amount - category_summaries : Array Array of objects containing summary information about labor categories

        - **category** : *string*<br>

    Labor category code - description : string Description of labor category - hours : number Total number of hours for the category - rate : number Labor rate being charged for the category (value is equal to final labor rate) - cost : number Total cost of the category - price : number Total price of the category

    - **material_summaries** : *Array*<br>

    Array of objects containing summary information about material

        - **total_cost** : *number*<br>

    Total cost of material for said vendor - total_price : number Total price of material for said vendor - vendor_code : string Code associated with vendor in CRM - vendor_number : string Number associated with vendor in CRM - material : array Array of objects containing info about each piece of material

            - **quantity** : *number*<br>

    Quantity of said material - part_description : string Description of said material - vendor_part_number : string Vendor's Part number used to order part from vendor - cost_each : number Cost of said material

    - **freight** : *number*<br>

    Cost of freight for Material - warranty : number Cost of warranty for material - contingency_cost : number Cost of contingency for material


  • Subcontracts : array Array of objects containing info about subcontracts in estimate being worked on

    - **system_name** : *string*<br>

    Name of system that has the subcontract - type : string Type of subcontract - zero_out_install : boolean Value indicating if hours for install categories should be set to zero - contractor : string Contractor who's doing the work - description : string Description of work being subcontracted - amount : number Cost of subcontracting


  • Other : object Object containing info found on "Others" section of Bid Day Tool

    - **total_cost** : *number*<br>

    Total cost of all categories in Others section - total_price : number Total price of all categories in Others section - categories : array Array of objects containing info about each category in Others section of Bid Day Tool

        - **category_name** : *string*<br>

    Name of individual category - cost : number Cost of individual category - price : number Price of individual category - items : array Array of objects containing info on items in individual category - cost : number Cost of item - description : string Description of item


  • Custom_Formulas : array Array of objects containing info on items in custom formulas found in the "Others" section of Bid Day Tool

    - **formula** : *string*<br>

    Formula. Can be a Number or Mathematical Expression - section : string Value indicating what section of the generated summary document a custom formula item goes in - value : number Value generated from evaluating the Mathematical Expression contained in the formula - variable_name : string Name of variable which holds the value evaluated from Mathematical Expression in the formula - where_to_apply : string Value indicating where to apply the value generated from evaluating the Mathematical Expression contained in the formula


  • Notes : object Object containing info on items in custom formulas found in the "Others" section of Bid Day Tool

    - **estimate_notes** : *array*<br>

    Array of objects containing info on general notes created in Unity

        - **page** : *string*<br>

    Value indicating what page of the Unity estimate said note is on - note_number : number Value indicating what number note said note is - note : string The note itself - subcontractor_notes : array Array of objects containing info on subcontractor notes created in Unity

        - **page** : *string*<br>

    Value indicating what page of the Unity estimate said note is on - note_number : number Value indicating what number note said note is - note : string The note itself - other_notes : array Array of objects containing info on notes created in Bid Day Tool

        - **page** : *string*<br>

    Value indicating what page of the Unity estimate said note is on - note_number : number Value indicating what number note said note is - note : string The note itself


  • Systems : array Array of objects containing info on items in systems found in the "Systems" section of Bid Day Tool

    - **system** : *string*<br>

    Name of system - typical_of : number Value indicating quantity of similar systems - total_cost : number Total cost of system - total_price : number Total price of system - points : array Array of objects containing info on I/O for system (created in Unity) - device_id : string ID of device out in the field - point_name : string Name of software I/O point in device

    - **category_labor_hours** : *array*<br>

    Array of objects containing info on labor categories for the system - category : string Labor category code - description : string Description of labor category - hours : number Total number of hours for the category - materials : array Array of objects containing info on material for the system

        - **quantity** : *number*<br>

    Quantity of said material - part_description : string Description of said material - vendor_part_number : string Vendor's Part number used to order part from vendor - cost_each : number Cost of said material


  • Custom_User_Data : object Object containing custom data saved into an estimate from a custom plugin

  • Version : string Version of Bid Day Tool that data was generated with

Example Usage

@Component({
  selector: 'app-my-component',
  templateUrl: './my-component.component.html',
  styleUrls: ['./my-component.component.scss']
})
export class MyComponentComponent implements OnInit {

  private BDT_Data_Subscription: Subscription = new Subscription()
  data:any =""
  constructor(private BDT_COMM_API:BDTCOMMAPIService) { }

  ngOnInit(): void {
    this.BDT_Data_Subscription=this.BDT_COMM_API.BDT_DATA.subscribe(x =>{
       this.data = x
       console.log(this.data)
      })
  }

   ngOnDestroy(){
    //you need to unsubscribe or you'll have memory leaks
    this.BDT_Data_Subscription.unsubscribe()
  }
}

Example value returned by subscribing to BDT_DATA

{
    "UserInfo": {
        "name": "Jon Doe",
        "username": "jon.does@fakemail.net",
        "is_admin": true
    },
    "JobInfo": {
        "estimate_name": "Test Estimate",
        "market": "Dallas",
        "labor_type": "Solutions",
        "taxes": {
            "tax_type": "No Taxes",
            "tax_amount": 0
        },
        "misc": {
            "price_of_job": "N/A",
            "percent_retention": "N/A",
            "percent_gross_margin": 27,
            "percent_warranty": 3,
            "percent_material_contingency": 3,
            "percent_freight": 3,
            "percent_labor_factor": "N/A",
            "percent_team_leader_factor": 0.07
        },
        "labor_rates": [
            {
                "category": "1",
                "description": "Design Labor",
                "wage": 0,
                "fringe": 0,
                "labor_rate": 99,
                "final_labor_rate": 99
            },
            {
                "category": "2",
                "description": "Programming Labor",
                "wage": 0,
                "fringe": 0,
                "labor_rate": 60,
                "final_labor_rate": 60
            },
        ]
    },
    "Summary": {
        "estimated_final_price_with_fees": 161831.33,
        "estimated_final_price_without_fees": 161831.33,
        "estimated_job_costs": 118136.87,
        "estimated_other_costs": 50,
        "precent_gross_margin": 27,
        "gross_margin": 43694.45,
        "category_summary": [
            {
                "category": "1",
                "description": "Design Labor",
                "hours": 64.1,
                "rate": 99,
                "cost": 4166.5,
                "price": 5707.53
            },
            {
                "category": "2",
                "description": "Programming Labor",
                "hours": 76.46,
                "rate": 60,
                "cost": 6193.26,
                "price": 8483.92
            },
        ],
        "material_summary": [
            {
                "total_cost": 1500,
                "total_price": 2054.79,
                "vendor_code": "DAKTECH",
                "vendor_number": "1",
                "material": [
                    {
                        "quantity": 1,
                        "part_description": "QUOTE FOR DIAGNOSTIC TERMINAL (LAPTOP)",
                        "vendor_part_number": "QUOTE",
                        "cost_each": 1500
                    }
                ]
            },
            {
                "total_cost": 13788.99,
                "total_price": 18889.03,
                "vendor_code": "DELTA",
                "vendor_number": "2",
                "material": [
                    {
                        "quantity": 1,
                        "part_description": "301604 eBMGR-2 enteliBUS System Controller w/Ether",
                        "vendor_part_number": "301604",
                        "cost_each": 540.55
                    },
                    {
                        "quantity": 6,
                        "part_description": "BA/10K-3-I-4\"-BBX Immersion temperature sensor wit",
                        "vendor_part_number": "402994",
                        "cost_each": "7.91"
                    },
                ]
            },
        ],
        "freight": 1284.49,
        "warranty": 1284.49,
        "contingency_cost": 1247.07
    },
    "Subcontracts": [
        {
            "system_name": "01|MANUAL",
            "type": "Electrical",
            "zero_out_install": false,
            "contractor": "Test Contractor",
            "description": "Test Descr",
            "amount": 500
        },
        {
            "system_name": "01|NETWORK",
            "type": "Mechanical",
            "zero_out_install": false,
            "contractor": "Test Cont 2",
            "description": "test Desc 2",
            "amount": 1000
        }
    ],
    "Other": {
        "total_cost": 50,
        "total_price": 68.49,
        "categories": [
            {
                "category_name": "Install Materials",
                "cost": 0,
                "price": 0,
                "items":[]
            },
            {
                "category_name": "Tools",
                "cost": 50,
                "price": 68.49,
                "items":[
                    {
                        "cost": 50,
                        "description": "Tools"
                    }
                ]
            },
        ]
    },
    "Custom_Formulas": [
        {
            "formula": "10",
            "section": "DO NOT APPLY",
            "value": 10,
            "variable_name": "varA",
            "where_to_apply": "DO NOT APPLY"
        },
        {
            "formula": "20",
            "section": "DO NOT APPLY",
            "value": 20,
            "variable_name": "varB",
            "where_to_apply": "DO NOT APPLY"
        },
        {
            "formula": "30",
            "section": "DO NOT APPLY",
            "value": 30,
            "variable_name": "varC",
            "where_to_apply": "DO NOT APPLY"
        },
        {
            "formula": "varA+varB+varC",
            "section": "DO NOT APPLY",
            "value": 60,
            "variable_name": "varD",
            "where_to_apply": "DO NOT APPLY"
        },
        {
            "formula": "50+25",
            "section": "New Custom Section",
            "value": 75,
            "variable_name": "NewVariable",
            "where_to_apply": "Cost"
        }
    ],
    "Notes": {
        "estimate_notes": [
            {
                "page": "CHW FLOW",
                "note_number": "2",
                "note": "Removed flow meter on CHWR (per updated control diagram)"
            },
            {
                "page": "CHW FLOW",
                "note_number": "3",
                "note": "Removed bypass valve (per updated control diagram)"
            },
        ],
        "subcontractor_notes": [],
        "other_notes": [
            {
                "page": "BDT Systems: 01|MANUAL",
                "note_number": 2,
                "note": "new note"
            },
            {
                "page": "BDT Systems: 01|MANUAL",
                "note_number": 3,
                "note": "llll"
            }
        ]
    },
    "Systems": [
        {
            "system": "01|MANUAL",
            "typical_of": 1,
            "total_cost": 4052.08,
            "total_price": 5550.79,
            "point_data": [],
            "category_labor_hours": [
                {
                    "category": "1",
                    "description": "Design Labor",
                    "hours": 15
                },
                {
                    "category": "12",
                    "description": "Programming Labor",
                    "hours": 2.68
                },
            ],
            "material": []
        },
        {
            "system": "01|NETWORK",
            "typical_of": 1,
            "total_cost": 6703.479036000001,
            "total_price": 9182.85,
            "point_data": [],
            "category_labor_hours": [
                {
                    "category": "1",
                    "description": "Design Labor",
                    "hours": 1
                },
                {
                    "category": "2",
                    "description": "Prgramming Labor",
                    "hours": 4.26
                },
            ],
            "material": [
                {
                    "vendor_code": "DAKTECH",
                    "vendor_number": "1",
                    "description": "QUOTE FOR DIAGNOSTIC TERMINAL (LAPTOP)",
                    "part_number": "QUOTE",
                    "quantity": 1,
                    "cost_each": 1500,
                    "total_cost": 1500
                },
                {
                    "vendor_code": "DELTA",
                    "vendor_number": "2",
                    "description": "301604 eBMGR-2 enteliBUS System Controller w/Ether",
                    "part_number": "301604",
                    "quantity": 1,
                    "cost_each": 540.55,
                    "total_cost": 540.55
                },
            ]
        },
        {
            "system": "03|CHW",
            "typical_of": 1,
            "total_cost": 21183.462668400003,
            "total_price": 29018.44,
            "point_data": [
                {
                    "DeviceID": "ALM-1",
                    "Pointname": "Ch1_Alm"
                },
                {
                    "DeviceID": "ALM-1A",
                    "Pointname": "CHWP1_Fault"
                },
                {
                    "DeviceID": "ALM-2",
                    "Pointname": "Ch2_Alm"
                }
            ]
            "category_labor_hours": [
                {
                    "category": "1",
                    "description": "Design Labor",
                    "hours": 12.04
                },
                {
                    "category": "2",
                    "description": "Programming Labor",
                    "hours": 13.7
                },
            ],
            "material": [
                {
                    "vendor_code": "DELTA",
                    "vendor_number": "2",
                    "description": "BA/10K-3-I-4\"-BBX Immersion temperature sensor wit",
                    "part_number": "402994",
                    "quantity": 6,
                    "cost_each": 7.91,
                    "total_cost": 47.46
                },
                {
                    "vendor_code": "DELTA",
                    "vendor_number": "2",
                    "description": "BA/4\"M316  Machined 316 Stainless Steel 4 Thermowe",
                    "part_number": "400504",
                    "quantity": 6,
                    "cost_each": 22.6,
                    "total_cost": 135.6
                },
            ]
        },
    ],
    "Custom_User_Data": {},
    "Version": "v1.3.0"
}

Setting Data in Bid Day Tool Estimate

To set data and save it to an estimate in Bid Day Tool so it can be retieved and used later in a custom plugin, call the setCustomUserData and pass in the custom data you want to save. Note: when saving data, you must send all of the data you want save at the same time and use a single call to setCustomUserData. Calling setCustomUserData multiple times with different data as parameters will cause the Custom_User_Data to be overriden with the last call to setCustomUserData

setCustomUserData(userData:any):void- sets data inside a Bid Day Tool estimate that can be retieved later inside a plugin by subscribing to the BDT_DATA Observable above. An estimate must be open before this can be called. This function sets the entire Custom User Data object.

1. Example Usage of setting Custom_User_Data to a singular piece of data

@Component({
  selector: 'app-my-component',
  templateUrl: './my-component.component.html',
  styleUrls: ['./my-component.component.scss']
})
export class MyComponentComponent implements OnInit {

  private BDT_Data_Subscription: Subscription = new Subscription()
  data:any =""
  constructor(private BDT_COMM_API:BDTCOMMAPIService) { }

  ngOnInit(): void {

    //subscribe to the Observable first to ensure the emited value isnt accidentally missed
    this.BDT_Data_Subscription=this.BDT_COMM_API.BDT_DATA.subscribe(x =>{
    this.data = x
    console.log(this.data)
    })

    //setting one single piece of data that can be retrieved later inside a plugin
    var singleItem = "testItem"
    this.BDT_COMM_API.setCustomUserData(singleItem) //this will trigger the subscribe method above

  }

    ngOnDestroy(){
    //you need to unsubscribe or you'll have memory leaks
    this.BDT_Data_Subscription.unsubscribe()
  }
}

Example value of Custom_User_Data returned from getAllData()

"Custom_User_Data": testItem,

2. Example Usage of setting Custom_User_Data to object containing Data

@Component({
  selector: 'app-my-component',
  templateUrl: './my-component.component.html',
  styleUrls: ['./my-component.component.scss']
})
export class MyComponentComponent implements OnInit {

  private BDT_Data_Subscription: Subscription = new Subscription()
  data:any =""
  constructor(private BDT_COMM_API:BDTCOMMAPIService) { }

  ngOnInit(): void {

    //subscribe to the Observable first to ensure the emited value isnt accidentally missed
    this.BDT_Data_Subscription=this.BDT_COMM_API.BDT_DATA.subscribe(x =>{
    this.data = x
    console.log(this.data)
    })

    //setting an object of data that can be retrieved later inside a plugin
    var singleItem = {
        "newData":"testItem"
    }
    this.BDT_COMM_API.setCustomUserData(singleItem) //this will trigger the subscribe method above

  }
    
    ngOnDestroy(){
    //you need to unsubscribe or you'll have memory leaks
    this.BDT_Data_Subscription.unsubscribe()
  }
}

Example value of Custom_User_Data returned from subscribing to BDT_DATA Observable

"Custom_User_Data": {
        "newData":"testItem"
    },

Build (for UDS use only)

Run ng build BDT-COMM-API to build the project. The build artifacts will be stored in the dist/ directory.

Publishing (for UDS use only)

After building your library with ng build BDT-COMM-API, go to the dist folder cd dist/bdt-comm-api and run npm publish.

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago

1.0.3

9 months ago

0.0.40

2 years ago

0.0.50

2 years ago

0.0.30

2 years ago

0.0.26

3 years ago

0.0.27

3 years ago

0.0.28

3 years ago

0.0.29

2 years ago

0.0.20

3 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.15

3 years ago

0.0.9

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.5

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago