taxtank-core 0.28.12 → 0.28.15

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 (62) hide show
  1. package/bundles/taxtank-core.umd.js +1488 -1251
  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/chart-accounts-list.enum.js +3 -1
  6. package/esm2015/lib/db/Enums/document-type.enum.js +5 -0
  7. package/esm2015/lib/db/Enums/index.js +3 -0
  8. package/esm2015/lib/db/Enums/sole-invoice-tax-type.enum.js +7 -0
  9. package/esm2015/lib/db/Enums/sole-invoice-template-tax-type.enum.js +4 -4
  10. package/esm2015/lib/db/Models/sole/sole-invoice-item.js +1 -1
  11. package/esm2015/lib/db/Models/sole/sole-invoice.js +1 -1
  12. package/esm2015/lib/forms/bank/bank-account/bank-account-add-manual.form.js +10 -6
  13. package/esm2015/lib/forms/bank/bank-account/bank-account-allocation.form.js +5 -4
  14. package/esm2015/lib/forms/sole/sole-invoice-item.form.js +3 -31
  15. package/esm2015/lib/forms/sole/sole-invoice-template.form.js +6 -6
  16. package/esm2015/lib/forms/sole/sole-invoice.form.js +93 -18
  17. package/esm2015/lib/models/dictionary/dictionary.js +2 -2
  18. package/esm2015/lib/models/document/index.js +3 -0
  19. package/esm2015/lib/models/index.js +2 -1
  20. package/esm2015/lib/models/sole/sole-details.js +1 -3
  21. package/esm2015/lib/models/sole/sole-invoice-item.js +10 -2
  22. package/esm2015/lib/models/sole/sole-invoice-template.js +13 -10
  23. package/esm2015/lib/models/sole/sole-invoice.js +82 -28
  24. package/esm2015/lib/services/http/document/document-folder/document-folder.service.js +1 -1
  25. package/esm2015/lib/services/http/document/document.service.js +20 -0
  26. package/esm2015/lib/services/http/document/index.js +3 -0
  27. package/esm2015/lib/services/http/index.js +2 -1
  28. package/esm2015/lib/services/http/rest/rest.service.js +23 -7
  29. package/esm2015/lib/services/http/sole/sole-invoice/sole-invoice.service.js +15 -1
  30. package/esm2015/lib/services/pdf/pdf-from-dom-element/pdf-from-dom-element.service.js +17 -5
  31. package/esm2015/lib/services/transaction/transaction-calculation.service.js +13 -1
  32. package/esm2015/public-api.js +3 -2
  33. package/fesm2015/taxtank-core.js +1153 -953
  34. package/fesm2015/taxtank-core.js.map +1 -1
  35. package/lib/collections/sole/sole-invoice-item.collection.d.ts +5 -0
  36. package/lib/db/Enums/chart-accounts-list.enum.d.ts +3 -1
  37. package/lib/db/Enums/document-type.enum.d.ts +3 -0
  38. package/lib/db/Enums/index.d.ts +1 -0
  39. package/lib/db/Enums/sole-invoice-tax-type.enum.d.ts +5 -0
  40. package/lib/db/Enums/sole-invoice-template-tax-type.enum.d.ts +3 -3
  41. package/lib/db/Models/sole/sole-invoice-item.d.ts +3 -1
  42. package/lib/db/Models/sole/sole-invoice.d.ts +8 -5
  43. package/lib/forms/bank/bank-account/bank-account-add-manual.form.d.ts +3 -1
  44. package/lib/forms/bank/bank-account/bank-account-allocation.form.d.ts +4 -1
  45. package/lib/forms/sole/sole-invoice-item.form.d.ts +2 -7
  46. package/lib/forms/sole/sole-invoice-template.form.d.ts +2 -3
  47. package/lib/forms/sole/sole-invoice.form.d.ts +19 -2
  48. package/lib/models/document/index.d.ts +2 -0
  49. package/lib/models/index.d.ts +1 -0
  50. package/lib/models/sole/sole-details.d.ts +0 -2
  51. package/lib/models/sole/sole-invoice-item.d.ts +7 -1
  52. package/lib/models/sole/sole-invoice-template.d.ts +10 -3
  53. package/lib/models/sole/sole-invoice.d.ts +49 -5
  54. package/lib/services/http/document/document.service.d.ts +10 -0
  55. package/lib/services/http/document/index.d.ts +2 -0
  56. package/lib/services/http/index.d.ts +1 -0
  57. package/lib/services/http/rest/rest.service.d.ts +13 -4
  58. package/lib/services/http/sole/sole-invoice/sole-invoice.service.d.ts +6 -1
  59. package/lib/services/pdf/pdf-from-dom-element/pdf-from-dom-element.service.d.ts +5 -1
  60. package/lib/services/transaction/transaction-calculation.service.d.ts +6 -0
  61. package/package.json +1 -1
  62. 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
@@ -2087,6 +2107,8 @@ var ChartAccountsListEnum;
2087
2107
  ChartAccountsListEnum[ChartAccountsListEnum["ASSESSABLE_AMOUNT_CAPPED_DEFINED_BENEFIT"] = 639] = "ASSESSABLE_AMOUNT_CAPPED_DEFINED_BENEFIT";
2088
2108
  ChartAccountsListEnum[ChartAccountsListEnum["CODE_B_SUPERANNUATION_INCOME_STREAMS_DISABILITY"] = 558] = "CODE_B_SUPERANNUATION_INCOME_STREAMS_DISABILITY";
2089
2109
  ChartAccountsListEnum[ChartAccountsListEnum["CODE_A_SUPERANNUATION_INCOME_STREAMS_DEATH"] = 640] = "CODE_A_SUPERANNUATION_INCOME_STREAMS_DEATH";
2110
+ ChartAccountsListEnum[ChartAccountsListEnum["PERSONAL_EXPENSES"] = 628] = "PERSONAL_EXPENSES";
2111
+ ChartAccountsListEnum[ChartAccountsListEnum["PERSONAL_INCOME"] = 630] = "PERSONAL_INCOME";
2090
2112
  })(ChartAccountsListEnum || (ChartAccountsListEnum = {}));
2091
2113
 
2092
2114
  var ChartAccountsCategoryEnum;
@@ -2362,455 +2384,321 @@ __decorate([
2362
2384
  Type(() => ChartAccountsMetadata)
2363
2385
  ], ChartAccounts.prototype, "metadata", void 0);
2364
2386
 
2365
- class SoleInvoiceItem extends SoleInvoiceItem$1 {
2366
- constructor() {
2367
- super(...arguments);
2368
- this.isGST = false;
2387
+ class TransactionBase extends AbstractModel {
2388
+ get tankType() {
2389
+ switch (true) {
2390
+ case this.isPropertyTank():
2391
+ return TankTypeEnum.PROPERTY;
2392
+ case this.isWorkTank():
2393
+ return TankTypeEnum.WORK;
2394
+ case this.isSoleTank():
2395
+ return TankTypeEnum.SOLE;
2396
+ default:
2397
+ return TankTypeEnum.OTHER;
2398
+ }
2369
2399
  }
2370
- get amount() {
2371
- return this.price * this.quantity;
2400
+ /**
2401
+ * Check if current tank is Property
2402
+ */
2403
+ isPropertyTank() {
2404
+ // chart accounts may be empty for new instances
2405
+ if (this.chartAccounts) {
2406
+ return CHART_ACCOUNTS_CATEGORIES.property.includes(this.chartAccounts.category);
2407
+ }
2408
+ return !!this.property;
2409
+ }
2410
+ /**
2411
+ * Check if current tank is Work
2412
+ */
2413
+ isWorkTank() {
2414
+ var _a;
2415
+ // chart accounts may be empty for new instances
2416
+ if (this.chartAccounts) {
2417
+ return CHART_ACCOUNTS_CATEGORIES.work.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2418
+ }
2419
+ return !this.isPropertyTank() && !this.isSoleTank();
2420
+ }
2421
+ /**
2422
+ * Check if current tank is Sole
2423
+ */
2424
+ isSoleTank() {
2425
+ var _a;
2426
+ // chart accounts may be empty for new instances
2427
+ if (this.chartAccounts) {
2428
+ return CHART_ACCOUNTS_CATEGORIES.sole.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2429
+ }
2430
+ return !!this.business;
2372
2431
  }
2373
2432
  }
2374
2433
  __decorate([
2375
- Type(() => SoleInvoice)
2376
- ], SoleInvoiceItem.prototype, "invoice", void 0);
2377
- __decorate([
2378
- Type(() => ChartAccounts)
2379
- ], SoleInvoiceItem.prototype, "chartAccounts", void 0);
2434
+ Exclude({ toPlainOnly: true }),
2435
+ Type(() => Object),
2436
+ Transform(({ obj }) => {
2437
+ return obj.file;
2438
+ })
2439
+ ], TransactionBase.prototype, "file", void 0);
2380
2440
 
2381
- class SoleContact$1 extends AbstractModel {
2441
+ class Transaction$1 extends TransactionBase {
2382
2442
  }
2383
2443
 
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);
2444
+ var TransactionTypeEnum;
2445
+ (function (TransactionTypeEnum) {
2446
+ TransactionTypeEnum[TransactionTypeEnum["DEBIT"] = 1] = "DEBIT";
2447
+ TransactionTypeEnum[TransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
2448
+ })(TransactionTypeEnum || (TransactionTypeEnum = {}));
2409
2449
 
2410
- class SoleInvoiceTemplate$1 extends AbstractModel {
2450
+ var TransactionOperationEnum;
2451
+ (function (TransactionOperationEnum) {
2452
+ TransactionOperationEnum[TransactionOperationEnum["ALLOCATE"] = 1] = "ALLOCATE";
2453
+ TransactionOperationEnum[TransactionOperationEnum["FIND_AND_MATCH"] = 2] = "FIND_AND_MATCH";
2454
+ TransactionOperationEnum[TransactionOperationEnum["TRANSFER"] = 3] = "TRANSFER";
2455
+ })(TransactionOperationEnum || (TransactionOperationEnum = {}));
2456
+
2457
+ var TransactionSourceEnum;
2458
+ (function (TransactionSourceEnum) {
2459
+ TransactionSourceEnum[TransactionSourceEnum["CASH"] = 1] = "CASH";
2460
+ TransactionSourceEnum[TransactionSourceEnum["BANK_TRANSACTION"] = 2] = "BANK_TRANSACTION";
2461
+ })(TransactionSourceEnum || (TransactionSourceEnum = {}));
2462
+
2463
+ var DepreciationTypeEnum;
2464
+ (function (DepreciationTypeEnum) {
2465
+ DepreciationTypeEnum[DepreciationTypeEnum["PLANT_EQUIPMENT"] = 1] = "PLANT_EQUIPMENT";
2466
+ DepreciationTypeEnum[DepreciationTypeEnum["CAPITAL_WORKS"] = 2] = "CAPITAL_WORKS";
2467
+ DepreciationTypeEnum[DepreciationTypeEnum["BULK_DEPRECIATION"] = 3] = "BULK_DEPRECIATION";
2468
+ DepreciationTypeEnum[DepreciationTypeEnum["BORROWING_EXPENSES"] = 4] = "BORROWING_EXPENSES";
2469
+ })(DepreciationTypeEnum || (DepreciationTypeEnum = {}));
2470
+
2471
+ var DepreciationCalculationEnum;
2472
+ (function (DepreciationCalculationEnum) {
2473
+ DepreciationCalculationEnum[DepreciationCalculationEnum["PRIME_COST"] = 1] = "PRIME_COST";
2474
+ DepreciationCalculationEnum[DepreciationCalculationEnum["DIMINISHING"] = 2] = "DIMINISHING";
2475
+ DepreciationCalculationEnum[DepreciationCalculationEnum["CAPITAL"] = 3] = "CAPITAL";
2476
+ DepreciationCalculationEnum[DepreciationCalculationEnum["LVP"] = 4] = "LVP";
2477
+ DepreciationCalculationEnum[DepreciationCalculationEnum["AMORTISATION"] = 5] = "AMORTISATION";
2478
+ DepreciationCalculationEnum[DepreciationCalculationEnum["SBP"] = 6] = "SBP";
2479
+ })(DepreciationCalculationEnum || (DepreciationCalculationEnum = {}));
2480
+
2481
+ class TransactionReceipt$1 extends AbstractModel {
2411
2482
  }
2412
2483
 
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 = {}));
2484
+ // @TODO this enum should come from backend
2485
+ /**
2486
+ * Enum with asset types
2487
+ */
2488
+ var AssetTypeEnum;
2489
+ (function (AssetTypeEnum) {
2490
+ AssetTypeEnum["RECEIPTS"] = "receipts";
2491
+ AssetTypeEnum["DOCUMENTS"] = "documents";
2492
+ AssetTypeEnum["MESSAGE"] = "message";
2493
+ })(AssetTypeEnum || (AssetTypeEnum = {}));
2419
2494
 
2420
- class SoleInvoiceTemplate extends SoleInvoiceTemplate$1 {
2495
+ /**
2496
+ * Enum with asset entity types
2497
+ */
2498
+ var AssetEntityTypeEnum;
2499
+ (function (AssetEntityTypeEnum) {
2500
+ AssetEntityTypeEnum["PROPERTIES"] = "properties";
2501
+ AssetEntityTypeEnum["FOLDERS"] = "folders";
2502
+ AssetEntityTypeEnum["DEPRECIATIONS"] = "depreciations";
2503
+ AssetEntityTypeEnum["TRANSACTIONS"] = "transactions";
2504
+ AssetEntityTypeEnum["MESSAGES"] = "messages";
2505
+ })(AssetEntityTypeEnum || (AssetEntityTypeEnum = {}));
2506
+
2507
+ class TransactionReceipt extends TransactionReceipt$1 {
2421
2508
  constructor() {
2422
2509
  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;
2510
+ this.type = AssetTypeEnum.RECEIPTS;
2511
+ this.entityType = AssetEntityTypeEnum.TRANSACTIONS;
2433
2512
  }
2434
2513
  }
2435
- __decorate([
2436
- Type(() => SoleBusiness)
2437
- ], SoleInvoiceTemplate.prototype, "business", void 0);
2438
- __decorate([
2439
- Type(() => BankAccount)
2440
- ], SoleInvoiceTemplate.prototype, "bankAccount", void 0);
2441
2514
 
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 = {}));
2515
+ class IncomeSource$1 extends AbstractModel {
2516
+ }
2449
2517
 
