taxtank-core 0.28.12 → 0.28.13

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 (60) hide show
  1. package/bundles/taxtank-core.umd.js +1484 -1250
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/collection-dictionary.js +5 -2
  4. package/esm2015/lib/collections/sole/sole-invoice-item.collection.js +7 -0
  5. package/esm2015/lib/db/Enums/document-type.enum.js +5 -0
  6. package/esm2015/lib/db/Enums/index.js +3 -0
  7. package/esm2015/lib/db/Enums/sole-invoice-tax-type.enum.js +7 -0
  8. package/esm2015/lib/db/Enums/sole-invoice-template-tax-type.enum.js +4 -4
  9. package/esm2015/lib/db/Models/sole/sole-invoice-item.js +1 -1
  10. package/esm2015/lib/db/Models/sole/sole-invoice.js +1 -1
  11. package/esm2015/lib/forms/bank/bank-account/bank-account-add-manual.form.js +10 -6
  12. package/esm2015/lib/forms/bank/bank-account/bank-account-allocation.form.js +5 -4
  13. package/esm2015/lib/forms/sole/sole-invoice-item.form.js +3 -31
  14. package/esm2015/lib/forms/sole/sole-invoice-template.form.js +4 -5
  15. package/esm2015/lib/forms/sole/sole-invoice.form.js +93 -18
  16. package/esm2015/lib/models/dictionary/dictionary.js +2 -2
  17. package/esm2015/lib/models/document/index.js +3 -0
  18. package/esm2015/lib/models/index.js +2 -1
  19. package/esm2015/lib/models/sole/sole-details.js +1 -3
  20. package/esm2015/lib/models/sole/sole-invoice-item.js +10 -2
  21. package/esm2015/lib/models/sole/sole-invoice-template.js +13 -10
  22. package/esm2015/lib/models/sole/sole-invoice.js +82 -28
  23. package/esm2015/lib/services/http/document/document-folder/document-folder.service.js +1 -1
  24. package/esm2015/lib/services/http/document/document.service.js +20 -0
  25. package/esm2015/lib/services/http/document/index.js +3 -0
  26. package/esm2015/lib/services/http/index.js +2 -1
  27. package/esm2015/lib/services/http/rest/rest.service.js +23 -7
  28. package/esm2015/lib/services/http/sole/sole-invoice/sole-invoice.service.js +15 -1
  29. package/esm2015/lib/services/pdf/pdf-from-dom-element/pdf-from-dom-element.service.js +17 -5
  30. package/esm2015/lib/services/transaction/transaction-calculation.service.js +13 -1
  31. package/esm2015/public-api.js +3 -2
  32. package/fesm2015/taxtank-core.js +1149 -952
  33. package/fesm2015/taxtank-core.js.map +1 -1
  34. package/lib/collections/sole/sole-invoice-item.collection.d.ts +5 -0
  35. package/lib/db/Enums/document-type.enum.d.ts +3 -0
  36. package/lib/db/Enums/index.d.ts +1 -0
  37. package/lib/db/Enums/sole-invoice-tax-type.enum.d.ts +5 -0
  38. package/lib/db/Enums/sole-invoice-template-tax-type.enum.d.ts +3 -3
  39. package/lib/db/Models/sole/sole-invoice-item.d.ts +3 -1
  40. package/lib/db/Models/sole/sole-invoice.d.ts +8 -5
  41. package/lib/forms/bank/bank-account/bank-account-add-manual.form.d.ts +3 -1
  42. package/lib/forms/bank/bank-account/bank-account-allocation.form.d.ts +4 -1
  43. package/lib/forms/sole/sole-invoice-item.form.d.ts +2 -7
  44. package/lib/forms/sole/sole-invoice-template.form.d.ts +2 -3
  45. package/lib/forms/sole/sole-invoice.form.d.ts +19 -2
  46. package/lib/models/document/index.d.ts +2 -0
  47. package/lib/models/index.d.ts +1 -0
  48. package/lib/models/sole/sole-details.d.ts +0 -2
  49. package/lib/models/sole/sole-invoice-item.d.ts +7 -1
  50. package/lib/models/sole/sole-invoice-template.d.ts +10 -3
  51. package/lib/models/sole/sole-invoice.d.ts +49 -5
  52. package/lib/services/http/document/document.service.d.ts +10 -0
  53. package/lib/services/http/document/index.d.ts +2 -0
  54. package/lib/services/http/index.d.ts +1 -0
  55. package/lib/services/http/rest/rest.service.d.ts +13 -4
  56. package/lib/services/http/sole/sole-invoice/sole-invoice.service.d.ts +6 -1
  57. package/lib/services/pdf/pdf-from-dom-element/pdf-from-dom-element.service.d.ts +5 -1
  58. package/lib/services/transaction/transaction-calculation.service.d.ts +6 -0
  59. package/package.json +1 -1
  60. package/public-api.d.ts +2 -1
@@ -15,7 +15,7 @@ import flatten from 'lodash/flatten';
15
15
  import hasIn from 'lodash/hasIn';
16
16
  import first from 'lodash/first';
17
17
  import * as moment$1 from 'moment';
18
- import { extendMoment, DateRange } from 'moment-range';
18
+ import { DateRange, extendMoment } from 'moment-range';
19
19
  import uniqBy from 'lodash/uniqBy';
20
20
  import concat from 'lodash/concat';
21
21
  import { throwError as throwError$1 } from 'rxjs/internal/observable/throwError';
@@ -23,6 +23,7 @@ import cloneDeep$1 from 'lodash/cloneDeep';
23
23
  import { EventSourcePolyfill } from 'event-source-polyfill/src/eventsource.min.js';
24
24
  import compact from 'lodash/compact';
25
25
  import { Validators, FormGroup, FormControl, FormArray } from '@angular/forms';
26
+ import merge from 'lodash/merge';
26
27
  import isEqual from 'lodash/isEqual';
27
28
  import fromPairs from 'lodash/fromPairs';
28
29
  import _ from 'lodash';
@@ -957,10 +958,9 @@ class RestService {
957
958
  }
958
959
  /**
959
960
  * add new instance and update cache
960
- * @TODO rename to post
961
961
  */
