taxtank-core 0.13.0 → 0.13.1

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.
@@ -13,14 +13,15 @@ import flatten from 'lodash/flatten';
13
13
  import hasIn from 'lodash/hasIn';
14
14
  import first from 'lodash/first';
15
15
  import last from 'lodash/last';
16
+ import compact from 'lodash/compact';
16
17
  import uniqBy from 'lodash/uniqBy';
17
18
  import concat from 'lodash/concat';
18
- import compact from 'lodash/compact';
19
19
  import { __decorate, __awaiter } from 'tslib';
20
20
  import * as moment from 'moment';
21
21
  import { DateRange } from 'moment-range';
22
22
  import cloneDeep$1 from 'lodash/cloneDeep';
23
23
  import { Validators, FormGroup, FormControl } from '@angular/forms';
24
+ import fromPairs from 'lodash/fromPairs';
24
25
  import _ from 'lodash';
25
26
  import { EventSourcePolyfill } from 'event-source-polyfill/src/eventsource.min.js';
26
27
  import * as i1$1 from '@angular/router';
@@ -959,8 +960,8 @@ class Collection {
959
960
  /**
960
961
  * Sort collection items by provided field
961
962
  */
962
- sortBy(filed = 'id', isDesc = true) {
963
- sort(this.items, filed, isDesc);
963
+ sortBy(field = 'id', isDesc = true) {
964
+ sort(this.items, field, isDesc);
964
965
  }
965
966
  getByDateRange(from, to, dateField = 'date') {
966
967
  return this.create(this.items.filter((item) => item[dateField] >= from && item[dateField] <= to));
@@ -969,7 +970,7 @@ class Collection {
969
970
 
970
971
  class AccountSetupItemCollection extends Collection {
971
972
  constructor(items) {
972
- super(items);
973
+ super(compact(items));
973
974
  this.sortBy('isCompleted', false);
974
975
  }
975
976
  isCompleted() {
@@ -2279,6 +2280,7 @@ var UserRolesEnum;
2279
2280
  UserRolesEnum["SUBSCRIPTION"] = "ROLE_USER_SUBSCRIPTION";
2280
2281
  UserRolesEnum["WORK_TANK"] = "ROLE_USER_WORK";
2281
2282
  UserRolesEnum["PROPERTY_TANK"] = "ROLE_USER_PROPERTY";
2283
+ UserRolesEnum["SOLE_TANK"] = "ROLE_USER_SOLE";
2282
2284
  UserRolesEnum["SWITCH_USER"] = "ROLE_PREVIOUS_ADMIN";
2283
2285
  })(UserRolesEnum || (UserRolesEnum = {}));
2284
2286
 
@@ -4030,6 +4032,37 @@ class PropertyReportItemDepreciationCollection extends PropertyReportItemCollect
4030
4032
  }
4031
4033
  }
4032
4034
 
4035
+ /**
4036
+ * Vehicle expense for logbook section
4037
+ */
4038
+ class VehicleExpense {
4039
+ constructor(amount, claimPercent, description) {
4040
+ this.amount = amount;
4041
+ this.claimPercent = claimPercent;
4042
+ this.description = description;
4043
+ }
4044
+ getClaimAmount() {
4045
+ return +(this.amount * (this.claimPercent / 100)).toFixed(2);
4046
+ }
4047
+ }
4048
+
4049
+ class VehicleExpenseCollection extends Collection {
4050
+ constructor(transactions, depreciations, vehicleClaim) {
4051
+ super();
4052
+ this.setItems(transactions, depreciations, vehicleClaim);
4053
+ }
4054
+ setItems(transactions, depreciations, vehicleClaim) {
4055
+ this.items = [];
4056
+ const transactionsByChartAccounts = new CollectionDictionary(transactions, 'chartAccounts.name');
4057
+ const transactionExpenses = transactionsByChartAccounts.keys.map((chartAccountsName) => {
4058
+ return new VehicleExpense(transactionsByChartAccounts.get(chartAccountsName).amount, vehicleClaim.workUsage, chartAccountsName);
4059
+ });
4060
+ // group all depreciations into one expense item
4061
+ const depreciationExpense = new VehicleExpense(depreciations.getCurrentYearForecastAmount(), vehicleClaim.workUsage, 'Depreciation');
4062
+ this.items.push(...[depreciationExpense, ...transactionExpenses]);
4063
+ }
4064
+ }
4065
+
4033
4066
  class ServiceSubscriptionCollection extends Collection {
4034
4067
  get individual() {
4035
4068
  return this.items.filter((subscription) => subscription.isIndividual())[0];
@@ -4865,6 +4898,9 @@ var VehicleLogbookPurposeEnum;
4865
4898
  * Account setup item instance is using for account setup checklist
4866
4899
  */
4867
4900
  class AccountSetupItem {
4901
+ constructor() {
4902
+ this.clientIncomeTypes = [];
4903
+ }
4868
4904
  }
4869
4905
 
4870
4906
  class Bank$1 extends AbstractModel {
@@ -6708,6 +6744,7 @@ const USER_ROLES = {
6708
6744
  ROLE_USER_SUBSCRIPTION: [UserRolesEnum.SUBSCRIPTION],
6709
6745
  ROLE_USER_WORK: [UserRolesEnum.WORK_TANK],
6710
6746
  ROLE_USER_PROPERTY: [UserRolesEnum.PROPERTY_TANK],
6747
+ ROLE_USER_SOLE: [UserRolesEnum.SOLE_TANK],
6711
6748
  ROLE_PREVIOUS_ADMIN: [UserRolesEnum.SWITCH_USER]
6712
6749
  };
6713
6750
 
@@ -6788,17 +6825,20 @@ const ACCOUNT_SETUP_ITEMS = {
6788
6825
  [AccountSetupItemsEnum.SALARY]: plainToClass(AccountSetupItem, {
6789
6826
  title: 'Add your work income forecast',
6790
6827
  description: 'One the most important steps is to add your salary or wage incomes so we can automatically calculate tax withheld and your forecasted tax position.',
6791
- url: '/client/work-tank/forecasting'
6828
+ url: '/client/work-tank/forecasting',
6829
+ clientIncomeTypes: ['salary']
6792
6830
  }),
6793
6831
  [AccountSetupItemsEnum.OTHER_INCOME]: plainToClass(AccountSetupItem, {
6794
6832
  title: 'Add any other expected incomes',
6795
6833
  description: 'To ensure an accurate tax position forecast, add estimates for any other income types, like dividends, interest, trusts, annuities, director payments etc.',
6796
- url: '/client/work-tank/forecasting'
6834
+ url: '/client/work-tank/forecasting',
6835
+ clientIncomeTypes: ['dividends', 'other']
6797
6836
  }),
6798
6837
  [AccountSetupItemsEnum.PROPERTY]: plainToClass(AccountSetupItem, {
6799
6838
  title: 'Add your properties',
6800
6839
  description: 'Add your properties to seamlessly manage your rental incomes and expenses, whilst tracking your cash position, tax positions and equity forecasts in real time.',
6801
- url: '/client/property-tank'
6840
+ url: '/client/property-tank',
6841
+ clientIncomeTypes: ['property']
6802
6842
  }),
6803
6843
  [AccountSetupItemsEnum.BANK_FEEDS]: plainToClass(AccountSetupItem, {
6804
6844
  title: 'Link banks and select accounts',
@@ -6813,7 +6853,8 @@ const ACCOUNT_SETUP_ITEMS = {
6813
6853
  [AccountSetupItemsEnum.SOLE_INCOME]: plainToClass(AccountSetupItem, {
6814
6854
  title: 'Add your business details',
6815
6855
  description: 'Add your business details, logo and payment terms to create invoice templates in minutes.',
6816
- url: '/client/sole-tank/forecasting'
6856
+ url: '/client/sole-tank/forecasting',
6857
+ clientIncomeTypes: ['sole']
6817
6858
  }),
6818
6859
  [AccountSetupItemsEnum.TRANSACTION]: plainToClass(AccountSetupItem, {
6819
6860
  title: 'Allocation transactions',
@@ -7482,7 +7523,11 @@ class TransactionAllocationService extends RestService {
7482
7523
  * Reset cache on transactions created
7483
7524
  */
7484
7525
  onTransactionsCreated() {
7485
- this.eventDispatcherService.on(AppEventTypeEnum.TRANSACTIONS_CREATED).subscribe(() => {
7526
+ this.eventDispatcherService.on(AppEventTypeEnum.TRANSACTIONS_CREATED).subscribe((transactions) => {
7527
+ // @TODO Alex hack: research and refactor cache update logic, dont reset cache each time transactions changed
7528
+ if (transactions[0].isTransfer) {
7529
+ return;
7530
+ }
7486
7531
  // Update allocations cache to synchronize data and fire subscriptions
7487
7532
  this.resetCache();
7488
7533
  });
@@ -7492,6 +7537,7 @@ class TransactionAllocationService extends RestService {
7492
7537
  */
7493
7538
  onDepreciationCreated() {
7494
7539
  this.eventDispatcherService.on(AppEventTypeEnum.DEPRECIATIONS_CREATED).subscribe(() => {
7540
+ // @TODO Alex hack: research and refactor cache update logic, dont reset cache each time depreciations changed
7495
7541
  // Update allocations cache to synchronize data and fire subscriptions
7496
7542
  this.resetCache();
7497
7543
  });
@@ -7501,6 +7547,7 @@ class TransactionAllocationService extends RestService {
7501
7547
  */
7502
7548
  onTransactionDeleted() {
7503
7549
  this.eventDispatcherService.on(AppEventTypeEnum.TRANSACTION_DELETED).subscribe(() => {
7550
+ // @TODO Alex hack: research and refactor cache update logic, dont reset cache each time transactions changed
7504
7551
  // Update allocations cache to synchronize data and fire subscriptions
7505
7552
  this.resetCache();
7506
7553
  });
@@ -7547,274 +7594,620 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
7547
7594
  }]
7548
7595
  }] });
7549
7596
 
7597
+ function enumToList(data) {
7598
+ const list = [];
7599
+ for (const key in data) {
7600
+ if (Number(key) >= 0) {
7601
+ list.push({
7602
+ label: data[key],
7603
+ value: Number(key)
7604
+ });
7605
+ }
7606
+ }
7607
+ return list;
7608
+ }
7609
+
7610
+ var MessagesEnum;
7611
+ (function (MessagesEnum) {
7612
+ MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
7613
+ MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
7614
+ MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
7615
+ })(MessagesEnum || (MessagesEnum = {}));
7616
+
7550
7617
  /**
7551
- * Service handling user's account setup process.
7552
- * Checks required steps and their completion
7618
+ * Service for transactions business logic
7553
7619
  */
7554
- class AccountSetupService {
7555
- constructor(clientIncomeTypesService, propertyService, incomeSourceService, bankAccountsService, transactionAllocationService, vehicleClaimService) {
7556
- this.clientIncomeTypesService = clientIncomeTypesService;
7557
- this.propertyService = propertyService;
7558
- this.incomeSourceService = incomeSourceService;
7559
- this.bankAccountsService = bankAccountsService;
7560
- this.transactionAllocationService = transactionAllocationService;
7561
- this.vehicleClaimService = vehicleClaimService;
7562
- this.cacheSubject = new ReplaySubject(1);
7620
+ class TransactionService extends RestService {
7621
+ constructor() {
7622
+ super(...arguments);
7623
+ // url part for Transaction API
7624
+ this.url = 'transactions';
7625
+ this.modelClass = Transaction;
7626
+ this.transactionDeleted = new EventEmitter();
7563
7627
  }
7564
7628
  /**
7565
- * Get list of account setup items for current user
7629
+ * Listen events from Event Dispatcher services
7630
+ */
7631
+ listenEvents() {
7632
+ this.listenDepreciationChange();
7633
+ this.listenPropertyShareUpdate();
7634
+ }
7635
+ /**
7636
+ * get list of all user's TaxTank transactions
7566
7637
  */
7567
7638
  get() {
7568
7639
  if (!this.cache) {
7569
- this.clientIncomeTypesService.get().subscribe((incomeTypes) => {
7570
- combineLatest(this.createBatch(incomeTypes)).subscribe((items) => {
7571
- this.cache = new AccountSetupItemCollection(items);
7572
- this.cacheSubject.next(this.cache);
7573
- });
7640
+ // set cache as default empty array to avoid multiple backend requests
7641
+ this.cache = [];
7642
+ this.fetch()
7643
+ .subscribe((transactions) => {
7644
+ this.cache = transactions;
7645
+ this.updateCache();
7574
7646
  });
7575
7647
  }
7576
- return this.cacheSubject.asObservable();
7648
+ return this.cacheSubject.asObservable().pipe(
7649
+ // assign child transactions (fees) to parent transactions
7650
+ map((transactions) => {
7651
+ transactions.forEach((transaction) => {
7652
+ transaction.transactions = transactions
7653
+ // get list of child transactions
7654
+ .filter((t) => t.parentTransaction && t.parentTransaction.id === transaction.id);
7655
+ });
7656
+ sort(transactions, 'date', false);
7657
+ return transactions;
7658
+ }));
7577
7659
  }
7578
7660
  /**
7579
- * Get a single AccountSetupItem and check it's completion
7661
+ * Add single new transaction
7662
+ * @param model New Transaction instance for saving
7580
7663
  */
7581
- create(itemType, request) {
7582
- return request.pipe(map((result) => {
7583
- const item = ACCOUNT_SETUP_ITEMS[itemType];
7584
- if (result.length) {
7585
- item.isCompleted = true;
7586
- }
7587
- return item;
7664
+ add(model) {
7665
+ // we don't have POST API endpoint for single transaction
7666
+ return this.addBatch([model])
7667
+ .pipe(map((newTransactions) => {
7668
+ // @TODO alex
7669
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTION_CREATED, newTransactions[0]));
7670
+ return newTransactions[0];
7588
7671
  }));
7589
7672
  }
7590
7673
  /**
7591
- * Get batch of requests to get list of required AccountSetupItem's.
7592
- * Some items are optional and depends of user's client income types
7674
+ * get transactions related with property
7593
7675
  */
7594
- createBatch(incomeTypes) {
7595
- const batch = [];
7596
- // Salary item is completed when user added salary income source
7597
- if (incomeTypes.salary) {
7598
- batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSourcesByType(IncomeSourceTypeEnum.SALARY)));
7599
- }
7600
- // Other income item is completed when user added at least one other income source
7601
- if (incomeTypes.dividends || incomeTypes.other) {
7602
- batch.push(this.create(AccountSetupItemsEnum.OTHER_INCOME, this.getIncomeSourcesByType(IncomeSourceTypeEnum.OTHER)));
7603
- }
7604
- // Rental income item is completed when user added at least one property
7605
- if (incomeTypes.property) {
7606
- batch.push(this.create(AccountSetupItemsEnum.PROPERTY, this.propertyService.get()));
7607
- }
7608
- // Bank feeds item is completed when user added at least one bank account (basiq or manual)
7609
- batch.push(this.create(AccountSetupItemsEnum.BANK_FEEDS, this.bankAccountsService.get()));
7610
- // Logbook item is completed when user has at least one vehicle claim with any method (klms or logbook)
7611
- batch.push(this.create(AccountSetupItemsEnum.WORK_LOGBOOK, this.vehicleClaimService.get()));
7612
- // @TODO waiting for sole tank forecast page
7613
- // Sole item is completed when user added at least one sole income source
7614
- // if (incomeTypes.soleTrader) {
7615
- // batch.push(
7616
- // this.prepareItem(
7617
- // AccountSetupItemsEnum.SOLE_INCOME,
7618
- // this.getIncomeSourcesByType(IncomeSourceTypeEnum.SOLE)
7619
- // )
7620
- // );
7621
- // }
7622
- // Allocation item is completed when user added at least one transaction allocation
7623
- batch.push(this.create(AccountSetupItemsEnum.TRANSACTION, this.transactionAllocationService.get()));
7624
- return batch;
7676
+ getByPropertyId(propertyId) {
7677
+ return this.get()
7678
+ .pipe(map((transactions) => {
7679
+ return transactions.filter((transaction) => {
7680
+ var _a;
7681
+ return ((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id) === propertyId;
7682
+ });
7683
+ }));
7625
7684
  }
7626
7685
  /**
7627
- * @TODO work with collection when services refactored
7686
+ * get list of transactions with tank type 'Work'
7628
7687
  */
7629
- getIncomeSourcesByType(type) {
7630
- return this.incomeSourceService.get().pipe(map((incomeSources) => {
7631
- return new IncomeSourceCollection(incomeSources).getBy('type', type).toArray();
7688
+ getWorkTransactions() {
7689
+ return this.get()
7690
+ .pipe(map((transactions) => {
7691
+ return transactions.filter((transaction) => transaction.isWorkTank());
7632
7692
  }));
7633
7693
  }
7634
- }
7635
- AccountSetupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, deps: [{ token: ClientIncomeTypesService }, { token: PropertyService }, { token: IncomeSourceService }, { token: BankAccountService }, { token: TransactionAllocationService }, { token: VehicleClaimService }], target: i0.ɵɵFactoryTarget.Injectable });
7636
- AccountSetupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, providedIn: 'root' });
7637
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, decorators: [{
7638
- type: Injectable,
7639
- args: [{
7640
- providedIn: 'root'
7641
- }]
7642
- }], ctorParameters: function () { return [{ type: ClientIncomeTypesService }, { type: PropertyService }, { type: IncomeSourceService }, { type: BankAccountService }, { type: TransactionAllocationService }, { type: VehicleClaimService }]; } });
7643
-
7644
- class AddressService {
7645
- constructor(http, environment) {
7646
- this.http = http;
7647
- this.environment = environment;
7648
- this.countriesSubject = new ReplaySubject(1);
7649
- }
7650
- getCountries() {
7651
- if (!this._countries) {
7652
- this.http.get(`${this.environment.apiV2}/countries`)
7653
- .pipe(map((response) => {
7654
- return response['hydra:member'].map((item) => plainToClass(Country, item));
7655
- }))
7656
- .subscribe((countries) => {
7657
- this._countries = countries;
7658
- this.countriesSubject.next(countries);
7659
- });
7660
- }
7661
- return this.countriesSubject.asObservable();
7662
- }
7663
- }
7664
- AddressService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AddressService, deps: [{ token: i1.HttpClient }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
7665
- AddressService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AddressService, providedIn: 'root' });
7666
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AddressService, decorators: [{
7667
- type: Injectable,
7668
- args: [{
7669
- providedIn: 'root'
7670
- }]
7671
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
7672
- type: Inject,
7673
- args: ['environment']
7674
- }] }]; } });
7675
-
7676
- /**
7677
- * Service to work with assets (documents, receipts, e.t.c.)
7678
- */
7679
- class AssetsService {
7680
- constructor(http, userSwitcherService, environment) {
7681
- this.http = http;
7682
- this.userSwitcherService = userSwitcherService;
7683
- this.environment = environment;
7684
- this.impersonatedClient = this.userSwitcherService.get();
7685
- }
7686
7694
  /**
7687
- * Get asset link
7688
- * @param asset to get the link for
7695
+ * Get list of property holding costs (transactions related to vacant land property)
7689
7696
  */
7690
- getLink(asset) {
7691
- return this.http.get(`${this.environment.apiV2}/assets/${asset.type}/${asset.id}`);
7697
+ getPropertyHoldingCosts(propertyId) {
7698
+ return this.http.get(`${this.environment.apiV2}/${this.url}?propertyId=${propertyId}&propertyCategoryId=${PropertyCategoryListEnum.VACANT_LAND}`)
7699
+ .pipe(map((transactionsBase) => {
7700
+ return transactionsBase.map((transactionBase) => plainToClass(Transaction, transactionBase));
7701
+ }));
7692
7702
  }
7693
7703
  /**
7694
- * Download asset
7695
- * @param asset which should be downloaded
7696
- * @TODO refactor
7704
+ * get list of taxable transactions with tank type 'Work'
7697
7705
  */
7698
- download(asset) {
7699
- return `${this.environment.apiV2}/assets/${asset.type}/${asset.id}/download?bearer=${localStorage.getItem('token')}${this.impersonatedClient ? `&_switch_user=${this.impersonatedClient}` : ''}`;
7706
+ getTaxableWorkTransactions() {
7707
+ return this.getWorkTransactions()
7708
+ .pipe(map((transactions) => {
7709
+ return transactions.filter((transaction) => !!transaction.chartAccounts.taxReturnItem);
7710
+ }));
7700
7711
  }
7701
- // @Todo refactor to event dispatcher
7702
7712
  /**
7703
- * Delete asset
7704
- * @param entityId: id of asset main entity (property, folder, transaction, e.t.c.)
7705
- * @param asset which should be deleted
7713
+ * add multiple transactions
7714
+ * @param transactions List of new Transaction instances for saving
7706
7715
  */
7707
- delete(entityId, asset) {
7708
- return this.http.delete(`${this.environment.apiV2}/${asset.entityType}/${entityId}/${asset.type}/${asset.id}`);
7709
- }
7710
- }
7711
- AssetsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AssetsService, deps: [{ token: i1.HttpClient }, { token: UserSwitcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
7712
- AssetsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AssetsService, providedIn: 'root' });
7713
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AssetsService, decorators: [{
7714
- type: Injectable,
7715
- args: [{
7716
- providedIn: 'root'
7717
- }]
7718
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: UserSwitcherService }, { type: undefined, decorators: [{
7719
- type: Inject,
7720
- args: ['environment']
7721
- }] }]; } });
7722
-
7723
- /**
7724
- * Service that handling banks logic
7725
- */
7726
- class BankService extends RestService {
7727
- constructor() {
7728
- super(...arguments);
7729
- this.modelClass = Bank;
7730
- this.url = 'banks';
7731
- this.isHydra = true;
7716
+ addBatch(transactions) {
7717
+ transactions = _.cloneDeep(transactions);
7718
+ return this.http.post(`${this.environment.apiV2}/${this.url}`, transactions)
7719
+ .pipe(map((response) => {
7720
+ const addedTransactions = response.map((item) => plainToClass(Transaction, item));
7721
+ transactions.forEach((transaction, index) => {
7722
+ // @TODO backend: need to upload file in the same backend endpoint with transaction add/update
7723
+ // check if passed receipt and upload file
7724
+ if (transaction.file) {
7725
+ transaction.id = response[index].id;
7726
+ addedTransactions[index].file = transaction.file;
7727
+ this.uploadReceipt(addedTransactions[index]);
7728
+ }
7729
+ // @TODO Viktor: implement API for saving of nested transactions
7730
+ // add child transactions if exist
7731
+ if (transaction.transactions.length) {
7732
+ transaction.transactions.forEach((childTransaction) => {
7733
+ childTransaction.parentTransaction = plainToClass(Transaction, { id: addedTransactions[index].id });
7734
+ });
7735
+ this.addBatch(transaction.transactions).subscribe();
7736
+ }
7737
+ // add transfer transaction to cache
7738
+ if (transaction.operation === TransactionOperationEnum.TRANSFER) {
7739
+ addedTransactions.push(addedTransactions[0].transfer);
7740
+ }
7741
+ });
7742
+ if (this.cache) {
7743
+ this.cache.push(...addedTransactions);
7744
+ this.updateCache();
7745
+ }
7746
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
7747
+ this.toastService.success(MessagesEnum.CREATED_MESSAGE);
7748
+ return addedTransactions;
7749
+ }));
7732
7750
  }
7733
- }
7734
- BankService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
7735
- BankService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankService, providedIn: 'root' });
7736
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankService, decorators: [{
7737
- type: Injectable,
7738
- args: [{
7739
- providedIn: 'root'
7740
- }]
7741
- }] });
7742
-
7743
- /**
7744
- * @TODO move to collection
7745
- */
7746
- class BankTransactionCalculationService {
7747
7751
  /**
7748
- * Sum of allocations for passed bank transactions
7752
+ * update existing transaction
7753
+ * @param transaction Transaction instance for updating
7749
7754
  */
7750
- getAllocatedAmount(bankTransactions, allocations) {
7751
- return allocations.getByBankTransactionsIds(bankTransactions.getIds()).amount;
7755
+ update(transaction) {
7756
+ return this.http.put(`${this.environment.apiV2}/${this.url}/${transaction.id}`, transaction)
7757
+ .pipe(map((response) => {
7758
+ const updatedTransaction = plainToClass(Transaction, response);
7759
+ // @TODO need to upload file in the same backend endpoint with transaction add/update
7760
+ // check if passed new receipt and upload file
7761
+ if (transaction.file) {
7762
+ updatedTransaction.file = transaction.file;
7763
+ this.uploadReceipt(updatedTransaction);
7764
+ }
7765
+ // @TODO Viktor: implement API for saving of nested transactions
7766
+ if (transaction.transactions.length) {
7767
+ // add parent transaction to child transactions
7768
+ transaction.transactions.forEach((childTransaction) => {
7769
+ childTransaction.parentTransaction = plainToClass(Transaction, { id: updatedTransaction.id });
7770
+ });
7771
+ // separate child transactions by id existing to define add or update action.
7772
+ const childTransactionsToUpdate = transaction.transactions.filter((t) => t.id);
7773
+ const childTransactionsToAdd = transaction.transactions.filter((t) => !t.id);
7774
+ // update child transactions
7775
+ if (childTransactionsToUpdate.length) {
7776
+ this.updateBatch(childTransactionsToUpdate).subscribe();
7777
+ }
7778
+ // add child transactions
7779
+ if (childTransactionsToAdd.length) {
7780
+ this.addBatch(childTransactionsToAdd).subscribe();
7781
+ }
7782
+ }
7783
+ this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
7784
+ replace(this.cache, updatedTransaction);
7785
+ this.updateCache();
7786
+ return updatedTransaction;
7787
+ }));
7752
7788
  }
7753
7789
  /**
7754
- * Difference between total bank transactions amount and sum of allocations for passed bank transactions
7790
+ * update multiple transactions
7791
+ * @param transactions list of transactions for updating
7755
7792
  */
7756
- getUnallocatedAmount(bankTransactionCollection, allocations) {
7757
- return bankTransactionCollection.getAmount() - allocations.amount;
7793
+ updateBatch(transactions) {
7794
+ return this.http.put(`${this.environment.apiV2}/${this.url}`, transactions)
7795
+ .pipe(map((response) => {
7796
+ const updatedTransactions = response.map((item) => plainToClass(Transaction, item));
7797
+ updatedTransactions.forEach((updatedTransaction) => {
7798
+ replace(this.cache, updatedTransaction);
7799
+ });
7800
+ this.updateCache();
7801
+ return updatedTransactions;
7802
+ }));
7758
7803
  }
7759
7804
  /**
7760
- * Check if bank transaction is allocated
7805
+ * delete transaction and related transactions
7806
+ * @param model
7761
7807
  */
7762
- isAllocated(bankTransaction, allocations) {
7763
- return bankTransaction.amount === this.getAllocatedAmount(new BankTransactionCollection([bankTransaction]), allocations);
7808
+ delete(model) {
7809
+ return this.http.delete(`${this.environment.apiV2}/${this.url}/${model.id}`)
7810
+ .pipe(map(() => {
7811
+ this.cache = this.cache.filter((transaction) => {
7812
+ var _a;
7813
+ // when delete transfer we delete actually 2 transactions
7814
+ if (model.isTransfer) {
7815
+ const ids = [model.id];
7816
+ // get id of related transfer transaction
7817
+ if (model.transfer) {
7818
+ // just take id if we delete source transaction
7819
+ ids.push(model.transfer.id);
7820
+ }
7821
+ else {
7822
+ // find source transaction id if we delete destination transaction
7823
+ ids.push(this.cache.find((t) => t.transfer.id === model.id).id);
7824
+ }
7825
+ return !ids.includes(transaction.id);
7826
+ }
7827
+ return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
7828
+ });
7829
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTION_DELETED, model));
7830
+ this.toastService.success(MessagesEnum.DELETED_MESSAGE);
7831
+ this.updateCache();
7832
+ this.transactionDeleted.emit(model);
7833
+ }));
7764
7834
  }
7765
7835
  /**
7766
- * Get collection of allocated bank transactions
7767
- * @TODO Alex: consider to move to collection
7836
+ * upload transaction receipt image
7837
+ * @param transaction Еhe transaction for which the receipt will be imported
7768
7838
  */
7769
- getAllocatedBankTransactions(bankTransactions, allocations) {
7770
- return new BankTransactionCollection(bankTransactions.items.filter((bankTransaction) => {
7771
- return this.isAllocated(bankTransaction, allocations);
7772
- }));
7839
+ uploadReceipt(transaction) {
7840
+ const formData = new FormData();
7841
+ formData.append('file', transaction.file);
7842
+ transaction.receipt = null;
7843
+ this.http.post(`${this.environment.apiV2}/${this.url}/${transaction.id}/receipts`, formData)
7844
+ .subscribe((receiptResponse) => {
7845
+ // we don't need to keep file after save
7846
+ transaction.file = null;
7847
+ transaction.receipt = plainToClass(TransactionReceipt, receiptResponse);
7848
+ replace(this.cache, transaction);
7849
+ this.updateCache();
7850
+ });
7773
7851
  }
7774
7852
  /**
7775
- * Get collection of unallocated bank transactions
7776
- * @TODO Alex: consider to move to collection
7853
+ * calculate gross income amount based on transaction amount and taxes (fees)
7854
+ * @param transaction Transaction instance for calculation
7777
7855
  */
7778
- getUnallocatedBankTransactions(bankTransactions, allocations) {
7779
- return new BankTransactionCollection(bankTransactions.items.filter((bankTransaction) => {
7780
- return !this.isAllocated(bankTransaction, allocations);
7781
- }));
7856
+ calculateGrossAmount(transaction) {
7857
+ let amount = transaction.amount || 0;
7858
+ // gross income amount includes amount of fees for property tank and tax for work tank
7859
+ if (transaction.isPropertyTank()) {
7860
+ amount += transaction.transactions.reduce((sum, item) => sum + item.amount, 0);
7861
+ }
7862
+ else {
7863
+ // @TODO Alex: fix logic after TT-641 ready
7864
+ amount += (transaction.tax || 0);
7865
+ }
7866
+ return amount;
7782
7867
  }
7783
7868
  /**
7784
- * Allocated sum of credit transactions
7869
+ * get label for transaction tax field depended of selected chart account.
7870
+ * tax type depends of chart account heading or category.
7785
7871
  */
7786
- getCreditAmount(bankTransactions, allocations) {
7787
- return allocations.getByBankTransactionsIds(bankTransactions.creditTransactions.getIds()).amount;
7872
+ getTaxLabel(chartAccounts) {
7873
+ var _a, _b;
7874
+ // get simple array of ids from enum with taxable chart accounts headings
7875
+ const taxableCAHeadingsIds = enumToList(ChartAccountsHeadingTaxableEnum)
7876
+ .map((item) => item.value);
7877
+ // get simple array of ids from enum with tax deductible chart accounts headings
7878
+ const deductibleCAHeadingsIds = enumToList(ChartAccountsHeadingTaxDeductibleEnum)
7879
+ .map((item) => item.value);
7880
+ // check if one of ids arrays includes current chart accounts heading id and set tax label
7881
+ // otherwise label is empty for this class
7882
+ switch (true) {
7883
+ case taxableCAHeadingsIds.includes((_a = chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id):
7884
+ return ChartAccountsTaxLabelsEnum.TAX_PAID;
7885
+ case deductibleCAHeadingsIds.includes((_b = chartAccounts.heading) === null || _b === void 0 ? void 0 : _b.id):
7886
+ return ChartAccountsTaxLabelsEnum.TAX_DEDUCTED;
7887
+ case CHART_ACCOUNTS_CATEGORIES.workIncome.includes(chartAccounts.category):
7888
+ return ChartAccountsTaxLabelsEnum.TAX_WITHHELD;
7889
+ default:
7890
+ return null;
7891
+ }
7788
7892
  }
7789
7893
  /**
7790
- * Allocated sum of debit transactions
7894
+ * Listen to EventDispatcherService event related to Depreciation changing
7791
7895
  */
7792
- getDebitAmount(bankTransactions, allocations) {
7793
- return allocations.getByBankTransactionsIds(bankTransactions.debitTransactions.getIds()).amount;
7896
+ listenDepreciationChange() {
7897
+ this.eventDispatcherService.on(AppEventTypeEnum.DEPRECIATION_DELETED).subscribe(() => {
7898
+ this.fetch()
7899
+ .subscribe((transactions) => {
7900
+ this.cache = transactions;
7901
+ this.updateCache();
7902
+ });
7903
+ });
7904
+ }
7905
+ /**
7906
+ * Listen to EventDispatcherService event related to Property Share changing
7907
+ */
7908
+ listenPropertyShareUpdate() {
7909
+ this.eventDispatcherService.on(AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(() => this.resetCache());
7794
7910
  }
7795
7911
  }
7796
- BankTransactionCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankTransactionCalculationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
7797
- BankTransactionCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankTransactionCalculationService, providedIn: 'root' });
7798
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankTransactionCalculationService, decorators: [{
7912
+ TransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
7913
+ TransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, providedIn: 'root' });
7914
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, decorators: [{
7799
7915
  type: Injectable,
7800
7916
  args: [{
7801
7917
  providedIn: 'root'
7802
7918
  }]
7803
7919
  }] });
7804
7920
 
7805
- class BankAccountCalculationService {
7806
- constructor(bankTransactionCalculationService) {
7807
- this.bankTransactionCalculationService = bankTransactionCalculationService;
7921
+ /**
7922
+ * Service handling user's account setup process.
7923
+ * Checks required steps and their completion
7924
+ */
7925
+ class AccountSetupService {
7926
+ constructor(clientIncomeTypesService, propertyService, incomeSourceService, bankAccountsService, transactionAllocationService, vehicleClaimService, transactionService) {
7927
+ this.clientIncomeTypesService = clientIncomeTypesService;
7928
+ this.propertyService = propertyService;
7929
+ this.incomeSourceService = incomeSourceService;
7930
+ this.bankAccountsService = bankAccountsService;
7931
+ this.transactionAllocationService = transactionAllocationService;
7932
+ this.vehicleClaimService = vehicleClaimService;
7933
+ this.transactionService = transactionService;
7934
+ this.cacheSubject = new ReplaySubject(1);
7808
7935
  }
7809
7936
  /**
7810
- * Sum of bank accounts opening balances and their bank transactions allocated amounts
7937
+ * Get list of account setup items for current user
7811
7938
  */
7812
- getTaxTankBalance(bankAccounts, bankTransactions, allocations) {
7813
- return bankAccounts.getOpeningBalance() +
7814
- this.bankTransactionCalculationService.getAllocatedAmount(bankTransactions.getByBankAccountsIds(bankAccounts.getIds()), allocations);
7939
+ get() {
7940
+ if (!this.cache) {
7941
+ this.clientIncomeTypesService.get().subscribe((incomeTypes) => {
7942
+ this.clientIncomeTypesId = incomeTypes.id;
7943
+ combineLatest(this.createBatch(incomeTypes)).subscribe((items) => {
7944
+ this.cache = new AccountSetupItemCollection(items);
7945
+ this.cacheSubject.next(this.cache);
7946
+ });
7947
+ });
7948
+ }
7949
+ return this.cacheSubject.asObservable();
7815
7950
  }
7816
7951
  /**
7817
- * get difference between total loans amount and total cash amount
7952
+ * Prepare client income types to update to hide depended account setup items
7953
+ */
7954
+ prepareIncomeTypes(item) {
7955
+ return plainToClass(ClientIncomeTypes, Object.assign({ id: this.clientIncomeTypesId }, fromPairs(item.clientIncomeTypes.map((type) => [type, false]))));
7956
+ }
7957
+ /**
7958
+ * Get a single AccountSetupItem and check it's completion
7959
+ */
7960
+ create(itemType, request) {
7961
+ return request.pipe(map((result) => {
7962
+ const item = ACCOUNT_SETUP_ITEMS[itemType];
7963
+ if (result.length) {
7964
+ item.isCompleted = true;
7965
+ }
7966
+ return item;
7967
+ }));
7968
+ }
7969
+ /**
7970
+ * Get batch of requests to get list of required AccountSetupItem's.
7971
+ * Some items are optional and depends of user's client income types
7972
+ */
7973
+ createBatch(incomeTypes) {
7974
+ const batch = [];
7975
+ // Salary item is completed when user added salary income source
7976
+ if (incomeTypes.salary) {
7977
+ batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSourcesByType(IncomeSourceTypeEnum.SALARY)));
7978
+ }
7979
+ // Other income item is completed when user added at least one other income source
7980
+ if (incomeTypes.dividends || incomeTypes.other) {
7981
+ batch.push(this.create(AccountSetupItemsEnum.OTHER_INCOME, this.getIncomeSourcesByType(IncomeSourceTypeEnum.OTHER)));
7982
+ }
7983
+ // Rental income item is completed when user added at least one property
7984
+ if (incomeTypes.property) {
7985
+ batch.push(this.create(AccountSetupItemsEnum.PROPERTY, this.propertyService.get()));
7986
+ }
7987
+ // Bank feeds item is completed when user added at least one bank account (basiq or manual)
7988
+ batch.push(this.create(AccountSetupItemsEnum.BANK_FEEDS, this.bankAccountsService.get()));
7989
+ // Logbook item is completed when user has at least one vehicle claim with any method (klms or logbook)
7990
+ batch.push(this.getLogbookItem());
7991
+ // @TODO waiting for sole tank forecast page
7992
+ // Sole item is completed when user added at least one sole income source
7993
+ // if (incomeTypes.soleTrader) {
7994
+ // batch.push(
7995
+ // this.prepareItem(
7996
+ // AccountSetupItemsEnum.SOLE_INCOME,
7997
+ // this.getIncomeSourcesByType(IncomeSourceTypeEnum.SOLE)
7998
+ // )
7999
+ // );
8000
+ // }
8001
+ // Allocation item is completed when user added at least one transaction allocation
8002
+ batch.push(this.create(AccountSetupItemsEnum.TRANSACTION, this.transactionAllocationService.get()));
8003
+ return batch;
8004
+ }
8005
+ /**
8006
+ * @TODO work with collection when services refactored
8007
+ */
8008
+ getIncomeSourcesByType(type) {
8009
+ return this.incomeSourceService.get().pipe(map((incomeSources) => {
8010
+ return new IncomeSourceCollection(incomeSources).getBy('type', type).toArray();
8011
+ }));
8012
+ }
8013
+ /**
8014
+ * Show logbook item when user has at least 1 vehicle transaction
8015
+ */
8016
+ getLogbookItem() {
8017
+ return combineLatest([
8018
+ this.transactionService.get(),
8019
+ this.create(AccountSetupItemsEnum.WORK_LOGBOOK, this.vehicleClaimService.get())
8020
+ ]).pipe(map(([transactions, item]) => {
8021
+ if (new TransactionCollection(transactions).getVehicleTransactions().length) {
8022
+ return item;
8023
+ }
8024
+ return null;
8025
+ }));
8026
+ }
8027
+ }
8028
+ AccountSetupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, deps: [{ token: ClientIncomeTypesService }, { token: PropertyService }, { token: IncomeSourceService }, { token: BankAccountService }, { token: TransactionAllocationService }, { token: VehicleClaimService }, { token: TransactionService }], target: i0.ɵɵFactoryTarget.Injectable });
8029
+ AccountSetupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, providedIn: 'root' });
8030
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, decorators: [{
8031
+ type: Injectable,
8032
+ args: [{
8033
+ providedIn: 'root'
8034
+ }]
8035
+ }], ctorParameters: function () { return [{ type: ClientIncomeTypesService }, { type: PropertyService }, { type: IncomeSourceService }, { type: BankAccountService }, { type: TransactionAllocationService }, { type: VehicleClaimService }, { type: TransactionService }]; } });
8036
+
8037
+ class AddressService {
8038
+ constructor(http, environment) {
8039
+ this.http = http;
8040
+ this.environment = environment;
8041
+ this.countriesSubject = new ReplaySubject(1);
8042
+ }
8043
+ getCountries() {
8044
+ if (!this._countries) {
8045
+ this.http.get(`${this.environment.apiV2}/countries`)
8046
+ .pipe(map((response) => {
8047
+ return response['hydra:member'].map((item) => plainToClass(Country, item));
8048
+ }))
8049
+ .subscribe((countries) => {
8050
+ this._countries = countries;
8051
+ this.countriesSubject.next(countries);
8052
+ });
8053
+ }
8054
+ return this.countriesSubject.asObservable();
8055
+ }
8056
+ }
8057
+ AddressService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AddressService, deps: [{ token: i1.HttpClient }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
8058
+ AddressService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AddressService, providedIn: 'root' });
8059
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AddressService, decorators: [{
8060
+ type: Injectable,
8061
+ args: [{
8062
+ providedIn: 'root'
8063
+ }]
8064
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
8065
+ type: Inject,
8066
+ args: ['environment']
8067
+ }] }]; } });
8068
+
8069
+ /**
8070
+ * Service to work with assets (documents, receipts, e.t.c.)
8071
+ */
8072
+ class AssetsService {
8073
+ constructor(http, userSwitcherService, environment) {
8074
+ this.http = http;
8075
+ this.userSwitcherService = userSwitcherService;
8076
+ this.environment = environment;
8077
+ this.impersonatedClient = this.userSwitcherService.get();
8078
+ }
8079
+ /**
8080
+ * Get asset link
8081
+ * @param asset to get the link for
8082
+ */
8083
+ getLink(asset) {
8084
+ return this.http.get(`${this.environment.apiV2}/assets/${asset.type}/${asset.id}`);
8085
+ }
8086
+ /**
8087
+ * Download asset
8088
+ * @param asset which should be downloaded
8089
+ * @TODO refactor
8090
+ */
8091
+ download(asset) {
8092
+ return `${this.environment.apiV2}/assets/${asset.type}/${asset.id}/download?bearer=${localStorage.getItem('token')}${this.impersonatedClient ? `&_switch_user=${this.impersonatedClient}` : ''}`;
8093
+ }
8094
+ // @Todo refactor to event dispatcher
8095
+ /**
8096
+ * Delete asset
8097
+ * @param entityId: id of asset main entity (property, folder, transaction, e.t.c.)
8098
+ * @param asset which should be deleted
8099
+ */
8100
+ delete(entityId, asset) {
8101
+ return this.http.delete(`${this.environment.apiV2}/${asset.entityType}/${entityId}/${asset.type}/${asset.id}`);
8102
+ }
8103
+ }
8104
+ AssetsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AssetsService, deps: [{ token: i1.HttpClient }, { token: UserSwitcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
8105
+ AssetsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AssetsService, providedIn: 'root' });
8106
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AssetsService, decorators: [{
8107
+ type: Injectable,
8108
+ args: [{
8109
+ providedIn: 'root'
8110
+ }]
8111
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: UserSwitcherService }, { type: undefined, decorators: [{
8112
+ type: Inject,
8113
+ args: ['environment']
8114
+ }] }]; } });
8115
+
8116
+ /**
8117
+ * Service that handling banks logic
8118
+ */
8119
+ class BankService extends RestService {
8120
+ constructor() {
8121
+ super(...arguments);
8122
+ this.modelClass = Bank;
8123
+ this.url = 'banks';
8124
+ this.isHydra = true;
8125
+ }
8126
+ }
8127
+ BankService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
8128
+ BankService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankService, providedIn: 'root' });
8129
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankService, decorators: [{
8130
+ type: Injectable,
8131
+ args: [{
8132
+ providedIn: 'root'
8133
+ }]
8134
+ }] });
8135
+
8136
+ /**
8137
+ * @TODO move to collection
8138
+ */
8139
+ class BankTransactionCalculationService {
8140
+ /**
8141
+ * Sum of allocations for passed bank transactions
8142
+ */
8143
+ getAllocatedAmount(bankTransactions, allocations) {
8144
+ return allocations.getByBankTransactionsIds(bankTransactions.getIds()).amount;
8145
+ }
8146
+ /**
8147
+ * Difference between total bank transactions amount and sum of allocations for passed bank transactions
8148
+ */
8149
+ getUnallocatedAmount(bankTransactionCollection, allocations) {
8150
+ return bankTransactionCollection.getAmount() - allocations.amount;
8151
+ }
8152
+ /**
8153
+ * Check if bank transaction is allocated
8154
+ */
8155
+ isAllocated(bankTransaction, allocations) {
8156
+ return bankTransaction.amount === this.getAllocatedAmount(new BankTransactionCollection([bankTransaction]), allocations);
8157
+ }
8158
+ /**
8159
+ * Get collection of allocated bank transactions
8160
+ * @TODO Alex: consider to move to collection
8161
+ */
8162
+ getAllocatedBankTransactions(bankTransactions, allocations) {
8163
+ return new BankTransactionCollection(bankTransactions.items.filter((bankTransaction) => {
8164
+ return this.isAllocated(bankTransaction, allocations);
8165
+ }));
8166
+ }
8167
+ /**
8168
+ * Get collection of unallocated bank transactions
8169
+ * @TODO Alex: consider to move to collection
8170
+ */
8171
+ getUnallocatedBankTransactions(bankTransactions, allocations) {
8172
+ return new BankTransactionCollection(bankTransactions.items.filter((bankTransaction) => {
8173
+ return !this.isAllocated(bankTransaction, allocations);
8174
+ }));
8175
+ }
8176
+ /**
8177
+ * Allocated sum of credit transactions
8178
+ */
8179
+ getCreditAmount(bankTransactions, allocations) {
8180
+ return allocations.getByBankTransactionsIds(bankTransactions.creditTransactions.getIds()).amount;
8181
+ }
8182
+ /**
8183
+ * Allocated sum of debit transactions
8184
+ */
8185
+ getDebitAmount(bankTransactions, allocations) {
8186
+ return allocations.getByBankTransactionsIds(bankTransactions.debitTransactions.getIds()).amount;
8187
+ }
8188
+ }
8189
+ BankTransactionCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankTransactionCalculationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
8190
+ BankTransactionCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankTransactionCalculationService, providedIn: 'root' });
8191
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BankTransactionCalculationService, decorators: [{
8192
+ type: Injectable,
8193
+ args: [{
8194
+ providedIn: 'root'
8195
+ }]
8196
+ }] });
8197
+
8198
+ class BankAccountCalculationService {
8199
+ constructor(bankTransactionCalculationService) {
8200
+ this.bankTransactionCalculationService = bankTransactionCalculationService;
8201
+ }
8202
+ /**
8203
+ * Sum of bank accounts opening balances and their bank transactions allocated amounts
8204
+ */
8205
+ getTaxTankBalance(bankAccounts, bankTransactions, allocations) {
8206
+ return bankAccounts.getOpeningBalance() +
8207
+ this.bankTransactionCalculationService.getAllocatedAmount(bankTransactions.getByBankAccountsIds(bankAccounts.getIds()), allocations);
8208
+ }
8209
+ /**
8210
+ * get difference between total loans amount and total cash amount
7818
8211
  */
7819
8212
  getNetPosition(bankAccounts, bankTransactions, allocations) {
7820
8213
  return bankAccounts.currentBalance - this.getTaxTankBalance(bankAccounts.getLoanAccounts(), bankTransactions, allocations);
@@ -9643,330 +10036,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
9643
10036
  }]