2450
- class SoleDetails$1 extends AbstractModel {
2518
+ var IncomeSourceTypeEnum;
2519
+ (function (IncomeSourceTypeEnum) {
2520
+ IncomeSourceTypeEnum[IncomeSourceTypeEnum["WORK"] = 1] = "WORK";
2521
+ IncomeSourceTypeEnum[IncomeSourceTypeEnum["SOLE"] = 2] = "SOLE";
2522
+ IncomeSourceTypeEnum[IncomeSourceTypeEnum["OTHER"] = 3] = "OTHER";
2523
+ })(IncomeSourceTypeEnum || (IncomeSourceTypeEnum = {}));
2524
+
2525
+ class SalaryForecast$1 extends AbstractModel {
2451
2526
  }
2452
2527
 
2453
- class SoleDetails extends SoleDetails$1 {
2528
+ class SalaryForecast extends SalaryForecast$1 {
2454
2529
  }
2455
- SoleDetails.GSTPercentMultiplier = 0.1;
2456
- SoleDetails.GSTPercentDivider = 11;
2457
2530
  __decorate([
2458
- Type(() => User)
2459
- ], SoleDetails.prototype, "user", void 0);
2531
+ Transform(({ obj }) => obj.netPay + obj.tax),
2532
+ Expose()
2533
+ ], SalaryForecast.prototype, "grossAmount", void 0);
2534
+ __decorate([
2535
+ Type(() => IncomeSource)
2536
+ ], SalaryForecast.prototype, "incomeSource", void 0);
2460
2537
 
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
- }
2538
+ class SoleForecast$1 extends AbstractModel {
2539
+ }
2540
+
2541
+ class SoleForecast extends SoleForecast$1 {
2542
+ get netPay() {
2499
2543
  return this.amount;
2500
2544
  }
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
- }
2545
+ ;
2519
2546
  }
2520
2547
  __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);
2548
+ Type(() => IncomeSource)
2549
+ ], SoleForecast.prototype, "incomeSource", void 0);
2541
2550
 
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
- }
2551
+ class IncomeSourceForecast$1 extends AbstractModel {
2555
2552
  }
2556
- __decorate([
2557
- Type(() => Date)
2558
- ], LogbookPeriod.prototype, "from", void 0);
2559
- __decorate([
2560
- Type(() => Date)
2561
- ], LogbookPeriod.prototype, "to", void 0);
2562
2553
 
2563
- class Vehicle$1 extends AbstractModel {
2564
- }
2554
+ var SalaryForecastFrequencyEnum;
2555
+ (function (SalaryForecastFrequencyEnum) {
2556
+ SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["ANNUAL"] = 1] = "ANNUAL";
2557
+ SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["MONTHLY"] = 12] = "MONTHLY";
2558
+ SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["FORTNIGHTLY"] = 26] = "FORTNIGHTLY";
2559
+ SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["WEEKLY"] = 52] = "WEEKLY";
2560
+ })(SalaryForecastFrequencyEnum || (SalaryForecastFrequencyEnum = {}));
2565
2561
 
