taxtank-core 0.12.3 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (478) hide show
  1. package/bundles/taxtank-core.umd.js +2528 -2274
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/account-setup-item.collection.js +3 -2
  4. package/esm2015/lib/collections/collection.js +44 -28
  5. package/esm2015/lib/collections/income-source.collection.js +1 -8
  6. package/esm2015/lib/collections/report/property/property-report-item-depreciation.collection.js +2 -2
  7. package/esm2015/lib/collections/report/property/property-report-item-transaction.collection.js +2 -2
  8. package/esm2015/lib/collections/report/vehicle-expense/vehicle-expense.collection.js +20 -0
  9. package/esm2015/lib/collections/subscription/service-subscription.collection.js +17 -0
  10. package/esm2015/lib/db/Enums/subscription/service-payment-status.enum.js +6 -0
  11. package/esm2015/lib/db/Enums/subscription/service-price-list.enum.js +5 -0
  12. package/esm2015/lib/db/Enums/{service-price-recurring-interval.enum.js → subscription/service-price-recurring-interval.enum.js} +1 -1
  13. package/esm2015/lib/db/Enums/subscription/service-price-type.enum.js +6 -0
  14. package/esm2015/lib/db/Enums/subscription/service-product-id.enum.js +10 -0
  15. package/esm2015/lib/db/Enums/subscription/service-product-status.enum.js +6 -0
  16. package/esm2015/lib/db/Enums/{service-subscription-status.enum.js → subscription/service-subscription-status.enum.js} +1 -1
  17. package/esm2015/lib/db/Enums/user-roles.enum.js +2 -1
  18. package/esm2015/lib/db/Models/abstract-model.js +7 -0
  19. package/esm2015/lib/db/Models/address.js +3 -2
  20. package/esm2015/lib/db/Models/bank/bank-account-balance.js +4 -0
  21. package/esm2015/lib/db/Models/bank/bank-account-property.js +4 -0
  22. package/esm2015/lib/db/Models/bank/bank-account.js +4 -0
  23. package/esm2015/lib/db/Models/bank/bank-connection.js +4 -0
  24. package/esm2015/lib/db/Models/bank/bank-transaction-import.js +4 -0
  25. package/esm2015/lib/db/Models/bank/bank-transaction.js +4 -0
  26. package/esm2015/lib/db/Models/bank/bank.js +4 -0
  27. package/esm2015/lib/db/Models/bank/basiq-job.js +4 -0
  28. package/esm2015/lib/db/Models/bank/financial-data-system.js +4 -0
  29. package/esm2015/lib/db/Models/chart-accounts/chart-accounts-depreciation.js +4 -0
  30. package/esm2015/lib/db/Models/chart-accounts/chart-accounts-heading.js +4 -0
  31. package/esm2015/lib/db/Models/chart-accounts/chart-accounts-metadata.js +4 -0
  32. package/esm2015/lib/db/Models/chart-accounts/chart-accounts-value.js +4 -0
  33. package/esm2015/lib/db/Models/chart-accounts/chart-accounts.js +4 -0
  34. package/esm2015/lib/db/Models/country.js +3 -2
  35. package/esm2015/lib/db/Models/depreciation/depreciation-capital-project.js +4 -0
  36. package/esm2015/lib/db/Models/depreciation/depreciation-forecast.js +4 -0
  37. package/esm2015/lib/db/Models/depreciation/depreciation-receipt.js +4 -0
  38. package/esm2015/lib/db/Models/depreciation/depreciation.js +4 -0
  39. package/esm2015/lib/db/Models/document/document-folder.js +4 -0
  40. package/esm2015/lib/db/Models/document/document.js +4 -0
  41. package/esm2015/lib/db/Models/document/property-document.js +10 -0
  42. package/esm2015/lib/db/Models/firm/accountant/tax-review.js +4 -0
  43. package/esm2015/lib/db/Models/firm/accountant/ticket.js +4 -0
  44. package/esm2015/lib/db/Models/firm/chat.js +4 -0
  45. package/esm2015/lib/db/Models/firm/client-invite.js +4 -0
  46. package/esm2015/lib/db/Models/firm/client-movement.js +4 -0
  47. package/esm2015/lib/db/Models/firm/employee-invite.js +4 -0
  48. package/esm2015/lib/db/Models/firm/firm.js +4 -0
  49. package/esm2015/lib/db/Models/firm/message-document.js +4 -0
  50. package/esm2015/lib/db/Models/firm/message.js +4 -0
  51. package/esm2015/lib/db/Models/incomeSource/income-source-forecast.js +4 -0
  52. package/esm2015/lib/db/Models/incomeSource/income-source-type.js +4 -0
  53. package/esm2015/lib/db/Models/incomeSource/income-source.js +4 -0
  54. package/esm2015/lib/db/Models/incomeSource/salary-forecast.js +4 -0
  55. package/esm2015/lib/db/Models/loan/borrowing-expense-loan.js +4 -0
  56. package/esm2015/lib/db/Models/loan/borrowing-expense.js +4 -0
  57. package/esm2015/lib/db/Models/loan/loan-payout.js +4 -0
  58. package/esm2015/lib/db/Models/loan/loan.js +4 -0
  59. package/esm2015/lib/db/Models/phone.js +3 -2
  60. package/esm2015/lib/db/Models/property/property-category-movement.js +3 -2
  61. package/esm2015/lib/db/Models/property/property-category.js +3 -2
  62. package/esm2015/lib/db/Models/property/property-forecast.js +3 -2
  63. package/esm2015/lib/db/Models/property/property-sale/property-sale-tax-exemption-metadata.js +3 -2
  64. package/esm2015/lib/db/Models/property/property-sale/property-sale.js +3 -2
  65. package/esm2015/lib/db/Models/property/property-sale/tax-exemption-metadata.js +3 -2
  66. package/esm2015/lib/db/Models/property/property-sale/tax-exemption.js +3 -2
  67. package/esm2015/lib/db/Models/property/property-share.js +3 -2
  68. package/esm2015/lib/db/Models/property/property-subscription.js +3 -2
  69. package/esm2015/lib/db/Models/property/property-valuation.js +3 -2
  70. package/esm2015/lib/db/Models/property/property.js +3 -2
  71. package/esm2015/lib/db/Models/service-notification.js +3 -2
  72. package/esm2015/lib/db/Models/sole/sole-forecast.js +4 -0
  73. package/esm2015/lib/db/Models/subscription/service-payment.js +4 -0
  74. package/esm2015/lib/db/Models/subscription/service-price.js +4 -0
  75. package/esm2015/lib/db/Models/subscription/service-product.js +4 -0
  76. package/esm2015/lib/db/Models/subscription/service-subscription-item.js +4 -0
  77. package/esm2015/lib/db/Models/subscription/service-subscription.js +4 -0
  78. package/esm2015/lib/db/Models/tax-return/tax-return-category.js +4 -0
  79. package/esm2015/lib/db/Models/tax-return/tax-return-item.js +4 -0
  80. package/esm2015/lib/db/Models/tax-return/tax-return.js +4 -0
  81. package/esm2015/lib/db/Models/transaction/transaction-allocation.js +4 -0
  82. package/esm2015/lib/db/Models/transaction/transaction-base.js +26 -0
  83. package/esm2015/lib/db/Models/transaction/transaction-metadata.js +4 -0
  84. package/esm2015/lib/db/Models/transaction/transaction-receipt.js +4 -0
  85. package/esm2015/lib/db/Models/transaction/transaction.js +4 -0
  86. package/esm2015/lib/db/Models/user/client-details.js +4 -0
  87. package/esm2015/lib/db/Models/user/client-income-types.js +4 -0
  88. package/esm2015/lib/db/Models/user/employee-details.js +4 -0
  89. package/esm2015/lib/db/Models/user/occupation.js +4 -0
  90. package/esm2015/lib/db/Models/user/registration-invite.js +4 -0
  91. package/esm2015/lib/db/Models/user/user-event-setting.js +4 -0
  92. package/esm2015/lib/db/Models/user/user-event-type-category.js +4 -0
  93. package/esm2015/lib/db/Models/user/user-event-type.js +4 -0
  94. package/esm2015/lib/db/Models/user/user-event.js +4 -0
  95. package/esm2015/lib/db/Models/user/user.js +4 -0
  96. package/esm2015/lib/db/Models/vehicle/vehicle-claim.js +4 -0
  97. package/esm2015/lib/db/Models/vehicle/vehicle-logbook.js +4 -0
  98. package/esm2015/lib/db/Models/vehicle/vehicle.js +4 -0
  99. package/esm2015/lib/interfaces/document.interface.js +1 -1
  100. package/esm2015/lib/models/account-setup/account-setup-item.js +4 -1
  101. package/esm2015/lib/models/account-setup/account-setup-items.const.js +9 -5
  102. package/esm2015/lib/models/bank/bank-account-property.js +2 -2
  103. package/esm2015/lib/models/bank/bank-account.js +3 -3
  104. package/esm2015/lib/models/bank/bank-connection.js +2 -2
  105. package/esm2015/lib/models/bank/bank-transaction.js +2 -2
  106. package/esm2015/lib/models/bank/bank.js +2 -2
  107. package/esm2015/lib/models/bank/basiq-job.js +2 -2
  108. package/esm2015/lib/models/borrowing-expense/borrowing-expense-loan.js +2 -2
  109. package/esm2015/lib/models/borrowing-expense/borrowing-expense.js +2 -2
  110. package/esm2015/lib/models/chart-accounts/chart-accounts-depreciation.js +2 -2
  111. package/esm2015/lib/models/chart-accounts/chart-accounts-heading.js +2 -2
  112. package/esm2015/lib/models/chart-accounts/chart-accounts-metadata.js +2 -2
  113. package/esm2015/lib/models/chart-accounts/chart-accounts-value.js +2 -2
  114. package/esm2015/lib/models/chart-accounts/chart-accounts.js +2 -2
  115. package/esm2015/lib/models/chat/chat.js +2 -2
  116. package/esm2015/lib/models/chat/message-document.js +2 -2
  117. package/esm2015/lib/models/chat/message.js +2 -2
  118. package/esm2015/lib/models/client/client-details.js +2 -2
  119. package/esm2015/lib/models/client/client-income-types.js +2 -2
  120. package/esm2015/lib/models/client/client-invite.js +2 -2
  121. package/esm2015/lib/models/client/client-movement.js +2 -2
  122. package/esm2015/lib/models/depreciation/depreciation-capital-project.js +2 -2
  123. package/esm2015/lib/models/depreciation/depreciation-forecast.js +2 -2
  124. package/esm2015/lib/models/depreciation/depreciation-receipt.js +2 -2
  125. package/esm2015/lib/models/depreciation/depreciation.js +2 -2
  126. package/esm2015/lib/models/document/document-folder.js +2 -2
  127. package/esm2015/lib/models/document/document.js +2 -2
  128. package/esm2015/lib/models/employee/employee-details.js +2 -2
  129. package/esm2015/lib/models/employee/employee-invite.js +2 -2
  130. package/esm2015/lib/models/firm/firm.js +2 -2
  131. package/esm2015/lib/models/income-source/income-source-forecast.js +2 -2
  132. package/esm2015/lib/models/income-source/income-source-type.js +2 -2
  133. package/esm2015/lib/models/income-source/income-source.js +2 -2
  134. package/esm2015/lib/models/income-source/salary-forecast.js +2 -2
  135. package/esm2015/lib/models/income-source/sole-forecast.js +2 -2
  136. package/esm2015/lib/models/loan/loan-payout.js +2 -2
  137. package/esm2015/lib/models/loan/loan.js +2 -2
  138. package/esm2015/lib/models/logbook/vehicle-claim.js +2 -2
  139. package/esm2015/lib/models/logbook/vehicle-logbook.js +2 -2
  140. package/esm2015/lib/models/logbook/vehicle.js +2 -2
  141. package/esm2015/lib/models/property/property-document.js +2 -2
  142. package/esm2015/lib/models/property/property.js +1 -1
  143. package/esm2015/lib/models/registration-invite/registration-invite.js +2 -2
  144. package/esm2015/lib/models/report/vehicle-expense/vehicle-expense.js +14 -0
  145. package/esm2015/lib/models/service-subscription/service-payment.js +2 -2
  146. package/esm2015/lib/models/service-subscription/service-price.js +2 -2
  147. package/esm2015/lib/models/service-subscription/service-product.js +14 -6
  148. package/esm2015/lib/models/service-subscription/service-subscription-item.js +12 -3
  149. package/esm2015/lib/models/service-subscription/service-subscription.js +29 -12
  150. package/esm2015/lib/models/tax-review/tax-review.js +2 -2
  151. package/esm2015/lib/models/tax-summary/report-item.js +1 -1
  152. package/esm2015/lib/models/transaction/transaction-allocation.js +2 -2
  153. package/esm2015/lib/models/transaction/transaction-metadata.js +2 -2
  154. package/esm2015/lib/models/transaction/transaction-receipt.js +2 -2
  155. package/esm2015/lib/models/transaction/transaction.js +2 -2
  156. package/esm2015/lib/models/user/occupation.js +2 -2
  157. package/esm2015/lib/models/user/user-roles.const.js +2 -1
  158. package/esm2015/lib/models/user/user.js +2 -2
  159. package/esm2015/lib/models/user-event/user-event-setting.js +2 -2
  160. package/esm2015/lib/models/user-event/user-event-type-category.js +2 -2
  161. package/esm2015/lib/models/user-event/user-event-type.js +2 -2
  162. package/esm2015/lib/services/account-setup/account-setup.service.js +32 -5
  163. package/esm2015/lib/services/http/bank/bank-account/bank-account.service.js +1 -1
  164. package/esm2015/lib/services/http/bank/bank-connection/bank-connection.service.js +1 -1
  165. package/esm2015/lib/services/http/bank/bank-transaction/bank-transaction.service.js +1 -1
  166. package/esm2015/lib/services/http/bank/bank.service.js +1 -1
  167. package/esm2015/lib/services/http/bank/basiq/basiq.service.js +1 -1
  168. package/esm2015/lib/services/http/chart-accounts/chart-accounts-depreciations/chart-accounts-depreciations.service.js +1 -1
  169. package/esm2015/lib/services/http/chart-accounts/chart-accounts.service.js +1 -1
  170. package/esm2015/lib/services/http/chat/chat.service.js +1 -1
  171. package/esm2015/lib/services/http/chat/message/message.service.js +1 -1
  172. package/esm2015/lib/services/http/chat/message-document/message-document.service.js +1 -1
  173. package/esm2015/lib/services/http/depreciation/depreciation-capital-project/depreciation-capital-project.service.js +1 -1
  174. package/esm2015/lib/services/http/depreciation/depreciation.service.js +1 -1
  175. package/esm2015/lib/services/http/document/document-folder/document-folder.service.js +1 -1
  176. package/esm2015/lib/services/http/firm/client-income/client-income-types.service.js +1 -1
  177. package/esm2015/lib/services/http/firm/client-invite/client-invite.service.js +1 -1
  178. package/esm2015/lib/services/http/firm/client-movement/client-movement.service.js +1 -1
  179. package/esm2015/lib/services/http/firm/employee/employee.service.js +1 -1
  180. package/esm2015/lib/services/http/firm/employee-invite/employee-invite.service.js +1 -1
  181. package/esm2015/lib/services/http/firm/firm.service.js +1 -1
  182. package/esm2015/lib/services/http/income-source/income-source-forecast/income-source-forecast.service.js +1 -1
  183. package/esm2015/lib/services/http/income-source/income-source.service.js +1 -1
  184. package/esm2015/lib/services/http/income-source/salary-forecast/salary-forecast.service.js +1 -1
  185. package/esm2015/lib/services/http/income-source/sole-forecast/sole-forecast.service.js +1 -1
  186. package/esm2015/lib/services/http/loan/loan.service.js +1 -1
  187. package/esm2015/lib/services/http/property/property-document/property-document.service.js +1 -1
  188. package/esm2015/lib/services/http/rest/rest.service.js +2 -2
  189. package/esm2015/lib/services/http/subscription/service-price.service.js +24 -0
  190. package/esm2015/lib/services/http/subscription/subscription.service.js +5 -48
  191. package/esm2015/lib/services/http/tax-review/tax-review-history/tax-review-history.service.js +1 -1
  192. package/esm2015/lib/services/http/tax-review/tax-review.service.js +1 -1
  193. package/esm2015/lib/services/http/transaction/transaction-allocation/transaction-allocation.service.js +1 -1
  194. package/esm2015/lib/services/http/transaction/transaction.service.js +1 -1
  195. package/esm2015/lib/services/http/user/user-event-setting/user-event-setting.service.js +1 -1
  196. package/esm2015/lib/services/http/user/user-event-type/user-event-type.service.js +1 -1
  197. package/esm2015/lib/services/http/user/user.service.js +1 -1
  198. package/esm2015/lib/services/http/vehicle/vehicle-claim.service.js +1 -1
  199. package/esm2015/lib/services/http/vehicle/vehicle-logbook.service.js +1 -1
  200. package/esm2015/lib/services/http/vehicle/vehicle.service.js +1 -1
  201. package/esm2015/public-api.js +11 -8
  202. package/fesm2015/taxtank-core.js +1286 -1178
  203. package/fesm2015/taxtank-core.js.map +1 -1
  204. package/lib/collections/collection.d.ts +14 -11
  205. package/lib/collections/income-source.collection.d.ts +0 -5
  206. package/lib/collections/report/vehicle-expense/vehicle-expense.collection.d.ts +9 -0
  207. package/lib/collections/{service-subscription.collection.d.ts → subscription/service-subscription.collection.d.ts} +2 -2
  208. package/lib/db/Enums/{service-payment-status.enum.d.ts → subscription/service-payment-status.enum.d.ts} +0 -0
  209. package/lib/db/Enums/subscription/service-price-list.enum.d.ts +3 -0
  210. package/lib/db/Enums/{service-price-recurring-interval.enum.d.ts → subscription/service-price-recurring-interval.enum.d.ts} +0 -0
  211. package/lib/db/Enums/{service-price-type.enum.d.ts → subscription/service-price-type.enum.d.ts} +0 -0
  212. package/lib/db/Enums/subscription/service-product-id.enum.d.ts +8 -0
  213. package/lib/db/Enums/subscription/service-product-status.enum.d.ts +4 -0
  214. package/lib/db/Enums/{service-subscription-status.enum.d.ts → subscription/service-subscription-status.enum.d.ts} +0 -0
  215. package/lib/db/Enums/user-roles.enum.d.ts +1 -0
  216. package/lib/db/Models/abstract-model.d.ts +3 -0
  217. package/lib/db/Models/address.d.ts +2 -1
  218. package/lib/db/Models/{bank-account-balance.d.ts → bank/bank-account-balance.d.ts} +2 -1
  219. package/lib/db/Models/bank/bank-account-property.d.ts +9 -0
  220. package/lib/db/Models/{bank-account.d.ts → bank/bank-account.d.ts} +6 -5
  221. package/lib/db/Models/{bank-connection.d.ts → bank/bank-connection.d.ts} +4 -3
  222. package/lib/db/Models/{bank-transaction-import.d.ts → bank/bank-transaction-import.d.ts} +2 -1
  223. package/lib/db/Models/{bank-transaction.d.ts → bank/bank-transaction.d.ts} +4 -3
  224. package/lib/db/Models/{bank.d.ts → bank/bank.d.ts} +2 -1
  225. package/lib/db/Models/{basiq-job.d.ts → bank/basiq-job.d.ts} +2 -1
  226. package/lib/db/Models/{financial-data-system.d.ts → bank/financial-data-system.d.ts} +2 -1
  227. package/lib/db/Models/{chart-accounts-depreciation.d.ts → chart-accounts/chart-accounts-depreciation.d.ts} +2 -1
  228. package/lib/db/Models/{chart-accounts-heading.d.ts → chart-accounts/chart-accounts-heading.d.ts} +2 -1
  229. package/lib/db/Models/chart-accounts/chart-accounts-metadata.d.ts +12 -0
  230. package/lib/db/Models/{chart-accounts-value.d.ts → chart-accounts/chart-accounts-value.d.ts} +2 -1
  231. package/lib/db/Models/{chart-accounts.d.ts → chart-accounts/chart-accounts.d.ts} +5 -4
  232. package/lib/db/Models/country.d.ts +2 -1
  233. package/lib/db/Models/depreciation/depreciation-capital-project.d.ts +14 -0
  234. package/lib/db/Models/{depreciation-forecast.d.ts → depreciation/depreciation-forecast.d.ts} +3 -2
  235. package/lib/db/Models/{depreciation-receipt.d.ts → depreciation/depreciation-receipt.d.ts} +2 -1
  236. package/lib/db/Models/{depreciation.d.ts → depreciation/depreciation.d.ts} +9 -9
  237. package/lib/db/Models/{document-folder.d.ts → document/document-folder.d.ts} +3 -2
  238. package/lib/db/Models/{document.d.ts → document/document.d.ts} +2 -1
  239. package/lib/db/Models/document/property-document.d.ts +18 -0
  240. package/lib/db/Models/firm/accountant/tax-review.d.ts +14 -0
  241. package/lib/db/Models/firm/accountant/ticket.d.ts +20 -0
  242. package/lib/db/Models/{chat.d.ts → firm/chat.d.ts} +4 -3
  243. package/lib/db/Models/firm/client-invite.d.ts +17 -0
  244. package/lib/db/Models/firm/client-movement.d.ts +13 -0
  245. package/lib/db/Models/firm/employee-invite.d.ts +10 -0
  246. package/lib/db/Models/{firm.d.ts → firm/firm.d.ts} +7 -6
  247. package/lib/db/Models/{message-document.d.ts → firm/message-document.d.ts} +3 -2
  248. package/lib/db/Models/{message.d.ts → firm/message.d.ts} +4 -3
  249. package/lib/db/Models/{income-source-forecast.d.ts → incomeSource/income-source-forecast.d.ts} +2 -1
  250. package/lib/db/Models/{income-source-type.d.ts → incomeSource/income-source-type.d.ts} +3 -2
  251. package/lib/db/Models/{income-source.d.ts → incomeSource/income-source.d.ts} +5 -4
  252. package/lib/db/Models/{salary-forecast.d.ts → incomeSource/salary-forecast.d.ts} +3 -2
  253. package/lib/db/Models/{borrowing-expense-loan.d.ts → loan/borrowing-expense-loan.d.ts} +3 -2
  254. package/lib/db/Models/loan/borrowing-expense.d.ts +8 -0
  255. package/lib/db/Models/{loan-payout.d.ts → loan/loan-payout.d.ts} +3 -2
  256. package/lib/db/Models/{loan.d.ts → loan/loan.d.ts} +9 -8
  257. package/lib/db/Models/phone.d.ts +2 -1
  258. package/lib/db/Models/property/property-category-movement.d.ts +3 -2
  259. package/lib/db/Models/property/property-category.d.ts +3 -2
  260. package/lib/db/Models/property/property-forecast.d.ts +2 -1
  261. package/lib/db/Models/property/property-sale/property-sale-tax-exemption-metadata.d.ts +2 -1
  262. package/lib/db/Models/property/property-sale/property-sale.d.ts +2 -1
  263. package/lib/db/Models/property/property-sale/tax-exemption-metadata.d.ts +2 -1
  264. package/lib/db/Models/property/property-sale/tax-exemption.d.ts +2 -1
  265. package/lib/db/Models/property/property-share.d.ts +4 -3
  266. package/lib/db/Models/property/property-subscription.d.ts +3 -2
  267. package/lib/db/Models/property/property-valuation.d.ts +3 -2
  268. package/lib/db/Models/property/property.d.ts +6 -5
  269. package/lib/db/Models/service-notification.d.ts +4 -3
  270. package/lib/db/Models/sole/sole-forecast.d.ts +9 -0
  271. package/lib/db/Models/{service-payment.d.ts → subscription/service-payment.d.ts} +3 -2
  272. package/lib/db/Models/{service-price.d.ts → subscription/service-price.d.ts} +4 -3
  273. package/lib/db/Models/subscription/service-product.d.ts +19 -0
  274. package/lib/db/Models/{service-subscription-item.d.ts → subscription/service-subscription-item.d.ts} +2 -1
  275. package/lib/db/Models/{service-subscription.d.ts → subscription/service-subscription.d.ts} +4 -3
  276. package/lib/db/Models/{tax-return-category.d.ts → tax-return/tax-return-category.d.ts} +3 -2
  277. package/lib/db/Models/{tax-return-item.d.ts → tax-return/tax-return-item.d.ts} +2 -1
  278. package/lib/db/Models/{tax-return.d.ts → tax-return/tax-return.d.ts} +2 -1
  279. package/lib/db/Models/transaction/transaction-allocation.d.ts +9 -0
  280. package/lib/db/Models/{transaction-base.d.ts → transaction/transaction-base.d.ts} +4 -3
  281. package/lib/db/Models/{transaction-metadata.d.ts → transaction/transaction-metadata.d.ts} +3 -2
  282. package/lib/db/Models/{transaction-receipt.d.ts → transaction/transaction-receipt.d.ts} +2 -1
  283. package/lib/db/Models/{transaction.d.ts → transaction/transaction.d.ts} +9 -9
  284. package/lib/db/Models/{client-details.d.ts → user/client-details.d.ts} +7 -6
  285. package/lib/db/Models/{client-income-types.d.ts → user/client-income-types.d.ts} +2 -1
  286. package/lib/db/Models/user/employee-details.d.ts +8 -0
  287. package/lib/db/Models/user/occupation.d.ts +6 -0
  288. package/lib/db/Models/{registration-invite.d.ts → user/registration-invite.d.ts} +3 -2
  289. package/lib/db/Models/{user-event-setting.d.ts → user/user-event-setting.d.ts} +2 -1
  290. package/lib/db/Models/user/user-event-type-category.d.ts +5 -0
  291. package/lib/db/Models/{user-event-type.d.ts → user/user-event-type.d.ts} +3 -2
  292. package/lib/db/Models/{user-event.d.ts → user/user-event.d.ts} +3 -2
  293. package/lib/db/Models/{user.d.ts → user/user.d.ts} +14 -13
  294. package/lib/db/Models/vehicle/vehicle-claim.d.ts +14 -0
  295. package/lib/db/Models/{vehicle-logbook.d.ts → vehicle/vehicle-logbook.d.ts} +4 -3
  296. package/lib/db/Models/vehicle/vehicle.d.ts +11 -0
  297. package/lib/models/account-setup/account-setup-item.d.ts +1 -0
  298. package/lib/models/bank/bank-account-property.d.ts +1 -1
  299. package/lib/models/bank/bank-account.d.ts +2 -2
  300. package/lib/models/bank/bank-connection.d.ts +1 -1
  301. package/lib/models/bank/bank-transaction.d.ts +1 -1
  302. package/lib/models/bank/bank.d.ts +1 -1
  303. package/lib/models/bank/basiq-job.d.ts +1 -1
  304. package/lib/models/borrowing-expense/borrowing-expense-loan.d.ts +1 -1
  305. package/lib/models/borrowing-expense/borrowing-expense.d.ts +1 -1
  306. package/lib/models/chart-accounts/chart-accounts-depreciation.d.ts +1 -1
  307. package/lib/models/chart-accounts/chart-accounts-heading.d.ts +1 -1
  308. package/lib/models/chart-accounts/chart-accounts-metadata.d.ts +1 -1
  309. package/lib/models/chart-accounts/chart-accounts-value.d.ts +1 -1
  310. package/lib/models/chart-accounts/chart-accounts.d.ts +1 -1
  311. package/lib/models/chat/chat.d.ts +1 -1
  312. package/lib/models/chat/message-document.d.ts +1 -1
  313. package/lib/models/chat/message.d.ts +1 -1
  314. package/lib/models/client/client-details.d.ts +1 -1
  315. package/lib/models/client/client-income-types.d.ts +1 -1
  316. package/lib/models/client/client-invite.d.ts +1 -1
  317. package/lib/models/client/client-movement.d.ts +1 -1
  318. package/lib/models/depreciation/depreciation-capital-project.d.ts +1 -1
  319. package/lib/models/depreciation/depreciation-forecast.d.ts +1 -1
  320. package/lib/models/depreciation/depreciation-receipt.d.ts +1 -1
  321. package/lib/models/depreciation/depreciation.d.ts +3 -3
  322. package/lib/models/document/document-folder.d.ts +1 -1
  323. package/lib/models/document/document.d.ts +1 -1
  324. package/lib/models/employee/employee-details.d.ts +1 -1
  325. package/lib/models/employee/employee-invite.d.ts +1 -1
  326. package/lib/models/firm/firm.d.ts +1 -1
  327. package/lib/models/income-source/income-source-forecast.d.ts +1 -1
  328. package/lib/models/income-source/income-source-type.d.ts +1 -1
  329. package/lib/models/income-source/income-source.d.ts +1 -1
  330. package/lib/models/income-source/salary-forecast.d.ts +1 -1
  331. package/lib/models/income-source/sole-forecast.d.ts +1 -1
  332. package/lib/models/loan/loan-payout.d.ts +1 -1
  333. package/lib/models/loan/loan.d.ts +1 -1
  334. package/lib/models/logbook/vehicle-claim.d.ts +1 -1
  335. package/lib/models/logbook/vehicle-logbook.d.ts +1 -1
  336. package/lib/models/logbook/vehicle.d.ts +1 -1
  337. package/lib/models/property/property-document.d.ts +1 -1
  338. package/lib/models/property/property.d.ts +0 -2
  339. package/lib/models/registration-invite/registration-invite.d.ts +1 -1
  340. package/lib/models/report/vehicle-expense/vehicle-expense.d.ts +10 -0
  341. package/lib/models/service-subscription/service-payment.d.ts +1 -1
  342. package/lib/models/service-subscription/service-price.d.ts +1 -1
  343. package/lib/models/service-subscription/service-product.d.ts +5 -3
  344. package/lib/models/service-subscription/service-subscription-item.d.ts +1 -1
  345. package/lib/models/service-subscription/service-subscription.d.ts +13 -3
  346. package/lib/models/tax-review/tax-review.d.ts +1 -1
  347. package/lib/models/tax-summary/report-item.d.ts +1 -1
  348. package/lib/models/transaction/transaction-allocation.d.ts +1 -1
  349. package/lib/models/transaction/transaction-metadata.d.ts +1 -1
  350. package/lib/models/transaction/transaction-receipt.d.ts +1 -1
  351. package/lib/models/transaction/transaction.d.ts +1 -1
  352. package/lib/models/user/occupation.d.ts +1 -1
  353. package/lib/models/user/user.d.ts +1 -1
  354. package/lib/models/user-event/user-event-setting.d.ts +1 -1
  355. package/lib/models/user-event/user-event-type-category.d.ts +1 -1
  356. package/lib/models/user-event/user-event-type.d.ts +1 -1
  357. package/lib/services/account-setup/account-setup.service.d.ts +14 -1
  358. package/lib/services/http/bank/bank-account/bank-account.service.d.ts +1 -1
  359. package/lib/services/http/bank/bank-connection/bank-connection.service.d.ts +1 -1
  360. package/lib/services/http/bank/bank-transaction/bank-transaction.service.d.ts +1 -1
  361. package/lib/services/http/bank/bank.service.d.ts +1 -1
  362. package/lib/services/http/bank/basiq/basiq.service.d.ts +1 -1
  363. package/lib/services/http/chart-accounts/chart-accounts-depreciations/chart-accounts-depreciations.service.d.ts +1 -1
  364. package/lib/services/http/chat/chat.service.d.ts +1 -1
  365. package/lib/services/http/chat/message/message.service.d.ts +1 -1
  366. package/lib/services/http/depreciation/depreciation.service.d.ts +1 -1
  367. package/lib/services/http/document/document-folder/document-folder.service.d.ts +1 -1
  368. package/lib/services/http/firm/client-invite/client-invite.service.d.ts +1 -1
  369. package/lib/services/http/firm/client-movement/client-movement.service.d.ts +1 -1
  370. package/lib/services/http/firm/employee/employee.service.d.ts +1 -1
  371. package/lib/services/http/firm/employee-invite/employee-invite.service.d.ts +1 -1
  372. package/lib/services/http/income-source/income-source-forecast/income-source-forecast.service.d.ts +1 -1
  373. package/lib/services/http/income-source/income-source.service.d.ts +1 -1
  374. package/lib/services/http/income-source/salary-forecast/salary-forecast.service.d.ts +1 -1
  375. package/lib/services/http/income-source/sole-forecast/sole-forecast.service.d.ts +1 -1
  376. package/lib/services/http/loan/loan.service.d.ts +1 -1
  377. package/lib/services/http/property/property-document/property-document.service.d.ts +1 -1
  378. package/lib/services/http/rest/rest.service.d.ts +1 -1
  379. package/lib/services/http/subscription/service-price.service.d.ts +14 -0
  380. package/lib/services/http/subscription/subscription.service.d.ts +2 -9
  381. package/lib/services/http/tax-review/tax-review-history/tax-review-history.service.d.ts +1 -1
  382. package/lib/services/http/tax-review/tax-review.service.d.ts +1 -1
  383. package/lib/services/http/transaction/transaction-allocation/transaction-allocation.service.d.ts +1 -1
  384. package/lib/services/http/transaction/transaction.service.d.ts +1 -1
  385. package/lib/services/http/user/user-event-setting/user-event-setting.service.d.ts +1 -1
  386. package/lib/services/http/user/user-event-type/user-event-type.service.d.ts +1 -1
  387. package/lib/services/http/vehicle/vehicle-claim.service.d.ts +1 -1
  388. package/lib/services/http/vehicle/vehicle.service.d.ts +1 -1
  389. package/package.json +1 -1
  390. package/public-api.d.ts +10 -7
  391. package/esm2015/lib/collections/service-price.collection.js +0 -10
  392. package/esm2015/lib/collections/service-subscription.collection.js +0 -17
  393. package/esm2015/lib/db/Enums/service-payment-status.enum.js +0 -6
  394. package/esm2015/lib/db/Enums/service-price-type.enum.js +0 -6
  395. package/esm2015/lib/db/Models/bank-account-balance.js +0 -3
  396. package/esm2015/lib/db/Models/bank-account-property.js +0 -3
  397. package/esm2015/lib/db/Models/bank-account.js +0 -3
  398. package/esm2015/lib/db/Models/bank-connection.js +0 -3
  399. package/esm2015/lib/db/Models/bank-transaction-import.js +0 -3
  400. package/esm2015/lib/db/Models/bank-transaction.js +0 -3
  401. package/esm2015/lib/db/Models/bank.js +0 -3
  402. package/esm2015/lib/db/Models/basiq-job.js +0 -3
  403. package/esm2015/lib/db/Models/borrowing-expense-loan.js +0 -3
  404. package/esm2015/lib/db/Models/borrowing-expense.js +0 -3
  405. package/esm2015/lib/db/Models/chart-accounts-depreciation.js +0 -3
  406. package/esm2015/lib/db/Models/chart-accounts-heading.js +0 -3
  407. package/esm2015/lib/db/Models/chart-accounts-metadata.js +0 -3
  408. package/esm2015/lib/db/Models/chart-accounts-value.js +0 -3
  409. package/esm2015/lib/db/Models/chart-accounts.js +0 -3
  410. package/esm2015/lib/db/Models/chat.js +0 -3
  411. package/esm2015/lib/db/Models/client-details.js +0 -3
  412. package/esm2015/lib/db/Models/client-income-types.js +0 -3
  413. package/esm2015/lib/db/Models/client-invite.js +0 -3
  414. package/esm2015/lib/db/Models/client-movement.js +0 -3
  415. package/esm2015/lib/db/Models/depreciation-capital-project.js +0 -3
  416. package/esm2015/lib/db/Models/depreciation-forecast.js +0 -3
  417. package/esm2015/lib/db/Models/depreciation-receipt.js +0 -3
  418. package/esm2015/lib/db/Models/depreciation.js +0 -4
  419. package/esm2015/lib/db/Models/document-folder.js +0 -3
  420. package/esm2015/lib/db/Models/document.js +0 -3
  421. package/esm2015/lib/db/Models/employee-details.js +0 -3
  422. package/esm2015/lib/db/Models/employee-invite.js +0 -3
  423. package/esm2015/lib/db/Models/financial-data-system.js +0 -3
  424. package/esm2015/lib/db/Models/firm.js +0 -3
  425. package/esm2015/lib/db/Models/income-source-forecast.js +0 -3
  426. package/esm2015/lib/db/Models/income-source-type.js +0 -3
  427. package/esm2015/lib/db/Models/income-source.js +0 -3
  428. package/esm2015/lib/db/Models/loan-payout.js +0 -3
  429. package/esm2015/lib/db/Models/loan.js +0 -3
  430. package/esm2015/lib/db/Models/message-document.js +0 -3
  431. package/esm2015/lib/db/Models/message.js +0 -3
  432. package/esm2015/lib/db/Models/occupation.js +0 -3
  433. package/esm2015/lib/db/Models/property/property-document.js +0 -3
  434. package/esm2015/lib/db/Models/registration-invite.js +0 -3
  435. package/esm2015/lib/db/Models/salary-forecast.js +0 -3
  436. package/esm2015/lib/db/Models/service-payment.js +0 -3
  437. package/esm2015/lib/db/Models/service-price.js +0 -3
  438. package/esm2015/lib/db/Models/service-product.js +0 -3
  439. package/esm2015/lib/db/Models/service-subscription-item.js +0 -3
  440. package/esm2015/lib/db/Models/service-subscription.js +0 -3
  441. package/esm2015/lib/db/Models/sole-forecast.js +0 -3
  442. package/esm2015/lib/db/Models/tax-return-category.js +0 -3
  443. package/esm2015/lib/db/Models/tax-return-item.js +0 -3
  444. package/esm2015/lib/db/Models/tax-return.js +0 -3
  445. package/esm2015/lib/db/Models/tax-review.js +0 -3
  446. package/esm2015/lib/db/Models/ticket.js +0 -3
  447. package/esm2015/lib/db/Models/transaction-allocation.js +0 -3
  448. package/esm2015/lib/db/Models/transaction-base.js +0 -25
  449. package/esm2015/lib/db/Models/transaction-metadata.js +0 -3
  450. package/esm2015/lib/db/Models/transaction-receipt.js +0 -3
  451. package/esm2015/lib/db/Models/transaction.js +0 -4
  452. package/esm2015/lib/db/Models/user-event-setting.js +0 -3
  453. package/esm2015/lib/db/Models/user-event-type-category.js +0 -3
  454. package/esm2015/lib/db/Models/user-event-type.js +0 -3
  455. package/esm2015/lib/db/Models/user-event.js +0 -3
  456. package/esm2015/lib/db/Models/user.js +0 -3
  457. package/esm2015/lib/db/Models/vehicle-claim.js +0 -3
  458. package/esm2015/lib/db/Models/vehicle-logbook.js +0 -3
  459. package/esm2015/lib/db/Models/vehicle.js +0 -3
  460. package/lib/collections/service-price.collection.d.ts +0 -6
  461. package/lib/db/Models/bank-account-property.d.ts +0 -8
  462. package/lib/db/Models/borrowing-expense.d.ts +0 -7
  463. package/lib/db/Models/chart-accounts-metadata.d.ts +0 -11
  464. package/lib/db/Models/client-invite.d.ts +0 -16
  465. package/lib/db/Models/client-movement.d.ts +0 -12
  466. package/lib/db/Models/depreciation-capital-project.d.ts +0 -13
  467. package/lib/db/Models/employee-details.d.ts +0 -7
  468. package/lib/db/Models/employee-invite.d.ts +0 -9
  469. package/lib/db/Models/occupation.d.ts +0 -5
  470. package/lib/db/Models/property/property-document.d.ts +0 -13
  471. package/lib/db/Models/service-product.d.ts +0 -12
  472. package/lib/db/Models/sole-forecast.d.ts +0 -8
  473. package/lib/db/Models/tax-review.d.ts +0 -13
  474. package/lib/db/Models/ticket.d.ts +0 -19
  475. package/lib/db/Models/transaction-allocation.d.ts +0 -8
  476. package/lib/db/Models/user-event-type-category.d.ts +0 -4
  477. package/lib/db/Models/vehicle-claim.d.ts +0 -13
  478. package/lib/db/Models/vehicle.d.ts +0 -10