962
- add(model, shouldUpdateCache = true) {
963
- return this.http.post(`${this.environment.apiV2}/${this.url}`, classToPlain(model))
962
+ create(data, shouldUpdateCache = true) {
963
+ return this.http.post(`${this.environment.apiV2}/${this.url}`, data)
964
964
  .pipe(map((newItem) => {
965
965
  if (!shouldUpdateCache) {
966
966
  return null;
@@ -976,11 +976,28 @@ class RestService {
976
976
  return newInstance;
977
977
  }));
978
978
  }
979
+ /**
980
+ * @TODO Alex TT-1777 rename to post
981
+ */
982
+ add(model, shouldUpdateCache = true) {
983
+ return this.create(classToPlain(model), shouldUpdateCache);
984
+ }
985
+ /**
986
+ * @TODO Alex TT-1777 rename to upload
987
+ */
988
+ postForm(file, params = {}) {
989
+ const formData = new FormData();
990
+ formData.append('file', file);
991
+ for (let key in params) {
992
+ formData.append(key, params[key]);
993
+ }
994
+ return this.create(formData);
995
+ }
979
996
  /**
980
997
  * Add several new items
981
998
  * @param models Array of new items for saving
982
999
  * @param queryParams query parameters for request
983
- * @TODO rename to postBatch
1000
+ * @TODO Alex TT-1777 rename to postBatch
984
1001
  */
985
1002
  addBatch(models, queryParams = {}) {
986
1003
  return this.http.post(`${this.environment.apiV2}/${this.url}`, classToPlain(models), queryParams)
@@ -1000,7 +1017,7 @@ class RestService {
1000
1017
  * Update item
1001
1018
  * @param model Existing instance for updating
1002
1019
  * @param queryParams query parameters for request
1003
- * @TODO rename to put
1020
+ * @TODO Alex TT-1777 rename to put
1004
1021
  */
1005
1022
  update(model, queryParams = {}) {
1006
1023
  return this.http.put(`${this.environment.apiV2}/${this.url}/${model['id']}`, classToPlain(model), queryParams)
@@ -1018,7 +1035,7 @@ class RestService {
1018
1035
  * Update several items
1019
1036
  * @param models Array of items for updating
1020
1037
  * @param queryParams query parameters for request
1021
- * TODO rename to putBatch
1038
+ * TODO Alex TT-1777 rename to putBatch
1022
1039
  */
1023
1040
  updateBatch(models, queryParams = {}) {
1024
1041
  return this.http.put(`${this.environment.apiV2}/${this.url}`, classToPlain(models), queryParams)
@@ -1273,7 +1290,10 @@ class CollectionDictionary {
1273
1290
  * Join several collections by ids
1274
1291
  */
1275
1292
  merge(keys) {
1276
- return this.createCollection(flatten(keys.map((id) => this.get(id.toString()).items)));
1293
+ if (!this.length) {
1294
+ return this.createCollection([]);
1295
+ }
1296
+ return this.createCollection(flatten(keys.map((key) => this.get(key.toString()).items)));
1277
1297
  }
1278
1298
  /**
1279
1299
  * Create instance of collection
@@ -2362,455 +2382,321 @@ __decorate([
2362
2382
  Type(() => ChartAccountsMetadata)
2363
2383
  ], ChartAccounts.prototype, "metadata", void 0);
2364
2384
 
2365
- class SoleInvoiceItem extends SoleInvoiceItem$1 {
2366
- constructor() {
2367
- super(...arguments);
2368
- this.isGST = false;
2385
+ class TransactionBase extends AbstractModel {
2386
+ get tankType() {
2387
+ switch (true) {
2388
+ case this.isPropertyTank():
2389
+ return TankTypeEnum.PROPERTY;
2390
+ case this.isWorkTank():
2391
+ return TankTypeEnum.WORK;
2392
+ case this.isSoleTank():
2393
+ return TankTypeEnum.SOLE;
2394
+ default:
2395
+ return TankTypeEnum.OTHER;
2396
+ }
2369
2397
  }
2370
- get amount() {
2371
- return this.price * this.quantity;
2398
+ /**
2399
+ * Check if current tank is Property
2400
+ */
2401
+ isPropertyTank() {
2402
+ // chart accounts may be empty for new instances
2403
+ if (this.chartAccounts) {
2404
+ return CHART_ACCOUNTS_CATEGORIES.property.includes(this.chartAccounts.category);
2405
+ }
2406
+ return !!this.property;
2407
+ }
2408
+ /**
2409
+ * Check if current tank is Work
2410
+ */
2411
+ isWorkTank() {
2412
+ var _a;
2413
+ // chart accounts may be empty for new instances
2414
+ if (this.chartAccounts) {
2415
+ return CHART_ACCOUNTS_CATEGORIES.work.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2416
+ }
2417
+ return !this.isPropertyTank() && !this.isSoleTank();
2418
+ }
2419
+ /**
2420
+ * Check if current tank is Sole
2421
+ */
2422
+ isSoleTank() {
2423
+ var _a;
2424
+ // chart accounts may be empty for new instances
2425
+ if (this.chartAccounts) {
2426
+ return CHART_ACCOUNTS_CATEGORIES.sole.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2427
+ }
2428
+ return !!this.business;
2372
2429
  }
2373
2430
  }
2374
2431
  __decorate([
2375
- Type(() => SoleInvoice)
2376
- ], SoleInvoiceItem.prototype, "invoice", void 0);
2377
- __decorate([
2378
- Type(() => ChartAccounts)
2379
- ], SoleInvoiceItem.prototype, "chartAccounts", void 0);
2432
+ Exclude({ toPlainOnly: true }),
2433
+ Type(() => Object),
2434
+ Transform(({ obj }) => {
2435
+ return obj.file;
2436
+ })
2437
+ ], TransactionBase.prototype, "file", void 0);
2380
2438
 
2381
- class SoleContact$1 extends AbstractModel {
2439
+ class Transaction$1 extends TransactionBase {
2382
2440
  }
2383
2441
 
2384
- // @TODO Alex/Vik: Create some base class for User and SoleContact with common methods and properties
2385
- class SoleContact extends SoleContact$1 {
2386
- get fullName() {
2387
- return `${this.firstName} ${this.lastName}`;
2388
- }
2389
- getPhotoPlaceholder() {
2390
- return `${this.firstName[0].toUpperCase()}${this.lastName[0].toUpperCase()}`;
2391
- }
2392
- // @TODO Vik: add photo field to SoleContact
2393
- getPhoto() {
2394
- return '';
2395
- }
2396
- }
2397
- __decorate([
2398
- Type(() => User)
2399
- ], SoleContact.prototype, "user", void 0);
2400
- __decorate([
2401
- Type(() => Phone)
2402
- ], SoleContact.prototype, "phone", void 0);
2403
- __decorate([
2404
- Type(() => Address)
2405
- ], SoleContact.prototype, "address", void 0);
2406
- __decorate([
2407
- Type(() => SoleInvoice)
2408
- ], SoleContact.prototype, "invoices", void 0);
2442
+ var TransactionTypeEnum;
2443
+ (function (TransactionTypeEnum) {
2444
+ TransactionTypeEnum[TransactionTypeEnum["DEBIT"] = 1] = "DEBIT";
2445
+ TransactionTypeEnum[TransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
2446
+ })(TransactionTypeEnum || (TransactionTypeEnum = {}));
2409
2447
 
2410
- class SoleInvoiceTemplate$1 extends AbstractModel {
2448
+ var TransactionOperationEnum;
2449
+ (function (TransactionOperationEnum) {
2450
+ TransactionOperationEnum[TransactionOperationEnum["ALLOCATE"] = 1] = "ALLOCATE";
2451
+ TransactionOperationEnum[TransactionOperationEnum["FIND_AND_MATCH"] = 2] = "FIND_AND_MATCH";
2452
+ TransactionOperationEnum[TransactionOperationEnum["TRANSFER"] = 3] = "TRANSFER";
2453
+ })(TransactionOperationEnum || (TransactionOperationEnum = {}));
2454
+
2455
+ var TransactionSourceEnum;
2456
+ (function (TransactionSourceEnum) {
2457
+ TransactionSourceEnum[TransactionSourceEnum["CASH"] = 1] = "CASH";
2458
+ TransactionSourceEnum[TransactionSourceEnum["BANK_TRANSACTION"] = 2] = "BANK_TRANSACTION";
2459
+ })(TransactionSourceEnum || (TransactionSourceEnum = {}));
2460
+
2461
+ var DepreciationTypeEnum;
2462
+ (function (DepreciationTypeEnum) {
2463
+ DepreciationTypeEnum[DepreciationTypeEnum["PLANT_EQUIPMENT"] = 1] = "PLANT_EQUIPMENT";
2464
+ DepreciationTypeEnum[DepreciationTypeEnum["CAPITAL_WORKS"] = 2] = "CAPITAL_WORKS";
2465
+ DepreciationTypeEnum[DepreciationTypeEnum["BULK_DEPRECIATION"] = 3] = "BULK_DEPRECIATION";
2466
+ DepreciationTypeEnum[DepreciationTypeEnum["BORROWING_EXPENSES"] = 4] = "BORROWING_EXPENSES";
2467
+ })(DepreciationTypeEnum || (DepreciationTypeEnum = {}));
2468
+
2469
+ var DepreciationCalculationEnum;
2470
+ (function (DepreciationCalculationEnum) {
2471
+ DepreciationCalculationEnum[DepreciationCalculationEnum["PRIME_COST"] = 1] = "PRIME_COST";
2472
+ DepreciationCalculationEnum[DepreciationCalculationEnum["DIMINISHING"] = 2] = "DIMINISHING";
2473
+ DepreciationCalculationEnum[DepreciationCalculationEnum["CAPITAL"] = 3] = "CAPITAL";
2474
+ DepreciationCalculationEnum[DepreciationCalculationEnum["LVP"] = 4] = "LVP";
2475
+ DepreciationCalculationEnum[DepreciationCalculationEnum["AMORTISATION"] = 5] = "AMORTISATION";
2476
+ DepreciationCalculationEnum[DepreciationCalculationEnum["SBP"] = 6] = "SBP";
2477
+ })(DepreciationCalculationEnum || (DepreciationCalculationEnum = {}));
2478
+
2479
+ class TransactionReceipt$1 extends AbstractModel {
2411
2480
  }
2412
2481
 
2413
- var SoleInvoiceTemplateTaxTypeEnum;
2414
- (function (SoleInvoiceTemplateTaxTypeEnum) {
2415
- SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["EXCLUSIVE"] = 0] = "EXCLUSIVE";
2416
- SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["INCLUSIVE"] = 1] = "INCLUSIVE";
2417
- SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["NONE"] = 2] = "NONE";
2418
- })(SoleInvoiceTemplateTaxTypeEnum || (SoleInvoiceTemplateTaxTypeEnum = {}));
2482
+ // @TODO this enum should come from backend
2483
+ /**
2484
+ * Enum with asset types
2485
+ */
2486
+ var AssetTypeEnum;
2487
+ (function (AssetTypeEnum) {
2488
+ AssetTypeEnum["RECEIPTS"] = "receipts";
2489
+ AssetTypeEnum["DOCUMENTS"] = "documents";
2490
+ AssetTypeEnum["MESSAGE"] = "message";
2491
+ })(AssetTypeEnum || (AssetTypeEnum = {}));
2419
2492
 
2420
- class SoleInvoiceTemplate extends SoleInvoiceTemplate$1 {
2493
+ /**
2494
+ * Enum with asset entity types
2495
+ */
2496
+ var AssetEntityTypeEnum;
2497
+ (function (AssetEntityTypeEnum) {
2498
+ AssetEntityTypeEnum["PROPERTIES"] = "properties";
2499
+ AssetEntityTypeEnum["FOLDERS"] = "folders";
2500
+ AssetEntityTypeEnum["DEPRECIATIONS"] = "depreciations";
2501
+ AssetEntityTypeEnum["TRANSACTIONS"] = "transactions";
2502
+ AssetEntityTypeEnum["MESSAGES"] = "messages";
2503
+ })(AssetEntityTypeEnum || (AssetEntityTypeEnum = {}));
2504
+
2505
+ class TransactionReceipt extends TransactionReceipt$1 {
2421
2506
  constructor() {
2422
2507
  super(...arguments);
2423
- this.taxType = SoleInvoiceTemplateTaxTypeEnum.NONE;
2424
- }
2425
- isNoTax() {
2426
- return this.taxType === SoleInvoiceTemplateTaxTypeEnum.NONE;
2427
- }
2428
- isTaxExclusive() {
2429
- return this.taxType === SoleInvoiceTemplateTaxTypeEnum.EXCLUSIVE;
2430
- }
2431
- isTaxInclusive() {
2432
- return this.taxType === SoleInvoiceTemplateTaxTypeEnum.INCLUSIVE;
2508
+ this.type = AssetTypeEnum.RECEIPTS;
2509
+ this.entityType = AssetEntityTypeEnum.TRANSACTIONS;
2433
2510
  }
2434
2511
  }
2435
- __decorate([
2436
- Type(() => SoleBusiness)
2437
- ], SoleInvoiceTemplate.prototype, "business", void 0);
2438
- __decorate([
2439
- Type(() => BankAccount)
2440
- ], SoleInvoiceTemplate.prototype, "bankAccount", void 0);
2441
2512
 
2442
- var SoleInvoiceStatusesEnum;
2443
- (function (SoleInvoiceStatusesEnum) {
2444
- SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["CANCELED"] = 0] = "CANCELED";
2445
- SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["DRAFT"] = 1] = "DRAFT";
2446
- SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PENDING"] = 2] = "PENDING";
2447
- SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PAID"] = 3] = "PAID";
2448
- })(SoleInvoiceStatusesEnum || (SoleInvoiceStatusesEnum = {}));
2513
+ class IncomeSource$1 extends AbstractModel {
2514
+ }
2449
2515
 
2450
- class SoleDetails$1 extends AbstractModel {
2516
+ var IncomeSourceTypeEnum;
2517
+ (function (IncomeSourceTypeEnum) {
2518
+ IncomeSourceTypeEnum[IncomeSourceTypeEnum["WORK"] = 1] = "WORK";
2519
+ IncomeSourceTypeEnum[IncomeSourceTypeEnum["SOLE"] = 2] = "SOLE";
2520
+ IncomeSourceTypeEnum[IncomeSourceTypeEnum["OTHER"] = 3] = "OTHER";
2521
+ })(IncomeSourceTypeEnum || (IncomeSourceTypeEnum = {}));
2522
+
2523
+ class SalaryForecast$1 extends AbstractModel {
2451
2524
  }
2452
2525
 
2453
- class SoleDetails extends SoleDetails$1 {
2526
+ class SalaryForecast extends SalaryForecast$1 {
2454
2527
  }
2455
- SoleDetails.GSTPercentMultiplier = 0.1;
2456
- SoleDetails.GSTPercentDivider = 11;
2457
2528
  __decorate([
2458
- Type(() => User)
2459
- ], SoleDetails.prototype, "user", void 0);
2529
+ Transform(({ obj }) => obj.netPay + obj.tax),
2530
+ Expose()
2531
+ ], SalaryForecast.prototype, "grossAmount", void 0);
2532
+ __decorate([
2533
+ Type(() => IncomeSource)
2534
+ ], SalaryForecast.prototype, "incomeSource", void 0);
2460
2535
 
2461
- class SoleInvoice extends SoleInvoice$1 {
2462
- constructor() {
2463
- super(...arguments);
2464
- this.items = [plainToClass(SoleInvoiceItem, {})];
2465
- this.status = SoleInvoiceStatusesEnum.DRAFT;
2466
- }
2467
- get amount() {
2468
- return this.items.reduce((sum, item) => sum + item.amount, 0);
2469
- }
2470
- getGSTItems() {
2471
- return this.items.filter((item) => item.isGST);
2472
- }
2473
- getGSTItemsAmount() {
2474
- return this.getGSTItems().reduce((sum, item) => sum + item.amount, 0);
2475
- }
2476
- get subtotal() {
2477
- var _a;
2478
- if ((_a = this.template) === null || _a === void 0 ? void 0 : _a.isTaxInclusive()) {
2479
- return this.amount - this.GSTAmount;
2480
- }
2481
- return this.amount;
2482
- }
2483
- get GSTAmount() {
2484
- var _a, _b;
2485
- switch (true) {
2486
- case (_a = this.template) === null || _a === void 0 ? void 0 : _a.isTaxInclusive():
2487
- return +(this.getGSTItemsAmount() / SoleDetails.GSTPercentDivider).toFixed(2);
2488
- case (_b = this.template) === null || _b === void 0 ? void 0 : _b.isTaxExclusive():
2489
- return +(this.getGSTItemsAmount() * SoleDetails.GSTPercentMultiplier).toFixed(2);
2490
- default:
2491
- return 0;
2492
- }
2493
- }
2494
- get total() {
2495
- var _a;
2496
- if ((_a = this.template) === null || _a === void 0 ? void 0 : _a.isTaxExclusive()) {
2497
- return this.amount + this.GSTAmount;
2498
- }
2536
+ class SoleForecast$1 extends AbstractModel {
2537
+ }
2538
+
2539
+ class SoleForecast extends SoleForecast$1 {
2540
+ get netPay() {
2499
2541
  return this.amount;
2500
2542
  }
2501
- isDraft() {
2502
- return this.status === SoleInvoiceStatusesEnum.DRAFT;
2503
- }
2504
- isCancelled() {
2505
- return this.status === SoleInvoiceStatusesEnum.CANCELED;
2506
- }
2507
- isPending() {
2508
- return this.status === SoleInvoiceStatusesEnum.PENDING;
2509
- }
2510
- isPaid() {
2511
- return this.status === SoleInvoiceStatusesEnum.PAID;
2512
- }
2513
- isOverdue() {
2514
- return this.isPending() && this.dateTo < new Date();
2515
- }
2516
- isUnpaid() {
2517
- return this.isPending() && this.dateTo >= new Date();
2518
- }
2543
+ ;
2519
2544
  }
2520
2545
  __decorate([
2521
- Type(() => Date)
2522
- ], SoleInvoice.prototype, "dateFrom", void 0);
2523
- __decorate([
2524
- Type(() => Date)
2525
- ], SoleInvoice.prototype, "dateTo", void 0);
2526
- __decorate([
2527
- Type(() => User)
2528
- ], SoleInvoice.prototype, "user", void 0);
2529
- __decorate([
2530
- Type(() => SoleBusiness)
2531
- ], SoleInvoice.prototype, "business", void 0);
2532
- __decorate([
2533
- Type(() => SoleInvoiceItem)
2534
- ], SoleInvoice.prototype, "items", void 0);
2535
- __decorate([
2536
- Type(() => SoleContact)
2537
- ], SoleInvoice.prototype, "payer", void 0);
2538
- __decorate([
2539
- Type(() => SoleInvoiceTemplate)
2540
- ], SoleInvoice.prototype, "template", void 0);
2546
+ Type(() => IncomeSource)
2547
+ ], SoleForecast.prototype, "incomeSource", void 0);
2541
2548
 
2542
- /**
2543
- * Class contains traveled kilometers and work usage percent in 12 weeks date range
2544
- * @TODO Vik: Best period: move this and related logic to backend
2545
- * @TODO Alex: check if we need this class when calculation refactored with backend
2546
- */
2547
- class LogbookPeriod {
2548
- isEndOfYear() {
2549
- return this.to === new FinancialYear().endDate;
2550
- }
2551
- getWorkUsageByClaim(claim) {
2552
- const claimKilometers = this.logbooks.getByVehicleClaim(claim).getClaimableLogbooks().kilometers;
2553
- return Math.round(this.workUsage * (claimKilometers / this.kilometers));
2554
- }
2549
+ class IncomeSourceForecast$1 extends AbstractModel {
2555
2550
  }
2556
- __decorate([
2557
- Type(() => Date)
2558
- ], LogbookPeriod.prototype, "from", void 0);
2559
- __decorate([
2560
- Type(() => Date)
2561
- ], LogbookPeriod.prototype, "to", void 0);
2562
2551
 
2563
- class Vehicle$1 extends AbstractModel {
2564
- }
2552
+ var SalaryForecastFrequencyEnum;
2553
+ (function (SalaryForecastFrequencyEnum) {
2554
+ SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["ANNUAL"] = 1] = "ANNUAL";
2555
+ SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["MONTHLY"] = 12] = "MONTHLY";
2556
+ SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["FORTNIGHTLY"] = 26] = "FORTNIGHTLY";
2557
+ SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["WEEKLY"] = 52] = "WEEKLY";
2558
+ })(SalaryForecastFrequencyEnum || (SalaryForecastFrequencyEnum = {}));
2565
2559
 
2566
- class VehicleLogbook$1 extends AbstractModel {
2560
+ class IncomeSourceType$1 extends AbstractModel {
2567
2561
  }
2568
2562
 
2569
- const moment = extendMoment(moment$1);
2570
- class VehicleLogbook extends VehicleLogbook$1 {
2571
- get kilometers() {
2572
- return this.odometerEnd - this.odometerStart;
2563
+ var IncomeSourceTypeListWorkEnum;
2564
+ (function (IncomeSourceTypeListWorkEnum) {
2565
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["BONUSES"] = 1] = "BONUSES";
2566
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIRECTOR_FEES"] = 2] = "DIRECTOR_FEES";
2567
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIVIDENDS"] = 3] = "DIVIDENDS";
2568
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["INTEREST"] = 4] = "INTEREST";
2569
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["PENSIONS_AND_ALLOWANCES"] = 5] = "PENSIONS_AND_ALLOWANCES";
2570
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["SUPERANNUATION"] = 8] = "SUPERANNUATION";
2571
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["ATTRIBUTED_P_S_I"] = 11] = "ATTRIBUTED_P_S_I";
2572
+ })(IncomeSourceTypeListWorkEnum || (IncomeSourceTypeListWorkEnum = {}));
2573
+
2574
+ var IncomeSourceTypeListOtherEnum;
2575
+ (function (IncomeSourceTypeListOtherEnum) {
2576
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PSI"] = 6] = "PSI";
2577
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
2578
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["TRUSTS"] = 9] = "TRUSTS";
2579
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["OTHER_INCOME"] = 10] = "OTHER_INCOME";
2580
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PARTNERSHIPS"] = 12] = "PARTNERSHIPS";
2581
+ })(IncomeSourceTypeListOtherEnum || (IncomeSourceTypeListOtherEnum = {}));
2582
+
2583
+ var IncomeSourceTypeListSoleEnum;
2584
+ (function (IncomeSourceTypeListSoleEnum) {
2585
+ IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
2586
+ })(IncomeSourceTypeListSoleEnum || (IncomeSourceTypeListSoleEnum = {}));
2587
+
2588
+ class IncomeSourceType extends IncomeSourceType$1 {
2589
+ isBonuses() {
2590
+ return this.id === IncomeSourceTypeListWorkEnum.BONUSES;
2573
2591
  }
2574
- get tankType() {
2575
- return this.isSoleTank() ? TankTypeEnum.SOLE : TankTypeEnum.WORK;
2592
+ isWork() {
2593
+ return !!IncomeSourceTypeListWorkEnum[this.id];
2576
2594
  }
2577
- isWorkTank() {
2578
- return !this.business;
2595
+ isOther() {
2596
+ return !!IncomeSourceTypeListOtherEnum[this.id];
2579
2597
  }
2580
- isSoleTank() {
2581
- return !!this.business;
2598
+ isSole() {
2599
+ return !!IncomeSourceTypeListSoleEnum[this.id];
2582
2600
  }
2583
- /**
2584
- * Get logbook period date range from logbook date and weeksInPeriod duration
2585
- */
2586
- getPeriod() {
2587
- return moment.rangeFromInterval('milliseconds', VehicleLogbook.bestPeriodDuration, this.date);
2601
+ get type() {
2602
+ switch (true) {
2603
+ case this.isWork():
2604
+ return IncomeSourceTypeEnum.WORK;
2605
+ case this.isSole():
2606
+ return IncomeSourceTypeEnum.SOLE;
2607
+ default:
2608
+ return IncomeSourceTypeEnum.OTHER;
2609
+ }
2588
2610
  }
2589
2611
  }
2590
- /**
2591
- * Logbook period duration in milliseconds.
2592
- * https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/211517441/Logbook+Vehicle
2593
- */
2594
- VehicleLogbook.bestPeriodDuration = 12 * 7 * 24 * 3600 * 1000;
2595
- __decorate([
2596
- Type(() => Date)
2597
- ], VehicleLogbook.prototype, "date", void 0);
2598
- __decorate([
2599
- Type(() => SoleBusiness)
2600
- ], VehicleLogbook.prototype, "business", void 0);
2601
-
2602
- class Vehicle extends Vehicle$1 {
2603
- }
2604
- __decorate([
2605
- Type(() => VehicleLogbook)
2606
- ], Vehicle.prototype, "logbook", void 0);
2607
-
2608
- class VehicleClaim$1 extends AbstractModel {
2609
- }
2610
2612
 
2611
- class VehicleClaimDetails$1 extends AbstractModel {
2612
- }
2613
-
2614
- var VehicleClaimDetailsMethodEnum;
2615
- (function (VehicleClaimDetailsMethodEnum) {
2616
- VehicleClaimDetailsMethodEnum[VehicleClaimDetailsMethodEnum["KMS"] = 1] = "KMS";
2617
- VehicleClaimDetailsMethodEnum[VehicleClaimDetailsMethodEnum["LOGBOOK"] = 2] = "LOGBOOK";
2618
- })(VehicleClaimDetailsMethodEnum || (VehicleClaimDetailsMethodEnum = {}));
2619
-
2620
- class VehicleClaimDetails extends VehicleClaimDetails$1 {
2613
+ class IncomeSourceForecast extends IncomeSourceForecast$1 {
2621
2614
  constructor() {
2622
2615
  super(...arguments);
2623
- /**
2624
- * Init default values for the new instances
2625
- */
2626
- this.isManual = true;
2627
- this.method = VehicleClaimDetailsMethodEnum.KMS;
2628
- this.financialYear = new FinancialYear().year;
2616
+ this.paygIncome = 0;
2617
+ this.frequency = SalaryForecastFrequencyEnum.ANNUAL;
2618
+ this.isTaxFree = false;
2629
2619
  }
2630
- isLogbookMethod() {
2631
- return this.method === VehicleClaimDetailsMethodEnum.LOGBOOK;
2620
+ /**
2621
+ * Sometimes Income source has Salary & Income source forecasts,
2622
+ * and we need these fields to work with Income source forecasts like with Salary Forecasts
2623
+ */
2624
+ get netPay() {
2625
+ return this.amount;
2632
2626
  }
2633
- isKmsMethod() {
2634
- return this.method === VehicleClaimDetailsMethodEnum.KMS;
2627
+ get grossAmount() {
2628
+ return this.amount + this.tax + this.taxInstalments + this.frankingCredits;
2635
2629
  }
2636
2630
  }
2637
2631
  __decorate([
2638
- Type(() => User)
2639
- ], VehicleClaimDetails.prototype, "user", void 0);
2632
+ Type(() => IncomeSourceType)
2633
+ ], IncomeSourceForecast.prototype, "incomeSourceType", void 0);
2634
+ __decorate([
2635
+ Type(() => IncomeSource)
2636
+ ], IncomeSourceForecast.prototype, "incomeSource", void 0);
2640
2637
 
2641
- class VehicleClaim extends VehicleClaim$1 {
2642
- constructor() {
2643
- super(...arguments);
2644
- this.kilometers = 0;
2645
- this.workUsage = 0;
2638
+ class IncomeSource extends IncomeSource$1 {
2639
+ isSalaryIncome() {
2640
+ return !!this.salaryForecasts.length;
2641
+ // @TODO Vik: old code
2642
+ // return this.type === IncomeSourceTypeEnum.SALARY;
2646
2643
  }
2647
- isWorkTank() {
2648
- return !this.business;
2644
+ isSoleIncome() {
2645
+ return !!this.soleForecasts.length;
2649
2646
  }
2650
- isSoleTank() {
2651
- return !!this.business;
2647
+ isWorkIncome() {
2648
+ return this.type === IncomeSourceTypeEnum.WORK;
2652
2649
  }
2653
- get tankType() {
2654
- return this.isSoleTank() ? TankTypeEnum.SOLE : TankTypeEnum.WORK;
2650
+ isOtherIncome() {
2651
+ return this.type === IncomeSourceTypeEnum.OTHER || (!this.isSoleIncome() && !this.isSalaryIncome());
2655
2652
  }
2656
2653
  /**
2657
- * Claim amount for KMs method. Exists only for KMs method.
2654
+ * Get salary and other income forecasts
2658
2655
  */
2659
- getKMSClaimAmount(vehicleClaimRate) {
2660
- return +(this.kilometers * vehicleClaimRate).toFixed(2);
2656
+ get forecasts() {
2657
+ return [...this.salaryForecasts, ...this.incomeSourceForecasts, ...this.soleForecasts];
2661
2658
  }
2662
2659
  /**
2663
- * Get logbook claim amount. Exists only for logbook method.
2664
- * ClaimAmount = WorkUsage * transaction/depreciation amount
2660
+ * Get actual (1st from the list) forecast
2665
2661
  */
2666
- getLogbookClaimAmount(transactions) {
2667
- const transactionsAmount = transactions
2668
- .getByVehicleClaim(this)
2669
- .getLogbookTransactions()
2670
- .sumBy('amount');
2671
- // Math.abs because amount will be negative (because we sum expenses), but we don't want negative percent value
2672
- return Math.abs(transactionsAmount) * this.workUsage / 100;
2673
- }
2674
- getAverageWeeklyKMS() {
2675
- return this.kilometers / FinancialYear.weeksInYear;
2662
+ get actualForecast() {
2663
+ return this.forecasts[0];
2676
2664
  }
2677
- static getKMSChartAccountsIdByTankType(tankType) {
2678
- return tankType === TankTypeEnum.WORK
2679
- ? ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK
2680
- : ChartAccountsListEnum.KLMS_TRAVELLED;
2665
+ /**
2666
+ * Check if user was working in month taken by the index
2667
+ * @param monthIndex by which month should be taken
2668
+ */
2669
+ isWorkedInMonth(monthIndex) {
2670
+ const monthDate = new FinancialYear().getMonthDate(monthIndex);
2671
+ return (!this.dateFrom || monthDate >= this.dateFrom) && (!this.dateTo || monthDate < this.dateTo);
2681
2672
  }
2682
2673
  }
2683
- /**
2684
- * limit for kms claim method
2685
- */
2686
- VehicleClaim.totalKmsLimit = 5000;
2687
- /**
2688
- * limit for work usage claim method
2689
- */
2690
- VehicleClaim.totalWorkUsagePercent = 100;
2691
2674
  __decorate([
2692
- Type(() => VehicleClaimDetails)
2693
- ], VehicleClaim.prototype, "details", void 0);
2675
+ Type(() => SalaryForecast)
2676
+ ], IncomeSource.prototype, "salaryForecasts", void 0);
2694
2677
  __decorate([
2695
- Type(() => SoleBusiness)
2696
- ], VehicleClaim.prototype, "business", void 0);
2678
+ Type(() => SoleForecast)
2679
+ ], IncomeSource.prototype, "soleForecasts", void 0);
2680
+ __decorate([
2681
+ Type(() => IncomeSourceForecast)
2682
+ ], IncomeSource.prototype, "incomeSourceForecasts", void 0);
2683
+ __decorate([
2684
+ Type(() => Date)
2685
+ ], IncomeSource.prototype, "dateFrom", void 0);
2686
+ __decorate([
2687
+ Type(() => Date)
2688
+ ], IncomeSource.prototype, "dateTo", void 0);
2697
2689
 
2698
- class TransactionBase extends AbstractModel {
2699
- get tankType() {
2700
- switch (true) {
2701
- case this.isPropertyTank():
2702
- return TankTypeEnum.PROPERTY;
2703
- case this.isWorkTank():
2704
- return TankTypeEnum.WORK;
2705
- case this.isSoleTank():
2706
- return TankTypeEnum.SOLE;
2707
- default:
2708
- return TankTypeEnum.OTHER;
2709
- }
2710
- }
2711
- /**
2712
- * Check if current tank is Property
2713
- */
2714
- isPropertyTank() {
2715
- // chart accounts may be empty for new instances
2716
- if (this.chartAccounts) {
2717
- return CHART_ACCOUNTS_CATEGORIES.property.includes(this.chartAccounts.category);
2718
- }
2719
- return !!this.property;
2720
- }
2721
- /**
2722
- * Check if current tank is Work
2723
- */
2724
- isWorkTank() {
2725
- var _a;
2726
- // chart accounts may be empty for new instances
2727
- if (this.chartAccounts) {
2728
- return CHART_ACCOUNTS_CATEGORIES.work.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2729
- }
2730
- return !this.isPropertyTank() && !this.isSoleTank();
2731
- }
2732
- /**
2733
- * Check if current tank is Sole
2734
- */
2735
- isSoleTank() {
2736
- var _a;
2737
- // chart accounts may be empty for new instances
2738
- if (this.chartAccounts) {
2739
- return CHART_ACCOUNTS_CATEGORIES.sole.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2740
- }
2741
- return !!this.business;
2742
- }
2743
- }
2744
- __decorate([
2745
- Exclude({ toPlainOnly: true }),
2746
- Type(() => Object),
2747
- Transform(({ obj }) => {
2748
- return obj.file;
2749
- })
2750
- ], TransactionBase.prototype, "file", void 0);
2751
-
2752
- class Depreciation$1 extends TransactionBase {
2753
- }
2754
-
2755
- var DepreciationTypeEnum;
2756
- (function (DepreciationTypeEnum) {
2757
- DepreciationTypeEnum[DepreciationTypeEnum["PLANT_EQUIPMENT"] = 1] = "PLANT_EQUIPMENT";
2758
- DepreciationTypeEnum[DepreciationTypeEnum["CAPITAL_WORKS"] = 2] = "CAPITAL_WORKS";
2759
- DepreciationTypeEnum[DepreciationTypeEnum["BULK_DEPRECIATION"] = 3] = "BULK_DEPRECIATION";
2760
- DepreciationTypeEnum[DepreciationTypeEnum["BORROWING_EXPENSES"] = 4] = "BORROWING_EXPENSES";
2761
- })(DepreciationTypeEnum || (DepreciationTypeEnum = {}));
2762
-
2763
- var DepreciationCalculationEnum;
2764
- (function (DepreciationCalculationEnum) {
2765
- DepreciationCalculationEnum[DepreciationCalculationEnum["PRIME_COST"] = 1] = "PRIME_COST";
2766
- DepreciationCalculationEnum[DepreciationCalculationEnum["DIMINISHING"] = 2] = "DIMINISHING";
2767
- DepreciationCalculationEnum[DepreciationCalculationEnum["CAPITAL"] = 3] = "CAPITAL";
2768
- DepreciationCalculationEnum[DepreciationCalculationEnum["LVP"] = 4] = "LVP";
2769
- DepreciationCalculationEnum[DepreciationCalculationEnum["AMORTISATION"] = 5] = "AMORTISATION";
2770
- DepreciationCalculationEnum[DepreciationCalculationEnum["SBP"] = 6] = "SBP";
2771
- })(DepreciationCalculationEnum || (DepreciationCalculationEnum = {}));
2772
-
2773
- class DepreciationCapitalProject$1 extends AbstractModel {
2690
+ class TransactionMetadata$1 extends AbstractModel {
2774
2691
  }
2775
2692
 
2776
- class DepreciationCapitalProject extends DepreciationCapitalProject$1 {
2693
+ class TransactionMetadata extends TransactionMetadata$1 {
2777
2694
  }
2778
2695
  __decorate([
2779
- Type(() => Date)
2780
- ], DepreciationCapitalProject.prototype, "effectiveDate", void 0);
2781
-
2782
- class DepreciationForecast$1 extends AbstractModel {
2783
- }
2696
+ Type(() => ChartAccountsMetadata)
2697
+ ], TransactionMetadata.prototype, "metadata", void 0);
2784
2698
 
2785
- class DepreciationForecast extends DepreciationForecast$1 {
2786
- get dailyClaimAmount() {
2787
- return this.claimAmount / this.daysApplied;
2788
- }
2789
- get daysApplied() {
2790
- return moment$1(this.toDate).diff(moment$1(this.fromDate), 'days');
2791
- }
2792
- getDaysByMonth(month) {
2793
- // @TODO find a better place
2794
- const year = this.financialYear - (month > 5 ? 1 : 0);
2795
- // forecast date intersect by month
2796
- const range = new DateRange(this.fromDate, this.toDate).intersect(new DateRange(new Date(year, month, 1), new Date(year, month + 1, 0)));
2797
- return range ? range.duration('days') + 1 : 0;
2798
- }
2799
- get claimOpenBalance() {
2800
- return this.openBalance * this.claimRate;
2801
- }
2802
- get claimCloseBalance() {
2803
- return this.closeBalance * this.claimRate;
2804
- }
2805
- get claimAmount() {
2806
- return this.amount * this.claimRate;
2807
- }
2808
- get claimRate() {
2809
- return this.claimPercent / 100;
2810
- }
2811
- getClaimAmountByMonth(month) {
2812
- return this.getDaysByMonth(month) * this.dailyClaimAmount;
2813
- }
2699
+ class TransactionAllocation$1 extends AbstractModel {
2814
2700
  }
2815
2701
 
2816
2702
  class BankTransaction$1 extends AbstractModel {
@@ -2822,275 +2708,296 @@ var BankTransactionTypeEnum;
2822
2708
  BankTransactionTypeEnum[BankTransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
2823
2709
  })(BankTransactionTypeEnum || (BankTransactionTypeEnum = {}));
2824
2710
 
2825
- var TransactionSourceEnum;
2826
- (function (TransactionSourceEnum) {
2827
- TransactionSourceEnum[TransactionSourceEnum["CASH"] = 1] = "CASH";
2828
- TransactionSourceEnum[TransactionSourceEnum["BANK_TRANSACTION"] = 2] = "BANK_TRANSACTION";
2829
- })(TransactionSourceEnum || (TransactionSourceEnum = {}));
2830
-
2831
- class Transaction$1 extends TransactionBase {
2832
- }
2833
-
2834
- var TransactionTypeEnum;
2835
- (function (TransactionTypeEnum) {
2836
- TransactionTypeEnum[TransactionTypeEnum["DEBIT"] = 1] = "DEBIT";
2837
- TransactionTypeEnum[TransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
2838
- })(TransactionTypeEnum || (TransactionTypeEnum = {}));
2839
-
2840
- var TransactionOperationEnum;
2841
- (function (TransactionOperationEnum) {
2842
- TransactionOperationEnum[TransactionOperationEnum["ALLOCATE"] = 1] = "ALLOCATE";
2843
- TransactionOperationEnum[TransactionOperationEnum["FIND_AND_MATCH"] = 2] = "FIND_AND_MATCH";
2844
- TransactionOperationEnum[TransactionOperationEnum["TRANSFER"] = 3] = "TRANSFER";
2845
- })(TransactionOperationEnum || (TransactionOperationEnum = {}));
2846
-
2847
- class TransactionReceipt$1 extends AbstractModel {
2848
- }
2849
-
2850
- // @TODO this enum should come from backend
2851
- /**
2852
- * Enum with asset types
2853
- */
2854
- var AssetTypeEnum;
2855
- (function (AssetTypeEnum) {
2856
- AssetTypeEnum["RECEIPTS"] = "receipts";
2857
- AssetTypeEnum["DOCUMENTS"] = "documents";
2858
- AssetTypeEnum["MESSAGE"] = "message";
2859
- })(AssetTypeEnum || (AssetTypeEnum = {}));
2860
-
2861
- /**
2862
- * Enum with asset entity types
2863
- */
2864
- var AssetEntityTypeEnum;
2865
- (function (AssetEntityTypeEnum) {
2866
- AssetEntityTypeEnum["PROPERTIES"] = "properties";
2867
- AssetEntityTypeEnum["FOLDERS"] = "folders";
2868
- AssetEntityTypeEnum["DEPRECIATIONS"] = "depreciations";
2869
- AssetEntityTypeEnum["TRANSACTIONS"] = "transactions";
2870
- AssetEntityTypeEnum["MESSAGES"] = "messages";
2871
- })(AssetEntityTypeEnum || (AssetEntityTypeEnum = {}));
2872
-
2873
- class TransactionReceipt extends TransactionReceipt$1 {
2711
+ class BankTransaction extends BankTransaction$1 {
2874
2712
  constructor() {
2875
2713
  super(...arguments);
2876
- this.type = AssetTypeEnum.RECEIPTS;
2877
- this.entityType = AssetEntityTypeEnum.TRANSACTIONS;
2714
+ // allocated money amount for bank transaction
2715
+ this.allocatedAmount = 0;
2716
+ this.unallocatedAmount = 0;
2717
+ }
2718
+ /**
2719
+ * get allocated amount value but with +/- sign
2720
+ */
2721
+ get balanceAmount() {
2722
+ return this.isCredit() ? this.allocatedAmount : -this.allocatedAmount;
2723
+ }
2724
+ /**
2725
+ * check if bank transaction is debit
2726
+ */
2727
+ isDebit() {
2728
+ return this.type === BankTransactionTypeEnum.DEBIT;
2729
+ }
2730
+ /**
2731
+ * check if bank transaction is credit
2732
+ */
2733
+ isCredit() {
2734
+ return this.type === BankTransactionTypeEnum.CREDIT;
2735
+ }
2736
+ /**
2737
+ * Create Transaction instance based on Bank Transaction
2738
+ */
2739
+ toTransaction() {
2740
+ return plainToClass(Transaction, {
2741
+ amount: +this.amount.toFixed(2),
2742
+ description: this.description,
2743
+ date: this.date,
2744
+ source: TransactionSourceEnum.BANK_TRANSACTION,
2745
+ operation: this.operation,
2746
+ type: this.type,
2747
+ });
2748
+ }
2749
+ /**
2750
+ * Check if bank transaction is completely allocated
2751
+ */
2752
+ isAllocated(allocations) {
2753
+ return this.amount === this.getAllocatedAmount(allocations);
2754
+ }
2755
+ /**
2756
+ * Get bank transaction allocated amount
2757
+ */
2758
+ getAllocatedAmount(allocations) {
2759
+ return allocations.getByBankTransactionsIds([this.id]).amount;
2760
+ }
2761
+ /**
2762
+ * Get bank transaction unallocated amount
2763
+ */
2764
+ getUnallocatedAmount(allocations) {
2765
+ return this.amount - this.getAllocatedAmount(allocations);
2878
2766
  }
2879
- }
2880
-
2881
- class IncomeSource$1 extends AbstractModel {
2882
- }
2883
-
2884
- var IncomeSourceTypeEnum;
2885
- (function (IncomeSourceTypeEnum) {
2886
- IncomeSourceTypeEnum[IncomeSourceTypeEnum["WORK"] = 1] = "WORK";
2887
- IncomeSourceTypeEnum[IncomeSourceTypeEnum["SOLE"] = 2] = "SOLE";
2888
- IncomeSourceTypeEnum[IncomeSourceTypeEnum["OTHER"] = 3] = "OTHER";
2889
- })(IncomeSourceTypeEnum || (IncomeSourceTypeEnum = {}));
2890
-
2891
- class SalaryForecast$1 extends AbstractModel {
2892
- }
2893
-
2894
- class SalaryForecast extends SalaryForecast$1 {
2895
2767
  }
2896
2768
  __decorate([
2897
- Transform(({ obj }) => obj.netPay + obj.tax),
2898
- Expose()
2899
- ], SalaryForecast.prototype, "grossAmount", void 0);
2900
- __decorate([
2901
- Type(() => IncomeSource)
2902
- ], SalaryForecast.prototype, "incomeSource", void 0);
2903
-
2904
- class SoleForecast$1 extends AbstractModel {
2905
- }
2769
+ Type(() => Date)
2770
+ ], BankTransaction.prototype, "date", void 0);
2906
2771
 
2907
- class SoleForecast extends SoleForecast$1 {
2908
- get netPay() {
2909
- return this.amount;
2772
+ class TransactionAllocation extends TransactionAllocation$1 {
2773
+ /**
2774
+ * Create a new instance of transaction allocation
2775
+ * transaction could be empty since we can POST allocation inside a new transaction
2776
+ */
2777
+ static create(amount, bankTransaction, transaction) {
2778
+ return plainToClass(TransactionAllocation, { amount, transaction, bankTransaction });
2910
2779
  }
2911
- ;
2912
2780
  }
2913
2781
  __decorate([
2914
- Type(() => IncomeSource)
2915
- ], SoleForecast.prototype, "incomeSource", void 0);
2916
-
2917
- class IncomeSourceForecast$1 extends AbstractModel {
2918
- }
2919
-
2920
- var SalaryForecastFrequencyEnum;
2921
- (function (SalaryForecastFrequencyEnum) {
2922
- SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["ANNUAL"] = 1] = "ANNUAL";
2923
- SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["MONTHLY"] = 12] = "MONTHLY";
2924
- SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["FORTNIGHTLY"] = 26] = "FORTNIGHTLY";
2925
- SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["WEEKLY"] = 52] = "WEEKLY";
2926
- })(SalaryForecastFrequencyEnum || (SalaryForecastFrequencyEnum = {}));
2782
+ Type(() => BankTransaction)
2783
+ ], TransactionAllocation.prototype, "bankTransaction", void 0);
2784
+ __decorate([
2785
+ Type(() => Transaction)
2786
+ ], TransactionAllocation.prototype, "transaction", void 0);
2927
2787
 
2928
- class IncomeSourceType$1 extends AbstractModel {
2929
- }
2788
+ /**
2789
+ * Enum with income amount types (Net or Gross)
2790
+ */
2791
+ var IncomeAmountTypeEnum;
2792
+ (function (IncomeAmountTypeEnum) {
2793
+ IncomeAmountTypeEnum[IncomeAmountTypeEnum["NET"] = 0] = "NET";
2794
+ IncomeAmountTypeEnum[IncomeAmountTypeEnum["GROSS"] = 1] = "GROSS";
2795
+ })(IncomeAmountTypeEnum || (IncomeAmountTypeEnum = {}));
2930
2796
 
2931
- var IncomeSourceTypeListWorkEnum;
2932
- (function (IncomeSourceTypeListWorkEnum) {
2933
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["BONUSES"] = 1] = "BONUSES";
2934
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIRECTOR_FEES"] = 2] = "DIRECTOR_FEES";
2935
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIVIDENDS"] = 3] = "DIVIDENDS";
2936
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["INTEREST"] = 4] = "INTEREST";
2937
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["PENSIONS_AND_ALLOWANCES"] = 5] = "PENSIONS_AND_ALLOWANCES";
2938
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["SUPERANNUATION"] = 8] = "SUPERANNUATION";
2939
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["ATTRIBUTED_P_S_I"] = 11] = "ATTRIBUTED_P_S_I";
2940
- })(IncomeSourceTypeListWorkEnum || (IncomeSourceTypeListWorkEnum = {}));
2797
+ class Depreciation$1 extends TransactionBase {
2798
+ }
2941
2799
 
2942
- var IncomeSourceTypeListOtherEnum;
2943
- (function (IncomeSourceTypeListOtherEnum) {
2944
- IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PSI"] = 6] = "PSI";
2945
- IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
2946
- IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["TRUSTS"] = 9] = "TRUSTS";
2947
- IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["OTHER_INCOME"] = 10] = "OTHER_INCOME";
2948
- IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PARTNERSHIPS"] = 12] = "PARTNERSHIPS";
2949
- })(IncomeSourceTypeListOtherEnum || (IncomeSourceTypeListOtherEnum = {}));
2800
+ class DepreciationCapitalProject$1 extends AbstractModel {
2801
+ }
2950
2802
 