2566
- class VehicleLogbook$1 extends AbstractModel {
2562
+ class IncomeSourceType$1 extends AbstractModel {
2567
2563
  }
2568
2564
 
2569
- const moment = extendMoment(moment$1);
2570
- class VehicleLogbook extends VehicleLogbook$1 {
2571
- get kilometers() {
2572
- return this.odometerEnd - this.odometerStart;
2565
+ var IncomeSourceTypeListWorkEnum;
2566
+ (function (IncomeSourceTypeListWorkEnum) {
2567
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["BONUSES"] = 1] = "BONUSES";
2568
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIRECTOR_FEES"] = 2] = "DIRECTOR_FEES";
2569
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIVIDENDS"] = 3] = "DIVIDENDS";
2570
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["INTEREST"] = 4] = "INTEREST";
2571
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["PENSIONS_AND_ALLOWANCES"] = 5] = "PENSIONS_AND_ALLOWANCES";
2572
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["SUPERANNUATION"] = 8] = "SUPERANNUATION";
2573
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["ATTRIBUTED_P_S_I"] = 11] = "ATTRIBUTED_P_S_I";
2574
+ })(IncomeSourceTypeListWorkEnum || (IncomeSourceTypeListWorkEnum = {}));
2575
+
2576
+ var IncomeSourceTypeListOtherEnum;
2577
+ (function (IncomeSourceTypeListOtherEnum) {
2578
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PSI"] = 6] = "PSI";
2579
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
2580
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["TRUSTS"] = 9] = "TRUSTS";
2581
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["OTHER_INCOME"] = 10] = "OTHER_INCOME";
2582
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PARTNERSHIPS"] = 12] = "PARTNERSHIPS";
2583
+ })(IncomeSourceTypeListOtherEnum || (IncomeSourceTypeListOtherEnum = {}));
2584
+
2585
+ var IncomeSourceTypeListSoleEnum;
2586
+ (function (IncomeSourceTypeListSoleEnum) {
2587
+ IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
2588
+ })(IncomeSourceTypeListSoleEnum || (IncomeSourceTypeListSoleEnum = {}));
2589
+
2590
+ class IncomeSourceType extends IncomeSourceType$1 {
2591
+ isBonuses() {
2592
+ return this.id === IncomeSourceTypeListWorkEnum.BONUSES;
2573
2593
  }
2574
- get tankType() {
2575
- return this.isSoleTank() ? TankTypeEnum.SOLE : TankTypeEnum.WORK;
2594
+ isWork() {
2595
+ return !!IncomeSourceTypeListWorkEnum[this.id];
2576
2596
  }
2577
- isWorkTank() {
2578
- return !this.business;
2597
+ isOther() {
2598
+ return !!IncomeSourceTypeListOtherEnum[this.id];
2579
2599
  }
2580
- isSoleTank() {
2581
- return !!this.business;
2600
+ isSole() {
2601
+ return !!IncomeSourceTypeListSoleEnum[this.id];
2582
2602
  }
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);
2603
+ get type() {
2604
+ switch (true) {
2605
+ case this.isWork():
2606
+ return IncomeSourceTypeEnum.WORK;
2607
+ case this.isSole():
2608
+ return IncomeSourceTypeEnum.SOLE;
2609
+ default:
2610
+ return IncomeSourceTypeEnum.OTHER;
2611
+ }
2588
2612
  }
2589
2613
  }
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
2614
 
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 {
2615
+ class IncomeSourceForecast extends IncomeSourceForecast$1 {
2621
2616
  constructor() {
2622
2617
  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;
2618
+ this.paygIncome = 0;
2619
+ this.frequency = SalaryForecastFrequencyEnum.ANNUAL;
2620
+ this.isTaxFree = false;
2629
2621
  }
2630
- isLogbookMethod() {
2631
- return this.method === VehicleClaimDetailsMethodEnum.LOGBOOK;
2622
+ /**
2623
+ * Sometimes Income source has Salary & Income source forecasts,
2624
+ * and we need these fields to work with Income source forecasts like with Salary Forecasts
2625
+ */
2626
+ get netPay() {
2627
+ return this.amount;
2632
2628
  }
2633
- isKmsMethod() {
2634
- return this.method === VehicleClaimDetailsMethodEnum.KMS;
2629
+ get grossAmount() {
2630
+ return this.amount + this.tax + this.taxInstalments + this.frankingCredits;
2635
2631
  }
2636
2632
  }
2637
2633
  __decorate([
2638
- Type(() => User)
2639
- ], VehicleClaimDetails.prototype, "user", void 0);
2634
+ Type(() => IncomeSourceType)
2635
+ ], IncomeSourceForecast.prototype, "incomeSourceType", void 0);
2636
+ __decorate([
2637
+ Type(() => IncomeSource)
2638
+ ], IncomeSourceForecast.prototype, "incomeSource", void 0);
2640
2639
 
2641
- class VehicleClaim extends VehicleClaim$1 {
2642
- constructor() {
2643
- super(...arguments);
2644
- this.kilometers = 0;
2645
- this.workUsage = 0;
2640
+ class IncomeSource extends IncomeSource$1 {
2641
+ isSalaryIncome() {
2642
+ return !!this.salaryForecasts.length;
2643
+ // @TODO Vik: old code
2644
+ // return this.type === IncomeSourceTypeEnum.SALARY;
2646
2645
  }
2647
- isWorkTank() {
2648
- return !this.business;
2646
+ isSoleIncome() {
2647
+ return !!this.soleForecasts.length;
2649
2648
  }
2650
- isSoleTank() {
2651
- return !!this.business;
2649
+ isWorkIncome() {
2650
+ return this.type === IncomeSourceTypeEnum.WORK;
2652
2651
  }
2653
- get tankType() {
2654
- return this.isSoleTank() ? TankTypeEnum.SOLE : TankTypeEnum.WORK;
2652
+ isOtherIncome() {
2653
+ return this.type === IncomeSourceTypeEnum.OTHER || (!this.isSoleIncome() && !this.isSalaryIncome());
2655
2654
  }
2656
2655
  /**
2657
- * Claim amount for KMs method. Exists only for KMs method.
2656
+ * Get salary and other income forecasts
2658
2657
  */
2659
- getKMSClaimAmount(vehicleClaimRate) {
2660
- return +(this.kilometers * vehicleClaimRate).toFixed(2);
2658
+ get forecasts() {
2659
+ return [...this.salaryForecasts, ...this.incomeSourceForecasts, ...this.soleForecasts];
2661
2660
  }
2662
2661
  /**
2663
- * Get logbook claim amount. Exists only for logbook method.
2664
- * ClaimAmount = WorkUsage * transaction/depreciation amount
2662
+ * Get actual (1st from the list) forecast
2665
2663
  */
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;
2664
+ get actualForecast() {
2665
+ return this.forecasts[0];
2676
2666
  }
2677
- static getKMSChartAccountsIdByTankType(tankType) {
2678
- return tankType === TankTypeEnum.WORK
2679
- ? ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK
2680
- : ChartAccountsListEnum.KLMS_TRAVELLED;
2667
+ /**
2668
+ * Check if user was working in month taken by the index
2669
+ * @param monthIndex by which month should be taken
2670
+ */
2671
+ isWorkedInMonth(monthIndex) {
2672
+ const monthDate = new FinancialYear().getMonthDate(monthIndex);
2673
+ return (!this.dateFrom || monthDate >= this.dateFrom) && (!this.dateTo || monthDate < this.dateTo);
2681
2674
  }
2682
2675
  }
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
2676
  __decorate([
2692
- Type(() => VehicleClaimDetails)
2693
- ], VehicleClaim.prototype, "details", void 0);
2677
+ Type(() => SalaryForecast)
2678
+ ], IncomeSource.prototype, "salaryForecasts", void 0);
2694
2679
  __decorate([
2695
- Type(() => SoleBusiness)
2696
- ], VehicleClaim.prototype, "business", void 0);
2680
+ Type(() => SoleForecast)
2681
+ ], IncomeSource.prototype, "soleForecasts", void 0);
2682
+ __decorate([
2683
+ Type(() => IncomeSourceForecast)
2684
+ ], IncomeSource.prototype, "incomeSourceForecasts", void 0);
2685
+ __decorate([
2686
+ Type(() => Date)
2687
+ ], IncomeSource.prototype, "dateFrom", void 0);
2688
+ __decorate([
2689
+ Type(() => Date)
2690
+ ], IncomeSource.prototype, "dateTo", void 0);
2697
2691
 
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 {
2692
+ class TransactionMetadata$1 extends AbstractModel {
2774
2693
  }
2775
2694
 
2776
- class DepreciationCapitalProject extends DepreciationCapitalProject$1 {
2695
+ class TransactionMetadata extends TransactionMetadata$1 {
2777
2696
  }
2778
2697
  __decorate([
2779
- Type(() => Date)
2780
- ], DepreciationCapitalProject.prototype, "effectiveDate", void 0);
2781
-
2782
- class DepreciationForecast$1 extends AbstractModel {
2783
- }
2698
+ Type(() => ChartAccountsMetadata)
2699
+ ], TransactionMetadata.prototype, "metadata", void 0);
2784
2700
 
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
- }
2701
+ class TransactionAllocation$1 extends AbstractModel {
2814
2702
  }
2815
2703
 
2816
2704
  class BankTransaction$1 extends AbstractModel {
@@ -2822,275 +2710,296 @@ var BankTransactionTypeEnum;
2822
2710
  BankTransactionTypeEnum[BankTransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
2823
2711
  })(BankTransactionTypeEnum || (BankTransactionTypeEnum = {}));
2824
2712
 
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 {
2713
+ class BankTransaction extends BankTransaction$1 {
2874
2714
  constructor() {
2875
2715
  super(...arguments);
2876
- this.type = AssetTypeEnum.RECEIPTS;
2877
- this.entityType = AssetEntityTypeEnum.TRANSACTIONS;
2716
+ // allocated money amount for bank transaction
2717
+ this.allocatedAmount = 0;
2718
+ this.unallocatedAmount = 0;
2719
+ }
2720
+ /**
2721
+ * get allocated amount value but with +/- sign
2722
+ */
2723
+ get balanceAmount() {
2724
+ return this.isCredit() ? this.allocatedAmount : -this.allocatedAmount;
2725
+ }
2726
+ /**
2727
+ * check if bank transaction is debit
2728
+ */
2729
+ isDebit() {
2730
+ return this.type === BankTransactionTypeEnum.DEBIT;
2731
+ }
2732
+ /**
2733
+ * check if bank transaction is credit
2734
+ */
2735
+ isCredit() {
2736
+ return this.type === BankTransactionTypeEnum.CREDIT;
2737
+ }
2738
+ /**
2739
+ * Create Transaction instance based on Bank Transaction
2740
+ */
2741
+ toTransaction() {
2742
+ return plainToClass(Transaction, {
2743
+ amount: +this.amount.toFixed(2),
2744
+ description: this.description,
2745
+ date: this.date,
2746
+ source: TransactionSourceEnum.BANK_TRANSACTION,
2747
+ operation: this.operation,
2748
+ type: this.type,
2749
+ });
2750
+ }
2751
+ /**
2752
+ * Check if bank transaction is completely allocated
2753
+ */
2754
+ isAllocated(allocations) {
2755
+ return this.amount === this.getAllocatedAmount(allocations);
2756
+ }
2757
+ /**
2758
+ * Get bank transaction allocated amount
2759
+ */
2760
+ getAllocatedAmount(allocations) {
2761
+ return allocations.getByBankTransactionsIds([this.id]).amount;
2762
+ }
2763
+ /**
2764
+ * Get bank transaction unallocated amount
2765
+ */
2766
+ getUnallocatedAmount(allocations) {
2767
+ return this.amount - this.getAllocatedAmount(allocations);
2878
2768
  }
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
2769
  }
2896
2770
  __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
- }
2771
+ Type(() => Date)
2772
+ ], BankTransaction.prototype, "date", void 0);
2906
2773
 
2907
- class SoleForecast extends SoleForecast$1 {
2908
- get netPay() {
2909
- return this.amount;
2774
+ class TransactionAllocation extends TransactionAllocation$1 {
2775
+ /**
2776
+ * Create a new instance of transaction allocation
2777
+ * transaction could be empty since we can POST allocation inside a new transaction
2778
+ */
2779
+ static create(amount, bankTransaction, transaction) {
2780
+ return plainToClass(TransactionAllocation, { amount, transaction, bankTransaction });
2910
2781
  }
2911
- ;
2912
2782
  }
2913
2783
  __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 = {}));
2784
+ Type(() => BankTransaction)
2785
+ ], TransactionAllocation.prototype, "bankTransaction", void 0);
2786
+ __decorate([
2787
+ Type(() => Transaction)
2788
+ ], TransactionAllocation.prototype, "transaction", void 0);
2927
2789
 
2928
- class IncomeSourceType$1 extends AbstractModel {
2929
- }
2790
+ /**
2791
+ * Enum with income amount types (Net or Gross)
2792
+ */
2793
+ var IncomeAmountTypeEnum;
2794
+ (function (IncomeAmountTypeEnum) {
2795
+ IncomeAmountTypeEnum[IncomeAmountTypeEnum["NET"] = 0] = "NET";
2796
+ IncomeAmountTypeEnum[IncomeAmountTypeEnum["GROSS"] = 1] = "GROSS";
2797
+ })(IncomeAmountTypeEnum || (IncomeAmountTypeEnum = {}));
2930
2798
 
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 = {}));
2799
+ class Depreciation$1 extends TransactionBase {
2800
+ }
2941
2801
 
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 = {}));
2802
+ class DepreciationCapitalProject$1 extends AbstractModel {
2803
+ }
2950
2804
 
2951
- var IncomeSourceTypeListSoleEnum;
2952
- (function (IncomeSourceTypeListSoleEnum) {
2953
- IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
2954
- })(IncomeSourceTypeListSoleEnum || (IncomeSourceTypeListSoleEnum = {}));
2805
+ class DepreciationCapitalProject extends DepreciationCapitalProject$1 {
2806
+ }
2807
+ __decorate([
2808
+ Type(() => Date)
2809
+ ], DepreciationCapitalProject.prototype, "effectiveDate", void 0);
2955
2810
 