@@ -13,14 +13,15 @@ import flatten from 'lodash/flatten';
13
13
  import hasIn from 'lodash/hasIn';
14
14
  import first from 'lodash/first';
15
15
  import last from 'lodash/last';
16
+ import compact from 'lodash/compact';
16
17
  import uniqBy from 'lodash/uniqBy';
17
18
  import concat from 'lodash/concat';
18
- import compact from 'lodash/compact';
19
19
  import { __decorate, __awaiter } from 'tslib';
20
20
  import * as moment from 'moment';
21
21
  import { DateRange } from 'moment-range';
22
22
  import cloneDeep$1 from 'lodash/cloneDeep';
23
23
  import { Validators, FormGroup, FormControl } from '@angular/forms';
24
+ import fromPairs from 'lodash/fromPairs';
24
25
  import _ from 'lodash';
25
26
  import { EventSourcePolyfill } from 'event-source-polyfill/src/eventsource.min.js';
26
27
  import * as i1$1 from '@angular/router';
@@ -874,9 +875,44 @@ class Collection {
874
875
  create(items = []) {
875
876
  return new this.constructor(items);
876
877
  }
878
+ /**
879
+ * Iterator that allow to iterate collection items
880
+ */
881
+ [Symbol.iterator]() {
882
+ return this.items.values();
883
+ }
884
+ get first() {
885
+ return first(this.items);
886
+ }
887
+ get last() {
888
+ return last(this.items);
889
+ }
890
+ push(item) {
891
+ return this.items.push(item);
892
+ }
893
+ replaceBy(path, item) {
894
+ const index = this.findIndexBy(path, get(item, path));
895
+ if (index >= 0) {
896
+ this.items.splice(index, 1, item);
897
+ }
898
+ return this;
899
+ }
900
+ removeBy(path, item) {
901
+ const index = this.findIndexBy(path, get(item, path));
902
+ if (index >= 0) {
903
+ this.items.splice(index, 1);
904
+ }
905
+ return this;
906
+ }
907
+ toArray() {
908
+ return [...this.items];
909
+ }
877
910
  groupBy(path = '') {
878
911
  return new CollectionDictionary(this, path);
879
912
  }
913
+ /**
914
+ * @TODO remove and use dictionary instead
915
+ */
880
916
  indexBy(path) {
881
917
  // Create empty initial object for groups
882
918
  const result = {};
@@ -885,13 +921,6 @@ class Collection {
885
921
  });
886
922
  return result;
887
923
  }
888
- /**
889
- * Iterator that allow to iterate collection items
890
- */
891
- [Symbol.iterator]() {
892
- // .values() returns Iterator instance for array
893
- return this.items.values();
894
- }
895
924
  /**
896
925
  * get collection length
897
926
  */
