@ironcode/vas-lib 2.3.0 → 3.0.0-alpha.10

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 (143) hide show
  1. package/cjs/lib/control-value/vas-camera-control-value.model.d.ts +6 -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 +10 -0
  4. package/cjs/lib/control-value/vas-camera-control-value.model.js.map +1 -1
  5. package/cjs/lib/entity/vas-base.model.d.ts +1 -1
  6. package/cjs/lib/entity/vas-base.model.d.ts.map +1 -1
  7. package/cjs/lib/entity/vas-base.model.js.map +1 -1
  8. package/cjs/lib/entity/vas-control.model.d.ts +4 -4
  9. package/cjs/lib/entity/vas-control.model.d.ts.map +1 -1
  10. package/cjs/lib/entity/vas-control.model.js +1 -1
  11. package/cjs/lib/entity/vas-control.model.js.map +1 -1
  12. package/cjs/lib/entity/vas-field.dto.d.ts +4 -7
  13. package/cjs/lib/entity/vas-field.dto.d.ts.map +1 -1
  14. package/cjs/lib/entity/vas-field.dto.js.map +1 -1
  15. package/cjs/lib/entity/vas-field.model.d.ts +4 -4
  16. package/cjs/lib/entity/vas-field.model.d.ts.map +1 -1
  17. package/cjs/lib/entity/vas-field.model.js +1 -1
  18. package/cjs/lib/entity/vas-field.model.js.map +1 -1
  19. package/cjs/lib/entity/vas-form.model.d.ts +4 -4
  20. package/cjs/lib/entity/vas-form.model.d.ts.map +1 -1
  21. package/cjs/lib/entity/vas-form.model.js +1 -1
  22. package/cjs/lib/entity/vas-form.model.js.map +1 -1
  23. package/cjs/lib/entity/vas-group.model.d.ts +2 -2
  24. package/cjs/lib/entity/vas-group.model.d.ts.map +1 -1
  25. package/cjs/lib/entity/vas-group.model.js.map +1 -1
  26. package/cjs/lib/entity/vas-job-copy.d.ts +12 -12
  27. package/cjs/lib/entity/vas-job-copy.d.ts.map +1 -1
  28. package/cjs/lib/entity/vas-job-copy.js.map +1 -1
  29. package/cjs/lib/entity/vas-job.dto.d.ts +12 -6
  30. package/cjs/lib/entity/vas-job.dto.d.ts.map +1 -1
  31. package/cjs/lib/entity/vas-job.dto.js.map +1 -1
  32. package/cjs/lib/entity/vas-job.model.d.ts +34 -142
  33. package/cjs/lib/entity/vas-job.model.d.ts.map +1 -1
  34. package/cjs/lib/entity/vas-job.model.js +248 -341
  35. package/cjs/lib/entity/vas-job.model.js.map +1 -1
  36. package/cjs/lib/model/estimate-control/estimate-control-value.dto.d.ts +14 -0
  37. package/cjs/lib/model/estimate-control/estimate-control-value.dto.d.ts.map +1 -0
  38. package/cjs/lib/model/estimate-control/estimate-control-value.dto.js +3 -0
  39. package/cjs/lib/model/estimate-control/estimate-control-value.dto.js.map +1 -0
  40. package/cjs/lib/model/estimate-control/estimate-control-value.model.d.ts +11 -0
  41. package/cjs/lib/model/estimate-control/estimate-control-value.model.d.ts.map +1 -0
  42. package/cjs/lib/model/estimate-control/estimate-control-value.model.js +84 -0
  43. package/cjs/lib/model/estimate-control/estimate-control-value.model.js.map +1 -0
  44. package/cjs/lib/model/estimate-control/estimate-item.dto.d.ts +16 -0
  45. package/cjs/lib/model/estimate-control/estimate-item.dto.d.ts.map +1 -0
  46. package/cjs/lib/model/estimate-control/estimate-item.dto.js +3 -0
  47. package/cjs/lib/model/estimate-control/estimate-item.dto.js.map +1 -0
  48. package/cjs/lib/model/estimate-control/estimate-item.model.d.ts +24 -0
  49. package/cjs/lib/model/estimate-control/estimate-item.model.d.ts.map +1 -0
  50. package/cjs/lib/model/estimate-control/estimate-item.model.js +121 -0
  51. package/cjs/lib/model/estimate-control/estimate-item.model.js.map +1 -0
  52. package/cjs/lib/model/estimate-control/estimate.dto.d.ts +37 -0
  53. package/cjs/lib/model/estimate-control/estimate.dto.d.ts.map +1 -0
  54. package/cjs/lib/model/estimate-control/estimate.dto.js +3 -0
  55. package/cjs/lib/model/estimate-control/estimate.dto.js.map +1 -0
  56. package/cjs/lib/model/estimate-control/estimate.model.d.ts +55 -0
  57. package/cjs/lib/model/estimate-control/estimate.model.d.ts.map +1 -0
  58. package/cjs/lib/model/estimate-control/estimate.model.js +279 -0
  59. package/cjs/lib/model/estimate-control/estimate.model.js.map +1 -0
  60. package/cjs/lib/model/estimate-control/estimate.types.d.ts +3 -0
  61. package/cjs/lib/model/estimate-control/estimate.types.d.ts.map +1 -0
  62. package/cjs/lib/model/estimate-control/estimate.types.js +3 -0
  63. package/cjs/lib/model/estimate-control/estimate.types.js.map +1 -0
  64. package/cjs/lib/model/estimate-control/index.d.ts +8 -0
  65. package/cjs/lib/model/estimate-control/index.d.ts.map +1 -0
  66. package/cjs/lib/model/estimate-control/index.js +11 -0
  67. package/cjs/lib/model/estimate-control/index.js.map +1 -0
  68. package/cjs/lib/model/firebase-document-meta.interface.d.ts +6 -0
  69. package/cjs/lib/model/firebase-document-meta.interface.d.ts.map +1 -0
  70. package/cjs/lib/model/firebase-document-meta.interface.js +3 -0
  71. package/cjs/lib/model/firebase-document-meta.interface.js.map +1 -0
  72. package/cjs/lib/model/index.d.ts +3 -0
  73. package/cjs/lib/model/index.d.ts.map +1 -1
  74. package/cjs/lib/model/index.js +3 -0
  75. package/cjs/lib/model/index.js.map +1 -1
  76. package/cjs/lib/model/report-invocation.d.ts +40 -0
  77. package/cjs/lib/model/report-invocation.d.ts.map +1 -0
  78. package/cjs/lib/model/report-invocation.js +3 -0
  79. package/cjs/lib/model/report-invocation.js.map +1 -0
  80. package/cjs/lib/utils/get-value-by-path.d.ts +5 -16
  81. package/cjs/lib/utils/get-value-by-path.d.ts.map +1 -1
  82. package/cjs/lib/utils/get-value-by-path.js +48 -59
  83. package/cjs/lib/utils/get-value-by-path.js.map +1 -1
  84. package/cjs/lib/utils/index.d.ts +8 -0
  85. package/cjs/lib/utils/index.d.ts.map +1 -0
  86. package/cjs/lib/utils/index.js +11 -0
  87. package/cjs/lib/utils/index.js.map +1 -0
  88. package/cjs/lib/utils/is-array-string.d.ts +3 -0
  89. package/cjs/lib/utils/is-array-string.d.ts.map +1 -1
  90. package/cjs/lib/utils/is-array-string.js +3 -0
  91. package/cjs/lib/utils/is-array-string.js.map +1 -1
  92. package/cjs/lib/utils/is-numeric.d.ts +2 -0
  93. package/cjs/lib/utils/is-numeric.d.ts.map +1 -0
  94. package/cjs/lib/utils/is-numeric.js +10 -0
  95. package/cjs/lib/utils/is-numeric.js.map +1 -0
  96. package/cjs/lib/utils/is-plain-object.d.ts +5 -0
  97. package/cjs/lib/utils/is-plain-object.d.ts.map +1 -0
  98. package/cjs/lib/utils/is-plain-object.js +10 -0
  99. package/cjs/lib/utils/is-plain-object.js.map +1 -0
  100. package/cjs/lib/utils/try-json.d.ts +6 -0
  101. package/cjs/lib/utils/try-json.d.ts.map +1 -0
  102. package/cjs/lib/utils/try-json.js +20 -0
  103. package/cjs/lib/utils/try-json.js.map +1 -0
  104. package/cjs/public-api.d.ts +1 -0
  105. package/cjs/public-api.d.ts.map +1 -1
  106. package/cjs/public-api.js +1 -0
  107. package/cjs/public-api.js.map +1 -1
  108. package/fesm2022/ironcode-vas-lib.mjs +831 -390
  109. package/fesm2022/ironcode-vas-lib.mjs.map +1 -1
  110. package/lib/control-value/vas-camera-control-value.model.d.ts +6 -2
  111. package/lib/entity/vas-base.model.d.ts +1 -1
  112. package/lib/entity/vas-control.model.d.ts +4 -4
  113. package/lib/entity/vas-field.dto.d.ts +4 -7
  114. package/lib/entity/vas-field.model.d.ts +4 -4
  115. package/lib/entity/vas-form.model.d.ts +4 -4
  116. package/lib/entity/vas-group.model.d.ts +2 -2
  117. package/lib/entity/vas-job-copy.d.ts +12 -12
  118. package/lib/entity/vas-job.dto.d.ts +12 -6
  119. package/lib/entity/vas-job.model.d.ts +34 -142
  120. package/lib/model/estimate-control/estimate-control-value.dto.d.ts +13 -0
  121. package/lib/model/estimate-control/estimate-control-value.model.d.ts +10 -0
  122. package/lib/model/estimate-control/estimate-item.dto.d.ts +15 -0
  123. package/lib/model/estimate-control/estimate-item.model.d.ts +23 -0
  124. package/lib/model/estimate-control/estimate.dto.d.ts +36 -0
  125. package/lib/model/estimate-control/estimate.model.d.ts +54 -0
  126. package/lib/model/estimate-control/estimate.types.d.ts +2 -0
  127. package/lib/model/estimate-control/index.d.ts +7 -0
  128. package/lib/model/firebase-document-meta.interface.d.ts +5 -0
  129. package/lib/model/index.d.ts +3 -0
  130. package/lib/model/report-invocation.d.ts +39 -0
  131. package/lib/utils/get-value-by-path.d.ts +5 -16
  132. package/lib/utils/index.d.ts +7 -0
  133. package/lib/utils/is-array-string.d.ts +3 -0
  134. package/lib/utils/is-numeric.d.ts +1 -0
  135. package/lib/utils/is-plain-object.d.ts +4 -0
  136. package/lib/utils/omit.d.ts +7 -0
  137. package/lib/utils/try-json.d.ts +5 -0
  138. package/package.json +3 -2
  139. package/public-api.d.ts +1 -0
  140. package/cjs/lib/entity/vas-job.model.spec-data.d.ts +0 -2
  141. package/cjs/lib/entity/vas-job.model.spec-data.d.ts.map +0 -1
  142. package/cjs/lib/entity/vas-job.model.spec-data.js +0 -29
  143. package/cjs/lib/entity/vas-job.model.spec-data.js.map +0 -1