9644
10037
  }] });
9645
10038
 
9646
- function enumToList(data) {
9647
- const list = [];
9648
- for (const key in data) {
9649
- if (Number(key) >= 0) {
9650
- list.push({
9651
- label: data[key],
9652
- value: Number(key)
9653
- });
9654
- }
9655
- }
9656
- return list;
9657
- }
9658
-
9659
- var MessagesEnum;
9660
- (function (MessagesEnum) {
9661
- MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
9662
- MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
9663
- MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
9664
- })(MessagesEnum || (MessagesEnum = {}));
9665
-
9666
- /**
9667
- * Service for transactions business logic
9668
- */
9669
- class TransactionService extends RestService {
9670
- constructor() {
9671
- super(...arguments);
9672
- // url part for Transaction API
9673
- this.url = 'transactions';
9674
- this.modelClass = Transaction;
9675
- this.transactionDeleted = new EventEmitter();
9676
- }
9677
- /**
9678
- * Listen events from Event Dispatcher services
9679
- */
9680
- listenEvents() {
9681
- this.listenDepreciationChange();
9682
- this.listenPropertyShareUpdate();
9683
- }
9684
- /**
9685
- * get list of all user's TaxTank transactions
9686
- */
9687
- get() {
9688
- if (!this.cache) {
9689
- // set cache as default empty array to avoid multiple backend requests
9690
- this.cache = [];
9691
- this.fetch()
9692
- .subscribe((transactions) => {
9693
- this.cache = transactions;
9694
- this.updateCache();
9695
- });
9696
- }
9697
- return this.cacheSubject.asObservable().pipe(
9698
- // assign child transactions (fees) to parent transactions
9699
- map((transactions) => {
9700
- transactions.forEach((transaction) => {
9701
- transaction.transactions = transactions
9702
- // get list of child transactions
9703
- .filter((t) => t.parentTransaction && t.parentTransaction.id === transaction.id);
9704
- });
9705
- sort(transactions, 'date', false);
9706
- return transactions;
9707
- }));
9708
- }
9709
- /**
9710
- * Add single new transaction
9711
- * @param model New Transaction instance for saving
9712
- */
9713
- add(model) {
9714
- // we don't have POST API endpoint for single transaction
9715
- return this.addBatch([model])
9716
- .pipe(map((newTransactions) => {
9717
- // @TODO alex
9718
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTION_CREATED, newTransactions[0]));
9719
- return newTransactions[0];
9720
- }));
9721
- }
9722
- /**
9723
- * get transactions related with property
9724
- */
9725
- getByPropertyId(propertyId) {
9726
- return this.get()
9727
- .pipe(map((transactions) => {
9728
- return transactions.filter((transaction) => {
9729
- var _a;
9730
- return ((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id) === propertyId;
9731
- });
9732
- }));
9733
- }
9734
- /**
9735
- * get list of transactions with tank type 'Work'
9736
- */
9737
- getWorkTransactions() {
9738
- return this.get()
9739
- .pipe(map((transactions) => {
9740
- return transactions.filter((transaction) => transaction.isWorkTank());
9741
- }));
9742
- }
9743
- /**
9744
- * Get list of property holding costs (transactions related to vacant land property)
9745
- */
9746
- getPropertyHoldingCosts(propertyId) {
9747
- return this.http.get(`${this.environment.apiV2}/${this.url}?propertyId=${propertyId}&propertyCategoryId=${PropertyCategoryListEnum.VACANT_LAND}`)
9748
- .pipe(map((transactionsBase) => {
9749
- return transactionsBase.map((transactionBase) => plainToClass(Transaction, transactionBase));
9750
- }));
9751
- }
9752
- /**
9753
- * get list of taxable transactions with tank type 'Work'
9754
- */
9755
- getTaxableWorkTransactions() {
9756
- return this.getWorkTransactions()
9757
- .pipe(map((transactions) => {
9758
- return transactions.filter((transaction) => !!transaction.chartAccounts.taxReturnItem);
9759
- }));
9760
- }
9761
- /**
9762
- * add multiple transactions
9763
- * @param transactions List of new Transaction instances for saving
9764
- */
9765
- addBatch(transactions) {
9766
- transactions = _.cloneDeep(transactions);
9767
- return this.http.post(`${this.environment.apiV2}/${this.url}`, transactions)
9768
- .pipe(map((response) => {
9769
- const addedTransactions = response.map((item) => plainToClass(Transaction, item));
9770
- transactions.forEach((transaction, index) => {
9771
- // @TODO backend: need to upload file in the same backend endpoint with transaction add/update
9772
- // check if passed receipt and upload file
9773
- if (transaction.file) {
9774
- transaction.id = response[index].id;
9775
- addedTransactions[index].file = transaction.file;
9776
- this.uploadReceipt(addedTransactions[index]);
9777
- }
9778
- // @TODO Viktor: implement API for saving of nested transactions
9779
- // add child transactions if exist
9780
- if (transaction.transactions.length) {
9781
- transaction.transactions.forEach((childTransaction) => {
9782
- childTransaction.parentTransaction = plainToClass(Transaction, { id: addedTransactions[index].id });
9783
- });
9784
- this.addBatch(transaction.transactions).subscribe();
9785
- }
9786
- // add transfer transaction to cache
9787
- if (transaction.operation === TransactionOperationEnum.TRANSFER) {
9788
- addedTransactions.push(addedTransactions[0].transfer);
9789
- }
9790
- });
9791
- if (this.cache) {
9792
- this.cache.push(...addedTransactions);
9793
- this.updateCache();
9794
- }
9795
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
9796
- this.toastService.success(MessagesEnum.CREATED_MESSAGE);
9797
- return addedTransactions;
9798
- }));
9799
- }
9800
- /**
9801
- * update existing transaction
9802
- * @param transaction Transaction instance for updating
9803
- */
9804
- update(transaction) {
9805
- return this.http.put(`${this.environment.apiV2}/${this.url}/${transaction.id}`, transaction)
9806
- .pipe(map((response) => {
9807
- const updatedTransaction = plainToClass(Transaction, response);
9808
- // @TODO need to upload file in the same backend endpoint with transaction add/update
9809
- // check if passed new receipt and upload file
9810
- if (transaction.file) {
9811
- updatedTransaction.file = transaction.file;
9812
- this.uploadReceipt(updatedTransaction);
9813
- }
9814
- // @TODO Viktor: implement API for saving of nested transactions
9815
- if (transaction.transactions.length) {
9816
- // add parent transaction to child transactions
9817
- transaction.transactions.forEach((childTransaction) => {
9818
- childTransaction.parentTransaction = plainToClass(Transaction, { id: updatedTransaction.id });
9819
- });
9820
- // separate child transactions by id existing to define add or update action.
9821
- const childTransactionsToUpdate = transaction.transactions.filter((t) => t.id);
9822
- const childTransactionsToAdd = transaction.transactions.filter((t) => !t.id);
9823
- // update child transactions
9824
- if (childTransactionsToUpdate.length) {
9825
- this.updateBatch(childTransactionsToUpdate).subscribe();
9826
- }
9827
- // add child transactions
9828
- if (childTransactionsToAdd.length) {
9829
- this.addBatch(childTransactionsToAdd).subscribe();
9830
- }
9831
- }
9832
- this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
9833
- replace(this.cache, updatedTransaction);
9834
- this.updateCache();
9835
- return updatedTransaction;
9836
- }));
9837
- }
9838
- /**
9839
- * update multiple transactions
9840
- * @param transactions list of transactions for updating
9841
- */
9842
- updateBatch(transactions) {
9843
- return this.http.put(`${this.environment.apiV2}/${this.url}`, transactions)
9844
- .pipe(map((response) => {
9845
- const updatedTransactions = response.map((item) => plainToClass(Transaction, item));
9846
- updatedTransactions.forEach((updatedTransaction) => {
9847
- replace(this.cache, updatedTransaction);
9848
- });
9849
- this.updateCache();
9850
- return updatedTransactions;
9851
- }));
9852
- }
9853
- /**
9854
- * delete transaction and related transactions
9855
- * @param model
9856
- */
9857
- delete(model) {
9858
- return this.http.delete(`${this.environment.apiV2}/${this.url}/${model.id}`)
9859
- .pipe(map(() => {
9860
- this.cache = this.cache.filter((transaction) => {
9861
- var _a;
9862
- // when delete transfer we delete actually 2 transactions
9863
- if (model.isTransfer) {
9864
- const ids = [model.id];
9865
- // get id of related transfer transaction
9866
- if (model.transfer) {
9867
- // just take id if we delete source transaction
9868
- ids.push(model.transfer.id);
9869
- }
9870
- else {
9871
- // find source transaction id if we delete destination transaction
9872
- ids.push(this.cache.find((t) => t.transfer.id === model.id).id);
9873
- }
9874
- return !ids.includes(transaction.id);
9875
- }
9876
- return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
9877
- });
9878
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTION_DELETED, model));
9879
- this.toastService.success(MessagesEnum.DELETED_MESSAGE);
9880
- this.updateCache();
9881
- this.transactionDeleted.emit(model);
9882
- }));
9883
- }
9884
- /**
9885
- * upload transaction receipt image
9886
- * @param transaction Еhe transaction for which the receipt will be imported
9887
- */
9888
- uploadReceipt(transaction) {
9889
- const formData = new FormData();
9890
- formData.append('file', transaction.file);
9891
- transaction.receipt = null;
9892
- this.http.post(`${this.environment.apiV2}/${this.url}/${transaction.id}/receipts`, formData)
9893
- .subscribe((receiptResponse) => {
9894
- // we don't need to keep file after save
9895
- transaction.file = null;
9896
- transaction.receipt = plainToClass(TransactionReceipt, receiptResponse);
9897
- replace(this.cache, transaction);
9898
- this.updateCache();
9899
- });
9900
- }
9901
- /**
9902
- * calculate gross income amount based on transaction amount and taxes (fees)
9903
- * @param transaction Transaction instance for calculation
9904
- */
9905
- calculateGrossAmount(transaction) {
9906
- let amount = transaction.amount || 0;
9907
- // gross income amount includes amount of fees for property tank and tax for work tank
9908
- if (transaction.isPropertyTank()) {
9909
- amount += transaction.transactions.reduce((sum, item) => sum + item.amount, 0);
9910
- }
9911
- else {
9912
- // @TODO Alex: fix logic after TT-641 ready
9913
- amount += (transaction.tax || 0);
9914
- }
9915
- return amount;
9916
- }
9917
- /**
9918
- * get label for transaction tax field depended of selected chart account.
9919
- * tax type depends of chart account heading or category.
9920
- */
9921
- getTaxLabel(chartAccounts) {
9922
- var _a, _b;
9923
- // get simple array of ids from enum with taxable chart accounts headings
9924
- const taxableCAHeadingsIds = enumToList(ChartAccountsHeadingTaxableEnum)
9925
- .map((item) => item.value);
9926
- // get simple array of ids from enum with tax deductible chart accounts headings
9927
- const deductibleCAHeadingsIds = enumToList(ChartAccountsHeadingTaxDeductibleEnum)
9928
- .map((item) => item.value);
9929
- // check if one of ids arrays includes current chart accounts heading id and set tax label
9930
- // otherwise label is empty for this class
9931
- switch (true) {
9932
- case taxableCAHeadingsIds.includes((_a = chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id):
9933
- return ChartAccountsTaxLabelsEnum.TAX_PAID;
9934
- case deductibleCAHeadingsIds.includes((_b = chartAccounts.heading) === null || _b === void 0 ? void 0 : _b.id):
9935
- return ChartAccountsTaxLabelsEnum.TAX_DEDUCTED;
9936
- case CHART_ACCOUNTS_CATEGORIES.workIncome.includes(chartAccounts.category):
9937
- return ChartAccountsTaxLabelsEnum.TAX_WITHHELD;
9938
- default:
9939
- return null;
9940
- }
9941
- }
9942
- /**
9943
- * Listen to EventDispatcherService event related to Depreciation changing
9944
- */
9945
- listenDepreciationChange() {
9946
- this.eventDispatcherService.on(AppEventTypeEnum.DEPRECIATION_DELETED).subscribe(() => {
9947
- this.fetch()
9948
- .subscribe((transactions) => {
9949
- this.cache = transactions;
9950
- this.updateCache();
9951
- });
9952
- });
9953
- }
9954
- /**
9955
- * Listen to EventDispatcherService event related to Property Share changing
9956
- */
9957
- listenPropertyShareUpdate() {
9958
- this.eventDispatcherService.on(AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(() => this.resetCache());
9959
- }
9960
- }
9961
- TransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9962
- TransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, providedIn: 'root' });
9963
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, decorators: [{
9964
- type: Injectable,
9965
- args: [{
9966
- providedIn: 'root'
9967
- }]
9968
- }] });
9969
-
9970
10039
  /**
9971
10040
  * Service to handle Property transactions report items data (get income / expense report items, e.t.c.)
9972
10041
  */