2951
- var IncomeSourceTypeListSoleEnum;
2952
- (function (IncomeSourceTypeListSoleEnum) {
2953
- IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
2954
- })(IncomeSourceTypeListSoleEnum || (IncomeSourceTypeListSoleEnum = {}));
2803
+ class DepreciationCapitalProject extends DepreciationCapitalProject$1 {
2804
+ }
2805
+ __decorate([
2806
+ Type(() => Date)
2807
+ ], DepreciationCapitalProject.prototype, "effectiveDate", void 0);
2955
2808
 
2956
- class IncomeSourceType extends IncomeSourceType$1 {
2957
- isBonuses() {
2958
- return this.id === IncomeSourceTypeListWorkEnum.BONUSES;
2809
+ class DepreciationForecast$1 extends AbstractModel {
2810
+ }
2811
+
2812
+ class DepreciationForecast extends DepreciationForecast$1 {
2813
+ get dailyClaimAmount() {
2814
+ return this.claimAmount / this.daysApplied;
2959
2815
  }
2960
- isWork() {
2961
- return !!IncomeSourceTypeListWorkEnum[this.id];
2816
+ get daysApplied() {
2817
+ return moment$1(this.toDate).diff(moment$1(this.fromDate), 'days');
2962
2818
  }
2963
- isOther() {
2964
- return !!IncomeSourceTypeListOtherEnum[this.id];
2819
+ getDaysByMonth(month) {
2820
+ // @TODO find a better place
2821
+ const year = this.financialYear - (month > 5 ? 1 : 0);
2822
+ // forecast date intersect by month
2823
+ const range = new DateRange(this.fromDate, this.toDate).intersect(new DateRange(new Date(year, month, 1), new Date(year, month + 1, 0)));
2824
+ return range ? range.duration('days') + 1 : 0;
2965
2825
  }
2966
- isSole() {
2967
- return !!IncomeSourceTypeListSoleEnum[this.id];
2826
+ get claimOpenBalance() {
2827
+ return this.openBalance * this.claimRate;
2968
2828
  }
2969
- get type() {
2970
- switch (true) {
2971
- case this.isWork():
2972
- return IncomeSourceTypeEnum.WORK;
2973
- case this.isSole():
2974
- return IncomeSourceTypeEnum.SOLE;
2975
- default:
2976
- return IncomeSourceTypeEnum.OTHER;
2977
- }
2829
+ get claimCloseBalance() {
2830
+ return this.closeBalance * this.claimRate;
2831
+ }
2832
+ get claimAmount() {
2833
+ return this.amount * this.claimRate;
2834
+ }
2835
+ get claimRate() {
2836
+ return this.claimPercent / 100;
2837
+ }
2838
+ getClaimAmountByMonth(month) {
2839
+ return this.getDaysByMonth(month) * this.dailyClaimAmount;
2978
2840
  }
2979
2841
  }
2980
2842
 
2981
- class IncomeSourceForecast extends IncomeSourceForecast$1 {
2843
+ /**
2844
+ * @TODO Alex: clarify grouping rules and refactor
2845
+ */
2846
+ class Depreciation extends Depreciation$1 {
2982
2847
  constructor() {
2983
2848
  super(...arguments);
2984
- this.paygIncome = 0;
2985
- this.frequency = SalaryForecastFrequencyEnum.ANNUAL;
2986
- this.isTaxFree = false;
2849
+ this.forecasts = [];
2850
+ this.type = DepreciationTypeEnum.PLANT_EQUIPMENT;
2851
+ /**
2852
+ * @TODO remove after ? signs removed from db models
2853
+ */
2854
+ this.amount = 0;
2987
2855
  }
2988
- /**
2989
- * Sometimes Income source has Salary & Income source forecasts,
2990
- * and we need these fields to work with Income source forecasts like with Salary Forecasts
2991
- */
2992
- get netPay() {
2993
- return this.amount;
2856
+ // Type checking
2857
+ isCapital() {
2858
+ return this.type === DepreciationTypeEnum.CAPITAL_WORKS;
2994
2859
  }
2995
- get grossAmount() {
2996
- return this.amount + this.tax + this.taxInstalments + this.frankingCredits;
2860
+ isBorrowingExpense() {
2861
+ return this.type === DepreciationTypeEnum.BORROWING_EXPENSES;
2997
2862
  }
2998
- }
2999
- __decorate([
3000
- Type(() => IncomeSourceType)
3001
- ], IncomeSourceForecast.prototype, "incomeSourceType", void 0);
3002
- __decorate([
3003
- Type(() => IncomeSource)
3004
- ], IncomeSourceForecast.prototype, "incomeSource", void 0);
3005
-
3006
- class IncomeSource extends IncomeSource$1 {
3007
- isSalaryIncome() {
3008
- return !!this.salaryForecasts.length;
3009
- // @TODO Vik: old code
3010
- // return this.type === IncomeSourceTypeEnum.SALARY;
2863
+ isAsset() {
2864
+ return this.type === DepreciationTypeEnum.PLANT_EQUIPMENT;
3011
2865
  }
3012
- isSoleIncome() {
3013
- return !!this.soleForecasts.length;
2866
+ // Calculation checking
2867
+ isSBPCalculation() {
2868
+ return this.calculation === DepreciationCalculationEnum.SBP;
3014
2869
  }
3015
- isWorkIncome() {
3016
- return this.type === IncomeSourceTypeEnum.WORK;
2870
+ isPrimeCost() {
2871
+ return this.calculation === DepreciationCalculationEnum.PRIME_COST;
3017
2872
  }
3018
- isOtherIncome() {
3019
- return this.type === IncomeSourceTypeEnum.OTHER || (!this.isSoleIncome() && !this.isSalaryIncome());
2873
+ isDiminishing() {
2874
+ return this.calculation === DepreciationCalculationEnum.DIMINISHING;
2875
+ }
2876
+ // Pool checking
2877
+ isPlantEquipmentPool() {
2878
+ return this.isAsset() && !this.isSBPCalculation() && !this.isWrittenOff() && !this.isLVP();
2879
+ }
2880
+ isLVP() {
2881
+ return this.isAsset()
2882
+ && !this.isSBPCalculation()
2883
+ && this.isDiminishing()
2884
+ && this.currentYearForecast.closeBalance > Depreciation.WRITTEN_OFF_THRESHOLD
2885
+ && this.currentYearForecast.closeBalance <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
2886
+ }
2887
+ isSBP() {
2888
+ return this.isAsset() && this.isSBPCalculation() && !this.isWrittenOff();
2889
+ }
2890
+ isWrittenOff() {
2891
+ return this.writeOffYear === new FinancialYear().year;
2892
+ }
2893
+ get writeOffYear() {
2894
+ var _a;
2895
+ if (!this.writeOffManualDate && !this.writeOffDate) {
2896
+ return null;
2897
+ }
2898
+ return (_a = new FinancialYear(this.writeOffManualDate || this.writeOffDate)) === null || _a === void 0 ? void 0 : _a.year;
3020
2899
  }
3021
2900
  /**
3022
- * Get salary and other income forecasts
2901
+ * Check if depreciation chart accounts heading related to vehicles category
3023
2902
  */
3024
- get forecasts() {
3025
- return [...this.salaryForecasts, ...this.incomeSourceForecasts, ...this.soleForecasts];
2903
+ isVehicleDepreciation() {
2904
+ var _a;
2905
+ return ((_a = this.chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id) === ChartAccountsHeadingVehicleListEnum.DEPRECIATION_VEHICLES;
3026
2906
  }
3027
2907
  /**
3028
- * Get actual (1st from the list) forecast
2908
+ * Get depreciation purchase date
3029
2909
  */
3030
- get actualForecast() {
3031
- return this.forecasts[0];
2910
+ getDate() {
2911
+ return this.date;
3032
2912
  }
3033
2913
  /**
3034
- * Check if user was working in month taken by the index
3035
- * @param monthIndex by which month should be taken
2914
+ * @TODO Vik: Research a problem with depreciations without current year forecast
3036
2915
  */
3037
- isWorkedInMonth(monthIndex) {
3038
- const monthDate = new FinancialYear().getMonthDate(monthIndex);
3039
- return (!this.dateFrom || monthDate >= this.dateFrom) && (!this.dateTo || monthDate < this.dateTo);
2916
+ get currentYearForecast() {
2917
+ return this.forecasts.find((forecast) => {
2918
+ return forecast.financialYear === new FinancialYear().year;
2919
+ }) || plainToClass(DepreciationForecast, {
2920
+ financialYear: new FinancialYear().year,
2921
+ openBalance: 0,
2922
+ closeBalance: 0,
2923
+ amount: 0,
2924
+ claimPercent: 0
2925
+ });
2926
+ }
2927
+ getForecastByYear(year) {
2928
+ return this.forecasts.find((forecast) => {
2929
+ return forecast.financialYear === year;
2930
+ });
2931
+ }
2932
+ getClaimAmountByYear(year) {
2933
+ var _a;
2934
+ return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
2935
+ }
2936
+ getCloseBalanceByYear(year) {
2937
+ var _a;
2938
+ return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.closeBalance) || 0;
2939
+ }
2940
+ isBuildingAtCost() {
2941
+ return this.chartAccounts.id === ChartAccountsListEnum.BUILDING_AT_COST;
2942
+ }
2943
+ /**
2944
+ * Create a new transaction from current depreciation
2945
+ */
2946
+ toTransaction(params = {}) {
2947
+ return plainToClass(Transaction, Object.assign(params, this, { amount: -this.claimAmount, claimAmount: -this.amount * (this.claimPercent / 100) }));
2948
+ }
2949
+ /**
2950
+ * @TODO Michael: remove and check everywhere in reports
2951
+ */
2952
+ get claimAmount() {
2953
+ var _a;
2954
+ return ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
3040
2955
  }
3041
2956
  }
2957
+ Depreciation.WRITTEN_OFF_THRESHOLD = 300;
2958
+ Depreciation.LOW_VALUE_POOL_THRESHOLD = 1000;
3042
2959
  __decorate([
3043
- Type(() => SalaryForecast)
3044
- ], IncomeSource.prototype, "salaryForecasts", void 0);
2960
+ Type(() => Date)
2961
+ ], Depreciation.prototype, "purchaseDate", void 0);
3045
2962
  __decorate([
3046
- Type(() => SoleForecast)
3047
- ], IncomeSource.prototype, "soleForecasts", void 0);
2963
+ Type(() => Date)
2964
+ ], Depreciation.prototype, "date", void 0);
3048
2965
  __decorate([
3049
- Type(() => IncomeSourceForecast)
3050
- ], IncomeSource.prototype, "incomeSourceForecasts", void 0);
2966
+ Type(() => Date)
2967
+ ], Depreciation.prototype, "lowValuePoolDate", void 0);
3051
2968
  __decorate([
3052
2969
  Type(() => Date)
3053
- ], IncomeSource.prototype, "dateFrom", void 0);
2970
+ ], Depreciation.prototype, "writeOffManualDate", void 0);
3054
2971
  __decorate([
3055
2972
  Type(() => Date)
3056
- ], IncomeSource.prototype, "dateTo", void 0);
3057
-
3058
- class TransactionMetadata$1 extends AbstractModel {
3059
- }
3060
-
3061
- class TransactionMetadata extends TransactionMetadata$1 {
3062
- }
2973
+ ], Depreciation.prototype, "writeOffDate", void 0);
3063
2974
  __decorate([
3064
- Type(() => ChartAccountsMetadata)
3065
- ], TransactionMetadata.prototype, "metadata", void 0);
3066
-
3067
- class TransactionAllocation$1 extends AbstractModel {
3068
- }
3069
-
3070
- class TransactionAllocation extends TransactionAllocation$1 {
3071
- /**
3072
- * Create a new instance of transaction allocation
3073
- * transaction could be empty since we can POST allocation inside a new transaction
3074
- */
3075
- static create(amount, bankTransaction, transaction) {
3076
- return plainToClass(TransactionAllocation, { amount, transaction, bankTransaction });
3077
- }
3078
- }
2975
+ Type(() => DepreciationCapitalProject)
2976
+ ], Depreciation.prototype, "depreciationCapitalProject", void 0);
2977
+ __decorate([
2978
+ Type(() => DepreciationForecast),
2979
+ Transform(({ value, obj }) => {
2980
+ // value = array of DepreciationForecast
2981
+ // obj = plain (whole Depreciation object)
2982
+ // Set isLVP flag for each DepreciationForecast
2983
+ // @TODO refactor
2984
+ value.forEach((forecast) => {
2985
+ forecast.isLVP =
2986
+ forecast.closeBalance < 1000 &&
2987
+ obj.calculation === DepreciationCalculationEnum.DIMINISHING &&
2988
+ obj.type === DepreciationTypeEnum.PLANT_EQUIPMENT &&
2989
+ !(obj.amount > Depreciation.WRITTEN_OFF_THRESHOLD && obj.amount < Depreciation.LOW_VALUE_POOL_THRESHOLD) &&
2990
+ !(obj.writeOffDate && new FinancialYear(new Date(obj.writeOffDate)).year === obj.financialYear);
2991
+ });
2992
+ return value;
2993
+ })
2994
+ ], Depreciation.prototype, "forecasts", void 0);
3079
2995
  __decorate([
3080
- Type(() => BankTransaction)
3081
- ], TransactionAllocation.prototype, "bankTransaction", void 0);
2996
+ Type(() => ChartAccounts)
2997
+ ], Depreciation.prototype, "chartAccounts", void 0);
3082
2998
  __decorate([
3083
- Type(() => Transaction)
3084
- ], TransactionAllocation.prototype, "transaction", void 0);
3085
-
3086
- /**
3087
- * Enum with income amount types (Net or Gross)
3088
- */
3089
- var IncomeAmountTypeEnum;
3090
- (function (IncomeAmountTypeEnum) {
3091
- IncomeAmountTypeEnum[IncomeAmountTypeEnum["NET"] = 0] = "NET";
3092
- IncomeAmountTypeEnum[IncomeAmountTypeEnum["GROSS"] = 1] = "GROSS";
3093
- })(IncomeAmountTypeEnum || (IncomeAmountTypeEnum = {}));
2999
+ Type(() => BankTransaction)
3000
+ ], Depreciation.prototype, "bankTransaction", void 0);
3094
3001
 
