taxtank-core 0.13.0 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/get'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('lodash/last'), require('lodash/uniqBy'), require('lodash/concat'), require('lodash/compact'), require('moment'), require('moment-range'), require('lodash/cloneDeep'), require('@angular/forms'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
- typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/get', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'lodash/last', 'lodash/uniqBy', 'lodash/concat', 'lodash/compact', 'moment', 'moment-range', 'lodash/cloneDeep', '@angular/forms', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.get, global.flatten, global.hasIn, global.first, global.last, global.uniqBy, global.concat, global.compact, global.moment, global.momentRange, global.cloneDeep$1, global.ng.forms, global._, global.eventsource_min_js, global.ng.router, global.clone, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
- })(this, (function (exports, i0, i2, i1, rxjs, operators, classTransformer, angularJwt, get, flatten, hasIn, first, last, uniqBy, concat, compact, moment, momentRange, cloneDeep$1, forms, _, eventsource_min_js, i1$1, clone, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/get'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('lodash/last'), require('lodash/compact'), require('lodash/uniqBy'), require('lodash/concat'), require('moment'), require('moment-range'), require('lodash/cloneDeep'), require('@angular/forms'), require('lodash/fromPairs'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
+ typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/get', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'lodash/last', 'lodash/compact', 'lodash/uniqBy', 'lodash/concat', 'moment', 'moment-range', 'lodash/cloneDeep', '@angular/forms', 'lodash/fromPairs', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.get, global.flatten, global.hasIn, global.first, global.last, global.compact, global.uniqBy, global.concat, global.moment, global.momentRange, global.cloneDeep$1, global.ng.forms, global.fromPairs, global._, global.eventsource_min_js, global.ng.router, global.clone, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
+ })(this, (function (exports, i0, i2, i1, rxjs, operators, classTransformer, angularJwt, get, flatten, hasIn, first, last, compact, uniqBy, concat, moment, momentRange, cloneDeep$1, forms, fromPairs, _, eventsource_min_js, i1$1, clone, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -32,11 +32,12 @@
32
32
  var hasIn__default = /*#__PURE__*/_interopDefaultLegacy(hasIn);
33
33
  var first__default = /*#__PURE__*/_interopDefaultLegacy(first);
34
34
  var last__default = /*#__PURE__*/_interopDefaultLegacy(last);
35
+ var compact__default = /*#__PURE__*/_interopDefaultLegacy(compact);
35
36
  var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
36
37
  var concat__default = /*#__PURE__*/_interopDefaultLegacy(concat);
37
- var compact__default = /*#__PURE__*/_interopDefaultLegacy(compact);
38
38
  var moment__namespace = /*#__PURE__*/_interopNamespace(moment);
39
39
  var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep$1);
40
+ var fromPairs__default = /*#__PURE__*/_interopDefaultLegacy(fromPairs);
40
41
  var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
41
42
  var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
42
43
  var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
@@ -1370,10 +1371,10 @@
1370
1371
  /**
1371
1372
  * Sort collection items by provided field
1372
1373
  */
1373
- Collection.prototype.sortBy = function (filed, isDesc) {
1374
- if (filed === void 0) { filed = 'id'; }
1374
+ Collection.prototype.sortBy = function (field, isDesc) {
1375
+ if (field === void 0) { field = 'id'; }
1375
1376
  if (isDesc === void 0) { isDesc = true; }
1376
- sort(this.items, filed, isDesc);
1377
+ sort(this.items, field, isDesc);
1377
1378
  };
1378
1379
  Collection.prototype.getByDateRange = function (from, to, dateField) {
1379
1380
  if (dateField === void 0) { dateField = 'date'; }
@@ -1385,7 +1386,7 @@
1385
1386
  var AccountSetupItemCollection = /** @class */ (function (_super) {
1386
1387
  __extends(AccountSetupItemCollection, _super);
1387
1388
  function AccountSetupItemCollection(items) {
1388
- var _this = _super.call(this, items) || this;
1389
+ var _this = _super.call(this, compact__default["default"](items)) || this;
1389
1390
  _this.sortBy('isCompleted', false);
1390
1391
  return _this;
1391
1392
  }
@@ -3038,6 +3039,7 @@
3038
3039
  UserRolesEnum["SUBSCRIPTION"] = "ROLE_USER_SUBSCRIPTION";
3039
3040
  UserRolesEnum["WORK_TANK"] = "ROLE_USER_WORK";
3040
3041
  UserRolesEnum["PROPERTY_TANK"] = "ROLE_USER_PROPERTY";
3042
+ UserRolesEnum["SOLE_TANK"] = "ROLE_USER_SOLE";
3041
3043
  UserRolesEnum["SWITCH_USER"] = "ROLE_PREVIOUS_ADMIN";
3042
3044
  })(exports.UserRolesEnum || (exports.UserRolesEnum = {}));
3043
3045
 
@@ -5373,6 +5375,42 @@
5373
5375
  return PropertyReportItemDepreciationCollection;
5374
5376
  }(PropertyReportItemCollection));
5375
5377
 
5378
+ /**
5379
+ * Vehicle expense for logbook section
5380
+ */
5381
+ var VehicleExpense = /** @class */ (function () {
5382
+ function VehicleExpense(amount, claimPercent, description) {
5383
+ this.amount = amount;
5384
+ this.claimPercent = claimPercent;
5385
+ this.description = description;
5386
+ }
5387
+ VehicleExpense.prototype.getClaimAmount = function () {
5388
+ return +(this.amount * (this.claimPercent / 100)).toFixed(2);
5389
+ };
5390
+ return VehicleExpense;
5391
+ }());
5392
+
5393
+ var VehicleExpenseCollection = /** @class */ (function (_super) {
5394
+ __extends(VehicleExpenseCollection, _super);
5395
+ function VehicleExpenseCollection(transactions, depreciations, vehicleClaim) {
5396
+ var _this = _super.call(this) || this;
5397
+ _this.setItems(transactions, depreciations, vehicleClaim);
5398
+ return _this;
5399
+ }
5400
+ VehicleExpenseCollection.prototype.setItems = function (transactions, depreciations, vehicleClaim) {
5401
+ var _a;
5402
+ this.items = [];
5403
+ var transactionsByChartAccounts = new CollectionDictionary(transactions, 'chartAccounts.name');
5404
+ var transactionExpenses = transactionsByChartAccounts.keys.map(function (chartAccountsName) {
5405
+ return new VehicleExpense(transactionsByChartAccounts.get(chartAccountsName).amount, vehicleClaim.workUsage, chartAccountsName);
5406
+ });
5407
+ // group all depreciations into one expense item
5408
+ var depreciationExpense = new VehicleExpense(depreciations.getCurrentYearForecastAmount(), vehicleClaim.workUsage, 'Depreciation');
5409
+ (_a = this.items).push.apply(_a, __spreadArray([depreciationExpense], __read(transactionExpenses)));
5410
+ };
5411
+ return VehicleExpenseCollection;
5412
+ }(Collection));
5413
+
5376
5414
  var ServiceSubscriptionCollection = /** @class */ (function (_super) {
5377
5415
  __extends(ServiceSubscriptionCollection, _super);
5378
5416
  function ServiceSubscriptionCollection() {
@@ -6345,6 +6383,7 @@
6345
6383
  */
6346
6384
  var AccountSetupItem = /** @class */ (function () {
6347
6385
  function AccountSetupItem() {
6386
+ this.clientIncomeTypes = [];
6348
6387
  }
6349
6388
  return AccountSetupItem;
6350
6389
  }());
@@ -8652,6 +8691,7 @@
8652
8691
  ROLE_USER_SUBSCRIPTION: [exports.UserRolesEnum.SUBSCRIPTION],
8653
8692
  ROLE_USER_WORK: [exports.UserRolesEnum.WORK_TANK],
8654
8693
  ROLE_USER_PROPERTY: [exports.UserRolesEnum.PROPERTY_TANK],
8694
+ ROLE_USER_SOLE: [exports.UserRolesEnum.SOLE_TANK],
8655
8695
  ROLE_PREVIOUS_ADMIN: [exports.UserRolesEnum.SWITCH_USER]
8656
8696
  };
8657
8697
 
@@ -8764,37 +8804,48 @@
8764
8804
  _a[AccountSetupItemsEnum.SALARY] = classTransformer.plainToClass(AccountSetupItem, {
8765
8805
  title: 'Add your work income forecast',
8766
8806
  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.',
8767
- url: '/client/work-tank/forecasting'
8807
+ url: '/client/work-tank/forecasting',
8808
+ urlFragment: 'salaryProductTour',
8809
+ clientIncomeTypes: ['salary']
8768
8810
  }),
8769
8811
  _a[AccountSetupItemsEnum.OTHER_INCOME] = classTransformer.plainToClass(AccountSetupItem, {
8770
8812
  title: 'Add any other expected incomes',
8771
8813
  description: 'To ensure an accurate tax position forecast, add estimates for any other income types, like dividends, interest, trusts, annuities, director payments etc.',
8772
- url: '/client/work-tank/forecasting'
8814
+ url: '/client/work-tank/forecasting',
8815
+ urlFragment: 'otherIncomeProductTour',
8816
+ clientIncomeTypes: ['dividends', 'other']
8773
8817
  }),
8774
8818
  _a[AccountSetupItemsEnum.PROPERTY] = classTransformer.plainToClass(AccountSetupItem, {
8775
8819
  title: 'Add your properties',
8776
8820
  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.',
8777
- url: '/client/property-tank'
8821
+ url: '/client/property-tank',
8822
+ urlFragment: 'productTour',
8823
+ clientIncomeTypes: ['property']
8778
8824
  }),
8779
8825
  _a[AccountSetupItemsEnum.BANK_FEEDS] = classTransformer.plainToClass(AccountSetupItem, {
8780
8826
  title: 'Link banks and select accounts',
8781
8827
  description: 'Link banks to automatically feed your account transactions to save you time and money. Allocating live transactions ensures nothing is missed, lost or forgotten!',
8782
- url: '/client/bank-feeds'
8828
+ url: '/client/bank-feeds',
8829
+ urlFragment: 'bankAccountProductTour',
8783
8830
  }),
8784
8831
  _a[AccountSetupItemsEnum.WORK_LOGBOOK] = classTransformer.plainToClass(AccountSetupItem, {
8785
8832
  title: 'Set up your logbook method',
8786
8833
  description: 'Do you use your vehicle for work? Select your method and the klms or logbook % to automate accurately all vehicle expenses throughout the year.',
8787
- url: '/client/work-tank/logbook'
8834
+ url: '/client/work-tank/logbook',
8835
+ urlFragment: 'productTour'
8788
8836
  }),
8789
8837
  _a[AccountSetupItemsEnum.SOLE_INCOME] = classTransformer.plainToClass(AccountSetupItem, {
8790
8838
  title: 'Add your business details',
8791
8839
  description: 'Add your business details, logo and payment terms to create invoice templates in minutes.',
8792
- url: '/client/sole-tank/forecasting'
8840
+ url: '/client/sole-tank/forecasting',
8841
+ urlFragment: 'productTour',
8842
+ clientIncomeTypes: ['sole']
8793
8843
  }),
8794
8844
  _a[AccountSetupItemsEnum.TRANSACTION] = classTransformer.plainToClass(AccountSetupItem, {
8795
8845
  title: 'Allocation transactions',
8796
8846
  description: 'Select one or multiple transactions, the category from the dropdown and attach your receipt. It’s that simple to capture every possible deduction, and keep organised all throughout the year.',
8797
- url: '/client/bank-feeds'
8847
+ url: '/client/bank-feeds',
8848
+ urlFragment: 'allocationProductTour',
8798
8849
  }),
8799
8850
  _a);
8800
8851
 
@@ -9510,7 +9561,11 @@
9510
9561
  */
9511
9562
  TransactionAllocationService.prototype.onTransactionsCreated = function () {
9512
9563
  var _this = this;
9513
- this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTIONS_CREATED).subscribe(function () {
9564
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTIONS_CREATED).subscribe(function (transactions) {
9565
+ // @TODO Alex hack: research and refactor cache update logic, dont reset cache each time transactions changed
9566
+ if (transactions[0].isTransfer) {
9567
+ return;
9568
+ }
9514
9569
  // Update allocations cache to synchronize data and fire subscriptions
9515
9570
  _this.resetCache();
9516
9571
  });
@@ -9521,6 +9576,7 @@
9521
9576
  TransactionAllocationService.prototype.onDepreciationCreated = function () {
9522
9577
  var _this = this;
9523
9578
  this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATIONS_CREATED).subscribe(function () {
9579
+ // @TODO Alex hack: research and refactor cache update logic, dont reset cache each time depreciations changed
9524
9580
  // Update allocations cache to synchronize data and fire subscriptions
9525
9581
  _this.resetCache();
9526
9582
  });
@@ -9531,6 +9587,7 @@
9531
9587
  TransactionAllocationService.prototype.onTransactionDeleted = function () {
9532
9588
  var _this = this;
9533
9589
  this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTION_DELETED).subscribe(function () {
9590
+ // @TODO Alex hack: research and refactor cache update logic, dont reset cache each time transactions changed
9534
9591
  // Update allocations cache to synchronize data and fire subscriptions
9535
9592
  _this.resetCache();
9536
9593
  });
@@ -9581,427 +9638,787 @@
9581
9638
  }]
9582
9639
  }] });