@@ -904,30 +933,24 @@ class Collection {
904
933
  getIds() {
905
934
  return this.items.map((item) => item['id']);
906
935
  }
907
- findBy(path, value) {
908
- return this.items.find((item) => get(item, path) === value);
909
- }
910
936
  getBy(path, value) {
911
937
  return this.create(this.items.filter((item) => get(item, path) === value));
912
938
  }
913
- /**
914
- * Get single item by id
915
- */
916
- getById(id) {
917
- return this.items.find((item) => item['id'] === id);
918
- }
919
939
  getByIds(ids) {
920
940
  return this.items.filter((item) => ids.includes(item['id']));
921
941
  }
942
+ findBy(path, value) {
943
+ return this.items.find((item) => get(item, path) === value);
944
+ }
945
+ findIndexBy(path, value) {
946
+ return this.items.findIndex((item) => get(item, path) === value);
947
+ }
922
948
  /**
923
949
  * Get total sum of items by field
924
950
  */
925
951
  sumBy(path) {
926
952
  return +this.items.reduce((sum, item) => sum + Number(get(item, path)), 0).toFixed(2);
927
953
  }
928
- toArray() {
929
- return [...this.items];
930
- }
931
954
  /**
932
955
  * Filter items by specific provided callback
933
956
  */
@@ -937,14 +960,8 @@ class Collection {
937
960
  /**
938
961
  * Sort collection items by provided field
939
962
  */
940
- sortBy(filed = 'id', isDesc = true) {
941
- sort(this.items, filed, isDesc);
942
- }
943
- get first() {
944
- return first(this.items);
945
- }
946
- get last() {
947
- return last(this.items);
963
+ sortBy(field = 'id', isDesc = true) {
964
+ sort(this.items, field, isDesc);
948
965
  }
949
966
  getByDateRange(from, to, dateField = 'date') {
950
967
  return this.create(this.items.filter((item) => item[dateField] >= from && item[dateField] <= to));
@@ -953,7 +970,7 @@ class Collection {
953
970
 
954
971
  class AccountSetupItemCollection extends Collection {
955
972
  constructor(items) {
956
- super(items);
973
+ super(compact(items));
957
974
  this.sortBy('isCompleted', false);
958
975
  }
959
976
  isCompleted() {
@@ -1602,13 +1619,6 @@ class IncomeSourceCollection extends Collection {
1602
1619
  filterByTypes(types) {
1603
1620
  return this.items.filter((incomeSource) => types.includes(incomeSource.type));
1604
1621
  }
1605
- /**
1606
- * Get income source by provided Id
1607
- * @param id
1608
- */
1609
- getById(id) {
1610
- return this.items.find((incomeSource) => incomeSource.id === id);
1611
- }
1612
1622
  /**
1613
1623
  * Get income sources list of forecasts
1614
1624
  */
@@ -1909,7 +1919,13 @@ const CHART_ACCOUNTS_CATEGORIES = {
1909
1919
  ]
1910
1920
  };
1911
1921
 
1912
- class TransactionBase {
1922
+ class AbstractModel {
1923
+ hasValue(value, path = 'id') {
1924
+ return get(path) === value;
1925
+ }
1926
+ }
1927
+
1928
+ class TransactionBase extends AbstractModel {
1913
1929
  /**
1914
1930
  * Check if current tank is Property
1915
1931
  */
@@ -1983,7 +1999,7 @@ var ChartAccountsListEnum;
1983
1999
  ChartAccountsListEnum[ChartAccountsListEnum["TAX_OFFSETS_N_R_A_S"] = 571] = "TAX_OFFSETS_N_R_A_S";
1984
2000
  })(ChartAccountsListEnum || (ChartAccountsListEnum = {}));
1985
2001
 
1986
- class DepreciationCapitalProject$1 {
2002
+ class DepreciationCapitalProject$1 extends AbstractModel {
1987
2003
  }
1988
2004
 
1989
2005
  class DepreciationCapitalProject extends DepreciationCapitalProject$1 {
@@ -1992,7 +2008,7 @@ __decorate([
1992
2008
  Type(() => Date)
1993
2009
  ], DepreciationCapitalProject.prototype, "effectiveDate", void 0);
1994
2010
 
1995
- class DepreciationForecast$1 {
2011
+ class DepreciationForecast$1 extends AbstractModel {
1996
2012
  }
1997
2013
 
1998
2014
  class DepreciationForecast extends DepreciationForecast$1 {
@@ -2026,16 +2042,16 @@ class DepreciationForecast extends DepreciationForecast$1 {
2026
2042
  }
2027
2043
  }
2028
2044
 
2029
- class ChartAccounts$1 {
2045
+ class ChartAccounts$1 extends AbstractModel {
2030
2046
  }
2031
2047
 
2032
- class ChartAccountsHeading$1 {
2048
+ class ChartAccountsHeading$1 extends AbstractModel {
2033
2049
  }
2034
2050
 
2035
2051
  class ChartAccountsHeading extends ChartAccountsHeading$1 {
2036
2052
  }
2037
2053
 
2038
- class ChartAccountsMetadata$1 {
2054
+ class ChartAccountsMetadata$1 extends AbstractModel {
2039
2055
  }
2040
2056
 
2041
2057
  var ChartAccountsMetadataListEnum;
@@ -2212,7 +2228,7 @@ __decorate([
2212
2228
  Type(() => ChartAccountsMetadata)
2213
2229
  ], ChartAccounts.prototype, "metadata", void 0);
2214
2230
 
2215
- class BankTransaction$1 {
2231
+ class BankTransaction$1 extends AbstractModel {
2216
2232
  }
2217
2233
 
2218
2234
  var BankTransactionTypeEnum;
@@ -2236,13 +2252,13 @@ var TransactionTypeEnum;
2236
2252
  TransactionTypeEnum[TransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
2237
2253
  })(TransactionTypeEnum || (TransactionTypeEnum = {}));
2238
2254
 
2239
- class Property$1 {
2255
+ class Property$1 extends AbstractModel {
2240
2256
  }
2241
2257
 
2242
- class PropertySubscription$1 {
2258
+ class PropertySubscription$1 extends AbstractModel {
2243
2259
  }
2244
2260
 
2245
- class User$1 {
2261
+ class User$1 extends AbstractModel {
2246
2262
  }
2247
2263
 
2248
2264
  var UserStatusEnum;
@@ -2264,13 +2280,14 @@ var UserRolesEnum;
2264
2280
  UserRolesEnum["SUBSCRIPTION"] = "ROLE_USER_SUBSCRIPTION";
2265
2281
  UserRolesEnum["WORK_TANK"] = "ROLE_USER_WORK";
2266
2282
  UserRolesEnum["PROPERTY_TANK"] = "ROLE_USER_PROPERTY";
2283
+ UserRolesEnum["SOLE_TANK"] = "ROLE_USER_SOLE";
2267
2284
  UserRolesEnum["SWITCH_USER"] = "ROLE_PREVIOUS_ADMIN";
2268
2285
  })(UserRolesEnum || (UserRolesEnum = {}));
2269
2286
 
2270
- class Address$1 {
2287
+ class Address$1 extends AbstractModel {
2271
2288
  }
2272
2289
 
2273
- class Country$1 {
2290
+ class Country$1 extends AbstractModel {
2274
2291
  }
2275
2292
 
2276
2293
  class Country extends Country$1 {
@@ -2319,19 +2336,19 @@ const USER_WORK_POSITION = {
2319
2336
  [UserRolesEnum.FIRM_OWNER]: 'Firm Owner'
2320
2337
  };
2321
2338
 
2322
- class ClientDetails$1 {
2339
+ class ClientDetails$1 extends AbstractModel {
2323
2340
  }
2324
2341
 
2325
2342
  class ClientDetails extends ClientDetails$1 {
2326
2343
  }
2327
2344
 
2328
- class EmployeeDetails$1 {
2345
+ class EmployeeDetails$1 extends AbstractModel {
2329
2346
  }
2330
2347
 
2331
- class Firm$1 {
2348
+ class Firm$1 extends AbstractModel {
2332
2349
  }
2333
2350
 
2334
- class Phone$1 {
2351
+ class Phone$1 extends AbstractModel {
2335
2352
  }
2336
2353
 
2337
2354
  var PhoneTypeEnum;
@@ -2380,24 +2397,46 @@ __decorate([
2380
2397
  Type(() => Firm)
2381
2398
  ], EmployeeDetails.prototype, "firm", void 0);
2382
2399
 
2383
- class ServiceSubscription$1 {
2400
+ class ServiceSubscription$1 extends AbstractModel {
2384
2401
  }
2385
2402
 
2386
- class ServiceSubscriptionItem$1 {
2403
+ class ServiceSubscriptionItem$1 extends AbstractModel {
2387
2404
  }
2388
2405
 
2389
- class ServicePrice$1 {
2406
+ class ServicePrice$1 extends AbstractModel {
2390
2407
  }
2391
2408
 
2392
- class ServiceProduct$1 {
2409
+ class ServiceProduct$1 extends AbstractModel {
2393
2410
  }
2394
2411
 
2412
+ var ServiceProductStatusEnum;
2413
+ (function (ServiceProductStatusEnum) {
2414
+ ServiceProductStatusEnum[ServiceProductStatusEnum["ARCHIVED"] = 0] = "ARCHIVED";
2415
+ ServiceProductStatusEnum[ServiceProductStatusEnum["ACTIVE"] = 1] = "ACTIVE";
2416
+ })(ServiceProductStatusEnum || (ServiceProductStatusEnum = {}));
2417
+
2418
+ var ServiceProductIdEnum;
2419
+ (function (ServiceProductIdEnum) {
2420
+ ServiceProductIdEnum[ServiceProductIdEnum["WORK_TANK_OLD"] = 1] = "WORK_TANK_OLD";
2421
+ ServiceProductIdEnum[ServiceProductIdEnum["PROPERTY_OLD"] = 2] = "PROPERTY_OLD";
2422
+ ServiceProductIdEnum[ServiceProductIdEnum["PROPERTY_TANK"] = 3] = "PROPERTY_TANK";
2423
+ ServiceProductIdEnum[ServiceProductIdEnum["WORK_TANK"] = 4] = "WORK_TANK";
2424
+ ServiceProductIdEnum[ServiceProductIdEnum["PROPERTIES"] = 5] = "PROPERTIES";
2425
+ ServiceProductIdEnum[ServiceProductIdEnum["SOLE_TANK"] = 6] = "SOLE_TANK";
2426
+ })(ServiceProductIdEnum || (ServiceProductIdEnum = {}));
2427
+
2395
2428
  class ServiceProduct extends ServiceProduct$1 {
2396
- isProperty() {
2397
- return this.title === 'Property';
2429
+ isProperties() {
2430
+ return [ServiceProductIdEnum.PROPERTY_OLD, ServiceProductIdEnum.PROPERTIES].includes(this.id);
2398
2431
  }
2399
- isWork() {
2400
- return this.title === 'Work Tank';
2432
+ isWorkTank() {
2433
+ return [ServiceProductIdEnum.WORK_TANK_OLD, ServiceProductIdEnum.WORK_TANK].includes(this.id);
2434
+ }
2435
+ isSoleTank() {
2436
+ return this.id === ServiceProductIdEnum.SOLE_TANK;
2437
+ }
2438
+ isArchived() {
2439
+ return this.status === ServiceProductStatusEnum.ARCHIVED;
2401
2440
  }
2402
2441
  }
2403
2442
 
@@ -2407,9 +2446,22 @@ __decorate([
2407
2446
  Type(() => ServiceProduct)
2408
2447
  ], ServicePrice.prototype, "product", void 0);
2409
2448
 
2449
+ var ServicePriceListEnum;
2450
+ (function (ServicePriceListEnum) {
2451
+ ServicePriceListEnum[ServicePriceListEnum["PROPERTIES"] = 5] = "PROPERTIES";
2452
+ })(ServicePriceListEnum || (ServicePriceListEnum = {}));
2453
+
2454
+ /**
2455
+ * backend bd doesn't support dynamic prices, as far as we have just one product like that we keep it hardcoded
2456
+ */
2457
+ const PROPERTY_TANK_PRICE = 9;
2410
2458
  class ServiceSubscriptionItem extends ServiceSubscriptionItem$1 {
2411
2459
  get total() {
2412
- return this.price.amount * this.quantity;
2460
+ let price = this.price.amount * this.quantity;
2461
+ if (this.price.id === ServicePriceListEnum.PROPERTIES) {
2462
+ price += PROPERTY_TANK_PRICE;
2463
+ }
2464
+ return price;
2413
2465
  }
2414
2466
  }
2415
2467
  __decorate([
@@ -2452,14 +2504,14 @@ class ServiceSubscription extends ServiceSubscription$1 {
2452
2504
  return this.items.reduce((sum, item) => sum + item.total, 0);
2453
2505
  }
2454
2506
  get propertyQuantity() {
2455
- return this.propertyTankItem ? this.propertyTankItem.quantity : 0;
2507
+ return this.propertiesItem ? this.propertiesItem.quantity : 0;
2456
2508
  }
2457
2509
  /**
2458
2510
  * get type of subscription
2459
2511
  */
2460
2512
  get type() {
2461
2513
  const workTankProduct = this.items.find((item) => {
2462
- return item.price.product.isWork();
2514
+ return item.price.product.isWorkTank();
2463
2515
  });
2464
2516
  if (!this.workTankItem || !this.isActive) {
2465
2517
  return SubscriptionTypeEnum.WITHOUT_SUBSCRIPTION;
@@ -2468,9 +2520,9 @@ class ServiceSubscription extends ServiceSubscription$1 {
2468
2520
  return SubscriptionTypeEnum.INDIVIDUAL;
2469
2521
  }
2470
2522
  const propertyTankProduct = this.items.find((item) => {
2471
- return item.price.product.isProperty();
2523
+ return item.price.product.isProperties();
2472
2524
  });
2473
- if (!!this.propertyTankItem && propertyTankProduct.quantity === PROPERTY_INVESTOR_MAX_PROPERTIES) {
2525
+ if (!!this.propertiesItem && propertyTankProduct.quantity === PROPERTY_INVESTOR_MAX_PROPERTIES) {
2474
2526
  return SubscriptionTypeEnum.INVESTOR;
2475
2527
  }
2476
2528
  return SubscriptionTypeEnum.INVESTOR_PLUS;
@@ -2487,12 +2539,6 @@ class ServiceSubscription extends ServiceSubscription$1 {
2487
2539
  get description() {
2488
2540
  return SUBSCRIPTION_DESCRIPTION[this.type];
2489
2541
  }
2490
- get workTankItem() {
2491
- return this.items.find((item) => item.price.product.isWork());
2492
- }
2493
- get propertyTankItem() {
2494
- return this.items.find((item) => item.price.product.isProperty());
2495
- }
2496
2542
  /**
2497
2543
  * This check on getIsActive need for firm. Accountant has a endDate, but user has not endDate
2498
2544
  * and for user we add check for endDate
@@ -2537,6 +2583,21 @@ class ServiceSubscription extends ServiceSubscription$1 {
2537
2583
  isTrialExpiring() {
2538
2584
  return this.daysRemain > 0 && this.daysRemain <= this.lastTrialDays;
2539
2585
  }
2586
+ isRenewable() {
2587
+ return !this.isTrial && !this.isArchived() && this.isActive;
2588
+ }
2589
+ /**
2590
+ * @TODO move to collection
2591
+ */
2592
+ get workTankItem() {
2593
+ return this.items.find((item) => item.price.product.isWorkTank());
2594
+ }
2595
+ get soleTankItem() {
2596
+ return this.items.find((item) => item.price.product.isSoleTank());
2597
+ }
2598
+ get propertiesItem() {
2599
+ return this.items.find((item) => item.price.product.isProperties());
2600
+ }
2540
2601
  hasPropertyTank() {
2541
2602
  return !!this.items.find((subscriptionItem) => {
2542
2603
  return subscriptionItem.price.product.role.includes(UserRolesEnum.PROPERTY_TANK);
@@ -2547,6 +2608,14 @@ class ServiceSubscription extends ServiceSubscription$1 {
2547
2608
  return subscriptionItem.price.product.role.includes(UserRolesEnum.WORK_TANK);
2548
2609
  });
2549
2610
  }
2611
+ /**
2612
+ * bought before price updates, active for some time to let customer select a new plan
2613
+ * impossible to update, only prolong or buy new
2614
+ */
2615
+ isArchived() {
2616
+ // subscription with at least one archived product considered as archived
2617
+ return !!this.items.map((item) => item.price.product.isArchived()).length;
2618
+ }
2550
2619
  }
2551
2620
  __decorate([
2552
2621
  Type(() => Date)
@@ -2694,7 +2763,7 @@ __decorate([
2694
2763
  Type(() => User)
2695
2764
  ], PropertySubscription.prototype, "user", void 0);
2696
2765
 
2697
- class PropertyCategory$1 {
2766
+ class PropertyCategory$1 extends AbstractModel {
2698
2767
  }
2699
2768
 
2700
2769
  class PropertyCategory extends PropertyCategory$1 {
@@ -2707,10 +2776,16 @@ class PropertyCategory extends PropertyCategory$1 {
2707
2776
  }
2708
2777
  }
2709
2778
 
2710
- class PropertyValuation$1 {
2779
+ class PropertyValuation$1 extends AbstractModel {
2711
2780
  }
2712
2781
 
2713
- class PropertyDocument$1 {
2782
+ class PropertyDocument$1 extends AbstractModel {
2783
+ getApiUrlPrefix() {
2784
+ return '';
2785
+ }
2786
+ getEntity() {
2787
+ return undefined;
2788
+ }
2714
2789
  }
2715
2790
 
2716
2791
  // @TODO this enum should come from backend
@@ -2768,7 +2843,7 @@ __decorate([
2768
2843
  Exclude()
2769
2844
  ], PropertyValuation.prototype, "documentFile", void 0);
2770
2845
 
2771
- class PropertyForecast$1 {
2846
+ class PropertyForecast$1 extends AbstractModel {
2772
2847
  }
2773
2848
 
2774
2849
  class PropertyForecast extends PropertyForecast$1 {
@@ -2819,7 +2894,7 @@ __decorate([
2819
2894
  Transform(({ value }) => +value)
2820
2895
  ], PropertyForecast.prototype, "marketValue", void 0);
2821
2896
 
2822
- class PropertyCategoryMovement$1 {
2897
+ class PropertyCategoryMovement$1 extends AbstractModel {
2823
2898
  }
2824
2899
 
2825
2900
  class PropertyCategoryMovement extends PropertyCategoryMovement$1 {
@@ -3085,7 +3160,7 @@ __decorate([
3085
3160
  Exclude()
3086
3161
  ], Property.prototype, "documentFile", void 0);
3087
3162
 
3088
- class TransactionReceipt$1 {
3163
+ class TransactionReceipt$1 extends AbstractModel {
3089
3164
  }
3090
3165
 
3091
3166
  class TransactionReceipt extends TransactionReceipt$1 {
@@ -3096,7 +3171,7 @@ class TransactionReceipt extends TransactionReceipt$1 {
3096
3171
  }
3097
3172
  }
3098
3173
 
3099
- class IncomeSource$1 {
3174
+ class IncomeSource$1 extends AbstractModel {
3100
3175
  }
3101
3176
 
3102
3177
  var IncomeSourceTypeEnum;
@@ -3107,7 +3182,7 @@ var IncomeSourceTypeEnum;
3107
3182
  IncomeSourceTypeEnum[IncomeSourceTypeEnum["SOLE"] = 4] = "SOLE";
3108
3183
  })(IncomeSourceTypeEnum || (IncomeSourceTypeEnum = {}));
3109
3184
 
3110
- class SalaryForecast$1 {
3185
+ class SalaryForecast$1 extends AbstractModel {
3111
3186
  }
3112
3187
 
3113
3188
  class SalaryForecast extends SalaryForecast$1 {
@@ -3120,7 +3195,7 @@ __decorate([
3120
3195
  Type(() => IncomeSource)
3121
3196
  ], SalaryForecast.prototype, "incomeSource", void 0);
3122
3197
 
3123
- class SoleForecast$1 {
3198
+ class SoleForecast$1 extends AbstractModel {
3124
3199
  }
3125
3200
 
3126
3201
  class SoleForecast extends SoleForecast$1 {
@@ -3133,7 +3208,7 @@ __decorate([
3133
3208
  Type(() => IncomeSource)
3134
3209
  ], SoleForecast.prototype, "incomeSource", void 0);
3135
3210
 
3136
- class IncomeSourceForecast$1 {
3211
+ class IncomeSourceForecast$1 extends AbstractModel {
3137
3212
  }
3138
3213
 
3139
3214
  var SalaryForecastFrequencyEnum;
@@ -3144,7 +3219,7 @@ var SalaryForecastFrequencyEnum;
3144
3219
  SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["WEEKLY"] = 52] = "WEEKLY";
3145
3220
  })(SalaryForecastFrequencyEnum || (SalaryForecastFrequencyEnum = {}));
3146
3221
 
3147
- class IncomeSourceType$1 {
3222
+ class IncomeSourceType$1 extends AbstractModel {
3148
3223
  }
3149
3224
 
3150
3225
  var IncomeSourceTypeListSalaryEnum;
@@ -3272,7 +3347,7 @@ __decorate([
3272
3347
  Type(() => Date)
3273
3348
  ], IncomeSource.prototype, "dateTo", void 0);
3274
3349
 
3275
- class TransactionMetadata$1 {
3350
+ class TransactionMetadata$1 extends AbstractModel {
3276
3351
  }
3277
3352
 
3278
3353
  class TransactionMetadata extends TransactionMetadata$1 {
@@ -3281,7 +3356,7 @@ __decorate([
3281
3356
  Type(() => ChartAccountsMetadata)
3282
3357
  ], TransactionMetadata.prototype, "metadata", void 0);
3283
3358
 
3284
- class Loan$1 {
3359
+ class Loan$1 extends AbstractModel {
3285
3360
  }
3286
3361
 
3287
3362
  var LoanRepaymentTypeEnum;
@@ -3307,7 +3382,7 @@ __decorate([
3307
3382
  Type(() => Date)
3308
3383
  ], LoanPayment.prototype, "date", void 0);
3309
3384
 
3310
- class LoanPayout$1 {
3385
+ class LoanPayout$1 extends AbstractModel {
3311
3386
  }
3312
3387
 
3313
3388
  var LoanPayoutTypeEnum;
@@ -3355,7 +3430,7 @@ __decorate([
3355
3430
  Type(() => LoanPayout)
3356
3431
  ], Loan.prototype, "payout", void 0);
3357
3432
 
3358
- class TransactionAllocation$1 {
3433
+ class TransactionAllocation$1 extends AbstractModel {
3359
3434
  }
3360
3435
 
3361
3436
  class TransactionAllocation extends TransactionAllocation$1 {
@@ -3914,7 +3989,7 @@ class PropertyReportItemTransactionCollection extends PropertyReportItemCollecti
3914
3989
  properties.items.forEach((property) => {
3915
3990
  const transactionsDictionary = new CollectionDictionary(transactions.getByPropertiesIds([property.id]), 'chartAccounts.id');
3916
3991
  transactionsDictionary.keys.map((chartAccountId) => {
3917
- this.items.push(new PropertyReportItemTransaction(transactionsDictionary.get(chartAccountId), property, chartAccounts.getById(+chartAccountId)));
3992
+ this.items.push(new PropertyReportItemTransaction(transactionsDictionary.get(chartAccountId), property, chartAccounts.findBy('id', +chartAccountId)));
3918
3993
  });
3919
3994
  });
3920
3995
  }
@@ -3951,18 +4026,40 @@ class PropertyReportItemDepreciationCollection extends PropertyReportItemCollect
3951
4026
  properties.items.forEach((property) => {
3952
4027
  const depreciationsByType = new CollectionDictionary(depreciations, 'type');
3953
4028
  depreciationsByType.keys.map((type) => {
3954
- this.items.push(new PropertyReportItemDepreciation(depreciationsByType.get(type), property, chartAccounts.getById(depreciationsByType.get(type).first.chartAccounts.id)));
4029
+ this.items.push(new PropertyReportItemDepreciation(depreciationsByType.get(type), property, chartAccounts.findBy('id', depreciationsByType.get(type).first.chartAccounts.id)));
3955
4030
  });
3956
4031
  });
3957
4032
  }
3958
4033
  }
3959
4034
 
3960
- class ServicePriceCollection extends Collection {
3961
- get work() {
3962
- return this.items.filter((price) => price.product.isWork())[0];
4035
+ /**
4036
+ * Vehicle expense for logbook section
4037
+ */
4038
+ class VehicleExpense {
4039
+ constructor(amount, claimPercent, description) {
4040
+ this.amount = amount;
4041
+ this.claimPercent = claimPercent;
4042
+ this.description = description;
4043
+ }
4044
+ getClaimAmount() {
4045
+ return +(this.amount * (this.claimPercent / 100)).toFixed(2);
4046
+ }
4047
+ }
4048
+
4049
+ class VehicleExpenseCollection extends Collection {
4050
+ constructor(transactions, depreciations, vehicleClaim) {
4051
+ super();
4052
+ this.setItems(transactions, depreciations, vehicleClaim);
3963
4053
  }
3964
- get property() {
3965
- return this.items.filter((price) => price.product.isProperty())[0];
4054
+ setItems(transactions, depreciations, vehicleClaim) {
4055
+ this.items = [];
4056
+ const transactionsByChartAccounts = new CollectionDictionary(transactions, 'chartAccounts.name');
4057
+ const transactionExpenses = transactionsByChartAccounts.keys.map((chartAccountsName) => {
4058
+ return new VehicleExpense(transactionsByChartAccounts.get(chartAccountsName).amount, vehicleClaim.workUsage, chartAccountsName);
4059
+ });
4060
+ // group all depreciations into one expense item
4061
+ const depreciationExpense = new VehicleExpense(depreciations.getCurrentYearForecastAmount(), vehicleClaim.workUsage, 'Depreciation');
4062
+ this.items.push(...[depreciationExpense, ...transactionExpenses]);
3966
4063
  }
3967
4064
  }
3968
4065
 
@@ -4801,9 +4898,12 @@ var VehicleLogbookPurposeEnum;
4801
4898
  * Account setup item instance is using for account setup checklist
4802
4899
  */
4803
4900
  class AccountSetupItem {
4901
+ constructor() {
4902
+ this.clientIncomeTypes = [];
4903
+ }
4804
4904
  }
4805
4905
 
4806
- class Bank$1 {
4906
+ class Bank$1 extends AbstractModel {
4807
4907
  }
4808
4908
 
4809
4909
  class Bank extends Bank$1 {
@@ -4818,13 +4918,13 @@ class Bank extends Bank$1 {
4818
4918
  }
4819
4919
  }
4820
4920
 
4821
- class BankAccount$1 {
4921
+ class BankAccount$1 extends AbstractModel {
4822
4922
  }
4823
4923
 
4824
- class BankAccountBalance {
4924
+ class BankAccountBalance extends AbstractModel {
4825
4925
  }
4826
4926
 
4827
- class BankAccountProperty$1 {
4927
+ class BankAccountProperty$1 extends AbstractModel {
4828
4928
  }
4829
4929
 
4830
4930
  class BankAccountProperty extends BankAccountProperty$1 {
@@ -4833,10 +4933,10 @@ __decorate([
4833
4933
  Type(() => Property)
4834
4934
  ], BankAccountProperty.prototype, "property", void 0);
4835
4935
 
4836
- class BankConnection$1 {
4936
+ class BankConnection$1 extends AbstractModel {
4837
4937
  }
4838
4938
 
4839
- class BasiqJob$1 {
4939
+ class BasiqJob$1 extends AbstractModel {
4840
4940
  }
4841
4941
 
4842
4942
  class BasiqJob extends BasiqJob$1 {
@@ -5192,13 +5292,13 @@ class BasiqToken {
5192
5292
  }
5193
5293
  }
5194
5294
 
5195
- class BorrowingExpense$1 {
5295
+ class BorrowingExpense$1 extends AbstractModel {
5196
5296
  }
5197
5297
 
5198
5298
  class BorrowingExpense extends BorrowingExpense$1 {
5199
5299
  }
5200
5300
 
5201
- class BorrowingExpenseLoan$1 {
5301
+ class BorrowingExpenseLoan$1 extends AbstractModel {
5202
5302
  }
5203
5303
 
5204
5304
  class BorrowingExpenseLoan extends BorrowingExpenseLoan$1 {
@@ -5221,7 +5321,7 @@ __decorate([
5221
5321
  Type(() => ChartSerie)
5222
5322
  ], ChartData.prototype, "data", void 0);
5223
5323
 
5224
- class ChartAccountsDepreciation$1 {
5324
+ class ChartAccountsDepreciation$1 extends AbstractModel {
5225
5325
  }
5226
5326
 
5227
5327
  class ChartAccountsDepreciation extends ChartAccountsDepreciation$1 {
@@ -5243,13 +5343,13 @@ var ChartAccountsTaxLabelsEnum;
5243
5343
  ChartAccountsTaxLabelsEnum["TAX_DEDUCTED"] = "Tax Deducted";
5244
5344
  })(ChartAccountsTaxLabelsEnum || (ChartAccountsTaxLabelsEnum = {}));
5245
5345
 
5246
- class ChartAccountsValue$1 {
5346
+ class ChartAccountsValue$1 extends AbstractModel {
5247
5347
  }
5248
5348
 
5249
5349
  class ChartAccountsValue extends ChartAccountsValue$1 {
5250
5350
  }
5251
5351
 
5252
- class Chat$1 {
5352
+ class Chat$1 extends AbstractModel {
5253
5353
  }
5254
5354
 
5255
5355
  class Chat extends Chat$1 {
@@ -5276,10 +5376,10 @@ var ChatViewTypeEnum;
5276
5376
  ChatViewTypeEnum[ChatViewTypeEnum["ATTACHMENTS"] = 1] = "ATTACHMENTS";
5277
5377
  })(ChatViewTypeEnum || (ChatViewTypeEnum = {}));
5278
5378
 
5279
- class Message$1 {
5379
+ class Message$1 extends AbstractModel {
5280
5380
  }
5281
5381
 
5282
- class MessageDocument$1 {
5382
+ class MessageDocument$1 extends AbstractModel {
5283
5383
  }
5284
5384
 
5285
5385
  class MessageDocument extends MessageDocument$1 {
@@ -5330,7 +5430,7 @@ __decorate([
5330
5430
  Expose()
5331
5431
  ], Message.prototype, "documents", void 0);
5332
5432
 
5333
- class ClientIncomeTypes$1 {
5433
+ class ClientIncomeTypes$1 extends AbstractModel {
5334
5434
  }
5335
5435
 
5336
5436
  class ClientIncomeTypes extends ClientIncomeTypes$1 {
@@ -5342,10 +5442,10 @@ class ClientIncomeTypes extends ClientIncomeTypes$1 {
5342
5442
  }
5343
5443
  }
5344
5444
 
5345
- class ClientInvite$1 {
5445
+ class ClientInvite$1 extends AbstractModel {
5346
5446
  }
5347
5447
 
5348
- class RegistrationInvite$1 {
5448
+ class RegistrationInvite$1 extends AbstractModel {
5349
5449
  }
5350
5450
 
5351
5451
  class RegistrationInvite extends RegistrationInvite$1 {
@@ -5416,7 +5516,7 @@ __decorate([
5416
5516
  Type(() => RegistrationInvite)
5417
5517
  ], ClientInvite.prototype, "registrationInvite", void 0);
5418
5518
 
5419
- class ClientMovement$1 {
5519
+ class ClientMovement$1 extends AbstractModel {
5420
5520
  }
5421
5521
 
5422
5522
  class ClientMovement extends ClientMovement$1 {
@@ -5596,7 +5696,7 @@ const DEPRECIATION_GROUPS = {
5596
5696
  }
5597
5697
  };
5598
5698
 
5599
- class DepreciationReceipt$1 {
5699
+ class DepreciationReceipt$1 extends AbstractModel {
5600
5700
  }
5601
5701
 
5602
5702
  class DepreciationReceipt extends DepreciationReceipt$1 {
@@ -5607,7 +5707,7 @@ class DepreciationReceipt extends DepreciationReceipt$1 {
5607
5707
  }
5608
5708
  }
5609
5709
 
5610
- class Document$1 {
5710
+ class Document$1 extends AbstractModel {
5611
5711
  }
5612
5712
 
5613
5713
  /**
@@ -5662,7 +5762,7 @@ const DOCUMENT_FILE_TYPES = {
5662
5762
  ]
5663
5763
  };
5664
5764
 
5665
- class DocumentFolder$1 {
5765
+ class DocumentFolder$1 extends AbstractModel {
5666
5766
  }
5667
5767
 
5668
5768
  class DocumentFolder extends DocumentFolder$1 {
@@ -5671,7 +5771,7 @@ __decorate([
5671
5771
  Type(() => Document)
5672
5772
  ], DocumentFolder.prototype, "documents", void 0);
5673
5773
 
5674
- class EmployeeInvite$1 {
5774
+ class EmployeeInvite$1 extends AbstractModel {
5675
5775
  }
5676
5776
 
5677
5777
  class EmployeeInvite extends EmployeeInvite$1 {
@@ -5838,10 +5938,10 @@ const WORK_TANK_LOGBOOK_PURPOSE_OPTIONS = [
5838
5938
  { label: 'Personal', value: VehicleLogbookPurposeEnum.PERSONAL }
5839
5939
  ];
5840
5940
 
5841
- class Vehicle$1 {
5941
+ class Vehicle$1 extends AbstractModel {
5842
5942
  }
5843
5943
 
5844
- class VehicleLogbook$1 {
5944
+ class VehicleLogbook$1 extends AbstractModel {
5845
5945
  }
5846
5946
 
5847
5947
  class VehicleLogbook extends VehicleLogbook$1 {
@@ -5874,7 +5974,7 @@ __decorate([
5874
5974
  Type(() => VehicleLogbook)
5875
5975
  ], Vehicle.prototype, "logbook", void 0);
5876
5976
 
5877
- class VehicleClaim$1 {
5977
+ class VehicleClaim$1 extends AbstractModel {
5878
5978
  }
5879
5979
 
5880
5980
  const WEEKS_IN_YEAR = 52;
@@ -5959,7 +6059,7 @@ class VehicleClaim extends VehicleClaim$1 {
5959
6059
  }
5960
6060
  }
5961
6061
 
5962
- class ServiceNotification {
6062
+ class ServiceNotification extends AbstractModel {
5963
6063
  }
5964
6064
 
5965
6065
  class Notification extends ServiceNotification {
@@ -6280,7 +6380,7 @@ class PropertyEquityChartData {
6280
6380
  }
6281
6381
  }
6282
6382
 
6283
- class PropertyShare$1 {
6383
+ class PropertyShare$1 extends AbstractModel {
6284
6384
  }
6285
6385
 
6286
6386
  class PropertyShare extends PropertyShare$1 {
@@ -6324,10 +6424,10 @@ __decorate([
6324
6424
  Transform(({ obj }) => obj.user ? obj.user.email : obj.invite.email)
6325
6425
  ], PropertyShare.prototype, "email", void 0);
6326
6426
 
6327
- class PropertySale$1 {
6427
+ class PropertySale$1 extends AbstractModel {
6328
6428
  }
6329
6429
 
6330
- class PropertySaleTaxExemptionMetadata$1 {
6430
+ class PropertySaleTaxExemptionMetadata$1 extends AbstractModel {
6331
6431
  }
6332
6432
 
6333
6433
  class PropertySale extends PropertySale$1 {
@@ -6345,13 +6445,13 @@ __decorate([
6345
6445
  Type(() => PropertySaleTaxExemptionMetadata$1)
6346
6446
  ], PropertySale.prototype, "taxExemptionMetadata", void 0);
6347
6447
 
6348
- class TaxExemption$1 {
6448
+ class TaxExemption$1 extends AbstractModel {
6349
6449
  }
6350
6450
 
6351
6451
  class TaxExemption extends TaxExemption$1 {
6352
6452
  }
6353
6453
 
6354
- class TaxExemptionMetadata$1 {
6454
+ class TaxExemptionMetadata$1 extends AbstractModel {
6355
6455
  }
6356
6456
 
6357
6457
  class TaxExemptionMetadata extends TaxExemptionMetadata$1 {
@@ -6372,7 +6472,7 @@ const MODULE_URL_LIST = {
6372
6472
  myAccount: '/client/my-account/subscription'
6373
6473
  };
6374
6474
 
6375
- class ServicePayment$1 {
6475
+ class ServicePayment$1 extends AbstractModel {
6376
6476
  }
6377
6477
 
6378
6478
  class ServicePayment extends ServicePayment$1 {
@@ -6381,7 +6481,7 @@ __decorate([
6381
6481
  Type(() => ServiceSubscription)
6382
6482
  ], ServicePayment.prototype, "subscription", void 0);
6383
6483
 
6384
- class TaxReview$1 {
6484
+ class TaxReview$1 extends AbstractModel {
6385
6485
  }
6386
6486
 
6387
6487
  class TaxReview extends TaxReview$1 {
@@ -6629,7 +6729,7 @@ var MyAccountHistoryTypeEnum;
6629
6729
  MyAccountHistoryTypeEnum[MyAccountHistoryTypeEnum["UPLOAD_DOCUMENT"] = 2] = "UPLOAD_DOCUMENT";
6630
6730
  })(MyAccountHistoryTypeEnum || (MyAccountHistoryTypeEnum = {}));
6631
6731
 
6632
- class Occupation$1 {
6732
+ class Occupation$1 extends AbstractModel {
6633
6733
  }
6634
6734
 
6635
6735
  class Occupation extends Occupation$1 {
@@ -6644,6 +6744,7 @@ const USER_ROLES = {
6644
6744
  ROLE_USER_SUBSCRIPTION: [UserRolesEnum.SUBSCRIPTION],
6645
6745
  ROLE_USER_WORK: [UserRolesEnum.WORK_TANK],
6646
6746
  ROLE_USER_PROPERTY: [UserRolesEnum.PROPERTY_TANK],
6747
+ ROLE_USER_SOLE: [UserRolesEnum.SOLE_TANK],
6647
6748
  ROLE_PREVIOUS_ADMIN: [UserRolesEnum.SWITCH_USER]
6648
6749
  };
6649
6750
 
@@ -6653,16 +6754,16 @@ const USER_ROLES = {
6653
6754
  class UserToRegister {
6654
6755
  }
6655
6756
 
6656
- class UserEventTypeCategory$1 {
6757
+ class UserEventTypeCategory$1 extends AbstractModel {
6657
6758
  }
6658
6759
 
6659
6760
  class UserEventTypeCategory extends UserEventTypeCategory$1 {
6660
6761
  }
6661
6762
 
6662
- class UserEventSetting$1 {
6763
+ class UserEventSetting$1 extends AbstractModel {
6663
6764
  }
6664
6765
 
6665
- class UserEventType$1 {
6766
+ class UserEventType$1 extends AbstractModel {
6666
6767
  }
6667
6768
 
6668
6769
  class UserEventType extends UserEventType$1 {
@@ -6724,17 +6825,20 @@ const ACCOUNT_SETUP_ITEMS = {
6724
6825
  [AccountSetupItemsEnum.SALARY]: plainToClass(AccountSetupItem, {
6725
6826
  title: 'Add your work income forecast',
6726
6827
  description: 'One the most important steps is to add your salary or wage incomes so we can automatically calculate tax withheld and your forecasted tax position.',
6727
- url: '/client/work-tank/forecasting'
6828
+ url: '/client/work-tank/forecasting',
6829
+ clientIncomeTypes: ['salary']
6728
6830
  }),
6729
6831
  [AccountSetupItemsEnum.OTHER_INCOME]: plainToClass(AccountSetupItem, {
6730
6832
  title: 'Add any other expected incomes',
6731
6833
  description: 'To ensure an accurate tax position forecast, add estimates for any other income types, like dividends, interest, trusts, annuities, director payments etc.',
6732
- url: '/client/work-tank/forecasting'
6834
+ url: '/client/work-tank/forecasting',
6835
+ clientIncomeTypes: ['dividends', 'other']
6733
6836
  }),
6734
6837
  [AccountSetupItemsEnum.PROPERTY]: plainToClass(AccountSetupItem, {
6735
6838
  title: 'Add your properties',
6736
6839
  description: 'Add your properties to seamlessly manage your rental incomes and expenses, whilst tracking your cash position, tax positions and equity forecasts in real time.',
6737
- url: '/client/property-tank'
6840
+ url: '/client/property-tank',
6841
+ clientIncomeTypes: ['property']
6738
6842
  }),
6739
6843
  [AccountSetupItemsEnum.BANK_FEEDS]: plainToClass(AccountSetupItem, {
6740
6844
  title: 'Link banks and select accounts',
@@ -6749,7 +6853,8 @@ const ACCOUNT_SETUP_ITEMS = {
6749
6853
  [AccountSetupItemsEnum.SOLE_INCOME]: plainToClass(AccountSetupItem, {
6750
6854
  title: 'Add your business details',
6751
6855
  description: 'Add your business details, logo and payment terms to create invoice templates in minutes.',
6752
- url: '/client/sole-tank/forecasting'
6856
+ url: '/client/sole-tank/forecasting',
6857
+ clientIncomeTypes: ['sole']
6753
6858
  }),
6754
6859
  [AccountSetupItemsEnum.TRANSACTION]: plainToClass(AccountSetupItem, {
6755
6860
  title: 'Allocation transactions',
@@ -6909,7 +7014,7 @@ class RestService {
6909
7014
  * get instance by id from cache
6910
7015
  * @param id ID of required item
6911
7016
  */
6912
- getById(id) {
7017
+ findById(id) {
6913
7018
  return this.get()
6914
7019
  .pipe(map((items) => {
6915
7020
  return items.find((item) => item['id'] === id);
@@ -7489,111 +7594,457 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
7489
7594
  }]
7490
7595
  }] });
7491
7596
 
7597
+ function enumToList(data) {
7598
+ const list = [];
7599
+ for (const key in data) {
7600
+ if (Number(key) >= 0) {
7601
+ list.push({
7602
+ label: data[key],
7603
+ value: Number(key)
7604
+ });
7605
+ }
7606
+ }
7607
+ return list;
7608
+ }
7609
+
7610
+ var MessagesEnum;
7611
+ (function (MessagesEnum) {
7612
+ MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
7613
+ MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
7614
+ MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
7615
+ })(MessagesEnum || (MessagesEnum = {}));
7616
+
7492
7617
  /**
7493
- * Service handling user's account setup process.
7494
- * Checks required steps and their completion
7618
+ * Service for transactions business logic
7495
7619
  */
7496
- class AccountSetupService {
7497
- constructor(clientIncomeTypesService, propertyService, incomeSourceService, bankAccountsService, transactionAllocationService, vehicleClaimService) {
7498
- this.clientIncomeTypesService = clientIncomeTypesService;
7499
- this.propertyService = propertyService;
7500
- this.incomeSourceService = incomeSourceService;
7501
- this.bankAccountsService = bankAccountsService;
7502
- this.transactionAllocationService = transactionAllocationService;
7503
- this.vehicleClaimService = vehicleClaimService;
7504
- this.cacheSubject = new ReplaySubject(1);
7620
+ class TransactionService extends RestService {
7621
+ constructor() {
7622
+ super(...arguments);
7623
+ // url part for Transaction API
7624
+ this.url = 'transactions';
7625
+ this.modelClass = Transaction;
7626
+ this.transactionDeleted = new EventEmitter();
7505
7627
  }
7506
7628
  /**
7507
- * Get list of account setup items for current user
7629
+ * Listen events from Event Dispatcher services
7630
+ */
7631
+ listenEvents() {
7632
+ this.listenDepreciationChange();
7633
+ this.listenPropertyShareUpdate();
7634
+ }
7635
+ /**
7636
+ * get list of all user's TaxTank transactions
7508
7637
  */
7509
7638
  get() {
7510
7639
  if (!this.cache) {
7511
- this.clientIncomeTypesService.get().subscribe((incomeTypes) => {
7512
- combineLatest(this.createBatch(incomeTypes)).subscribe((items) => {
7513
- this.cache = new AccountSetupItemCollection(items);
7514
- this.cacheSubject.next(this.cache);
7515
- });
7640
+ // set cache as default empty array to avoid multiple backend requests
7641
+ this.cache = [];
7642
+ this.fetch()
7643
+ .subscribe((transactions) => {
7644
+ this.cache = transactions;
7645
+ this.updateCache();
7516
7646
  });
7517
7647
  }
7518
- return this.cacheSubject.asObservable();
7648
+ return this.cacheSubject.asObservable().pipe(
7649
+ // assign child transactions (fees) to parent transactions
7650
+ map((transactions) => {
7651
+ transactions.forEach((transaction) => {
7652
+ transaction.transactions = transactions
7653
+ // get list of child transactions
7654
+ .filter((t) => t.parentTransaction && t.parentTransaction.id === transaction.id);
7655
+ });
7656
+ sort(transactions, 'date', false);
7657
+ return transactions;
7658
+ }));
7519
7659
  }
7520
7660
  /**
7521
- * Get a single AccountSetupItem and check it's completion
7661
+ * Add single new transaction
7662
+ * @param model New Transaction instance for saving
7522
7663
  */
7523
- create(itemType, request) {
7524
- return request.pipe(map((result) => {
7525
- const item = ACCOUNT_SETUP_ITEMS[itemType];
7526
- if (result.length) {
7527
- item.isCompleted = true;
7528
- }
7529
- return item;
7664
+ add(model) {
7665
+ // we don't have POST API endpoint for single transaction
7666
+ return this.addBatch([model])
7667
+ .pipe(map((newTransactions) => {
7668
+ // @TODO alex
7669
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTION_CREATED, newTransactions[0]));
7670
+ return newTransactions[0];
7530
7671
  }));
7531
7672
  }
7532
7673
  /**
7533
- * Get batch of requests to get list of required AccountSetupItem's.
7534
- * Some items are optional and depends of user's client income types
7674
+ * get transactions related with property
7535
7675
  */
7536
- createBatch(incomeTypes) {
7537
- const batch = [];
7538
- // Salary item is completed when user added salary income source
7539
- if (incomeTypes.salary) {
7540
- batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSourcesByType(IncomeSourceTypeEnum.SALARY)));
7541
- }
7542
- // Other income item is completed when user added at least one other income source
7543
- if (incomeTypes.dividends || incomeTypes.other) {
7544
- batch.push(this.create(AccountSetupItemsEnum.OTHER_INCOME, this.getIncomeSourcesByType(IncomeSourceTypeEnum.OTHER)));
7545
- }
7546
- // Rental income item is completed when user added at least one property
7547
- if (incomeTypes.property) {
7548
- batch.push(this.create(AccountSetupItemsEnum.PROPERTY, this.propertyService.get()));
7549
- }
7550
- // Bank feeds item is completed when user added at least one bank account (basiq or manual)
7551
- batch.push(this.create(AccountSetupItemsEnum.BANK_FEEDS, this.bankAccountsService.get()));
7552
- // Logbook item is completed when user has at least one vehicle claim with any method (klms or logbook)
7553
- batch.push(this.create(AccountSetupItemsEnum.WORK_LOGBOOK, this.vehicleClaimService.get()));
7554
- // @TODO waiting for sole tank forecast page
7555
- // Sole item is completed when user added at least one sole income source
7556
- // if (incomeTypes.soleTrader) {
7557
- // batch.push(
7558
- // this.prepareItem(
7559
- // AccountSetupItemsEnum.SOLE_INCOME,
7560
- // this.getIncomeSourcesByType(IncomeSourceTypeEnum.SOLE)
7561
- // )
7562
- // );
7563
- // }
7564
- // Allocation item is completed when user added at least one transaction allocation
7565
- batch.push(this.create(AccountSetupItemsEnum.TRANSACTION, this.transactionAllocationService.get()));
7566
- return batch;
7676
+ getByPropertyId(propertyId) {
7677
+ return this.get()
7678
+ .pipe(map((transactions) => {
7679
+ return transactions.filter((transaction) => {
7680
+ var _a;
7681
+ return ((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id) === propertyId;
7682
+ });
7683
+ }));
7567
7684
  }
7568
7685
  /**
7569
- * @TODO work with collection when services refactored
7686
+ * get list of transactions with tank type 'Work'
7570
7687
  */
7571
- getIncomeSourcesByType(type) {
7572
- return this.incomeSourceService.get().pipe(map((incomeSources) => {
7573
- return new IncomeSourceCollection(incomeSources).getBy('type', type).toArray();
7688
+ getWorkTransactions() {
7689
+ return this.get()
7690
+ .pipe(map((transactions) => {
7691
+ return transactions.filter((transaction) => transaction.isWorkTank());
7574
7692
  }));
7575
7693
  }
7576
- }
7577
- AccountSetupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, deps: [{ token: ClientIncomeTypesService }, { token: PropertyService }, { token: IncomeSourceService }, { token: BankAccountService }, { token: TransactionAllocationService }, { token: VehicleClaimService }], target: i0.ɵɵFactoryTarget.Injectable });
7578
- AccountSetupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, providedIn: 'root' });
7579
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, decorators: [{
7580
- type: Injectable,
7581
- args: [{
7582
- providedIn: 'root'
7583
- }]
7584
- }], ctorParameters: function () { return [{ type: ClientIncomeTypesService }, { type: PropertyService }, { type: IncomeSourceService }, { type: BankAccountService }, { type: TransactionAllocationService }, { type: VehicleClaimService }]; } });
7585
-
7586
- class AddressService {
7587
- constructor(http, environment) {
7588
- this.http = http;
7589
- this.environment = environment;
7590
- this.countriesSubject = new ReplaySubject(1);
7591
- }
7592
- getCountries() {
7593
- if (!this._countries) {
7594
- this.http.get(`${this.environment.apiV2}/countries`)
7595
- .pipe(map((response) => {
7596
- return response['hydra:member'].map((item) => plainToClass(Country, item));
7694
+ /**
7695
+ * Get list of property holding costs (transactions related to vacant land property)
7696
+ */
7697
+ getPropertyHoldingCosts(propertyId) {
7698
+ return this.http.get(`${this.environment.apiV2}/${this.url}?propertyId=${propertyId}&propertyCategoryId=${PropertyCategoryListEnum.VACANT_LAND}`)
7699
+ .pipe(map((transactionsBase) => {
7700
+ return transactionsBase.map((transactionBase) => plainToClass(Transaction, transactionBase));
7701
+ }));
7702
+ }
7703
+ /**
7704
+ * get list of taxable transactions with tank type 'Work'
7705
+ */
7706
+ getTaxableWorkTransactions() {
7707
+ return this.getWorkTransactions()
7708
+ .pipe(map((transactions) => {
7709
+ return transactions.filter((transaction) => !!transaction.chartAccounts.taxReturnItem);
7710
+ }));
7711
+ }
7712
+ /**
7713
+ * add multiple transactions
7714
+ * @param transactions List of new Transaction instances for saving
7715
+ */
7716
+ addBatch(transactions) {
7717
+ transactions = _.cloneDeep(transactions);
7718
+ return this.http.post(`${this.environment.apiV2}/${this.url}`, transactions)
7719
+ .pipe(map((response) => {
7720
+ const addedTransactions = response.map((item) => plainToClass(Transaction, item));
7721
+ transactions.forEach((transaction, index) => {
7722
+ // @TODO backend: need to upload file in the same backend endpoint with transaction add/update
7723
+ // check if passed receipt and upload file
7724
+ if (transaction.file) {
7725
+ transaction.id = response[index].id;
7726
+ addedTransactions[index].file = transaction.file;
7727
+ this.uploadReceipt(addedTransactions[index]);
7728
+ }
7729
+ // @TODO Viktor: implement API for saving of nested transactions
7730
+ // add child transactions if exist
7731
+ if (transaction.transactions.length) {
7732
+ transaction.transactions.forEach((childTransaction) => {
7733
+ childTransaction.parentTransaction = plainToClass(Transaction, { id: addedTransactions[index].id });
7734
+ });
7735
+ this.addBatch(transaction.transactions).subscribe();
7736
+ }
7737
+ // add transfer transaction to cache
7738
+ if (transaction.operation === TransactionOperationEnum.TRANSFER) {
7739
+ addedTransactions.push(addedTransactions[0].transfer);
7740
+ }
7741
+ });
7742
+ if (this.cache) {
7743
+ this.cache.push(...addedTransactions);
7744
+ this.updateCache();
7745
+ }
7746
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
7747
+ this.toastService.success(MessagesEnum.CREATED_MESSAGE);
7748
+ return addedTransactions;
7749
+ }));
7750
+ }
7751
+ /**
7752
+ * update existing transaction
7753
+ * @param transaction Transaction instance for updating
7754
+ */
7755
+ update(transaction) {
7756
+ return this.http.put(`${this.environment.apiV2}/${this.url}/${transaction.id}`, transaction)
7757
+ .pipe(map((response) => {
7758
+ const updatedTransaction = plainToClass(Transaction, response);
7759
+ // @TODO need to upload file in the same backend endpoint with transaction add/update
7760
+ // check if passed new receipt and upload file
7761
+ if (transaction.file) {
7762
+ updatedTransaction.file = transaction.file;
7763
+ this.uploadReceipt(updatedTransaction);
7764
+ }
7765
+ // @TODO Viktor: implement API for saving of nested transactions
7766
+ if (transaction.transactions.length) {
7767
+ // add parent transaction to child transactions
7768
+ transaction.transactions.forEach((childTransaction) => {
7769
+ childTransaction.parentTransaction = plainToClass(Transaction, { id: updatedTransaction.id });
7770
+ });
7771
+ // separate child transactions by id existing to define add or update action.
7772
+ const childTransactionsToUpdate = transaction.transactions.filter((t) => t.id);
7773
+ const childTransactionsToAdd = transaction.transactions.filter((t) => !t.id);
7774
+ // update child transactions
7775
+ if (childTransactionsToUpdate.length) {
7776
+ this.updateBatch(childTransactionsToUpdate).subscribe();
7777
+ }
7778
+ // add child transactions
7779
+ if (childTransactionsToAdd.length) {
7780
+ this.addBatch(childTransactionsToAdd).subscribe();
7781
+ }
7782
+ }
7783
+ this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
7784
+ replace(this.cache, updatedTransaction);
7785
+ this.updateCache();
7786
+ return updatedTransaction;
7787
+ }));
7788
+ }
7789
+ /**
7790
+ * update multiple transactions
7791
+ * @param transactions list of transactions for updating
7792
+ */
7793
+ updateBatch(transactions) {
7794
+ return this.http.put(`${this.environment.apiV2}/${this.url}`, transactions)
7795
+ .pipe(map((response) => {
7796
+ const updatedTransactions = response.map((item) => plainToClass(Transaction, item));
7797
+ updatedTransactions.forEach((updatedTransaction) => {
7798
+ replace(this.cache, updatedTransaction);
7799
+ });
7800
+ this.updateCache();
7801
+ return updatedTransactions;
7802
+ }));
7803
+ }
7804
+ /**
7805
+ * delete transaction and related transactions
7806
+ * @param model
7807
+ */
7808
+ delete(model) {
7809
+ return this.http.delete(`${this.environment.apiV2}/${this.url}/${model.id}`)
7810
+ .pipe(map(() => {
7811
+ this.cache = this.cache.filter((transaction) => {
7812
+ var _a;
7813
+ // when delete transfer we delete actually 2 transactions
7814
+ if (model.isTransfer) {
7815
+ const ids = [model.id];
7816
+ // get id of related transfer transaction
7817
+ if (model.transfer) {
7818
+ // just take id if we delete source transaction
7819
+ ids.push(model.transfer.id);
7820
+ }
7821
+ else {
7822
+ // find source transaction id if we delete destination transaction
7823
+ ids.push(this.cache.find((t) => t.transfer.id === model.id).id);
7824
+ }
7825
+ return !ids.includes(transaction.id);
7826
+ }
7827
+ return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
7828
+ });
7829
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTION_DELETED, model));
7830
+ this.toastService.success(MessagesEnum.DELETED_MESSAGE);
7831
+ this.updateCache();
7832
+ this.transactionDeleted.emit(model);
7833
+ }));
7834
+ }
7835
+ /**
7836
+ * upload transaction receipt image
7837
+ * @param transaction Еhe transaction for which the receipt will be imported
7838
+ */
7839
+ uploadReceipt(transaction) {
7840
+ const formData = new FormData();
7841
+ formData.append('file', transaction.file);
7842
+ transaction.receipt = null;
7843
+ this.http.post(`${this.environment.apiV2}/${this.url}/${transaction.id}/receipts`, formData)
7844
+ .subscribe((receiptResponse) => {
7845
+ // we don't need to keep file after save
7846
+ transaction.file = null;
7847
+ transaction.receipt = plainToClass(TransactionReceipt, receiptResponse);
7848
+ replace(this.cache, transaction);
7849
+ this.updateCache();
7850
+ });
7851
+ }
7852
+ /**
7853
+ * calculate gross income amount based on transaction amount and taxes (fees)
7854
+ * @param transaction Transaction instance for calculation
7855
+ */
7856
+ calculateGrossAmount(transaction) {
7857
+ let amount = transaction.amount || 0;
7858
+ // gross income amount includes amount of fees for property tank and tax for work tank
7859
+ if (transaction.isPropertyTank()) {
7860
+ amount += transaction.transactions.reduce((sum, item) => sum + item.amount, 0);
7861
+ }
7862
+ else {
7863
+ // @TODO Alex: fix logic after TT-641 ready
7864
+ amount += (transaction.tax || 0);
7865
+ }
7866
+ return amount;
7867
+ }
7868
+ /**
7869
+ * get label for transaction tax field depended of selected chart account.
7870
+ * tax type depends of chart account heading or category.
7871
+ */
7872
+ getTaxLabel(chartAccounts) {
7873
+ var _a, _b;
7874
+ // get simple array of ids from enum with taxable chart accounts headings
7875
+ const taxableCAHeadingsIds = enumToList(ChartAccountsHeadingTaxableEnum)
7876
+ .map((item) => item.value);
7877
+ // get simple array of ids from enum with tax deductible chart accounts headings
7878
+ const deductibleCAHeadingsIds = enumToList(ChartAccountsHeadingTaxDeductibleEnum)
7879
+ .map((item) => item.value);
7880
+ // check if one of ids arrays includes current chart accounts heading id and set tax label
7881
+ // otherwise label is empty for this class
7882
+ switch (true) {
7883
+ case taxableCAHeadingsIds.includes((_a = chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id):
7884
+ return ChartAccountsTaxLabelsEnum.TAX_PAID;
7885
+ case deductibleCAHeadingsIds.includes((_b = chartAccounts.heading) === null || _b === void 0 ? void 0 : _b.id):
7886
+ return ChartAccountsTaxLabelsEnum.TAX_DEDUCTED;
7887
+ case CHART_ACCOUNTS_CATEGORIES.workIncome.includes(chartAccounts.category):
7888
+ return ChartAccountsTaxLabelsEnum.TAX_WITHHELD;
7889
+ default:
7890
+ return null;
7891
+ }
7892
+ }
7893
+ /**
7894
+ * Listen to EventDispatcherService event related to Depreciation changing
7895
+ */
7896
+ listenDepreciationChange() {
7897
+ this.eventDispatcherService.on(AppEventTypeEnum.DEPRECIATION_DELETED).subscribe(() => {
7898
+ this.fetch()
7899
+ .subscribe((transactions) => {
7900
+ this.cache = transactions;
7901
+ this.updateCache();
7902
+ });
7903
+ });
7904
+ }
7905
+ /**
7906
+ * Listen to EventDispatcherService event related to Property Share changing
7907
+ */
7908
+ listenPropertyShareUpdate() {
7909
+ this.eventDispatcherService.on(AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(() => this.resetCache());
7910
+ }
7911
+ }
7912
+ TransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
7913
+ TransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, providedIn: 'root' });
7914
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, decorators: [{
7915
+ type: Injectable,
7916
+ args: [{
7917
+ providedIn: 'root'
7918
+ }]
7919
+ }] });
7920
+
7921
+ /**
7922
+ * Service handling user's account setup process.
7923
+ * Checks required steps and their completion
7924
+ */
7925
+ class AccountSetupService {
7926
+ constructor(clientIncomeTypesService, propertyService, incomeSourceService, bankAccountsService, transactionAllocationService, vehicleClaimService, transactionService) {
7927
+ this.clientIncomeTypesService = clientIncomeTypesService;
7928
+ this.propertyService = propertyService;
7929
+ this.incomeSourceService = incomeSourceService;
7930
+ this.bankAccountsService = bankAccountsService;
7931
+ this.transactionAllocationService = transactionAllocationService;
7932
+ this.vehicleClaimService = vehicleClaimService;
7933
+ this.transactionService = transactionService;
7934
+ this.cacheSubject = new ReplaySubject(1);
7935
+ }
7936
+ /**
7937
+ * Get list of account setup items for current user
7938
+ */
7939
+ get() {
7940
+ if (!this.cache) {
7941
+ this.clientIncomeTypesService.get().subscribe((incomeTypes) => {
7942
+ this.clientIncomeTypesId = incomeTypes.id;
7943
+ combineLatest(this.createBatch(incomeTypes)).subscribe((items) => {
7944
+ this.cache = new AccountSetupItemCollection(items);
7945
+ this.cacheSubject.next(this.cache);
7946
+ });
7947
+ });
7948
+ }
7949
+ return this.cacheSubject.asObservable();
7950
+ }
7951
+ /**
7952
+ * Prepare client income types to update to hide depended account setup items
7953
+ */
7954
+ prepareIncomeTypes(item) {
7955
+ return plainToClass(ClientIncomeTypes, Object.assign({ id: this.clientIncomeTypesId }, fromPairs(item.clientIncomeTypes.map((type) => [type, false]))));
7956
+ }
7957
+ /**
7958
+ * Get a single AccountSetupItem and check it's completion
7959
+ */
7960
+ create(itemType, request) {
7961
+ return request.pipe(map((result) => {
7962
+ const item = ACCOUNT_SETUP_ITEMS[itemType];
7963
+ if (result.length) {
7964
+ item.isCompleted = true;
7965
+ }
7966
+ return item;
7967
+ }));
7968
+ }
7969
+ /**
7970
+ * Get batch of requests to get list of required AccountSetupItem's.
7971
+ * Some items are optional and depends of user's client income types
7972
+ */
7973
+ createBatch(incomeTypes) {
7974
+ const batch = [];
7975
+ // Salary item is completed when user added salary income source
7976
+ if (incomeTypes.salary) {
7977
+ batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSourcesByType(IncomeSourceTypeEnum.SALARY)));
7978
+ }
7979
+ // Other income item is completed when user added at least one other income source
7980
+ if (incomeTypes.dividends || incomeTypes.other) {
7981
+ batch.push(this.create(AccountSetupItemsEnum.OTHER_INCOME, this.getIncomeSourcesByType(IncomeSourceTypeEnum.OTHER)));
7982
+ }
7983
+ // Rental income item is completed when user added at least one property
7984
+ if (incomeTypes.property) {
7985
+ batch.push(this.create(AccountSetupItemsEnum.PROPERTY, this.propertyService.get()));
7986
+ }
7987
+ // Bank feeds item is completed when user added at least one bank account (basiq or manual)
7988
+ batch.push(this.create(AccountSetupItemsEnum.BANK_FEEDS, this.bankAccountsService.get()));
7989
+ // Logbook item is completed when user has at least one vehicle claim with any method (klms or logbook)
7990
+ batch.push(this.getLogbookItem());
7991
+ // @TODO waiting for sole tank forecast page
7992
+ // Sole item is completed when user added at least one sole income source
7993
+ // if (incomeTypes.soleTrader) {
7994
+ // batch.push(
7995
+ // this.prepareItem(
7996
+ // AccountSetupItemsEnum.SOLE_INCOME,
7997
+ // this.getIncomeSourcesByType(IncomeSourceTypeEnum.SOLE)
7998
+ // )
7999
+ // );
8000
+ // }
8001
+ // Allocation item is completed when user added at least one transaction allocation
8002
+ batch.push(this.create(AccountSetupItemsEnum.TRANSACTION, this.transactionAllocationService.get()));
8003
+ return batch;
8004
+ }
8005
+ /**
8006
+ * @TODO work with collection when services refactored
8007
+ */
8008
+ getIncomeSourcesByType(type) {
8009
+ return this.incomeSourceService.get().pipe(map((incomeSources) => {
8010
+ return new IncomeSourceCollection(incomeSources).getBy('type', type).toArray();
8011
+ }));
8012
+ }
8013
+ /**
8014
+ * Show logbook item when user has at least 1 vehicle transaction
8015
+ */
8016
+ getLogbookItem() {
8017
+ return combineLatest([
8018
+ this.transactionService.get(),
8019
+ this.create(AccountSetupItemsEnum.WORK_LOGBOOK, this.vehicleClaimService.get())
8020
+ ]).pipe(map(([transactions, item]) => {
8021
+ if (new TransactionCollection(transactions).getVehicleTransactions().length) {
8022
+ return item;
8023
+ }
8024
+ return null;
8025
+ }));
8026
+ }
8027
+ }
8028
+ AccountSetupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, deps: [{ token: ClientIncomeTypesService }, { token: PropertyService }, { token: IncomeSourceService }, { token: BankAccountService }, { token: TransactionAllocationService }, { token: VehicleClaimService }, { token: TransactionService }], target: i0.ɵɵFactoryTarget.Injectable });
8029
+ AccountSetupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, providedIn: 'root' });
8030
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AccountSetupService, decorators: [{
8031
+ type: Injectable,
8032
+ args: [{
8033
+ providedIn: 'root'
8034
+ }]
8035
+ }], ctorParameters: function () { return [{ type: ClientIncomeTypesService }, { type: PropertyService }, { type: IncomeSourceService }, { type: BankAccountService }, { type: TransactionAllocationService }, { type: VehicleClaimService }, { type: TransactionService }]; } });
8036
+
8037
+ class AddressService {
8038
+ constructor(http, environment) {
8039
+ this.http = http;
8040
+ this.environment = environment;
8041
+ this.countriesSubject = new ReplaySubject(1);
8042
+ }
8043
+ getCountries() {
8044
+ if (!this._countries) {
8045
+ this.http.get(`${this.environment.apiV2}/countries`)
8046
+ .pipe(map((response) => {
8047
+ return response['hydra:member'].map((item) => plainToClass(Country, item));
7597
8048
  }))
7598
8049
  .subscribe((countries) => {
7599
8050
  this._countries = countries;
@@ -8793,612 +9244,279 @@ class DocumentFolderService extends RestService {
8793
9244
  * @param oldFolderId: id of old folder from which need to remove the document
8794
9245
  */
8795
9246
  updateDocument(editedDocument, selectedFolder, oldFolderId) {
8796
- return this.http.put(`${this.environment.apiV2}/folders/${selectedFolder.id}/documents/${editedDocument.id}`, editedDocument).pipe(map((response) => {
8797
- const oldFolder = this.cache.find((folder) => folder.id === oldFolderId);
8798
- // Remove document from old folder
8799
- oldFolder.documents = oldFolder.documents.filter((deletedDocument) => deletedDocument.id !== response.id);
8800
- // update old folder and replace it in cache
8801
- response.folder = plainToClass(DocumentFolder, { id: selectedFolder.id, name: selectedFolder.name });
8802
- replace(this.cache, plainToClass(DocumentFolder, oldFolder));
8803
- // update new document folder and replace it in cache
8804
- selectedFolder.documents.push(plainToClass(Document, response));
8805
- replace(this.cache, plainToClass(DocumentFolder, selectedFolder));
8806
- this.cacheSubject.next(this.cache);
8807
- }));
8808
- }
8809
- /**
8810
- * Delete document from folder
8811
- * @param document to remove
8812
- * @param folder from which document should be removed
8813
- */
8814
- deleteDocument(document, folder) {
8815
- return this.http.delete(`${this.environment.apiV2}/folders/${folder.id}/documents/${document.id}`).pipe(map(() => {
8816
- folder.documents = folder.documents
8817
- .filter((deletedDocument) => deletedDocument.id !== document.id);
8818
- replace(this.cache, plainToClass(DocumentFolder, folder));
8819
- this.cacheSubject.next(this.cache);
8820
- }));
8821
- }
8822
- }
8823
- DocumentFolderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
8824
- DocumentFolderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, providedIn: 'root' });
8825
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, decorators: [{
8826
- type: Injectable,
8827
- args: [{
8828
- providedIn: 'root'
8829
- }]
8830
- }] });
8831
-
8832
- class EmployeeService extends RestService {
8833
- constructor() {
8834
- super(...arguments);
8835
- this.url = 'employees';
8836
- this.modelClass = User;
8837
- }
8838
- /**
8839
- * Grant/Remove Manager role to employee
8840
- * @param employee
8841
- */
8842
- toggleManagerRole(employee) {
8843
- return this.http.put(`${this.environment.apiV2}/${this.url}/${employee.id}`, {})
8844
- .pipe(map((updatedEmployeeBase) => {
8845
- const tempCache = this.cache;
8846
- const updatedEmployee = plainToClass(User, updatedEmployeeBase);
8847
- replace(tempCache, updatedEmployee);
8848
- this.cache = _.cloneDeep(tempCache);
8849
- this.updateCache();
8850
- return updatedEmployee;
8851
- }));
8852
- }
8853
- }
8854
- EmployeeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
8855
- EmployeeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeService, providedIn: 'root' });
8856
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeService, decorators: [{
8857
- type: Injectable,
8858
- args: [{
8859
- providedIn: 'root'
8860
- }]
8861
- }] });
8862
-
8863
- class EmployeeInviteService extends RestService {
8864
- constructor() {
8865
- super(...arguments);
8866
- this.url = 'employees/invites';
8867
- this.modelClass = EmployeeInvite;
8868
- }
8869
- /**
8870
- * Import employees for firm from CSV file
8871
- * @param file
8872
- */
8873
- import(file) {
8874
- const formData = new FormData();
8875
- formData.append('file', file);
8876
- return this.http.post(`${this.environment.apiV2}/${this.url}/import`, formData)
8877
- .pipe(map((employeeInvite) => {
8878
- return employeeInvite;
8879
- }));
8880
- }
8881
- /**
8882
- * Resend invitation from firm to client
8883
- * @param invite
8884
- */
8885
- resend(invite) {
8886
- return this.http.post(`${this.environment.apiV2}/${this.url}/${invite.id}/resend`, null)
8887
- .pipe(map((resentInviteBase) => {
8888
- const updatedInvite = plainToClass(EmployeeInvite, resentInviteBase);
8889
- // avoid cache changes
8890
- // @TODO make cache readonly
8891
- const tempCache = _.cloneDeep(this.cache);
8892
- replace(tempCache, plainToClass(EmployeeInvite, updatedInvite));
8893
- this.cache = tempCache;
8894
- this.updateCache();
8895
- return updatedInvite;
8896
- }));
8897
- }
8898
- }
8899
- EmployeeInviteService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeInviteService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
8900
- EmployeeInviteService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeInviteService, providedIn: 'root' });
8901
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeInviteService, decorators: [{
8902
- type: Injectable,
8903
- args: [{
8904
- providedIn: 'root'
8905
- }]
8906
- }] });
8907
-
8908
- // @TODO Alex: think about extend base rest service
8909
- class FirmService {
8910
- constructor(http, environment) {
8911
- this.http = http;
8912
- this.environment = environment;
8913
- this.firmSubject = new ReplaySubject(1);
8914
- }
8915
- /**
8916
- * Register new firm
8917
- * @param data: firm and firm owner data to register
8918
- */
8919
- register(data) {
8920
- return this.http.post(`${this.environment.apiV2}/firms/registration`, data)
8921
- .pipe(map((firm) => {
8922
- return plainToClass(Firm, firm);
8923
- }));
8924
- }
8925
- get() {
8926
- if (!this.firm) {
8927
- this.http.get(`${this.environment.apiV2}/firms/current`)
8928
- .pipe(map((firm) => {
8929
- return plainToClass(Firm, firm);
8930
- }))
8931
- .subscribe((firm) => {
8932
- this.firm = firm;
8933
- this.firmSubject.next(this.firm);
8934
- });
8935
- }
8936
- return this.firmSubject.asObservable();
8937
- }
8938
- update(firm) {
8939
- return this.http.put(`${this.environment.apiV2}/firms/current`, firm)
8940
- .pipe(map((updatedItem) => {
8941
- const updatedInstance = plainToClass(Firm, updatedItem);
8942
- this.firmSubject.next(updatedInstance);
8943
- }));
8944
- }
8945
- /**
8946
- * get list of all registered firms
8947
- */
8948
- getAll() {
8949
- return this.http.get(`${this.environment.apiV2}/firms`)
8950
- .pipe(map((response) => {
8951
- return response['hydra:member'].map((firmBase) => plainToClass(Firm, firmBase));
8952
- }));
8953
- }
8954
- getByType(type) {
8955
- return this.getAll().pipe(map((firms) => {
8956
- return firms.filter((firm) => firm.type === type);
8957
- }));
8958
- }
8959
- updatePhoto(firm, photo) {
8960
- return this.http.post(`${this.environment.apiV2}/firms/photo?_method=PUT`, photo)
8961
- .pipe(map((firmPhoto) => {
8962
- this.firm = plainToClass(Firm, Object.assign(firm, { photo: firmPhoto }));
8963
- this.firmSubject.next(this.firm);
8964
- return firm;
8965
- }));
8966
- }
8967
- }
8968
- FirmService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FirmService, deps: [{ token: i1.HttpClient }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
8969
- FirmService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FirmService, providedIn: 'root' });
8970
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FirmService, decorators: [{
8971
- type: Injectable,
8972
- args: [{
8973
- providedIn: 'root'
8974
- }]
8975
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
8976
- type: Inject,
8977
- args: ['environment']
8978
- }] }]; } });
8979
-
8980
- class HeaderTitleService {
8981
- constructor(router, activatedRoute) {
8982
- this.router = router;
8983
- this.activatedRoute = activatedRoute;
8984
- }
8985
- handleTitle() {
8986
- return this.router.events.pipe(filter((event) => event instanceof NavigationEnd), map(() => this.activatedRoute), map((route) => {
8987
- while (route.firstChild) {
8988
- route = route.firstChild;
8989
- }
8990
- return route;
8991
- }), filter((route) => route.outlet === 'primary'), mergeMap((route) => route.data));
8992
- }
8993
- }
8994
- HeaderTitleService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: HeaderTitleService, deps: [{ token: i1$1.Router }, { token: i1$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Injectable });
8995
- HeaderTitleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: HeaderTitleService, providedIn: 'root' });
8996
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: HeaderTitleService, decorators: [{
8997
- type: Injectable,
8998
- args: [{
8999
- providedIn: 'root'
9000
- }]
9001
- }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: i1$1.ActivatedRoute }]; } });
9002
-
9003
- /**
9004
- * Service to work with Other Income Forecasts
9005
- */
9006
- class IncomeSourceForecastService extends RestService {
9007
- constructor() {
9008
- super(...arguments);
9009
- this.modelClass = IncomeSourceForecast;
9010
- this.url = 'income-source-forecasts';
9011
- }
9012
- /**
9013
- * Listen to Income Sources events
9014
- */
9015
- listenEvents() {
9016
- this.listenToAddedIncomeSources();
9017
- this.listenToUpdatedIncomeSources();
9018
- }
9019
- /**
9020
- * Listen to EventDispatcherService event related to added Income Sources
9021
- */
9022
- listenToAddedIncomeSources() {
9023
- this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_CREATED)
9024
- .pipe(map((incomeSources) => incomeSources
9025
- .filter((incomeSource) => !incomeSource.isSalaryIncome())))
9026
- .subscribe((incomeSources) => {
9027
- const incomeSourceForecasts = this.assignIncomeSourceForecasts(incomeSources);
9028
- if (incomeSourceForecasts.length) {
9029
- this.addBatch(incomeSourceForecasts).subscribe((createdIncomeSourceForecasts) => {
9030
- this.eventDispatcherService
9031
- .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, createdIncomeSourceForecasts));
9032
- });
9033
- }
9034
- });
9035
- }
9036
- /**
9037
- * Listen to EventDispatcherService event related to updated Income Sources
9038
- */
9039
- listenToUpdatedIncomeSources() {
9040
- this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_UPDATED)
9041
- .subscribe((incomeSources) => {
9042
- const incomeSourceForecasts = this.assignIncomeSourceForecasts(incomeSources);
9043
- if (incomeSourceForecasts.length) {
9044
- this.updateBatch(incomeSourceForecasts).subscribe((updatedIncomeSourceForecasts) => {
9045
- this.eventDispatcherService
9046
- .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED, updatedIncomeSourceForecasts));
9047
- });
9048
- }
9049
- });
9247
+ return this.http.put(`${this.environment.apiV2}/folders/${selectedFolder.id}/documents/${editedDocument.id}`, editedDocument).pipe(map((response) => {
9248
+ const oldFolder = this.cache.find((folder) => folder.id === oldFolderId);
9249
+ // Remove document from old folder
9250
+ oldFolder.documents = oldFolder.documents.filter((deletedDocument) => deletedDocument.id !== response.id);
9251
+ // update old folder and replace it in cache
9252
+ response.folder = plainToClass(DocumentFolder, { id: selectedFolder.id, name: selectedFolder.name });
9253
+ replace(this.cache, plainToClass(DocumentFolder, oldFolder));
9254
+ // update new document folder and replace it in cache
9255
+ selectedFolder.documents.push(plainToClass(Document, response));
9256
+ replace(this.cache, plainToClass(DocumentFolder, selectedFolder));
9257
+ this.cacheSubject.next(this.cache);
9258
+ }));
9050
9259
  }
9051
9260
  /**
9052
- * Assign other income forecasts based on provided income sources
9053
- * @param incomeSources by which other income forecasts will be assigned
9261
+ * Delete document from folder
9262
+ * @param document to remove
9263
+ * @param folder from which document should be removed
9054
9264
  */
9055
- assignIncomeSourceForecasts(incomeSources) {
9056
- return incomeSources.map((incomeSource) => {
9057
- incomeSource.incomeSourceForecasts = incomeSource.incomeSourceForecasts
9058
- .map((incomeSourceForecast) => {
9059
- incomeSourceForecast.incomeSource = plainToClass(IncomeSource, { id: incomeSource.id });
9060
- return incomeSourceForecast;
9061
- });
9062
- return incomeSource.incomeSourceForecasts;
9063
- }).flat();
9265
+ deleteDocument(document, folder) {
9266
+ return this.http.delete(`${this.environment.apiV2}/folders/${folder.id}/documents/${document.id}`).pipe(map(() => {
9267
+ folder.documents = folder.documents
9268
+ .filter((deletedDocument) => deletedDocument.id !== document.id);
9269
+ replace(this.cache, plainToClass(DocumentFolder, folder));
9270
+ this.cacheSubject.next(this.cache);
9271
+ }));
9064
9272
  }
9065
9273
  }
9066
- IncomeSourceForecastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IncomeSourceForecastService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9067
- IncomeSourceForecastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IncomeSourceForecastService, providedIn: 'root' });
9068
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IncomeSourceForecastService, decorators: [{
9274
+ DocumentFolderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9275
+ DocumentFolderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, providedIn: 'root' });
9276
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentFolderService, decorators: [{
9069
9277
  type: Injectable,
9070
9278
  args: [{
9071
9279
  providedIn: 'root'
9072
9280
  }]
9073
9281
  }] });
9074
9282
 
9075
- /**
9076
- * Service to work with Salary Forecasts
9077
- */
9078
- class SalaryForecastService extends RestService {
9283
+ class EmployeeService extends RestService {
9079
9284
  constructor() {
9080
9285
  super(...arguments);
9081
- this.modelClass = SalaryForecast;
9082
- this.url = 'salary-forecasts';
9083
- }
9084
- /**
9085
- * Listen to Income Sources events
9086
- */
9087
- listenEvents() {
9088
- this.listenToAddedIncomeSources();
9089
- this.listenToUpdatedIncomeSources();
9090
- }
9091
- /**
9092
- * Listen to EventDispatcherService event related to added Income Sources
9093
- */
9094
- listenToAddedIncomeSources() {
9095
- this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_CREATED)
9096
- .pipe(map((incomeSources) => incomeSources
9097
- .filter((incomeSource) => incomeSource.isSalaryIncome())))
9098
- .subscribe((incomeSources) => {
9099
- const salaryForecasts = this.assignSalaryForecasts(incomeSources);
9100
- if (salaryForecasts.length) {
9101
- this.addBatch(salaryForecasts).subscribe((createdSalaryForecasts) => {
9102
- this.eventDispatcherService
9103
- .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, createdSalaryForecasts));
9104
- });
9105
- }
9106
- });
9107
- }
9108
- /**
9109
- * Listen to EventDispatcherService event related to updated Income Sources
9110
- */
9111
- listenToUpdatedIncomeSources() {
9112
- this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_UPDATED)
9113
- .subscribe((incomeSources) => {
9114
- const salaryForecasts = this.assignSalaryForecasts(incomeSources);
9115
- if (salaryForecasts.length) {
9116
- this.updateBatch(salaryForecasts).subscribe((updatedSalaryForecasts) => {
9117
- this.eventDispatcherService
9118
- .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED, updatedSalaryForecasts));
9119
- });
9120
- }
9121
- });
9286
+ this.url = 'employees';
9287
+ this.modelClass = User;
9122
9288
  }
9123
9289
  /**
9124
- * Assign salary forecasts based on provided income sources
9125
- * @param incomeSources by which salary forecasts will be assigned
9290
+ * Grant/Remove Manager role to employee
9291
+ * @param employee
9126
9292
  */
9127
- assignSalaryForecasts(incomeSources) {
9128
- return incomeSources.map((incomeSource) => {
9129
- incomeSource.salaryForecasts = incomeSource.salaryForecasts
9130
- .map((salaryForecast) => {
9131
- salaryForecast.incomeSource = plainToClass(IncomeSource, { id: incomeSource.id });
9132
- return salaryForecast;
9133
- });
9134
- return incomeSource.salaryForecasts;
9135
- }).flat();
9293
+ toggleManagerRole(employee) {
9294
+ return this.http.put(`${this.environment.apiV2}/${this.url}/${employee.id}`, {})
9295
+ .pipe(map((updatedEmployeeBase) => {
9296
+ const tempCache = this.cache;
9297
+ const updatedEmployee = plainToClass(User, updatedEmployeeBase);
9298
+ replace(tempCache, updatedEmployee);
9299
+ this.cache = _.cloneDeep(tempCache);
9300
+ this.updateCache();
9301
+ return updatedEmployee;
9302
+ }));
9136
9303
  }
9137
9304
  }
9138
- SalaryForecastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SalaryForecastService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9139
- SalaryForecastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SalaryForecastService, providedIn: 'root' });
9140
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SalaryForecastService, decorators: [{
9305
+ EmployeeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9306
+ EmployeeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeService, providedIn: 'root' });
9307
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeService, decorators: [{
9141
9308
  type: Injectable,
9142
9309
  args: [{
9143
9310
  providedIn: 'root'
9144
9311
  }]
9145
9312
  }] });
9146
9313
 
9147
- class SoleForecastService extends RestService {
9314
+ class EmployeeInviteService extends RestService {
9148
9315
  constructor() {
9149
9316
  super(...arguments);
9150
- this.modelClass = SoleForecast;
9151
- this.url = 'sole-forecasts';
9152
- }
9153
- /**
9154
- * Listen to Income Sources events
9155
- */
9156
- listenEvents() {
9157
- this.listenToAddedIncomeSources();
9158
- this.listenToUpdatedIncomeSources();
9159
- }
9160
- /**
9161
- * Listen to EventDispatcherService event related to added Income Sources
9162
- */
9163
- listenToAddedIncomeSources() {
9164
- this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_CREATED)
9165
- .pipe(map((incomeSources) => incomeSources
9166
- .filter((incomeSource) => incomeSource.isSoleIncome())))
9167
- .subscribe((incomeSources) => {
9168
- const soleForecasts = this.assignSoleForecasts(incomeSources);
9169
- if (soleForecasts.length) {
9170
- this.addBatch(soleForecasts).subscribe((createdSoleForecasts) => {
9171
- this.eventDispatcherService
9172
- .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, createdSoleForecasts));
9173
- });
9174
- }
9175
- });
9317
+ this.url = 'employees/invites';
9318
+ this.modelClass = EmployeeInvite;
9176
9319
  }
9177
9320
  /**
9178
- * Listen to EventDispatcherService event related to updated Income Sources
9321
+ * Import employees for firm from CSV file
9322
+ * @param file
9179
9323
  */
9180
- listenToUpdatedIncomeSources() {
9181
- this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_UPDATED)
9182
- .subscribe((incomeSources) => {
9183
- const soleForecasts = this.assignSoleForecasts(incomeSources);
9184
- if (soleForecasts.length) {
9185
- this.updateBatch(soleForecasts).subscribe((updatedSoleForecasts) => {
9186
- this.eventDispatcherService
9187
- .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED, updatedSoleForecasts));
9188
- });
9189
- }
9190
- });
9324
+ import(file) {
9325
+ const formData = new FormData();
9326
+ formData.append('file', file);
9327
+ return this.http.post(`${this.environment.apiV2}/${this.url}/import`, formData)
9328
+ .pipe(map((employeeInvite) => {
9329
+ return employeeInvite;
9330
+ }));
9191
9331
  }
9192
9332
  /**
9193
- * Assign sole forecasts based on provided income sources
9194
- * @param incomeSources by which sole forecasts will be assigned
9333
+ * Resend invitation from firm to client
9334
+ * @param invite
9195
9335
  */
9196
- assignSoleForecasts(incomeSources) {
9197
- return incomeSources.map((incomeSource) => {
9198
- incomeSource.soleForecasts = incomeSource.soleForecasts
9199
- .map((soleForecast) => {
9200
- soleForecast.incomeSource = plainToClass(IncomeSource, { id: incomeSource.id });
9201
- return soleForecast;
9202
- });
9203
- return incomeSource.soleForecasts;
9204
- }).flat();
9336
+ resend(invite) {
9337
+ return this.http.post(`${this.environment.apiV2}/${this.url}/${invite.id}/resend`, null)
9338
+ .pipe(map((resentInviteBase) => {
9339
+ const updatedInvite = plainToClass(EmployeeInvite, resentInviteBase);
9340
+ // avoid cache changes
9341
+ // @TODO make cache readonly
9342
+ const tempCache = _.cloneDeep(this.cache);
9343
+ replace(tempCache, plainToClass(EmployeeInvite, updatedInvite));
9344
+ this.cache = tempCache;
9345
+ this.updateCache();
9346
+ return updatedInvite;
9347
+ }));
9205
9348
  }
9206
9349
  }
9207
- SoleForecastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleForecastService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9208
- SoleForecastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleForecastService, providedIn: 'root' });
9209
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleForecastService, decorators: [{
9350
+ EmployeeInviteService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeInviteService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9351
+ EmployeeInviteService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeInviteService, providedIn: 'root' });
9352
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EmployeeInviteService, decorators: [{
9210
9353
  type: Injectable,
9211
9354
  args: [{
9212
9355
  providedIn: 'root'
9213
9356
  }]
9214
9357
  }] });
9215
9358
 
9216
- /**
9217
- * Service to work with intercom
9218
- */
9219
- class IntercomService {
9220
- constructor(environment) {
9359
+ // @TODO Alex: think about extend base rest service
9360
+ class FirmService {
9361
+ constructor(http, environment) {
9362
+ this.http = http;
9221
9363
  this.environment = environment;
9364
+ this.firmSubject = new ReplaySubject(1);
9222
9365
  }
9223
9366
  /**
9224
- * Init object with user credentials
9225
- * @param user
9367
+ * Register new firm
9368
+ * @param data: firm and firm owner data to register
9226
9369
  */
9227
- initUser(user) {
9228
- return {
9229
- app_id: this.environment.intercomAppId,
9230
- email: user.email,
9231
- user_hash: user.hashedEmail
9232
- };
9370
+ register(data) {
9371
+ return this.http.post(`${this.environment.apiV2}/firms/registration`, data)
9372
+ .pipe(map((firm) => {
9373
+ return plainToClass(Firm, firm);
9374
+ }));
9375
+ }
9376
+ get() {
9377
+ if (!this.firm) {
9378
+ this.http.get(`${this.environment.apiV2}/firms/current`)
9379
+ .pipe(map((firm) => {
9380
+ return plainToClass(Firm, firm);
9381
+ }))
9382
+ .subscribe((firm) => {
9383
+ this.firm = firm;
9384
+ this.firmSubject.next(this.firm);
9385
+ });
9386
+ }
9387
+ return this.firmSubject.asObservable();
9388
+ }
9389
+ update(firm) {
9390
+ return this.http.put(`${this.environment.apiV2}/firms/current`, firm)
9391
+ .pipe(map((updatedItem) => {
9392
+ const updatedInstance = plainToClass(Firm, updatedItem);
9393
+ this.firmSubject.next(updatedInstance);
9394
+ }));
9233
9395
  }
9234
9396
  /**
9235
- * Init connection for provided data
9236
- * @param user
9397
+ * get list of all registered firms
9237
9398
  */
9238
- initConnection(user) {
9239
- const connectionCredentials = this.initUser(user);
9240
- window.Intercom('boot', connectionCredentials);
9399
+ getAll() {
9400
+ return this.http.get(`${this.environment.apiV2}/firms`)
9401
+ .pipe(map((response) => {
9402
+ return response['hydra:member'].map((firmBase) => plainToClass(Firm, firmBase));
9403
+ }));
9404
+ }
9405
+ getByType(type) {
9406
+ return this.getAll().pipe(map((firms) => {
9407
+ return firms.filter((firm) => firm.type === type);
9408
+ }));
9409
+ }
9410
+ updatePhoto(firm, photo) {
9411
+ return this.http.post(`${this.environment.apiV2}/firms/photo?_method=PUT`, photo)
9412
+ .pipe(map((firmPhoto) => {
9413
+ this.firm = plainToClass(Firm, Object.assign(firm, { photo: firmPhoto }));
9414
+ this.firmSubject.next(this.firm);
9415
+ return firm;
9416
+ }));
9241
9417
  }
9242
9418
  }
9243
- IntercomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IntercomService, deps: [{ token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
9244
- IntercomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IntercomService, providedIn: 'root' });
9245
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IntercomService, decorators: [{
9419
+ FirmService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FirmService, deps: [{ token: i1.HttpClient }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
9420
+ FirmService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FirmService, providedIn: 'root' });
9421
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FirmService, decorators: [{
9246
9422
  type: Injectable,
9247
9423
  args: [{
9248
9424
  providedIn: 'root'
9249
9425
  }]
9250
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
9426
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
9251
9427
  type: Inject,
9252
9428
  args: ['environment']
9253
9429
  }] }]; } });
9254
9430
 
9255
- /**
9256
- * Service listen and handle kompassify events
9257
- */
9258
- class KompassifyService {
9259
- constructor(
9260
- // router required for execution of js code from progressbar step
9261
- router) {
9431
+ class HeaderTitleService {
9432
+ constructor(router, activatedRoute) {
9262
9433
  this.router = router;
9434
+ this.activatedRoute = activatedRoute;
9263
9435
  }
9264
- listenEvents() {
9265
- window.addEventListener('message', (event) => {
9266
- // Execute js code from progressbar step
9267
- if (event.data.TYPE === 'KOMPASSIFY_EXECUTE_JS_CODE') {
9268
- eval(event.data.jsCode);
9436
+ handleTitle() {
9437
+ return this.router.events.pipe(filter((event) => event instanceof NavigationEnd), map(() => this.activatedRoute), map((route) => {
9438
+ while (route.firstChild) {
9439
+ route = route.firstChild;
9269
9440
  }
9270
- });
9441
+ return route;
9442
+ }), filter((route) => route.outlet === 'primary'), mergeMap((route) => route.data));
9271
9443
  }
9272
9444
  }
9273
- KompassifyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: KompassifyService, deps: [{ token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
9274
- KompassifyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: KompassifyService, providedIn: 'root' });
9275
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: KompassifyService, decorators: [{
9445
+ HeaderTitleService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: HeaderTitleService, deps: [{ token: i1$1.Router }, { token: i1$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Injectable });
9446
+ HeaderTitleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: HeaderTitleService, providedIn: 'root' });
9447
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: HeaderTitleService, decorators: [{
9276
9448
  type: Injectable,
9277
9449
  args: [{
9278
9450
  providedIn: 'root'
9279
9451
  }]
9280
- }], ctorParameters: function () { return [{ type: i1$1.Router }]; } });
9452
+ }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: i1$1.ActivatedRoute }]; } });
9281
9453
 
9282
9454
  /**
9283
- * Service that handling loans logic
9455
+ * Service to work with Other Income Forecasts
9284
9456
  */
9285
- class LoanService extends RestService {
9457
+ class IncomeSourceForecastService extends RestService {
9286
9458
  constructor() {
9287
9459
  super(...arguments);
9288
- this.url = 'bank-accounts/loans';
9289
- this.modelClass = Loan;
9460
+ this.modelClass = IncomeSourceForecast;
9461
+ this.url = 'income-source-forecasts';
9290
9462
  }
9291
9463
  /**
9292
- * Listen to Loans events
9464
+ * Listen to Income Sources events
9293
9465
  */
9294
9466
  listenEvents() {
9295
- this.listenToAddedLoans();
9296
- this.listenToUpdatedBankAccounts();
9297
- }
9298
- listenToAddedLoans() {
9299
- this.eventDispatcherService.on(AppEventTypeEnum.BANK_ACCOUNT_CREATED)
9300
- .subscribe((bankAccounts) => {
9301
- // fetch loans when loan bank account created
9302
- if (bankAccounts.find(ba => !!ba.loan)) {
9303
- this.resetCache();
9304
- }
9305
- });
9306
- }
9307
- listenToUpdatedBankAccounts() {
9308
- this.eventDispatcherService.on(AppEventTypeEnum.BANK_ACCOUNT_UPDATED)
9309
- .subscribe((updatedBankAccount) => {
9310
- if (!!updatedBankAccount.loan) {
9311
- this.resetCache();
9312
- }
9313
- });
9314
- }
9315
- /**
9316
- * Create Loan
9317
- */
9318
- add(model) {
9319
- return this.addBatch([model])
9320
- .pipe(map((newLoan) => {
9321
- return newLoan[0];
9322
- }));
9467
+ this.listenToAddedIncomeSources();
9468
+ this.listenToUpdatedIncomeSources();
9323
9469
  }
9324
9470
  /**
9325
- * Updated loan
9326
- * @param loan
9471
+ * Listen to EventDispatcherService event related to added Income Sources
9327
9472
  */
9328
- update(loan) {
9329
- return this.http.put(`${this.environment.apiV2}/${this.url}/${loan.id}`, loan)
9330
- .pipe(map((updatedLoanBase) => {
9331
- const updatedLoan = plainToClass(Loan, updatedLoanBase);
9332
- // if loan type is NOT vehicle - fire EventDispatcher event
9333
- if (!updatedLoan.isVehicle()) {
9334
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.LOAN_UPDATED, null));
9473
+ listenToAddedIncomeSources() {
9474
+ this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_CREATED)
9475
+ .pipe(map((incomeSources) => incomeSources
9476
+ .filter((incomeSource) => !incomeSource.isSalaryIncome())))
9477
+ .subscribe((incomeSources) => {
9478
+ const incomeSourceForecasts = this.assignIncomeSourceForecasts(incomeSources);
9479
+ if (incomeSourceForecasts.length) {
9480
+ this.addBatch(incomeSourceForecasts).subscribe((createdIncomeSourceForecasts) => {
9481
+ this.eventDispatcherService
9482
+ .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, createdIncomeSourceForecasts));
9483
+ });
9335
9484
  }
9336
- replace(this.cache, updatedLoan);
9337
- this.updateCache();
9338
- return updatedLoan;
9339
- }));
9340
- }
9341
- /**
9342
- * Get list of vehicle loans
9343
- */
9344
- getVehicleLoans() {
9345
- return this.get()
9346
- .pipe(map((loans) => {
9347
- return loans.filter((loan) => loan.isVehicle());
9348
- }));
9349
- }
9350
- /**
9351
- * Calculate loan payments
9352
- * @param loan
9353
- */
9354
- calculateLoanPayments(loan) {
9355
- return this.http.post(`${this.environment.apiV2}/${this.url}/calculation`, loan).pipe(map((response) => {
9356
- return plainToClass(Loan, response);
9357
- }));
9358
- }
9359
- /**
9360
- * Add new loan payout
9361
- * @param loan
9362
- * @param paidOutLoan
9363
- */
9364
- addPayoutLoan(loan, paidOutLoan) {
9365
- return this.http.post(`${this.environment.apiV2}/loans/${loan.id}/payout`, paidOutLoan).pipe(map((response) => {
9366
- loan.payout = plainToClass(LoanPayout, response);
9367
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.LOAN_PAYOUT_UPDATED, null));
9368
- // reset cache to fetch loans with updated data
9369
- this.resetCache();
9370
- }));
9485
+ });
9371
9486
  }
9372
9487
  /**
9373
- * Delete loan payout
9374
- * @param loan
9375
- * @param payout
9488
+ * Listen to EventDispatcherService event related to updated Income Sources
9376
9489
  */
9377
- deletePayoutLoan(loan, payout) {
9378
- return this.http.delete(`${this.environment.apiV2}/loans/${loan.id}/payout/${payout.id}`).pipe(map(() => {
9379
- loan.payout = null;
9380
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.LOAN_PAYOUT_UPDATED, null));
9381
- // reset cache to fetch loans with updated data
9382
- this.resetCache();
9383
- }));
9490
+ listenToUpdatedIncomeSources() {
9491
+ this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_UPDATED)
9492
+ .subscribe((incomeSources) => {
9493
+ const incomeSourceForecasts = this.assignIncomeSourceForecasts(incomeSources);
9494
+ if (incomeSourceForecasts.length) {
9495
+ this.updateBatch(incomeSourceForecasts).subscribe((updatedIncomeSourceForecasts) => {
9496
+ this.eventDispatcherService
9497
+ .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED, updatedIncomeSourceForecasts));
9498
+ });
9499
+ }
9500
+ });
9384
9501
  }
9385
9502
  /**
9386
- * Update loan payout
9387
- * @param loan
9388
- * @param paidOutLoan
9503
+ * Assign other income forecasts based on provided income sources
9504
+ * @param incomeSources by which other income forecasts will be assigned
9389
9505
  */
9390
- updatePayoutLoan(loan, paidOutLoan) {
9391
- return this.http.put(`${this.environment.apiV2}/loans/${loan.id}/payout/${paidOutLoan.id}`, paidOutLoan).pipe(map((response) => {
9392
- loan.payout = plainToClass(LoanPayout, response);
9393
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.LOAN_PAYOUT_UPDATED, null));
9394
- // reset cache to fetch loans with updated data
9395
- this.resetCache();
9396
- }));
9506
+ assignIncomeSourceForecasts(incomeSources) {
9507
+ return incomeSources.map((incomeSource) => {
9508
+ incomeSource.incomeSourceForecasts = incomeSource.incomeSourceForecasts
9509
+ .map((incomeSourceForecast) => {
9510
+ incomeSourceForecast.incomeSource = plainToClass(IncomeSource, { id: incomeSource.id });
9511
+ return incomeSourceForecast;
9512
+ });
9513
+ return incomeSource.incomeSourceForecasts;
9514
+ }).flat();
9397
9515
  }
9398
9516
  }
9399
- LoanService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LoanService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9400
- LoanService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LoanService, providedIn: 'root' });
9401
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LoanService, decorators: [{
9517
+ IncomeSourceForecastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IncomeSourceForecastService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9518
+ IncomeSourceForecastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IncomeSourceForecastService, providedIn: 'root' });
9519
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IncomeSourceForecastService, decorators: [{
9402
9520
  type: Injectable,
9403
9521
  args: [{
9404
9522
  providedIn: 'root'
@@ -9406,503 +9524,512 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
9406
9524
  }] });
9407
9525
 
9408
9526
  /**
9409
- * Service to handle service notifications logic
9527
+ * Service to work with Salary Forecasts
9410
9528
  */
9411
- class ServiceNotificationService extends RestService {
9412
- constructor(http, eventDispatcherService, environment, toastService, sseService) {
9413
- super(http, eventDispatcherService, environment, toastService);
9414
- this.http = http;
9415
- this.eventDispatcherService = eventDispatcherService;
9416
- this.environment = environment;
9417
- this.toastService = toastService;
9418
- this.sseService = sseService;
9419
- this.modelClass = Notification;
9420
- this.url = 'service-notifications';
9421
- this.isHydra = true;
9422
- this.listenNotifications();
9529
+ class SalaryForecastService extends RestService {
9530
+ constructor() {
9531
+ super(...arguments);
9532
+ this.modelClass = SalaryForecast;
9533
+ this.url = 'salary-forecasts';
9423
9534
  }
9424
9535
  /**
9425
- * subscribe to new chat messages
9536
+ * Listen to Income Sources events
9426
9537
  */
9427
- listenNotifications() {
9428
- this.sseService.on(`serviceNotification`).subscribe((notificationBase) => {
9429
- const notification = plainToClass(Notification, notificationBase);
9430
- const cache = clone(this.cache);
9431
- // update existing notification if read and add new notification if not read
9432
- if (notification.isRead) {
9433
- replace(cache, notification);
9538
+ listenEvents() {
9539
+ this.listenToAddedIncomeSources();
9540
+ this.listenToUpdatedIncomeSources();
9541
+ }
9542
+ /**
9543
+ * Listen to EventDispatcherService event related to added Income Sources
9544
+ */
9545
+ listenToAddedIncomeSources() {
9546
+ this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_CREATED)
9547
+ .pipe(map((incomeSources) => incomeSources
9548
+ .filter((incomeSource) => incomeSource.isSalaryIncome())))
9549
+ .subscribe((incomeSources) => {
9550
+ const salaryForecasts = this.assignSalaryForecasts(incomeSources);
9551
+ if (salaryForecasts.length) {
9552
+ this.addBatch(salaryForecasts).subscribe((createdSalaryForecasts) => {
9553
+ this.eventDispatcherService
9554
+ .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, createdSalaryForecasts));
9555
+ });
9434
9556
  }
9435
- else {
9436
- cache.unshift(notification);
9557
+ });
9558
+ }
9559
+ /**
9560
+ * Listen to EventDispatcherService event related to updated Income Sources
9561
+ */
9562
+ listenToUpdatedIncomeSources() {
9563
+ this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_UPDATED)
9564
+ .subscribe((incomeSources) => {
9565
+ const salaryForecasts = this.assignSalaryForecasts(incomeSources);
9566
+ if (salaryForecasts.length) {
9567
+ this.updateBatch(salaryForecasts).subscribe((updatedSalaryForecasts) => {
9568
+ this.eventDispatcherService
9569
+ .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED, updatedSalaryForecasts));
9570
+ });
9437
9571
  }
9438
- this.cache = cache;
9439
- this.cacheSubject.next(this.cache);
9440
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.NOTIFICATION_ADDED, notification));
9441
9572
  });
9442
9573
  }
9574
+ /**
9575
+ * Assign salary forecasts based on provided income sources
9576
+ * @param incomeSources by which salary forecasts will be assigned
9577
+ */
9578
+ assignSalaryForecasts(incomeSources) {
9579
+ return incomeSources.map((incomeSource) => {
9580
+ incomeSource.salaryForecasts = incomeSource.salaryForecasts
9581
+ .map((salaryForecast) => {
9582
+ salaryForecast.incomeSource = plainToClass(IncomeSource, { id: incomeSource.id });
9583
+ return salaryForecast;
9584
+ });
9585
+ return incomeSource.salaryForecasts;
9586
+ }).flat();
9587
+ }
9443
9588
  }
9444
- ServiceNotificationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ServiceNotificationService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }, { token: SseService }], target: i0.ɵɵFactoryTarget.Injectable });
9445
- ServiceNotificationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ServiceNotificationService, providedIn: 'root' });
9446
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ServiceNotificationService, decorators: [{
9589
+ SalaryForecastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SalaryForecastService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9590
+ SalaryForecastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SalaryForecastService, providedIn: 'root' });
9591
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SalaryForecastService, decorators: [{
9447
9592
  type: Injectable,
9448
9593
  args: [{
9449
9594
  providedIn: 'root'
9450
9595
  }]
9451
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
9452
- type: Inject,
9453
- args: ['environment']
9454
- }] }, { type: ToastService }, { type: SseService }]; } });
9596
+ }] });
9455
9597
 