3095
3002
  // @TODO refactor with baseModel in constructor
3096
3003
  class Transaction extends Transaction$1 {
@@ -3298,225 +3205,402 @@ __decorate([
3298
3205
  Type(() => TransactionAllocation)
3299
3206
  ], Transaction.prototype, "allocations", void 0);
3300
3207
 
3301
- class BankTransaction extends BankTransaction$1 {
3208
+ class SoleInvoiceItem extends SoleInvoiceItem$1 {
3302
3209
  constructor() {
3303
3210
  super(...arguments);
3304
- // allocated money amount for bank transaction
3305
- this.allocatedAmount = 0;
3306
- this.unallocatedAmount = 0;
3211
+ this.isGST = false;
3212
+ }
3213
+ get totalPrice() {
3214
+ return this.price * this.quantity;
3215
+ }
3216
+ }
3217
+ /**
3218
+ * GST percent value
3219
+ */
3220
+ SoleInvoiceItem.GSTRatio = 0.1;
3221
+ __decorate([
3222
+ Type(() => SoleInvoice)
3223
+ ], SoleInvoiceItem.prototype, "invoice", void 0);
3224
+ __decorate([
3225
+ Type(() => ChartAccounts)
3226
+ ], SoleInvoiceItem.prototype, "chartAccounts", void 0);
3227
+ __decorate([
3228
+ Type(() => Transaction)
3229
+ ], SoleInvoiceItem.prototype, "transaction", void 0);
3230
+
3231
+ class SoleContact$1 extends AbstractModel {
3232
+ }
3233
+
3234
+ // @TODO Alex/Vik: Create some base class for User and SoleContact with common methods and properties
3235
+ class SoleContact extends SoleContact$1 {
3236
+ get fullName() {
3237
+ return `${this.firstName} ${this.lastName}`;
3238
+ }
3239
+ getPhotoPlaceholder() {
3240
+ return `${this.firstName[0].toUpperCase()}${this.lastName[0].toUpperCase()}`;
3241
+ }
3242
+ // @TODO Vik: add photo field to SoleContact
3243
+ getPhoto() {
3244
+ return '';
3245
+ }
3246
+ }
3247
+ __decorate([
3248
+ Type(() => User)
3249
+ ], SoleContact.prototype, "user", void 0);
3250
+ __decorate([
3251
+ Type(() => Phone)
3252
+ ], SoleContact.prototype, "phone", void 0);
3253
+ __decorate([
3254
+ Type(() => Address)
3255
+ ], SoleContact.prototype, "address", void 0);
3256
+ __decorate([
3257
+ Type(() => SoleInvoice)
3258
+ ], SoleContact.prototype, "invoices", void 0);
3259
+
3260
+ class SoleInvoiceTemplate$1 extends AbstractModel {
3261
+ }
3262
+
3263
+ var SoleInvoiceTemplateTaxTypeEnum;
3264
+ (function (SoleInvoiceTemplateTaxTypeEnum) {
3265
+ SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["TAX_EXCLUSIVE"] = 0] = "TAX_EXCLUSIVE";
3266
+ SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["TAX_INCLUSIVE"] = 1] = "TAX_INCLUSIVE";
3267
+ SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["NO_TAX"] = 2] = "NO_TAX";
3268
+ })(SoleInvoiceTemplateTaxTypeEnum || (SoleInvoiceTemplateTaxTypeEnum = {}));
3269
+
3270
+ class SoleInvoiceTemplate extends SoleInvoiceTemplate$1 {
3271
+ constructor() {
3272
+ super(...arguments);
3273
+ /**
3274
+ * Affects to SoleInvoiceItem.isGST flag availability.
3275
+ * When NONE: isGST is unavailable
3276
+ * When EXCLUSIVE: GST amount added additionaly to invoice total price
3277
+ * When INCLUSIVE: GST amount is already included to invoice total price
3278
+ */
3279
+ this.taxType = SoleInvoiceTemplateTaxTypeEnum.NO_TAX;
3307
3280
  }
3308
3281
  /**
3309
- * get allocated amount value but with +/- sign
3282
+ * Get term duration in milliseconds
3310
3283
  */
3311
- get balanceAmount() {
3312
- return this.isCredit() ? this.allocatedAmount : -this.allocatedAmount;
3284
+ get termTime() {
3285
+ return this.term * 24 * 3600 * 1000;
3286
+ }
3287
+ }
3288
+ __decorate([
3289
+ Type(() => SoleBusiness)
3290
+ ], SoleInvoiceTemplate.prototype, "business", void 0);
3291
+ __decorate([
3292
+ Type(() => BankAccount)
3293
+ ], SoleInvoiceTemplate.prototype, "bankAccount", void 0);
3294
+
3295
+ var SoleInvoiceStatusesEnum;
3296
+ (function (SoleInvoiceStatusesEnum) {
3297
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["CANCELED"] = 0] = "CANCELED";
3298
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["DRAFT"] = 1] = "DRAFT";
3299
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PENDING"] = 2] = "PENDING";
3300
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PAID"] = 3] = "PAID";
3301
+ })(SoleInvoiceStatusesEnum || (SoleInvoiceStatusesEnum = {}));
3302
+
3303
+ var SoleInvoiceTaxTypeEnum;
3304
+ (function (SoleInvoiceTaxTypeEnum) {
3305
+ SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["TAX_EXCLUSIVE"] = 0] = "TAX_EXCLUSIVE";
3306
+ SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["TAX_INCLUSIVE"] = 1] = "TAX_INCLUSIVE";
3307
+ SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["NO_TAX"] = 2] = "NO_TAX";
3308
+ })(SoleInvoiceTaxTypeEnum || (SoleInvoiceTaxTypeEnum = {}));
3309
+
3310
+ class SoleInvoiceItemCollection extends Collection {
3311
+ get gstPrice() {
3312
+ return this.filterBy('isGST', true).sumBy('totalPrice');
3313
+ }
3314
+ }
3315
+
3316
+ class SoleInvoice extends SoleInvoice$1 {
3317
+ constructor() {
3318
+ super(...arguments);
3319
+ this.status = SoleInvoiceStatusesEnum.DRAFT;
3320
+ this.taxType = SoleInvoiceTaxTypeEnum.NO_TAX;
3313
3321
  }
3314
3322
  /**
3315
- * check if bank transaction is debit
3323
+ * Get items array as collection
3316
3324
  */
3317
- isDebit() {
3318
- return this.type === BankTransactionTypeEnum.DEBIT;
3325
+ get itemsCollection() {
3326
+ return new SoleInvoiceItemCollection(this.items);
3319
3327
  }
3320
3328
  /**
3321
- * check if bank transaction is credit
3329
+ * Total price of all items
3322
3330
  */
3323
- isCredit() {
3324
- return this.type === BankTransactionTypeEnum.CREDIT;
3331
+ get price() {
3332
+ return this.itemsCollection.sumBy('totalPrice');
3325
3333
  }
3326
3334
  /**
3327
- * Create Transaction instance based on Bank Transaction
3335
+ * Total invoice price without GST
3328
3336
  */
3329
- toTransaction() {
3330
- return plainToClass(Transaction, {
3331
- amount: +this.amount.toFixed(2),
3332
- description: this.description,
3333
- date: this.date,
3334
- source: TransactionSourceEnum.BANK_TRANSACTION,
3335
- operation: this.operation,
3336
- type: this.type,
3337
- });
3337
+ get netPrice() {
3338
+ if (this.isTaxInclusive()) {
3339
+ return this.price - this.GSTAmount;
3340
+ }
3341
+ return this.price;
3338
3342
  }
3339
3343
  /**
3340
- * Check if bank transaction is completely allocated
3344
+ * Total final price (net + GST)
3341
3345
  */
3342
- isAllocated(allocations) {
3343
- return this.amount === this.getAllocatedAmount(allocations);
3346
+ get grossPrice() {
3347
+ if (this.isTaxExclusive()) {
3348
+ return this.price + this.GSTAmount;
3349
+ }
3350
+ return this.price;
3344
3351
  }
3345
3352
  /**
3346
- * Get bank transaction allocated amount
3353
+ * Total GST amount
3347
3354
  */
3348
- getAllocatedAmount(allocations) {
3349
- return allocations.getByBankTransactionsIds([this.id]).amount;
3355
+ get GSTAmount() {
3356
+ switch (this.taxType) {
3357
+ case SoleInvoiceTaxTypeEnum.TAX_INCLUSIVE:
3358
+ return this.inclusiveGSTAmount;
3359
+ case SoleInvoiceTaxTypeEnum.TAX_EXCLUSIVE:
3360
+ return this.exclusiveGSTAmount;
3361
+ case SoleInvoiceTaxTypeEnum.NO_TAX:
3362
+ return 0;
3363
+ }
3350
3364
  }
3351
3365
  /**
3352
- * Get bank transaction unallocated amount
3366
+ * When tax inclusive, GST amount is included to total price
3353
3367
  */
3354
- getUnallocatedAmount(allocations) {
3355
- return this.amount - this.getAllocatedAmount(allocations);
3368
+ get inclusiveGSTAmount() {
3369
+ const gstPrice = this.itemsCollection.gstPrice;
3370
+ return +(gstPrice - (gstPrice / (1 + SoleInvoiceItem.GSTRatio))).toFixed(2);
3371
+ }
3372
+ /**
3373
+ * When tax exclusive, GST amount should be added additionally to total price
3374
+ */
3375
+ get exclusiveGSTAmount() {
3376
+ return +(this.itemsCollection.gstPrice * SoleInvoiceItem.GSTRatio).toFixed(2);
3377
+ }
3378
+ isDraft() {
3379
+ return this.status === SoleInvoiceStatusesEnum.DRAFT;
3380
+ }
3381
+ isCancelled() {
3382
+ return this.status === SoleInvoiceStatusesEnum.CANCELED;
3383
+ }
3384
+ isPending() {
3385
+ return this.status === SoleInvoiceStatusesEnum.PENDING;
3386
+ }
3387
+ isPaid() {
3388
+ return this.status === SoleInvoiceStatusesEnum.PAID;
3389
+ }
3390
+ isOverdue() {
3391
+ return this.isPending() && this.dateTo < new Date();
3392
+ }
3393
+ isUnpaid() {
3394
+ return this.isPending() && this.dateTo >= new Date();
3395
+ }
3396
+ /**
3397
+ * GST is not available for invoices without taxes
3398
+ */
3399
+ isNoTax() {
3400
+ return this.taxType === SoleInvoiceTaxTypeEnum.NO_TAX;
3401
+ }
3402
+ /**
3403
+ * GST amount is not included in items prices for invoices with tax exclusive,
3404
+ * we should add GST amount additionaly to subtotal price to get total price
3405
+ */
3406
+ isTaxExclusive() {
3407
+ return this.taxType === SoleInvoiceTaxTypeEnum.TAX_EXCLUSIVE;
3408
+ }
3409
+ /**
3410
+ * GST amount already included in items prices for invoices with tax inclusive,
3411
+ * we should subtract GST amount from total price to get subtotal price
3412
+ */
3413
+ isTaxInclusive() {
3414
+ return this.taxType === SoleInvoiceTaxTypeEnum.TAX_INCLUSIVE;
3415
+ }
3416
+ getNumber() {
3417
+ return String(this.number).padStart(SoleInvoice.NUMBER_LENGTH, '0');
3418
+ }
3419
+ get name() {
3420
+ return `invoice-${this.getNumber()}.pdf`;
3421
+ }
3422
+ }
3423
+ SoleInvoice.NUMBER_LENGTH = 4;
3424
+ __decorate([
3425
+ Type(() => Date)
3426
+ ], SoleInvoice.prototype, "dateFrom", void 0);
3427
+ __decorate([
3428
+ Type(() => Date)
3429
+ ], SoleInvoice.prototype, "dateTo", void 0);
3430
+ __decorate([
3431
+ Type(() => User)
3432
+ ], SoleInvoice.prototype, "user", void 0);
3433
+ __decorate([
3434
+ Type(() => SoleBusiness)
3435
+ ], SoleInvoice.prototype, "business", void 0);
3436
+ __decorate([
3437
+ Type(() => SoleInvoiceItem)
3438
+ ], SoleInvoice.prototype, "items", void 0);
3439
+ __decorate([
3440
+ Type(() => SoleContact)
3441
+ ], SoleInvoice.prototype, "payer", void 0);
3442
+ __decorate([
3443
+ Type(() => SoleInvoiceTemplate)
3444
+ ], SoleInvoice.prototype, "template", void 0);
3445
+ __decorate([
3446
+ Type(() => BankAccount)
3447
+ ], SoleInvoice.prototype, "bankAccount", void 0);
3448
+
3449
+ /**
3450
+ * Class contains traveled kilometers and work usage percent in 12 weeks date range
3451
+ * @TODO Vik: Best period: move this and related logic to backend
3452
+ * @TODO Alex: check if we need this class when calculation refactored with backend
3453
+ */
3454
+ class LogbookPeriod {
3455
+ isEndOfYear() {
3456
+ return this.to === new FinancialYear().endDate;
3457
+ }
3458
+ getWorkUsageByClaim(claim) {
3459
+ const claimKilometers = this.logbooks.getByVehicleClaim(claim).getClaimableLogbooks().kilometers;
3460
+ return Math.round(this.workUsage * (claimKilometers / this.kilometers));
3461
+ }
3462
+ }
3463
+ __decorate([
3464
+ Type(() => Date)
3465
+ ], LogbookPeriod.prototype, "from", void 0);
3466
+ __decorate([
3467
+ Type(() => Date)
3468
+ ], LogbookPeriod.prototype, "to", void 0);
3469
+
3470
+ class Vehicle$1 extends AbstractModel {
3471
+ }
3472
+
3473
+ class VehicleLogbook$1 extends AbstractModel {
3474
+ }
3475
+
3476
+ const moment = extendMoment(moment$1);
3477
+ class VehicleLogbook extends VehicleLogbook$1 {
3478
+ get kilometers() {
3479
+ return this.odometerEnd - this.odometerStart;
3480
+ }
3481
+ get tankType() {
3482
+ return this.isSoleTank() ? TankTypeEnum.SOLE : TankTypeEnum.WORK;
3483
+ }
3484
+ isWorkTank() {
3485
+ return !this.business;
3486
+ }
3487
+ isSoleTank() {
3488
+ return !!this.business;
3489
+ }
3490
+ /**
3491
+ * Get logbook period date range from logbook date and weeksInPeriod duration
3492
+ */
3493
+ getPeriod() {
3494
+ return moment.rangeFromInterval('milliseconds', VehicleLogbook.bestPeriodDuration, this.date);
3356
3495
  }
3357
3496
  }
3497
+ /**
3498
+ * Logbook period duration in milliseconds.
3499
+ * https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/211517441/Logbook+Vehicle
3500
+ */
3501
+ VehicleLogbook.bestPeriodDuration = 12 * 7 * 24 * 3600 * 1000;
3358
3502
  __decorate([
3359
3503
  Type(() => Date)
3360
- ], BankTransaction.prototype, "date", void 0);
3504
+ ], VehicleLogbook.prototype, "date", void 0);
3505
+ __decorate([
3506
+ Type(() => SoleBusiness)
3507
+ ], VehicleLogbook.prototype, "business", void 0);
3361
3508
 
3362
- /**
3363
- * @TODO Alex: clarify grouping rules and refactor
3364
- */
3365
- class Depreciation extends Depreciation$1 {
3509
+ class Vehicle extends Vehicle$1 {
3510
+ }
3511
+ __decorate([
3512
+ Type(() => VehicleLogbook)
3513
+ ], Vehicle.prototype, "logbook", void 0);
3514
+
3515
+ class VehicleClaim$1 extends AbstractModel {
3516
+ }
3517
+
3518
+ class VehicleClaimDetails$1 extends AbstractModel {
3519
+ }
3520
+
3521
+ var VehicleClaimDetailsMethodEnum;
3522
+ (function (VehicleClaimDetailsMethodEnum) {
3523
+ VehicleClaimDetailsMethodEnum[VehicleClaimDetailsMethodEnum["KMS"] = 1] = "KMS";
3524
+ VehicleClaimDetailsMethodEnum[VehicleClaimDetailsMethodEnum["LOGBOOK"] = 2] = "LOGBOOK";
3525
+ })(VehicleClaimDetailsMethodEnum || (VehicleClaimDetailsMethodEnum = {}));
3526
+
3527
+ class VehicleClaimDetails extends VehicleClaimDetails$1 {
3366
3528
  constructor() {
3367
3529
  super(...arguments);
3368
- this.forecasts = [];
3369
- this.type = DepreciationTypeEnum.PLANT_EQUIPMENT;
3370
3530
  /**
3371
- * @TODO remove after ? signs removed from db models
3531
+ * Init default values for the new instances
3372
3532
  */
3373
- this.amount = 0;
3374
- }
3375
- // Type checking
3376
- isCapital() {
3377
- return this.type === DepreciationTypeEnum.CAPITAL_WORKS;
3378
- }
3379
- isBorrowingExpense() {
3380
- return this.type === DepreciationTypeEnum.BORROWING_EXPENSES;
3381
- }
3382
- isAsset() {
3383
- return this.type === DepreciationTypeEnum.PLANT_EQUIPMENT;
3384
- }
3385
- // Calculation checking
3386
- isSBPCalculation() {
3387
- return this.calculation === DepreciationCalculationEnum.SBP;
3388
- }
3389
- isPrimeCost() {
3390
- return this.calculation === DepreciationCalculationEnum.PRIME_COST;
3391
- }
3392
- isDiminishing() {
3393
- return this.calculation === DepreciationCalculationEnum.DIMINISHING;
3533
+ this.isManual = true;
3534
+ this.method = VehicleClaimDetailsMethodEnum.KMS;
3535
+ this.financialYear = new FinancialYear().year;
3394
3536
  }
3395
- // Pool checking
3396
- isPlantEquipmentPool() {
3397
- return this.isAsset() && !this.isSBPCalculation() && !this.isWrittenOff() && !this.isLVP();
3537
+ isLogbookMethod() {
3538
+ return this.method === VehicleClaimDetailsMethodEnum.LOGBOOK;
3398
3539
  }
3399
- isLVP() {
3400
- return this.isAsset()
3401
- && !this.isSBPCalculation()
3402
- && this.isDiminishing()
3403
- && this.currentYearForecast.closeBalance > Depreciation.WRITTEN_OFF_THRESHOLD
3404
- && this.currentYearForecast.closeBalance <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
3540
+ isKmsMethod() {
3541
+ return this.method === VehicleClaimDetailsMethodEnum.KMS;
3405
3542
  }
3406
- isSBP() {
3407
- return this.isAsset() && this.isSBPCalculation() && !this.isWrittenOff();
3543
+ }
3544
+ __decorate([
3545
+ Type(() => User)
3546
+ ], VehicleClaimDetails.prototype, "user", void 0);
3547
+
3548
+ class VehicleClaim extends VehicleClaim$1 {
3549
+ constructor() {
3550
+ super(...arguments);
3551
+ this.kilometers = 0;
3552
+ this.workUsage = 0;
3408
3553
  }
3409
- isWrittenOff() {
3410
- return this.writeOffYear === new FinancialYear().year;
3554
+ isWorkTank() {
3555
+ return !this.business;
3411
3556
  }
3412
- get writeOffYear() {
3413
- var _a;
3414
- if (!this.writeOffManualDate && !this.writeOffDate) {
3415
- return null;
3416
- }
3417
- return (_a = new FinancialYear(this.writeOffManualDate || this.writeOffDate)) === null || _a === void 0 ? void 0 : _a.year;
3557
+ isSoleTank() {
3558
+ return !!this.business;
3418
3559
  }
3419
- /**
3420
- * Check if depreciation chart accounts heading related to vehicles category
3421
- */
3422
- isVehicleDepreciation() {
3423
- var _a;
3424
- return ((_a = this.chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id) === ChartAccountsHeadingVehicleListEnum.DEPRECIATION_VEHICLES;
3560
+ get tankType() {
3561
+ return this.isSoleTank() ? TankTypeEnum.SOLE : TankTypeEnum.WORK;
3425
3562
  }
3426
3563
  /**
3427
- * Get depreciation purchase date
3564
+ * Claim amount for KMs method. Exists only for KMs method.
3428
3565
  */
3429
- getDate() {
3430
- return this.date;
3566
+ getKMSClaimAmount(vehicleClaimRate) {
3567
+ return +(this.kilometers * vehicleClaimRate).toFixed(2);
3431
3568
  }
3432
3569
  /**
3433
- * @TODO Vik: Research a problem with depreciations without current year forecast
3570
+ * Get logbook claim amount. Exists only for logbook method.
3571
+ * ClaimAmount = WorkUsage * transaction/depreciation amount
3434
3572
  */
3435
- get currentYearForecast() {
3436
- return this.forecasts.find((forecast) => {
3437
- return forecast.financialYear === new FinancialYear().year;
3438
- }) || plainToClass(DepreciationForecast, {
3439
- financialYear: new FinancialYear().year,
3440
- openBalance: 0,
3441
- closeBalance: 0,
3442
- amount: 0,
3443
- claimPercent: 0
3444
- });
3445
- }
3446
- getForecastByYear(year) {
3447
- return this.forecasts.find((forecast) => {
3448
- return forecast.financialYear === year;
3449
- });
3450
- }
3451
- getClaimAmountByYear(year) {
3452
- var _a;
3453
- return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
3454
- }
3455
- getCloseBalanceByYear(year) {
3456
- var _a;
3457
- return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.closeBalance) || 0;
3458
- }
3459
- isBuildingAtCost() {
3460
- return this.chartAccounts.id === ChartAccountsListEnum.BUILDING_AT_COST;
3573
+ getLogbookClaimAmount(transactions) {
3574
+ const transactionsAmount = transactions
3575
+ .getByVehicleClaim(this)
3576
+ .getLogbookTransactions()
3577
+ .sumBy('amount');
3578
+ // Math.abs because amount will be negative (because we sum expenses), but we don't want negative percent value
3579
+ return Math.abs(transactionsAmount) * this.workUsage / 100;
3461
3580
  }
3462
- /**
3463
- * Create a new transaction from current depreciation
3464
- */
3465
- toTransaction(params = {}) {
3466
- return plainToClass(Transaction, Object.assign(params, this, { amount: -this.claimAmount, claimAmount: -this.amount * (this.claimPercent / 100) }));
3581
+ getAverageWeeklyKMS() {
3582
+ return this.kilometers / FinancialYear.weeksInYear;
3467
3583
  }
3468
- /**
3469
- * @TODO Michael: remove and check everywhere in reports
3470
- */
3471
- get claimAmount() {
3472
- var _a;
3473
- return ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
3584
+ static getKMSChartAccountsIdByTankType(tankType) {
3585
+ return tankType === TankTypeEnum.WORK
3586
+ ? ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK
3587
+ : ChartAccountsListEnum.KLMS_TRAVELLED;
3474
3588
  }
3475
3589
  }
3476
- Depreciation.WRITTEN_OFF_THRESHOLD = 300;
3477
- Depreciation.LOW_VALUE_POOL_THRESHOLD = 1000;
3478
- __decorate([
3479
- Type(() => Date)
3480
- ], Depreciation.prototype, "purchaseDate", void 0);
3481
- __decorate([
3482
- Type(() => Date)
3483
- ], Depreciation.prototype, "date", void 0);
3484
- __decorate([
3485
- Type(() => Date)
3486
- ], Depreciation.prototype, "lowValuePoolDate", void 0);
3487
- __decorate([
3488
- Type(() => Date)
3489
- ], Depreciation.prototype, "writeOffManualDate", void 0);
3490
- __decorate([
3491
- Type(() => Date)
3492
- ], Depreciation.prototype, "writeOffDate", void 0);
3493
- __decorate([
3494
- Type(() => DepreciationCapitalProject)
3495
- ], Depreciation.prototype, "depreciationCapitalProject", void 0);
3496
- __decorate([
3497
- Type(() => DepreciationForecast),
3498
- Transform(({ value, obj }) => {
3499
- // value = array of DepreciationForecast
3500
- // obj = plain (whole Depreciation object)
3501
- // Set isLVP flag for each DepreciationForecast
3502
- // @TODO refactor
3503
- value.forEach((forecast) => {
3504
- forecast.isLVP =
3505
- forecast.closeBalance < 1000 &&
3506
- obj.calculation === DepreciationCalculationEnum.DIMINISHING &&
3507
- obj.type === DepreciationTypeEnum.PLANT_EQUIPMENT &&
3508
- !(obj.amount > Depreciation.WRITTEN_OFF_THRESHOLD && obj.amount < Depreciation.LOW_VALUE_POOL_THRESHOLD) &&
3509
- !(obj.writeOffDate && new FinancialYear(new Date(obj.writeOffDate)).year === obj.financialYear);
3510
- });
3511
- return value;
3512
- })
3513
- ], Depreciation.prototype, "forecasts", void 0);
3590
+ /**
3591
+ * limit for kms claim method
3592
+ */
3593
+ VehicleClaim.totalKmsLimit = 5000;
3594
+ /**
3595
+ * limit for work usage claim method
3596
+ */
3597
+ VehicleClaim.totalWorkUsagePercent = 100;
3514
3598
  __decorate([
3515
- Type(() => ChartAccounts)
3516
- ], Depreciation.prototype, "chartAccounts", void 0);
3599
+ Type(() => VehicleClaimDetails)
3600
+ ], VehicleClaim.prototype, "details", void 0);
3517
3601
  __decorate([
3518
- Type(() => BankTransaction)
3519
- ], Depreciation.prototype, "bankTransaction", void 0);
3602
+ Type(() => SoleBusiness)
3603
+ ], VehicleClaim.prototype, "business", void 0);
3520
3604
 
3521
3605
  class SoleBusinessActivity$1 extends AbstractModel {
3522
3606
  }
@@ -3582,6 +3666,15 @@ class SoleDepreciationMethod extends SoleDepreciationMethod$1 {
3582
3666
  }
3583
3667
  }
3584
3668
 
3669
+ class SoleDetails$1 extends AbstractModel {
3670
+ }
3671
+
3672
+ class SoleDetails extends SoleDetails$1 {
3673
+ }
3674
+ __decorate([
3675
+ Type(() => User)
3676
+ ], SoleDetails.prototype, "user", void 0);
3677
+
3585
3678
  class User extends User$1 {
3586
3679
  get fullName() {
3587
3680
  return `${this.firstName} ${this.lastName}`;
@@ -5138,6 +5231,47 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
5138
5231
  }]
5139
5232
  }] });
5140
5233
 
5234
+ class Document$1 extends AbstractModel {
5235
+ }
5236
+
5237
+ /**
5238
+ * Enum with document types which used to API url prefix
5239
+ */
5240
+ var DocumentApiUrlPrefixEnum;
5241
+ (function (DocumentApiUrlPrefixEnum) {
5242
+ DocumentApiUrlPrefixEnum["FOLDERS"] = "folders";
5243
+ DocumentApiUrlPrefixEnum["PROPERTIES"] = "properties";
5244
+ })(DocumentApiUrlPrefixEnum || (DocumentApiUrlPrefixEnum = {}));
5245
+
5246
+ class Document extends Document$1 {
5247
+ constructor() {
5248
+ super(...arguments);
5249
+ this.type = AssetTypeEnum.DOCUMENTS;
5250
+ this.entityType = AssetEntityTypeEnum.FOLDERS;
5251
+ }
5252
+ /**
5253
+ * Get folder as document parent entity
5254
+ */
5255
+ getEntity() {
5256
+ return this.folder;
5257
+ }
5258
+ /**
5259
+ * Get API url prefix
5260
+ */
5261
+ getApiUrlPrefix() {
5262
+ return DocumentApiUrlPrefixEnum.FOLDERS;
5263
+ }
5264
+ }
5265
+
5266
+ class DocumentFolder$1 extends AbstractModel {
5267
+ }
5268
+
5269
+ class DocumentFolder extends DocumentFolder$1 {
5270
+ }
5271
+ __decorate([
5272
+ Type(() => Document)
5273
+ ], DocumentFolder.prototype, "documents", void 0);
5274
+
5141
5275
  class VehicleClaimCollection extends Collection {
5142
5276
  /**
5143
5277
  * Get remaining kilometers limit. Total limit ({@link VehicleClaim.totalKmsLimit}) - claimed kilometers from other vehicle claims
@@ -6615,6 +6749,13 @@ class ChartAccountsCategoryECollection {
6615
6749
  }
6616
6750
  }
6617
6751
 
6752
+ var DocumentTypeEnum;
6753
+ (function (DocumentTypeEnum) {
6754
+ DocumentTypeEnum[DocumentTypeEnum["INVOICE"] = 1] = "INVOICE";
6755
+ })(DocumentTypeEnum || (DocumentTypeEnum = {}));
6756
+
6757
+ // @TODO Artem TT-2308 move everything
6758
+
6618
6759
  var ChartAccountsEtpEnum;
6619
6760
  (function (ChartAccountsEtpEnum) {
6620
6761
  ChartAccountsEtpEnum[ChartAccountsEtpEnum["ETP_R"] = 549] = "ETP_R";
@@ -7672,7 +7813,7 @@ class Dictionary {
7672
7813
  this.items[key] = value;
7673
7814
  }
7674
7815
  get(key) {
7675
- return this.items[key] ? this.items[key] : null;
7816
+ return this.items[key] !== undefined ? this.items[key] : null;
7676
7817
  }
7677
7818
  groupItems(items, path) {
7678
7819
  items.forEach((item) => {
@@ -7770,38 +7911,6 @@ class DepreciationReceipt extends DepreciationReceipt$1 {
7770
7911
  }
7771
7912
  }
7772
7913
 
7773
- class Document$1 extends AbstractModel {
7774
- }
7775
-
7776
- /**
7777
- * Enum with document types which used to API url prefix
7778
- */
7779
- var DocumentApiUrlPrefixEnum;
7780
- (function (DocumentApiUrlPrefixEnum) {
7781
- DocumentApiUrlPrefixEnum["FOLDERS"] = "folders";
7782
- DocumentApiUrlPrefixEnum["PROPERTIES"] = "properties";
7783
- })(DocumentApiUrlPrefixEnum || (DocumentApiUrlPrefixEnum = {}));
7784
-
7785
- class Document extends Document$1 {
7786
- constructor() {
7787
- super(...arguments);
7788
- this.type = AssetTypeEnum.DOCUMENTS;
7789
- this.entityType = AssetEntityTypeEnum.FOLDERS;
7790
- }
7791
- /**
7792
- * Get folder as document parent entity
7793
- */
7794
- getEntity() {
7795
- return this.folder;
7796
- }
7797
- /**
7798
- * Get API url prefix
7799
- */
7800
- getApiUrlPrefix() {
7801
- return DocumentApiUrlPrefixEnum.FOLDERS;
7802
- }
7803
- }
7804
-
7805
7914
  const DOCUMENT_FILE_TYPES = {
7806
7915
  image: [
7807
7916
  'image/png',
@@ -7825,15 +7934,6 @@ const DOCUMENT_FILE_TYPES = {
7825
7934
  ]
7826
7935
  };
7827
7936
 
7828
- class DocumentFolder$1 extends AbstractModel {
7829
- }
7830
-
7831
- class DocumentFolder extends DocumentFolder$1 {
7832
- }
7833
- __decorate([
7834
- Type(() => Document)
7835
- ], DocumentFolder.prototype, "documents", void 0);
7836
-
7837
7937
  class EmployeeInvite$1 extends AbstractModel {
7838
7938
  }
7839
7939
 
@@ -9460,6 +9560,17 @@ class SoleInvoiceService extends RestService {
9460
9560
  this.url = 'sole-invoices';
9461
9561
  this.isHydra = true;
9462
9562
  }
9563
+ updateStatus(invoice, status) {
9564
+ // use id only to avoid unexpected changes
9565
+ return this.update(plainToClass(SoleInvoice, merge({}, { id: invoice.id }, { status })));
9566
+ }
9567
+ publish(invoice, document) {
9568
+ // use id only to avoid unexpected changes
9569
+ return this.update(merge({}, invoice, { document, status: SoleInvoiceStatusesEnum.PENDING }));
9570
+ }
9571
+ sendEmail(invoice) {
9572
+ return this.http.post(`${this.environment.apiV2}/${this.url}/${invoice.id}/send`, {});
9573
+ }
9463
9574
  }
9464
9575
  SoleInvoiceService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleInvoiceService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9465
9576
  SoleInvoiceService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleInvoiceService, providedIn: 'root' });
@@ -9798,6 +9909,90 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
9798
9909
  }]
9799
9910
  }] });