2956
- class IncomeSourceType extends IncomeSourceType$1 {
2957
- isBonuses() {
2958
- return this.id === IncomeSourceTypeListWorkEnum.BONUSES;
2811
+ class DepreciationForecast$1 extends AbstractModel {
2812
+ }
2813
+
2814
+ class DepreciationForecast extends DepreciationForecast$1 {
2815
+ get dailyClaimAmount() {
2816
+ return this.claimAmount / this.daysApplied;
2959
2817
  }
2960
- isWork() {
2961
- return !!IncomeSourceTypeListWorkEnum[this.id];
2818
+ get daysApplied() {
2819
+ return moment$1(this.toDate).diff(moment$1(this.fromDate), 'days');
2962
2820
  }
2963
- isOther() {
2964
- return !!IncomeSourceTypeListOtherEnum[this.id];
2821
+ getDaysByMonth(month) {
2822
+ // @TODO find a better place
2823
+ const year = this.financialYear - (month > 5 ? 1 : 0);
2824
+ // forecast date intersect by month
2825
+ const range = new DateRange(this.fromDate, this.toDate).intersect(new DateRange(new Date(year, month, 1), new Date(year, month + 1, 0)));
2826
+ return range ? range.duration('days') + 1 : 0;
2965
2827
  }
2966
- isSole() {
2967
- return !!IncomeSourceTypeListSoleEnum[this.id];
2828
+ get claimOpenBalance() {
2829
+ return this.openBalance * this.claimRate;
2968
2830
  }
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
- }
2831
+ get claimCloseBalance() {
2832
+ return this.closeBalance * this.claimRate;
2833
+ }
2834
+ get claimAmount() {
2835
+ return this.amount * this.claimRate;
2836
+ }
2837
+ get claimRate() {
2838
+ return this.claimPercent / 100;
2839
+ }
2840
+ getClaimAmountByMonth(month) {
2841
+ return this.getDaysByMonth(month) * this.dailyClaimAmount;
2978
2842
  }
2979
2843
  }
2980
2844
 
2981
- class IncomeSourceForecast extends IncomeSourceForecast$1 {
2845
+ /**
2846
+ * @TODO Alex: clarify grouping rules and refactor
2847
+ */
2848
+ class Depreciation extends Depreciation$1 {
2982
2849
  constructor() {
2983
2850
  super(...arguments);
2984
- this.paygIncome = 0;
2985
- this.frequency = SalaryForecastFrequencyEnum.ANNUAL;
2986
- this.isTaxFree = false;
2851
+ this.forecasts = [];
2852
+ this.type = DepreciationTypeEnum.PLANT_EQUIPMENT;
2853
+ /**
2854
+ * @TODO remove after ? signs removed from db models
2855
+ */
2856
+ this.amount = 0;
2987
2857
  }
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;
2858
+ // Type checking
2859
+ isCapital() {
2860
+ return this.type === DepreciationTypeEnum.CAPITAL_WORKS;
2994
2861
  }
2995
- get grossAmount() {
2996
- return this.amount + this.tax + this.taxInstalments + this.frankingCredits;
2862
+ isBorrowingExpense() {
2863
+ return this.type === DepreciationTypeEnum.BORROWING_EXPENSES;
2997
2864
  }
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;
2865
+ isAsset() {
2866
+ return this.type === DepreciationTypeEnum.PLANT_EQUIPMENT;
3011
2867
  }
3012
- isSoleIncome() {
3013
- return !!this.soleForecasts.length;
2868
+ // Calculation checking
2869
+ isSBPCalculation() {
2870
+ return this.calculation === DepreciationCalculationEnum.SBP;
3014
2871
  }
3015
- isWorkIncome() {
3016
- return this.type === IncomeSourceTypeEnum.WORK;
2872
+ isPrimeCost() {
2873
+ return this.calculation === DepreciationCalculationEnum.PRIME_COST;
3017
2874
  }
3018
- isOtherIncome() {
3019
- return this.type === IncomeSourceTypeEnum.OTHER || (!this.isSoleIncome() && !this.isSalaryIncome());
2875
+ isDiminishing() {
2876
+ return this.calculation === DepreciationCalculationEnum.DIMINISHING;
2877
+ }
2878
+ // Pool checking
2879
+ isPlantEquipmentPool() {
2880
+ return this.isAsset() && !this.isSBPCalculation() && !this.isWrittenOff() && !this.isLVP();
2881
+ }
2882
+ isLVP() {
2883
+ return this.isAsset()
2884
+ && !this.isSBPCalculation()
2885
+ && this.isDiminishing()
2886
+ && this.currentYearForecast.closeBalance > Depreciation.WRITTEN_OFF_THRESHOLD
2887
+ && this.currentYearForecast.closeBalance <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
2888
+ }
2889
+ isSBP() {
2890
+ return this.isAsset() && this.isSBPCalculation() && !this.isWrittenOff();
2891
+ }
2892
+ isWrittenOff() {
2893
+ return this.writeOffYear === new FinancialYear().year;
2894
+ }
2895
+ get writeOffYear() {
2896
+ var _a;
2897
+ if (!this.writeOffManualDate && !this.writeOffDate) {
2898
+ return null;
2899
+ }
2900
+ return (_a = new FinancialYear(this.writeOffManualDate || this.writeOffDate)) === null || _a === void 0 ? void 0 : _a.year;
3020
2901
  }
3021
2902
  /**
3022
- * Get salary and other income forecasts
2903
+ * Check if depreciation chart accounts heading related to vehicles category
3023
2904
  */
3024
- get forecasts() {
3025
- return [...this.salaryForecasts, ...this.incomeSourceForecasts, ...this.soleForecasts];
2905
+ isVehicleDepreciation() {
2906
+ var _a;
2907
+ return ((_a = this.chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id) === ChartAccountsHeadingVehicleListEnum.DEPRECIATION_VEHICLES;
3026
2908
  }
3027
2909
  /**
3028
- * Get actual (1st from the list) forecast
2910
+ * Get depreciation purchase date
3029
2911
  */
3030
- get actualForecast() {
3031
- return this.forecasts[0];
2912
+ getDate() {
2913
+ return this.date;
3032
2914
  }
3033
2915
  /**
3034
- * Check if user was working in month taken by the index
3035
- * @param monthIndex by which month should be taken
2916
+ * @TODO Vik: Research a problem with depreciations without current year forecast
3036
2917
  */
3037
- isWorkedInMonth(monthIndex) {
3038
- const monthDate = new FinancialYear().getMonthDate(monthIndex);
3039
- return (!this.dateFrom || monthDate >= this.dateFrom) && (!this.dateTo || monthDate < this.dateTo);
2918
+ get currentYearForecast() {
2919
+ return this.forecasts.find((forecast) => {
2920
+ return forecast.financialYear === new FinancialYear().year;
2921
+ }) || plainToClass(DepreciationForecast, {
2922
+ financialYear: new FinancialYear().year,
2923
+ openBalance: 0,
2924
+ closeBalance: 0,
2925
+ amount: 0,
2926
+ claimPercent: 0
2927
+ });
2928
+ }
2929
+ getForecastByYear(year) {
2930
+ return this.forecasts.find((forecast) => {
2931
+ return forecast.financialYear === year;
2932
+ });
2933
+ }
2934
+ getClaimAmountByYear(year) {
2935
+ var _a;
2936
+ return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
2937
+ }
2938
+ getCloseBalanceByYear(year) {
2939
+ var _a;
2940
+ return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.closeBalance) || 0;
2941
+ }
2942
+ isBuildingAtCost() {
2943
+ return this.chartAccounts.id === ChartAccountsListEnum.BUILDING_AT_COST;
2944
+ }
2945
+ /**
2946
+ * Create a new transaction from current depreciation
2947
+ */
2948
+ toTransaction(params = {}) {
2949
+ return plainToClass(Transaction, Object.assign(params, this, { amount: -this.claimAmount, claimAmount: -this.amount * (this.claimPercent / 100) }));
2950
+ }
2951
+ /**
2952
+ * @TODO Michael: remove and check everywhere in reports
2953
+ */
2954
+ get claimAmount() {
2955
+ var _a;
2956
+ return ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
3040
2957
  }
3041
2958
  }
2959
+ Depreciation.WRITTEN_OFF_THRESHOLD = 300;
2960
+ Depreciation.LOW_VALUE_POOL_THRESHOLD = 1000;
3042
2961
  __decorate([
3043
- Type(() => SalaryForecast)
3044
- ], IncomeSource.prototype, "salaryForecasts", void 0);
2962
+ Type(() => Date)
2963
+ ], Depreciation.prototype, "purchaseDate", void 0);
3045
2964
  __decorate([
3046
- Type(() => SoleForecast)
3047
- ], IncomeSource.prototype, "soleForecasts", void 0);
2965
+ Type(() => Date)
2966
+ ], Depreciation.prototype, "date", void 0);
3048
2967
  __decorate([
3049
- Type(() => IncomeSourceForecast)
3050
- ], IncomeSource.prototype, "incomeSourceForecasts", void 0);
2968
+ Type(() => Date)
2969
+ ], Depreciation.prototype, "lowValuePoolDate", void 0);
3051
2970
  __decorate([
3052
2971
  Type(() => Date)
3053
- ], IncomeSource.prototype, "dateFrom", void 0);
2972
+ ], Depreciation.prototype, "writeOffManualDate", void 0);
3054
2973
  __decorate([
3055
2974
  Type(() => Date)
3056
- ], IncomeSource.prototype, "dateTo", void 0);
3057
-
3058
- class TransactionMetadata$1 extends AbstractModel {
3059
- }
3060
-
3061
- class TransactionMetadata extends TransactionMetadata$1 {
3062
- }
2975
+ ], Depreciation.prototype, "writeOffDate", void 0);
3063
2976
  __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
- }
2977
+ Type(() => DepreciationCapitalProject)
2978
+ ], Depreciation.prototype, "depreciationCapitalProject", void 0);
2979
+ __decorate([
2980
+ Type(() => DepreciationForecast),
2981
+ Transform(({ value, obj }) => {
2982
+ // value = array of DepreciationForecast
2983
+ // obj = plain (whole Depreciation object)
2984
+ // Set isLVP flag for each DepreciationForecast
2985
+ // @TODO refactor
2986
+ value.forEach((forecast) => {
2987
+ forecast.isLVP =
2988
+ forecast.closeBalance < 1000 &&
2989
+ obj.calculation === DepreciationCalculationEnum.DIMINISHING &&
2990
+ obj.type === DepreciationTypeEnum.PLANT_EQUIPMENT &&
2991
+ !(obj.amount > Depreciation.WRITTEN_OFF_THRESHOLD && obj.amount < Depreciation.LOW_VALUE_POOL_THRESHOLD) &&
2992
+ !(obj.writeOffDate && new FinancialYear(new Date(obj.writeOffDate)).year === obj.financialYear);
2993
+ });
2994
+ return value;
2995
+ })
2996
+ ], Depreciation.prototype, "forecasts", void 0);
3079
2997
  __decorate([
3080
- Type(() => BankTransaction)
3081
- ], TransactionAllocation.prototype, "bankTransaction", void 0);
2998
+ Type(() => ChartAccounts)
2999
+ ], Depreciation.prototype, "chartAccounts", void 0);
3082
3000
  __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 = {}));
3001
+ Type(() => BankTransaction)
3002
+ ], Depreciation.prototype, "bankTransaction", void 0);
3094
3003
 
3095
3004
  // @TODO refactor with baseModel in constructor
