@ironcode/vas-lib 3.0.0-alpha.1 → 3.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/cjs/lib/control-value/vas-camera-control-value.model.d.ts +4 -2
  2. package/cjs/lib/control-value/vas-camera-control-value.model.d.ts.map +1 -1
  3. package/cjs/lib/control-value/vas-camera-control-value.model.js.map +1 -1
  4. package/cjs/lib/entity/vas-field.dto.d.ts +3 -4
  5. package/cjs/lib/entity/vas-field.dto.d.ts.map +1 -1
  6. package/cjs/lib/entity/vas-field.dto.js.map +1 -1
  7. package/cjs/lib/entity/vas-job.model.js +1 -1
  8. package/cjs/lib/entity/vas-job.model.js.map +1 -1
  9. package/cjs/lib/model/estimate-control/estimate-control-value.dto.d.ts +14 -0
  10. package/cjs/lib/model/estimate-control/estimate-control-value.dto.d.ts.map +1 -0
  11. package/cjs/lib/model/estimate-control/estimate-control-value.dto.js +3 -0
  12. package/cjs/lib/model/estimate-control/estimate-control-value.dto.js.map +1 -0
  13. package/cjs/lib/model/estimate-control/estimate-control-value.model.d.ts +11 -0
  14. package/cjs/lib/model/estimate-control/estimate-control-value.model.d.ts.map +1 -0
  15. package/cjs/lib/model/estimate-control/estimate-control-value.model.js +84 -0
  16. package/cjs/lib/model/estimate-control/estimate-control-value.model.js.map +1 -0
  17. package/cjs/lib/model/estimate-control/estimate-item.dto.d.ts +16 -0
  18. package/cjs/lib/model/estimate-control/estimate-item.dto.d.ts.map +1 -0
  19. package/cjs/lib/model/estimate-control/estimate-item.dto.js +3 -0
  20. package/cjs/lib/model/estimate-control/estimate-item.dto.js.map +1 -0
  21. package/cjs/lib/model/estimate-control/estimate-item.model.d.ts +24 -0
  22. package/cjs/lib/model/estimate-control/estimate-item.model.d.ts.map +1 -0
  23. package/cjs/lib/model/estimate-control/estimate-item.model.js +121 -0
  24. package/cjs/lib/model/estimate-control/estimate-item.model.js.map +1 -0
  25. package/cjs/lib/model/estimate-control/estimate.dto.d.ts +37 -0
  26. package/cjs/lib/model/estimate-control/estimate.dto.d.ts.map +1 -0
  27. package/cjs/lib/model/estimate-control/estimate.dto.js +3 -0
  28. package/cjs/lib/model/estimate-control/estimate.dto.js.map +1 -0
  29. package/cjs/lib/model/estimate-control/estimate.model.d.ts +55 -0
  30. package/cjs/lib/model/estimate-control/estimate.model.d.ts.map +1 -0
  31. package/cjs/lib/model/estimate-control/estimate.model.js +265 -0
  32. package/cjs/lib/model/estimate-control/estimate.model.js.map +1 -0
  33. package/cjs/lib/model/estimate-control/estimate.types.d.ts +3 -0
  34. package/cjs/lib/model/estimate-control/estimate.types.d.ts.map +1 -0
  35. package/cjs/lib/model/estimate-control/estimate.types.js +3 -0
  36. package/cjs/lib/model/estimate-control/estimate.types.js.map +1 -0
  37. package/cjs/lib/model/estimate-control/index.d.ts +8 -0
  38. package/cjs/lib/model/estimate-control/index.d.ts.map +1 -0
  39. package/cjs/lib/model/estimate-control/index.js +11 -0
  40. package/cjs/lib/model/estimate-control/index.js.map +1 -0
  41. package/cjs/lib/model/index.d.ts +2 -0
  42. package/cjs/lib/model/index.d.ts.map +1 -1
  43. package/cjs/lib/model/index.js +2 -0
  44. package/cjs/lib/model/index.js.map +1 -1
  45. package/cjs/lib/model/report-invocation.d.ts +40 -0
  46. package/cjs/lib/model/report-invocation.d.ts.map +1 -0
  47. package/cjs/lib/model/report-invocation.js +3 -0
  48. package/cjs/lib/model/report-invocation.js.map +1 -0
  49. package/cjs/lib/utils/get-value-by-path.d.ts +5 -15
  50. package/cjs/lib/utils/get-value-by-path.d.ts.map +1 -1
  51. package/cjs/lib/utils/get-value-by-path.js +49 -60
  52. package/cjs/lib/utils/get-value-by-path.js.map +1 -1
  53. package/cjs/lib/utils/index.d.ts +8 -0
  54. package/cjs/lib/utils/index.d.ts.map +1 -0
  55. package/cjs/lib/utils/index.js +11 -0
  56. package/cjs/lib/utils/index.js.map +1 -0
  57. package/cjs/lib/utils/is-array-string.d.ts +3 -0
  58. package/cjs/lib/utils/is-array-string.d.ts.map +1 -1
  59. package/cjs/lib/utils/is-array-string.js +3 -0
  60. package/cjs/lib/utils/is-array-string.js.map +1 -1
  61. package/cjs/lib/utils/is-numeric.d.ts +2 -0
  62. package/cjs/lib/utils/is-numeric.d.ts.map +1 -0
  63. package/cjs/lib/utils/is-numeric.js +10 -0
  64. package/cjs/lib/utils/is-numeric.js.map +1 -0
  65. package/cjs/lib/utils/is-plain-object.d.ts +3 -0
  66. package/cjs/lib/utils/is-plain-object.d.ts.map +1 -1
  67. package/cjs/lib/utils/is-plain-object.js +3 -0
  68. package/cjs/lib/utils/is-plain-object.js.map +1 -1
  69. package/cjs/lib/utils/try-json.d.ts +2 -2
  70. package/cjs/lib/utils/try-json.js +2 -2
  71. package/cjs/lib/utils/try-json.js.map +1 -1
  72. package/cjs/public-api.d.ts +1 -0
  73. package/cjs/public-api.d.ts.map +1 -1
  74. package/cjs/public-api.js +1 -0
  75. package/cjs/public-api.js.map +1 -1
  76. package/fesm2022/ironcode-vas-lib.mjs +548 -56
  77. package/fesm2022/ironcode-vas-lib.mjs.map +1 -1
  78. package/lib/control-value/vas-camera-control-value.model.d.ts +4 -2
  79. package/lib/entity/vas-field.dto.d.ts +3 -4
  80. package/lib/model/estimate-control/estimate-control-value.dto.d.ts +13 -0
  81. package/lib/model/estimate-control/estimate-control-value.model.d.ts +10 -0
  82. package/lib/model/estimate-control/estimate-item.dto.d.ts +15 -0
  83. package/lib/model/estimate-control/estimate-item.model.d.ts +23 -0
  84. package/lib/model/estimate-control/estimate.dto.d.ts +36 -0
  85. package/lib/model/estimate-control/estimate.model.d.ts +54 -0
  86. package/lib/model/estimate-control/estimate.types.d.ts +2 -0
  87. package/lib/model/estimate-control/index.d.ts +7 -0
  88. package/lib/model/index.d.ts +2 -0
  89. package/lib/model/report-invocation.d.ts +39 -0
  90. package/lib/utils/get-value-by-path.d.ts +5 -15
  91. package/lib/utils/index.d.ts +7 -0
  92. package/lib/utils/is-array-string.d.ts +4 -0
  93. package/lib/utils/is-numeric.d.ts +1 -0
  94. package/lib/utils/is-plain-object.d.ts +3 -0
  95. package/lib/utils/omit.d.ts +7 -0
  96. package/lib/utils/try-json.d.ts +2 -2
  97. package/package.json +3 -2
  98. package/public-api.d.ts +1 -0
@@ -1,10 +1,12 @@
1
1
  import { VasFileDto } from '../entity';