9583
9640
 
9641
+ function enumToList(data) {
9642
+ var list = [];
9643
+ for (var key in data) {
9644
+ if (Number(key) >= 0) {
9645
+ list.push({
9646
+ label: data[key],
9647
+ value: Number(key)
9648
+ });
9649
+ }
9650
+ }
9651
+ return list;
9652
+ }
9653
+
9654
+ var MessagesEnum;
9655
+ (function (MessagesEnum) {
9656
+ MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
9657
+ MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
9658
+ MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
9659
+ })(MessagesEnum || (MessagesEnum = {}));
9660
+
9584
9661
  /**
9585
- * Service handling user's account setup process.
9586
- * Checks required steps and their completion
9662
+ * Service for transactions business logic
9587
9663
  */
9588
- var AccountSetupService = /** @class */ (function () {
9589
- function AccountSetupService(clientIncomeTypesService, propertyService, incomeSourceService, bankAccountsService, transactionAllocationService, vehicleClaimService) {
9590
- this.clientIncomeTypesService = clientIncomeTypesService;
9591
- this.propertyService = propertyService;
9592
- this.incomeSourceService = incomeSourceService;
9593
- this.bankAccountsService = bankAccountsService;
9594
- this.transactionAllocationService = transactionAllocationService;
9595
- this.vehicleClaimService = vehicleClaimService;
9596
- this.cacheSubject = new rxjs.ReplaySubject(1);
9664
+ var TransactionService = /** @class */ (function (_super) {
9665
+ __extends(TransactionService, _super);
9666
+ function TransactionService() {
9667
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
9668
+ // url part for Transaction API
9669
+ _this.url = 'transactions';
9670
+ _this.modelClass = Transaction;
9671
+ _this.transactionDeleted = new i0.EventEmitter();
9672
+ return _this;
9597
9673
  }
9598
9674
  /**
9599
- * Get list of account setup items for current user
9675
+ * Listen events from Event Dispatcher services
9600
9676
  */
9601
- AccountSetupService.prototype.get = function () {
9677
+ TransactionService.prototype.listenEvents = function () {
9678
+ this.listenDepreciationChange();
9679
+ this.listenPropertyShareUpdate();
9680
+ };
9681
+ /**
9682
+ * get list of all user's TaxTank transactions
9683
+ */
9684
+ TransactionService.prototype.get = function () {
9602
9685
  var _this = this;
9603
9686
  if (!this.cache) {
9604
- this.clientIncomeTypesService.get().subscribe(function (incomeTypes) {
9605
- rxjs.combineLatest(_this.createBatch(incomeTypes)).subscribe(function (items) {
9606
- _this.cache = new AccountSetupItemCollection(items);
9607
- _this.cacheSubject.next(_this.cache);
9608
- });
9687
+ // set cache as default empty array to avoid multiple backend requests
9688
+ this.cache = [];
9689
+ this.fetch()
9690
+ .subscribe(function (transactions) {
9691
+ _this.cache = transactions;
9692
+ _this.updateCache();
9609
9693
  });
9610
9694
  }
9611
- return this.cacheSubject.asObservable();
9695
+ return this.cacheSubject.asObservable().pipe(
9696
+ // assign child transactions (fees) to parent transactions
9697
+ operators.map(function (transactions) {
9698
+ transactions.forEach(function (transaction) {
9699
+ transaction.transactions = transactions
9700
+ // get list of child transactions
9701
+ .filter(function (t) { return t.parentTransaction && t.parentTransaction.id === transaction.id; });
9702
+ });
9703
+ sort(transactions, 'date', false);
9704
+ return transactions;
9705
+ }));
9612
9706
  };
9613
9707
  /**
9614
- * Get a single AccountSetupItem and check it's completion
9708
+ * Add single new transaction
9709
+ * @param model New Transaction instance for saving
9615
9710
  */
9616
- AccountSetupService.prototype.create = function (itemType, request) {
9617
- return request.pipe(operators.map(function (result) {
9618
- var item = ACCOUNT_SETUP_ITEMS[itemType];
9619
- if (result.length) {
9620
- item.isCompleted = true;
9621
- }
9622
- return item;
9711
+ TransactionService.prototype.add = function (model) {
9712
+ var _this = this;
9713
+ // we don't have POST API endpoint for single transaction
9714
+ return this.addBatch([model])
9715
+ .pipe(operators.map(function (newTransactions) {
9716
+ // @TODO alex
9717
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_CREATED, newTransactions[0]));
9718
+ return newTransactions[0];
9623
9719
  }));
9624
9720
  };
9625
9721
  /**
9626
- * Get batch of requests to get list of required AccountSetupItem's.
9627
- * Some items are optional and depends of user's client income types
9722
+ * get transactions related with property
9628
9723
  */
9629
- AccountSetupService.prototype.createBatch = function (incomeTypes) {
9630
- var batch = [];
9631
- // Salary item is completed when user added salary income source
9632
- if (incomeTypes.salary) {
9633
- batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSourcesByType(exports.IncomeSourceTypeEnum.SALARY)));
9634
- }
9635
- // Other income item is completed when user added at least one other income source
9636
- if (incomeTypes.dividends || incomeTypes.other) {
9637
- batch.push(this.create(AccountSetupItemsEnum.OTHER_INCOME, this.getIncomeSourcesByType(exports.IncomeSourceTypeEnum.OTHER)));
9638
- }
9639
- // Rental income item is completed when user added at least one property
9640
- if (incomeTypes.property) {
9641
- batch.push(this.create(AccountSetupItemsEnum.PROPERTY, this.propertyService.get()));
9642
- }
9643
- // Bank feeds item is completed when user added at least one bank account (basiq or manual)
9644
- batch.push(this.create(AccountSetupItemsEnum.BANK_FEEDS, this.bankAccountsService.get()));
9645
- // Logbook item is completed when user has at least one vehicle claim with any method (klms or logbook)
9646
- batch.push(this.create(AccountSetupItemsEnum.WORK_LOGBOOK, this.vehicleClaimService.get()));
9647
- // @TODO waiting for sole tank forecast page
9648
- // Sole item is completed when user added at least one sole income source
9649
- // if (incomeTypes.soleTrader) {
9650
- // batch.push(
9651
- // this.prepareItem(
9652
- // AccountSetupItemsEnum.SOLE_INCOME,
9653
- // this.getIncomeSourcesByType(IncomeSourceTypeEnum.SOLE)
9654
- // )
9655
- // );
9656
- // }
9657
- // Allocation item is completed when user added at least one transaction allocation
9658
- batch.push(this.create(AccountSetupItemsEnum.TRANSACTION, this.transactionAllocationService.get()));
9659
- return batch;
9724
+ TransactionService.prototype.getByPropertyId = function (propertyId) {
9725
+ return this.get()
9726
+ .pipe(operators.map(function (transactions) {
9727
+ return transactions.filter(function (transaction) {
9728
+ var _a;
9729
+ return ((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id) === propertyId;
9730
+ });
9731
+ }));
9660
9732
  };
9661
9733
  /**
9662
- * @TODO work with collection when services refactored
9734
+ * get list of transactions with tank type 'Work'
9663
9735
  */
9664
- AccountSetupService.prototype.getIncomeSourcesByType = function (type) {
9665
- return this.incomeSourceService.get().pipe(operators.map(function (incomeSources) {
9666
- return new IncomeSourceCollection(incomeSources).getBy('type', type).toArray();
9736
+ TransactionService.prototype.getWorkTransactions = function () {
9737
+ return this.get()
9738
+ .pipe(operators.map(function (transactions) {
9739
+ return transactions.filter(function (transaction) { return transaction.isWorkTank(); });
9667
9740
  }));
9668
9741
  };
9669
- return AccountSetupService;
9670
- }());
9671
- AccountSetupService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AccountSetupService, deps: [{ token: ClientIncomeTypesService }, { token: PropertyService }, { token: IncomeSourceService }, { token: BankAccountService }, { token: TransactionAllocationService }, { token: VehicleClaimService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9672
- AccountSetupService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AccountSetupService, providedIn: 'root' });
9673
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AccountSetupService, decorators: [{
9674
- type: i0.Injectable,
9675
- args: [{
9676
- providedIn: 'root'
9677
- }]
9678
- }], ctorParameters: function () { return [{ type: ClientIncomeTypesService }, { type: PropertyService }, { type: IncomeSourceService }, { type: BankAccountService }, { type: TransactionAllocationService }, { type: VehicleClaimService }]; } });
9679
-
9680
- var AddressService = /** @class */ (function () {
9681
- function AddressService(http, environment) {
9682
- this.http = http;
9683
- this.environment = environment;
9684
- this.countriesSubject = new rxjs.ReplaySubject(1);
9685
- }
9686
- AddressService.prototype.getCountries = function () {
9687
- var _this = this;
9688
- if (!this._countries) {
9689
- this.http.get(this.environment.apiV2 + "/countries")
9690
- .pipe(operators.map(function (response) {
9691
- return response['hydra:member'].map(function (item) { return classTransformer.plainToClass(Country, item); });
9692
- }))
9693
- .subscribe(function (countries) {
9694
- _this._countries = countries;
9695
- _this.countriesSubject.next(countries);
9696
- });
9697
- }
9698
- return this.countriesSubject.asObservable();
9699
- };
9700
- return AddressService;
9701
- }());
9702
- AddressService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9703
- AddressService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, providedIn: 'root' });
9704
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, decorators: [{
9705
- type: i0.Injectable,
9706
- args: [{
9707
- providedIn: 'root'
9708
- }]
9709
- }], ctorParameters: function () {
9710
- return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
9711
- type: i0.Inject,
9712
- args: ['environment']
9713
- }] }];
9714
- } });
9715
-
9716
- /**
9717
- * Service to work with assets (documents, receipts, e.t.c.)
9718
- */
9719
- var AssetsService = /** @class */ (function () {
9720
- function AssetsService(http, userSwitcherService, environment) {
9721
- this.http = http;
9722
- this.userSwitcherService = userSwitcherService;
9723
- this.environment = environment;
9724
- this.impersonatedClient = this.userSwitcherService.get();
9725
- }
9726
9742
  /**
9727
- * Get asset link
9728
- * @param asset to get the link for
9743
+ * Get list of property holding costs (transactions related to vacant land property)
9729
9744
  */
9730
- AssetsService.prototype.getLink = function (asset) {
9731
- return this.http.get(this.environment.apiV2 + "/assets/" + asset.type + "/" + asset.id);
9745
+ TransactionService.prototype.getPropertyHoldingCosts = function (propertyId) {
9746
+ return this.http.get(this.environment.apiV2 + "/" + this.url + "?propertyId=" + propertyId + "&propertyCategoryId=" + exports.PropertyCategoryListEnum.VACANT_LAND)
9747
+ .pipe(operators.map(function (transactionsBase) {
9748
+ return transactionsBase.map(function (transactionBase) { return classTransformer.plainToClass(Transaction, transactionBase); });
9749
+ }));
9732
9750
  };
9733
9751
  /**
9734
- * Download asset
9735
- * @param asset which should be downloaded
9736
- * @TODO refactor
9752
+ * get list of taxable transactions with tank type 'Work'
9737
9753
  */
9738
- AssetsService.prototype.download = function (asset) {
9739
- return this.environment.apiV2 + "/assets/" + asset.type + "/" + asset.id + "/download?bearer=" + localStorage.getItem('token') + (this.impersonatedClient ? "&_switch_user=" + this.impersonatedClient : '');
9754
+ TransactionService.prototype.getTaxableWorkTransactions = function () {
9755
+ return this.getWorkTransactions()
9756
+ .pipe(operators.map(function (transactions) {
9757
+ return transactions.filter(function (transaction) { return !!transaction.chartAccounts.taxReturnItem; });
9758
+ }));
9740
9759
  };
9741
- // @Todo refactor to event dispatcher
9742
9760
  /**
9743
- * Delete asset
9744
- * @param entityId: id of asset main entity (property, folder, transaction, e.t.c.)
9745
- * @param asset which should be deleted
9761
+ * add multiple transactions
9762
+ * @param transactions List of new Transaction instances for saving
9746
9763
  */
9747
- AssetsService.prototype.delete = function (entityId, asset) {
9748
- return this.http.delete(this.environment.apiV2 + "/" + asset.entityType + "/" + entityId + "/" + asset.type + "/" + asset.id);
9749
- };
9750
- return AssetsService;
9751
- }());
9752
- AssetsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, deps: [{ token: i1__namespace.HttpClient }, { token: UserSwitcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9753
- AssetsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, providedIn: 'root' });
9754
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, decorators: [{
9755
- type: i0.Injectable,
9756
- args: [{
9757
- providedIn: 'root'
9758
- }]
9759
- }], ctorParameters: function () {
9760
- return [{ type: i1__namespace.HttpClient }, { type: UserSwitcherService }, { type: undefined, decorators: [{
9761
- type: i0.Inject,
9762
- args: ['environment']
9763
- }] }];
9764
- } });
9765
-
9766
- /**
9767
- * Service that handling banks logic
9768
- */
9769
- var BankService = /** @class */ (function (_super) {
9770
- __extends(BankService, _super);
9771
- function BankService() {
9772
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
9773
- _this.modelClass = Bank;
9774
- _this.url = 'banks';
9775
- _this.isHydra = true;
9776
- return _this;
9777
- }
9778
- return BankService;
9779
- }(RestService));
9780
- BankService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9781
- BankService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, providedIn: 'root' });
9782
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, decorators: [{
9783
- type: i0.Injectable,
9784
- args: [{
9785
- providedIn: 'root'
9786
- }]
9787
- }] });
9788
-
9789
- /**
9790
- * @TODO move to collection
9791
- */
9792
- var BankTransactionCalculationService = /** @class */ (function () {
9793
- function BankTransactionCalculationService() {
9794
- }
9795
- /**
9796
- * Sum of allocations for passed bank transactions
9797
- */
9798
- BankTransactionCalculationService.prototype.getAllocatedAmount = function (bankTransactions, allocations) {
9799
- return allocations.getByBankTransactionsIds(bankTransactions.getIds()).amount;
9764
+ TransactionService.prototype.addBatch = function (transactions) {
9765
+ var _this = this;
9766
+ transactions = ___default["default"].cloneDeep(transactions);
9767
+ return this.http.post(this.environment.apiV2 + "/" + this.url, transactions)
9768
+ .pipe(operators.map(function (response) {
9769
+ var _c;
9770
+ var addedTransactions = response.map(function (item) { return classTransformer.plainToClass(Transaction, item); });
9771
+ transactions.forEach(function (transaction, index) {
9772
+ // @TODO backend: need to upload file in the same backend endpoint with transaction add/update
9773
+ // check if passed receipt and upload file
9774
+ if (transaction.file) {
9775
+ transaction.id = response[index].id;
9776
+ addedTransactions[index].file = transaction.file;
9777
+ _this.uploadReceipt(addedTransactions[index]);
9778
+ }
9779
+ // @TODO Viktor: implement API for saving of nested transactions
9780
+ // add child transactions if exist
9781
+ if (transaction.transactions.length) {
9782
+ transaction.transactions.forEach(function (childTransaction) {
9783
+ childTransaction.parentTransaction = classTransformer.plainToClass(Transaction, { id: addedTransactions[index].id });
9784
+ });
9785
+ _this.addBatch(transaction.transactions).subscribe();
9786
+ }
9787
+ // add transfer transaction to cache
9788
+ if (transaction.operation === exports.TransactionOperationEnum.TRANSFER) {
9789
+ addedTransactions.push(addedTransactions[0].transfer);
9790
+ }
9791
+ });
9792
+ if (_this.cache) {
9793
+ (_c = _this.cache).push.apply(_c, __spreadArray([], __read(addedTransactions)));
9794
+ _this.updateCache();
9795
+ }
9796
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
9797
+ _this.toastService.success(MessagesEnum.CREATED_MESSAGE);
9798
+ return addedTransactions;
9799
+ }));
9800
9800
  };
9801
9801
  /**
9802
- * Difference between total bank transactions amount and sum of allocations for passed bank transactions
9802
+ * update existing transaction
9803
+ * @param transaction Transaction instance for updating
9803
9804
  */
9804
- BankTransactionCalculationService.prototype.getUnallocatedAmount = function (bankTransactionCollection, allocations) {
9805
- return bankTransactionCollection.getAmount() - allocations.amount;
9805
+ TransactionService.prototype.update = function (transaction) {
9806
+ var _this = this;
9807
+ return this.http.put(this.environment.apiV2 + "/" + this.url + "/" + transaction.id, transaction)
9808
+ .pipe(operators.map(function (response) {
9809
+ var updatedTransaction = classTransformer.plainToClass(Transaction, response);
9810
+ // @TODO need to upload file in the same backend endpoint with transaction add/update
9811
+ // check if passed new receipt and upload file
9812
+ if (transaction.file) {
9813
+ updatedTransaction.file = transaction.file;
9814
+ _this.uploadReceipt(updatedTransaction);
9815
+ }
9816
+ // @TODO Viktor: implement API for saving of nested transactions
9817
+ if (transaction.transactions.length) {
9818
+ // add parent transaction to child transactions
9819
+ transaction.transactions.forEach(function (childTransaction) {
9820
+ childTransaction.parentTransaction = classTransformer.plainToClass(Transaction, { id: updatedTransaction.id });
9821
+ });
9822
+ // separate child transactions by id existing to define add or update action.
9823
+ var childTransactionsToUpdate = transaction.transactions.filter(function (t) { return t.id; });
9824
+ var childTransactionsToAdd = transaction.transactions.filter(function (t) { return !t.id; });
9825
+ // update child transactions
9826
+ if (childTransactionsToUpdate.length) {
9827
+ _this.updateBatch(childTransactionsToUpdate).subscribe();
9828
+ }
9829
+ // add child transactions
9830
+ if (childTransactionsToAdd.length) {
9831
+ _this.addBatch(childTransactionsToAdd).subscribe();
9832
+ }
9833
+ }
9834
+ _this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
9835
+ replace(_this.cache, updatedTransaction);
9836
+ _this.updateCache();
9837
+ return updatedTransaction;
9838
+ }));
9806
9839
  };
9807
9840
  /**
9808
- * Check if bank transaction is allocated
9841
+ * update multiple transactions
9842
+ * @param transactions list of transactions for updating
9809
9843
  */
9810
- BankTransactionCalculationService.prototype.isAllocated = function (bankTransaction, allocations) {
9811
- return bankTransaction.amount === this.getAllocatedAmount(new BankTransactionCollection([bankTransaction]), allocations);
9844
+ TransactionService.prototype.updateBatch = function (transactions) {
9845
+ var _this = this;
9846
+ return this.http.put(this.environment.apiV2 + "/" + this.url, transactions)
9847
+ .pipe(operators.map(function (response) {
9848
+ var updatedTransactions = response.map(function (item) { return classTransformer.plainToClass(Transaction, item); });
9849
+ updatedTransactions.forEach(function (updatedTransaction) {
9850
+ replace(_this.cache, updatedTransaction);
9851
+ });
9852
+ _this.updateCache();
9853
+ return updatedTransactions;
9854
+ }));
9812
9855
  };
9813
9856
  /**
9814
- * Get collection of allocated bank transactions
9815
- * @TODO Alex: consider to move to collection
9857
+ * delete transaction and related transactions
9858
+ * @param model
9816
9859
  */
9817
- BankTransactionCalculationService.prototype.getAllocatedBankTransactions = function (bankTransactions, allocations) {
9860
+ TransactionService.prototype.delete = function (model) {
9818
9861
  var _this = this;
9819
- return new BankTransactionCollection(bankTransactions.items.filter(function (bankTransaction) {
9820
- return _this.isAllocated(bankTransaction, allocations);
9862
+ return this.http.delete(this.environment.apiV2 + "/" + this.url + "/" + model.id)
9863
+ .pipe(operators.map(function () {
9864
+ _this.cache = _this.cache.filter(function (transaction) {
9865
+ var _a;
9866
+ // when delete transfer we delete actually 2 transactions
9867
+ if (model.isTransfer) {
9868
+ var ids = [model.id];
9869
+ // get id of related transfer transaction
9870
+ if (model.transfer) {
9871
+ // just take id if we delete source transaction
9872
+ ids.push(model.transfer.id);
9873
+ }
9874
+ else {
9875
+ // find source transaction id if we delete destination transaction
9876
+ ids.push(_this.cache.find(function (t) { return t.transfer.id === model.id; }).id);
9877
+ }
9878
+ return !ids.includes(transaction.id);
9879
+ }
9880
+ return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
9881
+ });
9882
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_DELETED, model));
9883
+ _this.toastService.success(MessagesEnum.DELETED_MESSAGE);
9884
+ _this.updateCache();
9885
+ _this.transactionDeleted.emit(model);
9821
9886
  }));
9822
9887
  };
9823
9888
  /**
9824
- * Get collection of unallocated bank transactions
9825
- * @TODO Alex: consider to move to collection
9889
+ * upload transaction receipt image
9890
+ * @param transaction Еhe transaction for which the receipt will be imported
9826
9891
  */
9827
- BankTransactionCalculationService.prototype.getUnallocatedBankTransactions = function (bankTransactions, allocations) {
9892
+ TransactionService.prototype.uploadReceipt = function (transaction) {
9828
9893
  var _this = this;
9829
- return new BankTransactionCollection(bankTransactions.items.filter(function (bankTransaction) {
9830
- return !_this.isAllocated(bankTransaction, allocations);
9831
- }));
9894
+ var formData = new FormData();
9895
+ formData.append('file', transaction.file);
9896
+ transaction.receipt = null;
9897
+ this.http.post(this.environment.apiV2 + "/" + this.url + "/" + transaction.id + "/receipts", formData)
9898
+ .subscribe(function (receiptResponse) {
9899
+ // we don't need to keep file after save
9900
+ transaction.file = null;
9901
+ transaction.receipt = classTransformer.plainToClass(TransactionReceipt, receiptResponse);
9902
+ replace(_this.cache, transaction);
9903
+ _this.updateCache();
9904
+ });
9832
9905
  };
9833
9906
  /**
9834
- * Allocated sum of credit transactions
9907
+ * calculate gross income amount based on transaction amount and taxes (fees)
9908
+ * @param transaction Transaction instance for calculation
9835
9909
  */
9836
- BankTransactionCalculationService.prototype.getCreditAmount = function (bankTransactions, allocations) {
9837
- return allocations.getByBankTransactionsIds(bankTransactions.creditTransactions.getIds()).amount;
9910
+ TransactionService.prototype.calculateGrossAmount = function (transaction) {
9911
+ var amount = transaction.amount || 0;
9912
+ // gross income amount includes amount of fees for property tank and tax for work tank
9913
+ if (transaction.isPropertyTank()) {
9914
+ amount += transaction.transactions.reduce(function (sum, item) { return sum + item.amount; }, 0);
9915
+ }
9916
+ else {
9917
+ // @TODO Alex: fix logic after TT-641 ready
9918
+ amount += (transaction.tax || 0);
9919
+ }
9920
+ return amount;
9838
9921
  };
9839
9922
  /**
9840
- * Allocated sum of debit transactions
9923
+ * get label for transaction tax field depended of selected chart account.
9924
+ * tax type depends of chart account heading or category.
9841
9925
  */
9842
- BankTransactionCalculationService.prototype.getDebitAmount = function (bankTransactions, allocations) {
9843
- return allocations.getByBankTransactionsIds(bankTransactions.debitTransactions.getIds()).amount;
9926
+ TransactionService.prototype.getTaxLabel = function (chartAccounts) {
9927
+ var _a, _b;
9928
+ // get simple array of ids from enum with taxable chart accounts headings
9929
+ var taxableCAHeadingsIds = enumToList(exports.ChartAccountsHeadingTaxableEnum)
9930
+ .map(function (item) { return item.value; });
9931
+ // get simple array of ids from enum with tax deductible chart accounts headings
9932
+ var deductibleCAHeadingsIds = enumToList(exports.ChartAccountsHeadingTaxDeductibleEnum)
9933
+ .map(function (item) { return item.value; });
9934
+ // check if one of ids arrays includes current chart accounts heading id and set tax label
9935
+ // otherwise label is empty for this class
9936
+ switch (true) {
9937
+ case taxableCAHeadingsIds.includes((_a = chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id):
9938
+ return exports.ChartAccountsTaxLabelsEnum.TAX_PAID;
9939
+ case deductibleCAHeadingsIds.includes((_b = chartAccounts.heading) === null || _b === void 0 ? void 0 : _b.id):
9940
+ return exports.ChartAccountsTaxLabelsEnum.TAX_DEDUCTED;
9941
+ case CHART_ACCOUNTS_CATEGORIES.workIncome.includes(chartAccounts.category):
9942
+ return exports.ChartAccountsTaxLabelsEnum.TAX_WITHHELD;
9943
+ default:
9944
+ return null;
9945
+ }
9844
9946
  };
9845
- return BankTransactionCalculationService;
9846
- }());
9847
- BankTransactionCalculationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionCalculationService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9848
- BankTransactionCalculationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionCalculationService, providedIn: 'root' });
9849
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionCalculationService, decorators: [{
9947
+ /**
9948
+ * Listen to EventDispatcherService event related to Depreciation changing
9949
+ */
9950
+ TransactionService.prototype.listenDepreciationChange = function () {
9951
+ var _this = this;
9952
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATION_DELETED).subscribe(function () {
9953
+ _this.fetch()
9954
+ .subscribe(function (transactions) {
9955
+ _this.cache = transactions;
9956
+ _this.updateCache();
9957
+ });
9958
+ });
9959
+ };
9960
+ /**
9961
+ * Listen to EventDispatcherService event related to Property Share changing
9962
+ */
9963
+ TransactionService.prototype.listenPropertyShareUpdate = function () {
9964
+ var _this = this;
9965
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(function () { return _this.resetCache(); });
9966
+ };
9967
+ return TransactionService;
9968
+ }(RestService));
9969
+ TransactionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9970
+ TransactionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, providedIn: 'root' });
9971
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, decorators: [{
9850
9972
  type: i0.Injectable,
9851
9973
  args: [{
9852
9974
  providedIn: 'root'
9853
9975
  }]
9854
9976
  }] });
9855
9977
 
9856
- var BankAccountCalculationService = /** @class */ (function () {
9857
- function BankAccountCalculationService(bankTransactionCalculationService) {
9858
- this.bankTransactionCalculationService = bankTransactionCalculationService;
9978
+ /**
9979
+ * Service handling user's account setup process.
9980
+ * Checks required steps and their completion
9981
+ */
9982
+ var AccountSetupService = /** @class */ (function () {
9983
+ function AccountSetupService(clientIncomeTypesService, propertyService, incomeSourceService, bankAccountsService, transactionAllocationService, vehicleClaimService, transactionService) {
9984
+ this.clientIncomeTypesService = clientIncomeTypesService;
9985
+ this.propertyService = propertyService;
9986
+ this.incomeSourceService = incomeSourceService;
9987
+ this.bankAccountsService = bankAccountsService;
9988
+ this.transactionAllocationService = transactionAllocationService;
9989
+ this.vehicleClaimService = vehicleClaimService;
9990
+ this.transactionService = transactionService;
9991
+ this.cacheSubject = new rxjs.ReplaySubject(1);
9859
9992
  }
9860
9993
  /**
9861
- * Sum of bank accounts opening balances and their bank transactions allocated amounts
9994
+ * Get list of account setup items for current user
9862
9995
  */
9863
- BankAccountCalculationService.prototype.getTaxTankBalance = function (bankAccounts, bankTransactions, allocations) {
9864
- return bankAccounts.getOpeningBalance() +
9865
- this.bankTransactionCalculationService.getAllocatedAmount(bankTransactions.getByBankAccountsIds(bankAccounts.getIds()), allocations);
9996
+ AccountSetupService.prototype.get = function () {
9997
+ var _this = this;
9998
+ if (!this.cache) {
9999
+ this.clientIncomeTypesService.get().subscribe(function (incomeTypes) {
10000
+ _this.clientIncomeTypesId = incomeTypes.id;
10001
+ rxjs.combineLatest(_this.createBatch(incomeTypes)).subscribe(function (items) {
10002
+ _this.cache = new AccountSetupItemCollection(items);
10003
+ _this.cacheSubject.next(_this.cache);
10004
+ });
10005
+ });
10006
+ }
10007
+ return this.cacheSubject.asObservable();
9866
10008
  };
9867
10009
  /**
9868
- * get difference between total loans amount and total cash amount
10010
+ * Prepare client income types to update to hide depended account setup items
9869
10011
  */
9870
- BankAccountCalculationService.prototype.getNetPosition = function (bankAccounts, bankTransactions, allocations) {
9871
- return bankAccounts.currentBalance - this.getTaxTankBalance(bankAccounts.getLoanAccounts(), bankTransactions, allocations);
10012
+ AccountSetupService.prototype.prepareIncomeTypes = function (item) {
10013
+ return classTransformer.plainToClass(ClientIncomeTypes, Object.assign({ id: this.clientIncomeTypesId }, fromPairs__default["default"](item.clientIncomeTypes.map(function (type) { return [type, false]; }))));
9872
10014
  };
9873
- return BankAccountCalculationService;
10015
+ /**
10016
+ * Get a single AccountSetupItem and check it's completion
10017
+ */
10018
+ AccountSetupService.prototype.create = function (itemType, request) {
10019
+ return request.pipe(operators.map(function (result) {
10020
+ var item = ACCOUNT_SETUP_ITEMS[itemType];
10021
+ if (result.length) {
10022
+ item.isCompleted = true;
10023
+ }
10024
+ return item;
10025
+ }));
10026
+ };
10027
+ /**
10028
+ * Get batch of requests to get list of required AccountSetupItem's.
10029
+ * Some items are optional and depends of user's client income types
10030
+ */
10031
+ AccountSetupService.prototype.createBatch = function (incomeTypes) {
10032
+ var batch = [];
10033
+ // Salary item is completed when user added salary income source
10034
+ if (incomeTypes.salary) {
10035
+ batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSourcesByType(exports.IncomeSourceTypeEnum.SALARY)));
10036
+ }
10037
+ // Other income item is completed when user added at least one other income source
10038
+ if (incomeTypes.dividends || incomeTypes.other) {
10039
+ batch.push(this.create(AccountSetupItemsEnum.OTHER_INCOME, this.getIncomeSourcesByType(exports.IncomeSourceTypeEnum.OTHER)));
10040
+ }
10041
+ // Rental income item is completed when user added at least one property
10042
+ if (incomeTypes.property) {
10043
+ batch.push(this.create(AccountSetupItemsEnum.PROPERTY, this.propertyService.get()));
10044
+ }
10045
+ // Bank feeds item is completed when user added at least one bank account (basiq or manual)
10046
+ batch.push(this.create(AccountSetupItemsEnum.BANK_FEEDS, this.bankAccountsService.get()));
10047
+ // Logbook item is completed when user has at least one vehicle claim with any method (klms or logbook)
10048
+ batch.push(this.getLogbookItem());
10049
+ // @TODO waiting for sole tank forecast page
10050
+ // Sole item is completed when user added at least one sole income source
10051
+ // if (incomeTypes.soleTrader) {
10052
+ // batch.push(
10053
+ // this.prepareItem(
10054
+ // AccountSetupItemsEnum.SOLE_INCOME,
10055
+ // this.getIncomeSourcesByType(IncomeSourceTypeEnum.SOLE)
10056
+ // )
10057
+ // );
10058
+ // }
10059
+ // Allocation item is completed when user added at least one transaction allocation
10060
+ batch.push(this.create(AccountSetupItemsEnum.TRANSACTION, this.transactionAllocationService.get()));
10061
+ return batch;
10062
+ };
10063
+ /**
10064
+ * @TODO work with collection when services refactored
10065
+ */
10066
+ AccountSetupService.prototype.getIncomeSourcesByType = function (type) {
10067
+ return this.incomeSourceService.get().pipe(operators.map(function (incomeSources) {
10068
+ return new IncomeSourceCollection(incomeSources).getBy('type', type).toArray();
10069
+ }));
10070
+ };
10071
+ /**
10072
+ * Show logbook item when user has at least 1 vehicle transaction
10073
+ */
10074
+ AccountSetupService.prototype.getLogbookItem = function () {
10075
+ return rxjs.combineLatest([
10076
+ this.transactionService.get(),
10077
+ this.create(AccountSetupItemsEnum.WORK_LOGBOOK, this.vehicleClaimService.get())
10078
+ ]).pipe(operators.map(function (_a) {
10079
+ var _b = __read(_a, 2), transactions = _b[0], item = _b[1];
10080
+ if (new TransactionCollection(transactions).getVehicleTransactions().length) {
10081
+ return item;
10082
+ }
10083
+ return null;
10084
+ }));
10085
+ };
10086
+ return AccountSetupService;
9874
10087
  }());
9875
- BankAccountCalculationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountCalculationService, deps: [{ token: BankTransactionCalculationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9876
- BankAccountCalculationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountCalculationService, providedIn: 'root' });
9877
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountCalculationService, decorators: [{
10088
+ AccountSetupService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AccountSetupService, deps: [{ token: ClientIncomeTypesService }, { token: PropertyService }, { token: IncomeSourceService }, { token: BankAccountService }, { token: TransactionAllocationService }, { token: VehicleClaimService }, { token: TransactionService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10089
+ AccountSetupService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AccountSetupService, providedIn: 'root' });
10090
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AccountSetupService, decorators: [{
9878
10091
  type: i0.Injectable,
9879
10092
  args: [{
9880
10093
  providedIn: 'root'
9881
10094
  }]
9882
- }], ctorParameters: function () { return [{ type: BankTransactionCalculationService }]; } });
10095
+ }], ctorParameters: function () { return [{ type: ClientIncomeTypesService }, { type: PropertyService }, { type: IncomeSourceService }, { type: BankAccountService }, { type: TransactionAllocationService }, { type: VehicleClaimService }, { type: TransactionService }]; } });
9883
10096
 
9884
- /**
9885
- * BankConnection means user account at specific bank (usually each user has only one at the same bank)
9886
- * service handles BankConnection management
9887
- */
9888
- var BankConnectionService = /** @class */ (function (_super) {
9889
- __extends(BankConnectionService, _super);
9890
- function BankConnectionService() {
9891
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
9892
- _this.modelClass = BankConnection;
9893
- _this.url = 'bank-connections';
9894
- return _this;
10097
+ var AddressService = /** @class */ (function () {
10098
+ function AddressService(http, environment) {
10099
+ this.http = http;
10100
+ this.environment = environment;
10101
+ this.countriesSubject = new rxjs.ReplaySubject(1);
9895
10102
  }
9896
- BankConnectionService.prototype.listenEvents = function () {
9897
- this.listenToAddedBankAccounts();
9898
- };
9899
- BankConnectionService.prototype.post = function (bankConnection) {
9900
- var _this = this;
9901
- return this.http.post(this.environment.apiV2 + "/" + this.url, bankConnection)
9902
- .pipe(operators.map(function (bankConnectionBase) {
9903
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.BANK_CONNECTION_ADDED, null));
9904
- return classTransformer.plainToClass(BankConnection, bankConnectionBase);
9905
- }));
9906
- };
9907
- BankConnectionService.prototype.listenToAddedBankAccounts = function () {
10103
+ AddressService.prototype.getCountries = function () {
9908
10104
  var _this = this;
9909
- this.eventDispatcherService.on(exports.AppEventTypeEnum.BANK_ACCOUNT_CREATED).subscribe(function () {
9910
- _this.resetCache();
9911
- });
10105
+ if (!this._countries) {
10106
+ this.http.get(this.environment.apiV2 + "/countries")
10107
+ .pipe(operators.map(function (response) {
10108
+ return response['hydra:member'].map(function (item) { return classTransformer.plainToClass(Country, item); });
10109
+ }))
10110
+ .subscribe(function (countries) {
10111
+ _this._countries = countries;
10112
+ _this.countriesSubject.next(countries);
10113
+ });
10114
+ }
10115
+ return this.countriesSubject.asObservable();
9912
10116
  };
9913
- return BankConnectionService;
9914
- }(RestService));
9915
- BankConnectionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankConnectionService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9916
- BankConnectionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankConnectionService, providedIn: 'root' });
9917
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankConnectionService, decorators: [{
10117
+ return AddressService;
10118
+ }());
10119
+ AddressService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10120
+ AddressService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, providedIn: 'root' });
10121
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, decorators: [{
9918
10122
  type: i0.Injectable,
9919
10123
  args: [{
9920
10124
  providedIn: 'root'
9921
10125
  }]
9922
- }] });
10126
+ }], ctorParameters: function () {
10127
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
10128
+ type: i0.Inject,
10129
+ args: ['environment']
10130
+ }] }];
10131
+ } });
9923
10132
 