3096
3005
  class Transaction extends Transaction$1 {
@@ -3298,225 +3207,402 @@ __decorate([
3298
3207
  Type(() => TransactionAllocation)
3299
3208
  ], Transaction.prototype, "allocations", void 0);
3300
3209
 
3301
- class BankTransaction extends BankTransaction$1 {
3210
+ class SoleInvoiceItem extends SoleInvoiceItem$1 {
3302
3211
  constructor() {
3303
3212
  super(...arguments);
3304
- // allocated money amount for bank transaction
3305
- this.allocatedAmount = 0;
3306
- this.unallocatedAmount = 0;
3213
+ this.isGST = false;
3214
+ }
3215
+ get totalPrice() {
3216
+ return this.price * this.quantity;
3217
+ }
3218
+ }
3219
+ /**
3220
+ * GST percent value
3221
+ */
3222
+ SoleInvoiceItem.GSTRatio = 0.1;
3223
+ __decorate([
3224
+ Type(() => SoleInvoice)
3225
+ ], SoleInvoiceItem.prototype, "invoice", void 0);
3226
+ __decorate([
3227
+ Type(() => ChartAccounts)
3228
+ ], SoleInvoiceItem.prototype, "chartAccounts", void 0);
3229
+ __decorate([
3230
+ Type(() => Transaction)
3231
+ ], SoleInvoiceItem.prototype, "transaction", void 0);
3232
+
3233
+ class SoleContact$1 extends AbstractModel {
3234
+ }
3235
+
3236
+ // @TODO Alex/Vik: Create some base class for User and SoleContact with common methods and properties
3237
+ class SoleContact extends SoleContact$1 {
3238
+ get fullName() {
3239
+ return `${this.firstName} ${this.lastName}`;
3240
+ }
3241
+ getPhotoPlaceholder() {
3242
+ return `${this.firstName[0].toUpperCase()}${this.lastName[0].toUpperCase()}`;
3243
+ }
3244
+ // @TODO Vik: add photo field to SoleContact
3245
+ getPhoto() {
3246
+ return '';
3247
+ }
3248
+ }
3249
+ __decorate([
3250
+ Type(() => User)
3251
+ ], SoleContact.prototype, "user", void 0);
3252
+ __decorate([
3253
+ Type(() => Phone)
3254
+ ], SoleContact.prototype, "phone", void 0);
3255
+ __decorate([
3256
+ Type(() => Address)
3257
+ ], SoleContact.prototype, "address", void 0);
3258
+ __decorate([
3259
+ Type(() => SoleInvoice)
3260
+ ], SoleContact.prototype, "invoices", void 0);
3261
+
3262
+ class SoleInvoiceTemplate$1 extends AbstractModel {
3263
+ }
3264
+
3265
+ var SoleInvoiceTemplateTaxTypeEnum;
3266
+ (function (SoleInvoiceTemplateTaxTypeEnum) {
3267
+ SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["TAX_EXCLUSIVE"] = 0] = "TAX_EXCLUSIVE";
3268
+ SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["TAX_INCLUSIVE"] = 1] = "TAX_INCLUSIVE";
3269
+ SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["NO_TAX"] = 2] = "NO_TAX";
3270
+ })(SoleInvoiceTemplateTaxTypeEnum || (SoleInvoiceTemplateTaxTypeEnum = {}));
3271
+
3272
+ class SoleInvoiceTemplate extends SoleInvoiceTemplate$1 {
3273
+ constructor() {
3274
+ super(...arguments);
3275
+ /**
3276
+ * Affects to SoleInvoiceItem.isGST flag availability.
3277
+ * When NONE: isGST is unavailable
3278
+ * When EXCLUSIVE: GST amount added additionaly to invoice total price
3279
+ * When INCLUSIVE: GST amount is already included to invoice total price
3280
+ */
3281
+ this.taxType = SoleInvoiceTemplateTaxTypeEnum.NO_TAX;
3307
3282
  }
3308
3283
  /**
3309
- * get allocated amount value but with +/- sign
3284
+ * Get term duration in milliseconds
3310
3285
  */
3311
- get balanceAmount() {
3312
- return this.isCredit() ? this.allocatedAmount : -this.allocatedAmount;
3286
+ get termTime() {
3287
+ return this.term * 24 * 3600 * 1000;
3288
+ }
3289
+ }
3290
+ __decorate([
3291
+ Type(() => SoleBusiness)
3292
+ ], SoleInvoiceTemplate.prototype, "business", void 0);
3293
+ __decorate([
3294
+ Type(() => BankAccount)
3295
+ ], SoleInvoiceTemplate.prototype, "bankAccount", void 0);
3296
+
3297
+ var SoleInvoiceStatusesEnum;
3298
+ (function (SoleInvoiceStatusesEnum) {
3299
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["CANCELED"] = 0] = "CANCELED";
3300
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["DRAFT"] = 1] = "DRAFT";
3301
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PENDING"] = 2] = "PENDING";
3302
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PAID"] = 3] = "PAID";
3303
+ })(SoleInvoiceStatusesEnum || (SoleInvoiceStatusesEnum = {}));
3304
+
3305
+ var SoleInvoiceTaxTypeEnum;
3306
+ (function (SoleInvoiceTaxTypeEnum) {
3307
+ SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["TAX_EXCLUSIVE"] = 0] = "TAX_EXCLUSIVE";
3308
+ SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["TAX_INCLUSIVE"] = 1] = "TAX_INCLUSIVE";
3309
+ SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["NO_TAX"] = 2] = "NO_TAX";
3310
+ })(SoleInvoiceTaxTypeEnum || (SoleInvoiceTaxTypeEnum = {}));
3311
+
3312
+ class SoleInvoiceItemCollection extends Collection {
3313
+ get gstPrice() {
3314
+ return this.filterBy('isGST', true).sumBy('totalPrice');
3315
+ }
3316
+ }
3317
+
3318
+ class SoleInvoice extends SoleInvoice$1 {
3319
+ constructor() {
3320
+ super(...arguments);
3321
+ this.status = SoleInvoiceStatusesEnum.DRAFT;
3322
+ this.taxType = SoleInvoiceTaxTypeEnum.NO_TAX;
3313
3323
  }
3314
3324
  /**
3315
- * check if bank transaction is debit
3325
+ * Get items array as collection
3316
3326
  */
3317
- isDebit() {
3318
- return this.type === BankTransactionTypeEnum.DEBIT;
3327
+ get itemsCollection() {
3328
+ return new SoleInvoiceItemCollection(this.items);
3319
3329
  }
3320
3330
  /**
3321
- * check if bank transaction is credit
3331
+ * Total price of all items
3322
3332
  */
3323
- isCredit() {
3324
- return this.type === BankTransactionTypeEnum.CREDIT;
3333
+ get price() {
3334
+ return this.itemsCollection.sumBy('totalPrice');
3325
3335
  }
3326
3336
  /**
3327
- * Create Transaction instance based on Bank Transaction
3337
+ * Total invoice price without GST
3328
3338
  */
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
- });
3339
+ get netPrice() {
3340
+ if (this.isTaxInclusive()) {
3341
+ return this.price - this.GSTAmount;
3342
+ }
3343
+ return this.price;
3338
3344
  }
3339
3345
  /**
3340
- * Check if bank transaction is completely allocated
3346
+ * Total final price (net + GST)
3341
3347
  */
3342
- isAllocated(allocations) {
3343
- return this.amount === this.getAllocatedAmount(allocations);
3348
+ get grossPrice() {
3349
+ if (this.isTaxExclusive()) {
3350
+ return this.price + this.GSTAmount;
3351
+ }
3352
+ return this.price;
3344
3353
  }
3345
3354
  /**
3346
- * Get bank transaction allocated amount
3355
+ * Total GST amount
3347
3356
  */
3348
- getAllocatedAmount(allocations) {
3349
- return allocations.getByBankTransactionsIds([this.id]).amount;
3357
+ get GSTAmount() {
3358
+ switch (this.taxType) {
3359
+ case SoleInvoiceTaxTypeEnum.TAX_INCLUSIVE:
3360
+ return this.inclusiveGSTAmount;
3361
+ case SoleInvoiceTaxTypeEnum.TAX_EXCLUSIVE:
3362
+ return this.exclusiveGSTAmount;
3363
+ case SoleInvoiceTaxTypeEnum.NO_TAX:
3364
+ return 0;
3365
+ }
3350
3366
  }
3351
3367
  /**
3352
- * Get bank transaction unallocated amount
3368
+ * When tax inclusive, GST amount is included to total price
3353
3369
  */
3354
- getUnallocatedAmount(allocations) {
3355
- return this.amount - this.getAllocatedAmount(allocations);
3370
+ get inclusiveGSTAmount() {
3371
+ const gstPrice = this.itemsCollection.gstPrice;
3372
+ return +(gstPrice - (gstPrice / (1 + SoleInvoiceItem.GSTRatio))).toFixed(2);
3373
+ }
3374
+ /**
3375
+ * When tax exclusive, GST amount should be added additionally to total price
3376
+ */
3377
+ get exclusiveGSTAmount() {
3378
+ return +(this.itemsCollection.gstPrice * SoleInvoiceItem.GSTRatio).toFixed(2);
3379
+ }
3380
+ isDraft() {
3381
+ return this.status === SoleInvoiceStatusesEnum.DRAFT;
3382
+ }
3383
+ isCancelled() {
3384
+ return this.status === SoleInvoiceStatusesEnum.CANCELED;
3385
+ }
3386
+ isPending() {
3387
+ return this.status === SoleInvoiceStatusesEnum.PENDING;
3388
+ }
3389
+ isPaid() {
3390
+ return this.status === SoleInvoiceStatusesEnum.PAID;
3391
+ }
3392
+ isOverdue() {
3393
+ return this.isPending() && this.dateTo < new Date();
3394
+ }
3395
+ isUnpaid() {
3396
+ return this.isPending() && this.dateTo >= new Date();
3397
+ }
3398
+ /**
3399
+ * GST is not available for invoices without taxes
3400
+ */
3401
+ isNoTax() {
3402
+ return this.taxType === SoleInvoiceTaxTypeEnum.NO_TAX;
3403
+ }
3404
+ /**
3405
+ * GST amount is not included in items prices for invoices with tax exclusive,
3406
+ * we should add GST amount additionaly to subtotal price to get total price
3407
+ */
3408
+ isTaxExclusive() {
3409
+ return this.taxType === SoleInvoiceTaxTypeEnum.TAX_EXCLUSIVE;
3410
+ }
3411
+ /**
3412
+ * GST amount already included in items prices for invoices with tax inclusive,
3413
+ * we should subtract GST amount from total price to get subtotal price
3414
+ */
3415
+ isTaxInclusive() {
3416
+ return this.taxType === SoleInvoiceTaxTypeEnum.TAX_INCLUSIVE;
3417
+ }
3418
+ getNumber() {
3419
+ return String(this.number).padStart(SoleInvoice.NUMBER_LENGTH, '0');
3420
+ }
3421
+ get name() {
3422
+ return `invoice-${this.getNumber()}.pdf`;
3423
+ }
3424
+ }
3425
+ SoleInvoice.NUMBER_LENGTH = 4;
3426
+ __decorate([
3427
+ Type(() => Date)
3428
+ ], SoleInvoice.prototype, "dateFrom", void 0);
3429
+ __decorate([
3430
+ Type(() => Date)
3431
+ ], SoleInvoice.prototype, "dateTo", void 0);
3432
+ __decorate([
3433
+ Type(() => User)
3434
+ ], SoleInvoice.prototype, "user", void 0);
3435
+ __decorate([
3436
+ Type(() => SoleBusiness)
3437
+ ], SoleInvoice.prototype, "business", void 0);
3438
+ __decorate([
3439
+ Type(() => SoleInvoiceItem)
3440
+ ], SoleInvoice.prototype, "items", void 0);
3441
+ __decorate([
3442
+ Type(() => SoleContact)
3443
+ ], SoleInvoice.prototype, "payer", void 0);
3444
+ __decorate([
3445
+ Type(() => SoleInvoiceTemplate)
3446
+ ], SoleInvoice.prototype, "template", void 0);
3447
+ __decorate([
3448
+ Type(() => BankAccount)
3449
+ ], SoleInvoice.prototype, "bankAccount", void 0);
3450
+
3451
+ /**
3452
+ * Class contains traveled kilometers and work usage percent in 12 weeks date range
3453
+ * @TODO Vik: Best period: move this and related logic to backend
3454
+ * @TODO Alex: check if we need this class when calculation refactored with backend
3455
+ */
3456
+ class LogbookPeriod {
3457
+ isEndOfYear() {
3458
+ return this.to === new FinancialYear().endDate;
3459
+ }
3460
+ getWorkUsageByClaim(claim) {
3461
+ const claimKilometers = this.logbooks.getByVehicleClaim(claim).getClaimableLogbooks().kilometers;
3462
+ return Math.round(this.workUsage * (claimKilometers / this.kilometers));
3463
+ }
3464
+ }
3465
+ __decorate([
3466
+ Type(() => Date)
3467
+ ], LogbookPeriod.prototype, "from", void 0);
3468
+ __decorate([
3469
+ Type(() => Date)
3470
+ ], LogbookPeriod.prototype, "to", void 0);
3471
+
3472
+ class Vehicle$1 extends AbstractModel {
3473
+ }
3474
+
3475
+ class VehicleLogbook$1 extends AbstractModel {
3476
+ }
3477
+
3478
+ const moment = extendMoment(moment$1);
3479
+ class VehicleLogbook extends VehicleLogbook$1 {
3480
+ get kilometers() {
3481
+ return this.odometerEnd - this.odometerStart;
3482
+ }
3483
+ get tankType() {
3484
+ return this.isSoleTank() ? TankTypeEnum.SOLE : TankTypeEnum.WORK;
3485
+ }
3486
+ isWorkTank() {
3487
+ return !this.business;
3488
+ }
3489
+ isSoleTank() {
3490
+ return !!this.business;
3491
+ }
3492
+ /**
3493
+ * Get logbook period date range from logbook date and weeksInPeriod duration
3494
+ */
3495
+ getPeriod() {
3496
+ return moment.rangeFromInterval('milliseconds', VehicleLogbook.bestPeriodDuration, this.date);
3356
3497
  }
3357
3498
  }
3499
+ /**
3500
+ * Logbook period duration in milliseconds.
3501
+ * https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/211517441/Logbook+Vehicle
3502
+ */
3503
+ VehicleLogbook.bestPeriodDuration = 12 * 7 * 24 * 3600 * 1000;
3358
3504
  __decorate([
3359
3505
  Type(() => Date)
3360
- ], BankTransaction.prototype, "date", void 0);
3506
+ ], VehicleLogbook.prototype, "date", void 0);
3507
+ __decorate([
3508
+ Type(() => SoleBusiness)
3509
+ ], VehicleLogbook.prototype, "business", void 0);
3361
3510
 
3362
- /**
3363
- * @TODO Alex: clarify grouping rules and refactor
3364
- */
3365
- class Depreciation extends Depreciation$1 {
3511
+ class Vehicle extends Vehicle$1 {
3512
+ }
3513
+ __decorate([
3514
+ Type(() => VehicleLogbook)
3515
+ ], Vehicle.prototype, "logbook", void 0);
3516
+
3517
+ class VehicleClaim$1 extends AbstractModel {
3518
+ }
3519
+
3520
+ class VehicleClaimDetails$1 extends AbstractModel {
3521
+ }
3522
+
3523
+ var VehicleClaimDetailsMethodEnum;
3524
+ (function (VehicleClaimDetailsMethodEnum) {
3525
+ VehicleClaimDetailsMethodEnum[VehicleClaimDetailsMethodEnum["KMS"] = 1] = "KMS";
3526
+ VehicleClaimDetailsMethodEnum[VehicleClaimDetailsMethodEnum["LOGBOOK"] = 2] = "LOGBOOK";
3527
+ })(VehicleClaimDetailsMethodEnum || (VehicleClaimDetailsMethodEnum = {}));
3528
+
3529
+ class VehicleClaimDetails extends VehicleClaimDetails$1 {
3366
3530
  constructor() {
3367
3531
  super(...arguments);
3368
- this.forecasts = [];
3369
- this.type = DepreciationTypeEnum.PLANT_EQUIPMENT;
3370
3532
  /**
3371
- * @TODO remove after ? signs removed from db models
3533
+ * Init default values for the new instances
3372
3534
  */
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;
3535
+ this.isManual = true;
3536
+ this.method = VehicleClaimDetailsMethodEnum.KMS;
3537
+ this.financialYear = new FinancialYear().year;
3394
3538
  }
3395
- // Pool checking
3396
- isPlantEquipmentPool() {
3397
- return this.isAsset() && !this.isSBPCalculation() && !this.isWrittenOff() && !this.isLVP();
3539
+ isLogbookMethod() {
3540
+ return this.method === VehicleClaimDetailsMethodEnum.LOGBOOK;
3398
3541
  }
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;
3542
+ isKmsMethod() {
3543
+ return this.method === VehicleClaimDetailsMethodEnum.KMS;
3405
3544
  }
3406
- isSBP() {
3407
- return this.isAsset() && this.isSBPCalculation() && !this.isWrittenOff();
3545
+ }
3546
+ __decorate([
3547
+ Type(() => User)
3548
+ ], VehicleClaimDetails.prototype, "user", void 0);
3549
+
3550
+ class VehicleClaim extends VehicleClaim$1 {
3551
+ constructor() {
3552
+ super(...arguments);
3553
+ this.kilometers = 0;
3554
+ this.workUsage = 0;
3408
3555
  }
3409
- isWrittenOff() {
3410
- return this.writeOffYear === new FinancialYear().year;
3556
+ isWorkTank() {
3557
+ return !this.business;
3411
3558
  }
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;
3559
+ isSoleTank() {
3560
+ return !!this.business;
3418
3561
  }
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;
3562
+ get tankType() {
3563
+ return this.isSoleTank() ? TankTypeEnum.SOLE : TankTypeEnum.WORK;
3425
3564
  }
3426
3565
  /**
3427
- * Get depreciation purchase date
3566
+ * Claim amount for KMs method. Exists only for KMs method.
3428
3567
  */
3429
- getDate() {
3430
- return this.date;
3568
+ getKMSClaimAmount(vehicleClaimRate) {
3569
+ return +(this.kilometers * vehicleClaimRate).toFixed(2);
3431
3570
  }
3432
3571
  /**
3433
- * @TODO Vik: Research a problem with depreciations without current year forecast
3572
+ * Get logbook claim amount. Exists only for logbook method.
3573
+ * ClaimAmount = WorkUsage * transaction/depreciation amount
3434
3574
  */
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;
3575
+ getLogbookClaimAmount(transactions) {
3576
+ const transactionsAmount = transactions
3577
+ .getByVehicleClaim(this)
3578
+ .getLogbookTransactions()
3579
+ .sumBy('amount');
3580
+ // Math.abs because amount will be negative (because we sum expenses), but we don't want negative percent value
3581
+ return Math.abs(transactionsAmount) * this.workUsage / 100;
3461
3582
  }
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) }));
3583
+ getAverageWeeklyKMS() {
3584
+ return this.kilometers / FinancialYear.weeksInYear;
3467
3585
  }
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;
3586
+ static getKMSChartAccountsIdByTankType(tankType) {
3587
+ return tankType === TankTypeEnum.WORK
3588
+ ? ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK
3589
+ : ChartAccountsListEnum.KLMS_TRAVELLED;
3474
3590
  }
3475
3591
  }
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);
3592
+ /**
3593
+ * limit for kms claim method
3594
+ */
3595
+ VehicleClaim.totalKmsLimit = 5000;
3596
+ /**
3597
+ * limit for work usage claim method
3598
+ */
3599
+ VehicleClaim.totalWorkUsagePercent = 100;
3514
3600
  __decorate([
3515
- Type(() => ChartAccounts)
3516
- ], Depreciation.prototype, "chartAccounts", void 0);
3601
+ Type(() => VehicleClaimDetails)
3602
+ ], VehicleClaim.prototype, "details", void 0);
3517
3603
  __decorate([
3518
- Type(() => BankTransaction)
3519
- ], Depreciation.prototype, "bankTransaction", void 0);
3604
+ Type(() => SoleBusiness)
3605
+ ], VehicleClaim.prototype, "business", void 0);
3520
3606
 
