taxtank-core 0.28.10 → 0.28.13

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