9800
9911
 
9912
+ class DocumentService extends RestService {
9913
+ constructor() {
9914
+ super(...arguments);
9915
+ this.url = 'documents';
9916
+ this.modelClass = Document;
9917
+ }
9918
+ }
9919
+ DocumentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9920
+ DocumentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentService, providedIn: 'root' });
9921
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentService, decorators: [{
9922
+ type: Injectable,
9923
+ args: [{
9924
+ providedIn: 'root'
9925
+ }]
9926
+ }] });
9927
+
9928
+ /**
9929
+ * Service to handle document-folders and depending documents logic
9930
+ */
9931
+ class DocumentFolderService extends RestService {
9932
+ constructor() {
9933
+ super(...arguments);
9934
+ this.url = 'folders';
9935
+ this.modelClass = DocumentFolder;
9936
+ }
9937
+ /**
9938
+ * Add new document to the folder
9939
+ * @param file to be uploaded to the folder
9940
+ * @param folder for document
9941
+ */
9942
+ addDocument(file, folder) {
9943
+ // create formData object with provided file
9944
+ const formDataDocument = new FormData();
9945
+ formDataDocument.append('file', file);
9946
+ return this.http.post(`${this.environment.apiV2}/folders/${folder.id}/documents`, formDataDocument).pipe(map((response) => {
9947
+ const updatedFolder = Object.assign(plainToClass(DocumentFolder, {}), folder);
9948
+ updatedFolder.documents.push(plainToClass(Document, response));
9949
+ replace(this.cache, plainToClass(DocumentFolder, updatedFolder));
9950
+ this.cacheSubject.next(this.cache);
9951
+ }));
9952
+ }
9953
+ /**
9954
+ * Edit folder document by moving it from one folder to another
9955
+ * @param editedDocument
9956
+ * @param selectedFolder to move the document to
9957
+ * @param oldFolderId: id of old folder from which need to remove the document
9958
+ */
9959
+ updateDocument(editedDocument, selectedFolder, oldFolderId) {
9960
+ return this.http.put(`${this.environment.apiV2}/folders/${selectedFolder.id}/documents/${editedDocument.id}`, editedDocument).pipe(map((response) => {
9961
+ const oldFolder = this.cache.find((folder) => folder.id === oldFolderId);
9962
+ // Remove document from old folder
9963
+ oldFolder.documents = oldFolder.documents.filter((deletedDocument) => deletedDocument.id !== response.id);
9964
+ // update old folder and replace it in cache
9965
+ response.folder = plainToClass(DocumentFolder, { id: selectedFolder.id, name: selectedFolder.name });
9966
+ replace(this.cache, plainToClass(DocumentFolder, oldFolder));
9967
+ // update new document folder and replace it in cache
9968
+ selectedFolder.documents.push(plainToClass(Document, response));
9969
+ replace(this.cache, plainToClass(DocumentFolder, selectedFolder));
9970
+ this.cacheSubject.next(this.cache);
9971
+ }));
9972
+ }
9973
+ /**
9974
+ * Delete document from folder
9975
+ * @param document to remove
9976
+ * @param folder from which document should be removed
9977
+ */
9978
+ deleteDocument(document, folder) {
9979
+ return this.http.delete(`${this.environment.apiV2}/folders/${folder.id}/documents/${document.id}`).pipe(map(() => {
9980
+ folder.documents = folder.documents
9981
+ .filter((deletedDocument) => deletedDocument.id !== document.id);
9982
+ replace(this.cache, plainToClass(DocumentFolder, folder));
9983
+ this.cacheSubject.next(this.cache);
9984
+ }));
9985
+ }
9986
+ }
9987
+ DocumentFolderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9988
+ DocumentFolderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, providedIn: 'root' });
9989
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, decorators: [{
9990
+ type: Injectable,
9991
+ args: [{
9992
+ providedIn: 'root'
9993
+ }]
9994
+ }] });
9995
+
9801
9996
  /**
9802
9997
  * Service to work with Rewardful (affiliate program) API
9803
9998
  * https://developers.rewardful.com/javascript-api/overview#executing-code-when-rewardful-loads
@@ -12124,74 +12319,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
12124
12319
  args: ['environment']
12125
12320
  }] }]; } });
12126
12321
 
12127
- /**
12128
- * Service to handle document-folders and depending documents logic
12129
- */
12130
- class DocumentFolderService extends RestService {
12131
- constructor() {
12132
- super(...arguments);
12133
- this.url = 'folders';
12134
- this.modelClass = DocumentFolder;
12135
- }
12136
- /**
12137
- * Add new document to the folder
12138
- * @param file to be uploaded to the folder
12139
- * @param folder for document
12140
- */
12141
- addDocument(file, folder) {
12142
- // create formData object with provided file
12143
- const formDataDocument = new FormData();
12144
- formDataDocument.append('file', file);
12145
- return this.http.post(`${this.environment.apiV2}/folders/${folder.id}/documents`, formDataDocument).pipe(map((response) => {
12146
- const updatedFolder = Object.assign(plainToClass(DocumentFolder, {}), folder);
12147
- updatedFolder.documents.push(plainToClass(Document, response));
12148
- replace(this.cache, plainToClass(DocumentFolder, updatedFolder));
12149
- this.cacheSubject.next(this.cache);
12150
- }));
12151
- }
12152
- /**
12153
- * Edit folder document by moving it from one folder to another
12154
- * @param editedDocument
12155
- * @param selectedFolder to move the document to
12156
- * @param oldFolderId: id of old folder from which need to remove the document
12157
- */
12158
- updateDocument(editedDocument, selectedFolder, oldFolderId) {
12159
- return this.http.put(`${this.environment.apiV2}/folders/${selectedFolder.id}/documents/${editedDocument.id}`, editedDocument).pipe(map((response) => {
12160
- const oldFolder = this.cache.find((folder) => folder.id === oldFolderId);
12161
- // Remove document from old folder
12162
- oldFolder.documents = oldFolder.documents.filter((deletedDocument) => deletedDocument.id !== response.id);
12163
- // update old folder and replace it in cache
12164
- response.folder = plainToClass(DocumentFolder, { id: selectedFolder.id, name: selectedFolder.name });
12165
- replace(this.cache, plainToClass(DocumentFolder, oldFolder));
12166
- // update new document folder and replace it in cache
12167
- selectedFolder.documents.push(plainToClass(Document, response));
12168
- replace(this.cache, plainToClass(DocumentFolder, selectedFolder));
12169
- this.cacheSubject.next(this.cache);
12170
- }));
12171
- }
12172
- /**
12173
- * Delete document from folder
12174
- * @param document to remove
12175
- * @param folder from which document should be removed
12176
- */
12177
- deleteDocument(document, folder) {
12178
- return this.http.delete(`${this.environment.apiV2}/folders/${folder.id}/documents/${document.id}`).pipe(map(() => {
12179
- folder.documents = folder.documents
12180
- .filter((deletedDocument) => deletedDocument.id !== document.id);
12181
- replace(this.cache, plainToClass(DocumentFolder, folder));
12182
- this.cacheSubject.next(this.cache);
12183
- }));
12184
- }
12185
- }
12186
- DocumentFolderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
12187
- DocumentFolderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, providedIn: 'root' });
12188
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, decorators: [{
12189
- type: Injectable,
12190
- args: [{
12191
- providedIn: 'root'
12192
- }]
12193
- }] });
12194
-
12195
12322
  class EmployeeService extends RestService {
12196
12323
  constructor() {
12197
12324
  super(...arguments);
@@ -12864,25 +12991,36 @@ const FILE_SETTINGS$1 = {
12864
12991
  };
12865
12992
 
12866
12993
  /**
12994
+ * @TODO mikhail better typehint
12995
+ *
12867
12996
  * Service to generate and export PDF file from provided HTML elements
12868
12997
  * The file is generated using the html2pdf library in order to get a canvas at the output,
12869
12998
  * in which all the styles that the user sees on the page will be saved
12870
12999
  */
12871
13000
  class PdfFromDomElementService {
12872
- export(elements, fileSettings) {
13001
+ init(elements, fileSettings) {
12873
13002
  const options = FILE_SETTINGS$1;
12874
- options.filename = `${fileSettings.filename}.pdf`;
13003
+ if (fileSettings) {
13004
+ merge(options, fileSettings);
13005
+ }
12875
13006
  // HTML container in which the exported DOM elements will be placed
12876
13007
  const htmlWrapper = document.createElement('div');
12877
13008
  elements.forEach((element) => {
12878
13009
  htmlWrapper.append(element.cloneNode(true));
12879
13010
  });
12880
13011
  // Set PDF options, save file and return result as Observable
12881
- return from(html2pdf().from(htmlWrapper)
12882
- .set(options)
13012
+ return html2pdf().from(htmlWrapper).set(options);
13013
+ }
13014
+ download(elements, fileSettings) {
13015
+ return from(this.init(elements, fileSettings)
12883
13016
  .save()
12884
13017
  .then());
12885
13018
  }
13019
+ export(elements, filename = FILE_SETTINGS$1.filename) {
13020
+ return from(this.init(elements)
13021
+ .outputPdf('blob')
13022
+ .then((blob) => new File([blob], filename, { type: 'application/pdf' })));
13023
+ }
12886
13024
  }
12887
13025
  PdfFromDomElementService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PdfFromDomElementService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
12888
13026
  PdfFromDomElementService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PdfFromDomElementService, providedIn: 'root' });
@@ -13913,6 +14051,17 @@ class TransactionCalculationService {
13913
14051
  return !this.isAllocated(transaction, allocations);
13914
14052
  }));