3521
3607
  class SoleBusinessActivity$1 extends AbstractModel {
3522
3608
  }
@@ -3582,6 +3668,15 @@ class SoleDepreciationMethod extends SoleDepreciationMethod$1 {
3582
3668
  }
3583
3669
  }
3584
3670
 
3671
+ class SoleDetails$1 extends AbstractModel {
3672
+ }
3673
+
3674
+ class SoleDetails extends SoleDetails$1 {
3675
+ }
3676
+ __decorate([
3677
+ Type(() => User)
3678
+ ], SoleDetails.prototype, "user", void 0);
3679
+
3585
3680
  class User extends User$1 {
3586
3681
  get fullName() {
3587
3682
  return `${this.firstName} ${this.lastName}`;
@@ -5138,6 +5233,47 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
5138
5233
  }]
5139
5234
  }] });
5140
5235
 
5236
+ class Document$1 extends AbstractModel {
5237
+ }
5238
+
5239
+ /**
5240
+ * Enum with document types which used to API url prefix
5241
+ */
5242
+ var DocumentApiUrlPrefixEnum;
5243
+ (function (DocumentApiUrlPrefixEnum) {
5244
+ DocumentApiUrlPrefixEnum["FOLDERS"] = "folders";
5245
+ DocumentApiUrlPrefixEnum["PROPERTIES"] = "properties";
5246
+ })(DocumentApiUrlPrefixEnum || (DocumentApiUrlPrefixEnum = {}));
5247
+
5248
+ class Document extends Document$1 {
5249
+ constructor() {
5250
+ super(...arguments);
5251
+ this.type = AssetTypeEnum.DOCUMENTS;
5252
+ this.entityType = AssetEntityTypeEnum.FOLDERS;
5253
+ }
5254
+ /**
5255
+ * Get folder as document parent entity
5256
+ */
5257
+ getEntity() {
5258
+ return this.folder;
5259
+ }
5260
+ /**
5261
+ * Get API url prefix
5262
+ */
5263
+ getApiUrlPrefix() {
5264
+ return DocumentApiUrlPrefixEnum.FOLDERS;
5265
+ }
5266
+ }
5267
+
5268
+ class DocumentFolder$1 extends AbstractModel {
5269
+ }
5270
+
5271
+ class DocumentFolder extends DocumentFolder$1 {
5272
+ }
5273
+ __decorate([
5274
+ Type(() => Document)
5275
+ ], DocumentFolder.prototype, "documents", void 0);
5276
+
5141
5277
  class VehicleClaimCollection extends Collection {
5142
5278
  /**
5143
5279
  * Get remaining kilometers limit. Total limit ({@link VehicleClaim.totalKmsLimit}) - claimed kilometers from other vehicle claims
@@ -6615,6 +6751,13 @@ class ChartAccountsCategoryECollection {
6615
6751
  }
6616
6752
  }
6617
6753
 
6754
+ var DocumentTypeEnum;
6755
+ (function (DocumentTypeEnum) {
6756
+ DocumentTypeEnum[DocumentTypeEnum["INVOICE"] = 1] = "INVOICE";
6757
+ })(DocumentTypeEnum || (DocumentTypeEnum = {}));
6758
+
6759
+ // @TODO Artem TT-2308 move everything
6760
+
6618
6761
  var ChartAccountsEtpEnum;
6619
6762
  (function (ChartAccountsEtpEnum) {
6620
6763
  ChartAccountsEtpEnum[ChartAccountsEtpEnum["ETP_R"] = 549] = "ETP_R";
@@ -7672,7 +7815,7 @@ class Dictionary {
7672
7815
  this.items[key] = value;
7673
7816
  }
7674
7817
  get(key) {
7675
- return this.items[key] ? this.items[key] : null;
7818
+ return this.items[key] !== undefined ? this.items[key] : null;
7676
7819
  }
7677
7820
  groupItems(items, path) {
7678
7821
  items.forEach((item) => {
@@ -7770,38 +7913,6 @@ class DepreciationReceipt extends DepreciationReceipt$1 {
7770
7913
  }
7771
7914
  }
7772
7915
 
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
7916
  const DOCUMENT_FILE_TYPES = {
7806
7917
  image: [
7807
7918
  'image/png',
@@ -7825,15 +7936,6 @@ const DOCUMENT_FILE_TYPES = {
7825
7936
  ]
7826
7937
  };
7827
7938
 
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
7939
  class EmployeeInvite$1 extends AbstractModel {
7838
7940
  }
7839
7941
 
@@ -9460,6 +9562,17 @@ class SoleInvoiceService extends RestService {
9460
9562
  this.url = 'sole-invoices';
9461
9563
  this.isHydra = true;
9462
9564
  }
9565
+ updateStatus(invoice, status) {
9566
+ // use id only to avoid unexpected changes
9567
+ return this.update(plainToClass(SoleInvoice, merge({}, { id: invoice.id }, { status })));
9568
+ }
9569
+ publish(invoice, document) {
9570
+ // use id only to avoid unexpected changes
9571
+ return this.update(merge({}, invoice, { document, status: SoleInvoiceStatusesEnum.PENDING }));
9572
+ }
9573
+ sendEmail(invoice) {
9574
+ return this.http.post(`${this.environment.apiV2}/${this.url}/${invoice.id}/send`, {});
9575
+ }
9463
9576
  }
9464
9577
  SoleInvoiceService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleInvoiceService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9465
9578
  SoleInvoiceService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleInvoiceService, providedIn: 'root' });
@@ -9798,6 +9911,90 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
9798
9911
  }]
9799
9912
  }] });
9800
9913
 
9914
+ class DocumentService extends RestService {
9915
+ constructor() {
9916
+ super(...arguments);
9917
+ this.url = 'documents';
9918
+ this.modelClass = Document;
9919
+ }
9920
+ }
9921
+ DocumentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9922
+ DocumentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentService, providedIn: 'root' });
9923
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentService, decorators: [{
9924
+ type: Injectable,
9925
+ args: [{
9926
+ providedIn: 'root'
9927
+ }]
9928
+ }] });
9929
+
9930
+ /**
9931
+ * Service to handle document-folders and depending documents logic
9932
+ */
9933
+ class DocumentFolderService extends RestService {
9934
+ constructor() {
9935
+ super(...arguments);
9936
+ this.url = 'folders';
9937
+ this.modelClass = DocumentFolder;
9938
+ }
9939
+ /**
9940
+ * Add new document to the folder
9941
+ * @param file to be uploaded to the folder
9942
+ * @param folder for document
9943
+ */
9944
+ addDocument(file, folder) {
9945
+ // create formData object with provided file
9946
+ const formDataDocument = new FormData();
9947
+ formDataDocument.append('file', file);
9948
+ return this.http.post(`${this.environment.apiV2}/folders/${folder.id}/documents`, formDataDocument).pipe(map((response) => {
9949
+ const updatedFolder = Object.assign(plainToClass(DocumentFolder, {}), folder);
9950
+ updatedFolder.documents.push(plainToClass(Document, response));
9951
+ replace(this.cache, plainToClass(DocumentFolder, updatedFolder));
9952
+ this.cacheSubject.next(this.cache);
9953
+ }));
9954
+ }
9955
+ /**
9956
+ * Edit folder document by moving it from one folder to another
9957
+ * @param editedDocument
9958
+ * @param selectedFolder to move the document to
9959
+ * @param oldFolderId: id of old folder from which need to remove the document
9960
+ */
9961
+ updateDocument(editedDocument, selectedFolder, oldFolderId) {
9962
+ return this.http.put(`${this.environment.apiV2}/folders/${selectedFolder.id}/documents/${editedDocument.id}`, editedDocument).pipe(map((response) => {
9963
+ const oldFolder = this.cache.find((folder) => folder.id === oldFolderId);
9964
+ // Remove document from old folder
9965
+ oldFolder.documents = oldFolder.documents.filter((deletedDocument) => deletedDocument.id !== response.id);
9966
+ // update old folder and replace it in cache
9967
+ response.folder = plainToClass(DocumentFolder, { id: selectedFolder.id, name: selectedFolder.name });
9968
+ replace(this.cache, plainToClass(DocumentFolder, oldFolder));
9969
+ // update new document folder and replace it in cache
9970
+ selectedFolder.documents.push(plainToClass(Document, response));
9971
+ replace(this.cache, plainToClass(DocumentFolder, selectedFolder));
9972
+ this.cacheSubject.next(this.cache);
9973
+ }));
9974
+ }
9975
+ /**
9976
+ * Delete document from folder
9977
+ * @param document to remove
9978
+ * @param folder from which document should be removed
9979
+ */
9980
+ deleteDocument(document, folder) {
9981
+ return this.http.delete(`${this.environment.apiV2}/folders/${folder.id}/documents/${document.id}`).pipe(map(() => {
9982
+ folder.documents = folder.documents
9983
+ .filter((deletedDocument) => deletedDocument.id !== document.id);
9984
+ replace(this.cache, plainToClass(DocumentFolder, folder));
9985
+ this.cacheSubject.next(this.cache);
9986
+ }));
9987
+ }
9988
+ }
9989
+ DocumentFolderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9990
+ DocumentFolderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, providedIn: 'root' });
9991
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, decorators: [{
9992
+ type: Injectable,
9993
+ args: [{
9994
+ providedIn: 'root'
9995
+ }]
9996
+ }] });
9997
+
9801
9998
  /**
9802
9999
  * Service to work with Rewardful (affiliate program) API
9803
10000
  * https://developers.rewardful.com/javascript-api/overview#executing-code-when-rewardful-loads
@@ -12124,74 +12321,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
12124
12321
  args: ['environment']
12125
12322
  }] }]; } });
12126
12323
 
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
12324
  class EmployeeService extends RestService {
12196
12325
  constructor() {
12197
12326
  super(...arguments);
@@ -12864,25 +12993,36 @@ const FILE_SETTINGS$1 = {
12864
12993
  };
12865
12994
 
12866
12995
  /**
12996
+ * @TODO mikhail better typehint
12997
+ *
12867
12998
  * Service to generate and export PDF file from provided HTML elements
12868
12999
  * The file is generated using the html2pdf library in order to get a canvas at the output,
12869
13000
  * in which all the styles that the user sees on the page will be saved
12870
13001
  */