9456
- /**
9457
- * Configuration file with the settings to generate PDF file
9458
- */
9459
- const PDF_CONFIG = {
9460
- text: {
9461
- fontSize: 12,
9462
- fontName: 'helvetica',
9463
- fontStyle: '',
9464
- fontWeight: 'bold',
9465
- positionX: 14,
9466
- positionY: 10,
9467
- colorWhite: '#ffffff',
9468
- colorBlack: '#000000',
9469
- colorPrimary: '#00b7f0'
9470
- },
9471
- logo: {
9472
- src: '/assets/img/icons/logo.png',
9473
- width: 30,
9474
- height: 7,
9475
- positionX: 42,
9476
- positionY: 6
9477
- },
9478
- // coords for file section title (group, table, e.t.c.)
9479
- contentTitleCoords: {
9480
- marginTop: 15
9481
- },
9482
- contentCoords: {
9483
- marginTop: 15,
9484
- marginLeft: 14
9485
- },
9486
- table: {
9487
- headStyles: {
9488
- fillColor: '#00b7f0',
9489
- lineWidth: .2,
9490
- halign: 'center'
9491
- },
9492
- footStyles: {
9493
- fillColor: '#ffffff',
9494
- textColor: '#000000'
9495
- },
9598
+ class SoleForecastService extends RestService {
9599
+ constructor() {
9600
+ super(...arguments);
9601
+ this.modelClass = SoleForecast;
9602
+ this.url = 'sole-forecasts';
9496
9603
  }
9497
- };
9498
-
9499
- /**
9500
- * Service to work with PDF (generate, download, e.t.c.)
9501
- */
9502
- class PdfService {
9503
9604
  /**
9504
- * Export file from provided HTML tables
9605
+ * Listen to Income Sources events
9505
9606
  */
9506
- exportTables(tables, fileSettings) {
9507
- const document = this.generateFromTables(tables, fileSettings);
9508
- document.save(`${fileSettings.filename}.pdf`);
9607
+ listenEvents() {
9608
+ this.listenToAddedIncomeSources();
9609
+ this.listenToUpdatedIncomeSources();
9509
9610
  }
9510
9611
  /**
9511
- * Export file from provided array-like table data
9612
+ * Listen to EventDispatcherService event related to added Income Sources
9512
9613
  */
9513
- exportFromDataTables(dataTables, fileSettings) {
9514
- const document = this.generateFromDataTables(dataTables, fileSettings.title);
9515
- document.save(`${fileSettings.filename}.pdf`);
9614
+ listenToAddedIncomeSources() {
9615
+ this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_CREATED)
9616
+ .pipe(map((incomeSources) => incomeSources
9617
+ .filter((incomeSource) => incomeSource.isSoleIncome())))
9618
+ .subscribe((incomeSources) => {
9619
+ const soleForecasts = this.assignSoleForecasts(incomeSources);
9620
+ if (soleForecasts.length) {
9621
+ this.addBatch(soleForecasts).subscribe((createdSoleForecasts) => {
9622
+ this.eventDispatcherService
9623
+ .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, createdSoleForecasts));
9624
+ });
9625
+ }
9626
+ });
9516
9627
  }
9517
9628
  /**
9518
- * Generate file from array-like table data
9629
+ * Listen to EventDispatcherService event related to updated Income Sources
9519
9630
  */
9520
- generateFromDataTables(dataTables, title) {
9521
- const pdf = new jsPDF();
9522
- this.setDocumentTitle(pdf, title);
9523
- this.setDocumentLogo(pdf);
9524
- dataTables.forEach((dataTable) => {
9525
- autoTable(pdf, Object.assign({ head: [dataTable.header], body: dataTable.rows, foot: [dataTable.footer] }, this.setTableOptions(pdf, dataTable.caption)));
9526
- });
9527
- return pdf;
9528
- }
9529
- generateFromTables(tables, fileSettings) {
9530
- const pdf = new jsPDF(fileSettings.orientation);
9531
- this.setDocumentTitle(pdf, fileSettings.title);
9532
- this.setDocumentLogo(pdf);
9533
- tables.forEach((table) => {
9534
- // Add table caption if not provided
9535
- if (!table.caption) {
9536
- table.createCaption();
9537
- table.caption.innerText = '';
9631
+ listenToUpdatedIncomeSources() {
9632
+ this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_UPDATED)
9633
+ .subscribe((incomeSources) => {
9634
+ const soleForecasts = this.assignSoleForecasts(incomeSources);
9635
+ if (soleForecasts.length) {
9636
+ this.updateBatch(soleForecasts).subscribe((updatedSoleForecasts) => {
9637
+ this.eventDispatcherService
9638
+ .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED, updatedSoleForecasts));
9639
+ });
9538
9640
  }
9539
- autoTable(pdf, Object.assign({ html: table }, this.setTableOptions(pdf, table.caption.innerText)));
9540
9641
  });
9541
- return pdf;
9542
9642
  }
9543
9643
  /**
9544
- * Set basic options for PDF table
9644
+ * Assign sole forecasts based on provided income sources
9645
+ * @param incomeSources by which sole forecasts will be assigned
9545
9646
  */
9546
- setTableOptions(pdf, tableCaption = '') {
9547
- const lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
9548
- // get caption height based on caption content height
9549
- const captionHeight = pdf.getTextDimensions(pdf.splitTextToSize(tableCaption, pdf.internal.pageSize.width)).h;
9550
- pdf.text(tableCaption, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
9647
+ assignSoleForecasts(incomeSources) {
9648
+ return incomeSources.map((incomeSource) => {
9649
+ incomeSource.soleForecasts = incomeSource.soleForecasts
9650
+ .map((soleForecast) => {
9651
+ soleForecast.incomeSource = plainToClass(IncomeSource, { id: incomeSource.id });
9652
+ return soleForecast;
9653
+ });
9654
+ return incomeSource.soleForecasts;
9655
+ }).flat();
9656
+ }
9657
+ }
9658
+ SoleForecastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleForecastService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9659
+ SoleForecastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleForecastService, providedIn: 'root' });
9660
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleForecastService, decorators: [{
9661
+ type: Injectable,
9662
+ args: [{
9663
+ providedIn: 'root'
9664
+ }]
9665
+ }] });
9666
+
9667
+ /**
9668
+ * Service to work with intercom
9669
+ */
9670
+ class IntercomService {
9671
+ constructor(environment) {
9672
+ this.environment = environment;
9673
+ }
9674
+ /**
9675
+ * Init object with user credentials
9676
+ * @param user
9677
+ */
9678
+ initUser(user) {
9551
9679
  return {
9552
- headStyles: {
9553
- fillColor: PDF_CONFIG.text.colorPrimary,
9554
- },
9555
- footStyles: {
9556
- fillColor: PDF_CONFIG.text.colorWhite,
9557
- textColor: PDF_CONFIG.text.colorBlack
9558
- },
9559
- startY: lastTableCoords + captionHeight + PDF_CONFIG.contentTitleCoords.marginTop,
9560
- didParseCell: (data) => {
9561
- // Align last column content to right
9562
- if (data.table.columns.length > 1 && (data.column.index === data.table.columns.length - 1)) {
9563
- data.cell.styles.halign = 'right';
9564
- }
9565
- }
9680
+ app_id: this.environment.intercomAppId,
9681
+ email: user.email,
9682
+ user_hash: user.hashedEmail
9566
9683
  };
9567
9684
  }
9568
- setDocumentTitle(doc, title) {
9569
- doc.setFontSize(PDF_CONFIG.text.fontSize)
9570
- .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
9571
- .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
9572
- }
9573
- setDocumentLogo(doc) {
9574
- const logo = new Image();
9575
- logo.src = PDF_CONFIG.logo.src;
9576
- doc.addImage(logo, 'PNG', doc.internal.pageSize.width - PDF_CONFIG.logo.positionX, PDF_CONFIG.logo.positionY, PDF_CONFIG.logo.width, PDF_CONFIG.logo.height);
9685
+ /**
9686
+ * Init connection for provided data
9687
+ * @param user
9688
+ */
9689
+ initConnection(user) {
9690
+ const connectionCredentials = this.initUser(user);
9691
+ window.Intercom('boot', connectionCredentials);
9577
9692
  }
9578
9693
  }
9579
- PdfService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PdfService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
9580
- PdfService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PdfService, providedIn: 'root' });
9581
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PdfService, decorators: [{
9694
+ IntercomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IntercomService, deps: [{ token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
9695
+ IntercomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IntercomService, providedIn: 'root' });
9696
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IntercomService, decorators: [{
9582
9697
  type: Injectable,
9583
9698
  args: [{
9584
9699
  providedIn: 'root'
9585
9700
  }]
9586
- }] });
9701
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
9702
+ type: Inject,
9703
+ args: ['environment']
9704
+ }] }]; } });
9587
9705
 