9924
10133
  /**
9925
- * Service for bank transactions business logic
10134
+ * Service to work with assets (documents, receipts, e.t.c.)
9926
10135
  */
9927
- var BankTransactionService = /** @class */ (function (_super) {
9928
- __extends(BankTransactionService, _super);
9929
- function BankTransactionService() {
9930
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
9931
- // url part for BankTransaction API
9932
- _this.url = 'bank-transactions';
9933
- _this.modelClass = BankTransaction;
9934
- return _this;
10136
+ var AssetsService = /** @class */ (function () {
10137
+ function AssetsService(http, userSwitcherService, environment) {
10138
+ this.http = http;
10139
+ this.userSwitcherService = userSwitcherService;
10140
+ this.environment = environment;
10141
+ this.impersonatedClient = this.userSwitcherService.get();
9935
10142
  }
9936
- BankTransactionService.prototype.listenEvents = function () {
9937
- this.listenBankTransactionsImport();
9938
- };
9939
- ;
9940
10143
  /**
9941
- * get list of bank transactions for passed bank account id
9942
- * @param bankAccountId Id of bank account we search bank transactions for
10144
+ * Get asset link
10145
+ * @param asset to get the link for
9943
10146
  */
9944
- BankTransactionService.prototype.getByBankAccountId = function (bankAccountId) {
9945
- return this.get()
9946
- .pipe(operators.map(function (bankTransactions) {
9947
- return bankTransactions.filter(function (bankTransaction) { return bankTransaction.bankAccount.id === bankAccountId; });
9948
- }));
10147
+ AssetsService.prototype.getLink = function (asset) {
10148
+ return this.http.get(this.environment.apiV2 + "/assets/" + asset.type + "/" + asset.id);
9949
10149
  };
9950
10150
  /**
9951
- * Get list of bank transactions for provided financial year
9952
- * @TODO VIK/Alex: consider to use one endpoint to get bank transactions for 2 fin years
10151
+ * Download asset
10152
+ * @param asset which should be downloaded
10153
+ * @TODO refactor
9953
10154
  */
9954
- BankTransactionService.prototype.getTransactionsByYear = function (finYear) {
9955
- return this.http.get(this.environment.apiV2 + "/bank-transactions?financialYear=" + finYear)
9956
- .pipe(operators.map(function (bankTransactionsBase) {
9957
- return bankTransactionsBase.map(function (bankTransaction) { return classTransformer.plainToClass(BankTransaction, bankTransaction); });
9958
- }));
10155
+ AssetsService.prototype.download = function (asset) {
10156
+ return this.environment.apiV2 + "/assets/" + asset.type + "/" + asset.id + "/download?bearer=" + localStorage.getItem('token') + (this.impersonatedClient ? "&_switch_user=" + this.impersonatedClient : '');
9959
10157
  };
10158
+ // @Todo refactor to event dispatcher
9960
10159
  /**
9961
- * import bank transactions from csv file
9962
- * @param bankAccountId Bank account id we import bank transactions for
9963
- * @param file File with bank transactions for import
10160
+ * Delete asset
10161
+ * @param entityId: id of asset main entity (property, folder, transaction, e.t.c.)
10162
+ * @param asset which should be deleted
9964
10163
  */
9965
- BankTransactionService.prototype.import = function (bankAccountId, file) {
9966
- var _this = this;
9967
- var formData = new FormData();
9968
- formData.append('file', file);
9969
- return this.http.post(this.environment.apiV2 + "/bank-accounts/" + bankAccountId + "/bank-transaction-imports", formData)
9970
- .pipe(operators.map(function (response) {
9971
- var _a;
9972
- var newBankTransactions = response.map(function (bankTransaction) { return classTransformer.plainToClass(BankTransaction, bankTransaction); });
9973
- // push new items to cache only if we already have cache. Otherwise cache will contain only new items.
9974
- if (_this.cache) {
9975
- // just current year's transactions should be added
9976
- (_a = _this.cache).push.apply(_a, __spreadArray([], __read(newBankTransactions.filter(function (bt) { return new FinancialYear().includes(bt.date); }))));
9977
- _this.updateCache();
9978
- }
9979
- return newBankTransactions;
9980
- }));
9981
- };
9982
- BankTransactionService.prototype.listenBankTransactionsImport = function () {
9983
- var _this = this;
9984
- this.eventDispatcherService.on(exports.AppEventTypeEnum.NOTIFICATION_ADDED).subscribe(function (notification) {
9985
- if (!notification.isRead && notification.eventType === exports.UserEventTypeClientTypeEnum.BASIQ_FIRST_IMPORT_COMPLETE) {
9986
- _this.resetCache();
9987
- }
9988
- });
10164
+ AssetsService.prototype.delete = function (entityId, asset) {
10165
+ return this.http.delete(this.environment.apiV2 + "/" + asset.entityType + "/" + entityId + "/" + asset.type + "/" + asset.id);
9989
10166
  };
9990
- return BankTransactionService;
9991
- }(RestService));
9992
- BankTransactionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9993
- BankTransactionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionService, providedIn: 'root' });
9994
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionService, decorators: [{
10167
+ return AssetsService;
10168
+ }());
10169
+ AssetsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, deps: [{ token: i1__namespace.HttpClient }, { token: UserSwitcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10170
+ AssetsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, providedIn: 'root' });
10171
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, decorators: [{
9995
10172
  type: i0.Injectable,
9996
10173
  args: [{
9997
10174
  providedIn: 'root'
9998
10175
  }]
9999
- }] });
10000
-
10001
- /**
10002
- * basiq is a middleman between bank and user
10003
- * service is responsible for fetching bank related information
10004
- */
10176
+ }], ctorParameters: function () {
10177
+ return [{ type: i1__namespace.HttpClient }, { type: UserSwitcherService }, { type: undefined, decorators: [{
10178
+ type: i0.Inject,
10179
+ args: ['environment']
10180
+ }] }];
10181
+ } });
10182
+
10183
+ /**
10184
+ * Service that handling banks logic
10185
+ */
10186
+ var BankService = /** @class */ (function (_super) {
10187
+ __extends(BankService, _super);
10188
+ function BankService() {
10189
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
10190
+ _this.modelClass = Bank;
10191
+ _this.url = 'banks';
10192
+ _this.isHydra = true;
10193
+ return _this;
10194
+ }
10195
+ return BankService;
10196
+ }(RestService));
10197
+ BankService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
10198
+ BankService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, providedIn: 'root' });
10199
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, decorators: [{
10200
+ type: i0.Injectable,
10201
+ args: [{
10202
+ providedIn: 'root'
10203
+ }]
10204
+ }] });
10205
+
10206
+ /**
10207
+ * @TODO move to collection
10208
+ */
10209
+ var BankTransactionCalculationService = /** @class */ (function () {
10210
+ function BankTransactionCalculationService() {
10211
+ }
10212
+ /**
10213
+ * Sum of allocations for passed bank transactions
10214
+ */
10215
+ BankTransactionCalculationService.prototype.getAllocatedAmount = function (bankTransactions, allocations) {
10216
+ return allocations.getByBankTransactionsIds(bankTransactions.getIds()).amount;
10217
+ };
10218
+ /**
10219
+ * Difference between total bank transactions amount and sum of allocations for passed bank transactions
10220
+ */
10221
+ BankTransactionCalculationService.prototype.getUnallocatedAmount = function (bankTransactionCollection, allocations) {
10222
+ return bankTransactionCollection.getAmount() - allocations.amount;
10223
+ };
10224
+ /**
10225
+ * Check if bank transaction is allocated
10226
+ */
10227
+ BankTransactionCalculationService.prototype.isAllocated = function (bankTransaction, allocations) {
10228
+ return bankTransaction.amount === this.getAllocatedAmount(new BankTransactionCollection([bankTransaction]), allocations);
10229
+ };
10230
+ /**
10231
+ * Get collection of allocated bank transactions
10232
+ * @TODO Alex: consider to move to collection
10233
+ */
10234
+ BankTransactionCalculationService.prototype.getAllocatedBankTransactions = function (bankTransactions, allocations) {
10235
+ var _this = this;
10236
+ return new BankTransactionCollection(bankTransactions.items.filter(function (bankTransaction) {
10237
+ return _this.isAllocated(bankTransaction, allocations);
10238
+ }));
10239
+ };
10240
+ /**
10241
+ * Get collection of unallocated bank transactions
10242
+ * @TODO Alex: consider to move to collection
10243
+ */
10244
+ BankTransactionCalculationService.prototype.getUnallocatedBankTransactions = function (bankTransactions, allocations) {
10245
+ var _this = this;
10246
+ return new BankTransactionCollection(bankTransactions.items.filter(function (bankTransaction) {
10247
+ return !_this.isAllocated(bankTransaction, allocations);
10248
+ }));
10249
+ };
10250
+ /**
10251
+ * Allocated sum of credit transactions
10252
+ */
10253
+ BankTransactionCalculationService.prototype.getCreditAmount = function (bankTransactions, allocations) {
10254
+ return allocations.getByBankTransactionsIds(bankTransactions.creditTransactions.getIds()).amount;
10255
+ };
10256
+ /**
10257
+ * Allocated sum of debit transactions
10258
+ */
10259
+ BankTransactionCalculationService.prototype.getDebitAmount = function (bankTransactions, allocations) {
10260
+ return allocations.getByBankTransactionsIds(bankTransactions.debitTransactions.getIds()).amount;
10261
+ };
10262
+ return BankTransactionCalculationService;
10263
+ }());
10264
+ BankTransactionCalculationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionCalculationService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10265
+ BankTransactionCalculationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionCalculationService, providedIn: 'root' });
10266
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionCalculationService, decorators: [{
10267
+ type: i0.Injectable,
10268
+ args: [{
10269
+ providedIn: 'root'
10270
+ }]
10271
+ }] });
10272
+
10273
+ var BankAccountCalculationService = /** @class */ (function () {
10274
+ function BankAccountCalculationService(bankTransactionCalculationService) {
10275
+ this.bankTransactionCalculationService = bankTransactionCalculationService;
10276
+ }
10277
+ /**
10278
+ * Sum of bank accounts opening balances and their bank transactions allocated amounts
10279
+ */
10280
+ BankAccountCalculationService.prototype.getTaxTankBalance = function (bankAccounts, bankTransactions, allocations) {
10281
+ return bankAccounts.getOpeningBalance() +
10282
+ this.bankTransactionCalculationService.getAllocatedAmount(bankTransactions.getByBankAccountsIds(bankAccounts.getIds()), allocations);
10283
+ };
10284
+ /**
10285
+ * get difference between total loans amount and total cash amount
10286
+ */
10287
+ BankAccountCalculationService.prototype.getNetPosition = function (bankAccounts, bankTransactions, allocations) {
10288
+ return bankAccounts.currentBalance - this.getTaxTankBalance(bankAccounts.getLoanAccounts(), bankTransactions, allocations);
10289
+ };
10290
+ return BankAccountCalculationService;
10291
+ }());
10292
+ BankAccountCalculationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountCalculationService, deps: [{ token: BankTransactionCalculationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10293
+ BankAccountCalculationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountCalculationService, providedIn: 'root' });
10294
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountCalculationService, decorators: [{
10295
+ type: i0.Injectable,
10296
+ args: [{
10297
+ providedIn: 'root'
10298
+ }]
10299
+ }], ctorParameters: function () { return [{ type: BankTransactionCalculationService }]; } });
10300
+
10301
+ /**
10302
+ * BankConnection means user account at specific bank (usually each user has only one at the same bank)
10303
+ * service handles BankConnection management
10304
+ */
10305
+ var BankConnectionService = /** @class */ (function (_super) {
10306
+ __extends(BankConnectionService, _super);
10307
+ function BankConnectionService() {
10308
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
10309
+ _this.modelClass = BankConnection;
10310
+ _this.url = 'bank-connections';
10311
+ return _this;
10312
+ }
10313
+ BankConnectionService.prototype.listenEvents = function () {
10314
+ this.listenToAddedBankAccounts();
10315
+ };
10316
+ BankConnectionService.prototype.post = function (bankConnection) {
10317
+ var _this = this;
10318
+ return this.http.post(this.environment.apiV2 + "/" + this.url, bankConnection)
10319
+ .pipe(operators.map(function (bankConnectionBase) {
10320
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.BANK_CONNECTION_ADDED, null));
10321
+ return classTransformer.plainToClass(BankConnection, bankConnectionBase);
10322
+ }));
10323
+ };
10324
+ BankConnectionService.prototype.listenToAddedBankAccounts = function () {
10325
+ var _this = this;
10326
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.BANK_ACCOUNT_CREATED).subscribe(function () {
10327
+ _this.resetCache();
10328
+ });
10329
+ };
10330
+ return BankConnectionService;
10331
+ }(RestService));
10332
+ BankConnectionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankConnectionService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
10333
+ BankConnectionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankConnectionService, providedIn: 'root' });
10334
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankConnectionService, decorators: [{
10335
+ type: i0.Injectable,
10336
+ args: [{
10337
+ providedIn: 'root'
10338
+ }]
10339
+ }] });
10340
+
10341
+ /**
10342
+ * Service for bank transactions business logic
10343
+ */
10344
+ var BankTransactionService = /** @class */ (function (_super) {
10345
+ __extends(BankTransactionService, _super);
10346
+ function BankTransactionService() {
10347
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
10348
+ // url part for BankTransaction API
10349
+ _this.url = 'bank-transactions';
10350
+ _this.modelClass = BankTransaction;
10351
+ return _this;
10352
+ }
10353
+ BankTransactionService.prototype.listenEvents = function () {
10354
+ this.listenBankTransactionsImport();
10355
+ };
10356
+ ;
10357
+ /**
10358
+ * get list of bank transactions for passed bank account id
10359
+ * @param bankAccountId Id of bank account we search bank transactions for
10360
+ */
10361
+ BankTransactionService.prototype.getByBankAccountId = function (bankAccountId) {
10362
+ return this.get()
10363
+ .pipe(operators.map(function (bankTransactions) {
10364
+ return bankTransactions.filter(function (bankTransaction) { return bankTransaction.bankAccount.id === bankAccountId; });
10365
+ }));
10366
+ };
10367
+ /**
10368
+ * Get list of bank transactions for provided financial year
10369
+ * @TODO VIK/Alex: consider to use one endpoint to get bank transactions for 2 fin years
10370
+ */
10371
+ BankTransactionService.prototype.getTransactionsByYear = function (finYear) {
10372
+ return this.http.get(this.environment.apiV2 + "/bank-transactions?financialYear=" + finYear)
10373
+ .pipe(operators.map(function (bankTransactionsBase) {
10374
+ return bankTransactionsBase.map(function (bankTransaction) { return classTransformer.plainToClass(BankTransaction, bankTransaction); });
10375
+ }));
10376
+ };
10377
+ /**
10378
+ * import bank transactions from csv file
10379
+ * @param bankAccountId Bank account id we import bank transactions for
10380
+ * @param file File with bank transactions for import
10381
+ */
10382
+ BankTransactionService.prototype.import = function (bankAccountId, file) {
10383
+ var _this = this;
10384
+ var formData = new FormData();
10385
+ formData.append('file', file);
10386
+ return this.http.post(this.environment.apiV2 + "/bank-accounts/" + bankAccountId + "/bank-transaction-imports", formData)
10387
+ .pipe(operators.map(function (response) {
10388
+ var _a;
10389
+ var newBankTransactions = response.map(function (bankTransaction) { return classTransformer.plainToClass(BankTransaction, bankTransaction); });
10390
+ // push new items to cache only if we already have cache. Otherwise cache will contain only new items.
10391
+ if (_this.cache) {
10392
+ // just current year's transactions should be added
10393
+ (_a = _this.cache).push.apply(_a, __spreadArray([], __read(newBankTransactions.filter(function (bt) { return new FinancialYear().includes(bt.date); }))));
10394
+ _this.updateCache();
10395
+ }
10396
+ return newBankTransactions;
10397
+ }));
10398
+ };
10399
+ BankTransactionService.prototype.listenBankTransactionsImport = function () {
10400
+ var _this = this;
10401
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.NOTIFICATION_ADDED).subscribe(function (notification) {
10402
+ if (!notification.isRead && notification.eventType === exports.UserEventTypeClientTypeEnum.BASIQ_FIRST_IMPORT_COMPLETE) {
10403
+ _this.resetCache();
10404
+ }
10405
+ });
10406
+ };
10407
+ return BankTransactionService;
10408
+ }(RestService));
10409
+ BankTransactionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
10410
+ BankTransactionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionService, providedIn: 'root' });
10411
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionService, decorators: [{
10412
+ type: i0.Injectable,
10413
+ args: [{
10414
+ providedIn: 'root'
10415
+ }]
10416
+ }] });
10417
+
10418
+ /**
10419
+ * basiq is a middleman between bank and user
10420
+ * service is responsible for fetching bank related information
10421
+ */
10005
10422
  var BasiqService = /** @class */ (function (_super) {
10006
10423
  __extends(BasiqService, _super);
10007
10424
  function BasiqService() {
@@ -11845,343 +12262,6 @@
11845
12262
  }]
11846
12263
  }] });