12871
13002
  class PdfFromDomElementService {
12872
- export(elements, fileSettings) {
13003
+ init(elements, fileSettings) {
12873
13004
  const options = FILE_SETTINGS$1;
12874
- options.filename = `${fileSettings.filename}.pdf`;
13005
+ if (fileSettings) {
13006
+ merge(options, fileSettings);
13007
+ }
12875
13008
  // HTML container in which the exported DOM elements will be placed
12876
13009
  const htmlWrapper = document.createElement('div');
12877
13010
  elements.forEach((element) => {
12878
13011
  htmlWrapper.append(element.cloneNode(true));
12879
13012
  });
12880
13013
  // Set PDF options, save file and return result as Observable
12881
- return from(html2pdf().from(htmlWrapper)
12882
- .set(options)
13014
+ return html2pdf().from(htmlWrapper).set(options);
13015
+ }
13016
+ download(elements, fileSettings) {
13017
+ return from(this.init(elements, fileSettings)
12883
13018
  .save()
12884
13019
  .then());
12885
13020
  }
13021
+ export(elements, filename = FILE_SETTINGS$1.filename) {
13022
+ return from(this.init(elements)
13023
+ .outputPdf('blob')
13024
+ .then((blob) => new File([blob], filename, { type: 'application/pdf' })));
13025
+ }
12886
13026
  }
12887
13027
  PdfFromDomElementService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PdfFromDomElementService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
12888
13028
  PdfFromDomElementService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PdfFromDomElementService, providedIn: 'root' });
@@ -13913,6 +14053,17 @@ class TransactionCalculationService {
13913
14053
  return !this.isAllocated(transaction, allocations);
13914
14054
  }));
13915
14055
  }
14056
+ /**
14057
+ * Get invoices allocated amounts grouped bu invoice id
14058
+ */
14059
+ getAllocationsAmountsByInvoiceId(allocations, invoices) {
14060
+ const allocationsByTransactionId = allocations.groupBy('transaction.id');
14061
+ const dictionary = new Dictionary([]);
14062
+ invoices.toArray().forEach((invoice) => {
14063
+ dictionary.add(invoice.id, allocationsByTransactionId.merge(invoice.itemsCollection.mapBy('transaction.id')).amount || 0);
14064
+ });
14065
+ return dictionary;
14066
+ }
13916
14067
  }