@@ -11493,5 +11562,5 @@ class VehicleClaimForm extends AbstractForm {
11493
11562
  * Generated bundle index. Do not edit.
11494
11563
  */
11495
11564
 
11496
- export { AbstractForm, AccountSetupItem, AccountSetupItemCollection, AccountSetupService, Address, AddressService, AddressTypeEnum, AlphabetColorsEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Bank, BankAccount, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqConfig, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, ChartAccounts, ChartAccountsCategoryEnum, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, 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, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, Collection, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEFAULT_VEHICLE_EXPENSE, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCapitalProjectService, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationLvpAssetTypeEnum, DepreciationLvpReportItem, DepreciationLvpReportItemCollection, DepreciationReceipt, DepreciationReportItem, DepreciationReportItemCollection, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EquityPositionChartService, EventDispatcherService, ExportDataTable, ExportFormatEnum, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSalaryEnum, IncomeSourceTypeListWorkEnum, InterceptorsModule, IntercomService, InviteStatusEnum, JwtService, KompassifyService, Loan, LoanBankTypeEnum, LoanCollection, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookPeriod, LoginForm, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, Notification, Occupation, OccupationService, PasswordForm, PdfOrientationEnum, PdfService, PdfSettings, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCategory, PropertyCategoryListEnum, PropertyCategoryMovement, PropertyCategoryMovementService, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertyHoldingCostsService, PropertyReportItem, PropertyReportItemCollection, PropertyReportItemDepreciationCollection, PropertyReportItemTransaction, PropertyReportItemTransactionCollection, PropertySale, PropertySaleService, PropertySaleTaxExemptionMetadata, PropertyService, PropertyShare, PropertyShareAccessEnum, PropertyShareService, PropertyShareStatusEnum, PropertySubscription, PropertyTransactionReportService, PropertyValuation, RegisterClientForm, RegisterFirmForm, RegistrationInvite, RegistrationInviteStatusEnum, ReportItem, ReportItemCollection, ReportItemDetails, ResetPasswordForm, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceRecurringIntervalEnum, ServicePriceService, ServicePriceTypeEnum, ServiceProduct, ServiceProductStatusEnum, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, ShareFilterOptionsEnum, SoleForecast, SoleForecastService, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, 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, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, Vehicle, VehicleClaim, VehicleClaimForm, VehicleClaimMethodEnum, VehicleClaimService, VehicleCollection, VehicleForm, VehicleLogbook, VehicleLogbookCollection, VehicleLogbookPurposeEnum, VehicleLogbookService, VehicleService, WORK_TANK_LOGBOOK_PURPOSE_OPTIONS, XlsxService, cloneDeep, compare, compareMatOptions, createDate, displayMatOptions, enumToList, getDocIcon, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
11565
+ export { AbstractForm, AccountSetupItem, AccountSetupItemCollection, AccountSetupService, Address, AddressService, AddressTypeEnum, AlphabetColorsEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Bank, BankAccount, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqConfig, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, ChartAccounts, ChartAccountsCategoryEnum, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, 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, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, Collection, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEFAULT_VEHICLE_EXPENSE, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCapitalProjectService, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationLvpAssetTypeEnum, DepreciationLvpReportItem, DepreciationLvpReportItemCollection, DepreciationReceipt, DepreciationReportItem, DepreciationReportItemCollection, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EquityPositionChartService, EventDispatcherService, ExportDataTable, ExportFormatEnum, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSalaryEnum, IncomeSourceTypeListWorkEnum, InterceptorsModule, IntercomService, InviteStatusEnum, JwtService, KompassifyService, Loan, LoanBankTypeEnum, LoanCollection, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookPeriod, LoginForm, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, Notification, Occupation, OccupationService, PasswordForm, PdfOrientationEnum, PdfService, PdfSettings, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCategory, PropertyCategoryListEnum, PropertyCategoryMovement, PropertyCategoryMovementService, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertyHoldingCostsService, PropertyReportItem, PropertyReportItemCollection, PropertyReportItemDepreciationCollection, PropertyReportItemTransaction, PropertyReportItemTransactionCollection, PropertySale, PropertySaleService, PropertySaleTaxExemptionMetadata, PropertyService, PropertyShare, PropertyShareAccessEnum, PropertyShareService, PropertyShareStatusEnum, PropertySubscription, PropertyTransactionReportService, PropertyValuation, RegisterClientForm, RegisterFirmForm, RegistrationInvite, RegistrationInviteStatusEnum, ReportItem, ReportItemCollection, ReportItemDetails, ResetPasswordForm, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceRecurringIntervalEnum, ServicePriceService, ServicePriceTypeEnum, ServiceProduct, ServiceProductStatusEnum, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, ShareFilterOptionsEnum, SoleForecast, SoleForecastService, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, 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, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, Vehicle, VehicleClaim, VehicleClaimForm, VehicleClaimMethodEnum, VehicleClaimService, VehicleCollection, VehicleExpense, VehicleExpenseCollection, VehicleForm, VehicleLogbook, VehicleLogbookCollection, VehicleLogbookPurposeEnum, VehicleLogbookService, VehicleService, WORK_TANK_LOGBOOK_PURPOSE_OPTIONS, XlsxService, cloneDeep, compare, compareMatOptions, createDate, displayMatOptions, enumToList, getDocIcon, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
11497
11566
  //# sourceMappingURL=taxtank-core.js.map