13915
14053
  }
14054
+ /**
14055
+ * Get invoices allocated amounts grouped bu invoice id
14056
+ */
14057
+ getAllocationsAmountsByInvoiceId(allocations, invoices) {
14058
+ const allocationsByTransactionId = allocations.groupBy('transaction.id');
14059
+ const dictionary = new Dictionary([]);
14060
+ invoices.toArray().forEach((invoice) => {
14061
+ dictionary.add(invoice.id, allocationsByTransactionId.merge(invoice.itemsCollection.mapBy('transaction.id')).amount || 0);
14062
+ });
14063
+ return dictionary;
14064
+ }
13916
14065
  }
13917
14066
  TransactionCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionCalculationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
13918
14067
  TransactionCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionCalculationService, providedIn: 'root' });
@@ -14677,51 +14826,35 @@ class SoleInvoiceItemForm extends AbstractForm {
14677
14826
  description: new FormControl(item.description, Validators.required),
14678
14827
  quantity: new FormControl(item.quantity, Validators.required),
14679
14828
  price: new FormControl(item.price, Validators.required),
14680
- isGST: new FormControl({ value: item.isGST, disabled: !((_a = item.chartAccounts) === null || _a === void 0 ? void 0 : _a.isGST) }),
14681
- chartAccounts: new FormControl(item.chartAccounts, Validators.required)
14829
+ isGST: new FormControl({ value: item.isGST || false, disabled: !((_a = item.chartAccounts) === null || _a === void 0 ? void 0 : _a.isGST) }),
14830
+ chartAccounts: new FormControl(item.chartAccounts, Validators.required),
14682
14831
  }, item);