13917
14068
  TransactionCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionCalculationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
13918
14069
  TransactionCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionCalculationService, providedIn: 'root' });
@@ -14677,51 +14828,35 @@ class SoleInvoiceItemForm extends AbstractForm {
14677
14828
  description: new FormControl(item.description, Validators.required),
14678
14829
  quantity: new FormControl(item.quantity, Validators.required),
14679
14830
  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)
14831
+ isGST: new FormControl({ value: item.isGST || false, disabled: !((_a = item.chartAccounts) === null || _a === void 0 ? void 0 : _a.isGST) }),
14832
+ chartAccounts: new FormControl(item.chartAccounts, Validators.required),
14682
14833
  }, 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
14834
  }
14712
14835
  }
14713
14836
 
14714
14837
  class SoleInvoiceForm extends AbstractForm {
14715
- constructor(invoice) {
14838
+ constructor(invoice, soleDetailsGST) {
14716
14839
  super({
14717
- dateFrom: new FormControl(invoice.dateFrom, Validators.required),
14840
+ dateFrom: new FormControl(invoice.dateFrom || new Date(), Validators.required),
14718
14841
  dateTo: new FormControl(invoice.dateTo, Validators.required),
14719
- items: new FormArray(invoice.items.map((item) => new SoleInvoiceItemForm(item))),
14842
+ items: new FormArray((invoice.items || [plainToClass(SoleInvoiceItem, {})]).map((item) => new SoleInvoiceItemForm(item))),
14720
14843
  payer: new FormControl(invoice.payer, Validators.required),
14721
- template: new FormControl(invoice.template, Validators.required)
14844
+ taxType: new FormControl(invoice.taxType, Validators.required),
14845
+ bankAccount: new FormControl(invoice.bankAccount, Validators.required)
14722
14846
  }, invoice);
14723
- if (invoice.id) {
14724
- this.updateItemsForm(invoice.template);
14847
+ this.soleDetailsGST = soleDetailsGST;
14848
+ // we need invoice template only for new invoices
14849
+ if (!invoice.id) {
14850
+ this.addControl('template', new FormControl(invoice.template));
14851
+ }
14852
+ // invoice.taxType is always NONE ('No Tax') when soleDetails.isGST === false
14853
+ if (!this.soleDetailsGST) {
14854
+ this.get('taxType').setValue(SoleInvoiceTaxTypeEnum.NO_TAX);
14855
+ this.get('taxType').disable();
14856
+ // Items isGST is not available when invoice.taxType === NONE ('No Tax')
14857
+ this.items.controls.forEach((itemForm) => {
14858
+ this.disableItemGST(itemForm);
14859
+ });
14725
14860
  }
14726
14861
  this.listenEvents();
14727
14862
  }
@@ -14729,52 +14864,113 @@ class SoleInvoiceForm extends AbstractForm {
14729
14864
  return this.get('items');
14730
14865
  }
14731
14866
  listenEvents() {
14732
- this.listenTemplateChanges();
14867
+ // no need to listen tax type and items chart accounts changes when soleDetails.isGST === false
14868
+ // because invoice tax type always 'No Tax' in this case and not available for changing
14869
+ if (this.soleDetailsGST) {
14870
+ this.listenTaxTypeChanges();
14871
+ this.items.controls.forEach((itemForm) => {
14872
+ this.listenItemChartAccountsChanges(itemForm);
14873
+ });
14874
+ }
14875
+ // nothing to listen if template field is not учшые (edit invoice case)
14876
+ if (this.contains('template')) {
14877
+ this.listenTemplateChanges();
14878
+ }
14733
14879
  }
14734
14880
  addItem() {
14735
- this.items.push(new SoleInvoiceItemForm(plainToClass(SoleInvoiceItem, {})));
14881
+ const itemForm = new SoleInvoiceItemForm(plainToClass(SoleInvoiceItem, {}));
14882
+ // no need to listen items chart accounts changes when soleDetails.isGST === false
14883
+ // because invoice tax type always 'No Tax' in this case and not available for changing
14884
+ if (this.soleDetailsGST) {
14885
+ this.listenItemChartAccountsChanges(itemForm);
14886
+ }
14887
+ this.items.push(itemForm);
14736
14888
  }
14737
14889
  removeItem(index) {
14738
- // do not remove the last item
14739
- if (this.items.length === 1) {
14740
- return;
14741
- }
14742
14890
  this.items.removeAt(index);
14743
14891
  }
14744
14892
  submit(data = {}) {
14893
+ // @TODO Alex TT-2190: move child custom forms submit to Abstract Form
14745
14894
  const items = this.items.controls.map((control) => control.submit());
14746
- return super.submit(Object.assign({}, data, { items }));
14895
+ return super.submit(merge(data, { items }));
14747
14896
  }
14897
+ /**
14898
+ * Update default values from selected invoice template
14899
+ */
14748
14900
  listenTemplateChanges() {
14749
14901
  this.get('template').valueChanges.subscribe((template) => {
14750
- this.updateItemsForm(template);
14902
+ this.get('bankAccount').setValue(template.bankAccount);
14903
+ const dateFrom = this.get('dateFrom').value;
14904
+ if (dateFrom) {
14905
+ this.get('dateTo').setValue(new Date(dateFrom.getTime() + template.termTime));
14906
+ }
14907
+ // invoice.taxType is always 'No Tax' when soleDetails.isGST = false and not available for changing
14908
+ if (this.soleDetailsGST) {
14909
+ this.get('taxType').setValue(template.taxType);
14910
+ }
14911
+ });
14912
+ }
14913
+ /**
14914
+ * GST is not available for items when invoice.taxType === NONE
14915
+ */
14916
+ listenTaxTypeChanges() {
14917
+ this.get('taxType').valueChanges.subscribe((type) => {
14918
+ this.items.controls.forEach((itemForm) => {
14919
+ const chartAccounts = itemForm.get('chartAccounts').value;
14920
+ // Item GST is available when invoice.taxType !== NONE ('No Tax')
14921
+ if (type !== SoleInvoiceTaxTypeEnum.NO_TAX && (chartAccounts === null || chartAccounts === void 0 ? void 0 : chartAccounts.isGST)) {
14922
+ this.enableItemGST(itemForm);
14923
+ return;
14924
+ }
14925
+ this.disableItemGST(itemForm);
14926
+ });
14751
14927
  });
14752
14928
  }
14753
- updateItemsForm(template) {
14754
- this.items.controls.forEach((itemForm) => {
14755
- itemForm.onTemplateChanged(template);
14929
+ /**
14930
+ * GST availability depends of chart accounts isGST flag
14931
+ */
14932
+ listenItemChartAccountsChanges(itemForm) {
14933
+ itemForm.get('chartAccounts').valueChanges.subscribe((chartAccounts) => {
14934
+ // item.isGST is available only when item.chartAccounts.isGST === true, soleDetails.isGST === true and invoice.taxType !== NONE ('No Tax')
14935
+ if (this.soleDetailsGST && chartAccounts.isGST && !this.currentValue.isNoTax()) {
14936
+ this.enableItemGST(itemForm);
14937
+ return;
14938
+ }
14939
+ this.disableItemGST(itemForm);
14756
14940
  });
14757
14941
  }
14942
+ disableItemGST(itemForm) {
14943
+ itemForm.get('isGST').setValue(false);
14944
+ itemForm.get('isGST').disable();
14945
+ }
14946
+ /**
14947
+ * Enable GST field for passed item form. Value is always true by default because only case when this field is enabled is
14948
+ * when ChartAccounts.isGST === true, so we just use default value from chartAccounts.isGST
14949
+ */
14950
+ enableItemGST(itemForm) {
14951
+ itemForm.get('isGST').setValue(true);
14952
+ itemForm.get('isGST').enable();
14953
+ }
14758
14954
  }
14759
14955
 
14760
14956
  class SoleInvoiceTemplateForm extends AbstractForm {
14761
- constructor(invoiceTemplate, soleDetails) {
14957
+ constructor(invoiceTemplate) {
14762
14958
  super({
14763
14959
  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),
14766
- term: new FormControl(invoiceTemplate.term, [Validators.required, Validators.min(0)]),
14960
+ // taxType is always 'No Tax' when soleDetails.isGST === false
14961
+ taxType: new FormControl(invoiceTemplate.taxType, Validators.required),
14962
+ // 32767 - max value because we have small int data type in database for this field, but we don't have actual max validation for term
14963
+ term: new FormControl(invoiceTemplate.term, [Validators.required, Validators.min(0), Validators.max(32767)]),
14767
14964
  bankAccount: new FormControl(invoiceTemplate.bankAccount, [Validators.required])
14768
14965
  }, invoiceTemplate);
14769
- this.soleDetails = soleDetails;
14770
14966
  }
14771
14967
  }
14772
14968
 
14773
14969
  class BankAccountAllocationForm extends AbstractForm {
14774
- constructor(bankAccount) {
14775
- super({
14970
+ constructor(bankAccount, controls) {
14971
+ super(merge(controls, {
14776
14972
  tankType: new FormControl(bankAccount ? bankAccount.tankType : null, Validators.required)
14777
- }, plainToClass(BankAccount, bankAccount || {}));
14973
+ }), plainToClass(BankAccount, bankAccount || {}));
14778
14974
  this.bankAccount = bankAccount;
14779
14975
  if (bankAccount === null || bankAccount === void 0 ? void 0 : bankAccount.isPropertyTank()) {
14780
14976
  this.addControl('bankAccountProperties', new BankAccountPropertiesForm(bankAccount.bankAccountProperties));
@@ -14827,12 +15023,16 @@ class BankAccountImportForm extends BankAccountAllocationForm {
14827
15023
  */
14828
15024
  class BankAccountAddManualForm extends BankAccountAllocationForm {
14829
15025
  constructor(connection) {
14830
- super();
15026
+ super(null, {
15027
+ type: new FormControl(null, Validators.required),
15028
+ accountName: new FormControl(null, Validators.required),
15029
+ currentBalance: new FormControl(null, Validators.required),
15030
+ accountNumber: new FormControl(null, [Validators.required, Validators.pattern(BankAccountAddManualForm.accountNumberPattern)])
15031
+ });
14831
15032
  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)]));
15033
+ }
15034
+ listenEvents() {
15035
+ super.listenEvents();
14836
15036
  this.listenTypeChanges();
14837
15037
  }
14838
15038
  /**
@@ -15709,5 +15909,5 @@ VehicleLogbookForm.maxDescriptionLength = 60;
15709
15909
  * Generated bundle index. Do not edit.
15710
15910
  */
15711
15911
 
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 };
15912
+ 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
15913
  //# sourceMappingURL=taxtank-core.js.map