taxtank-core 0.27.2 → 0.27.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/bundles/taxtank-core.umd.js +441 -199
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/chart-accounts.collection.js +3 -3
  4. package/esm2015/lib/collections/depreciation.collection.js +10 -9
  5. package/esm2015/lib/collections/transaction/transaction.collection.js +5 -2
  6. package/esm2015/lib/collections/vehicle/vehicle-claim.collection.js +2 -4
  7. package/esm2015/lib/collections/vehicle/vehicle-logbook.collection.js +15 -30
  8. package/esm2015/lib/db/Enums/depreciation-calculation.enum.js +2 -1
  9. package/esm2015/lib/db/Enums/sole-depreciation-method.enum.js +6 -0
  10. package/esm2015/lib/db/Models/sole/sole-business-activity.js +4 -0
  11. package/esm2015/lib/db/Models/sole/sole-business.js +1 -1
  12. package/esm2015/lib/db/Models/sole/sole-depreciation-method.js +4 -0
  13. package/esm2015/lib/db/Models/sole/sole-details.js +1 -1
  14. package/esm2015/lib/db/Models/user/user.js +1 -1
  15. package/esm2015/lib/forms/abstract.form.js +11 -5
  16. package/esm2015/lib/forms/bank/bank-account/bank-account-allocation.form.js +6 -3
  17. package/esm2015/lib/forms/sole/index.js +2 -1
  18. package/esm2015/lib/forms/sole/sole-business-allocations.form.js +2 -1
  19. package/esm2015/lib/forms/sole/sole-business.form.js +3 -3
  20. package/esm2015/lib/forms/sole/sole-depreciation-method.form.js +10 -0
  21. package/esm2015/lib/forms/sole/sole-invoice-template.form.js +2 -2
  22. package/esm2015/lib/forms/vehicle/vehicle-claim-details.form.js +3 -7
  23. package/esm2015/lib/forms/vehicle/vehicle-claim.form.js +8 -2
  24. package/esm2015/lib/forms/vehicle/vehicle-logbook.form.js +22 -15
  25. package/esm2015/lib/models/account-setup/account-setup-items.const.js +2 -2
  26. package/esm2015/lib/models/bank/bank-account.js +4 -1
  27. package/esm2015/lib/models/chart-accounts/chart-accounts.js +9 -9
  28. package/esm2015/lib/models/depreciation/depreciation-group.enum.js +2 -1
  29. package/esm2015/lib/models/depreciation/depreciation-groups.const.js +7 -2
  30. package/esm2015/lib/models/depreciation/depreciation.js +32 -25
  31. package/esm2015/lib/models/endpoint/endpoints.const.js +6 -4
  32. package/esm2015/lib/models/event/app-event-type.enum.js +33 -31
  33. package/esm2015/lib/models/financial-year/financial-year.js +2 -1
  34. package/esm2015/lib/models/report/depreciation/depreciation-report-item.js +2 -2
  35. package/esm2015/lib/models/report/my-tax/my-tax-deductions/my-tax-deductions.js +3 -3
  36. package/esm2015/lib/models/sole/index.js +3 -1
  37. package/esm2015/lib/models/sole/sole-business-activity.js +4 -0
  38. package/esm2015/lib/models/sole/sole-business.js +5 -1
  39. package/esm2015/lib/models/sole/sole-depreciation-method.js +8 -0
  40. package/esm2015/lib/models/sole/sole-invoice-template.js +5 -4
  41. package/esm2015/lib/models/transaction/transaction.js +3 -3
  42. package/esm2015/lib/models/vehicle/logbook-period.js +2 -1
  43. package/esm2015/lib/models/vehicle/vehicle-claim-details.js +12 -11
  44. package/esm2015/lib/models/vehicle/vehicle-claim.js +14 -13
  45. package/esm2015/lib/models/vehicle/vehicle-logbook.js +18 -5
  46. package/esm2015/lib/services/account-setup/account-setup.service.js +2 -2
  47. package/esm2015/lib/services/affiliate/rewardful/rewardful.service.js +34 -0
  48. package/esm2015/lib/services/http/depreciation/depreciation.service.js +19 -2
  49. package/esm2015/lib/services/http/property/property.service.js +8 -1
  50. package/esm2015/lib/services/http/sole/index.js +3 -1
  51. package/esm2015/lib/services/http/sole/sole-business-activity/sole-business-activity.service.js +21 -0
  52. package/esm2015/lib/services/http/sole/sole-depreciation-method/sole-depreciation-method.service.js +62 -0
  53. package/esm2015/lib/services/http/transaction/transaction.service.js +1 -2
  54. package/esm2015/lib/services/http/vehicle/vehicle-claim-details.service.js +7 -6
  55. package/esm2015/lib/services/http/vehicle/vehicle-claim.service.js +10 -10
  56. package/esm2015/lib/services/index.js +2 -1
  57. package/esm2015/public-api.js +2 -1
  58. package/fesm2015/taxtank-core.js +381 -189
  59. package/fesm2015/taxtank-core.js.map +1 -1
  60. package/lib/collections/chart-accounts.collection.d.ts +2 -2
  61. package/lib/collections/depreciation.collection.d.ts +2 -1
  62. package/lib/collections/transaction/transaction.collection.d.ts +2 -2
  63. package/lib/collections/vehicle/vehicle-claim.collection.d.ts +1 -3
  64. package/lib/collections/vehicle/vehicle-logbook.collection.d.ts +4 -9
  65. package/lib/db/Enums/depreciation-calculation.enum.d.ts +2 -1
  66. package/lib/db/Enums/sole-depreciation-method.enum.d.ts +4 -0
  67. package/lib/db/Models/sole/sole-business-activity.d.ts +6 -0
  68. package/lib/db/Models/sole/sole-business.d.ts +2 -1
  69. package/lib/db/Models/sole/sole-depreciation-method.d.ts +10 -0
  70. package/lib/db/Models/user/user.d.ts +1 -0
  71. package/lib/forms/abstract.form.d.ts +3 -1
  72. package/lib/forms/bank/bank-account/bank-account-allocation.form.d.ts +4 -2
  73. package/lib/forms/sole/index.d.ts +1 -0
  74. package/lib/forms/sole/sole-business-allocations.form.d.ts +1 -0
  75. package/lib/forms/sole/sole-business.form.d.ts +1 -1
  76. package/lib/forms/sole/sole-depreciation-method.form.d.ts +5 -0
  77. package/lib/forms/vehicle/vehicle-claim-details.form.d.ts +1 -6
  78. package/lib/forms/vehicle/vehicle-claim.form.d.ts +3 -0
  79. package/lib/forms/vehicle/vehicle-logbook.form.d.ts +4 -0
  80. package/lib/models/bank/bank-account.d.ts +2 -0
  81. package/lib/models/chart-accounts/chart-accounts.d.ts +6 -6
  82. package/lib/models/depreciation/depreciation-group.enum.d.ts +2 -1
  83. package/lib/models/depreciation/depreciation.d.ts +9 -16
  84. package/lib/models/event/app-event-type.enum.d.ts +32 -30
  85. package/lib/models/financial-year/financial-year.d.ts +1 -0
  86. package/lib/models/sole/index.d.ts +2 -0
  87. package/lib/models/sole/sole-business-activity.d.ts +3 -0
  88. package/lib/models/sole/sole-business.d.ts +2 -0
  89. package/lib/models/sole/sole-depreciation-method.d.ts +4 -0
  90. package/lib/models/sole/sole-invoice-template.d.ts +1 -1
  91. package/lib/models/transaction/transaction.d.ts +2 -2
  92. package/lib/models/vehicle/logbook-period.d.ts +1 -0
  93. package/lib/models/vehicle/vehicle-claim-details.d.ts +8 -2
  94. package/lib/models/vehicle/vehicle-claim.d.ts +6 -4
  95. package/lib/models/vehicle/vehicle-logbook.d.ts +8 -4
  96. package/lib/services/affiliate/rewardful/rewardful.service.d.ts +13 -0
  97. package/lib/services/http/depreciation/depreciation.service.d.ts +8 -0
  98. package/lib/services/http/property/property.service.d.ts +1 -0
  99. package/lib/services/http/sole/index.d.ts +2 -0
  100. package/lib/services/http/sole/sole-business-activity/sole-business-activity.service.d.ts +11 -0
  101. package/lib/services/http/sole/sole-depreciation-method/sole-depreciation-method.service.d.ts +23 -0
  102. package/lib/services/index.d.ts +1 -0
  103. package/package.json +1 -1
  104. package/public-api.d.ts +1 -0
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
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/last'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('moment'), require('moment-range'), require('lodash/uniqBy'), require('lodash/concat'), require('rxjs/internal/observable/throwError'), require('lodash/cloneDeep'), require('lodash/compact'), require('@angular/forms'), require('lodash/isEqual'), require('lodash/fromPairs'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('html2pdf.js'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
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/last', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'moment', 'moment-range', 'lodash/uniqBy', 'lodash/concat', 'rxjs/internal/observable/throwError', 'lodash/cloneDeep', 'lodash/compact', '@angular/forms', 'lodash/isEqual', 'lodash/fromPairs', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'html2pdf.js', '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.last, global.flatten, global.hasIn, global.first, global.moment, global.momentRange, global.uniqBy, global.concat, global.rxjs["internal/observable/throwError"], global.cloneDeep$1, global.compact, global.ng.forms, global.isEqual, global.fromPairs, global._, global.eventsource_min_js, global.ng.router, global.clone, global.html2pdf, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
- })(this, (function (exports, i0, i1$1, i1, rxjs, operators, classTransformer, angularJwt, get, last, flatten, hasIn, first, moment, momentRange, uniqBy, concat, throwError, cloneDeep$1, compact, forms, isEqual, fromPairs, _, eventsource_min_js, i1$2, clone, html2pdf, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
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.last, global.flatten, global.hasIn, global.first, global.moment$1, global.momentRange, global.uniqBy, global.concat, global.rxjs["internal/observable/throwError"], global.cloneDeep$1, global.compact, global.ng.forms, global.isEqual, global.fromPairs, global._, global.eventsource_min_js, global.ng.router, global.clone, global.html2pdf, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
+ })(this, (function (exports, i0, i1$1, i1, rxjs, operators, classTransformer, angularJwt, get, last, flatten, hasIn, first, moment$1, momentRange, uniqBy, concat, throwError, cloneDeep$1, compact, forms, isEqual, fromPairs, _, eventsource_min_js, i1$2, clone, html2pdf, 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,7 +32,7 @@
32
32
  var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
33
33
  var hasIn__default = /*#__PURE__*/_interopDefaultLegacy(hasIn);
34
34
  var first__default = /*#__PURE__*/_interopDefaultLegacy(first);
35
- var moment__namespace = /*#__PURE__*/_interopNamespace(moment);
35
+ var moment__namespace = /*#__PURE__*/_interopNamespace(moment$1);
36
36
  var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
37
37
  var concat__default = /*#__PURE__*/_interopDefaultLegacy(concat);
38
38
  var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep$1);
@@ -575,36 +575,38 @@
575
575
  AppEventTypeEnum[AppEventTypeEnum["MESSAGE_FILE_CREATED"] = 25] = "MESSAGE_FILE_CREATED";
576
576
  AppEventTypeEnum[AppEventTypeEnum["MESSAGE_FILE_DELETED"] = 26] = "MESSAGE_FILE_DELETED";
577
577
  AppEventTypeEnum[AppEventTypeEnum["NOTIFICATION_ADDED"] = 27] = "NOTIFICATION_ADDED";
578
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_UPDATED_WITH_DOCUMENT"] = 28] = "PROPERTY_UPDATED_WITH_DOCUMENT";
579
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_DOCUMENT_ADDED"] = 29] = "PROPERTY_DOCUMENT_ADDED";
580
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_CREATED"] = 30] = "PROPERTY_MOVEMENT_CREATED";
581
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_UPDATED"] = 31] = "PROPERTY_MOVEMENT_UPDATED";
582
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_DELETED"] = 32] = "PROPERTY_MOVEMENT_DELETED";
583
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SHARE_UPDATED"] = 33] = "PROPERTY_SHARE_UPDATED";
584
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_ADDED"] = 34] = "PROPERTY_SALE_ADDED";
585
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_DELETED"] = 35] = "PROPERTY_SALE_DELETED";
586
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 36] = "PROPERTY_SUBSCRIPTION_ADDED";
587
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 37] = "PROPERTY_SUBSCRIPTION_DELETED";
588
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 38] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
589
- AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 39] = "SERVICE_SUBSCRIPTION_UPDATED";
590
- AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 40] = "TAX_REVIEW_UPDATED";
591
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 41] = "TRANSACTION_CREATED";
592
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 42] = "TRANSACTION_DELETED";
593
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 43] = "TRANSACTION_UPDATED";
594
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_RECEIPT"] = 44] = "TRANSACTION_UPDATED_WITH_RECEIPT";
595
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_DELETED_RECEIPT"] = 45] = "TRANSACTION_UPDATED_WITH_DELETED_RECEIPT";
596
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_CREATED"] = 46] = "TRANSACTION_RECEIPT_CREATED";
597
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_DELETED"] = 47] = "TRANSACTION_RECEIPT_DELETED";
598
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 48] = "TRANSACTIONS_CREATED";
599
- AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 49] = "USER_UPDATED";
600
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 50] = "VEHICLE_CLAIM_UPDATED";
601
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 51] = "VEHICLE_CLAIM_CREATED";
602
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_UPDATED"] = 52] = "VEHICLE_CLAIM_DETAILS_UPDATED";
603
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_CREATED"] = 53] = "VEHICLE_CLAIM_DETAILS_CREATED";
604
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 54] = "VEHICLE_LOGBOOK_CREATED";
605
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 55] = "VEHICLE_LOGBOOK_UPDATED";
606
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 56] = "VEHICLE_LOGBOOK_DELETED";
607
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED"] = 57] = "VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED";
578
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_DEPRECIATION_CALCULATION_UPDATED"] = 28] = "PROPERTY_DEPRECIATION_CALCULATION_UPDATED";
579
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_UPDATED_WITH_DOCUMENT"] = 29] = "PROPERTY_UPDATED_WITH_DOCUMENT";
580
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_DOCUMENT_ADDED"] = 30] = "PROPERTY_DOCUMENT_ADDED";
581
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_CREATED"] = 31] = "PROPERTY_MOVEMENT_CREATED";
582
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_UPDATED"] = 32] = "PROPERTY_MOVEMENT_UPDATED";
583
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_DELETED"] = 33] = "PROPERTY_MOVEMENT_DELETED";
584
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SHARE_UPDATED"] = 34] = "PROPERTY_SHARE_UPDATED";
585
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_ADDED"] = 35] = "PROPERTY_SALE_ADDED";
586
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_DELETED"] = 36] = "PROPERTY_SALE_DELETED";
587
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 37] = "PROPERTY_SUBSCRIPTION_ADDED";
588
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 38] = "PROPERTY_SUBSCRIPTION_DELETED";
589
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 39] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
590
+ AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 40] = "SERVICE_SUBSCRIPTION_UPDATED";
591
+ AppEventTypeEnum[AppEventTypeEnum["SOLE_DEPRECIATION_METHOD_UPDATED"] = 41] = "SOLE_DEPRECIATION_METHOD_UPDATED";
592
+ AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 42] = "TAX_REVIEW_UPDATED";
593
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 43] = "TRANSACTION_CREATED";
594
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 44] = "TRANSACTION_DELETED";
595
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 45] = "TRANSACTION_UPDATED";
596
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_RECEIPT"] = 46] = "TRANSACTION_UPDATED_WITH_RECEIPT";
597
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_DELETED_RECEIPT"] = 47] = "TRANSACTION_UPDATED_WITH_DELETED_RECEIPT";
598
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_CREATED"] = 48] = "TRANSACTION_RECEIPT_CREATED";
599
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_DELETED"] = 49] = "TRANSACTION_RECEIPT_DELETED";
600
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 50] = "TRANSACTIONS_CREATED";
601
+ AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 51] = "USER_UPDATED";
602
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 52] = "VEHICLE_CLAIM_UPDATED";
603
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 53] = "VEHICLE_CLAIM_CREATED";
604
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_UPDATED"] = 54] = "VEHICLE_CLAIM_DETAILS_UPDATED";
605
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_CREATED"] = 55] = "VEHICLE_CLAIM_DETAILS_CREATED";
606
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 56] = "VEHICLE_LOGBOOK_CREATED";
607
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 57] = "VEHICLE_LOGBOOK_UPDATED";
608
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 58] = "VEHICLE_LOGBOOK_DELETED";
609
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED"] = 59] = "VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED";
608
610
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
609
611
 