@@ -0,0 +1,55 @@
1
+ import { EstimateItemModel } from './estimate-item.model';
2
+ import { EstimateDto, EstimateSummaryDto } from './estimate.dto';
3
+ import { EstimateItemDto } from './estimate-item.dto';
4
+ export declare type EstimateSundryMethod = 'fixed' | 'percentage' | 'percentage-with-max';
5
+ export declare type EstimateSource = 'audatex' | 'glassmatix' | 'gtmotive' | 'ibody' | 'manual';
6
+ export declare class EstimateModel {
7
+ id: string;
8
+ source: EstimateSource;
9
+ label: string;
10
+ comment: string;
11
+ timestamp: string;
12
+ version: number;
13
+ net: string;
14
+ vat: string;
15
+ gross: string;
16
+ labourRate: string;
17
+ vatRate: string;
18
+ sundryRate: string;
19
+ sundryMax: string;
20
+ sundryFixed: string;
21
+ sundryMethod: EstimateSundryMethod;
22
+ partsDiscount: string;
23
+ paintDiscount: string;
24
+ timeBasis: string;
25
+ adjusted: boolean;
26
+ items: Array<EstimateItemModel>;
27
+ summaryNet: EstimateSummaryDto;
28
+ summary: EstimateSummaryDto;
29
+ summaryAdjusted: EstimateSummaryDto;
30
+ get timeBasisSafe(): string;
31
+ static create(source?: EstimateSource): EstimateModel;
32
+ static fromDto<T extends EstimateModel>(this: new () => T, dto: Partial<EstimateDto>): T;
33
+ addItem(modelOrDto: EstimateItemModel | Partial<EstimateItemDto>, opts?: {
34
+ calculate?: boolean;
35
+ }): void;
36
+ addItems(items: Array<EstimateItemModel>, opts?: {
37
+ calculate?: boolean;
38
+ }): void;
39
+ calculate(): void;
40
+ /**
41
+ * Returns the net summary (before sundries and discounts) of the estimate.
42
+ * By summary, we mean grouping the costs by cost category.
43
+ *
44
+ * @param adjusted if the values should be calculated using the original or
45
+ * adjusted values
46
+ */
47
+ getSummaryNet(adjusted?: boolean): EstimateSummaryDto;
48
+ /**
49
+ * Applies the sundry and discount values to the net summary.
50
+ */
51
+ getSummary(summaryNet: EstimateDto['summary'], sundryRate: string, sundryMax: string, sundryFixed: string, sundryMethod: EstimateSundryMethod, partsDiscount: string, paintDiscount: string, adjusted: boolean): EstimateDto['summary'];
52
+ toDto(): EstimateDto;
53
+ getTotalHours(adjusted?: boolean): string;
54
+ }
55
+ //# sourceMappingURL=estimate.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate.model.d.ts","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate.model.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAuB,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,MAAM,CAAC,OAAO,MAAM,oBAAoB,GACtC,OAAO,GACP,YAAY,GACZ,qBAAqB,CAAC;AAExB,MAAM,CAAC,OAAO,MAAM,cAAc,GAChC,SAAS,GAC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,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAOxE,SAAS,IAAI,IAAI;IAsCjB;;;;;;OAMG;IACH,aAAa,CAAC,QAAQ,UAAQ,GAAG,kBAAkB;IAoDnD;;OAEG;IACH,UAAU,CACR,UAAU,EAAE,WAAW,CAAC,SAAS,CAAC,EAClC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,oBAAoB,EAClC,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,OAAO,GAChB,WAAW,CAAC,SAAS,CAAC;IAgDzB,KAAK,IAAI,WAAW;IA2BpB,aAAa,CAAC,QAAQ,UAAQ,GAAG,MAAM;CAoBxC"}
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EstimateModel = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const big_js_1 = require("big.js");
6
+ const moment_1 = tslib_1.__importDefault(require("moment"));
7
+ const uuid_1 = require("uuid");
8
+ const estimate_item_model_1 = require("./estimate-item.model");
9
+ const b = (value = '0') => {
10
+ try {
11
+ if (typeof value === 'string') {
12
+ return new big_js_1.Big(value.replace(/[^\d^.]/g, ''));
13
+ }
14
+ return new big_js_1.Big(value);
15
+ }
16
+ catch (e) {
17
+ console.error(`failed to construct Big from value '${value}'`);
18
+ return new big_js_1.Big('0');
19
+ }
20
+ };
21
+ function isLabourWorkCategory(value) {
22
+ return ['check', 'rr', 'repair', 'removed'].includes(value);
23
+ }
24
+ function isPaintWorkCategory(value) {
25
+ return ['blend', 'paint'].includes(value);
26
+ }
27
+ class EstimateModel {
28
+ constructor() {
29
+ this.id = (0, uuid_1.v4)();
30
+ this.source = 'manual';
31
+ this.label = '';
32
+ this.comment = '';
33
+ this.timestamp = (0, moment_1.default)().toISOString();
34
+ this.version = 1;
35
+ this.net = '0.00';
36
+ this.vat = '0.00';
37
+ this.gross = '0.00';
38
+ this.labourRate = '1';
39
+ this.vatRate = '0.00';
40
+ this.sundryRate = '0.00';
41
+ this.sundryMax = '0.00';
42
+ this.sundryFixed = '0.00';
43
+ this.sundryMethod = 'fixed';
44
+ this.partsDiscount = '0.00';
45
+ this.paintDiscount = '0.00';
46
+ this.timeBasis = '1';
47
+ this.adjusted = false;
48
+ this.items = [];
49
+ this.summaryNet = {
50
+ labour: '0.00',
51
+ none: '0.00',
52
+ parts: '0.00',
53
+ pm: '0.00',
54
+ pl: '0.00',
55
+ specialist: '0.00',
56
+ other: '0.00',
57
+ gross: '0.00',
58
+ net: '0.00',
59
+ hours: '0.00',
60
+ vat: '0.00',
61
+ labourRate: '0.00',
62
+ };
63
+ this.summary = {
64
+ labour: '0.00',
65
+ none: '0.00',
66
+ parts: '0.00',
67
+ pm: '0.00',
68
+ pl: '0.00',
69
+ specialist: '0.00',
70
+ other: '0.00',
71
+ gross: '0.00',
72
+ net: '0.00',
73
+ hours: '0.00',
74
+ vat: '0.00',
75
+ labourRate: '0.00',
76
+ };
77
+ this.summaryAdjusted = {
78
+ labour: '0.00',
79
+ none: '0.00',
80
+ parts: '0.00',
81
+ pm: '0.00',
82
+ pl: '0.00',
83
+ specialist: '0.00',
84
+ other: '0.00',
85
+ gross: '0.00',
86
+ net: '0.00',
87
+ hours: '0.00',
88
+ vat: '0.00',
89
+ labourRate: '0.00',
90
+ };
91
+ }
92
+ get timeBasisSafe() {
93
+ return (this.timeBasis || '1') === '0' ? '1' : this.timeBasis;
94
+ }
95
+ static create(source = 'manual') {
96
+ const model = new EstimateModel();
97
+ model.source = source;
98
+ return model;
99
+ }
100
+ static fromDto(dto) {
101
+ var _a;
102
+ const model = new this();
103
+ Object.assign(model, Object.assign(Object.assign({}, dto), { items: (_a = dto.items) === null || _a === void 0 ? void 0 : _a.map(item => estimate_item_model_1.EstimateItemModel.fromDto(item)) }));
104
+ model.calculate();
105
+ return model;
106
+ }
107
+ addItem(modelOrDto, opts) {
108
+ this.items.push(modelOrDto instanceof estimate_item_model_1.EstimateItemModel ?
109
+ modelOrDto :
110
+ estimate_item_model_1.EstimateItemModel.fromDto(modelOrDto));
111
+ if (!opts || (opts && opts.calculate)) {
112
+ this.calculate();
113
+ }
114
+ }
115
+ addItems(items, opts) {
116
+ this.items = this.items.concat(items);
117
+ if (!opts || (opts && opts.calculate)) {
118
+ this.calculate();
119
+ }
120
+ }
121
+ calculate() {
122
+ this.summaryNet = this.getSummaryNet(false);
123
+ if (this.adjusted) {
124
+ this.summaryAdjusted = this.getSummary(this.summaryNet, this.sundryRate, this.sundryMax, this.sundryFixed, this.sundryMethod, this.partsDiscount, this.paintDiscount, this.adjusted);
125
+ }
126
+ this.summary = this.getSummary(this.summaryNet, this.sundryRate, this.sundryMax, this.sundryFixed, this.sundryMethod, this.partsDiscount, this.paintDiscount, this.adjusted);
127
+ this.net = b(0)
128
+ .add(this.summary.labour)
129
+ .add(this.summary.none)
130
+ .add(this.summary.parts)
131
+ .add(this.summary.pm)
132
+ .add(this.summary.specialist)
133
+ .toFixed(2);
134
+ this.vat = b(this.net || '0').mul(this.vatRate || '0').toFixed(2);
135
+ this.gross = b(this.net || '0').add(this.vat || '0').toFixed(2);
136
+ }
137
+ /**
138
+ * Returns the net summary (before sundries and discounts) of the estimate.
139
+ * By summary, we mean grouping the costs by cost category.
140
+ *
141
+ * @param adjusted if the values should be calculated using the original or
142
+ * adjusted values
143
+ */
144
+ getSummaryNet(adjusted = false) {
145
+ const summary = this.items.reduce((map, item) => {
146
+ map[item.costCategory] = b(map[item.costCategory] || '0')
147
+ .add(item.getLineValue(this.labourRate, this.timeBasisSafe, adjusted))
148
+ .toFixed(2);
149
+ return map;
150
+ }, {
151
+ labour: '0.00',
152
+ none: '0.00',
153
+ parts: '0.00',
154
+ pm: '0.00',
155
+ pl: '0.00',
156
+ specialist: '0.00',
157
+ other: '0.00',
158
+ net: '0.00',
159
+ vat: '0.00',
160
+ gross: '0.00',
161
+ hours: '0.00',
162
+ labourRate: '0',
163
+ });
164
+ if (this.source === 'audatex') {
165
+ const mechHours = this.items
166
+ .reduce((h, item) => {
167
+ return isLabourWorkCategory(item.workCategory) ?
168
+ h.add(b(item.quantity || '0').mul(item.units || '0')) :
169
+ h;
170
+ }, b())
171
+ .div(this.timeBasisSafe || '1')
172
+ .round(2);
173
+ const paintHours = this.items
174
+ .reduce((h, item) => {
175
+ return isPaintWorkCategory(item.workCategory) ?
176
+ h.add(b(item.quantity || '0').mul(item.units || '0')) :
177
+ h;
178
+ }, b())
179
+ .div(this.timeBasisSafe || '1')
180
+ .round(1);
181
+ const mechCost = mechHours.mul(this.labourRate || '0');
182
+ const paintCost = paintHours.mul(this.labourRate || '0');
183
+ summary.labour = mechCost.add(paintCost).toFixed(2);
184
+ }
185
+ return summary;
186
+ }
187
+ /**
188
+ * Applies the sundry and discount values to the net summary.
189
+ */
190
+ getSummary(summaryNet, sundryRate, sundryMax, sundryFixed, sundryMethod, partsDiscount, paintDiscount, adjusted) {
191
+ const partsDisc = b('1').minus(partsDiscount || '0');
192
+ const paintDisc = b('1').minus(paintDiscount || '0');
193
+ let partsSundry = '0.00';
194
+ if (sundryMethod === 'percentage') {
195
+ partsSundry = b(summaryNet.parts).mul(sundryRate || '1').toFixed(2);
196
+ }
197
+ else if (sundryMethod === 'percentage-with-max') {
198
+ partsSundry = b(summaryNet.parts).mul(sundryRate || '1').toFixed(2);
199
+ partsSundry = Math.min(parseFloat(sundryMax || '0'), parseFloat(partsSundry)).toFixed(2);
200
+ }
201
+ else if (sundryMethod === 'fixed') {
202
+ partsSundry = b(sundryFixed).toFixed(2);
203
+ }
204
+ const parts = b(summaryNet.parts).add(partsSundry);
205
+ const net = b(0)
206
+ .add(summaryNet.labour)
207
+ .add(summaryNet.none)
208
+ .add(parts)
209
+ .add(summaryNet.pm)
210
+ .add(summaryNet.specialist)
211
+ .toFixed(2);
212
+ const vat = b(net || '0')
213
+ .mul(this.vatRate || '0')
214
+ .toFixed(2);
215
+ const gross = b(net || '0').add(vat || '0').toFixed(2);
216
+ return {
217
+ labour: summaryNet.labour,
218
+ none: summaryNet.none,
219
+ parts: b(parts).mul(partsDisc).toFixed(2),
220
+ pm: b(summaryNet.pm).mul(paintDisc).toFixed(2),
221
+ pl: summaryNet.pl,
222
+ specialist: summaryNet.specialist,
223
+ other: summaryNet.other,
224
+ net: net,
225
+ vat: vat,
226
+ gross: gross,
227
+ labourRate: this.labourRate,
228
+ hours: this.getTotalHours(adjusted)
229
+ };
230
+ }
231
+ toDto() {
232
+ return {
233
+ id: this.id,
234
+ source: this.source,
235
+ label: this.label,
236
+ comment: this.comment,
237
+ timestamp: this.timestamp,
238
+ version: this.version,
239
+ net: this.net,
240
+ vat: this.vat,
241
+ gross: this.gross,
242
+ labourRate: this.labourRate,
243
+ vatRate: this.vatRate,
244
+ sundryRate: this.sundryRate,
245
+ sundryMax: this.sundryMax,
246
+ sundryFixed: this.sundryFixed,
247
+ sundryMethod: this.sundryMethod,
248
+ partsDiscount: this.partsDiscount,
249
+ paintDiscount: this.paintDiscount,
250
+ timeBasis: this.timeBasisSafe,
251
+ items: this.items.map(i => i.toDto()),
252
+ adjusted: this.adjusted,
253
+ summary: this.summary,
254
+ summaryAdjusted: this.summaryAdjusted
255
+ };
256
+ }
257
+ getTotalHours(adjusted = false) {
258
+ if (this.source === 'audatex') {
259
+ const mechUnitsHours = this.items
260
+ .filter(item => item.workCategory !== 'paint')
261
+ .reduce((h, item) => h.add(b(item.getTotalUnits(adjusted))), b())
262
+ .round(2)
263
+ .div(this.timeBasisSafe);
264
+ const paintHours = this.items
265
+ .filter(item => item.workCategory === 'paint')
266
+ .reduce((h, item) => h.add(b(item.getTotalUnits(adjusted))), b())
267
+ .round(1)
268
+ .div(this.timeBasisSafe);
269
+ return mechUnitsHours.add(paintHours).toFixed(2);
270
+ }
271
+ const units = this.items
272
+ .filter(i => i.costCategory === 'labour')
273
+ .reduce((p, c) => p.add(b(c.getTotalUnits(adjusted))), b('0'))
274
+ .toFixed(2);
275
+ return b(units).div(this.timeBasisSafe).toFixed(2);
276
+ }
277
+ }
278
+ exports.EstimateModel = EstimateModel;
279
+ //# sourceMappingURL=estimate.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate.model.js","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate.model.ts"],"names":[],"mappings":";;;;AAAA,mCAA6B;AAC7B,4DAA4B;AAC5B,+BAAkC;AAClC,+DAA0D;AAiB1D,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;QACD,OAAO,IAAI,YAAG,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,uCAAuC,KAAK,GAAG,CAAC,CAAC;QAC/D,OAAO,IAAI,YAAG,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;AACH,CAAC,CAAC;AAEF,SAAS,oBAAoB,CAAC,KAA2B;IACvD,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,mBAAmB,CAAC,KAA2B;IACtD,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED,MAAa,aAAa;IAA1B;QAES,OAAE,GAAW,IAAA,SAAI,GAAE,CAAC;QACpB,WAAM,GAAmB,QAAQ,CAAC;QAClC,UAAK,GAAW,EAAE,CAAC;QACnB,YAAO,GAAW,EAAE,CAAC;QACrB,cAAS,GAAW,IAAA,gBAAM,GAAE,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AE,CAAC,IAAI,CAAC,YAAY,KAAK,OAAO,CAAC;iBAC7C,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;iBAChE,KAAK,CAAC,CAAC,CAAC;iBACR,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC3B,OAAO,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACnD,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK;aACrB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,QAAQ,CAAC;aACxC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;aAC7D,OAAO,CAAC,CAAC,CAAC,CAAC;QACd,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;CACF;AAxTD,sCAwTC","sourcesContent":["import { Big } from 'big.js';\nimport moment from 'moment';\nimport { v4 as uuid } from 'uuid';\nimport { EstimateItemModel } from './estimate-item.model';\nimport { CostCategorySummary, EstimateDto, EstimateSummaryDto } from './estimate.dto';\nimport { EstimateItemDto } from './estimate-item.dto';\nimport { EstimateWorkCategory } from './estimate.types';\n\nexport declare type EstimateSundryMethod =\n 'fixed' |\n 'percentage' |\n 'percentage-with-max';\n\nexport declare type EstimateSource =\n 'audatex' |\n 'glassmatix' |\n 'gtmotive' |\n 'ibody' |\n 'manual';\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 } catch (e) {\n console.error(`failed to construct Big from value '${value}'`);\n return new Big('0');\n }\n};\n\nfunction isLabourWorkCategory(value: EstimateWorkCategory): boolean {\n return ['check', 'rr', 'repair', 'removed'].includes(value);\n}\n\nfunction isPaintWorkCategory(value: EstimateWorkCategory): boolean {\n return ['blend', 'paint'].includes(value);\n}\n\nexport class EstimateModel {\n\n public id: string = uuid();\n public source: EstimateSource = 'manual';\n public label: string = '';\n public comment: string = '';\n public timestamp: string = moment().toISOString();\n public version: number = 1;\n public net: string = '0.00';\n public vat: string = '0.00';\n public gross: string = '0.00';\n public labourRate: string = '1';\n public vatRate: string = '0.00';\n public sundryRate: string = '0.00';\n public sundryMax: string = '0.00';\n public sundryFixed: string = '0.00';\n public sundryMethod: EstimateSundryMethod = 'fixed';\n public partsDiscount: string = '0.00';\n public paintDiscount: string = '0.00';\n public timeBasis: string = '1';\n public adjusted = false;\n public items: Array<EstimateItemModel> = [];\n public summaryNet: EstimateSummaryDto = {\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 gross: '0.00',\n net: '0.00',\n hours: '0.00',\n vat: '0.00',\n labourRate: '0.00',\n };\n public summary: EstimateSummaryDto = {\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 gross: '0.00',\n net: '0.00',\n hours: '0.00',\n vat: '0.00',\n labourRate: '0.00',\n };\n public summaryAdjusted: EstimateSummaryDto = {\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 gross: '0.00',\n net: '0.00',\n hours: '0.00',\n vat: '0.00',\n labourRate: '0.00',\n };\n\n get timeBasisSafe(): string {\n return (this.timeBasis || '1') === '0' ? '1' : this.timeBasis;\n }\n\n static create(source: EstimateSource = 'manual'): EstimateModel {\n const model = new EstimateModel();\n model.source = source;\n return model;\n }\n\n static fromDto<T extends EstimateModel>(\n this: new () => T,\n dto: Partial<EstimateDto>\n ): T {\n const model = new this();\n Object.assign(model, {\n ...dto,\n items: dto.items?.map(item => EstimateItemModel.fromDto(item)),\n });\n model.calculate();\n return model;\n }\n\n addItem(\n modelOrDto: EstimateItemModel | Partial<EstimateItemDto>,\n opts?: { calculate?: boolean }\n ) {\n this.items.push(modelOrDto instanceof EstimateItemModel ?\n modelOrDto :\n EstimateItemModel.fromDto(modelOrDto)\n );\n if (!opts || (opts && opts.calculate)) {\n this.calculate();\n }\n }\n\n addItems(items: Array<EstimateItemModel>, opts?: { calculate?: boolean }) {\n this.items = this.items.concat(items);\n if (!opts || (opts && opts.calculate)) {\n this.calculate();\n }\n }\n\n calculate(): void {\n\n this.summaryNet = this.getSummaryNet(false);\n\n if (this.adjusted) {\n this.summaryAdjusted = this.getSummary(\n this.summaryNet,\n this.sundryRate,\n this.sundryMax,\n this.sundryFixed,\n this.sundryMethod,\n this.partsDiscount,\n this.paintDiscount,\n this.adjusted\n );\n }\n this.summary = this.getSummary(\n this.summaryNet,\n this.sundryRate,\n this.sundryMax,\n this.sundryFixed,\n this.sundryMethod,\n this.partsDiscount,\n this.paintDiscount,\n this.adjusted\n );\n\n this.net = b(0)\n .add(this.summary.labour)\n .add(this.summary.none)\n .add(this.summary.parts)\n .add(this.summary.pm)\n .add(this.summary.specialist)\n .toFixed(2);\n this.vat = b(this.net || '0').mul(this.vatRate || '0').toFixed(2);\n this.gross = b(this.net || '0').add(this.vat || '0').toFixed(2);\n }\n\n /**\n * Returns the net summary (before sundries and discounts) of the estimate.\n * By summary, we mean grouping the costs by cost category.\n *\n * @param adjusted if the values should be calculated using the original or\n * adjusted values\n */\n getSummaryNet(adjusted = false): EstimateSummaryDto {\n const summary = this.items.reduce((map, item) => {\n map[item.costCategory] = b(map[item.costCategory] || '0')\n .add(item.getLineValue(this.labourRate, this.timeBasisSafe, adjusted))\n .toFixed(2);\n return map;\n }, {\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.00',\n labourRate: '0',\n } as EstimateSummaryDto);\n\n if (this.source === 'audatex') {\n const mechHours = this.items\n .reduce(\n (h, item) => {\n return isLabourWorkCategory(item.workCategory) ?\n h.add(b(item.quantity || '0').mul(item.units || '0')) :\n h;\n },\n b()\n )\n .div(this.timeBasisSafe || '1')\n .round(2);\n const paintHours = this.items\n .reduce(\n (h, item) => {\n return isPaintWorkCategory(item.workCategory) ?\n h.add(b(item.quantity || '0').mul(item.units || '0')) :\n h;\n },\n b()\n )\n .div(this.timeBasisSafe || '1')\n .round(1);\n\n const mechCost = mechHours.mul(this.labourRate || '0');\n const paintCost = paintHours.mul(this.labourRate || '0');\n summary.labour = mechCost.add(paintCost).toFixed(2);\n }\n return summary;\n }\n\n /**\n * Applies the sundry and discount values to the net summary.\n */\n getSummary(\n summaryNet: EstimateDto['summary'],\n sundryRate: string,\n sundryMax: string,\n sundryFixed: string,\n sundryMethod: EstimateSundryMethod,\n partsDiscount: string,\n paintDiscount: string,\n adjusted: boolean\n ): EstimateDto['summary'] {\n const partsDisc = b('1').minus(partsDiscount || '0');\n const paintDisc = b('1').minus(paintDiscount || '0');\n\n let partsSundry = '0.00';\n\n if (sundryMethod === 'percentage') {\n partsSundry = b(summaryNet.parts).mul(sundryRate || '1').toFixed(2);\n } else if (sundryMethod === 'percentage-with-max') {\n partsSundry = b(summaryNet.parts).mul(sundryRate || '1').toFixed(2);\n partsSundry = Math.min(\n parseFloat(sundryMax || '0'),\n parseFloat(partsSundry)\n ).toFixed(2);\n } else if (sundryMethod === 'fixed') {\n partsSundry = b(sundryFixed).toFixed(2);\n }\n\n const parts = b(summaryNet.parts).add(partsSundry);\n\n const net = b(0)\n .add(summaryNet.labour)\n .add(summaryNet.none)\n .add(parts)\n .add(summaryNet.pm)\n .add(summaryNet.specialist)\n .toFixed(2);\n const vat = b(net || '0')\n .mul(this.vatRate || '0')\n .toFixed(2);\n const gross = b(net || '0').add(vat || '0').toFixed(2);\n\n return {\n labour: summaryNet.labour,\n none: summaryNet.none,\n parts: b(parts).mul(partsDisc).toFixed(2),\n pm: b(summaryNet.pm).mul(paintDisc).toFixed(2),\n pl: summaryNet.pl,\n specialist: summaryNet.specialist,\n other: summaryNet.other,\n net: net,\n vat: vat,\n gross: gross,\n labourRate: this.labourRate,\n hours: this.getTotalHours(adjusted)\n };\n }\n\n toDto(): EstimateDto {\n return {\n id: this.id,\n source: this.source,\n label: this.label,\n comment: this.comment,\n timestamp: this.timestamp,\n version: this.version,\n net: this.net,\n vat: this.vat,\n gross: this.gross,\n labourRate: this.labourRate,\n vatRate: this.vatRate,\n sundryRate: this.sundryRate,\n sundryMax: this.sundryMax,\n sundryFixed: this.sundryFixed,\n sundryMethod: this.sundryMethod,\n partsDiscount: this.partsDiscount,\n paintDiscount: this.paintDiscount,\n timeBasis: this.timeBasisSafe,\n items: this.items.map(i => i.toDto()),\n adjusted: this.adjusted,\n summary: this.summary,\n summaryAdjusted: this.summaryAdjusted\n };\n }\n\n getTotalHours(adjusted = false): string {\n if (this.source === 'audatex') {\n const mechUnitsHours = this.items\n .filter(item => item.workCategory !== 'paint')\n .reduce((h, item) => h.add(b(item.getTotalUnits(adjusted))), b())\n .round(2)\n .div(this.timeBasisSafe);\n const paintHours = this.items\n .filter(item => item.workCategory === 'paint')\n .reduce((h, item) => h.add(b(item.getTotalUnits(adjusted))), b())\n .round(1)\n .div(this.timeBasisSafe);\n return mechUnitsHours.add(paintHours).toFixed(2);\n }\n const units = this.items\n .filter(i => i.costCategory === 'labour')\n .reduce((p, c) => p.add(b(c.getTotalUnits(adjusted))), b('0'))\n .toFixed(2);\n return b(units).div(this.timeBasisSafe).toFixed(2);\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare type EstimateWorkCategory = 'none' | 'blend' | 'check' | 'new' | 'paint' | 'rr' | 'removed' | 'repair' | 'specialist';
2
+ export declare type EstimateCostCategory = 'labour' | 'none' | 'pm' | 'pl' | 'parts' | 'other' | 'specialist';
3
+ //# sourceMappingURL=estimate.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate.types.d.ts","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate.types.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,OAAO,MAAM,oBAAoB,GACtC,MAAM,GACJ,OAAO,GACP,OAAO,GACP,KAAK,GACL,OAAO,GACP,IAAI,GACJ,SAAS,GACT,QAAQ,GACR,YAAY,CAAC;AAEjB,MAAM,CAAC,OAAO,MAAM,oBAAoB,GACtC,QAAQ,GACR,MAAM,GACN,IAAI,GACJ,IAAI,GACJ,OAAO,GACP,OAAO,GACP,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=estimate.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate.types.js","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/estimate.types.ts"],"names":[],"mappings":"","sourcesContent":["\nexport declare type EstimateWorkCategory =\n 'none'\n | 'blend'\n | 'check'\n | 'new'\n | 'paint'\n | 'rr'\n | 'removed'\n | 'repair'\n | 'specialist';\n\nexport declare type EstimateCostCategory =\n 'labour' |\n 'none' |\n 'pm' |\n 'pl' |\n 'parts' |\n 'other' |\n 'specialist';\n"]}
@@ -0,0 +1,8 @@
1
+ export * from './estimate.dto';
2
+ export * from './estimate.model';
3
+ export * from './estimate.types';
4
+ export * from './estimate-control-value.dto';
5
+ export * from './estimate-control-value.model';
6
+ export * from './estimate-item.dto';
7
+ export * from './estimate-item.model';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./estimate.dto"), exports);
5
+ tslib_1.__exportStar(require("./estimate.model"), exports);
6
+ tslib_1.__exportStar(require("./estimate.types"), exports);
7
+ tslib_1.__exportStar(require("./estimate-control-value.dto"), exports);
8
+ tslib_1.__exportStar(require("./estimate-control-value.model"), exports);
9
+ tslib_1.__exportStar(require("./estimate-item.dto"), exports);
10
+ tslib_1.__exportStar(require("./estimate-item.model"), exports);
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../projects/vas-lib/src/lib/model/estimate-control/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,2DAAiC;AACjC,2DAAiC;AACjC,uEAA6C;AAC7C,yEAA+C;AAC/C,8DAAoC;AACpC,gEAAsC","sourcesContent":["export * from './estimate.dto';\nexport * from './estimate.model';\nexport * from './estimate.types';\nexport * from './estimate-control-value.dto';\nexport * from './estimate-control-value.model';\nexport * from './estimate-item.dto';\nexport * from './estimate-item.model';\n"]}
@@ -0,0 +1,6 @@
1
+ export interface FirebaseDocumentMetaInterface {
2
+ _meta: {
3
+ source: 'client' | 'server';
4
+ };
5
+ }
6
+ //# sourceMappingURL=firebase-document-meta.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firebase-document-meta.interface.d.ts","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/model/firebase-document-meta.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE;QACL,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;KAC7B,CAAA;CACF"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=firebase-document-meta.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firebase-document-meta.interface.js","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/model/firebase-document-meta.interface.ts"],"names":[],"mappings":"","sourcesContent":["export interface FirebaseDocumentMetaInterface {\n _meta: {\n source: 'client' | 'server';\n }\n}\n"]}
@@ -1,3 +1,6 @@
1
+ export * from './estimate-control';
2
+ export * from './firebase-document-meta.interface';
1
3
  export * from './geo-location';