9588
- function enumToList(data) {
9589
- const list = [];
9590
- for (const key in data) {
9591
- if (Number(key) >= 0) {
9592
- list.push({
9593
- label: data[key],
9594
- value: Number(key)
9595
- });
9596
- }
9706
+ /**
9707
+ * Service listen and handle kompassify events
9708
+ */
9709
+ class KompassifyService {
9710
+ constructor(
9711
+ // router required for execution of js code from progressbar step
9712
+ router) {
9713
+ this.router = router;
9714
+ }
9715
+ listenEvents() {
9716
+ window.addEventListener('message', (event) => {
9717
+ // Execute js code from progressbar step
9718
+ if (event.data.TYPE === 'KOMPASSIFY_EXECUTE_JS_CODE') {
9719
+ eval(event.data.jsCode);
9720
+ }
9721
+ });
9597
9722
  }
9598
- return list;
9599
9723
  }
9600
-
9601
- var MessagesEnum;
9602
- (function (MessagesEnum) {
9603
- MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
9604
- MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
9605
- MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
9606
- })(MessagesEnum || (MessagesEnum = {}));
9724
+ KompassifyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: KompassifyService, deps: [{ token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
9725
+ KompassifyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: KompassifyService, providedIn: 'root' });
9726
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: KompassifyService, decorators: [{
9727
+ type: Injectable,
9728
+ args: [{
9729
+ providedIn: 'root'
9730
+ }]
9731
+ }], ctorParameters: function () { return [{ type: i1$1.Router }]; } });
9607
9732
 