11847
12264
 
11848
- function enumToList(data) {
11849
- var list = [];
11850
- for (var key in data) {
11851
- if (Number(key) >= 0) {
11852
- list.push({
11853
- label: data[key],
11854
- value: Number(key)
11855
- });
11856
- }
11857
- }
11858
- return list;
11859
- }
11860
-
11861
- var MessagesEnum;
11862
- (function (MessagesEnum) {
11863
- MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
11864
- MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
11865
- MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
11866
- })(MessagesEnum || (MessagesEnum = {}));
11867
-
11868
- /**
11869
- * Service for transactions business logic
11870
- */
11871
- var TransactionService = /** @class */ (function (_super) {
11872
- __extends(TransactionService, _super);
11873
- function TransactionService() {
11874
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11875
- // url part for Transaction API
11876
- _this.url = 'transactions';
11877
- _this.modelClass = Transaction;
11878
- _this.transactionDeleted = new i0.EventEmitter();
11879
- return _this;
11880
- }
11881
- /**
11882
- * Listen events from Event Dispatcher services
11883
- */
11884
- TransactionService.prototype.listenEvents = function () {
11885
- this.listenDepreciationChange();
11886
- this.listenPropertyShareUpdate();
11887
- };
11888
- /**
11889
- * get list of all user's TaxTank transactions
11890
- */
11891
- TransactionService.prototype.get = function () {
11892
- var _this = this;
11893
- if (!this.cache) {
11894
- // set cache as default empty array to avoid multiple backend requests
11895
- this.cache = [];
11896
- this.fetch()
11897
- .subscribe(function (transactions) {
11898
- _this.cache = transactions;
11899
- _this.updateCache();
11900
- });
11901
- }
11902
- return this.cacheSubject.asObservable().pipe(
11903
- // assign child transactions (fees) to parent transactions
11904
- operators.map(function (transactions) {
11905
- transactions.forEach(function (transaction) {
11906
- transaction.transactions = transactions
11907
- // get list of child transactions
11908
- .filter(function (t) { return t.parentTransaction && t.parentTransaction.id === transaction.id; });
11909
- });
11910
- sort(transactions, 'date', false);
11911
- return transactions;
11912
- }));
11913
- };
11914
- /**
11915
- * Add single new transaction
11916
- * @param model New Transaction instance for saving
11917
- */
11918
- TransactionService.prototype.add = function (model) {
11919
- var _this = this;
11920
- // we don't have POST API endpoint for single transaction
11921
- return this.addBatch([model])
11922
- .pipe(operators.map(function (newTransactions) {
11923
- // @TODO alex
11924
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_CREATED, newTransactions[0]));
11925
- return newTransactions[0];
11926
- }));
11927
- };
11928
- /**
11929
- * get transactions related with property
11930
- */
11931
- TransactionService.prototype.getByPropertyId = function (propertyId) {
11932
- return this.get()
11933
- .pipe(operators.map(function (transactions) {
11934
- return transactions.filter(function (transaction) {
11935
- var _a;
11936
- return ((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id) === propertyId;
11937
- });
11938
- }));
11939
- };
11940
- /**
11941
- * get list of transactions with tank type 'Work'
11942
- */
11943
- TransactionService.prototype.getWorkTransactions = function () {
11944
- return this.get()
11945
- .pipe(operators.map(function (transactions) {
11946
- return transactions.filter(function (transaction) { return transaction.isWorkTank(); });
11947
- }));
11948
- };
11949
- /**
11950
- * Get list of property holding costs (transactions related to vacant land property)
11951
- */
11952
- TransactionService.prototype.getPropertyHoldingCosts = function (propertyId) {
11953
- return this.http.get(this.environment.apiV2 + "/" + this.url + "?propertyId=" + propertyId + "&propertyCategoryId=" + exports.PropertyCategoryListEnum.VACANT_LAND)
11954
- .pipe(operators.map(function (transactionsBase) {
11955
- return transactionsBase.map(function (transactionBase) { return classTransformer.plainToClass(Transaction, transactionBase); });
11956
- }));
11957
- };
11958
- /**
11959
- * get list of taxable transactions with tank type 'Work'
11960
- */
11961
- TransactionService.prototype.getTaxableWorkTransactions = function () {
11962
- return this.getWorkTransactions()
11963
- .pipe(operators.map(function (transactions) {
11964
- return transactions.filter(function (transaction) { return !!transaction.chartAccounts.taxReturnItem; });
11965
- }));
11966
- };
11967
- /**
11968
- * add multiple transactions
11969
- * @param transactions List of new Transaction instances for saving
11970
- */
11971
- TransactionService.prototype.addBatch = function (transactions) {
11972
- var _this = this;
11973
- transactions = ___default["default"].cloneDeep(transactions);
11974
- return this.http.post(this.environment.apiV2 + "/" + this.url, transactions)
11975
- .pipe(operators.map(function (response) {
11976
- var _c;
11977
- var addedTransactions = response.map(function (item) { return classTransformer.plainToClass(Transaction, item); });
11978
- transactions.forEach(function (transaction, index) {
11979
- // @TODO backend: need to upload file in the same backend endpoint with transaction add/update
11980
- // check if passed receipt and upload file
11981
- if (transaction.file) {
11982
- transaction.id = response[index].id;
11983
- addedTransactions[index].file = transaction.file;
11984
- _this.uploadReceipt(addedTransactions[index]);
11985
- }
11986
- // @TODO Viktor: implement API for saving of nested transactions
11987
- // add child transactions if exist
11988
- if (transaction.transactions.length) {
11989
- transaction.transactions.forEach(function (childTransaction) {
11990
- childTransaction.parentTransaction = classTransformer.plainToClass(Transaction, { id: addedTransactions[index].id });
11991
- });
11992
- _this.addBatch(transaction.transactions).subscribe();
11993
- }
11994
- // add transfer transaction to cache
11995
- if (transaction.operation === exports.TransactionOperationEnum.TRANSFER) {
11996
- addedTransactions.push(addedTransactions[0].transfer);
11997
- }
11998
- });
11999
- if (_this.cache) {
12000
- (_c = _this.cache).push.apply(_c, __spreadArray([], __read(addedTransactions)));
12001
- _this.updateCache();
12002
- }
12003
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
12004
- _this.toastService.success(MessagesEnum.CREATED_MESSAGE);
12005
- return addedTransactions;
12006
- }));
12007
- };
12008
- /**
12009
- * update existing transaction
12010
- * @param transaction Transaction instance for updating
12011
- */
12012
- TransactionService.prototype.update = function (transaction) {
12013
- var _this = this;
12014
- return this.http.put(this.environment.apiV2 + "/" + this.url + "/" + transaction.id, transaction)
12015
- .pipe(operators.map(function (response) {
12016
- var updatedTransaction = classTransformer.plainToClass(Transaction, response);
12017
- // @TODO need to upload file in the same backend endpoint with transaction add/update
12018
- // check if passed new receipt and upload file
12019
- if (transaction.file) {
12020
- updatedTransaction.file = transaction.file;
12021
- _this.uploadReceipt(updatedTransaction);
12022
- }
12023
- // @TODO Viktor: implement API for saving of nested transactions
12024
- if (transaction.transactions.length) {
12025
- // add parent transaction to child transactions
12026
- transaction.transactions.forEach(function (childTransaction) {
12027
- childTransaction.parentTransaction = classTransformer.plainToClass(Transaction, { id: updatedTransaction.id });
12028
- });
12029
- // separate child transactions by id existing to define add or update action.
12030
- var childTransactionsToUpdate = transaction.transactions.filter(function (t) { return t.id; });
12031
- var childTransactionsToAdd = transaction.transactions.filter(function (t) { return !t.id; });
12032
- // update child transactions
12033
- if (childTransactionsToUpdate.length) {
12034
- _this.updateBatch(childTransactionsToUpdate).subscribe();
12035
- }
12036
- // add child transactions
12037
- if (childTransactionsToAdd.length) {
12038
- _this.addBatch(childTransactionsToAdd).subscribe();
12039
- }
12040
- }
12041
- _this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
12042
- replace(_this.cache, updatedTransaction);
12043
- _this.updateCache();
12044
- return updatedTransaction;
12045
- }));
12046
- };
12047
- /**
12048
- * update multiple transactions
12049
- * @param transactions list of transactions for updating
12050
- */
12051
- TransactionService.prototype.updateBatch = function (transactions) {
12052
- var _this = this;
12053
- return this.http.put(this.environment.apiV2 + "/" + this.url, transactions)
12054
- .pipe(operators.map(function (response) {
12055
- var updatedTransactions = response.map(function (item) { return classTransformer.plainToClass(Transaction, item); });
12056
- updatedTransactions.forEach(function (updatedTransaction) {
12057
- replace(_this.cache, updatedTransaction);
12058
- });
12059
- _this.updateCache();
12060
- return updatedTransactions;
12061
- }));
12062
- };
12063
- /**
12064
- * delete transaction and related transactions
12065
- * @param model
12066
- */
12067
- TransactionService.prototype.delete = function (model) {
12068
- var _this = this;
12069
- return this.http.delete(this.environment.apiV2 + "/" + this.url + "/" + model.id)
12070
- .pipe(operators.map(function () {
12071
- _this.cache = _this.cache.filter(function (transaction) {
12072
- var _a;
12073
- // when delete transfer we delete actually 2 transactions
12074
- if (model.isTransfer) {
12075
- var ids = [model.id];
12076
- // get id of related transfer transaction
12077
- if (model.transfer) {
12078
- // just take id if we delete source transaction
12079
- ids.push(model.transfer.id);
12080
- }
12081
- else {
12082
- // find source transaction id if we delete destination transaction
12083
- ids.push(_this.cache.find(function (t) { return t.transfer.id === model.id; }).id);
12084
- }
12085
- return !ids.includes(transaction.id);
12086
- }
12087
- return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
12088
- });
12089
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_DELETED, model));
12090
- _this.toastService.success(MessagesEnum.DELETED_MESSAGE);
12091
- _this.updateCache();
12092
- _this.transactionDeleted.emit(model);
12093
- }));
12094
- };
12095
- /**
12096
- * upload transaction receipt image
12097
- * @param transaction Еhe transaction for which the receipt will be imported
12098
- */
12099
- TransactionService.prototype.uploadReceipt = function (transaction) {
12100
- var _this = this;
12101
- var formData = new FormData();
12102
- formData.append('file', transaction.file);
12103
- transaction.receipt = null;
12104
- this.http.post(this.environment.apiV2 + "/" + this.url + "/" + transaction.id + "/receipts", formData)
12105
- .subscribe(function (receiptResponse) {
12106
- // we don't need to keep file after save
12107
- transaction.file = null;
12108
- transaction.receipt = classTransformer.plainToClass(TransactionReceipt, receiptResponse);
12109
- replace(_this.cache, transaction);
12110
- _this.updateCache();
12111
- });
12112
- };
12113
- /**
12114
- * calculate gross income amount based on transaction amount and taxes (fees)
12115
- * @param transaction Transaction instance for calculation
12116
- */
12117
- TransactionService.prototype.calculateGrossAmount = function (transaction) {
12118
- var amount = transaction.amount || 0;
12119
- // gross income amount includes amount of fees for property tank and tax for work tank
12120
- if (transaction.isPropertyTank()) {
12121
- amount += transaction.transactions.reduce(function (sum, item) { return sum + item.amount; }, 0);
12122
- }
12123
- else {
12124
- // @TODO Alex: fix logic after TT-641 ready
12125
- amount += (transaction.tax || 0);
12126
- }
12127
- return amount;
12128
- };
12129
- /**
12130
- * get label for transaction tax field depended of selected chart account.
12131
- * tax type depends of chart account heading or category.
12132
- */
12133
- TransactionService.prototype.getTaxLabel = function (chartAccounts) {
12134
- var _a, _b;
12135
- // get simple array of ids from enum with taxable chart accounts headings
12136
- var taxableCAHeadingsIds = enumToList(exports.ChartAccountsHeadingTaxableEnum)
12137
- .map(function (item) { return item.value; });
12138
- // get simple array of ids from enum with tax deductible chart accounts headings
12139
- var deductibleCAHeadingsIds = enumToList(exports.ChartAccountsHeadingTaxDeductibleEnum)
12140
- .map(function (item) { return item.value; });
12141
- // check if one of ids arrays includes current chart accounts heading id and set tax label
12142
- // otherwise label is empty for this class
12143
- switch (true) {
12144
- case taxableCAHeadingsIds.includes((_a = chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id):
12145
- return exports.ChartAccountsTaxLabelsEnum.TAX_PAID;
12146
- case deductibleCAHeadingsIds.includes((_b = chartAccounts.heading) === null || _b === void 0 ? void 0 : _b.id):
12147
- return exports.ChartAccountsTaxLabelsEnum.TAX_DEDUCTED;
12148
- case CHART_ACCOUNTS_CATEGORIES.workIncome.includes(chartAccounts.category):
12149
- return exports.ChartAccountsTaxLabelsEnum.TAX_WITHHELD;
12150
- default:
12151
- return null;
12152
- }
12153
- };
12154
- /**
12155
- * Listen to EventDispatcherService event related to Depreciation changing
12156
- */
12157
- TransactionService.prototype.listenDepreciationChange = function () {
12158
- var _this = this;
12159
- this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATION_DELETED).subscribe(function () {
12160
- _this.fetch()
12161
- .subscribe(function (transactions) {
12162
- _this.cache = transactions;
12163
- _this.updateCache();
12164
- });
12165
- });
12166
- };
12167
- /**
12168
- * Listen to EventDispatcherService event related to Property Share changing
12169
- */
12170
- TransactionService.prototype.listenPropertyShareUpdate = function () {
12171
- var _this = this;
12172
- this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(function () { return _this.resetCache(); });
12173
- };
12174
- return TransactionService;
12175
- }(RestService));
12176
- TransactionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
12177
- TransactionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, providedIn: 'root' });
12178
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, decorators: [{
12179
- type: i0.Injectable,
12180
- args: [{
12181
- providedIn: 'root'
12182
- }]
12183
- }] });
12184
-
12185
12265
  /**
12186
12266
  * Service to handle Property transactions report items data (get income / expense report items, e.t.c.)
12187
12267
  */
@@ -14079,6 +14159,8 @@
14079
14159
  exports.VehicleClaimForm = VehicleClaimForm;
14080
14160
  exports.VehicleClaimService = VehicleClaimService;
14081
14161
  exports.VehicleCollection = VehicleCollection;
14162
+ exports.VehicleExpense = VehicleExpense;
14163
+ exports.VehicleExpenseCollection = VehicleExpenseCollection;
14082
14164
  exports.VehicleForm = VehicleForm;
14083
14165
  exports.VehicleLogbook = VehicleLogbook;
14084
14166
  exports.VehicleLogbookCollection = VehicleLogbookCollection;