2
- export interface VasCameraControlValueModel {
2
+ export interface VasCameraControlValueValue {
3
3
  webPath: string;
4
4
  path: string;
5
5
  url?: string;
6
6
  id?: string;
7
7
  }
8
- export declare function isCameraControlValueV1(object: any): object is VasCameraControlValueModel;
8
+ /** @deprecated */
9
+ export type VasCameraControlValueModel = VasCameraControlValueValue;
10
+ export declare function isCameraControlValueV1(object: any): object is VasCameraControlValueValue;
9
11
  export declare function isCameraControlValueV2(object: any): object is VasFileDto;
10
12
  //# sourceMappingURL=vas-camera-control-value.model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vas-camera-control-value.model.d.ts","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/control-value/vas-camera-control-value.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,WAAW,0BAA0B;IAGzC,OAAO,EAAE,MAAM,CAAC;IAGhB,IAAI,EAAE,MAAM,CAAC;IAGb,GAAG,CAAC,EAAE,MAAM,CAAC;IAGb,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,GAAG,GACV,MAAM,IAAI,0BAA0B,CAMtC;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,GAAG,GACV,MAAM,IAAI,UAAU,CAQtB"}
1
+ {"version":3,"file":"vas-camera-control-value.model.d.ts","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/control-value/vas-camera-control-value.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,WAAW,0BAA0B;IAGzC,OAAO,EAAE,MAAM,CAAC;IAGhB,IAAI,EAAE,MAAM,CAAC;IAGb,GAAG,CAAC,EAAE,MAAM,CAAC;IAGb,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ;AAED,kBAAkB;AAClB,MAAM,MAAM,0BAA0B,GAAG,0BAA0B,CAAC;AAEpE,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,GAAG,GACV,MAAM,IAAI,0BAA0B,CAMtC;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,GAAG,GACV,MAAM,IAAI,UAAU,CAQtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"vas-camera-control-value.model.js","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/control-value/vas-camera-control-value.model.ts"],"names":[],"mappings":";;AAiBA,wDAQC;AAED,wDAUC;AApBD,SAAgB,sBAAsB,CACpC,MAAW;IAEX,OAAO,MAAM,YAAY,MAAM;WAC1B,SAAS,IAAI,MAAM;WACnB,MAAM,IAAI,MAAM;WAChB,KAAK,IAAI,MAAM;WACf,IAAI,IAAI,MAAM,CAAA;AACrB,CAAC;AAED,SAAgB,sBAAsB,CACpC,MAAW;IAEX,OAAO,MAAM,YAAY,MAAM;WAC1B,IAAI,IAAI,MAAM;WACd,MAAM,IAAI,MAAM;WAChB,UAAU,IAAI,MAAM;WACpB,UAAU,IAAI,MAAM;WACpB,UAAU,IAAI,MAAM;WACpB,QAAQ,IAAI,MAAM,CAAA;AACzB,CAAC","sourcesContent":["import { VasFileDto } from '../entity';\n\nexport interface VasCameraControlValueModel {\n // this is the object url which can be used as an img src.\n // **WARNING** only valid during the session when image was captured\n webPath: string;\n // path to the image on the device's storage.\n // **WARNING** only valid on the device that took the image\n path: string;\n // path to the image in cloud storage.\n // **WARNING** only valid once the image has been uploaded\n url?: string;\n // id we generated when uploading to Firebase Cloudstore\n // **WARNING** only valid once the image has been uploaded\n id?: string\n}\n\nexport function isCameraControlValueV1(\n object: any\n): object is VasCameraControlValueModel {\n return object instanceof Object\n && 'webPath' in object\n && 'path' in object\n && 'url' in object\n && 'id' in object\n}\n\nexport function isCameraControlValueV2(\n object: any\n): object is VasFileDto {\n return object instanceof Object\n && 'id' in object\n && 'name' in object\n && 'fileSize' in object\n && 'mimeType' in object\n && 'sequence' in object\n && 'config' in object\n}\n"]}
1
+ {"version":3,"file":"vas-camera-control-value.model.js","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/control-value/vas-camera-control-value.model.ts"],"names":[],"mappings":";;AAoBA,wDAQC;AAED,wDAUC;AApBD,SAAgB,sBAAsB,CACpC,MAAW;IAEX,OAAO,MAAM,YAAY,MAAM;WAC1B,SAAS,IAAI,MAAM;WACnB,MAAM,IAAI,MAAM;WAChB,KAAK,IAAI,MAAM;WACf,IAAI,IAAI,MAAM,CAAA;AACrB,CAAC;AAED,SAAgB,sBAAsB,CACpC,MAAW;IAEX,OAAO,MAAM,YAAY,MAAM;WAC1B,IAAI,IAAI,MAAM;WACd,MAAM,IAAI,MAAM;WAChB,UAAU,IAAI,MAAM;WACpB,UAAU,IAAI,MAAM;WACpB,UAAU,IAAI,MAAM;WACpB,QAAQ,IAAI,MAAM,CAAA;AACzB,CAAC","sourcesContent":["import { VasFileDto } from '../entity';\n\nexport interface VasCameraControlValueValue {\n // this is the object url which can be used as an img src.\n // **WARNING** only valid during the session when image was captured\n webPath: string;\n // path to the image on the device's storage.\n // **WARNING** only valid on the device that took the image\n path: string;\n // path to the image in cloud storage.\n // **WARNING** only valid once the image has been uploaded\n url?: string;\n // id we generated when uploading to Firebase Cloudstore\n // **WARNING** only valid once the image has been uploaded\n id?: string\n}\n\n/** @deprecated */\nexport type VasCameraControlValueModel = VasCameraControlValueValue;\n\nexport function isCameraControlValueV1(\n object: any\n): object is VasCameraControlValueValue {\n return object instanceof Object\n && 'webPath' in object\n && 'path' in object\n && 'url' in object\n && 'id' in object\n}\n\nexport function isCameraControlValueV2(\n object: any\n): object is VasFileDto {\n return object instanceof Object\n && 'id' in object\n && 'name' in object\n && 'fileSize' in object\n && 'mimeType' in object\n && 'sequence' in object\n && 'config' in object\n}\n"]}
@@ -1,9 +1,8 @@
1
1
  import { VasJobDataDto } from './vas-job-data.dto';
2
2
  import { VasFileDto } from './vas-file.dto';
3
- import { GeoLocation } from '../model';
4
- import { VasFunctionControlValueDto } from '../control-value';
5
- import { VasCameraControlValueModel } from '../control-value';
6
- export declare type FieldValueType = string | number | boolean | null | GeoLocation | Array<object | string | number | boolean | VasFileDto> | Record<string, any> | VasCameraControlValueModel | VasFunctionControlValueDto;
3
+ import { EstimateControlValueDto, GeoLocation } from '../model';
4
+ import { VasCameraControlValueValue, VasFunctionControlValueDto } from '../control-value';
5
+ export declare type FieldValueType = string | number | boolean | null | GeoLocation | Array<object | string | number | boolean | VasFileDto> | Record<string, any> | VasCameraControlValueValue | EstimateControlValueDto | VasFunctionControlValueDto;
7
6
  export interface VasFieldDto extends VasJobDataDto {
8
7
  control: string;
9
8
  fieldJobPointers: Array<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"vas-field.dto.d.ts","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/entity/vas-field.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,CAAC,OAAO,MAAM,cAAc,GAChC,MAAM,GACJ,MAAM,GACN,OAAO,GACP,IAAI,GACJ,WAAW,GACX,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC,GACtD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnB,0BAA0B,GAC1B,0BAA0B,CAC3B;AAEH,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB"}
1
+ {"version":3,"file":"vas-field.dto.d.ts","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/entity/vas-field.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE1F,MAAM,CAAC,OAAO,MAAM,cAAc,GAChC,MAAM,GACJ,MAAM,GACN,OAAO,GACP,IAAI,GACJ,WAAW,GACX,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC,GACtD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnB,0BAA0B,GAC1B,uBAAuB,GACvB,0BAA0B,CAC3B;AAEH,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"vas-field.dto.js","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/entity/vas-field.dto.ts"],"names":[],"mappings":"","sourcesContent":["import { VasJobDataDto } from './vas-job-data.dto';\nimport { VasFileDto } from './vas-file.dto';\nimport { GeoLocation } from '../model';\nimport { VasFunctionControlValueDto } from '../control-value';\nimport { VasCameraControlValueModel } from '../control-value';\n\nexport declare type FieldValueType =\n string\n | number\n | boolean\n | null\n | GeoLocation\n | Array<object | string | number | boolean | VasFileDto>\n | Record<string, any>\n | VasCameraControlValueModel\n | VasFunctionControlValueDto\n ;\n\nexport interface VasFieldDto extends VasJobDataDto {\n control: string;\n fieldJobPointers: Array<string>;\n value: FieldValueType;\n version: number;\n controlName: string;\n controlTitle: string;\n controlTypeName: string;\n}\n"]}
1
+ {"version":3,"file":"vas-field.dto.js","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/entity/vas-field.dto.ts"],"names":[],"mappings":"","sourcesContent":["import { VasJobDataDto } from './vas-job-data.dto';\nimport { VasFileDto } from './vas-file.dto';\nimport { EstimateControlValueDto, GeoLocation } from '../model';\nimport { VasCameraControlValueValue, VasFunctionControlValueDto } from '../control-value';\n\nexport declare type FieldValueType =\n string\n | number\n | boolean\n | null\n | GeoLocation\n | Array<object | string | number | boolean | VasFileDto>\n | Record<string, any>\n | VasCameraControlValueValue\n | EstimateControlValueDto\n | VasFunctionControlValueDto\n ;\n\nexport interface VasFieldDto extends VasJobDataDto {\n control: string;\n fieldJobPointers: Array<string>;\n value: FieldValueType;\n version: number;\n controlName: string;\n controlTitle: string;\n controlTypeName: string;\n}\n"]}
@@ -105,7 +105,7 @@ class VasJobModel extends vas_restricted_account_object_model_1.VasRestrictedAcc
105
105
  .keys(dto[groupName])
106
106
  .forEach(controlName => {
107
107
  const cn = controlName.replace('fields.', '');
108
- fields[cn] = dto[groupName][cn];
108
+ fields[cn] = dto[groupName][controlName];
109
109
  });
110
110
  });