4
+ export * from './report-invocation';
2
5
  export * from './vas-time-range.model';
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,oCAAoC,CAAA;AAClD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAC"}
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./estimate-control"), exports);
5
+ tslib_1.__exportStar(require("./firebase-document-meta.interface"), exports);
4
6
  tslib_1.__exportStar(require("./geo-location"), exports);
7
+ tslib_1.__exportStar(require("./report-invocation"), exports);
5
8
  tslib_1.__exportStar(require("./vas-time-range.model"), exports);
6
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/model/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,iEAAuC","sourcesContent":["export * from './geo-location';\nexport * from './vas-time-range.model';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/model/index.ts"],"names":[],"mappings":";;;AAAA,6DAAkC;AAClC,6EAAkD;AAClD,yDAA+B;AAC/B,8DAAmC;AACnC,iEAAuC","sourcesContent":["export * from './estimate-control'\nexport * from './firebase-document-meta.interface'\nexport * from './geo-location';\nexport * from './report-invocation'\nexport * from './vas-time-range.model';\n"]}
@@ -0,0 +1,40 @@
1
+ import { FieldValueType } from '../entity';
2
+ export interface ReportInvocationFile {
3
+ id: string;
4
+ name: string;
5
+ sequence: number;
6
+ fileSize: number;
7
+ mimeType: string;
8
+ url: string;
9
+ embedLink: boolean;
10
+ rotation: number;
11
+ description: string;
12
+ displayAs: string;
13
+ displayedName: string;
14
+ group: string;
15
+ index: number;
16
+ }
17
+ export interface ReportInvocation {
18
+ id: string;
19
+ reportLayout: string;
20
+ data: {
21
+ id: string;
22
+ account: string;
23
+ reference: string;
24
+ jobDate: string;
25
+ assigneeId: string;
26
+ assigneeName: string;
27
+ jobStatus: string;
28
+ jobType: string;
29
+ /** @deprecated */
30
+ timeZoneOffset?: number;
31
+ files: {
32
+ photo: Array<ReportInvocationFile>;
33
+ documents: Array<ReportInvocationFile>;
34
+ other: Array<ReportInvocationFile>;
35
+ pdf: Array<ReportInvocationFile>;
36
+ };
37
+ fields: Record<string, FieldValueType>;
38
+ };
39
+ }
40
+ //# sourceMappingURL=report-invocation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-invocation.d.ts","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/model/report-invoc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Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=report-invocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-invocation.js","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/model/report-invocation.ts"],"names":[],"mappings":"","sourcesContent":["import { FieldValueType } from '../entity';\n\nexport interface ReportInvocationFile {\n id: string;\n name: string;\n sequence: number;\n fileSize: number;\n mimeType: string;\n url: string;\n embedLink: boolean;\n rotation: number;\n description: string;\n displayAs: string;\n displayedName: string;\n group: string;\n index: number;\n}\n\nexport interface ReportInvocation {\n id: string;\n reportLayout: string;\n data: {\n id: string;\n account: string;\n reference: string;\n jobDate: string;\n assigneeId: string;\n assigneeName: string;\n jobStatus: string;\n jobType: string;\n /** @deprecated */\n timeZoneOffset?: number;\n files: {\n photo: Array<ReportInvocationFile>;\n documents: Array<ReportInvocationFile>;\n other: Array<ReportInvocationFile>;\n pdf: Array<ReportInvocationFile>;\n }\n fields: Record<string, FieldValueType>\n };\n}\n"]}
@@ -1,20 +1,9 @@
1
- import { VasFieldDtoValue } from '../entity/vas-field.dto';
2
1
  /**
3
- * A non sophisticated way to get values from the job via paths. For example:
2
+ * Get a value from an object by path.
4
3
  *
5
- * getValueByPath(
6
- * ['foo', 'bar'],
7
- * {
8
- * foo: {
9
- * bar: 'value'
10
- * }
11
- * }
12
- * );
13
- *
14
- * will return "value"
15
- * @param {string[]} path
16
- * @param {Record<string, VasFieldDtoValue>} object
17
- * @return {T | undefined}
4
+ * Path can be an array of strings or numbers.
5
+ * Path can be a string using dot notation, which can include square brackets to
6
+ * access array positions e.g. foo.bar[0].baz
18
7
  */
19
- export declare const getValueByPath: <T extends VasFieldDtoValue>(path: string[], object: Record<string, VasFieldDtoValue | Record<string, VasFieldDtoValue>>) => T | undefined;
8
+ export declare function getValueByPath<T>(path: string | number | Array<string | number>, object: null | Record<string, any>): T | null | undefined;
20
9
  //# sourceMappingURL=get-value-by-path.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-value-by-path.d.ts","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/utils/get-value-by-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,gBAAgB,QACjD,MAAM,EAAE,UACN,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,KAC1E,CAAC,GAAG,SA6CN,CAAA"}
1
+ {"version":3,"file":"get-value-by-path.d.ts","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/utils/get-value-by-path.ts"],"names":[],"mappings":"AAmCA;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAC9C,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACjC,CAAC,GAAG,IAAI,GAAG,SAAS,CActB"}