@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
@@ -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 = 'percentage' | 'percentage-with-max' | 'fixed';
5
+ export declare type EstimateSource = 'audatex' | 'glassmatix' | 'manual' | 'ibody';
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
+ static create(source?: EstimateSource): EstimateModel;
31
+ static fromDto(dto: Partial<EstimateDto>): EstimateModel;
32
+ addItem(modelOrDto: EstimateItemModel | Partial<EstimateItemDto>, opts?: {
33
+ calculate?: boolean;
34
+ }): void;
35
+ addItems(items: Array<EstimateItemModel>, opts?: {
36
+ calculate?: boolean;
37
+ }): void;
38
+ calculate(): void;
39
+ /**
40
+ * Returns the net summary (before sundries and discounts) of the estimate.
41
+ * By summary, we mean grouping the costs by cost category.
42
+ *
43
+ * @param adjusted if the values should be calculated using the original or
44
+ * adjusted values
45
+ */
46
+ getSummaryNet(adjusted?: boolean): EstimateSummaryDto;
47
+ /**
48
+ * Applies the sundry and discount values to the net summary.
49
+
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;AAEtD,MAAM,CAAC,OAAO,MAAM,oBAAoB,GAAG,YAAY,GAAG,qBAAqB,GAAG,OAAO,CAAC;AAE1F,MAAM,CAAC,OAAO,MAAM,cAAc,GAAG,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAenF,qBAAa,aAAa;IAEjB,EAAE,EAAE,MAAM,CAAU;IACpB,MAAM,EAAE,cAAc,CAAY;IAClC,KAAK,EAAE,MAAM,CAAM;IACnB,OAAO,EAAE,MAAM,CAAM;IACrB,SAAS,EAAE,MAAM,CAA0B;IAC3C,OAAO,EAAE,MAAM,CAAK;IACpB,GAAG,EAAE,MAAM,CAAU;IACrB,GAAG,EAAE,MAAM,CAAU;IACrB,KAAK,EAAE,MAAM,CAAU;IACvB,UAAU,EAAE,MAAM,CAAO;IACzB,OAAO,EAAE,MAAM,CAAU;IACzB,UAAU,EAAE,MAAM,CAAU;IAC5B,SAAS,EAAE,MAAM,CAAU;IAC3B,WAAW,EAAE,MAAM,CAAU;IAC7B,YAAY,EAAE,oBAAoB,CAAW;IAC7C,aAAa,EAAE,MAAM,CAAU;IAC/B,aAAa,EAAE,MAAM,CAAU;IAC/B,SAAS,EAAE,MAAM,CAAO;IACxB,QAAQ,UAAS;IACjB,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAM;IACrC,UAAU,EAAE,kBAAkB,CAanC;IACK,OAAO,EAAE,kBAAkB,CAahC;IACK,eAAe,EAAE,kBAAkB,CAaxC;IAEF,MAAM,CAAC,MAAM,CAAC,MAAM,GAAE,cAAyB,GAAG,aAAa;IAM/D,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,aAAa;IAUxD,OAAO,CACL,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,EACxD,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAWhC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAOxE,SAAS,IAAI,IAAI;IAqCjB;;;;;;OAMG;IACH,aAAa,CAAC,QAAQ,UAAQ,GAAG,kBAAkB;IAwCnD;;;OAGG;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,265 @@
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
+ class EstimateModel {
22
+ constructor() {
23
+ this.id = (0, uuid_1.v4)();
24
+ this.source = 'manual';
25
+ this.label = '';
26
+ this.comment = '';
27
+ this.timestamp = (0, moment_1.default)().toISOString();
28
+ this.version = 1;
29
+ this.net = '0.00';
30
+ this.vat = '0.00';
31
+ this.gross = '0.00';
32
+ this.labourRate = '1';
33
+ this.vatRate = '0.00';
34
+ this.sundryRate = '0.00';
35
+ this.sundryMax = '0.00';
36
+ this.sundryFixed = '0.00';
37
+ this.sundryMethod = 'fixed';
38
+ this.partsDiscount = '0.00';
39
+ this.paintDiscount = '0.00';
40
+ this.timeBasis = '1';
41
+ this.adjusted = false;
42
+ this.items = [];
43
+ this.summaryNet = {
44
+ labour: '0.00',
45
+ none: '0.00',
46
+ parts: '0.00',
47
+ pm: '0.00',
48
+ pl: '0.00',
49
+ specialist: '0.00',
50
+ other: '0.00',
51
+ gross: '0.00',
52
+ net: '0.00',
53
+ hours: '0.00',
54
+ vat: '0.00',
55
+ labourRate: '0.00',
56
+ };
57
+ this.summary = {
58
+ labour: '0.00',
59
+ none: '0.00',
60
+ parts: '0.00',
61
+ pm: '0.00',
62
+ pl: '0.00',
63
+ specialist: '0.00',
64
+ other: '0.00',
65
+ gross: '0.00',
66
+ net: '0.00',
67
+ hours: '0.00',
68
+ vat: '0.00',
69
+ labourRate: '0.00',
70
+ };
71
+ this.summaryAdjusted = {
72
+ labour: '0.00',
73
+ none: '0.00',
74
+ parts: '0.00',
75
+ pm: '0.00',
76
+ pl: '0.00',
77
+ specialist: '0.00',
78
+ other: '0.00',
79
+ gross: '0.00',
80
+ net: '0.00',
81
+ hours: '0.00',
82
+ vat: '0.00',
83
+ labourRate: '0.00',
84
+ };
85
+ }
86
+ static create(source = 'manual') {
87
+ const model = new EstimateModel();
88
+ model.source = source;
89
+ return model;
90
+ }
91
+ static fromDto(dto) {
92
+ var _a;
93
+ const model = new EstimateModel();
94
+ 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)) }));
95
+ model.calculate();
96
+ return model;
97
+ }
98
+ addItem(modelOrDto, opts) {
99
+ this.items.push(modelOrDto instanceof estimate_item_model_1.EstimateItemModel ?
100
+ modelOrDto :
101
+ estimate_item_model_1.EstimateItemModel.fromDto(modelOrDto));
102
+ if (!opts || (opts && opts.calculate)) {
103
+ this.calculate();
104
+ }
105
+ }
106
+ addItems(items, opts) {
107
+ this.items = this.items.concat(items);
108
+ if (!opts || (opts && opts.calculate)) {
109
+ this.calculate();
110
+ }
111
+ }
112
+ calculate() {
113
+ this.summaryNet = this.getSummaryNet(false);
114
+ if (this.adjusted) {
115
+ this.summaryAdjusted = this.getSummary(this.summaryNet, this.sundryRate, this.sundryMax, this.sundryFixed, this.sundryMethod, this.partsDiscount, this.paintDiscount, this.adjusted);
116
+ }
117
+ this.summary = this.getSummary(this.summaryNet, this.sundryRate, this.sundryMax, this.sundryFixed, this.sundryMethod, this.partsDiscount, this.paintDiscount, this.adjusted);
118
+ this.net = b(0)
119
+ .add(this.summary.labour)
120
+ .add(this.summary.none)
121
+ .add(this.summary.parts)
122
+ .add(this.summary.pm)
123
+ .add(this.summary.specialist)
124
+ .toFixed(2);
125
+ this.vat = b(this.net || '0').mul(this.vatRate || '0').toFixed(2);
126
+ this.gross = b(this.net || '0').add(this.vat || '0').toFixed(2);
127
+ }
128
+ /**
129
+ * Returns the net summary (before sundries and discounts) of the estimate.
130
+ * By summary, we mean grouping the costs by cost category.
131
+ *
132
+ * @param adjusted if the values should be calculated using the original or
133
+ * adjusted values
134
+ */
135
+ getSummaryNet(adjusted = false) {
136
+ const summary = this.items.reduce((map, item) => {
137
+ map[item.costCategory] = b(map[item.costCategory] || '0')
138
+ .add(item.getLineValue(this.labourRate, this.timeBasis, adjusted))
139
+ .toFixed(2);
140
+ return map;
141
+ }, {
142
+ labour: '0.00',
143
+ none: '0.00',
144
+ parts: '0.00',
145
+ pm: '0.00',
146
+ pl: '0.00',
147
+ specialist: '0.00',
148
+ other: '0.00',
149
+ net: '0.00',
150
+ vat: '0.00',
151
+ gross: '0.00',
152
+ hours: '0.00',
153
+ labourRate: '0',
154
+ });
155
+ if (this.source === 'audatex') {
156
+ const mechHours = this.items
157
+ .filter(item => item.workCategory !== 'paint')
158
+ .reduce((h, item) => h.add(b(item.getTotalUnits(adjusted))), b())
159
+ .div(this.timeBasis || '1')
160
+ .round(2);
161
+ const paintHours = this.items
162
+ .filter(item => item.workCategory === 'paint')
163
+ .reduce((h, item) => h.add(b(item.getTotalUnits(adjusted))), b())
164
+ .div(this.timeBasis || '1')
165
+ .round(1);
166
+ const mechCost = mechHours.mul(this.labourRate || '0');
167
+ const paintCost = paintHours.mul(this.labourRate || '0');
168
+ summary.labour = mechCost.add(paintCost).toFixed(2);
169
+ }
170
+ return summary;
171
+ }
172
+ /**
173
+ * Applies the sundry and discount values to the net summary.
174
+
175
+ */
176
+ getSummary(summaryNet, sundryRate, sundryMax, sundryFixed, sundryMethod, partsDiscount, paintDiscount, adjusted) {
177
+ const partsDisc = b('1').minus(partsDiscount || '0');
178
+ const paintDisc = b('1').minus(paintDiscount || '0');
179
+ let partsSundry = '0.00';
180
+ if (sundryMethod === 'percentage') {
181
+ partsSundry = b(summaryNet.parts).mul(sundryRate || '1').toFixed(2);
182
+ }
183
+ else if (sundryMethod === 'percentage-with-max') {
184
+ partsSundry = b(summaryNet.parts).mul(sundryRate || '1').toFixed(2);
185
+ partsSundry = Math.min(parseFloat(sundryMax || '0'), parseFloat(partsSundry)).toFixed();
186
+ }
187
+ else if (sundryMethod === 'fixed') {
188
+ partsSundry = b(sundryFixed).toFixed(2);
189
+ }
190
+ const parts = b(summaryNet.parts).add(partsSundry);
191
+ const net = b(0)
192
+ .add(summaryNet.labour)
193
+ .add(summaryNet.none)
194
+ .add(parts)
195
+ .add(summaryNet.pm)
196
+ .add(summaryNet.specialist)
197
+ .toFixed(2);
198
+ const vat = b(net || '0')
199
+ .mul(this.vatRate || '0')
200
+ .toFixed(2);
201
+ const gross = b(net || '0').add(vat || '0').toFixed(2);
202
+ return {
203
+ labour: summaryNet.labour,
204
+ none: summaryNet.none,
205
+ parts: b(parts).mul(partsDisc).toFixed(2),
206
+ pm: b(summaryNet.pm).mul(paintDisc).toFixed(2),
207
+ pl: summaryNet.pl,
208
+ specialist: summaryNet.specialist,
209
+ other: summaryNet.other,
210
+ net: net,
211
+ vat: vat,
212
+ gross: gross,
213
+ labourRate: this.labourRate,
214
+ hours: this.getTotalHours(adjusted)
215
+ };
216
+ }
217
+ toDto() {
218
+ return {
219
+ id: this.id,
220
+ source: this.source,
221
+ label: this.label,
222
+ comment: this.comment,
223
+ timestamp: this.timestamp,
224
+ version: this.version,
225
+ net: this.net,
226
+ vat: this.vat,
227
+ gross: this.gross,
228
+ labourRate: this.labourRate,
229
+ vatRate: this.vatRate,
230
+ sundryRate: this.sundryRate,
231
+ sundryMax: this.sundryMax,
232
+ sundryFixed: this.sundryFixed,
233
+ sundryMethod: this.sundryMethod,
234
+ partsDiscount: this.partsDiscount,
235
+ paintDiscount: this.paintDiscount,
236
+ timeBasis: this.timeBasis,
237
+ items: this.items.map(i => i.toDto()),
238
+ adjusted: this.adjusted,
239
+ summary: this.summary,
240
+ summaryAdjusted: this.summaryAdjusted
241
+ };
242
+ }
243
+ getTotalHours(adjusted = false) {
244
+ if (this.source === 'audatex') {
245
+ const mechUnitsHours = this.items
246
+ .filter(item => item.workCategory !== 'paint')
247
+ .reduce((h, item) => h.add(b(item.getTotalUnits(adjusted))), b())
248
+ .round(2)
249
+ .div(this.timeBasis || '1');
250
+ const paintHours = this.items
251
+ .filter(item => item.workCategory === 'paint')
252
+ .reduce((h, item) => h.add(b(item.getTotalUnits(adjusted))), b())
253
+ .round(1)
254
+ .div(this.timeBasis || '1');
255
+ return mechUnitsHours.add(paintHours).toFixed(2);
256
+ }
257
+ const units = this.items
258
+ .filter(i => i.costCategory === 'labour')
259
+ .reduce((p, c) => p.add(b(c.getTotalUnits(adjusted))), b('0'))
260
+ .toFixed(2);
261
+ return b(units).div(this.timeBasis || '1').toFixed(2);
262
+ }
263
+ }
264
+ exports.EstimateModel = EstimateModel;
265
+ //# 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;AAQ1D,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;AAGF,MAAa,aAAa;IAA1B;QAES,OAAE,GAAW,IAAA,SAAI,GAAE,CAAC;QACpB,WAAM,GAAmB,QAAQ,CAAC;QAClC,UAAK,GAAW,EAAE,CAAC;QACnB,YAAO,GAAW,EAAE,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AC,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC;YAC9B,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,SAAS,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;CACF;AArSD,sCAqSC","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';\n\nexport declare type EstimateSundryMethod = 'percentage' | 'percentage-with-max' | 'fixed';\n\nexport declare type EstimateSource = 'audatex' | 'glassmatix' | 'manual' | 'ibody';\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\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 static create(source: EstimateSource = 'manual'): EstimateModel {\n const model = new EstimateModel();\n model.source = source;\n return model;\n }\n\n static fromDto(dto: Partial<EstimateDto>): EstimateModel {\n const model = new EstimateModel();\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 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.timeBasis, 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 .filter(item => item.workCategory !== 'paint')\n .reduce((h, item) => h.add(b(item.getTotalUnits(adjusted))), b())\n .div(this.timeBasis || '1')\n .round(2);\n const paintHours = this.items\n .filter(item => item.workCategory === 'paint')\n .reduce((h, item) => h.add(b(item.getTotalUnits(adjusted))), b())\n .div(this.timeBasis || '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 */\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();\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.timeBasis,\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.timeBasis || '1');\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.timeBasis || '1');\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.timeBasis || '1').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"]}
@@ -1,4 +1,6 @@
1
+ export * from './estimate-control';
1
2
  export * from './firebase-document-meta.interface';