111
111
  }
@@ -1 +1 @@
1
- {"version":3,"file":"vas-job.model.js","sourceRoot":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D,kCAuYC","sourcesContent":["import { isFileDto, VasFileDto } from './vas-file.dto';\nimport moment from 'moment';\nimport { getValueByPath } from '../utils/get-value-by-path';\nimport { VasBaseDto } from './vas-base.dto';\nimport { FieldValueType, VasFieldDto } from './vas-field.dto';\nimport { VasFormModel } from './vas-form.model';\nimport { VasJobDto } from './vas-job.dto';\nimport { VasRestrictedAccountObjectModel } from './vas-restricted-account-object.model';\nimport { GeoLocation, getEmptyGeoLocation } from '../model';\nimport { isCameraControlValueV1, VasCameraControlValueModel, isCameraControlValueV2 } from '../control-value';\nimport { only } from '../utils/only';\nimport { VasReportDto } from './vas-report.dto';\nimport { VasTaskDto } from './vas-task.dto';\nimport { VasNoteDto } from './vas-note.dto';\nimport { VasJobEmailDto } from './vas-job-email.dto';\nimport { VasInstructionDto } from './vas-instruction.dto';\nimport { tryJson } from \"../utils/try-json\";\nimport { isPlainObject } from \"../utils/is-plain-object\";\n\nexport interface ParseSyntaxOptions {\n // This value will be used to adjust any datetime values that are referenced\n // in the syntax string. See\n // https://momentjscom.readthedocs.io/en/latest/moment/03-manipulating/09-utc-offset/\n // for more information about how `moment` will handle the value.\n timeZoneOffset: number,\n // this dictionary can be passed in to contain other objects to be referenced\n // in the syntax. For example if we have {job.foo} this will reference the\n // job's `foo` property, however if we have \"reportLayout.title\" this will\n // expect to find a property of `objects` called `reportLayout` which will\n // have a property called `title`\n objects?: Record<string, Partial<VasBaseDto> | Record<string, FieldValueType>>;\n}\n\nlet jobStaticProps: Set<string> | undefined;\n\nfunction getJobStaticProperties() {\n if (jobStaticProps) {\n return jobStaticProps;\n }\n return jobStaticProps = new Set(Object.getOwnPropertyNames(VasJobModel.empty()));\n}\n\n/**\n * JobModel\n */\nexport class VasJobModel extends VasRestrictedAccountObjectModel {\n\n constructor(\n public override id: string,\n public override created: string,\n public override serverCreated: string,\n public override createdBy: string,\n public override modified: string,\n public override serverModified: string,\n public override modifiedBy: string,\n public override createdByName: string,\n public override modifiedByName: string,\n public override account: string,\n public override accessGroup: string,\n public reference: string,\n public jobDate: string,\n public jobStatus: string,\n public jobType: string,\n public assigneeId: string,\n public formId: string,\n public timeZoneOffset: number,\n public pendingFields: number,\n public childModified: string,\n public version: number,\n public geoLocation: GeoLocation,\n public files: Array<VasFileDto>,\n public fields: Record<string, FieldValueType>,\n public jobEmails: Array<VasJobEmailDto>,\n public notes: Array<VasNoteDto>,\n public reports: Array<VasReportDto>,\n public tasks: Array<VasTaskDto>,\n public instruction: VasInstructionDto | null\n ) {\n super(\n id,\n created,\n serverCreated,\n createdBy,\n modified,\n serverModified,\n modifiedBy,\n createdByName,\n modifiedByName,\n account,\n accessGroup\n );\n }\n\n get createdByDisplayName(): string {\n return this.createdByName;\n }\n\n get modifiedByDisplayName(): string {\n return this.modifiedByName;\n }\n\n /**\n * Return the list of Job properties\n */\n get staticProperties(): Set<string> {\n if (jobStaticProps) {\n return jobStaticProps;\n }\n return jobStaticProps = new Set(Object.getOwnPropertyNames(VasJobModel.empty()));\n }\n\n /**\n * @return {VasJobModel}\n */\n static empty(): VasJobModel {\n return new VasJobModel(\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n moment().utcOffset(),\n 0,\n '',\n 0,\n getEmptyGeoLocation(),\n [],\n {},\n [],\n [],\n [],\n [],\n null\n );\n }\n\n static override fromDto(dto: Partial<VasJobDto>): VasJobModel {\n // we have changed the job model and stopped using the dynamic properties\n // from form group names to hold fields. Instead, we store a simple object\n // where the control name (minus the \"fields.\" prefix) is the key, and the\n // field value is the value. However, we have to cater for data that may\n // be persisted in the old structure, or an API response where fields is an\n // array of VasFieldDto.\n\n // 1: if dto.fields is already an object, we use the existing value\n const fields: Record<string, FieldValueType> =\n isPlainObject<Record<string, FieldValueType>>(dto.fields) ?\n dto.fields :\n {};\n\n // 2: if dto.fields is an array, we're handling a vas-rest response, we\n // iterate over the fields and update the fields object.\n Array.isArray(dto.fields) && dto.fields.forEach((field: VasFieldDto) => {\n fields[field.controlName.replace('fields.', '')] = tryJson(field.value);\n });\n\n // 3: if `fields` still has no keys, we're restoring a VasJobDto object that\n // was saved in the old \"form-group\" style, where dynamic keys are\n // derived from the form-group names. We'll iterate over those keys, and\n // update the `fields` object. Once this model is serialized back to a\n // dto, it will have the new shape.\n if (Object.keys(fields).length === 0) {\n Object\n .keys(dto)\n .filter(key => !getJobStaticProperties().has(key))\n .forEach(groupName => {\n Object\n .keys((dto as any)[groupName])\n .forEach(controlName => {\n const cn = controlName.replace('fields.', '');\n fields[cn] = (dto as any)[groupName][cn];\n });\n });\n }\n\n return new VasJobModel(\n dto.id || '',\n dto.created || '',\n dto.serverCreated || '',\n dto.createdBy || '',\n dto.modified || '',\n dto.serverModified || '',\n dto.modifiedBy || '',\n dto.createdByName || '',\n dto.modifiedByName || '',\n dto.account || '',\n dto.accessGroup || '',\n dto.reference || '',\n dto.jobDate || '',\n dto.jobStatus || '',\n dto.jobType || '',\n dto.assigneeId || '',\n dto.formId || (dto as any).lastForm || '',\n dto.timeZoneOffset || moment().utcOffset(),\n dto.pendingFields || 0,\n dto.childModified || '',\n dto.version || 0,\n dto.geoLocation || getEmptyGeoLocation(),\n dto.files || [],\n fields,\n dto.jobEmails || [],\n dto.notes || [],\n dto.reports || [],\n dto.tasks || [],\n dto.instruction || null\n );\n }\n\n /**\n * Returns an object describing how many attachments were added to this job\n * (camera controls and files), and how many have not been uploaded yet.\n *\n * @param formModel instance of {@link VasFormModel} that was used when the\n * job was created\n */\n getFilesUploadStatus(\n formModel: VasFormModel\n ): { pending: number; total: number } {\n\n const cameraFieldValues = Object\n .values(this.fields)\n .filter(value => isCameraControlValueV2(value) || isCameraControlValueV1(value));\n\n\n let total = cameraFieldValues.length + this.files.length;\n\n // calculate the number of camera images still to upload\n let pending = cameraFieldValues\n .map((value: VasFileDto | VasCameraControlValueModel) => {\n if (isFileDto(value)) {\n return value.id && value.status !== 'COMPLETE';\n } else if (isCameraControlValueV1(value)) {\n // if url is not set, it hasn't been uploaded\n return value.id && !value.url;\n }\n return false;\n })\n .filter(hasUploaded => hasUploaded)\n .length;\n\n // add count of job.files that are complete\n pending += this.files.filter(value => value.status !== 'COMPLETE').length;\n\n return {\n pending,\n total\n };\n }\n\n /**\n * @param path path segments\n */\n getValueByPath<T>(\n path: string | string[] = []\n ): T | undefined {\n return getValueByPath<T>(\n Array.isArray(path) ? path : path.split('.'),\n this\n );\n }\n\n public toDto(): VasJobDto {\n return {\n id: this.id,\n created: this.created,\n createdBy: this.createdBy,\n modified: this.modified,\n modifiedBy: this.modifiedBy,\n serverCreated: this.serverCreated,\n serverModified: this.serverModified,\n createdByName: this.createdByName,\n modifiedByName: this.modifiedByName,\n account: this.account,\n accessGroup: this.accessGroup,\n reference: this.reference,\n jobDate: this.jobDate,\n jobStatus: this.jobStatus,\n jobType: this.jobType,\n assigneeId: this.assigneeId,\n formId: this.formId,\n timeZoneOffset: this.timeZoneOffset,\n pendingFields: this.pendingFields,\n childModified: this.childModified,\n version: this.version,\n geoLocation: this.geoLocation,\n files: this.files,\n fields: this.fields,\n jobEmails: this.jobEmails,\n notes: this.notes,\n reports: this.reports,\n tasks: this.tasks,\n instruction: this.instruction\n };\n }\n\n /**\n * This method will parse a syntax that allows us to build strings from the\n * values of from the job model. For example if the job model was:\n *\n * {\n * foo: 'bar'\n * }\n *\n * and we pass \"i am foo {foo}\", the result would be:\n *\n * \"i am foo bar\"\n *\n * we can also use moment to parse dates, for example if the job model was:\n *\n * {\n * created: \"2022-01-01T00:00:00+0000\"\n * }\n *\n * and we pass \"{created|date:YY-MM-DD}\", the result would be:\n *\n * \"2022-01-01\"\n *\n * @param {string} value a string with the syntax\n * @param {ParseSyntaxOptions} options\n * @return the results of parsing the syntax on this job\n */\n parseSyntax(\n value: string,\n options: ParseSyntaxOptions = {\n timeZoneOffset: 0\n }\n ): string {\n\n if (!value || typeof value !== 'string') {\n return '';\n }\n const fields = this.fields;\n return value.replace(/({[^}]*})/g, (match: string, token: string) => {\n const syntax = token.substring(1, token.length - 1);\n\n let [key, filter] = syntax.split('|');\n key = (key || '').trim();\n filter = (filter || '').trim();\n\n let filterName, filterArg: string = '';\n if (filter) {\n const splitIndex = filter.indexOf(':');\n if (splitIndex !== -1) {\n filterName = filter.substring(0, splitIndex);\n filterArg = filter.substring(splitIndex + 1);\n } else {\n filterName = filter;\n filterArg = '';\n }\n filterName = (filterName || '').trim();\n filterArg = (filterArg || '').trim();\n }\n const path = key.split('.');\n const objectKey = path.shift() || '';\n let result = '';\n if (objectKey === 'job') {\n result = (this.getValueByPath(path) || '').toString();\n } else if (objectKey === 'fields' || this.fields[path[0]] !== undefined) {\n result = (getValueByPath(path, fields) || '').toString();\n } else if (objectKey.length && options.objects && options.objects[objectKey] !== undefined) {\n result = (getValueByPath(path, options.objects[objectKey]) || '').toString();\n } else {\n return '';\n }\n\n if (filterName && result) {\n switch (filterName) {\n case 'date': {\n if (!options.timeZoneOffset) {\n return moment(result).format(filterArg || '');\n } else {\n return moment(result)\n .utcOffset(options.timeZoneOffset)\n .format(filterArg || '');\n }\n }\n default: {\n console.warn('unknown filter %s', filterName);\n }\n }\n }\n\n return result;\n }).trim();\n };\n\n /**\n * @return {object}\n */\n override toApiDto(): Record<string, string | number | boolean> {\n return {\n ...super.toApiDto(),\n reference: this.reference || '~',\n jobDate: this.jobDate || '~',\n jobType: this.jobType || '~',\n accessGroup: this.accessGroup || '~',\n jobStatus: this.jobStatus || '~',\n assigneeId: this.assigneeId || '~',\n timeZoneOffset: this.timeZoneOffset || 0,\n pendingFields: this.pendingFields || 0,\n lastForm: this.formId || '~'\n };\n }\n\n public static toApiPatchDto(\n item: Partial<VasJobDto>\n ): Partial<VasJobDto> {\n return only(\n item,\n [\n 'created',\n 'modified',\n 'reference',\n 'jobDate',\n 'jobType',\n 'accessGroup',\n 'jobStatus',\n 'assigneeId',\n 'timeZoneOffset',\n 'pendingFields',\n 'formId'\n ]\n );\n }\n}\n"]}
1
+ {"version":3,"file":"vas-job.model.js","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/entity/vas-job.model.ts"],"names":[],"mappings":";;;;AAAA,iDAAuD;AACvD,4DAA4B;AAC5B,kEAA4D;AAK5D,+FAAwF;AACxF,oCAA4D;AAC5D,oDAA8G;AAC9G,wCAAqC;AAMrC,gDAA4C;AAC5C,8DAAyD;AAgBzD,IAAI,cAAuC,CAAC;AAE5C,SAAS,sBAAsB;IAC7B,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,OAAO,cAAc,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,mBAAmB,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;AACnF,CAAC;AAED;;GAEG;AACH,MAAa,WAAY,SAAQ,qEAA+B;IAE9D,YACkB,EAAU,EACV,OAAe,EACf,aAAqB,EACrB,SAAiB,EACjB,QAAgB,EAChB,cAAsB,EACtB,UAAkB,EAClB,aAAqB,EACrB,cAAsB,EACtB,OAAe,EACf,WAAmB,EAC5B,SAAiB,EACjB,OAAe,EACf,SAAiB,EACjB,OAAe,EACf,UAAkB,EAClB,MAAc,EACd,cAAsB,EACtB,aAAqB,EACrB,aAAqB,EACrB,OAAe,EACf,WAAwB,EACxB,KAAwB,EACxB,MAAsC,EACtC,SAAgC,EAChC,KAAwB,EACxB,OAA4B,EAC5B,KAAwB,EACxB,WAAqC;QAE5C,KAAK,CACH,EAAE,EACF,OAAO,EACP,aAAa,EACb,SAAS,EACT,QAAQ,EACR,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,OAAO,EACP,WAAW,CACZ,CAAC;QA1Cc,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAQ;QACf,kBAAa,GAAb,aAAa,CAAQ;QACrB,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,mBAAc,GAAd,cAAc,CAAQ;QACtB,eAAU,GAAV,UAAU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CACF;AAvYD,kCAuYC","sourcesContent":["import { isFileDto, VasFileDto } from './vas-file.dto';\nimport moment from 'moment';\nimport { getValueByPath } from '../utils/get-value-by-path';\nimport { VasBaseDto } from './vas-base.dto';\nimport { FieldValueType, VasFieldDto } from './vas-field.dto';\nimport { VasFormModel } from './vas-form.model';\nimport { VasJobDto } from './vas-job.dto';\nimport { VasRestrictedAccountObjectModel } from './vas-restricted-account-object.model';\nimport { GeoLocation, getEmptyGeoLocation } from '../model';\nimport { isCameraControlValueV1, VasCameraControlValueModel, isCameraControlValueV2 } from '../control-value';\nimport { only } from '../utils/only';\nimport { VasReportDto } from './vas-report.dto';\nimport { VasTaskDto } from './vas-task.dto';\nimport { VasNoteDto } from './vas-note.dto';\nimport { VasJobEmailDto } from './vas-job-email.dto';\nimport { VasInstructionDto } from './vas-instruction.dto';\nimport { tryJson } from \"../utils/try-json\";\nimport { isPlainObject } from \"../utils/is-plain-object\";\n\nexport interface ParseSyntaxOptions {\n // This value will be used to adjust any datetime values that are referenced\n // in the syntax string. See\n // https://momentjscom.readthedocs.io/en/latest/moment/03-manipulating/09-utc-offset/\n // for more information about how `moment` will handle the value.\n timeZoneOffset: number,\n // this dictionary can be passed in to contain other objects to be referenced\n // in the syntax. For example if we have {job.foo} this will reference the\n // job's `foo` property, however if we have \"reportLayout.title\" this will\n // expect to find a property of `objects` called `reportLayout` which will\n // have a property called `title`\n objects?: Record<string, Partial<VasBaseDto> | Record<string, FieldValueType>>;\n}\n\nlet jobStaticProps: Set<string> | undefined;\n\nfunction getJobStaticProperties() {\n if (jobStaticProps) {\n return jobStaticProps;\n }\n return jobStaticProps = new Set(Object.getOwnPropertyNames(VasJobModel.empty()));\n}\n\n/**\n * JobModel\n */\nexport class VasJobModel extends VasRestrictedAccountObjectModel {\n\n constructor(\n public override id: string,\n public override created: string,\n public override serverCreated: string,\n public override createdBy: string,\n public override modified: string,\n public override serverModified: string,\n public override modifiedBy: string,\n public override createdByName: string,\n public override modifiedByName: string,\n public override account: string,\n public override accessGroup: string,\n public reference: string,\n public jobDate: string,\n public jobStatus: string,\n public jobType: string,\n public assigneeId: string,\n public formId: string,\n public timeZoneOffset: number,\n public pendingFields: number,\n public childModified: string,\n public version: number,\n public geoLocation: GeoLocation,\n public files: Array<VasFileDto>,\n public fields: Record<string, FieldValueType>,\n public jobEmails: Array<VasJobEmailDto>,\n public notes: Array<VasNoteDto>,\n public reports: Array<VasReportDto>,\n public tasks: Array<VasTaskDto>,\n public instruction: VasInstructionDto | null\n ) {\n super(\n id,\n created,\n serverCreated,\n createdBy,\n modified,\n serverModified,\n modifiedBy,\n createdByName,\n modifiedByName,\n account,\n accessGroup\n );\n }\n\n get createdByDisplayName(): string {\n return this.createdByName;\n }\n\n get modifiedByDisplayName(): string {\n return this.modifiedByName;\n }\n\n /**\n * Return the list of Job properties\n */\n get staticProperties(): Set<string> {\n if (jobStaticProps) {\n return jobStaticProps;\n }\n return jobStaticProps = new Set(Object.getOwnPropertyNames(VasJobModel.empty()));\n }\n\n /**\n * @return {VasJobModel}\n */\n static empty(): VasJobModel {\n return new VasJobModel(\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n '',\n moment().utcOffset(),\n 0,\n '',\n 0,\n getEmptyGeoLocation(),\n [],\n {},\n [],\n [],\n [],\n [],\n null\n );\n }\n\n static override fromDto(dto: Partial<VasJobDto>): VasJobModel {\n // we have changed the job model and stopped using the dynamic properties\n // from form group names to hold fields. Instead, we store a simple object\n // where the control name (minus the \"fields.\" prefix) is the key, and the\n // field value is the value. However, we have to cater for data that may\n // be persisted in the old structure, or an API response where fields is an\n // array of VasFieldDto.\n\n // 1: if dto.fields is already an object, we use the existing value\n const fields: Record<string, FieldValueType> =\n isPlainObject<Record<string, FieldValueType>>(dto.fields) ?\n dto.fields :\n {};\n\n // 2: if dto.fields is an array, we're handling a vas-rest response, we\n // iterate over the fields and update the fields object.\n Array.isArray(dto.fields) && dto.fields.forEach((field: VasFieldDto) => {\n fields[field.controlName.replace('fields.', '')] = tryJson(field.value);\n });\n\n // 3: if `fields` still has no keys, we're restoring a VasJobDto object that\n // was saved in the old \"form-group\" style, where dynamic keys are\n // derived from the form-group names. We'll iterate over those keys, and\n // update the `fields` object. Once this model is serialized back to a\n // dto, it will have the new shape.\n if (Object.keys(fields).length === 0) {\n Object\n .keys(dto)\n .filter(key => !getJobStaticProperties().has(key))\n .forEach(groupName => {\n Object\n .keys((dto as any)[groupName])\n .forEach(controlName => {\n const cn = controlName.replace('fields.', '');\n fields[cn] = (dto as any)[groupName][controlName];\n });\n });\n }\n\n return new VasJobModel(\n dto.id || '',\n dto.created || '',\n dto.serverCreated || '',\n dto.createdBy || '',\n dto.modified || '',\n dto.serverModified || '',\n dto.modifiedBy || '',\n dto.createdByName || '',\n dto.modifiedByName || '',\n dto.account || '',\n dto.accessGroup || '',\n dto.reference || '',\n dto.jobDate || '',\n dto.jobStatus || '',\n dto.jobType || '',\n dto.assigneeId || '',\n dto.formId || (dto as any).lastForm || '',\n dto.timeZoneOffset || moment().utcOffset(),\n dto.pendingFields || 0,\n dto.childModified || '',\n dto.version || 0,\n dto.geoLocation || getEmptyGeoLocation(),\n dto.files || [],\n fields,\n dto.jobEmails || [],\n dto.notes || [],\n dto.reports || [],\n dto.tasks || [],\n dto.instruction || null\n );\n }\n\n /**\n * Returns an object describing how many attachments were added to this job\n * (camera controls and files), and how many have not been uploaded yet.\n *\n * @param formModel instance of {@link VasFormModel} that was used when the\n * job was created\n */\n getFilesUploadStatus(\n formModel: VasFormModel\n ): { pending: number; total: number } {\n\n const cameraFieldValues = Object\n .values(this.fields)\n .filter(value => isCameraControlValueV2(value) || isCameraControlValueV1(value));\n\n\n let total = cameraFieldValues.length + this.files.length;\n\n // calculate the number of camera images still to upload\n let pending = cameraFieldValues\n .map((value: VasFileDto | VasCameraControlValueModel) => {\n if (isFileDto(value)) {\n return value.id && value.status !== 'COMPLETE';\n } else if (isCameraControlValueV1(value)) {\n // if url is not set, it hasn't been uploaded\n return value.id && !value.url;\n }\n return false;\n })\n .filter(hasUploaded => hasUploaded)\n .length;\n\n // add count of job.files that are complete\n pending += this.files.filter(value => value.status !== 'COMPLETE').length;\n\n return {\n pending,\n total\n };\n }\n\n /**\n * @param path path segments\n */\n getValueByPath<T>(\n path: string | string[] = []\n ): T | undefined {\n return getValueByPath<T>(\n Array.isArray(path) ? path : path.split('.'),\n this\n );\n }\n\n public toDto(): VasJobDto {\n return {\n id: this.id,\n created: this.created,\n createdBy: this.createdBy,\n modified: this.modified,\n modifiedBy: this.modifiedBy,\n serverCreated: this.serverCreated,\n serverModified: this.serverModified,\n createdByName: this.createdByName,\n modifiedByName: this.modifiedByName,\n account: this.account,\n accessGroup: this.accessGroup,\n reference: this.reference,\n jobDate: this.jobDate,\n jobStatus: this.jobStatus,\n jobType: this.jobType,\n assigneeId: this.assigneeId,\n formId: this.formId,\n timeZoneOffset: this.timeZoneOffset,\n pendingFields: this.pendingFields,\n childModified: this.childModified,\n version: this.version,\n geoLocation: this.geoLocation,\n files: this.files,\n fields: this.fields,\n jobEmails: this.jobEmails,\n notes: this.notes,\n reports: this.reports,\n tasks: this.tasks,\n instruction: this.instruction\n };\n }\n\n /**\n * This method will parse a syntax that allows us to build strings from the\n * values of from the job model. For example if the job model was:\n *\n * {\n * foo: 'bar'\n * }\n *\n * and we pass \"i am foo {foo}\", the result would be:\n *\n * \"i am foo bar\"\n *\n * we can also use moment to parse dates, for example if the job model was:\n *\n * {\n * created: \"2022-01-01T00:00:00+0000\"\n * }\n *\n * and we pass \"{created|date:YY-MM-DD}\", the result would be:\n *\n * \"2022-01-01\"\n *\n * @param {string} value a string with the syntax\n * @param {ParseSyntaxOptions} options\n * @return the results of parsing the syntax on this job\n */\n parseSyntax(\n value: string,\n options: ParseSyntaxOptions = {\n timeZoneOffset: 0\n }\n ): string {\n\n if (!value || typeof value !== 'string') {\n return '';\n }\n const fields = this.fields;\n return value.replace(/({[^}]*})/g, (match: string, token: string) => {\n const syntax = token.substring(1, token.length - 1);\n\n let [key, filter] = syntax.split('|');\n key = (key || '').trim();\n filter = (filter || '').trim();\n\n let filterName, filterArg: string = '';\n if (filter) {\n const splitIndex = filter.indexOf(':');\n if (splitIndex !== -1) {\n filterName = filter.substring(0, splitIndex);\n filterArg = filter.substring(splitIndex + 1);\n } else {\n filterName = filter;\n filterArg = '';\n }\n filterName = (filterName || '').trim();\n filterArg = (filterArg || '').trim();\n }\n const path = key.split('.');\n const objectKey = path.shift() || '';\n let result = '';\n if (objectKey === 'job') {\n result = (this.getValueByPath(path) || '').toString();\n } else if (objectKey === 'fields' || this.fields[path[0]] !== undefined) {\n result = (getValueByPath(path, fields) || '').toString();\n } else if (objectKey.length && options.objects && options.objects[objectKey] !== undefined) {\n result = (getValueByPath(path, options.objects[objectKey]) || '').toString();\n } else {\n return '';\n }\n\n if (filterName && result) {\n switch (filterName) {\n case 'date': {\n if (!options.timeZoneOffset) {\n return moment(result).format(filterArg || '');\n } else {\n return moment(result)\n .utcOffset(options.timeZoneOffset)\n .format(filterArg || '');\n }\n }\n default: {\n console.warn('unknown filter %s', filterName);\n }\n }\n }\n\n return result;\n }).trim();\n };\n\n /**\n * @return {object}\n */\n override toApiDto(): Record<string, string | number | boolean> {\n return {\n ...super.toApiDto(),\n reference: this.reference || '~',\n jobDate: this.jobDate || '~',\n jobType: this.jobType || '~',\n accessGroup: this.accessGroup || '~',\n jobStatus: this.jobStatus || '~',\n assigneeId: this.assigneeId || '~',\n timeZoneOffset: this.timeZoneOffset || 0,\n pendingFields: this.pendingFields || 0,\n lastForm: this.formId || '~'\n };\n }\n\n public static toApiPatchDto(\n item: Partial<VasJobDto>\n ): Partial<VasJobDto> {\n return only(\n item,\n [\n 'created',\n 'modified',\n 'reference',\n 'jobDate',\n 'jobType',\n 'accessGroup',\n 'jobStatus',\n 'assigneeId',\n 'timeZoneOffset',\n 'pendingFields',\n 'formId'\n ]\n );\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { EstimateDto, EstimateSummaryDto } from './estimate.dto';
2
+ export interface EstimateControlValueSummaryDto {
3
+ original: EstimateSummaryDto;
4
+ latest: EstimateSummaryDto;
5
+ savings: EstimateSummaryDto;
6
+ }
7
+ /**
8
+ * Describes the value of the estimate control
9
+ */
10
+ export interface EstimateControlValueDto {
11
+ estimates: Array<EstimateDto>;
12
+ summary: EstimateControlValueSummaryDto;
13
+ }
14
+ //# sourceMappingURL=estimate-control-value.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-control-value.dto.d.ts","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate-control-value.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9B,OAAO,EAAE,8BAA8B,CAAC;CACzC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=estimate-control-value.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-control-value.dto.js","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate-control-value.dto.ts"],"names":[],"mappings":"","sourcesContent":["import { EstimateDto, EstimateSummaryDto } from './estimate.dto';\n\nexport interface EstimateControlValueSummaryDto {\n original: EstimateSummaryDto;\n latest: EstimateSummaryDto;\n savings: EstimateSummaryDto;\n}\n\n/**\n * Describes the value of the estimate control\n */\nexport interface EstimateControlValueDto {\n estimates: Array<EstimateDto>;\n summary: EstimateControlValueSummaryDto;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { EstimateControlValueSummaryDto } from './estimate-control-value.dto';
2
+ import { EstimateModel } from './estimate.model';
3
+ /**
4
+ * Utility class for computing the summary value for an estimate control given
5
+ * the first and last estimates
6
+ */
7
+ export declare class EstimateControlValueModel {
8
+ static calculateSummary(original: EstimateModel, latest: EstimateModel): EstimateControlValueSummaryDto;
9
+ static getEmptySummary(): EstimateControlValueSummaryDto;
10
+ }
11
+ //# sourceMappingURL=estimate-control-value.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-control-value.model.d.ts","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate-control-value.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKjD;;;GAGG;AACH,qBAAa,yBAAyB;IAEpC,MAAM,CAAC,gBAAgB,CACrB,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,aAAa,GACpB,8BAA8B;IA6BjC,MAAM,CAAC,eAAe,IAAI,8BAA8B;CA8CzD"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EstimateControlValueModel = void 0;
4
+ const big_js_1 = require("big.js");
5
+ const b = (value = '0') => new big_js_1.Big(value);
6
+ /**
7
+ * Utility class for computing the summary value for an estimate control given
8
+ * the first and last estimates
9
+ */
10
+ class EstimateControlValueModel {
11
+ static calculateSummary(original, latest) {
12
+ const o = original.summary;
13
+ const l = latest.adjusted ?
14
+ latest.summaryAdjusted :
15
+ latest.summary;
16
+ const s = {
17
+ labour: b(o.labour).minus(l.labour).toFixed(2),
18
+ none: b(o.none).minus(l.none).toFixed(2),
19
+ parts: b(o.parts).minus(l.parts).toFixed(2),
20
+ pm: b(o.pm).minus(l.pm).toFixed(2),
21
+ pl: b(o.pm).minus(l.pl).toFixed(2),
22
+ specialist: b(o.specialist).minus(l.specialist).toFixed(2),
23
+ other: b(o.other).minus(l.other).toFixed(2),
24
+ net: b(o.net).minus(l.net).toFixed(2),
25
+ vat: b(o.vat).minus(l.vat).toFixed(2),
26
+ gross: b(o.gross).minus(l.gross).toFixed(2),
27
+ hours: b(o.hours).minus(l.hours).toFixed(0),
28
+ labourRate: b(o.labourRate).minus(l.labourRate).toFixed(0)
29
+ };
30
+ return {
31
+ original: o,
32
+ latest: l,
33
+ savings: s
34
+ };
35
+ }
36
+ static getEmptySummary() {
37
+ return {
38
+ original: {
39
+ labour: '0.00',
40
+ none: '0.00',
41
+ parts: '0.00',
42
+ pm: '0.00',
43
+ pl: '0.00',
44
+ specialist: '0.00',
45
+ other: '0.00',
46
+ net: '0.00',
47
+ vat: '0.00',
48
+ gross: '0.00',
49
+ hours: '0',
50
+ labourRate: '0.00'
51
+ },
52
+ latest: {
53
+ labour: '0.00',
54
+ none: '0.00',
55
+ parts: '0.00',
56
+ pm: '0.00',
57
+ pl: '0.00',
58
+ specialist: '0.00',
59
+ other: '0.00',
60
+ net: '0.00',
61
+ vat: '0.00',
62
+ gross: '0.00',
63
+ hours: '0',
64
+ labourRate: '0.00'
65
+ },
66
+ savings: {
67
+ labour: '0.00',
68
+ none: '0.00',
69
+ parts: '0.00',
70
+ pm: '0.00',
71
+ pl: '0.00',
72
+ specialist: '0.00',
73
+ other: '0.00',
74
+ net: '0.00',
75
+ vat: '0.00',
76
+ gross: '0.00',
77
+ hours: '0',
78
+ labourRate: '0.00'
79
+ }
80
+ };
81
+ }
82
+ }
83
+ exports.EstimateControlValueModel = EstimateControlValueModel;
84
+ //# sourceMappingURL=estimate-control-value.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-control-value.model.js","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate-control-value.model.ts"],"names":[],"mappings":";;;AAAA,mCAAwC;AAKxC,MAAM,CAAC,GAAG,CAAC,QA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BACV,EAAE,EAAE,MAAM;gBACV,UAAU,EAAE,MAAM;gBAClB,KAAK,EAAE,MAAM;gBACb,GAAG,EAAE,MAAM;gBACX,GAAG,EAAE,MAAM;gBACX,KAAK,EAAE,MAAM;gBACb,KAAK,EAAE,GAAG;gBACV,UAAU,EAAE,MAAM;aACnB;YACD,OAAO,EAAE;gBACP,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;gBACb,EAAE,EAAE,MAAM;gBACV,EAAE,EAAE,MAAM;gBACV,UAAU,EAAE,MAAM;gBAClB,KAAK,EAAE,MAAM;gBACb,GAAG,EAAE,MAAM;gBACX,GAAG,EAAE,MAAM;gBACX,KAAK,EAAE,MAAM;gBACb,KAAK,EAAE,GAAG;gBACV,UAAU,EAAE,MAAM;aACnB;SACF,CAAC;IACJ,CAAC;CACF;AAhFD,8DAgFC","sourcesContent":["import { Big, BigSource } from 'big.js';\nimport { EstimateControlValueSummaryDto } from './estimate-control-value.dto';\nimport { EstimateModel } from './estimate.model';\nimport { EstimateSummaryDto } from './estimate.dto';\n\nconst b = (value: BigSource = '0') => new Big(value);\n\n/**\n * Utility class for computing the summary value for an estimate control given\n * the first and last estimates\n */\nexport class EstimateControlValueModel {\n\n static calculateSummary(\n original: EstimateModel,\n latest: EstimateModel\n ): EstimateControlValueSummaryDto {\n\n const o: EstimateSummaryDto = original.summary;\n\n const l: EstimateSummaryDto = latest.adjusted ?\n latest.summaryAdjusted as EstimateSummaryDto :\n latest.summary;\n\n const s: EstimateControlValueSummaryDto['savings'] = {\n labour: b(o.labour).minus(l.labour).toFixed(2),\n none: b(o.none).minus(l.none).toFixed(2),\n parts: b(o.parts).minus(l.parts).toFixed(2),\n pm: b(o.pm).minus(l.pm).toFixed(2),\n pl: b(o.pm).minus(l.pl).toFixed(2),\n specialist: b(o.specialist).minus(l.specialist).toFixed(2),\n other: b(o.other).minus(l.other).toFixed(2),\n net: b(o.net).minus(l.net).toFixed(2),\n vat: b(o.vat).minus(l.vat).toFixed(2),\n gross: b(o.gross).minus(l.gross).toFixed(2),\n hours: b(o.hours).minus(l.hours).toFixed(0),\n labourRate: b(o.labourRate).minus(l.labourRate).toFixed(0)\n };\n return {\n original: o,\n latest: l,\n savings: s\n };\n }\n\n static getEmptySummary(): EstimateControlValueSummaryDto {\n return {\n original: {\n labour: '0.00',\n none: '0.00',\n parts: '0.00',\n pm: '0.00',\n pl: '0.00',\n specialist: '0.00',\n other: '0.00',\n net: '0.00',\n vat: '0.00',\n gross: '0.00',\n hours: '0',\n labourRate: '0.00'\n },\n latest: {\n labour: '0.00',\n none: '0.00',\n parts: '0.00',\n pm: '0.00',\n pl: '0.00',\n specialist: '0.00',\n other: '0.00',\n net: '0.00',\n vat: '0.00',\n gross: '0.00',\n hours: '0',\n labourRate: '0.00'\n },\n savings: {\n labour: '0.00',\n none: '0.00',\n parts: '0.00',\n pm: '0.00',\n pl: '0.00',\n specialist: '0.00',\n other: '0.00',\n net: '0.00',\n vat: '0.00',\n gross: '0.00',\n hours: '0',\n labourRate: '0.00'\n }\n };\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { EstimateCostCategory, EstimateWorkCategory } from './estimate.types';
2
+ export interface EstimateItemDto {
3
+ id: string;
4
+ description: string;
5
+ type: string;
6
+ quantity: number;
7
+ units: number;
8
+ price: string;
9
+ workCategory: EstimateWorkCategory;
10
+ costCategory: EstimateCostCategory;
11
+ comment: string;
12
+ quantityAdjusted: number;
13
+ unitsAdjusted: number;
14
+ priceAdjusted: string;
15
+ }
16
+ //# sourceMappingURL=estimate-item.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-item.dto.d.ts","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate-item.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,oBAAoB,CAAC;IACnC,YAAY,EAAE,oBAAoB,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=estimate-item.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-item.dto.js","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate-item.dto.ts"],"names":[],"mappings":"","sourcesContent":["import { EstimateCostCategory, EstimateWorkCategory } from './estimate.types';\n\nexport interface EstimateItemDto {\n id: string;\n description: string;\n type: string;\n quantity: number;\n units: number;\n price: string;\n workCategory: EstimateWorkCategory;\n costCategory: EstimateCostCategory;\n comment: string;\n quantityAdjusted: number;\n unitsAdjusted: number;\n priceAdjusted: string;\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { EstimateItemDto } from './estimate-item.dto';
2
+ import { EstimateCostCategory, EstimateWorkCategory } from './estimate.types';
3
+ export declare class EstimateItemModel {
4
+ id: string;
5
+ description: string;
6
+ type: string;
7
+ quantity: number;
8
+ quantityAdjusted: number;
9
+ units: number;
10
+ unitsAdjusted: number;
11
+ price: string;
12
+ priceAdjusted: string;
13
+ workCategory: EstimateWorkCategory;
14
+ costCategory: EstimateCostCategory;
15
+ comment: string;
16
+ constructor(id: string, description: string, type: string, quantity: number, quantityAdjusted: number, units: number, unitsAdjusted: number, price: string, priceAdjusted: string, workCategory: EstimateWorkCategory, costCategory: EstimateCostCategory, comment: string);
17
+ getTotalUnits(adjusted?: boolean): string;
18
+ getLineValue(labourRate?: string, timeBasis?: string, adjusted?: boolean): string;
19
+ toDto(): EstimateItemDto;
20
+ static create(): EstimateItemModel;
21
+ static fromDto(dto: Partial<EstimateItemDto>): EstimateItemModel;
22
+ static equal(a: EstimateItemDto | undefined, b: EstimateItemDto | undefined): boolean;
23
+ }
24
+ //# sourceMappingURL=estimate-item.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-item.model.d.ts","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate-item.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAe9E,qBAAa,iBAAiB;IAGnB,EAAE,EAAE,MAAM;IACV,WAAW,EAAE,MAAM;IACnB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,MAAM;IAChB,gBAAgB,EAAE,MAAM;IACxB,KAAK,EAAE,MAAM;IACb,aAAa,EAAE,MAAM;IACrB,KAAK,EAAE,MAAM;IACb,aAAa,EAAE,MAAM;IACrB,YAAY,EAAE,oBAAoB;IAClC,YAAY,EAAE,oBAAoB;IAClC,OAAO,EAAE,MAAM;gBAXf,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,oBAAoB,EAClC,YAAY,EAAE,oBAAoB,EAClC,OAAO,EAAE,MAAM;IAIxB,aAAa,CAAC,QAAQ,UAAQ,GAAG,MAAM;IAMvC,YAAY,CACV,UAAU,SAAM,EAChB,SAAS,SAAM,EACf,QAAQ,UAAQ,GACf,MAAM;IA+CT,KAAK,IAAI,eAAe;IAiBxB,MAAM,CAAC,MAAM,IAAI,iBAAiB;IAiBlC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,iBAAiB;IAiBhE,MAAM,CAAC,KAAK,CACV,CAAC,EAAE,eAAe,GAAG,SAAS,EAC9B,CAAC,EAAE,eAAe,GAAG,SAAS,GAC7B,OAAO;CAiBX"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EstimateItemModel = void 0;
4
+ const big_js_1 = require("big.js");
5
+ const uuid_1 = require("uuid");
6
+ const b = (value = '0') => {
7
+ try {
8
+ if (typeof value === 'string') {
9
+ return new big_js_1.Big(value.replace(/[^\d^.]/g, ''));
10
+ }
11
+ return new big_js_1.Big(value);
12
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
+ }
14
+ catch (e) {
15
+ console.error(`failed to construct Big from value '${value}'`);
16
+ return new big_js_1.Big('0');
17
+ }
18
+ };
19
+ class EstimateItemModel {
20
+ constructor(id, description, type, quantity, quantityAdjusted, units, unitsAdjusted, price, priceAdjusted, workCategory, costCategory, comment) {
21
+ this.id = id;
22
+ this.description = description;
23
+ this.type = type;
24
+ this.quantity = quantity;
25
+ this.quantityAdjusted = quantityAdjusted;
26
+ this.units = units;
27
+ this.unitsAdjusted = unitsAdjusted;
28
+ this.price = price;
29
+ this.priceAdjusted = priceAdjusted;
30
+ this.workCategory = workCategory;
31
+ this.costCategory = costCategory;
32
+ this.comment = comment;
33
+ }
34
+ getTotalUnits(adjusted = false) {
35
+ return adjusted ?
36
+ b(this.quantityAdjusted || '0').mul(this.unitsAdjusted || '0').toFixed(2) :
37
+ b(this.quantity || '0').mul(this.units || '0').toFixed(2);
38
+ }
39
+ getLineValue(labourRate = '1', timeBasis = '1', adjusted = false) {
40
+ const cat = this.costCategory || 'none';
41
+ if (this.workCategory === 'removed') {
42
+ return '0';
43
+ }
44
+ const units = (adjusted ? this.unitsAdjusted : this.units) || 0;
45
+ const quantity = (adjusted ? this.quantityAdjusted : this.quantity) || 0;
46
+ const price = (adjusted ? this.priceAdjusted : this.price) || '';
47
+ try {
48
+ switch (cat) {
49
+ case 'labour': {
50
+ return price != '' ?
51
+ price :
52
+ b(quantity || '0')
53
+ .mul(units || '0')
54
+ .mul(labourRate || '0')
55
+ .div(timeBasis || '1')
56
+ .toFixed(2);
57
+ }
58
+ case 'pm': {
59
+ return b(price || '0')
60
+ .mul(quantity || '0')
61
+ .toFixed(2);
62
+ }
63
+ case 'parts': {
64
+ return b(price || '0')
65
+ .mul(quantity || '0')
66
+ .toFixed(2);
67
+ }
68
+ case 'specialist': {
69
+ return b(price || '0')
70
+ .mul(quantity || '0')
71
+ .toFixed(2);
72
+ }
73
+ default: {
74
+ return '0';
75
+ }
76
+ }
77
+ }
78
+ catch (e) {
79
+ console.warn(e);
80
+ }
81
+ return '0';
82
+ }
83
+ toDto() {
84
+ return {
85
+ id: this.id,
86
+ description: this.description,
87
+ type: this.type,
88
+ quantity: this.quantity,
89
+ quantityAdjusted: this.quantityAdjusted,
90
+ units: this.units,
91
+ unitsAdjusted: this.unitsAdjusted,
92
+ price: this.price,
93
+ priceAdjusted: this.priceAdjusted,
94
+ workCategory: this.workCategory,
95
+ costCategory: this.costCategory,
96
+ comment: this.comment
97
+ };
98
+ }
99
+ static create() {
100
+ return new EstimateItemModel((0, uuid_1.v4)(), '', '', 1, 1, 0, 0, '', '', 'none', 'none', '');
101
+ }
102
+ static fromDto(dto) {
103
+ return new EstimateItemModel(dto.id || (0, uuid_1.v4)(), dto.description || '', dto.type || '', dto.quantity || 0, dto.quantityAdjusted || 0, dto.units || 0, dto.unitsAdjusted || 0, dto.price || '', dto.priceAdjusted || '', dto.workCategory || 'none', dto.costCategory || 'none', dto.comment || '');
104
+ }
105
+ static equal(a, b) {
106
+ return ((a === null || a === void 0 ? void 0 : a.id) === (b === null || b === void 0 ? void 0 : b.id) &&
107
+ (a === null || a === void 0 ? void 0 : a.description) === (b === null || b === void 0 ? void 0 : b.description) &&
108
+ (a === null || a === void 0 ? void 0 : a.type) === (b === null || b === void 0 ? void 0 : b.type) &&
109
+ (a === null || a === void 0 ? void 0 : a.quantity) === (b === null || b === void 0 ? void 0 : b.quantity) &&
110
+ (a === null || a === void 0 ? void 0 : a.quantityAdjusted) === (b === null || b === void 0 ? void 0 : b.quantityAdjusted) &&
111
+ (a === null || a === void 0 ? void 0 : a.units) === (b === null || b === void 0 ? void 0 : b.units) &&
112
+ (a === null || a === void 0 ? void 0 : a.unitsAdjusted) === (b === null || b === void 0 ? void 0 : b.unitsAdjusted) &&
113
+ (a === null || a === void 0 ? void 0 : a.price) === (b === null || b === void 0 ? void 0 : b.price) &&
114
+ (a === null || a === void 0 ? void 0 : a.priceAdjusted) === (b === null || b === void 0 ? void 0 : b.priceAdjusted) &&
115
+ (a === null || a === void 0 ? void 0 : a.workCategory) === (b === null || b === void 0 ? void 0 : b.workCategory) &&
116
+ (a === null || a === void 0 ? void 0 : a.costCategory) === (b === null || b === void 0 ? void 0 : b.costCategory) &&
117
+ (a === null || a === void 0 ? void 0 : a.comment) === (b === null || b === void 0 ? void 0 : b.comment));
118
+ }
119
+ }
120
+ exports.EstimateItemModel = EstimateItemModel;
121
+ //# sourceMappingURL=estimate-item.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-item.model.js","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate-item.model.ts"],"names":[],"mappings":";;;AAAA,mCAA6B;AAE7B,+BAAkC;AAGlC,MAAM,CAAC,GAAG,CAAC,QAA+B,GAAG,EAAE,EAAE;IAC/C,IAAI,CAAC;QACH,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,YAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC;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,KAAK,CAAA;YACrB,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,aAAa,OAAK,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,aAAa,CAAA;YACrC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,KAAK,OAAK,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,KAAK,CAAA;YACrB,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,aAAa,OAAK,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,aAAa,CAAA;YACrC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,YAAY,OAAK,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,YAAY,CAAA;YACnC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,YAAY,OAAK,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,YAAY,CAAA;YACnC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,OAAK,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,CAAA,CAC1B,CAAC;IACJ,CAAC;CAEF;AAlJD,8CAkJC","sourcesContent":["import { Big } from 'big.js';\nimport { EstimateItemDto } from './estimate-item.dto';\nimport { v4 as uuid } from 'uuid';\nimport { EstimateCostCategory, EstimateWorkCategory } from './estimate.types';\n\nconst b = (value: string | number | Big = '0') => {\n try {\n if (typeof value === 'string') {\n return new Big(value.replace(/[^\\d^.]/g, ''));\n }\n return new Big(value);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n console.error(`failed to construct Big from value '${value}'`);\n return new Big('0');\n }\n};\n\nexport class EstimateItemModel {\n\n constructor(\n public id: string,\n public description: string,\n public type: string,\n public quantity: number,\n public quantityAdjusted: number,\n public units: number,\n public unitsAdjusted: number,\n public price: string,\n public priceAdjusted: string,\n public workCategory: EstimateWorkCategory,\n public costCategory: EstimateCostCategory,\n public comment: string\n ) {\n }\n\n getTotalUnits(adjusted = false): string {\n return adjusted ?\n b(this.quantityAdjusted || '0').mul(this.unitsAdjusted || '0').toFixed(2) :\n b(this.quantity || '0').mul(this.units || '0').toFixed(2);\n }\n\n getLineValue(\n labourRate = '1',\n timeBasis = '1',\n adjusted = false\n ): string {\n const cat: EstimateCostCategory = this.costCategory || 'none';\n\n if (this.workCategory === 'removed') {\n return '0';\n }\n\n const units = (adjusted ? this.unitsAdjusted : this.units) || 0;\n const quantity = (adjusted ? this.quantityAdjusted : this.quantity) || 0;\n const price = (adjusted ? this.priceAdjusted : this.price) || '';\n\n try {\n switch (cat) {\n case 'labour': {\n return price != '' ?\n price :\n b(quantity || '0')\n .mul(units || '0')\n .mul(labourRate || '0')\n .div(timeBasis || '1')\n .toFixed(2);\n }\n case 'pm': {\n return b(price || '0')\n .mul(quantity || '0')\n .toFixed(2);\n }\n case 'parts': {\n return b(price || '0')\n .mul(quantity || '0')\n .toFixed(2);\n }\n case 'specialist': {\n return b(price || '0')\n .mul(quantity || '0')\n .toFixed(2);\n }\n default: {\n return '0';\n }\n }\n } catch (e) {\n console.warn(e);\n }\n return '0';\n }\n\n toDto(): EstimateItemDto {\n return {\n id: this.id,\n description: this.description,\n type: this.type,\n quantity: this.quantity,\n quantityAdjusted: this.quantityAdjusted,\n units: this.units,\n unitsAdjusted: this.unitsAdjusted,\n price: this.price,\n priceAdjusted: this.priceAdjusted,\n workCategory: this.workCategory,\n costCategory: this.costCategory,\n comment: this.comment\n };\n }\n\n static create(): EstimateItemModel {\n return new EstimateItemModel(\n uuid(),\n '',\n '',\n 1,\n 1,\n 0,\n 0,\n '',\n '',\n 'none',\n 'none',\n ''\n );\n }\n\n static fromDto(dto: Partial<EstimateItemDto>): EstimateItemModel {\n return new EstimateItemModel(\n dto.id || uuid(),\n dto.description || '',\n dto.type || '',\n dto.quantity || 0,\n dto.quantityAdjusted || 0,\n dto.units || 0,\n dto.unitsAdjusted || 0,\n dto.price || '',\n dto.priceAdjusted || '',\n dto.workCategory || 'none',\n dto.costCategory || 'none',\n dto.comment || ''\n );\n }\n\n static equal(\n a: EstimateItemDto | undefined,\n b: EstimateItemDto | undefined\n ): boolean {\n return (\n a?.id === b?.id &&\n a?.description === b?.description &&\n a?.type === b?.type &&\n a?.quantity === b?.quantity &&\n a?.quantityAdjusted === b?.quantityAdjusted &&\n a?.units === b?.units &&\n a?.unitsAdjusted === b?.unitsAdjusted &&\n a?.price === b?.price &&\n a?.priceAdjusted === b?.priceAdjusted &&\n a?.workCategory === b?.workCategory &&\n a?.costCategory === b?.costCategory &&\n a?.comment === b?.comment\n );\n }\n\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import { EstimateItemDto } from './estimate-item.dto';
2
+ import { EstimateSource, EstimateSundryMethod } from './estimate.model';
3
+ import { EstimateCostCategory } from './estimate.types';
4
+ export type CostCategorySummary = Record<EstimateCostCategory, string>;
5
+ export interface CostCategorySummaryTotals {
6
+ net: string;
7
+ vat: string;
8
+ gross: string;
9
+ hours: string;
10
+ labourRate: string;
11
+ }
12
+ export type EstimateSummaryDto = CostCategorySummary & CostCategorySummaryTotals;
13
+ export interface EstimateDto {
14
+ id: string;
15
+ source: EstimateSource;
16
+ label: string;
17
+ comment: string;
18
+ timestamp: string;
19
+ version: number;
20
+ net: string;
21
+ vat: string;
22
+ gross: string;
23
+ labourRate: string;
24
+ vatRate: string;
25
+ sundryRate: string;
26
+ sundryMax: string;
27
+ sundryFixed: string;
28
+ sundryMethod: EstimateSundryMethod;
29
+ partsDiscount: string;
30
+ paintDiscount: string;
31
+ timeBasis: string;
32
+ adjusted: boolean;
33
+ items: Array<EstimateItemDto>;
34
+ summary: EstimateSummaryDto;
35
+ summaryAdjusted: EstimateSummaryDto | null;
36
+ }
37
+ //# sourceMappingURL=estimate.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate.dto.d.ts","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate.dto.ts"],"names":[],"mappings":"AAA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3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=estimate.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate.dto.js","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate.dto.ts"],"names":[],"mappings":"","sourcesContent":["import { EstimateItemDto } from './estimate-item.dto';\nimport { EstimateSource, EstimateSundryMethod } from './estimate.model';\nimport { EstimateCostCategory } from './estimate.types';\n\nexport type CostCategorySummary = Record<EstimateCostCategory, string>;\n\nexport interface CostCategorySummaryTotals {\n net: string;\n vat: string;\n gross: string;\n hours: string;\n labourRate: string;\n}\n\nexport type EstimateSummaryDto = CostCategorySummary & CostCategorySummaryTotals;\n\nexport interface EstimateDto {\n id: string;\n source: EstimateSource;\n label: string;\n comment: string;\n timestamp: string;\n version: number;\n net: string;\n vat: string;\n gross: string;\n labourRate: string;\n vatRate: string;\n sundryRate: string;\n sundryMax: string;\n sundryFixed: string;\n sundryMethod: EstimateSundryMethod;\n partsDiscount: string;\n paintDiscount: string;\n timeBasis: string;\n adjusted: boolean;\n items: Array<EstimateItemDto>;\n summary: EstimateSummaryDto;\n summaryAdjusted: EstimateSummaryDto | null;\n}\n"]}