14683
- this.listenEvents();
14684
- }
14685
- listenEvents() {
14686
- this.listenChartAccountsChanges();
14687
- }
14688
- onTemplateChanged(template) {
14689
- this.template = template;
14690
- if (this.template.isNoTax()) {
14691
- this.get('isGST').setValue(false);
14692
- this.get('isGST').disable();
14693
- }
14694
- else {
14695
- this.get('isGST').enable();
14696
- }
14697
- }
14698
- listenChartAccountsChanges() {
14699
- this.get('chartAccounts').valueChanges.subscribe((chartAccounts) => {
14700
- if (this.template.isNoTax()) {
14701
- return;
14702
- }
14703
- if (chartAccounts.isGST) {
14704
- this.get('isGST').enable();
14705
- }
14706
- else {
14707
- this.get('isGST').setValue(false);
14708
- this.get('isGST').disable();
14709
- }
14710
- });
14711
14832
  }
14712
14833
  }
14713
14834
 
14714
14835
  class SoleInvoiceForm extends AbstractForm {
14715
- constructor(invoice) {
14836
+ constructor(invoice, soleDetailsGST) {
14716
14837
  super({
14717
- dateFrom: new FormControl(invoice.dateFrom, Validators.required),
14838
+ dateFrom: new FormControl(invoice.dateFrom || new Date(), Validators.required),
14718
14839
  dateTo: new FormControl(invoice.dateTo, Validators.required),
14719
- items: new FormArray(invoice.items.map((item) => new SoleInvoiceItemForm(item))),
14840
+ items: new FormArray((invoice.items || [plainToClass(SoleInvoiceItem, {})]).map((item) => new SoleInvoiceItemForm(item))),
14720
14841
  payer: new FormControl(invoice.payer, Validators.required),
14721
- template: new FormControl(invoice.template, Validators.required)
14842
+ taxType: new FormControl(invoice.taxType, Validators.required),
14843
+ bankAccount: new FormControl(invoice.bankAccount, Validators.required)
14722
14844
  }, invoice);
14723
- if (invoice.id) {
14724
- this.updateItemsForm(invoice.template);
14845
+ this.soleDetailsGST = soleDetailsGST;
14846
+ // we need invoice template only for new invoices
14847
+ if (!invoice.id) {
14848
+ this.addControl('template', new FormControl(invoice.template));
14849
+ }
14850
+ // invoice.taxType is always NONE ('No Tax') when soleDetails.isGST === false
14851
+ if (!this.soleDetailsGST) {
14852
+ this.get('taxType').setValue(SoleInvoiceTaxTypeEnum.NO_TAX);
14853
+ this.get('taxType').disable();
14854
+ // Items isGST is not available when invoice.taxType === NONE ('No Tax')
14855
+ this.items.controls.forEach((itemForm) => {
14856
+ this.disableItemGST(itemForm);
14857
+ });
14725
14858
  }
14726
14859
  this.listenEvents();
14727
14860
  }
@@ -14729,52 +14862,112 @@ class SoleInvoiceForm extends AbstractForm {
14729
14862
  return this.get('items');
14730
14863
  }
14731
14864
  listenEvents() {
14732
- this.listenTemplateChanges();
14865
+ // no need to listen tax type and items chart accounts changes when soleDetails.isGST === false
14866
+ // because invoice tax type always 'No Tax' in this case and not available for changing
14867
+ if (this.soleDetailsGST) {
14868
+ this.listenTaxTypeChanges();
14869
+ this.items.controls.forEach((itemForm) => {
14870
+ this.listenItemChartAccountsChanges(itemForm);
14871
+ });
14872
+ }
14873
+ // nothing to listen if template field is not учшые (edit invoice case)
14874
+ if (this.contains('template')) {
14875
+ this.listenTemplateChanges();
14876
+ }
14733
14877
  }
14734
14878
  addItem() {
14735
- this.items.push(new SoleInvoiceItemForm(plainToClass(SoleInvoiceItem, {})));
14879
+ const itemForm = new SoleInvoiceItemForm(plainToClass(SoleInvoiceItem, {}));
14880
+ // no need to listen items chart accounts changes when soleDetails.isGST === false
14881
+ // because invoice tax type always 'No Tax' in this case and not available for changing
14882
+ if (this.soleDetailsGST) {
14883
+ this.listenItemChartAccountsChanges(itemForm);
14884
+ }
14885
+ this.items.push(itemForm);
14736
14886
  }
14737
14887
  removeItem(index) {
14738
- // do not remove the last item
14739
- if (this.items.length === 1) {
14740
- return;
14741
- }
14742
14888
  this.items.removeAt(index);
14743
14889
  }
14744
14890
  submit(data = {}) {
14891
+ // @TODO Alex TT-2190: move child custom forms submit to Abstract Form
14745
14892
  const items = this.items.controls.map((control) => control.submit());
14746
- return super.submit(Object.assign({}, data, { items }));
14893
+ return super.submit(merge(data, { items }));
14747
14894
  }
14895
+ /**
14896
+ * Update default values from selected invoice template
14897
+ */
14748
14898
  listenTemplateChanges() {
14749
14899
  this.get('template').valueChanges.subscribe((template) => {
14750
- this.updateItemsForm(template);
14900
+ this.get('bankAccount').setValue(template.bankAccount);
14901
+ const dateFrom = this.get('dateFrom').value;
14902
+ if (dateFrom) {
14903
+ this.get('dateTo').setValue(new Date(dateFrom.getTime() + template.termTime));
14904
+ }
14905
+ // invoice.taxType is always 'No Tax' when soleDetails.isGST = false and not available for changing
14906
+ if (this.soleDetailsGST) {
14907
+ this.get('taxType').setValue(template.taxType);
14908
+ }
14909
+ });
14910
+ }
14911
+ /**
14912
+ * GST is not available for items when invoice.taxType === NONE
14913
+ */
14914
+ listenTaxTypeChanges() {
14915
+ this.get('taxType').valueChanges.subscribe((type) => {
14916
+ this.items.controls.forEach((itemForm) => {
14917
+ const chartAccounts = itemForm.get('chartAccounts').value;
14918
+ // Item GST is available when invoice.taxType !== NONE ('No Tax')
14919
+ if (type !== SoleInvoiceTaxTypeEnum.NO_TAX && (chartAccounts === null || chartAccounts === void 0 ? void 0 : chartAccounts.isGST)) {
14920
+ this.enableItemGST(itemForm);
14921
+ return;
14922
+ }
14923
+ this.disableItemGST(itemForm);
14924
+ });
14751
14925
  });
14752
14926
  }
14753
- updateItemsForm(template) {
14754
- this.items.controls.forEach((itemForm) => {
14755
- itemForm.onTemplateChanged(template);
14927
+ /**
14928
+ * GST availability depends of chart accounts isGST flag
14929
+ */
14930
+ listenItemChartAccountsChanges(itemForm) {
14931
+ itemForm.get('chartAccounts').valueChanges.subscribe((chartAccounts) => {
14932
+ // item.isGST is available only when item.chartAccounts.isGST === true, soleDetails.isGST === true and invoice.taxType !== NONE ('No Tax')
14933
+ if (this.soleDetailsGST && chartAccounts.isGST && !this.currentValue.isNoTax()) {
14934
+ this.enableItemGST(itemForm);
14935
+ return;
14936
+ }
14937
+ this.disableItemGST(itemForm);
14756
14938
  });
14757
14939
  }
14940
+ disableItemGST(itemForm) {
14941
+ itemForm.get('isGST').setValue(false);
14942
+ itemForm.get('isGST').disable();
14943
+ }
14944
+ /**
14945
+ * Enable GST field for passed item form. Value is always true by default because only case when this field is enabled is
14946
+ * when ChartAccounts.isGST === true, so we just use default value from chartAccounts.isGST
14947
+ */
14948
+ enableItemGST(itemForm) {
14949
+ itemForm.get('isGST').setValue(true);
14950
+ itemForm.get('isGST').enable();
14951
+ }
14758
14952
  }
14759
14953
 
14760
14954
  class SoleInvoiceTemplateForm extends AbstractForm {
14761
- constructor(invoiceTemplate, soleDetails) {
14955
+ constructor(invoiceTemplate) {
14762
14956
  super({
14763
14957
  name: new FormControl(invoiceTemplate.name, Validators.required),
14764
- // taxType always 'No Tax' when sole details are not GST registered
14765
- taxType: new FormControl({ value: invoiceTemplate.taxType, disabled: !soleDetails.isGST }, Validators.required),
14958
+ // taxType is always 'No Tax' when soleDetails.isGST === false
14959
+ taxType: new FormControl(invoiceTemplate.taxType, Validators.required),
14766
14960
  term: new FormControl(invoiceTemplate.term, [Validators.required, Validators.min(0)]),
14767
14961
  bankAccount: new FormControl(invoiceTemplate.bankAccount, [Validators.required])
14768
14962
  }, invoiceTemplate);
14769
- this.soleDetails = soleDetails;
14770
14963
  }
14771
14964
  }
14772
14965
 
14773
14966
  class BankAccountAllocationForm extends AbstractForm {
14774
- constructor(bankAccount) {
14775
- super({
14967
+ constructor(bankAccount, controls) {
14968
+ super(merge(controls, {
14776
14969
  tankType: new FormControl(bankAccount ? bankAccount.tankType : null, Validators.required)
14777
- }, plainToClass(BankAccount, bankAccount || {}));
14970
+ }), plainToClass(BankAccount, bankAccount || {}));
14778
14971
  this.bankAccount = bankAccount;
14779
14972
  if (bankAccount === null || bankAccount === void 0 ? void 0 : bankAccount.isPropertyTank()) {
14780
14973
  this.addControl('bankAccountProperties', new BankAccountPropertiesForm(bankAccount.bankAccountProperties));
@@ -14827,12 +15020,16 @@ class BankAccountImportForm extends BankAccountAllocationForm {
14827
15020
  */
14828
15021
  class BankAccountAddManualForm extends BankAccountAllocationForm {
14829
15022
  constructor(connection) {
14830
- super();
15023
+ super(null, {
15024
+ type: new FormControl(null, Validators.required),
15025
+ accountName: new FormControl(null, Validators.required),
15026
+ currentBalance: new FormControl(null, Validators.required),
15027
+ accountNumber: new FormControl(null, [Validators.required, Validators.pattern(BankAccountAddManualForm.accountNumberPattern)])
15028
+ });
14831
15029
  this.connection = connection;
14832
- this.addControl('type', new FormControl(null, Validators.required));
14833
- this.addControl('accountName', new FormControl(null, Validators.required));
14834
- this.addControl('currentBalance', new FormControl(null, Validators.required));
14835
- this.addControl('accountNumber', new FormControl(null, [Validators.required, Validators.pattern(BankAccountAddManualForm.accountNumberPattern)]));
15030
+ }
15031
+ listenEvents() {
15032
+ super.listenEvents();
14836
15033
  this.listenTypeChanges();
14837
15034
  }
14838
15035
  /**
@@ -15709,5 +15906,5 @@ VehicleLogbookForm.maxDescriptionLength = 60;
15709
15906
  * Generated bundle index. Do not edit.
15710
15907
  */
15711
15908
 
15712
- export { AbstractForm, AbstractModel, AccountSetupItem, AccountSetupItemCollection, AccountSetupService, Address, AddressService, AddressTypeEnum, AlphabetColorsEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Badge, BadgeColorEnum, Bank, BankAccount, BankAccountAddManualForm, BankAccountAllocationForm, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountImportForm, BankAccountPropertiesForm, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankAccountsImportForm, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankLoginData, BankLoginForm, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqConfig, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, CgtExemptionAndRolloverCodeEnum, ChartAccounts, ChartAccountsCategoryECollection, ChartAccountsCategoryEnum, ChartAccountsCollection, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, ChartAccountsHeadingListEnum, ChartAccountsHeadingTaxDeductibleEnum, ChartAccountsHeadingTaxableEnum, ChartAccountsHeadingVehicleListEnum, ChartAccountsListEnum, ChartAccountsMetadata, ChartAccountsMetadataListEnum, ChartAccountsMetadataTypeEnum, ChartAccountsService, ChartAccountsTaxLabelsEnum, ChartAccountsTypeEnum, ChartAccountsValue, ChartData, ChartSerie, Chat, ChatService, ChatStatusEnum, ChatViewTypeEnum, ClientCollection, ClientDetails, ClientDetailsMedicareExemptionEnum, ClientDetailsWorkDepreciationCalculationEnum, ClientDetailsWorkingHolidayMakerEnum, ClientIncomeTypes, ClientIncomeTypesForm, ClientIncomeTypesService, ClientInvite, ClientInviteCollection, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, Collection, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEDUCTION_CATEGORIES, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, DeductionClothingTypeEnum, DeductionSelfEducationTypeEnum, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCapitalProjectService, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationLvpAssetTypeEnum, DepreciationLvpReportItem, DepreciationLvpReportItemCollection, DepreciationReceipt, DepreciationReceiptService, DepreciationReportItem, DepreciationReportItemCollection, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Dictionary, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EquityPositionChartService, EventDispatcherService, ExportDataTable, ExportFormatEnum, ExportFormatterService, ExportableCollection, FacebookService, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceForecastTrustTypeEnum, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSoleEnum, IncomeSourceTypeListWorkEnum, InterceptorsModule, IntercomService, InviteStatusEnum, JwtService, KompassifyService, Loan, LoanBankTypeEnum, LoanCollection, LoanForm, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPaymentCollection, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookBestPeriodService, LogbookPeriod, LoginForm, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, MyTaxBusinessOrLosses, MyTaxBusinessOrLossesForm, MyTaxCgt, MyTaxCgtForm, MyTaxDeductions, MyTaxDeductionsForm, MyTaxDividends, MyTaxDividendsForm, MyTaxEmployeeShareSchemes, MyTaxEmployeeShareSchemesForm, MyTaxEstimate, MyTaxIncomeStatements, MyTaxIncomeStatementsForm, MyTaxIncomeTests, MyTaxIncomeTestsForm, MyTaxInterest, MyTaxInterestForm, MyTaxLosses, MyTaxLossesForm, MyTaxMedicareForm, MyTaxOffsets, MyTaxOffsetsForm, MyTaxOtherIncome, MyTaxOtherIncomeForm, MyTaxPartnershipsAndTrusts, MyTaxPartnershipsAndTrustsForm, MyTaxRent, MyTaxRentForm, Notification, Occupation, OccupationService, PASSWORD_REGEXPS, PasswordForm, PdfFromDataTableService, PdfFromDomElementService, PdfFromHtmlTableService, PdfOrientationEnum, PdfSettings, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCategory, PropertyCategoryListEnum, PropertyCategoryMovement, PropertyCategoryMovementService, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertyReportItem, PropertyReportItemCollection, PropertyReportItemDepreciation, PropertyReportItemDepreciationCollection, PropertyReportItemTransaction, PropertyReportItemTransactionCollection, PropertySale, PropertySaleCollection, PropertySaleCostBase, PropertySaleCostBaseForm, PropertySaleCostSaleForm, PropertySaleExemptionsForm, PropertySaleService, PropertySaleTaxExemptionMetadata, PropertyService, PropertyShare, PropertyShareAccessEnum, PropertyShareService, PropertyShareStatusEnum, PropertySubscription, PropertyTransactionReportService, PropertyValuation, RegisterClientForm, RegisterFirmForm, RegistrationInvite, RegistrationInviteStatusEnum, ReportItem, ReportItemCollection, ReportItemDetails, ResetPasswordForm, RewardfulService, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceRecurringIntervalEnum, ServicePriceService, ServicePriceTypeEnum, ServiceProduct, ServiceProductIdEnum, ServiceProductStatusEnum, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, ShareFilterOptionsEnum, SoleBusiness, SoleBusinessActivity, SoleBusinessActivityService, SoleBusinessAllocation, SoleBusinessAllocationsForm, SoleBusinessForm, SoleBusinessLoss, SoleBusinessLossReport, SoleBusinessLossService, SoleBusinessService, SoleContact, SoleContactForm, SoleContactService, SoleDepreciationMethod, SoleDepreciationMethodEnum, SoleDepreciationMethodForm, SoleDepreciationMethodService, SoleDetails, SoleDetailsForm, SoleDetailsService, SoleForecast, SoleForecastService, SoleInvoice, SoleInvoiceCollection, SoleInvoiceForm, SoleInvoiceItem, SoleInvoiceItemForm, SoleInvoiceService, SoleInvoiceStatusesEnum, SoleInvoiceTemplate, SoleInvoiceTemplateForm, SoleInvoiceTemplateService, SoleInvoiceTemplateTaxTypeEnum, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, TAX_RETURN_CATEGORIES, TYPE_LOAN, TankTypeEnum, TaxCalculationMedicareExemptionEnum, TaxCalculationTypeEnum, TaxExemption, TaxExemptionEnum, TaxExemptionMetadata, TaxExemptionMetadataEnum, TaxExemptionService, TaxReturnCategoryListEnum, TaxReturnCategorySectionEnum, TaxReview, TaxReviewCollection, TaxReviewHistoryService, TaxReviewService, TaxReviewStatusEnum, TaxSummary, TaxSummaryListEnum, TaxSummarySection, TaxSummarySectionEnum, TaxSummaryService, TaxSummaryTaxSummaryEnum, TaxSummaryTypeEnum, TicketFeedbackEnum, TicketStatusEnum, TicketTypesEnum, Toast, ToastService, ToastTypeEnum, Transaction, TransactionAllocation, TransactionAllocationCollection, TransactionAllocationService, TransactionBase, TransactionCalculationService, TransactionCategoryEnum, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, TutorialVideoService, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserInviteForm, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, UsersInviteService, Vehicle, VehicleClaim, VehicleClaimCollection, VehicleClaimDetails, VehicleClaimDetailsForm, VehicleClaimDetailsMethodEnum, VehicleClaimDetailsService, VehicleClaimForm, VehicleClaimService, VehicleExpense, VehicleExpenseCollection, VehicleForm, VehicleLogbook, VehicleLogbookCollection, VehicleLogbookForm, VehicleLogbookPurposeEnum, VehicleLogbookService, VehicleService, XlsxService, atLeastOneCheckedValidator, atoLinks, autocompleteValidator, cloneDeep, compare, compareMatOptions, conditionalValidator, createDate, displayMatOptions, enumToList, fieldsSumValidator, getDocIcon, minDateValidator, passwordMatchValidator, passwordValidator, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
15909
+ export { AbstractForm, AbstractModel, AccountSetupItem, AccountSetupItemCollection, AccountSetupService, Address, AddressService, AddressTypeEnum, AlphabetColorsEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Badge, BadgeColorEnum, Bank, BankAccount, BankAccountAddManualForm, BankAccountAllocationForm, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountImportForm, BankAccountPropertiesForm, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankAccountsImportForm, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankLoginData, BankLoginForm, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqConfig, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, CgtExemptionAndRolloverCodeEnum, ChartAccounts, ChartAccountsCategoryECollection, ChartAccountsCategoryEnum, ChartAccountsCollection, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, ChartAccountsHeadingListEnum, ChartAccountsHeadingTaxDeductibleEnum, ChartAccountsHeadingTaxableEnum, ChartAccountsHeadingVehicleListEnum, ChartAccountsListEnum, ChartAccountsMetadata, ChartAccountsMetadataListEnum, ChartAccountsMetadataTypeEnum, ChartAccountsService, ChartAccountsTaxLabelsEnum, ChartAccountsTypeEnum, ChartAccountsValue, ChartData, ChartSerie, Chat, ChatService, ChatStatusEnum, ChatViewTypeEnum, ClientCollection, ClientDetails, ClientDetailsMedicareExemptionEnum, ClientDetailsWorkDepreciationCalculationEnum, ClientDetailsWorkingHolidayMakerEnum, ClientIncomeTypes, ClientIncomeTypesForm, ClientIncomeTypesService, ClientInvite, ClientInviteCollection, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, Collection, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEDUCTION_CATEGORIES, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, DeductionClothingTypeEnum, DeductionSelfEducationTypeEnum, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCapitalProjectService, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationLvpAssetTypeEnum, DepreciationLvpReportItem, DepreciationLvpReportItemCollection, DepreciationReceipt, DepreciationReceiptService, DepreciationReportItem, DepreciationReportItemCollection, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Dictionary, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, DocumentService, DocumentTypeEnum, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EquityPositionChartService, EventDispatcherService, ExportDataTable, ExportFormatEnum, ExportFormatterService, ExportableCollection, FacebookService, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceForecastTrustTypeEnum, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSoleEnum, IncomeSourceTypeListWorkEnum, InterceptorsModule, IntercomService, InviteStatusEnum, JwtService, KompassifyService, Loan, LoanBankTypeEnum, LoanCollection, LoanForm, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPaymentCollection, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookBestPeriodService, LogbookPeriod, LoginForm, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, MyTaxBusinessOrLosses, MyTaxBusinessOrLossesForm, MyTaxCgt, MyTaxCgtForm, MyTaxDeductions, MyTaxDeductionsForm, MyTaxDividends, MyTaxDividendsForm, MyTaxEmployeeShareSchemes, MyTaxEmployeeShareSchemesForm, MyTaxEstimate, MyTaxIncomeStatements, MyTaxIncomeStatementsForm, MyTaxIncomeTests, MyTaxIncomeTestsForm, MyTaxInterest, MyTaxInterestForm, MyTaxLosses, MyTaxLossesForm, MyTaxMedicareForm, MyTaxOffsets, MyTaxOffsetsForm, MyTaxOtherIncome, MyTaxOtherIncomeForm, MyTaxPartnershipsAndTrusts, MyTaxPartnershipsAndTrustsForm, MyTaxRent, MyTaxRentForm, Notification, Occupation, OccupationService, PASSWORD_REGEXPS, PasswordForm, PdfFromDataTableService, PdfFromDomElementService, PdfFromHtmlTableService, PdfOrientationEnum, PdfSettings, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCategory, PropertyCategoryListEnum, PropertyCategoryMovement, PropertyCategoryMovementService, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertyReportItem, PropertyReportItemCollection, PropertyReportItemDepreciation, PropertyReportItemDepreciationCollection, PropertyReportItemTransaction, PropertyReportItemTransactionCollection, PropertySale, PropertySaleCollection, PropertySaleCostBase, PropertySaleCostBaseForm, PropertySaleCostSaleForm, PropertySaleExemptionsForm, PropertySaleService, PropertySaleTaxExemptionMetadata, PropertyService, PropertyShare, PropertyShareAccessEnum, PropertyShareService, PropertyShareStatusEnum, PropertySubscription, PropertyTransactionReportService, PropertyValuation, RegisterClientForm, RegisterFirmForm, RegistrationInvite, RegistrationInviteStatusEnum, ReportItem, ReportItemCollection, ReportItemDetails, ResetPasswordForm, RewardfulService, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceRecurringIntervalEnum, ServicePriceService, ServicePriceTypeEnum, ServiceProduct, ServiceProductIdEnum, ServiceProductStatusEnum, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, ShareFilterOptionsEnum, SoleBusiness, SoleBusinessActivity, SoleBusinessActivityService, SoleBusinessAllocation, SoleBusinessAllocationsForm, SoleBusinessForm, SoleBusinessLoss, SoleBusinessLossReport, SoleBusinessLossService, SoleBusinessService, SoleContact, SoleContactForm, SoleContactService, SoleDepreciationMethod, SoleDepreciationMethodEnum, SoleDepreciationMethodForm, SoleDepreciationMethodService, SoleDetails, SoleDetailsForm, SoleDetailsService, SoleForecast, SoleForecastService, SoleInvoice, SoleInvoiceCollection, SoleInvoiceForm, SoleInvoiceItem, SoleInvoiceItemForm, SoleInvoiceService, SoleInvoiceStatusesEnum, SoleInvoiceTaxTypeEnum, SoleInvoiceTemplate, SoleInvoiceTemplateForm, SoleInvoiceTemplateService, SoleInvoiceTemplateTaxTypeEnum, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, TAX_RETURN_CATEGORIES, TYPE_LOAN, TankTypeEnum, TaxCalculationMedicareExemptionEnum, TaxCalculationTypeEnum, TaxExemption, TaxExemptionEnum, TaxExemptionMetadata, TaxExemptionMetadataEnum, TaxExemptionService, TaxReturnCategoryListEnum, TaxReturnCategorySectionEnum, TaxReview, TaxReviewCollection, TaxReviewHistoryService, TaxReviewService, TaxReviewStatusEnum, TaxSummary, TaxSummaryListEnum, TaxSummarySection, TaxSummarySectionEnum, TaxSummaryService, TaxSummaryTaxSummaryEnum, TaxSummaryTypeEnum, TicketFeedbackEnum, TicketStatusEnum, TicketTypesEnum, Toast, ToastService, ToastTypeEnum, Transaction, TransactionAllocation, TransactionAllocationCollection, TransactionAllocationService, TransactionBase, TransactionCalculationService, TransactionCategoryEnum, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, TutorialVideoService, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserInviteForm, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, UsersInviteService, Vehicle, VehicleClaim, VehicleClaimCollection, VehicleClaimDetails, VehicleClaimDetailsForm, VehicleClaimDetailsMethodEnum, VehicleClaimDetailsService, VehicleClaimForm, VehicleClaimService, VehicleExpense, VehicleExpenseCollection, VehicleForm, VehicleLogbook, VehicleLogbookCollection, VehicleLogbookForm, VehicleLogbookPurposeEnum, VehicleLogbookService, VehicleService, XlsxService, atLeastOneCheckedValidator, atoLinks, autocompleteValidator, cloneDeep, compare, compareMatOptions, conditionalValidator, createDate, displayMatOptions, enumToList, fieldsSumValidator, getDocIcon, minDateValidator, passwordMatchValidator, passwordValidator, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
15713
15910
  //# sourceMappingURL=taxtank-core.js.map