610
612
  var EventDispatcherService = /** @class */ (function () {
@@ -1054,11 +1056,13 @@
1054
1056
  SUBSCRIPTION_ITEMS_PUT: new Endpoint('PUT', '\\/subscriptions\\/items'),
1055
1057
  SOLE_BUSINESSES_GET: new Endpoint('GET', '\\/sole-businesses'),
1056
1058
  SOLE_BUSINESSES_POST: new Endpoint('POST', '\\/sole-businesses'),
1057
- SOLE_BUSINESSES_PUT: new Endpoint('PUT', '\\/sole-businesses\\d+'),
1059
+ SOLE_BUSINESSES_PUT: new Endpoint('PUT', '\\/sole-businesses\\/\\d+'),
1060
+ SOLE_DEPRECIATION_METHODS_GET: new Endpoint('GET', '\\/sole-depreciation-methods'),
1061
+ SOLE_DEPRECIATION_METHODS_PUT: new Endpoint('PUT', '\\/sole-depreciation-methods\\/\\d+'),
1058
1062
  SOLE_INVOICE_TEMPLATES_GET: new Endpoint('GET', '\\/sole-invoice-templates'),
1059
1063
  SOLE_INVOICE_TEMPLATES_POST: new Endpoint('POST', '\\/sole-invoice-templates'),
1060
- SOLE_INVOICE_TEMPLATES_PUT: new Endpoint('PUT', '\\/sole-invoice-templates\\d+'),
1061
- SOLE_INVOICE_TEMPLATES_DELETE: new Endpoint('DELETE', '\\/sole-invoice-templates\\d+'),
1064
+ SOLE_INVOICE_TEMPLATES_PUT: new Endpoint('PUT', '\\/sole-invoice-templates\\/\\d+'),
1065
+ SOLE_INVOICE_TEMPLATES_DELETE: new Endpoint('DELETE', '\\/sole-invoice-templates\\/\\d+'),
1062
1066
  TAX_CALCULATION_POST: new Endpoint('POST', '\\/tax-calculation'),
1063
1067
  TAX_REVIEWS_GET: new Endpoint('GET', '\\/tax-reviews'),
1064
1068
  TAX_REVIEWS_DELETE: new Endpoint('DELETE', '\\/tax-reviews\\/\\d+'),
@@ -1670,6 +1674,7 @@
1670
1674
  };
1671
1675
  return FinancialYear;
1672
1676
  }());
1677
+ FinancialYear.weeksInYear = 52;
1673
1678
  FinancialYear.startMonthIndex = 6;
1674
1679
 
1675
1680
  /**
@@ -2979,26 +2984,26 @@
2979
2984
  return this.name;
2980
2985
  };
2981
2986
  /**
2982
- * Check if chart accounts id is related for 'Klms travelled for work' category
2987
+ * Check if chart accounts id is related for 'Kms travelled for work' category
2983
2988
  */