9608
9733
  /**
9609
- * Service for transactions business logic
9734
+ * Service that handling loans logic
9610
9735
  */
9611
- class TransactionService extends RestService {
9736
+ class LoanService extends RestService {
9612
9737
  constructor() {
9613
9738
  super(...arguments);
9614
- // url part for Transaction API
9615
- this.url = 'transactions';
9616
- this.modelClass = Transaction;
9617
- this.transactionDeleted = new EventEmitter();
9739
+ this.url = 'bank-accounts/loans';
9740
+ this.modelClass = Loan;
9618
9741
  }
9619
9742
  /**
9620
- * Listen events from Event Dispatcher services
9743
+ * Listen to Loans events
9621
9744
  */
9622
9745
  listenEvents() {
9623
- this.listenDepreciationChange();
9624
- this.listenPropertyShareUpdate();
9746
+ this.listenToAddedLoans();
9747
+ this.listenToUpdatedBankAccounts();
9625
9748
  }
9626
- /**
9627
- * get list of all user's TaxTank transactions
9628
- */
9629
- get() {
9630
- if (!this.cache) {
9631
- // set cache as default empty array to avoid multiple backend requests
9632
- this.cache = [];
9633
- this.fetch()
9634
- .subscribe((transactions) => {
9635
- this.cache = transactions;
9636
- this.updateCache();
9637
- });
9638
- }
9639
- return this.cacheSubject.asObservable().pipe(
9640
- // assign child transactions (fees) to parent transactions
9641
- map((transactions) => {
9642
- transactions.forEach((transaction) => {
9643
- transaction.transactions = transactions
9644
- // get list of child transactions
9645
- .filter((t) => t.parentTransaction && t.parentTransaction.id === transaction.id);
9646
- });
9647
- sort(transactions, 'date', false);
9648
- return transactions;
9649
- }));
9749
+ listenToAddedLoans() {
9750
+ this.eventDispatcherService.on(AppEventTypeEnum.BANK_ACCOUNT_CREATED)
9751
+ .subscribe((bankAccounts) => {
9752
+ // fetch loans when loan bank account created
9753
+ if (bankAccounts.find(ba => !!ba.loan)) {
9754
+ this.resetCache();
9755
+ }
9756
+ });
9757
+ }
9758
+ listenToUpdatedBankAccounts() {
9759
+ this.eventDispatcherService.on(AppEventTypeEnum.BANK_ACCOUNT_UPDATED)
9760
+ .subscribe((updatedBankAccount) => {
9761
+ if (!!updatedBankAccount.loan) {
9762
+ this.resetCache();
9763
+ }
9764
+ });
9650
9765
  }
9651
9766
  /**
9652
- * Add single new transaction
9653
- * @param model New Transaction instance for saving
9767
+ * Create Loan
9654
9768
  */
9655
9769
  add(model) {
9656
- // we don't have POST API endpoint for single transaction
9657
9770
  return this.addBatch([model])
9658
- .pipe(map((newTransactions) => {
9659
- // @TODO alex
9660
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTION_CREATED, newTransactions[0]));
9661
- return newTransactions[0];
9771
+ .pipe(map((newLoan) => {
9772
+ return newLoan[0];
9662
9773
  }));
9663
9774
  }
9664
9775
  /**
9665
- * get transactions related with property
9776
+ * Updated loan
9777
+ * @param loan
9666
9778
  */
9667
- getByPropertyId(propertyId) {
9668
- return this.get()
9669
- .pipe(map((transactions) => {
9670
- return transactions.filter((transaction) => {
9671
- var _a;
9672
- return ((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id) === propertyId;
9673
- });
9779
+ update(loan) {
9780
+ return this.http.put(`${this.environment.apiV2}/${this.url}/${loan.id}`, loan)
9781
+ .pipe(map((updatedLoanBase) => {
9782
+ const updatedLoan = plainToClass(Loan, updatedLoanBase);
9783
+ // if loan type is NOT vehicle - fire EventDispatcher event
9784
+ if (!updatedLoan.isVehicle()) {
9785
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.LOAN_UPDATED, null));
9786
+ }
9787
+ replace(this.cache, updatedLoan);
9788
+ this.updateCache();
9789
+ return updatedLoan;
9674
9790
  }));
9675
9791
  }
9676
9792
  /**
9677
- * get list of transactions with tank type 'Work'
9793
+ * Get list of vehicle loans
9678
9794
  */
9679
- getWorkTransactions() {
9795
+ getVehicleLoans() {
9680
9796
  return this.get()
9681
- .pipe(map((transactions) => {
9682
- return transactions.filter((transaction) => transaction.isWorkTank());
9683
- }));
9684
- }
9685
- /**
9686
- * Get list of property holding costs (transactions related to vacant land property)
9687
- */
9688
- getPropertyHoldingCosts(propertyId) {
9689
- return this.http.get(`${this.environment.apiV2}/${this.url}?propertyId=${propertyId}&propertyCategoryId=${PropertyCategoryListEnum.VACANT_LAND}`)
9690
- .pipe(map((transactionsBase) => {
9691
- return transactionsBase.map((transactionBase) => plainToClass(Transaction, transactionBase));
9692
- }));
9693
- }
9694
- /**
9695
- * get list of taxable transactions with tank type 'Work'
9696
- */
9697
- getTaxableWorkTransactions() {
9698
- return this.getWorkTransactions()
9699
- .pipe(map((transactions) => {
9700
- return transactions.filter((transaction) => !!transaction.chartAccounts.taxReturnItem);
9797
+ .pipe(map((loans) => {
9798
+ return loans.filter((loan) => loan.isVehicle());
9701
9799
  }));
9702
9800
  }
9703
9801
  /**
9704
- * add multiple transactions
9705
- * @param transactions List of new Transaction instances for saving
9802
+ * Calculate loan payments
9803
+ * @param loan
9706
9804
  */
9707
- addBatch(transactions) {
9708
- transactions = _.cloneDeep(transactions);
9709
- return this.http.post(`${this.environment.apiV2}/${this.url}`, transactions)
9710
- .pipe(map((response) => {
9711
- const addedTransactions = response.map((item) => plainToClass(Transaction, item));
9712
- transactions.forEach((transaction, index) => {
9713
- // @TODO backend: need to upload file in the same backend endpoint with transaction add/update
9714
- // check if passed receipt and upload file
9715
- if (transaction.file) {
9716
- transaction.id = response[index].id;
9717
- addedTransactions[index].file = transaction.file;
9718
- this.uploadReceipt(addedTransactions[index]);
9719
- }
9720
- // @TODO Viktor: implement API for saving of nested transactions
9721
- // add child transactions if exist
9722
- if (transaction.transactions.length) {
9723
- transaction.transactions.forEach((childTransaction) => {
9724
- childTransaction.parentTransaction = plainToClass(Transaction, { id: addedTransactions[index].id });
9725
- });
9726
- this.addBatch(transaction.transactions).subscribe();
9727
- }
9728
- // add transfer transaction to cache
9729
- if (transaction.operation === TransactionOperationEnum.TRANSFER) {
9730
- addedTransactions.push(addedTransactions[0].transfer);
9731
- }
9732
- });
9733
- if (this.cache) {
9734
- this.cache.push(...addedTransactions);
9735
- this.updateCache();
9736
- }
9737
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
9738
- this.toastService.success(MessagesEnum.CREATED_MESSAGE);
9739
- return addedTransactions;
9805
+ calculateLoanPayments(loan) {
9806
+ return this.http.post(`${this.environment.apiV2}/${this.url}/calculation`, loan).pipe(map((response) => {
9807
+ return plainToClass(Loan, response);
9740
9808
  }));
9741
9809
  }
9742
9810
  /**
9743
- * update existing transaction
9744
- * @param transaction Transaction instance for updating
9811
+ * Add new loan payout
9812
+ * @param loan
9813
+ * @param paidOutLoan
9745
9814
  */
9746
- update(transaction) {
9747
- return this.http.put(`${this.environment.apiV2}/${this.url}/${transaction.id}`, transaction)
9748
- .pipe(map((response) => {
9749
- const updatedTransaction = plainToClass(Transaction, response);
9750
- // @TODO need to upload file in the same backend endpoint with transaction add/update
9751
- // check if passed new receipt and upload file
9752
- if (transaction.file) {
9753
- updatedTransaction.file = transaction.file;
9754
- this.uploadReceipt(updatedTransaction);
9755
- }
9756
- // @TODO Viktor: implement API for saving of nested transactions
9757
- if (transaction.transactions.length) {
9758
- // add parent transaction to child transactions
9759
- transaction.transactions.forEach((childTransaction) => {
9760
- childTransaction.parentTransaction = plainToClass(Transaction, { id: updatedTransaction.id });
9761
- });
9762
- // separate child transactions by id existing to define add or update action.
9763
- const childTransactionsToUpdate = transaction.transactions.filter((t) => t.id);
9764
- const childTransactionsToAdd = transaction.transactions.filter((t) => !t.id);
9765
- // update child transactions
9766
- if (childTransactionsToUpdate.length) {
9767
- this.updateBatch(childTransactionsToUpdate).subscribe();
9768
- }
9769
- // add child transactions
9770
- if (childTransactionsToAdd.length) {
9771
- this.addBatch(childTransactionsToAdd).subscribe();
9772
- }
9773
- }
9774
- this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
9775
- replace(this.cache, updatedTransaction);
9776
- this.updateCache();
9777
- return updatedTransaction;
9815
+ addPayoutLoan(loan, paidOutLoan) {
9816
+ return this.http.post(`${this.environment.apiV2}/loans/${loan.id}/payout`, paidOutLoan).pipe(map((response) => {
9817
+ loan.payout = plainToClass(LoanPayout, response);
9818
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.LOAN_PAYOUT_UPDATED, null));
9819
+ // reset cache to fetch loans with updated data
9820
+ this.resetCache();
9778
9821
  }));
9779
9822
  }
9780
9823
  /**
9781
- * update multiple transactions
9782
- * @param transactions list of transactions for updating
9824
+ * Delete loan payout
9825
+ * @param loan
9826
+ * @param payout
9783
9827
  */
9784
- updateBatch(transactions) {
9785
- return this.http.put(`${this.environment.apiV2}/${this.url}`, transactions)
9786
- .pipe(map((response) => {
9787
- const updatedTransactions = response.map((item) => plainToClass(Transaction, item));
9788
- updatedTransactions.forEach((updatedTransaction) => {
9789
- replace(this.cache, updatedTransaction);
9790
- });
9791
- this.updateCache();
9792
- return updatedTransactions;
9828
+ deletePayoutLoan(loan, payout) {
9829
+ return this.http.delete(`${this.environment.apiV2}/loans/${loan.id}/payout/${payout.id}`).pipe(map(() => {
9830
+ loan.payout = null;
9831
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.LOAN_PAYOUT_UPDATED, null));
9832
+ // reset cache to fetch loans with updated data
9833
+ this.resetCache();
9793
9834
  }));
9794
9835
  }
9795
9836
  /**
9796
- * delete transaction and related transactions
9797
- * @param model
9837
+ * Update loan payout
9838
+ * @param loan
9839
+ * @param paidOutLoan
9798
9840
  */
9799
- delete(model) {
9800
- return this.http.delete(`${this.environment.apiV2}/${this.url}/${model.id}`)
9801
- .pipe(map(() => {
9802
- this.cache = this.cache.filter((transaction) => {
9803
- var _a;
9804
- // when delete transfer we delete actually 2 transactions
9805
- if (model.isTransfer) {
9806
- const ids = [model.id];
9807
- // get id of related transfer transaction
9808
- if (model.transfer) {
9809
- // just take id if we delete source transaction
9810
- ids.push(model.transfer.id);
9811
- }
9812
- else {
9813
- // find source transaction id if we delete destination transaction
9814
- ids.push(this.cache.find((t) => t.transfer.id === model.id).id);
9815
- }
9816
- return !ids.includes(transaction.id);
9817
- }
9818
- return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
9819
- });
9820
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTION_DELETED, model));
9821
- this.toastService.success(MessagesEnum.DELETED_MESSAGE);
9822
- this.updateCache();
9823
- this.transactionDeleted.emit(model);
9841
+ updatePayoutLoan(loan, paidOutLoan) {
9842
+ return this.http.put(`${this.environment.apiV2}/loans/${loan.id}/payout/${paidOutLoan.id}`, paidOutLoan).pipe(map((response) => {
9843
+ loan.payout = plainToClass(LoanPayout, response);
9844
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.LOAN_PAYOUT_UPDATED, null));
9845
+ // reset cache to fetch loans with updated data
9846
+ this.resetCache();
9824
9847
  }));
9825
9848
  }
9849
+ }
9850
+ LoanService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LoanService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9851
+ LoanService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LoanService, providedIn: 'root' });
9852
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LoanService, decorators: [{
9853
+ type: Injectable,
9854
+ args: [{
9855
+ providedIn: 'root'
9856
+ }]
9857
+ }] });
9858
+
9859
+ /**
9860
+ * Service to handle service notifications logic
9861
+ */
9862
+ class ServiceNotificationService extends RestService {
9863
+ constructor(http, eventDispatcherService, environment, toastService, sseService) {
9864
+ super(http, eventDispatcherService, environment, toastService);
9865
+ this.http = http;
9866
+ this.eventDispatcherService = eventDispatcherService;
9867
+ this.environment = environment;
9868
+ this.toastService = toastService;
9869
+ this.sseService = sseService;
9870
+ this.modelClass = Notification;
9871
+ this.url = 'service-notifications';
9872
+ this.isHydra = true;
9873
+ this.listenNotifications();
9874
+ }
9826
9875
  /**
9827
- * upload transaction receipt image
9828
- * @param transaction Еhe transaction for which the receipt will be imported
9876
+ * subscribe to new chat messages
9829
9877
  */
9830
- uploadReceipt(transaction) {
9831
- const formData = new FormData();
9832
- formData.append('file', transaction.file);
9833
- transaction.receipt = null;
9834
- this.http.post(`${this.environment.apiV2}/${this.url}/${transaction.id}/receipts`, formData)
9835
- .subscribe((receiptResponse) => {
9836
- // we don't need to keep file after save
9837
- transaction.file = null;
9838
- transaction.receipt = plainToClass(TransactionReceipt, receiptResponse);
9839
- replace(this.cache, transaction);
9840
- this.updateCache();
9878
+ listenNotifications() {
9879
+ this.sseService.on(`serviceNotification`).subscribe((notificationBase) => {
9880
+ const notification = plainToClass(Notification, notificationBase);
9881
+ const cache = clone(this.cache);
9882
+ // update existing notification if read and add new notification if not read
9883
+ if (notification.isRead) {
9884
+ replace(cache, notification);
9885
+ }
9886
+ else {
9887
+ cache.unshift(notification);
9888
+ }
9889
+ this.cache = cache;
9890
+ this.cacheSubject.next(this.cache);
9891
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.NOTIFICATION_ADDED, notification));
9841
9892
  });
9842
9893
  }
9894
+ }
9895
+ ServiceNotificationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ServiceNotificationService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }, { token: SseService }], target: i0.ɵɵFactoryTarget.Injectable });
9896
+ ServiceNotificationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ServiceNotificationService, providedIn: 'root' });
9897
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ServiceNotificationService, decorators: [{
9898
+ type: Injectable,
9899
+ args: [{
9900
+ providedIn: 'root'
9901
+ }]
9902
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
9903
+ type: Inject,
9904
+ args: ['environment']
9905
+ }] }, { type: ToastService }, { type: SseService }]; } });
9906
+
9907
+ /**
9908
+ * Configuration file with the settings to generate PDF file
9909
+ */
9910
+ const PDF_CONFIG = {
9911
+ text: {
9912
+ fontSize: 12,
9913
+ fontName: 'helvetica',
9914
+ fontStyle: '',
9915
+ fontWeight: 'bold',
9916
+ positionX: 14,
9917
+ positionY: 10,
9918
+ colorWhite: '#ffffff',
9919
+ colorBlack: '#000000',
9920
+ colorPrimary: '#00b7f0'
9921
+ },
9922
+ logo: {
9923
+ src: '/assets/img/icons/logo.png',
9924
+ width: 30,
9925
+ height: 7,
9926
+ positionX: 42,
9927
+ positionY: 6
9928
+ },
9929
+ // coords for file section title (group, table, e.t.c.)
9930
+ contentTitleCoords: {
9931
+ marginTop: 15
9932
+ },
9933
+ contentCoords: {
9934
+ marginTop: 15,
9935
+ marginLeft: 14
9936
+ },
9937
+ table: {
9938
+ headStyles: {
9939
+ fillColor: '#00b7f0',
9940
+ lineWidth: .2,
9941
+ halign: 'center'
9942
+ },
9943
+ footStyles: {
9944
+ fillColor: '#ffffff',
9945
+ textColor: '#000000'
9946
+ },
9947
+ }
9948
+ };
9949
+
9950
+ /**
9951
+ * Service to work with PDF (generate, download, e.t.c.)
9952
+ */
9953
+ class PdfService {
9843
9954
  /**
9844
- * calculate gross income amount based on transaction amount and taxes (fees)
9845
- * @param transaction Transaction instance for calculation
9955
+ * Export file from provided HTML tables
9846
9956
  */
9847
- calculateGrossAmount(transaction) {
9848
- let amount = transaction.amount || 0;
9849
- // gross income amount includes amount of fees for property tank and tax for work tank
9850
- if (transaction.isPropertyTank()) {
9851
- amount += transaction.transactions.reduce((sum, item) => sum + item.amount, 0);
9852
- }
9853
- else {
9854
- // @TODO Alex: fix logic after TT-641 ready
9855
- amount += (transaction.tax || 0);
9856
- }
9857
- return amount;
9957
+ exportTables(tables, fileSettings) {
9958
+ const document = this.generateFromTables(tables, fileSettings);
9959
+ document.save(`${fileSettings.filename}.pdf`);
9858
9960
  }
9859
9961
  /**
9860
- * get label for transaction tax field depended of selected chart account.
9861
- * tax type depends of chart account heading or category.
9962
+ * Export file from provided array-like table data
9862
9963
  */
9863
- getTaxLabel(chartAccounts) {
9864
- var _a, _b;
9865
- // get simple array of ids from enum with taxable chart accounts headings
9866
- const taxableCAHeadingsIds = enumToList(ChartAccountsHeadingTaxableEnum)
9867
- .map((item) => item.value);
9868
- // get simple array of ids from enum with tax deductible chart accounts headings
9869
- const deductibleCAHeadingsIds = enumToList(ChartAccountsHeadingTaxDeductibleEnum)
9870
- .map((item) => item.value);
9871
- // check if one of ids arrays includes current chart accounts heading id and set tax label
9872
- // otherwise label is empty for this class
9873
- switch (true) {
9874
- case taxableCAHeadingsIds.includes((_a = chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id):
9875
- return ChartAccountsTaxLabelsEnum.TAX_PAID;
9876
- case deductibleCAHeadingsIds.includes((_b = chartAccounts.heading) === null || _b === void 0 ? void 0 : _b.id):
9877
- return ChartAccountsTaxLabelsEnum.TAX_DEDUCTED;
9878
- case CHART_ACCOUNTS_CATEGORIES.workIncome.includes(chartAccounts.category):
9879
- return ChartAccountsTaxLabelsEnum.TAX_WITHHELD;
9880
- default:
9881
- return null;
9882
- }
9964
+ exportFromDataTables(dataTables, fileSettings) {
9965
+ const document = this.generateFromDataTables(dataTables, fileSettings.title);
9966
+ document.save(`${fileSettings.filename}.pdf`);
9883
9967
  }
9884
9968
  /**
9885
- * Listen to EventDispatcherService event related to Depreciation changing
9969
+ * Generate file from array-like table data
9886
9970
  */
9887
- listenDepreciationChange() {
9888
- this.eventDispatcherService.on(AppEventTypeEnum.DEPRECIATION_DELETED).subscribe(() => {
9889
- this.fetch()
9890
- .subscribe((transactions) => {
9891
- this.cache = transactions;
9892
- this.updateCache();
9893
- });
9971
+ generateFromDataTables(dataTables, title) {
9972
+ const pdf = new jsPDF();
9973
+ this.setDocumentTitle(pdf, title);
9974
+ this.setDocumentLogo(pdf);
9975
+ dataTables.forEach((dataTable) => {
9976
+ autoTable(pdf, Object.assign({ head: [dataTable.header], body: dataTable.rows, foot: [dataTable.footer] }, this.setTableOptions(pdf, dataTable.caption)));
9977
+ });
9978
+ return pdf;
9979
+ }
9980
+ generateFromTables(tables, fileSettings) {
9981
+ const pdf = new jsPDF(fileSettings.orientation);
9982
+ this.setDocumentTitle(pdf, fileSettings.title);
9983
+ this.setDocumentLogo(pdf);
9984
+ tables.forEach((table) => {
9985
+ // Add table caption if not provided
9986
+ if (!table.caption) {
9987
+ table.createCaption();
9988
+ table.caption.innerText = '';
9989
+ }
9990
+ autoTable(pdf, Object.assign({ html: table }, this.setTableOptions(pdf, table.caption.innerText)));
9894
9991
  });
9992
+ return pdf;
9895
9993
  }
9896
9994
  /**
9897
- * Listen to EventDispatcherService event related to Property Share changing
9995
+ * Set basic options for PDF table
9898
9996
  */
9899
- listenPropertyShareUpdate() {
9900
- this.eventDispatcherService.on(AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(() => this.resetCache());
9997
+ setTableOptions(pdf, tableCaption = '') {
9998
+ const lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
9999
+ // get caption height based on caption content height
10000
+ const captionHeight = pdf.getTextDimensions(pdf.splitTextToSize(tableCaption, pdf.internal.pageSize.width)).h;
10001
+ pdf.text(tableCaption, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
10002
+ return {
10003
+ headStyles: {
10004
+ fillColor: PDF_CONFIG.text.colorPrimary,
10005
+ },
10006
+ footStyles: {
10007
+ fillColor: PDF_CONFIG.text.colorWhite,
10008
+ textColor: PDF_CONFIG.text.colorBlack
10009
+ },
10010
+ startY: lastTableCoords + captionHeight + PDF_CONFIG.contentTitleCoords.marginTop,
10011
+ didParseCell: (data) => {
10012
+ // Align last column content to right
10013
+ if (data.table.columns.length > 1 && (data.column.index === data.table.columns.length - 1)) {
10014
+ data.cell.styles.halign = 'right';
10015
+ }
10016
+ }
10017
+ };
10018
+ }
10019
+ setDocumentTitle(doc, title) {
10020
+ doc.setFontSize(PDF_CONFIG.text.fontSize)
10021
+ .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
10022
+ .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
10023
+ }
10024
+ setDocumentLogo(doc) {
10025
+ const logo = new Image();
10026
+ logo.src = PDF_CONFIG.logo.src;
10027
+ doc.addImage(logo, 'PNG', doc.internal.pageSize.width - PDF_CONFIG.logo.positionX, PDF_CONFIG.logo.positionY, PDF_CONFIG.logo.width, PDF_CONFIG.logo.height);
9901
10028
  }
9902
10029
  }
9903
- TransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
9904
- TransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, providedIn: 'root' });
9905
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, decorators: [{
10030
+ PdfService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PdfService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
10031
+ PdfService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PdfService, providedIn: 'root' });
10032
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PdfService, decorators: [{
9906
10033
  type: Injectable,
9907
10034
  args: [{
9908
10035
  providedIn: 'root'
@@ -10420,55 +10547,16 @@ class SubscriptionService {
10420
10547
  }
10421
10548
  return this.serviceSubscriptionSubject.asObservable();
10422
10549
  }
10423
- /**
10424
- * @TODO right now we have only monthly prices, the function should be refactored to support other options in future
10425
- *
10426
- * create available subscription plans based on existing products
10427
- */
10428
- getSubscriptionPlans() {
10429
- if (!this._serviceSubscriptions) {
10430
- this.http.get(`${this.environment.apiV2}/service-prices`)
10431
- .pipe(map((response) => {
10432
- return new ServicePriceCollection(response['hydra:member'].map((item) => plainToClass(ServicePrice, item)));
10433
- }))
10434
- .subscribe((prices) => {
10435
- this._serviceSubscriptions = new ServiceSubscriptionCollection([
10436
- plainToClass(ServiceSubscription, { items: [] }),
10437
- plainToClass(ServiceSubscription, {
10438
- items: [plainToClass(ServiceSubscriptionItem, {
10439
- price: prices.property,
10440
- quantity: 2
10441
- })]
10442
- }),
10443
- plainToClass(ServiceSubscription, {
10444
- items: [plainToClass(ServiceSubscriptionItem, {
10445
- price: prices.property,
10446
- quantity: 3
10447
- })]
10448
- })
10449
- ]);
10450
- this._serviceSubscriptions.items.forEach((subscription) => {
10451
- subscription.items.push(plainToClass(ServiceSubscriptionItem, { price: prices.work, quantity: 1 }));
10452
- });
10453
- this.serviceSubscriptionsSubject.next(this._serviceSubscriptions);
10454
- });
10455
- }
10456
- return this.serviceSubscriptionsSubject.asObservable();
10457
- }
10458
10550
  /**
10459
10551
  * redirect to stripe payment page
10460
10552
  */
10461
- checkoutRedirect(subscription, successUrl, cancelUrl) {
10553
+ checkoutRedirect(subscription) {
10462
10554
  return __awaiter(this, void 0, void 0, function* () {
10463
10555
  const stripe = yield loadStripe(this.environment.stripePk);
10464
- // @TODO vik
10465
- const lineItems = subscription.items.map((item) => {
10466
- return { servicePriceId: item.price.id, quantity: item.quantity };
10467
- });
10468
10556
  this.http.post(`${this.environment.apiV2}/stripe/checkout-session`, {
10469
- lineItems,
10470
- successUrl: successUrl,
10471
- cancelUrl: cancelUrl
10557
+ items: subscription.items,
10558
+ successUrl: window.location.href,
10559
+ cancelUrl: window.location.href
10472
10560
  })
10473
10561
  .subscribe((session) => {
10474
10562
  // @Todo remove user TRIAL status
@@ -10531,6 +10619,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
10531
10619
  args: ['environment']
10532
10620
  }] }]; } });
10533
10621
 
10622
+ /**
10623
+ * Service that handling banks logic
10624
+ */
10625
+ class ServicePriceService extends RestService {
10626
+ constructor() {
10627
+ super(...arguments);
10628
+ this.modelClass = ServicePrice;
10629
+ this.url = 'service-prices';
10630
+ this.isHydra = true;
10631
+ }
10632
+ }
10633
+ ServicePriceService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ServicePriceService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
10634
+ ServicePriceService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ServicePriceService, providedIn: 'root' });
10635
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ServicePriceService, decorators: [{
10636
+ type: Injectable,
10637
+ args: [{
10638
+ providedIn: 'root'
10639
+ }]
10640
+ }] });
10641
+
10534
10642
  /**
10535
10643
  * Service to work with tax review
10536
10644
  */
@@ -11454,5 +11562,5 @@ class VehicleClaimForm extends AbstractForm {
11454
11562
  * Generated bundle index. Do not edit.
11455
11563
  */
11456
11564
 
11457
- export { AbstractForm, AccountSetupItem, AccountSetupItemCollection, AccountSetupService, Address, AddressService, AddressTypeEnum, AlphabetColorsEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Bank, BankAccount, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqConfig, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, ChartAccounts, ChartAccountsCategoryEnum, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, ChartAccountsHeadingTaxDeductibleEnum, ChartAccountsHeadingTaxableEnum, ChartAccountsHeadingVehicleListEnum, ChartAccountsListEnum, ChartAccountsMetadata, ChartAccountsMetadataListEnum, ChartAccountsMetadataTypeEnum, ChartAccountsService, ChartAccountsTaxLabelsEnum, ChartAccountsTypeEnum, ChartAccountsValue, ChartData, ChartSerie, Chat, ChatService, ChatStatusEnum, ChatViewTypeEnum, ClientCollection, ClientDetails, ClientDetailsMedicareExemptionEnum, ClientDetailsWorkDepreciationCalculationEnum, ClientDetailsWorkingHolidayMakerEnum, ClientIncomeTypes, ClientIncomeTypesForm, ClientIncomeTypesService, ClientInvite, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, Collection, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEFAULT_VEHICLE_EXPENSE, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCapitalProjectService, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationLvpAssetTypeEnum, DepreciationLvpReportItem, DepreciationLvpReportItemCollection, DepreciationReceipt, DepreciationReportItem, DepreciationReportItemCollection, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EquityPositionChartService, EventDispatcherService, ExportDataTable, ExportFormatEnum, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSalaryEnum, IncomeSourceTypeListWorkEnum, InterceptorsModule, IntercomService, InviteStatusEnum, JwtService, KompassifyService, Loan, LoanBankTypeEnum, LoanCollection, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookPeriod, LoginForm, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, Notification, Occupation, OccupationService, PasswordForm, PdfOrientationEnum, PdfService, PdfSettings, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCategory, PropertyCategoryListEnum, PropertyCategoryMovement, PropertyCategoryMovementService, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertyHoldingCostsService, PropertyReportItem, PropertyReportItemCollection, PropertyReportItemDepreciationCollection, PropertyReportItemTransaction, PropertyReportItemTransactionCollection, PropertySale, PropertySaleService, PropertySaleTaxExemptionMetadata, PropertyService, PropertyShare, PropertyShareAccessEnum, PropertyShareService, PropertyShareStatusEnum, PropertySubscription, PropertyTransactionReportService, PropertyValuation, RegisterClientForm, RegisterFirmForm, RegistrationInvite, RegistrationInviteStatusEnum, ReportItem, ReportItemCollection, ReportItemDetails, ResetPasswordForm, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceCollection, ServicePriceRecurringIntervalEnum, ServicePriceTypeEnum, ServiceProduct, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, ShareFilterOptionsEnum, SoleForecast, SoleForecastService, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, TYPE_LOAN, TankTypeEnum, TaxCalculationMedicareExemptionEnum, TaxCalculationTypeEnum, TaxExemption, TaxExemptionEnum, TaxExemptionMetadata, TaxExemptionMetadataEnum, TaxExemptionService, TaxReturnCategoryListEnum, TaxReturnCategorySectionEnum, TaxReview, TaxReviewCollection, TaxReviewHistoryService, TaxReviewService, TaxReviewStatusEnum, TaxSummary, TaxSummaryListEnum, TaxSummarySection, TaxSummarySectionEnum, TaxSummaryService, TaxSummaryTaxSummaryEnum, TaxSummaryTypeEnum, TicketFeedbackEnum, TicketStatusEnum, TicketTypesEnum, Toast, ToastService, ToastTypeEnum, Transaction, TransactionAllocation, TransactionAllocationCollection, TransactionAllocationService, TransactionBase, TransactionCalculationService, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, Vehicle, VehicleClaim, VehicleClaimForm, VehicleClaimMethodEnum, VehicleClaimService, VehicleCollection, VehicleForm, VehicleLogbook, VehicleLogbookCollection, VehicleLogbookPurposeEnum, VehicleLogbookService, VehicleService, WORK_TANK_LOGBOOK_PURPOSE_OPTIONS, XlsxService, cloneDeep, compare, compareMatOptions, createDate, displayMatOptions, enumToList, getDocIcon, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
11565
+ export { AbstractForm, AccountSetupItem, AccountSetupItemCollection, AccountSetupService, Address, AddressService, AddressTypeEnum, AlphabetColorsEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Bank, BankAccount, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqConfig, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, ChartAccounts, ChartAccountsCategoryEnum, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, ChartAccountsHeadingTaxDeductibleEnum, ChartAccountsHeadingTaxableEnum, ChartAccountsHeadingVehicleListEnum, ChartAccountsListEnum, ChartAccountsMetadata, ChartAccountsMetadataListEnum, ChartAccountsMetadataTypeEnum, ChartAccountsService, ChartAccountsTaxLabelsEnum, ChartAccountsTypeEnum, ChartAccountsValue, ChartData, ChartSerie, Chat, ChatService, ChatStatusEnum, ChatViewTypeEnum, ClientCollection, ClientDetails, ClientDetailsMedicareExemptionEnum, ClientDetailsWorkDepreciationCalculationEnum, ClientDetailsWorkingHolidayMakerEnum, ClientIncomeTypes, ClientIncomeTypesForm, ClientIncomeTypesService, ClientInvite, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, Collection, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEFAULT_VEHICLE_EXPENSE, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCapitalProjectService, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationLvpAssetTypeEnum, DepreciationLvpReportItem, DepreciationLvpReportItemCollection, DepreciationReceipt, DepreciationReportItem, DepreciationReportItemCollection, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EquityPositionChartService, EventDispatcherService, ExportDataTable, ExportFormatEnum, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSalaryEnum, IncomeSourceTypeListWorkEnum, InterceptorsModule, IntercomService, InviteStatusEnum, JwtService, KompassifyService, Loan, LoanBankTypeEnum, LoanCollection, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookPeriod, LoginForm, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, Notification, Occupation, OccupationService, PasswordForm, PdfOrientationEnum, PdfService, PdfSettings, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCategory, PropertyCategoryListEnum, PropertyCategoryMovement, PropertyCategoryMovementService, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertyHoldingCostsService, PropertyReportItem, PropertyReportItemCollection, PropertyReportItemDepreciationCollection, PropertyReportItemTransaction, PropertyReportItemTransactionCollection, PropertySale, PropertySaleService, PropertySaleTaxExemptionMetadata, PropertyService, PropertyShare, PropertyShareAccessEnum, PropertyShareService, PropertyShareStatusEnum, PropertySubscription, PropertyTransactionReportService, PropertyValuation, RegisterClientForm, RegisterFirmForm, RegistrationInvite, RegistrationInviteStatusEnum, ReportItem, ReportItemCollection, ReportItemDetails, ResetPasswordForm, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceRecurringIntervalEnum, ServicePriceService, ServicePriceTypeEnum, ServiceProduct, ServiceProductStatusEnum, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, ShareFilterOptionsEnum, SoleForecast, SoleForecastService, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, TYPE_LOAN, TankTypeEnum, TaxCalculationMedicareExemptionEnum, TaxCalculationTypeEnum, TaxExemption, TaxExemptionEnum, TaxExemptionMetadata, TaxExemptionMetadataEnum, TaxExemptionService, TaxReturnCategoryListEnum, TaxReturnCategorySectionEnum, TaxReview, TaxReviewCollection, TaxReviewHistoryService, TaxReviewService, TaxReviewStatusEnum, TaxSummary, TaxSummaryListEnum, TaxSummarySection, TaxSummarySectionEnum, TaxSummaryService, TaxSummaryTaxSummaryEnum, TaxSummaryTypeEnum, TicketFeedbackEnum, TicketStatusEnum, TicketTypesEnum, Toast, ToastService, ToastTypeEnum, Transaction, TransactionAllocation, TransactionAllocationCollection, TransactionAllocationService, TransactionBase, TransactionCalculationService, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, Vehicle, VehicleClaim, VehicleClaimForm, VehicleClaimMethodEnum, VehicleClaimService, VehicleCollection, VehicleExpense, VehicleExpenseCollection, VehicleForm, VehicleLogbook, VehicleLogbookCollection, VehicleLogbookPurposeEnum, VehicleLogbookService, VehicleService, WORK_TANK_LOGBOOK_PURPOSE_OPTIONS, XlsxService, cloneDeep, compare, compareMatOptions, createDate, displayMatOptions, enumToList, getDocIcon, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
11458
11566
  //# sourceMappingURL=taxtank-core.js.map