2
3
  export * from './geo-location';
4
+ export * from './report-invocation';
3
5
  export * from './vas-time-range.model';
4
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,oCAAoC,CAAA;AAClD,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,7 +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);
4
5
  tslib_1.__exportStar(require("./firebase-document-meta.interface"), exports);
5
6
  tslib_1.__exportStar(require("./geo-location"), exports);
7
+ tslib_1.__exportStar(require("./report-invocation"), exports);
6
8
  tslib_1.__exportStar(require("./vas-time-range.model"), exports);
7
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,6EAAkD;AAClD,yDAA+B;AAC/B,iEAAuC","sourcesContent":["export * from './firebase-document-meta.interface'\nexport * 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":["../../../../../proj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3 @@
1
+ "use strict";
2
+ 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,19 +1,9 @@
1
1
  /**
2
- * A non sophisticated way to get values from the job via paths. For example:
2
+ * Get a value from an object by path.
3
3
  *
4
- * getValueByPath(
5
- * ['foo', 'bar'],
6
- * {
7
- * foo: {
8
- * bar: 'value'
9
- * }
10
- * }
11
- * );
12
- *
13
- * will return "value"
14
- * @param {string[]} path
15
- * @param {Record<string, FieldValueType>} object
16
- * @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
17
7
  */
18
- export declare const getValueByPath: <T>(path: string[], object: Record<string, any>) => T | undefined;
8
+ export declare function getValueByPath<T>(path: string | number | Array<string | number>, object: null | Record<string, any>): T | undefined;
19
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;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,QACxB,MAAM,EAAE,UACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC1B,CAAC,GAAG,SA6CN,CAAC"}
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,SAAS,CAaf"}