2984
- ChartAccounts.prototype.isKlmsForWork = function () {
2989
+ ChartAccounts.prototype.isKmsForWork = function () {
2985
2990
  return this.id === exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK;
2986
2991
  };
2987
2992
  /**
2988
- * Check if chart accounts id is related for 'Klms travelled for sole' category
2993
+ * Check if chart accounts id is related for 'Kms travelled for sole' category
2989
2994
  */
2990
- ChartAccounts.prototype.isKlmsForSole = function () {
2995
+ ChartAccounts.prototype.isKmsForSole = function () {
2991
2996
  return this.id === exports.ChartAccountsListEnum.KLMS_TRAVELLED;
2992
2997
  };
2993
2998
  /**
2994
- * Check if accounts id is related for KLMs category related to passed tank type
2999
+ * Check if accounts id is related for KMs category related to passed tank type
2995
3000
  */
2996
- ChartAccounts.prototype.isKLMsByTankType = function (tankType) {
3001
+ ChartAccounts.prototype.isKMsByTankType = function (tankType) {
2997
3002
  switch (tankType) {
2998
3003
  case exports.TankTypeEnum.WORK:
2999
- return this.isKlmsForWork();
3004
+ return this.isKmsForWork();
3000
3005
  case exports.TankTypeEnum.SOLE:
3001
- return this.isKlmsForSole();
3006
+ return this.isKmsForSole();
3002
3007
  default:
3003
3008
  return false;
3004
3009
  }
@@ -3186,11 +3191,10 @@
3186
3191
  var SoleInvoiceTemplate = /** @class */ (function (_super) {
3187
3192
  __extends(SoleInvoiceTemplate, _super);
3188
3193
  function SoleInvoiceTemplate() {
3189
- return _super !== null && _super.apply(this, arguments) || this;
3194
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
3195
+ _this.isTaxIncluded = false;
3196
+ return _this;
3190
3197
  }
3191
- SoleInvoiceTemplate.create = function (businessId) {
3192
- return classTransformer.plainToClass(SoleInvoiceTemplate, { business: { id: businessId }, isTaxIncluded: false });
3193
- };
3194
3198
  return SoleInvoiceTemplate;
3195
3199
  }(SoleInvoiceTemplate$1));
3196
3200
  __decorate([
@@ -3232,6 +3236,7 @@
3232
3236
  /**
3233
3237
  * Class contains traveled kilometers and work usage percent in 12 weeks date range
3234
3238
  * @TODO Vik: Best period: move this and related logic to backend
3239
+ * @TODO Alex: check if we need this class when calculation refactored with backend
3235
3240
  */
3236
3241
  var LogbookPeriod = /** @class */ (function () {
3237
3242
  function LogbookPeriod() {
@@ -3268,6 +3273,7 @@
3268
3273
  return VehicleLogbook;
3269
3274
  }(AbstractModel));
3270
3275
 
3276
+ var moment = momentRange.extendMoment(moment__namespace);
3271
3277
  var VehicleLogbook = /** @class */ (function (_super) {
3272
3278
  __extends(VehicleLogbook, _super);
3273
3279
  function VehicleLogbook() {
@@ -3293,14 +3299,19 @@
3293
3299
  VehicleLogbook.prototype.isSoleTank = function () {
3294
3300
  return !!this.business;
3295
3301
  };
3302
+ /**
3303
+ * Get logbook period date range from logbook date and weeksInPeriod duration
3304
+ */
3305
+ VehicleLogbook.prototype.getPeriod = function () {
3306
+ return moment.rangeFromInterval('weeks', VehicleLogbook.bestPeriodWeeks, this.date);
3307
+ };
3296
3308
  return VehicleLogbook;
3297
3309
  }(VehicleLogbook$1));
3298
3310
  /**
3299
- * 12 weeks in milliseconds
3300
- * "To work out your business-use percentage, you need to keep a logbook and the odometer readings for the logbook period.
3301
- * The logbook period is a minimum continuous period of 12 weeks." © Nicole Kelly
3311
+ * Logbook period duration in weeks.
3312
+ * https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/211517441/Logbook+Vehicle
3302
3313
  */
3303
- VehicleLogbook.periodDuration = 7257600000;
3314
+ VehicleLogbook.bestPeriodWeeks = 12;
3304
3315
  __decorate([
3305
3316
  classTransformer.Type(function () { return Date; })
3306
3317
  ], VehicleLogbook.prototype, "date", void 0);
@@ -3344,22 +3355,21 @@
3344
3355
  var VehicleClaimDetails = /** @class */ (function (_super) {
3345
3356
  __extends(VehicleClaimDetails, _super);
3346
3357
  function VehicleClaimDetails() {
3347
- return _super !== null && _super.apply(this, arguments) || this;
3358
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
3359
+ /**
3360
+ * Init default values for the new instances
3361
+ */
3362
+ _this.isManual = true;
3363
+ _this.method = exports.VehicleClaimDetailsMethodEnum.KMS;
3364
+ _this.financialYear = new FinancialYear().year;
3365
+ return _this;
3348
3366
  }
3349
3367
  VehicleClaimDetails.prototype.isLogbookMethod = function () {
3350
3368
  return this.method === exports.VehicleClaimDetailsMethodEnum.LOGBOOK;
3351
3369
  };
3352
- VehicleClaimDetails.prototype.isKlmsMethod = function () {
3370
+ VehicleClaimDetails.prototype.isKmsMethod = function () {
3353
3371
  return this.method === exports.VehicleClaimDetailsMethodEnum.KMS;
3354
3372
  };
3355
- // @TODO Alex: discuss with Vik and think about abstract method in AbstractModel
3356
- VehicleClaimDetails.create = function () {
3357
- return classTransformer.plainToClass(VehicleClaimDetails, {
3358
- isManual: true,
3359
- method: exports.VehicleClaimDetailsMethodEnum.KMS,
3360
- financialYear: new FinancialYear().year
3361
- });
3362
- };
3363
3373
  return VehicleClaimDetails;
3364
3374
  }(VehicleClaimDetails$1));
3365
3375
  __decorate([
@@ -3369,7 +3379,10 @@
3369
3379
  var VehicleClaim = /** @class */ (function (_super) {
3370
3380
  __extends(VehicleClaim, _super);
3371
3381
  function VehicleClaim() {
3372
- return _super !== null && _super.apply(this, arguments) || this;
3382
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
3383
+ _this.kilometers = 0;
3384
+ _this.workUsage = 0;
3385
+ return _this;
3373
3386
  }
3374
3387
  VehicleClaim.prototype.isWorkTank = function () {
3375
3388
  return !this.business;
@@ -3385,9 +3398,9 @@
3385
3398
  configurable: true
3386
3399
  });
3387
3400
  /**
3388
- * Claim amount for KLMs method. Exists only for KLMs method.
3401
+ * Claim amount for KMs method. Exists only for KMs method.
3389
3402
  */
3390
- VehicleClaim.prototype.getKLMsClaimAmount = function (vehicleClaimRate) {
3403
+ VehicleClaim.prototype.getKMSClaimAmount = function (vehicleClaimRate) {
3391
3404
  return +(this.kilometers * vehicleClaimRate).toFixed(2);
3392
3405
  };
3393
3406
  /**
@@ -3402,20 +3415,14 @@
3402
3415
  // Math.abs because amount will be negative (because we sum expenses), but we don't want negative percent value
3403
3416
  return Math.abs(transactionsAmount) * this.workUsage / 100;
3404
3417
  };
3405
- VehicleClaim.prototype.getKlmsChartAccountsIdByTankType = function (tankType) {
3406
- if (tankType === void 0) { tankType = this.tankType; }
3418
+ VehicleClaim.prototype.getAverageWeeklyKMS = function () {
3419
+ return this.kilometers / FinancialYear.weeksInYear;
3420
+ };
3421
+ VehicleClaim.getKMSChartAccountsIdByTankType = function (tankType) {
3407
3422
  return tankType === exports.TankTypeEnum.WORK
3408
3423
  ? exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK
3409
3424
  : exports.ChartAccountsListEnum.KLMS_TRAVELLED;
3410
3425
  };
3411
- VehicleClaim.create = function (details, business) {
3412
- return classTransformer.plainToClass(VehicleClaim, {
3413
- kilometers: 0,
3414
- workUsage: 0,
3415
- details: details,
3416
- business: business
3417
- });
3418
- };
3419
3426
  return VehicleClaim;
3420
3427
  }(VehicleClaim$1));
3421
3428
  /**
@@ -3520,6 +3527,7 @@
3520
3527
  DepreciationCalculationEnum[DepreciationCalculationEnum["CAPITAL"] = 3] = "CAPITAL";
3521
3528
  DepreciationCalculationEnum[DepreciationCalculationEnum["LVP"] = 4] = "LVP";
3522
3529
  DepreciationCalculationEnum[DepreciationCalculationEnum["AMORTISATION"] = 5] = "AMORTISATION";
3530
+ DepreciationCalculationEnum[DepreciationCalculationEnum["SBP"] = 6] = "SBP";
3523
3531
  })(exports.DepreciationCalculationEnum || (exports.DepreciationCalculationEnum = {}));
3524
3532
 
3525
3533
  var DepreciationCapitalProject$1 = /** @class */ (function (_super) {
@@ -4053,9 +4061,9 @@
4053
4061
  enumerable: false,
4054
4062
  configurable: true
4055
4063
  });
4056
- Object.defineProperty(Transaction.prototype, "isKlmsChartAccountsCategory", {
4064
+ Object.defineProperty(Transaction.prototype, "isKmsChartAccountsCategory", {
4057
4065
  /**
4058
- * Check if transaction has 'Klms travelled for work' chart accounts category
4066
+ * Check if transaction has 'Kms travelled for work' chart accounts category
4059
4067
  */
4060
4068
  get: function () {
4061
4069
  return this.chartAccounts.id === exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK;
@@ -4314,6 +4322,9 @@
4314
4322
  classTransformer.Type(function () { return Date; })
4315
4323
  ], BankTransaction.prototype, "date", void 0);
4316
4324
 
4325
+ /**
4326
+ * @TODO Alex: clarify grouping rules and refactor
4327
+ */
4317
4328
  var Depreciation = /** @class */ (function (_super) {
4318
4329
  __extends(Depreciation, _super);
4319
4330
  function Depreciation() {
@@ -4326,6 +4337,7 @@
4326
4337
  _this.amount = 0;
4327
4338
  return _this;
4328
4339
  }
4340
+ // Type checking
4329
4341
  Depreciation.prototype.isCapital = function () {
4330
4342
  return this.type === exports.DepreciationTypeEnum.CAPITAL_WORKS;
4331
4343
  };
@@ -4335,30 +4347,9 @@
4335
4347
  Depreciation.prototype.isAsset = function () {
4336
4348
  return this.type === exports.DepreciationTypeEnum.PLANT_EQUIPMENT;
4337
4349
  };
4338
- /**
4339
- * check if depreciation should be displayed in written off category
4340
- * details in project documentation
4341
- * @TODO new FinancialYear(this.writeOffDate) === new FinancialYear()
4342
- */
4343
- Depreciation.prototype.isWrittenOff = function () {
4344
- return this.isAsset && this.writeOffDate && new FinancialYear(this.writeOffDate).year === this.financialYear;
4345
- };
4346
- /**
4347
- * Check if depreciation is Plant & Equipment
4348
- */
4349
- Depreciation.prototype.isPlantEquipment = function () {
4350
- return this.isAsset() && !this.isWrittenOff() && !this.isLowValuePool();
4351
- };
4352
- /**
4353
- * check if depreciation should be displayed in low value pool
4354
- * details in project documentation
4355
- * @TODO new FinancialYear(this.writeOffDate) === new FinancialYear()
4356
- */
4357
- Depreciation.prototype.isLowValuePool = function () {
4358
- return this.isAsset &&
4359
- this.calculation === exports.DepreciationCalculationEnum.DIMINISHING &&
4360
- this.amount > Depreciation.WRITTEN_OFF_THRESHOLD &&
4361
- this.amount <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
4350
+ // Calculation checking
4351
+ Depreciation.prototype.isSBPCalculation = function () {
4352
+ return this.calculation === exports.DepreciationCalculationEnum.SBP;
4362
4353
  };
4363
4354
  Depreciation.prototype.isPrimeCost = function () {
4364
4355
  return this.calculation === exports.DepreciationCalculationEnum.PRIME_COST;
@@ -4366,6 +4357,34 @@
4366
4357
  Depreciation.prototype.isDiminishing = function () {
4367
4358
  return this.calculation === exports.DepreciationCalculationEnum.DIMINISHING;
4368
4359
  };
4360
+ // Pool checking
4361
+ Depreciation.prototype.isPlantEquipmentPool = function () {
4362
+ return this.isAsset() && !this.isSBPCalculation() && !this.isWrittenOff() && !this.isLVP();
4363
+ };
4364
+ Depreciation.prototype.isLVP = function () {
4365
+ return this.isAsset()
4366
+ && !this.isSBPCalculation()
4367
+ && this.isDiminishing()
4368
+ && this.currentYearForecast.closeBalance > Depreciation.WRITTEN_OFF_THRESHOLD
4369
+ && this.currentYearForecast.closeBalance <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
4370
+ };
4371
+ Depreciation.prototype.isSBP = function () {
4372
+ return this.isAsset() && this.isSBPCalculation() && !this.isWrittenOff();
4373
+ };
4374
+ Depreciation.prototype.isWrittenOff = function () {
4375
+ return this.writeOffYear === new FinancialYear().year;
4376
+ };
4377
+ Object.defineProperty(Depreciation.prototype, "writeOffYear", {
4378
+ get: function () {
4379
+ var _a;
4380
+ if (!this.writeOffManualDate && !this.writeOffDate) {
4381
+ return null;
4382
+ }
4383
+ return (_a = new FinancialYear(this.writeOffManualDate || this.writeOffDate)) === null || _a === void 0 ? void 0 : _a.year;
4384
+ },
4385
+ enumerable: false,
4386
+ configurable: true
4387
+ });
4369
4388
  /**
4370
4389
  * Check if depreciation chart accounts heading related to vehicles category
4371
4390
  */
@@ -4479,6 +4498,14 @@
4479
4498
  classTransformer.Type(function () { return BankTransaction; })
4480
4499
  ], Depreciation.prototype, "bankTransaction", void 0);
4481
4500
 
4501
+ var SoleBusinessActivity$1 = /** @class */ (function (_super) {
4502
+ __extends(SoleBusinessActivity, _super);
4503
+ function SoleBusinessActivity() {
4504
+ return _super !== null && _super.apply(this, arguments) || this;
4505
+ }
4506
+ return SoleBusinessActivity;
4507
+ }(AbstractModel));
4508
+
4482
4509
  var SoleBusiness = /** @class */ (function (_super) {
4483
4510
  __extends(SoleBusiness, _super);
4484
4511
  function SoleBusiness() {
@@ -4520,6 +4547,42 @@
4520
4547
  __decorate([
4521
4548
  classTransformer.Type(function () { return Depreciation; })
4522
4549
  ], SoleBusiness.prototype, "depreciations", void 0);
4550
+ __decorate([
4551
+ classTransformer.Type(function () { return SoleBusinessActivity$1; })
4552
+ ], SoleBusiness.prototype, "activity", void 0);
4553
+
4554
+ var SoleBusinessActivity = /** @class */ (function (_super) {
4555
+ __extends(SoleBusinessActivity, _super);
4556
+ function SoleBusinessActivity() {
4557
+ return _super !== null && _super.apply(this, arguments) || this;
4558
+ }
4559
+ return SoleBusinessActivity;
4560
+ }(SoleBusinessActivity$1));
4561
+
4562
+ var SoleDepreciationMethod$1 = /** @class */ (function (_super) {
4563
+ __extends(SoleDepreciationMethod, _super);
4564
+ function SoleDepreciationMethod() {
4565
+ return _super !== null && _super.apply(this, arguments) || this;
4566
+ }
4567
+ return SoleDepreciationMethod;
4568
+ }(AbstractModel));
4569
+
4570
+ exports.SoleDepreciationMethodEnum = void 0;
4571
+ (function (SoleDepreciationMethodEnum) {
4572
+ SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["SBP"] = 1] = "SBP";
4573
+ SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["DEPRECIATION"] = 2] = "DEPRECIATION";
4574
+ })(exports.SoleDepreciationMethodEnum || (exports.SoleDepreciationMethodEnum = {}));
4575
+
4576
+ var SoleDepreciationMethod = /** @class */ (function (_super) {
4577
+ __extends(SoleDepreciationMethod, _super);
4578
+ function SoleDepreciationMethod() {
4579
+ return _super !== null && _super.apply(this, arguments) || this;
4580
+ }
4581
+ SoleDepreciationMethod.prototype.isSBP = function () {
4582
+ return this.method === exports.SoleDepreciationMethodEnum.SBP;
4583
+ };
4584
+ return SoleDepreciationMethod;
4585
+ }(SoleDepreciationMethod$1));
4523
4586
 
4524
4587
  var SoleDetails$1 = /** @class */ (function (_super) {
4525
4588
  __extends(SoleDetails, _super);
@@ -5415,6 +5478,13 @@
5415
5478
  function BankAccount() {
5416
5479
  return _super !== null && _super.apply(this, arguments) || this;
5417
5480
  }
5481
+ Object.defineProperty(BankAccount.prototype, "bank", {
5482
+ get: function () {
5483
+ return this.bankConnection.bank;
5484
+ },
5485
+ enumerable: false,
5486
+ configurable: true
5487
+ });
5418
5488
  /**
5419
5489
  * Get current opening balance amount
5420
5490
  */
@@ -6091,9 +6161,8 @@
6091
6161
  }
6092
6162
  /**
6093
6163
  * Get remaining kilometers limit. Total limit ({@link VehicleClaim.totalKmsLimit}) - claimed kilometers from other vehicle claims
6094
- * @param claim may not exist when user come to vehicle claim page 1st time and not created claim yet
6095
6164
  */
6096
- VehicleClaimCollection.prototype.getKlmsLimitForClaim = function (claim) {
6165
+ VehicleClaimCollection.prototype.getKmsLimitForClaim = function (claim) {
6097
6166
  var collection = this;
6098
6167
  if (claim) {
6099
6168
  collection = collection.removeBy('id', claim.id);
@@ -6102,7 +6171,6 @@
6102
6171
  };
6103
6172
  /**
6104
6173
  * Get remaining work usage limit. Total limit ({@link VehicleClaim.totalWorkUsagePercent}) - claimed percent from other vehicle claims
6105
- * @param claim may not exist when user come to vehicle claim page 1st time and not created claim yet
6106
6174
  */
6107
6175
  VehicleClaimCollection.prototype.getWorkUsageLimitForClaim = function (claim) {
6108
6176
  var collection = this;
@@ -6120,14 +6188,14 @@
6120
6188
  return _super !== null && _super.apply(this, arguments) || this;
6121
6189
  }
6122
6190
  /**
6123
- * Best period may be calculated only when user has logbooks minimum for {@link VehicleLogbook.periodDuration}
6191
+ * Best period may be calculated only when user has logbooks minimum for VehicleLogbook.bestPeriodWeeks
6124
6192
  * @TODO Vik: Best period: move this and related logic to backend
6125
6193
  */
6126
6194
  VehicleLogbookCollection.prototype.isBestPeriodExist = function () {
6127
6195
  if (this.items.length < 2) {
6128
6196
  return false;
6129
6197
  }
6130
- return VehicleLogbook.periodDuration < (this.last.date.getTime() - this.first.date.getTime());
6198
+ return VehicleLogbook.bestPeriodWeeks < (this.last.date.getTime() - this.first.date.getTime());
6131
6199
  };
6132
6200
  /**
6133
6201
  * Get collection of non-personal logbooks (work-related, sole-related).
@@ -6137,15 +6205,14 @@
6137
6205
  return this.filterBy('isPersonal', false);
6138
6206
  };
6139
6207
  /**
6140
- * Logbook Period is the best when it has the biggest work usage percent
6141
- * Best period duration is defined as {@link VehicleLogbook.periodDuration} by the ATO
6208
+ * Get Logbook Period with the biggest work usage percent
6209
+ * Best period duration is defined as VehicleLogbook.bestPeriodWeeks by the ATO
6142
6210
  * @TODO Vik: Best period: move this and related logic to backend
6143
6211
  */
6144
6212
  VehicleLogbookCollection.prototype.getBestPeriod = function () {
6145
6213
  if (!this.isBestPeriodExist()) {
6146
6214
  return null;
6147
6215
  }
6148
- // declare best period variable
6149
6216
  var bestPeriod;
6150
6217
  // get list of all logbooks available for best period calculation
6151
6218
  var claimableLogbooks = this.getClaimableLogbooks().toArray();
@@ -6155,12 +6222,12 @@
6155
6222
  break;
6156
6223
  }
6157
6224
  // get date range started from current handling logbook date
6158
- var dateRange = this.getPeriodRange(claimableLogbooks[i].date);
6225
+ var dateRange = claimableLogbooks[i].getPeriod();
6159
6226
  // get all logbooks included in current logbook period
6160
- var logbooksInRange = this.filterByRange('date', dateRange.from, dateRange.to);
6227
+ var logbooksInRange = this.filterByRange('date', dateRange.start, dateRange.end);
6161
6228
  var currentPeriod = classTransformer.plainToClass(LogbookPeriod, {
6162
- from: dateRange.from,
6163
- to: dateRange.to,
6229
+ from: dateRange.start,
6230
+ to: dateRange.end,
6164
6231
  kilometers: logbooksInRange.getClaimableLogbooks().kilometers,
6165
6232
  workUsage: logbooksInRange.getWorkUsage(),
6166
6233
  logbooks: logbooksInRange
@@ -6198,28 +6265,15 @@
6198
6265
  var workKilometers = this.getClaimableLogbooks().kilometers;
6199
6266
  return Math.round(workKilometers / this.kilometers * 100);
6200
6267
  };
6201
- /**
6202
- * Get LOGBOOK_PERIOD_DURATION date range from passed start date
6203
- * @TODO Vik: Best period: move this and related logic to backend
6204
- */
6205
- VehicleLogbookCollection.prototype.getPeriodRange = function (from) {
6206
- // set end date as VehicleLogbook.periodDuration after start date
6207
- var to = new Date(from.getTime() + VehicleLogbook.periodDuration);
6208
- var financialYear = new FinancialYear();
6209
- // set as period last VehicleLogbook.periodDuration of current year if period end date after end of current year
6210
- if (to > financialYear.endDate) {
6211
- to = financialYear.endDate;
6212
- from = new Date(to.getTime() - VehicleLogbook.periodDuration);
6213
- }
6214
- return { from: from, to: to };
6215
- };
6216
6268
  /**
6217
6269
  * Get list of logbooks related to passed vehicle claim
6218
6270
  */
6219
- VehicleLogbookCollection.prototype.getByVehicleClaim = function (claim) {
6220
- return claim.isWorkTank()
6221
- ? this.filterBy('tankType', exports.TankTypeEnum.WORK)
6222
- : this.filterBy('business.id', claim.business.id);
6271
+ VehicleLogbookCollection.prototype.getByVehicleClaim = function (vehicleClaim) {
6272
+ return vehicleClaim.isSoleTank()
6273
+ // sole tank may have multiple vehicle claims, so we need to filter by business.id
6274
+ ? this.filterBy('business.id', vehicleClaim.business.id)
6275
+ // work tank may have only one vehicle claim, so we need to filter by tank type
6276
+ : this.filterBy('tankType', exports.TankTypeEnum.WORK);
6223
6277
  };
6224
6278
  return VehicleLogbookCollection;
6225
6279
  }(Collection));
@@ -6379,9 +6433,9 @@
6379
6433
  return _super !== null && _super.apply(this, arguments) || this;
6380
6434
  }
6381
6435
  /**
6382
- * Get 'Klms travelled for work' related chart account value
6436
+ * Get 'Kms travelled for work' related chart account value
6383
6437
  */
6384
- ChartAccountsCollection.prototype.getVehicleKlmsRate = function (year) {
6438
+ ChartAccountsCollection.prototype.getVehicleKmsRate = function (year) {
6385
6439
  if (year === void 0) { year = new FinancialYear().year; }
6386
6440
  return this.findBy('id', exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK).getValueByYear(year).value;
6387
6441
  };
@@ -6742,6 +6796,9 @@
6742
6796
  * Get list of vehicle transactions filtered by vehicle claim
6743
6797
  */
6744
6798
  TransactionCollection.prototype.getByVehicleClaim = function (vehicleClaim) {
6799
+ if (!vehicleClaim) {
6800
+ return this.create([]);
6801
+ }
6745
6802
  return vehicleClaim.isSoleTank()
6746
6803
  // sole tank may have multiple vehicle claims, so we need to filter by business.id
6747
6804
  ? this.getVehicleTransactions().filterBy('business.id', vehicleClaim.business.id)
@@ -6749,7 +6806,7 @@
6749
6806
  : this.getVehicleTransactions().filterBy('tankType', exports.TankTypeEnum.WORK);
6750
6807
  };
6751
6808
  /**
6752
- * Get list of vehicle transactions except KLMS transactions
6809
+ * Get list of vehicle transactions except KMS transactions
6753
6810
  */
6754
6811
  TransactionCollection.prototype.getLogbookTransactions = function () {
6755
6812
  return this
@@ -6832,19 +6889,22 @@
6832
6889
  return this.filter(function (depreciation) { return depreciation.isAsset(); });
6833
6890
  };
6834
6891
  DepreciationCollection.prototype.getPlantEquipment = function () {
6835
- return this.filter(function (depreciation) { return depreciation.isPlantEquipment(); });
6892
+ return this.filter(function (depreciation) { return depreciation.isPlantEquipmentPool(); });
6836
6893
  };
6837
6894
  DepreciationCollection.prototype.getCapitalDepreciations = function () {
6838
6895
  return this.filter(function (depreciation) { return depreciation.isCapital(); });
6839
6896
  };
6840
6897
  DepreciationCollection.prototype.getBorrowingExpenseDepreciations = function () {
6841
- return new DepreciationCollection(this.items.filter(function (depreciation) { return depreciation.isBorrowingExpense(); }));
6898
+ return this.filter(function (depreciation) { return depreciation.isBorrowingExpense(); });
6842
6899
  };
6843
6900
  DepreciationCollection.prototype.getWrittenOffDepreciations = function () {
6844
- return new DepreciationCollection(this.items.filter(function (depreciation) { return depreciation.isWrittenOff(); }));
6901
+ return this.filter(function (depreciation) { return depreciation.isWrittenOff(); });
6845
6902
  };
6846
- DepreciationCollection.prototype.getLowValuePoolDepreciations = function () {
6847
- return new DepreciationCollection(this.items.filter(function (depreciation) { return depreciation.isLowValuePool(); }));
6903
+ DepreciationCollection.prototype.getLVPDepreciations = function () {
6904
+ return this.filter(function (depreciation) { return depreciation.isLVP(); });
6905
+ };
6906
+ DepreciationCollection.prototype.getSBPDepreciations = function () {
6907
+ return this.filter(function (depreciation) { return depreciation.isSBP(); });
6848
6908
  };
6849
6909
  DepreciationCollection.prototype.getCapitalProjects = function () {
6850
6910
  return uniqBy__default["default"](compact__default["default"](this.items.map(function (depreciation) {
@@ -6855,9 +6915,7 @@
6855
6915
  * Get a new collection of depreciations related to vehicles
6856
6916
  */
6857
6917
  DepreciationCollection.prototype.getVehicleDepreciations = function () {
6858
- return this.create(this.items.filter(function (depreciation) {
6859
- return depreciation.isVehicleDepreciation();
6860
- }));
6918
+ return this.filter(function (depreciation) { return depreciation.isVehicleDepreciation(); });
6861
6919
  };
6862
6920
  DepreciationCollection.prototype.getByTankType = function (tankType) {
6863
6921
  return this.create(this.items.filter(function (depreciation) {
@@ -7274,7 +7332,7 @@
7274
7332
  Object.defineProperty(DepreciationReportItem.prototype, "categoryTitle", {
7275
7333
  get: function () {
7276
7334
  switch (true) {
7277
- case this.isPlantEquipment():
7335
+ case this.isPlantEquipmentPool():
7278
7336
  return 'Plant & Equipment';
7279
7337
  case this.isWrittenOff():
7280
7338
  return 'Written Off Items';
@@ -9127,6 +9185,7 @@
9127
9185
  DepreciationGroupEnum[DepreciationGroupEnum["LOW_VALUE_POOL"] = 2] = "LOW_VALUE_POOL";
9128
9186
  DepreciationGroupEnum[DepreciationGroupEnum["WRITTEN_OFF_ITEMS"] = 3] = "WRITTEN_OFF_ITEMS";
9129
9187
  DepreciationGroupEnum[DepreciationGroupEnum["BORROWING_EXPENSES"] = 4] = "BORROWING_EXPENSES";
9188
+ DepreciationGroupEnum[DepreciationGroupEnum["SMALL_BUSINESS_POOL"] = 5] = "SMALL_BUSINESS_POOL";
9130
9189
  })(exports.DepreciationGroupEnum || (exports.DepreciationGroupEnum = {}));
9131
9190
 
9132
9191
  /**
@@ -9190,6 +9249,11 @@
9190
9249
  description: 'Items below $300, replaced or obsolete are fully deductible',
9191
9250
  icon: 'cart'
9192
9251
  },
9252
+ _a$1[exports.DepreciationGroupEnum.SMALL_BUSINESS_POOL] = {
9253
+ label: 'Small business pool',
9254
+ description: 'The small business pool allows business owners to claim depreciation on plant and equipment items at an accelerated rate.',
9255
+ icon: 'portfolio'
9256
+ },
9193
9257
  _a$1);
9194
9258
 
9195
9259
  var DepreciationReceipt$1 = /** @class */ (function (_super) {
@@ -10076,7 +10140,7 @@
10076
10140
  exports.DeductionSelfEducationTypeEnum.IMPROVE_SKILLS_FOR_CURRENT_EARNINGS_K : null;
10077
10141
  this.workRelatedSelfEducationTotalAmount = this.workRelatedSelfEducationExpenses.sumBy('claimAmount');
10078
10142
  this.lowValuePoolDeductionTotalAmount = this.depreciations.getByTankType(exports.TankTypeEnum.WORK)
10079
- .getLowValuePoolDepreciations().sumBy('claimAmount');
10143
+ .getLVPDepreciations().sumBy('claimAmount');
10080
10144
  this.interestExpensesTotalAmount = this.transactions
10081
10145
  .filterBy('chartAccounts.heading.id', DEDUCTION_CATEGORIES.interestExpenses)
10082
10146
  .sumBy('claimAmount');
@@ -10110,7 +10174,7 @@
10110
10174
  return 0;
10111
10175
  };
10112
10176
  MyTaxDeductions.prototype.setVehicleClaimData = function () {
10113
- this.klmsMethodClaimAmount = this.vehicleClaim.getKLMsClaimAmount(this.vehicleClaimRate);
10177
+ this.klmsMethodClaimAmount = this.vehicleClaim.getKMSClaimAmount(this.vehicleClaimRate);
10114
10178
  this.totalExpensesAmount = this.vehicleClaim.getLogbookClaimAmount(new TransactionCollection(__spreadArray(__spreadArray([], __read(this.transactions.getByTankType(this.vehicleClaim.tankType))), __read(this.depreciations.getByTankType(this.vehicleClaim.tankType).toTransactions().toArray()))));
10115
10179
  };
10116
10180
  /**
@@ -10954,6 +11018,26 @@
10954
11018
  }]
10955
11019
  }] });
10956
11020
 
11021
+ var SoleBusinessActivityService = /** @class */ (function (_super) {
11022
+ __extends(SoleBusinessActivityService, _super);
11023
+ function SoleBusinessActivityService() {
11024
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11025
+ _this.modelClass = SoleBusinessActivity;
11026
+ _this.url = 'sole-business-activities';
11027
+ _this.isHydra = true;
11028
+ return _this;
11029
+ }
11030
+ return SoleBusinessActivityService;
11031
+ }(RestService));
11032
+ SoleBusinessActivityService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessActivityService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
11033
+ SoleBusinessActivityService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessActivityService, providedIn: 'root' });
11034
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessActivityService, decorators: [{
11035
+ type: i0.Injectable,
11036
+ args: [{
11037
+ providedIn: 'root'
11038
+ }]
11039
+ }] });
11040
+
10957
11041
  var SoleContactService = /** @class */ (function (_super) {
10958
11042
  __extends(SoleContactService, _super);
10959
11043
  function SoleContactService() {
@@ -10974,6 +11058,61 @@
10974
11058
  }]
10975
11059
  }] });
10976
11060
 
11061
+ /**
11062
+ * @TODO Alex: extend rest service when refactored
11063
+ */
11064
+ var SoleDepreciationMethodService = /** @class */ (function () {
11065
+ function SoleDepreciationMethodService(http, environment, eventDispatcherService, toastService) {
11066
+ this.http = http;
11067
+ this.environment = environment;
11068
+ this.eventDispatcherService = eventDispatcherService;
11069
+ this.toastService = toastService;
11070
+ this.cacheSubject = new rxjs.ReplaySubject(1);
11071
+ this.url = 'sole-depreciation-methods';
11072
+ }
11073
+ SoleDepreciationMethodService.prototype.get = function () {
11074
+ var _this = this;
11075
+ if (!this.cache) {
11076
+ this.http.get(this.environment.apiV2 + "/" + this.url)
11077
+ .pipe(operators.map(function (response) { return classTransformer.plainToClass(SoleDepreciationMethod, response['hydra:member'][0]); }))
11078
+ .subscribe(function (soleDepreciationMethod) {
11079
+ _this.cache = soleDepreciationMethod;
11080
+ _this.cacheSubject.next(_this.cache);
11081
+ return soleDepreciationMethod;
11082
+ });
11083
+ }
11084
+ return this.cacheSubject.asObservable();
11085
+ };
11086
+ SoleDepreciationMethodService.prototype.update = function (soleDepreciationMethod) {
11087
+ var _this = this;
11088
+ return this.http.put(this.environment.apiV2 + "/" + this.url + "/" + soleDepreciationMethod.id, soleDepreciationMethod)
11089
+ .pipe(operators.map(function (soleDepreciationMethodBase) {
11090
+ var method = classTransformer.plainToClass(SoleDepreciationMethod, soleDepreciationMethodBase);
11091
+ _this.cache = method;
11092
+ _this.cacheSubject.next(_this.cache);
11093
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SOLE_DEPRECIATION_METHOD_UPDATED, method));
11094
+ return _this.cache;
11095
+ }), operators.catchError(function (error) {
11096
+ _this.toastService.error(error.error['hydra:description']);
11097
+ return throwError.throwError(error);
11098
+ }));
11099
+ };
11100
+ return SoleDepreciationMethodService;
11101
+ }());
11102
+ SoleDepreciationMethodService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDepreciationMethodService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }, { token: EventDispatcherService }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11103
+ SoleDepreciationMethodService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDepreciationMethodService, providedIn: 'root' });
11104
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDepreciationMethodService, decorators: [{
11105
+ type: i0.Injectable,
11106
+ args: [{
11107
+ providedIn: 'root'
11108
+ }]
11109
+ }], ctorParameters: function () {
11110
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
11111
+ type: i0.Inject,
11112
+ args: ['environment']
11113
+ }] }, { type: EventDispatcherService }, { type: ToastService }];
11114
+ } });
11115
+
10977
11116
  /**
10978
11117
  * @TODO TT-1777 Alex: extend from rest service when it refactored
10979
11118
  */
@@ -11107,10 +11246,7 @@
11107
11246
  */
11108
11247
  VehicleClaimService.prototype.listenVehicleClaimDetailsChanges = function () {
11109
11248
  var _this = this;
11110
- this.eventDispatcherService.on([
11111
- exports.AppEventTypeEnum.VEHICLE_CLAIM_DETAILS_CREATED,
11112
- exports.AppEventTypeEnum.VEHICLE_CLAIM_DETAILS_UPDATED
11113
- ])
11249
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.VEHICLE_CLAIM_DETAILS_UPDATED)
11114
11250
  .subscribe(function () {
11115
11251
  _this.resetCache();
11116
11252
  });
@@ -11137,14 +11273,17 @@
11137
11273
  */
11138
11274
  VehicleClaimService.prototype.updateWorkUsage = function (bestPeriod) {
11139
11275
  var _this = this;
11140
- // We are sure this.cache exist here because logbook best period calculation is based on vehicle claims,
11141
- // so before we can get logbook best period changes, we must get vehicle claims
11276
+ // no need to update if cache not exist
11277
+ if (!this.cache) {
11278
+ return;
11279
+ }
11280
+ // @TODO Vik (TT-2210): need batch endpoint for this update
11281
+ // @TODO Alex (TT-2210): fix frontend when endpoint ready
11142
11282
  var batch$ = this.cache.map(function (claim) {
11143
11283
  var claimToUpdate = classTransformer.plainToClass(VehicleClaim, Object.assign({}, claim, { workUsage: bestPeriod === null || bestPeriod === void 0 ? void 0 : bestPeriod.getWorkUsageByClaim(claim) }));
11144
11284
  return _this.update(claimToUpdate);
11145
11285
  });
11146
- // take(1) is using to avoid unnecessary callback calling whe user updated details directly
11147
- rxjs.combineLatest(batch$).pipe(operators.take(1)).subscribe();
11286
+ rxjs.combineLatest(batch$).subscribe();
11148
11287
  };
11149
11288
  return VehicleClaimService;
11150
11289
  }(RestService));
@@ -11223,11 +11362,12 @@
11223
11362
  * @TODO Vik: Best period move this and related logic to backend
11224
11363
  */
11225
11364
  VehicleClaimDetailsService.prototype.updateToManual = function () {
11226
- // We are sure this.cache exist here because logbook best period calculation is based on vehicle claim details,
11227
- // so before we can get logbook best period changes, we must get vehicle claim details
11365
+ // no need to update if cache not exist
11366
+ if (!this.cache) {
11367
+ return;
11368
+ }
11228
11369
  var vehicleClaimDetails = classTransformer.plainToClass(VehicleClaimDetails, Object.assign({}, this.cache, { isManual: true }));
11229
- // take(1) is using to avoid unnecessary callback calling whe user updated details directly
11230
- this.update(vehicleClaimDetails).pipe(operators.take(1)).subscribe();
11370
+ this.update(vehicleClaimDetails).subscribe();
11231
11371
  };
11232
11372
  return VehicleClaimDetailsService;
11233
11373
  }());
@@ -11398,6 +11538,41 @@
11398
11538
  }]
11399
11539
  }] });
11400
11540
 
11541
+ /**
11542
+ * Service to work with Rewardful (affiliate program) API
11543
+ * https://developers.rewardful.com/javascript-api/overview#executing-code-when-rewardful-loads
11544
+ */
11545
+ var RewardfulService = /** @class */ (function () {
11546
+ function RewardfulService(environment) {
11547
+ this.environment = environment;
11548
+ }
11549
+ RewardfulService.prototype.getReferralCode = function () {
11550
+ var _this = this;
11551
+ return new rxjs.Observable(function (observer) {
11552
+ if (!_this.environment.rewardfulId) {
11553
+ return observer.next(null);
11554
+ }
11555
+ window['rewardful']('ready', function () {
11556
+ observer.next(window['Rewardful'].referral);
11557
+ });
11558
+ });
11559
+ };
11560
+ return RewardfulService;
11561
+ }());
11562
+ RewardfulService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RewardfulService, deps: [{ token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11563
+ RewardfulService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RewardfulService, providedIn: 'root' });
11564
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RewardfulService, decorators: [{
11565
+ type: i0.Injectable,
11566
+ args: [{
11567
+ providedIn: 'root'
11568
+ }]
11569
+ }], ctorParameters: function () {
11570
+ return [{ type: undefined, decorators: [{
11571
+ type: i0.Inject,
11572
+ args: ['environment']
11573
+ }] }];
11574
+ } });
11575
+
11401
11576
  /**
11402
11577
  * Service for logbook best period calculation
11403
11578
  * @TODO Vik: improve structure for such cases (TT-2043)
@@ -11512,7 +11687,7 @@
11512
11687
  }),
11513
11688
  _a[AccountSetupItemsEnum.WORK_LOGBOOK] = classTransformer.plainToClass(AccountSetupItem, {
11514
11689
  title: 'Set up your logbook method',
11515
- 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.',
11690
+ description: 'Do you use your vehicle for work? Select your method and the kms or logbook % to automate accurately all vehicle expenses throughout the year.',
11516
11691
  url: '/client/work-tank/logbook',
11517
11692
  urlFragment: 'productTour'
11518
11693
  }),
@@ -11647,6 +11822,14 @@
11647
11822
  return updatedProperty;
11648
11823
  }));
11649
11824
  };
11825
+ PropertyService.prototype.updateDepreciationCalculation = function (property) {
11826
+ var _this = this;
11827
+ var propertyToUpdate = classTransformer.plainToClass(Property, { id: property.id, depreciationCalculation: property.depreciationCalculation });
11828
+ return this.update(propertyToUpdate).pipe(operators.map(function (updatedProperty) {
11829
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_DEPRECIATION_CALCULATION_UPDATED, updatedProperty));
11830
+ return updatedProperty;
11831
+ }));
11832
+ };
11650
11833
  PropertyService.prototype.getByCategoryId = function (id) {
11651
11834
  return this.get().pipe(operators.map(function (properties) {
11652
11835
  return properties.filter(function (property) { return property.category.id === id; });
@@ -12446,7 +12629,6 @@
12446
12629
  this.eventDispatcherService.on([
12447
12630
  exports.AppEventTypeEnum.VEHICLE_CLAIM_CREATED,
12448
12631
  exports.AppEventTypeEnum.VEHICLE_CLAIM_UPDATED,
12449
- exports.AppEventTypeEnum.VEHICLE_CLAIM_DETAILS_CREATED,
12450
12632
  exports.AppEventTypeEnum.VEHICLE_CLAIM_DETAILS_UPDATED
12451
12633
  ]).subscribe(function () {
12452
12634
  _this.resetCache();
@@ -12554,7 +12736,7 @@
12554
12736
  }
12555
12737
  // Bank feeds item is completed when user added at least one bank account (basiq or manual)
12556
12738
  batch.push(this.create(AccountSetupItemsEnum.BANK_FEEDS, this.bankAccountsService.get()));
12557
- // Logbook item is completed when user has at least one vehicle claim with any method (klms or logbook)
12739
+ // Logbook item is completed when user has at least one vehicle claim with any method (kms or logbook)
12558
12740
  batch.push(this.getLogbookItem());
12559
12741
  // @TODO waiting for sole tank forecast page
12560
12742
  // Sole item is completed when user added at least one sole income source
@@ -13735,6 +13917,8 @@
13735
13917
  this.listenReceiptDeleted();
13736
13918
  this.listenVehicleClaimChanges();
13737
13919
  this.listenToUpdatedBankAccount();
13920
+ this.listenSoleDepreciationMethodChanges();
13921
+ this.listenPropertyDepreciationCalculationChanges();
13738
13922
  };
13739
13923
  DepreciationService.prototype.getOpenBalance = function (depreciation) {
13740
13924
  return this.http.post(this.environment.apiV2 + "/" + this.url + "/opening-balance?financialYear=" + new FinancialYear().year, depreciation)
@@ -13788,7 +13972,6 @@
13788
13972
  this.eventDispatcherService.on([
13789
13973
  exports.AppEventTypeEnum.VEHICLE_CLAIM_CREATED,
13790
13974
  exports.AppEventTypeEnum.VEHICLE_CLAIM_UPDATED,
13791
- exports.AppEventTypeEnum.VEHICLE_CLAIM_DETAILS_CREATED,
13792
13975
  exports.AppEventTypeEnum.VEHICLE_CLAIM_DETAILS_UPDATED
13793
13976
  ]).subscribe(function () {
13794
13977
  _this.resetCache();
@@ -13798,6 +13981,24 @@
13798
13981
  replace(this.cache, depreciationToReplace);
13799
13982
  this.updateCache();
13800
13983
  };
13984
+ /**
13985
+ * @TODO Alex: create common method resetCacheOn(events: AppEventType[])
13986
+ */
13987
+ DepreciationService.prototype.listenSoleDepreciationMethodChanges = function () {
13988
+ var _this = this;
13989
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.SOLE_DEPRECIATION_METHOD_UPDATED).subscribe(function () {
13990
+ _this.resetCache();
13991
+ });
13992
+ };
13993
+ /**
13994
+ * @TODO Alex: create common method resetCacheOn(events: AppEventType[])
13995
+ */
13996
+ DepreciationService.prototype.listenPropertyDepreciationCalculationChanges = function () {
13997
+ var _this = this;
13998
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_DEPRECIATION_CALCULATION_UPDATED).subscribe(function () {
13999
+ _this.resetCache();
14000
+ });
14001
+ };
13801
14002
  return DepreciationService;
13802
14003
  }(RestService));
13803
14004
  DepreciationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }, { token: DepreciationReceiptService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -16261,7 +16462,7 @@
16261
16462
  /**
16262
16463
  * Abstract form class
16263
16464
  * @TODO rename to AbstractFormGroup
16264
- * @TODO Alex: refactor: check and improve logic
16465
+ * @TODO Alex TT-2190: refactor: check and improve logic
16265
16466
  */
16266
16467
  var AbstractForm = /** @class */ (function (_super) {
16267
16468
  __extends(AbstractForm, _super);
@@ -16278,9 +16479,7 @@
16278
16479
  if (model && !model['id']) {
16279
16480
  _this.markAsUnsaved();
16280
16481
  }
16281
- _this.valueChanges.subscribe(function () {
16282
- !!model && !!model['id'] && isEqual__default["default"](_this.value, _this.initialValue) ? _this.markAsSaved() : _this.markAsUnsaved();
16283
- });
16482
+ _this.listenValueChanges();
16284
16483
  return _this;
16285
16484
  }
16286
16485
  Object.defineProperty(AbstractForm.prototype, "saved", {
@@ -16290,6 +16489,13 @@
16290
16489
  enumerable: false,
16291
16490
  configurable: true
16292
16491
  });
16492
+ Object.defineProperty(AbstractForm.prototype, "currentValue", {
16493
+ get: function () {
16494
+ return this.createModelInstance(Object.assign({}, this.model, this.getRawValue()));
16495
+ },
16496
+ enumerable: false,
16497
+ configurable: true
16498
+ });
16293
16499
  /**
16294
16500
  * Check validation and return a new instance of generic model.
16295
16501
  * Merge form value to initial object
@@ -16320,6 +16526,12 @@
16320
16526
  if (data === void 0) { data = {}; }
16321
16527
  return classTransformer.plainToClass(this.modelClass, data);
16322
16528
  };
16529
+ AbstractForm.prototype.listenValueChanges = function () {
16530
+ var _this = this;
16531
+ this.valueChanges.subscribe(function () {
16532
+ !!_this.model && !!_this.model['id'] && isEqual__default["default"](_this.value, _this.initialValue) ? _this.markAsSaved() : _this.markAsUnsaved();
16533
+ });
16534
+ };
16323
16535
  return AbstractForm;
16324
16536
  }(forms.FormGroup));
16325
16537
 
@@ -16603,7 +16815,7 @@
16603
16815
  if (business === void 0) { business = classTransformer.plainToClass(SoleBusiness, {}); }
16604
16816
  return _super.call(this, {
16605
16817
  name: new forms.FormControl(business.name, forms.Validators.required),
16606
- code: new forms.FormControl(business.code, forms.Validators.required),
16818
+ activity: new forms.FormControl(business.activity, forms.Validators.required),
16607
16819
  description: new forms.FormControl(business.description),
16608
16820
  website: new forms.FormControl(business.website)
16609
16821
  }, business) || this;
@@ -16614,6 +16826,7 @@
16614
16826
  /**
16615
16827
  * Form array with bank account business allocations
16616
16828
  * @TODO create AbstractFormArray
16829
+ * @TODO Alex/Vik (TT-2184): copypasted from bank-account-properties.form, improve logic and create common parent class maybe
16617
16830
  */
16618
16831
  var SoleBusinessAllocationsForm = /** @class */ (function (_super) {
16619
16832
  __extends(SoleBusinessAllocationsForm, _super);
@@ -16692,6 +16905,16 @@
16692
16905
  return SoleContactForm;
16693
16906
  }(AbstractForm));
16694
16907
 
16908
+ var SoleDepreciationMethodForm = /** @class */ (function (_super) {
16909
+ __extends(SoleDepreciationMethodForm, _super);
16910
+ function SoleDepreciationMethodForm(soleDepreciationMethod) {
16911
+ return _super.call(this, {
16912
+ method: new forms.FormControl(soleDepreciationMethod.method)
16913
+ }, soleDepreciationMethod) || this;
16914
+ }
16915
+ return SoleDepreciationMethodForm;
16916
+ }(AbstractForm));
16917
+
16695
16918
  var SoleDetailsForm = /** @class */ (function (_super) {
16696
16919
  __extends(SoleDetailsForm, _super);
16697
16920
  function SoleDetailsForm(soleDetails) {
@@ -16710,7 +16933,7 @@
16710
16933
  name: new forms.FormControl(invoiceTemplate.name, forms.Validators.required),
16711
16934
  isTaxIncluded: new forms.FormControl(invoiceTemplate.isTaxIncluded),
16712
16935
  term: new forms.FormControl(invoiceTemplate.term, [forms.Validators.required, forms.Validators.min(0)]),
16713
- bankAccount: new forms.FormControl(invoiceTemplate.bankAccount)
16936
+ bankAccount: new forms.FormControl(invoiceTemplate.bankAccount, [forms.Validators.required])
16714
16937
  }, invoiceTemplate) || this;
16715
16938
  }
16716
16939
  return SoleInvoiceTemplateForm;
@@ -16729,10 +16952,13 @@
16729
16952
  if (bankAccount === null || bankAccount === void 0 ? void 0 : bankAccount.isSoleTank()) {
16730
16953
  _this.addControl('businessAllocations', new SoleBusinessAllocationsForm(bankAccount.businessAllocations));
16731
16954
  }
16732
- _this.watchTankType();
16955
+ _this.listenEvents();
16733
16956
  return _this;
16734
16957
  }
16735
- BankAccountAllocationForm.prototype.watchTankType = function () {
16958
+ BankAccountAllocationForm.prototype.listenEvents = function () {
16959
+ this.listenTankTypeChanges();
16960
+ };
16961
+ BankAccountAllocationForm.prototype.listenTankTypeChanges = function () {
16736
16962
  var _this = this;
16737
16963
  this.get('tankType').valueChanges.subscribe(function (tankType) {
16738
16964
  var _a, _b;
@@ -17470,17 +17696,23 @@
17470
17696
  * @param details required for form controls disabled state management
17471
17697
  */
17472
17698
  function VehicleClaimForm(vehicleClaim, details) {
17473
- return _super.call(this, {
17699
+ var _this = _super.call(this, {
17474
17700
  kilometers: new forms.FormControl({
17475
17701
  value: vehicleClaim.kilometers,
17476
17702
  disabled: !details.isManual || details.isLogbookMethod()
17477
17703
  }),
17478
17704
  workUsage: new forms.FormControl({
17479
17705
  value: vehicleClaim.workUsage,
17480
- disabled: !details.isManual || details.isKlmsMethod()
17706
+ disabled: !details.isManual || details.isKmsMethod()
17481
17707
  })
17482
17708
  }, vehicleClaim) || this;
17709
+ _this.vehicleClaim = vehicleClaim;
17710
+ _this.details = details;
17711
+ return _this;
17483
17712
  }
17713
+ VehicleClaimForm.prototype.getAverageWeeklyKMS = function () {
17714
+ return this.get('kilometers').value / FinancialYear.weeksInYear;
17715
+ };
17484
17716
  return VehicleClaimForm;
17485
17717
  }(AbstractForm));
17486
17718
 
@@ -17489,16 +17721,12 @@
17489
17721
  */
17490
17722
  var VehicleClaimDetailsForm = /** @class */ (function (_super) {
17491
17723
  __extends(VehicleClaimDetailsForm, _super);
17492
- /**
17493
- * @param vehicleClaimDetails required because we create a new details with prefilled data (like Financial year)
17494
- * @param logbooks required for isManual field disabled state management
17495
- */
17496
- function VehicleClaimDetailsForm(vehicleClaimDetails, logbooks) {
17724
+ function VehicleClaimDetailsForm(vehicleClaimDetails, isBestPeriodExist) {
17497
17725
  return _super.call(this, {
17498
17726
  method: new forms.FormControl(vehicleClaimDetails.method, forms.Validators.required),
17499
17727
  isManual: new forms.FormControl({
17500
17728
  value: vehicleClaimDetails.isManual,
17501
- disabled: !logbooks.isBestPeriodExist()
17729
+ disabled: !isBestPeriodExist
17502
17730
  }),
17503
17731
  }, vehicleClaimDetails) || this;
17504
17732
  }
@@ -17525,36 +17753,44 @@
17525
17753
  date: new forms.FormControl(logbook.date, forms.Validators.required),
17526
17754
  odometerStart: new forms.FormControl(logbook.odometerStart, forms.Validators.required),
17527
17755
  odometerEnd: new forms.FormControl(logbook.odometerEnd, forms.Validators.required),
17528
- business: new forms.FormControl(logbook.business),
17529
- // @TODO Alex: remove when backend fixed
17530
- purpose: new forms.FormControl(exports.VehicleLogbookPurposeEnum.BUSINESS)
17756
+ business: new forms.FormControl(logbook.business)
17531
17757
  }, logbook) || this;
17532
17758
  _this.logbook = logbook;
17533
17759
  _this.logbooks = logbooks;
17760
+ _this.updateStateAndValidators();
17761
+ return _this;
17762
+ }
17763
+ /**
17764
+ * Set logbook validators and disable state depends of initial logbook and its place in the whole list
17765
+ */
17766
+ VehicleLogbookForm.prototype.updateStateAndValidators = function () {
17534
17767
  switch (true) {
17535
17768
  // Create the first or edit the single logbook
17536
- case !logbook.id && !logbooks.length:
17537
- case !!logbook.id && logbooks.length === 1:
17538
- _this.get('odometerStart').setValidators(forms.Validators.min(0));
17539
- _this.get('date').setValidators(dateRangeValidator(new FinancialYear().startDate, new FinancialYear().endDate));
17769
+ case !this.logbook.id && !this.logbooks.length:
17770
+ case !!this.logbook.id && this.logbooks.length === 1:
17771
+ this.get('odometerStart').setValidators(forms.Validators.min(0));
17772
+ this.get('date').setValidators(dateRangeValidator(new FinancialYear().startDate, new FinancialYear().endDate));
17540
17773
  break;
17541
- // Create the non-first or edit the last logbook
17542
- case !logbook.id && !!logbooks.length:
17543
- case !!logbook.id && logbook.id === logbooks.last.id && logbooks.length > 1:
17544
- _this.get('odometerStart').disable();
17545
- _this.get('odometerEnd').setValidators(forms.Validators.min(logbooks.last.odometerEnd));
17546
- if (!!logbook.id) {
17547
- }
17548
- _this.get('date').setValidators(dateRangeValidator(logbooks.last.date, new FinancialYear().endDate));
17774
+ // Create the non-first
17775
+ case !this.logbook.id && !!this.logbooks.length:
17776
+ this.get('odometerStart').disable();
17777
+ this.get('odometerEnd').setValidators(forms.Validators.min(this.logbooks.last.odometerEnd));
17778
+ this.get('date').setValidators(dateRangeValidator(this.logbooks.last.date, new FinancialYear().endDate));
17779
+ break;
17780
+ // Edit the last logbook
17781
+ case !!this.logbook.id && this.logbook.id === this.logbooks.last.id && this.logbooks.length > 1:
17782
+ this.get('odometerStart').disable();
17783
+ this.get('odometerEnd').setValidators(forms.Validators.min(this.logbooks.last.odometerEnd));
17784
+ var preLastDate = this.logbooks.toArray()[this.logbooks.length - 1].date;
17785
+ this.get('date').setValidators(dateRangeValidator(preLastDate, new FinancialYear().endDate));
17549
17786
  break;
17550
17787
  // Edit the non-last logbook
17551
- case !!logbook.id && logbook.id !== logbooks.last.id && logbooks.length > 1:
17552
- _this.get('odometerStart').disable();
17553
- _this.get('odometerEnd').disable();
17554
- _this.get('date').disable();
17788
+ case !!this.logbook.id && this.logbook.id !== this.logbooks.last.id && this.logbooks.length > 1:
17789
+ this.get('odometerStart').disable();
17790
+ this.get('odometerEnd').disable();
17791
+ this.get('date').disable();
17555
17792
  }
17556
- return _this;
17557
- }
17793
+ };
17558
17794
  return VehicleLogbookForm;
17559
17795
  }(AbstractForm));
17560
17796
  VehicleLogbookForm.maxDescriptionLength = 60;
@@ -17785,6 +18021,7 @@
17785
18021
  exports.ReportItemCollection = ReportItemCollection;
17786
18022
  exports.ReportItemDetails = ReportItemDetails;
17787
18023
  exports.ResetPasswordForm = ResetPasswordForm;
18024
+ exports.RewardfulService = RewardfulService;
17788
18025
  exports.SUBSCRIPTION_DESCRIPTION = SUBSCRIPTION_DESCRIPTION;
17789
18026
  exports.SUBSCRIPTION_TITLE = SUBSCRIPTION_TITLE;
17790
18027
  exports.SalaryForecast = SalaryForecast;
@@ -17798,6 +18035,8 @@
17798
18035
  exports.ServiceSubscriptionCollection = ServiceSubscriptionCollection;
17799
18036
  exports.ServiceSubscriptionItem = ServiceSubscriptionItem;
17800
18037
  exports.SoleBusiness = SoleBusiness;
18038
+ exports.SoleBusinessActivity = SoleBusinessActivity;
18039
+ exports.SoleBusinessActivityService = SoleBusinessActivityService;
17801
18040
  exports.SoleBusinessAllocation = SoleBusinessAllocation;
17802
18041
  exports.SoleBusinessAllocationsForm = SoleBusinessAllocationsForm;
17803
18042
  exports.SoleBusinessForm = SoleBusinessForm;
@@ -17806,6 +18045,9 @@
17806
18045
  exports.SoleContact = SoleContact;
17807
18046
  exports.SoleContactForm = SoleContactForm;
17808
18047
  exports.SoleContactService = SoleContactService;
18048
+ exports.SoleDepreciationMethod = SoleDepreciationMethod;
18049
+ exports.SoleDepreciationMethodForm = SoleDepreciationMethodForm;
18050
+ exports.SoleDepreciationMethodService = SoleDepreciationMethodService;
17809
18051
  exports.SoleDetails = SoleDetails;
17810
18052
  exports.SoleDetailsForm = SoleDetailsForm;
17811
18053
  exports.SoleDetailsService = SoleDetailsService;