taxtank-core 0.0.1 → 0.1.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 (476) hide show
  1. package/.browserslistrc +16 -0
  2. package/karma.conf.js +44 -0
  3. package/ng-package.json +12 -0
  4. package/package.json +13 -12
  5. package/src/lib/collections/abstract.collection.ts +83 -0
  6. package/src/lib/collections/bank-account.collection.ts +171 -0
  7. package/src/lib/collections/bank-transaction.collection.ts +153 -0
  8. package/src/lib/collections/client-movement.collection.ts +42 -0
  9. package/src/lib/collections/client-portfolio-report.collection.ts +47 -0
  10. package/src/lib/collections/client.collection.ts +5 -0
  11. package/src/lib/collections/collection-dictionary.ts +112 -0
  12. package/src/lib/collections/depreciation-forecast.collection.ts +25 -0
  13. package/src/lib/collections/depreciation.collection.ts +113 -0
  14. package/src/lib/collections/employee.collection.ts +14 -0
  15. package/src/lib/collections/income-source.collection.ts +44 -0
  16. package/src/lib/collections/loan.collection.ts +22 -0
  17. package/src/lib/collections/logbook.collection.ts +129 -0
  18. package/src/lib/collections/message-document.collection.ts +16 -0
  19. package/src/lib/collections/message.collection.ts +27 -0
  20. package/src/lib/collections/property.collection.ts +88 -0
  21. package/src/lib/collections/service-price.collection.ts +13 -0
  22. package/src/lib/collections/service-subscription.collection.ts +20 -0
  23. package/src/lib/collections/tax-return-category-item.collection.ts +148 -0
  24. package/src/lib/collections/tax-review.collection.ts +64 -0
  25. package/src/lib/collections/transaction-allocation.collection.ts +54 -0
  26. package/src/lib/collections/transaction.collection.ts +170 -0
  27. package/src/lib/collections/user-event-setting.collection.ts +70 -0
  28. package/src/lib/db/Enums/address-type.enum.ts +4 -0
  29. package/src/lib/db/Enums/bank-account-status.enum.ts +4 -0
  30. package/src/lib/db/Enums/bank-account-type.enum.ts +10 -0
  31. package/src/lib/db/Enums/bank-connection-status.enum.ts +5 -0
  32. package/src/lib/db/Enums/bank-transaction-type.enum.ts +4 -0
  33. package/src/lib/db/Enums/chart-accounts-category.enum.ts +13 -0
  34. package/src/lib/db/Enums/chart-accounts-etp.enum.ts +7 -0
  35. package/src/lib/db/Enums/chart-accounts-heading-tax-deductible.enum.ts +6 -0
  36. package/src/lib/db/Enums/chart-accounts-heading-taxable.enum.ts +6 -0
  37. package/src/lib/db/Enums/chart-accounts-heading-vehicle-list.enum.ts +4 -0
  38. package/src/lib/db/Enums/chart-accounts-list.enum.ts +19 -0
  39. package/src/lib/db/Enums/chart-accounts-metadata-list.enum.ts +14 -0
  40. package/src/lib/db/Enums/chart-accounts-metadata-type.enum.ts +4 -0
  41. package/src/lib/db/Enums/chart-accounts-type.enum.ts +4 -0
  42. package/src/lib/db/Enums/chat-status.enum.ts +4 -0
  43. package/src/lib/db/Enums/client-details-medicare-exemption.enum.ts +5 -0
  44. package/src/lib/db/Enums/client-details-work-depreciation-calculation.enum.ts +4 -0
  45. package/src/lib/db/Enums/client-details-working-holiday-maker.enum.ts +5 -0
  46. package/src/lib/db/Enums/client-invite-status.enum.ts +4 -0
  47. package/src/lib/db/Enums/client-invite-type.enum.ts +4 -0
  48. package/src/lib/db/Enums/depreciation-calculation-percent.enum.ts +7 -0
  49. package/src/lib/db/Enums/depreciation-calculation.enum.ts +7 -0
  50. package/src/lib/db/Enums/depreciation-type.enum.ts +6 -0
  51. package/src/lib/db/Enums/depreciation-write-off-amount.enum.ts +4 -0
  52. package/src/lib/db/Enums/firm-type.enum.ts +4 -0
  53. package/src/lib/db/Enums/income-source-type-list-other.enum.ts +6 -0
  54. package/src/lib/db/Enums/income-source-type-list-salary.enum.ts +3 -0
  55. package/src/lib/db/Enums/income-source-type-list-work.enum.ts +8 -0
  56. package/src/lib/db/Enums/income-source-type.enum.ts +5 -0
  57. package/src/lib/db/Enums/invite-status.enum.ts +5 -0
  58. package/src/lib/db/Enums/loan-bank-type.enum.ts +10 -0
  59. package/src/lib/db/Enums/loan-frequency.enum.ts +6 -0
  60. package/src/lib/db/Enums/loan-interest-type.enum.ts +4 -0
  61. package/src/lib/db/Enums/loan-payout-type.enum.ts +4 -0
  62. package/src/lib/db/Enums/loan-repayment-frequency.enum.ts +5 -0
  63. package/src/lib/db/Enums/loan-repayment-type.enum.ts +4 -0
  64. package/src/lib/db/Enums/loan-type.enum.ts +12 -0
  65. package/src/lib/db/Enums/loan-vehicle-type.enum.ts +5 -0
  66. package/src/lib/db/Enums/phone-type.enum.ts +4 -0
  67. package/src/lib/db/Enums/property-depreciation-calculation.enum.ts +4 -0
  68. package/src/lib/db/Enums/property-owner-access.enum.ts +4 -0
  69. package/src/lib/db/Enums/property-owner-status.enum.ts +5 -0
  70. package/src/lib/db/Enums/registration-invite-status.enum.ts +4 -0
  71. package/src/lib/db/Enums/salary-forecast-frequency.enum.ts +6 -0
  72. package/src/lib/db/Enums/service-notification-status.enum.ts +5 -0
  73. package/src/lib/db/Enums/service-notification-type.enum.ts +4 -0
  74. package/src/lib/db/Enums/service-payment-status.enum.ts +4 -0
  75. package/src/lib/db/Enums/service-price-recurring-interval.enum.ts +6 -0
  76. package/src/lib/db/Enums/service-price-type.enum.ts +4 -0
  77. package/src/lib/db/Enums/service-subscription-status.enum.ts +8 -0
  78. package/src/lib/db/Enums/spare-document-spare-type.enum.ts +4 -0
  79. package/src/lib/db/Enums/tank-type.enum.ts +5 -0
  80. package/src/lib/db/Enums/tax-calculation-medicare-exemption.enum.ts +4 -0
  81. package/src/lib/db/Enums/tax-calculation-type.enum.ts +12 -0
  82. package/src/lib/db/Enums/tax-return-category-list.enum.ts +26 -0
  83. package/src/lib/db/Enums/tax-return-category-section.enum.ts +6 -0
  84. package/src/lib/db/Enums/tax-review-status.enum.ts +11 -0
  85. package/src/lib/db/Enums/tax-summary-list.enum.ts +15 -0
  86. package/src/lib/db/Enums/tax-summary-section.enum.ts +6 -0
  87. package/src/lib/db/Enums/tax-summary-tax-summary.enum.ts +15 -0
  88. package/src/lib/db/Enums/ticket-feedback.enum.ts +4 -0
  89. package/src/lib/db/Enums/ticket-status.enum.ts +7 -0
  90. package/src/lib/db/Enums/ticket-types.enum.ts +3 -0
  91. package/src/lib/db/Enums/transaction-operation.enum.ts +5 -0
  92. package/src/lib/db/Enums/transaction-source.enum.ts +4 -0
  93. package/src/lib/db/Enums/transaction-type.enum.ts +4 -0
  94. package/src/lib/db/Enums/user-event-status.enum.ts +6 -0
  95. package/src/lib/db/Enums/user-event-type-frequency.enum.ts +6 -0
  96. package/src/lib/db/Enums/user-event-type-reminder-type.enum.ts +6 -0
  97. package/src/lib/db/Enums/user-event-type-reminder.enum.ts +5 -0
  98. package/src/lib/db/Enums/user-event-type-type.enum.ts +33 -0
  99. package/src/lib/db/Enums/user-medicare-exemption.enum.ts +5 -0
  100. package/src/lib/db/Enums/user-roles.enum.ts +13 -0
  101. package/src/lib/db/Enums/user-status.enum.ts +6 -0
  102. package/src/lib/db/Enums/user-title.enum.ts +7 -0
  103. package/src/lib/db/Enums/user-work-depreciation-calculation.enum.ts +4 -0
  104. package/src/lib/db/Enums/user-working-holiday-maker.enum.ts +5 -0
  105. package/src/lib/db/Enums/vehicle-claim-method.enum.ts +4 -0
  106. package/src/lib/db/Enums/vehicle-logbook-purpose.enum.ts +4 -0
  107. package/src/lib/db/Models/address.ts +20 -0
  108. package/src/lib/db/Models/bank-account-balance.ts +13 -0
  109. package/src/lib/db/Models/bank-account-property.ts +9 -0
  110. package/src/lib/db/Models/bank-account.ts +34 -0
  111. package/src/lib/db/Models/bank-connection.ts +15 -0
  112. package/src/lib/db/Models/bank-provider-account.ts +13 -0
  113. package/src/lib/db/Models/bank-transaction-import.ts +12 -0
  114. package/src/lib/db/Models/bank-transaction-rule.ts +26 -0
  115. package/src/lib/db/Models/bank-transaction.ts +17 -0
  116. package/src/lib/db/Models/bank.ts +12 -0
  117. package/src/lib/db/Models/basiq-job.ts +9 -0
  118. package/src/lib/db/Models/borrowing-expense-loan.ts +15 -0
  119. package/src/lib/db/Models/borrowing-expense.ts +7 -0
  120. package/src/lib/db/Models/capital-cost-property.ts +14 -0
  121. package/src/lib/db/Models/capital-cost.ts +4 -0
  122. package/src/lib/db/Models/chart-accounts-depreciation.ts +11 -0
  123. package/src/lib/db/Models/chart-accounts-heading.ts +7 -0
  124. package/src/lib/db/Models/chart-accounts-metadata.ts +12 -0
  125. package/src/lib/db/Models/chart-accounts-value.ts +13 -0
  126. package/src/lib/db/Models/chart-accounts.ts +24 -0
  127. package/src/lib/db/Models/chat.ts +18 -0
  128. package/src/lib/db/Models/client-details.ts +30 -0
  129. package/src/lib/db/Models/client-invite.ts +17 -0
  130. package/src/lib/db/Models/client-movement.ts +13 -0
  131. package/src/lib/db/Models/country.ts +5 -0
  132. package/src/lib/db/Models/depreciation-capital-project.ts +14 -0
  133. package/src/lib/db/Models/depreciation-forecast.ts +19 -0
  134. package/src/lib/db/Models/depreciation-receipt.ts +12 -0
  135. package/src/lib/db/Models/depreciation.ts +43 -0
  136. package/src/lib/db/Models/document-base.ts +10 -0
  137. package/src/lib/db/Models/document-folder.ts +10 -0
  138. package/src/lib/db/Models/document.ts +12 -0
  139. package/src/lib/db/Models/employee-details.ts +8 -0
  140. package/src/lib/db/Models/employee-invite.ts +10 -0
  141. package/src/lib/db/Models/financial-data-system.ts +10 -0
  142. package/src/lib/db/Models/firm-invite.ts +15 -0
  143. package/src/lib/db/Models/firm.ts +29 -0
  144. package/src/lib/db/Models/income-source-forecast.ts +13 -0
  145. package/src/lib/db/Models/income-source-type.ts +9 -0
  146. package/src/lib/db/Models/income-source.ts +21 -0
  147. package/src/lib/db/Models/loan-payout.ts +13 -0
  148. package/src/lib/db/Models/loan.ts +34 -0
  149. package/src/lib/db/Models/message-document.ts +16 -0
  150. package/src/lib/db/Models/message.ts +16 -0
  151. package/src/lib/db/Models/occupation.ts +5 -0
  152. package/src/lib/db/Models/phone.ts +13 -0
  153. package/src/lib/db/Models/property-capital-cost.ts +14 -0
  154. package/src/lib/db/Models/property-category-movement.ts +18 -0
  155. package/src/lib/db/Models/property-category.ts +14 -0
  156. package/src/lib/db/Models/property-document.ts +14 -0
  157. package/src/lib/db/Models/property-forecast.ts +15 -0
  158. package/src/lib/db/Models/property-owner.ts +21 -0
  159. package/src/lib/db/Models/property-sold.ts +13 -0
  160. package/src/lib/db/Models/property-subscription.ts +10 -0
  161. package/src/lib/db/Models/property-valuation.ts +13 -0
  162. package/src/lib/db/Models/property.ts +42 -0
  163. package/src/lib/db/Models/registration-invite.ts +13 -0
  164. package/src/lib/db/Models/salary-forecast.ts +16 -0
  165. package/src/lib/db/Models/service-notification.ts +14 -0
  166. package/src/lib/db/Models/service-payment.ts +12 -0
  167. package/src/lib/db/Models/service-price.ts +16 -0
  168. package/src/lib/db/Models/service-product.ts +13 -0
  169. package/src/lib/db/Models/service-subscription-item.ts +10 -0
  170. package/src/lib/db/Models/service-subscription.ts +15 -0
  171. package/src/lib/db/Models/spare-document-category.ts +6 -0
  172. package/src/lib/db/Models/spare-document.ts +16 -0
  173. package/src/lib/db/Models/tax-calculation.ts +19 -0
  174. package/src/lib/db/Models/tax-return-category.ts +13 -0
  175. package/src/lib/db/Models/tax-return-item.ts +16 -0
  176. package/src/lib/db/Models/tax-return.ts +9 -0
  177. package/src/lib/db/Models/tax-review.ts +14 -0
  178. package/src/lib/db/Models/ticket.ts +20 -0
  179. package/src/lib/db/Models/transaction-allocation.ts +9 -0
  180. package/src/lib/db/Models/transaction-base.ts +33 -0
  181. package/src/lib/db/Models/transaction-metadata.ts +12 -0
  182. package/src/lib/db/Models/transaction-receipt.ts +12 -0
  183. package/src/lib/db/Models/transaction.ts +44 -0
  184. package/src/lib/db/Models/user-event-setting.ts +11 -0
  185. package/src/lib/db/Models/user-event-type.ts +16 -0
  186. package/src/lib/db/Models/user-event.ts +14 -0
  187. package/src/lib/db/Models/user.ts +52 -0
  188. package/src/lib/db/Models/vehicle-claim.ts +12 -0
  189. package/src/lib/db/Models/vehicle-logbook.ts +17 -0
  190. package/src/lib/db/Models/vehicle.ts +9 -0
  191. package/src/lib/functions/array/index.ts +3 -0
  192. package/src/lib/functions/array/replace.ts +5 -0
  193. package/src/lib/functions/array/sort-deep.ts +19 -0
  194. package/src/lib/functions/array/sort.ts +8 -0
  195. package/src/lib/functions/clone-deep.ts +4 -0
  196. package/src/lib/functions/create-date.ts +7 -0
  197. package/src/lib/functions/enum-to-list.ts +16 -0
  198. package/src/lib/functions/get-doc-icon.ts +21 -0
  199. package/src/lib/functions/mat-options-functions.ts +11 -0
  200. package/src/lib/functions/mat-sort-options.ts +9 -0
  201. package/src/lib/functions/round-to.ts +9 -0
  202. package/src/lib/functions/tax-review-filter-predicate.ts +11 -0
  203. package/src/lib/interfaces/asset-entity-type.enum.ts +10 -0
  204. package/src/lib/interfaces/asset-type.enum.ts +9 -0
  205. package/src/lib/interfaces/asset.interface.ts +18 -0
  206. package/src/lib/interfaces/chart-data.interface.ts +11 -0
  207. package/src/lib/interfaces/chart-serie.interface.ts +8 -0
  208. package/src/lib/interfaces/document.interface.ts +20 -0
  209. package/src/lib/interfaces/documentable.interface.ts +9 -0
  210. package/src/lib/interfaces/event-listener.interface.ts +9 -0
  211. package/src/lib/interfaces/income-source-forecast.interface.ts +7 -0
  212. package/src/lib/interfaces/option.interface.ts +4 -0
  213. package/src/lib/interfaces/photoable.ts +14 -0
  214. package/src/lib/interfaces/receipt.interface.ts +13 -0
  215. package/src/lib/interfaces/salary-forecast.interface.ts +17 -0
  216. package/src/lib/interfaces/tank.interface.ts +9 -0
  217. package/src/lib/models/address/address.ts +24 -0
  218. package/src/lib/models/address/country.ts +17 -0
  219. package/src/lib/models/bank/bank-account-chart-data.ts +42 -0
  220. package/src/lib/models/bank/bank-account-property.ts +8 -0
  221. package/src/lib/models/bank/bank-account-types.const.ts +15 -0
  222. package/src/lib/models/bank/bank-account.ts +136 -0
  223. package/src/lib/models/bank/bank-connection.ts +12 -0
  224. package/src/lib/models/bank/bank-transaction-chart-data.ts +132 -0
  225. package/src/lib/models/bank/bank-transaction-summary-fields.enum.ts +4 -0
  226. package/src/lib/models/bank/bank-transaction.ts +74 -0
  227. package/src/lib/models/bank/bank.ts +21 -0
  228. package/src/lib/models/bank/basiq-job.ts +4 -0
  229. package/src/lib/models/bank/basiq-token.ts +16 -0
  230. package/src/lib/models/bank/type-loan.const.ts +7 -0
  231. package/src/lib/models/borrowing-expense/borrowing-expense-loan.ts +4 -0
  232. package/src/lib/models/borrowing-expense/borrowing-expense.ts +4 -0
  233. package/src/lib/models/chart/chart-data.ts +13 -0
  234. package/src/lib/models/chart/chart-serie.ts +8 -0
  235. package/src/lib/models/chart-accounts/chart-accounts-categories.const.ts +85 -0
  236. package/src/lib/models/chart-accounts/chart-accounts-depreciation.ts +14 -0
  237. package/src/lib/models/chart-accounts/chart-accounts-heading.ts +6 -0
  238. package/src/lib/models/chart-accounts/chart-accounts-metadata.ts +15 -0
  239. package/src/lib/models/chart-accounts/chart-accounts-tax-labels.enum.ts +5 -0
  240. package/src/lib/models/chart-accounts/chart-accounts.ts +137 -0
  241. package/src/lib/models/chat/chat-view-type.enum.ts +4 -0
  242. package/src/lib/models/chat/chat.ts +23 -0
  243. package/src/lib/models/chat/message-document.ts +18 -0
  244. package/src/lib/models/chat/message.ts +40 -0
  245. package/src/lib/models/client/client-details.ts +4 -0
  246. package/src/lib/models/client/client-invite.ts +70 -0
  247. package/src/lib/models/client/client-movement.ts +25 -0
  248. package/src/lib/models/client/client-portfolio-chart-data.ts +65 -0
  249. package/src/lib/models/client/client-portfolio-report.ts +10 -0
  250. package/src/lib/models/depreciation/depreciation-capital-project.ts +10 -0
  251. package/src/lib/models/depreciation/depreciation-forecast.ts +31 -0
  252. package/src/lib/models/depreciation/depreciation-group-item.ts +20 -0
  253. package/src/lib/models/depreciation/depreciation-group.enum.ts +7 -0
  254. package/src/lib/models/depreciation/depreciation-group.ts +25 -0
  255. package/src/lib/models/depreciation/depreciation-groups.const.ts +35 -0
  256. package/src/lib/models/depreciation/depreciation-receipt.ts +9 -0
  257. package/src/lib/models/depreciation/depreciation.ts +174 -0
  258. package/src/lib/models/document/document-api-url-prefix.enum.ts +7 -0
  259. package/src/lib/models/document/document-file-types.const.ts +22 -0
  260. package/src/lib/models/document/document-folder.ts +11 -0
  261. package/src/lib/models/document/document.ts +29 -0
  262. package/src/lib/models/employee/employee-details.ts +8 -0
  263. package/src/lib/models/employee/employee-invite.ts +12 -0
  264. package/src/lib/models/endpoint/endpoint.ts +35 -0
  265. package/src/lib/models/endpoint/endpoints.const.ts +157 -0
  266. package/src/lib/models/event/app-event-type.enum.ts +37 -0
  267. package/src/lib/models/event/app-event.ts +9 -0
  268. package/src/lib/models/file/icons-file.enum.ts +5 -0
  269. package/src/lib/models/financial-year/financial-year.ts +57 -0
  270. package/src/lib/models/financial-year/month-name-short.enum.ts +19 -0
  271. package/src/lib/models/financial-year/month-number.enum.ts +19 -0
  272. package/src/lib/models/financial-year/months.const.ts +1 -0
  273. package/src/lib/models/firm/firm.ts +31 -0
  274. package/src/lib/models/income-position/income-position.ts +13 -0
  275. package/src/lib/models/income-source/income-source-chart-data.ts +57 -0
  276. package/src/lib/models/income-source/income-source-forecast.ts +35 -0
  277. package/src/lib/models/income-source/income-source-type.ts +30 -0
  278. package/src/lib/models/income-source/income-source.ts +57 -0
  279. package/src/lib/models/income-source/salary-forecast.ts +23 -0
  280. package/src/lib/models/loan/loan-max-number-of-payments.enum.ts +8 -0
  281. package/src/lib/models/loan/loan-payment.ts +17 -0
  282. package/src/lib/models/loan/loan-payout.ts +13 -0
  283. package/src/lib/models/loan/loan.ts +38 -0
  284. package/src/lib/models/logbook/default-vehicle-expense.ts +20 -0
  285. package/src/lib/models/logbook/logbook-period.ts +12 -0
  286. package/src/lib/models/logbook/logbook-purpose-options.const.ts +6 -0
  287. package/src/lib/models/logbook/vehicle-claim.ts +27 -0
  288. package/src/lib/models/logbook/vehicle-logbook.ts +16 -0
  289. package/src/lib/models/logbook/vehicle.ts +46 -0
  290. package/src/lib/models/notification/notification-event-types.const.ts +43 -0
  291. package/src/lib/models/notification/notification.ts +66 -0
  292. package/src/lib/models/phone/phone.ts +10 -0
  293. package/src/lib/models/property/calculation-form-item.ts +24 -0
  294. package/src/lib/models/property/calculation-form-type.enum.ts +7 -0
  295. package/src/lib/models/property/capital-costs-itmes.const.ts +57 -0
  296. package/src/lib/models/property/corelogic-suggestion.ts +18 -0
  297. package/src/lib/models/property/ownership-filter-options.enum.ts +8 -0
  298. package/src/lib/models/property/property-capital-cost.ts +4 -0
  299. package/src/lib/models/property/property-category-movement.ts +18 -0
  300. package/src/lib/models/property/property-category.ts +9 -0
  301. package/src/lib/models/property/property-document.ts +21 -0
  302. package/src/lib/models/property/property-equity-chart-data.ts +188 -0
  303. package/src/lib/models/property/property-equity-chart-item.ts +35 -0
  304. package/src/lib/models/property/property-equity-chart-type.enum.ts +4 -0
  305. package/src/lib/models/property/property-forecast.ts +55 -0
  306. package/src/lib/models/property/property-owner.ts +50 -0
  307. package/src/lib/models/property/property-sold.ts +10 -0
  308. package/src/lib/models/property/property-subscription.ts +11 -0
  309. package/src/lib/models/property/property-valuation.ts +24 -0
  310. package/src/lib/models/property/property.ts +157 -0
  311. package/src/lib/models/registration-invite/registration-invite.ts +12 -0
  312. package/src/lib/models/service-subscription/module-url-list.const.ts +11 -0
  313. package/src/lib/models/service-subscription/service-payment.ts +8 -0
  314. package/src/lib/models/service-subscription/service-price.ts +8 -0
  315. package/src/lib/models/service-subscription/service-product.ts +11 -0
  316. package/src/lib/models/service-subscription/service-subscription-item.ts +12 -0
  317. package/src/lib/models/service-subscription/service-subscription.ts +151 -0
  318. package/src/lib/models/service-subscription/subscription-description.const.ts +8 -0
  319. package/src/lib/models/service-subscription/subscription-title.const.ts +8 -0
  320. package/src/lib/models/service-subscription/subscription-type.enum.ts +6 -0
  321. package/src/lib/models/tax-review/tax-review.ts +96 -0
  322. package/src/lib/models/tax-summary/tax-return-category-item-details.ts +14 -0
  323. package/src/lib/models/tax-summary/tax-return-category-item.ts +22 -0
  324. package/src/lib/models/tax-summary/tax-summary-section.ts +32 -0
  325. package/src/lib/models/tax-summary/tax-summary-type.enum.ts +7 -0
  326. package/src/lib/models/tax-summary/tax-summary.ts +79 -0
  327. package/src/lib/models/transaction/income-amount-type.enum.ts +7 -0
  328. package/src/lib/models/transaction/transaction-allocation.ts +20 -0
  329. package/src/lib/models/transaction/transaction-metadata.ts +8 -0
  330. package/src/lib/models/transaction/transaction-receipt.ts +9 -0
  331. package/src/lib/models/transaction/transaction.ts +241 -0
  332. package/src/lib/models/user/my-account-history-initiated-by.enum.ts +4 -0
  333. package/src/lib/models/user/my-account-history-status.enum.ts +4 -0
  334. package/src/lib/models/user/my-account-history-type.enum.ts +5 -0
  335. package/src/lib/models/user/my-account-history.ts +12 -0
  336. package/src/lib/models/user/occupation.ts +4 -0
  337. package/src/lib/models/user/user-roles.const.ts +13 -0
  338. package/src/lib/models/user/user-to-register.ts +7 -0
  339. package/src/lib/models/user/user-work-position.const.ts +7 -0
  340. package/src/lib/models/user/user.ts +160 -0
  341. package/src/lib/models/user-event/user-event-category.enum.ts +9 -0
  342. package/src/lib/models/user-event/user-event-category.ts +9 -0
  343. package/src/lib/models/user-event/user-event-setting-field.enum.ts +8 -0
  344. package/src/lib/models/user-event/user-event-setting.ts +11 -0
  345. package/src/lib/models/user-event/user-event-type.ts +22 -0
  346. package/src/lib/services/address/address.service.spec.ts +12 -0
  347. package/src/lib/services/address/address.service.ts +36 -0
  348. package/src/lib/services/asset/assets.service.spec.ts +12 -0
  349. package/src/lib/services/asset/assets.service.ts +51 -0
  350. package/src/lib/services/auth/auth.service.ts +48 -0
  351. package/src/lib/services/auth/jwt.service.ts +37 -0
  352. package/src/lib/services/bank/bank-account-calculation.service.spec.ts +16 -0
  353. package/src/lib/services/bank/bank-account-calculation.service.ts +38 -0
  354. package/src/lib/services/bank/bank-account.service.spec.ts +12 -0
  355. package/src/lib/services/bank/bank-account.service.ts +120 -0
  356. package/src/lib/services/bank/bank-connection.service.spec.ts +12 -0
  357. package/src/lib/services/bank/bank-connection.service.ts +42 -0
  358. package/src/lib/services/bank/bank-transaction-calculation.service.spec.ts +16 -0
  359. package/src/lib/services/bank/bank-transaction-calculation.service.ts +71 -0
  360. package/src/lib/services/bank/bank-transaction.service.spec.ts +12 -0
  361. package/src/lib/services/bank/bank-transaction.service.ts +97 -0
  362. package/src/lib/services/bank/bank.service.spec.ts +12 -0
  363. package/src/lib/services/bank/bank.service.ts +16 -0
  364. package/src/lib/services/bank/basiq.service.spec.ts +12 -0
  365. package/src/lib/services/bank/basiq.service.ts +103 -0
  366. package/src/lib/services/base-rest.service.spec.ts +13 -0
  367. package/src/lib/services/base-rest.service.ts +229 -0
  368. package/src/lib/services/borrowing-expense/borrowing-expense.service.spec.ts +12 -0
  369. package/src/lib/services/borrowing-expense/borrowing-expense.service.ts +82 -0
  370. package/src/lib/services/chart-accounts/chart-accounts-depreciations.service.spec.ts +16 -0
  371. package/src/lib/services/chart-accounts/chart-accounts-depreciations.service.ts +34 -0
  372. package/src/lib/services/chart-accounts/chart-accounts.service.spec.ts +12 -0
  373. package/src/lib/services/chart-accounts/chart-accounts.service.ts +101 -0
  374. package/src/lib/services/chat/chat.service.spec.ts +16 -0
  375. package/src/lib/services/chat/chat.service.ts +79 -0
  376. package/src/lib/services/chat/message-document.service.spec.ts +16 -0
  377. package/src/lib/services/chat/message-document.service.ts +133 -0
  378. package/src/lib/services/chat/message.service.spec.ts +16 -0
  379. package/src/lib/services/chat/message.service.ts +61 -0
  380. package/src/lib/services/client/client-invite.service.spec.ts +16 -0
  381. package/src/lib/services/client/client-invite.service.ts +111 -0
  382. package/src/lib/services/client/client-movement.service.spec.ts +16 -0
  383. package/src/lib/services/client/client-movement.service.ts +114 -0
  384. package/src/lib/services/client/client-portfolio-report.service.spec.ts +16 -0
  385. package/src/lib/services/client/client-portfolio-report.service.ts +34 -0
  386. package/src/lib/services/depreciation/capital-project.service.spec.ts +16 -0
  387. package/src/lib/services/depreciation/capital-project.service.ts +69 -0
  388. package/src/lib/services/depreciation/depreciation.service.spec.ts +12 -0
  389. package/src/lib/services/depreciation/depreciation.service.ts +171 -0
  390. package/src/lib/services/document/document-folder.service.spec.ts +16 -0
  391. package/src/lib/services/document/document-folder.service.ts +95 -0
  392. package/src/lib/services/employee/employee-invite.service.spec.ts +16 -0
  393. package/src/lib/services/employee/employee-invite.service.ts +53 -0
  394. package/src/lib/services/employee/employee.service.spec.ts +16 -0
  395. package/src/lib/services/employee/employee.service.ts +35 -0
  396. package/src/lib/services/event/event-dispatcher.service.spec.ts +16 -0
  397. package/src/lib/services/event/event-dispatcher.service.ts +29 -0
  398. package/src/lib/services/event/sse.service.spec.ts +16 -0
  399. package/src/lib/services/event/sse.service.ts +42 -0
  400. package/src/lib/services/firm/firm.service.spec.ts +16 -0
  401. package/src/lib/services/firm/firm.service.ts +93 -0
  402. package/src/lib/services/header-title/header-title.service.spec.ts +12 -0
  403. package/src/lib/services/header-title/header-title.service.ts +31 -0
  404. package/src/lib/services/income-source/income-source-forecast.service.spec.ts +16 -0
  405. package/src/lib/services/income-source/income-source-forecast.service.ts +91 -0
  406. package/src/lib/services/income-source/income-source.service.spec.ts +12 -0
  407. package/src/lib/services/income-source/income-source.service.ts +127 -0
  408. package/src/lib/services/income-source/salary-forecast.service.spec.ts +16 -0
  409. package/src/lib/services/income-source/salary-forecast.service.ts +92 -0
  410. package/src/lib/services/intercom/intercom.service.spec.ts +16 -0
  411. package/src/lib/services/intercom/intercom.service.ts +37 -0
  412. package/src/lib/services/loan/loan.service.spec.ts +12 -0
  413. package/src/lib/services/loan/loan.service.ts +166 -0
  414. package/src/lib/services/notification/notification.service.spec.ts +12 -0
  415. package/src/lib/services/notification/notification.service.ts +60 -0
  416. package/src/lib/services/preloader/preloader.service.spec.ts +16 -0
  417. package/src/lib/services/preloader/preloader.service.ts +28 -0
  418. package/src/lib/services/property/corelogic.service.spec.ts +12 -0
  419. package/src/lib/services/property/corelogic.service.ts +47 -0
  420. package/src/lib/services/property/property-calculation.service.spec.ts +16 -0
  421. package/src/lib/services/property/property-calculation.service.ts +166 -0
  422. package/src/lib/services/property/property-capital-cost.service.ts +42 -0
  423. package/src/lib/services/property/property-category.service.spec.ts +16 -0
  424. package/src/lib/services/property/property-category.service.ts +15 -0
  425. package/src/lib/services/property/property-document.service.spec.ts +16 -0
  426. package/src/lib/services/property/property-document.service.ts +74 -0
  427. package/src/lib/services/property/property-owner.service.spec.ts +12 -0
  428. package/src/lib/services/property/property-owner.service.ts +134 -0
  429. package/src/lib/services/property/property-sold.service.spec.ts +16 -0
  430. package/src/lib/services/property/property-sold.service.ts +15 -0
  431. package/src/lib/services/property/property.service.spec.ts +12 -0
  432. package/src/lib/services/property/property.service.ts +136 -0
  433. package/src/lib/services/subscription/subscription.service.spec.ts +12 -0
  434. package/src/lib/services/subscription/subscription.service.ts +153 -0
  435. package/src/lib/services/tax-review/tax-review-history.service.spec.ts +16 -0
  436. package/src/lib/services/tax-review/tax-review-history.service.ts +35 -0
  437. package/src/lib/services/tax-review/tax-review.service.spec.ts +16 -0
  438. package/src/lib/services/tax-review/tax-review.service.ts +114 -0
  439. package/src/lib/services/tax-summary/tax-summary.service.ts +70 -0
  440. package/src/lib/services/transaction/transaction-allocation.service.spec.ts +12 -0
  441. package/src/lib/services/transaction/transaction-allocation.service.ts +92 -0
  442. package/src/lib/services/transaction/transaction-calculation.service.spec.ts +16 -0
  443. package/src/lib/services/transaction/transaction-calculation.service.ts +50 -0
  444. package/src/lib/services/transaction/transaction.service.spec.ts +12 -0
  445. package/src/lib/services/transaction/transaction.service.ts +374 -0
  446. package/src/lib/services/user/occupation.service.spec.ts +12 -0
  447. package/src/lib/services/user/occupation.service.ts +42 -0
  448. package/src/lib/services/user/user-switcher.service.ts +34 -0
  449. package/src/lib/services/user/user.service.spec.ts +12 -0
  450. package/src/lib/services/user/user.service.ts +140 -0
  451. package/src/lib/services/user-event/user-event-setting.service.spec.ts +16 -0
  452. package/src/lib/services/user-event/user-event-setting.service.ts +60 -0
  453. package/src/lib/services/user-event/user-event-type.service.spec.ts +16 -0
  454. package/src/lib/services/user-event/user-event-type.service.ts +24 -0
  455. package/src/lib/services/work/work-tank.service.spec.ts +12 -0
  456. package/src/lib/services/work/work-tank.service.ts +277 -0
  457. package/src/lib/tt-core.module.ts +22 -0
  458. package/src/lib/tt-core.service.spec.ts +16 -0
  459. package/src/lib/tt-core.service.ts +17 -0
  460. package/src/public-api.ts +425 -0
  461. package/src/test.ts +27 -0
  462. package/tsconfig.lib.json +15 -0
  463. package/tsconfig.lib.prod.json +10 -0
  464. package/tsconfig.spec.json +17 -0
  465. package/bundles/taxtank-core.umd.js +0 -97
  466. package/bundles/taxtank-core.umd.js.map +0 -1
  467. package/esm2015/lib/tt-core.module.js +0 -33
  468. package/esm2015/lib/tt-core.service.js +0 -23
  469. package/esm2015/public-api.js +0 -6
  470. package/esm2015/taxtank-core.js +0 -5
  471. package/fesm2015/taxtank-core.js +0 -64
  472. package/fesm2015/taxtank-core.js.map +0 -1
  473. package/lib/tt-core.module.d.ts +0 -9
  474. package/lib/tt-core.service.d.ts +0 -8
  475. package/public-api.d.ts +0 -2
  476. package/taxtank-core.d.ts +0 -5
@@ -0,0 +1,374 @@
1
+ import { EventEmitter, Inject, Injectable } from '@angular/core';
2
+ import { Observable } from 'rxjs';
3
+ import { Transaction as TransactionBase } from '../../db/Models/transaction';
4
+ import { map } from 'rxjs/operators';
5
+ import { replace, sort } from '../../functions/array';
6
+ import { enumToList } from '../../functions/enum-to-list';
7
+ import { ChartAccountsHeadingTaxableEnum } from '../../db/Enums/chart-accounts-heading-taxable.enum';
8
+ import { ChartAccountsHeadingTaxDeductibleEnum } from '../../db/Enums/chart-accounts-heading-tax-deductible.enum';
9
+ import { TransactionOperationEnum } from '../../db/Enums/transaction-operation.enum';
10
+ import { HttpClient } from '@angular/common/http';
11
+ import { EventDispatcherService } from '../event/event-dispatcher.service';
12
+ import { BaseRestService } from '../base-rest.service';
13
+ import { plainToClass } from 'class-transformer';
14
+ import { CHART_ACCOUNTS_CATEGORIES } from '../../models/chart-accounts/chart-accounts-categories.const';
15
+ import { Transaction } from '../../models/transaction/transaction';
16
+ import { AppEventTypeEnum } from '../../models/event/app-event-type.enum';
17
+ import { AppEvent } from '../../models/event/app-event';
18
+ import { TransactionReceipt } from '../../models/transaction/transaction-receipt';
19
+ import { ChartAccounts } from '../../models/chart-accounts/chart-accounts';
20
+ import _ from 'lodash';
21
+ import { ChartAccountsTaxLabelsEnum } from '../../models/chart-accounts/chart-accounts-tax-labels.enum';
22
+
23
+ /**
24
+ * Service for transactions business logic
25
+ */
26
+ @Injectable({
27
+ providedIn: 'root'
28
+ })
29
+ export class TransactionService extends BaseRestService<TransactionBase, Transaction> {
30
+ // url part for Transaction API
31
+ url: string = 'transactions';
32
+ modelClass = Transaction;
33
+ transactionDeleted: EventEmitter<Transaction> = new EventEmitter<Transaction>();
34
+
35
+ constructor(
36
+ protected http: HttpClient,
37
+ protected eventDispatcherService: EventDispatcherService,
38
+ @Inject('environment') protected environment: any
39
+ ) {
40
+ super(http, eventDispatcherService, environment);
41
+ this.listenEvents();
42
+ }
43
+
44
+ /**
45
+ * Listen events from Event Dispatcher services
46
+ */
47
+ listenEvents(): void {
48
+ this.listenDepreciationChange();
49
+ }
50
+
51
+ /**
52
+ * get list of all user's TaxTank transactions
53
+ */
54
+ get(): Observable<Transaction[]> {
55
+ if (!this.cache) {
56
+ // set cache as default empty array to avoid multiple backend requests
57
+ this.cache = [];
58
+ this.fetch()
59
+ .subscribe((transactions: Transaction[]) => {
60
+ this.cache = transactions;
61
+ this.updateCache();
62
+ });
63
+ }
64
+
65
+ return this.cacheSubject.asObservable().pipe(
66
+ // assign child transactions (fees) to parent transactions
67
+ map((transactions: Transaction[]): Transaction[] => {
68
+ transactions.forEach((transaction: Transaction): void => {
69
+ transaction.transactions = transactions
70
+ // get list of child transactions
71
+ .filter((t: Transaction): boolean => t.parentTransaction && t.parentTransaction.id === transaction.id);
72
+ });
73
+ sort(transactions, 'date', false);
74
+ return transactions;
75
+ })
76
+ );
77
+ }
78
+
79
+ /**
80
+ * Add single new transaction
81
+ * @param model New Transaction instance for saving
82
+ */
83
+ add(model: Transaction): Observable<Transaction> {
84
+ // we don't have POST API endpoint for single transaction
85
+ return this.addBatch([model])
86
+ .pipe(
87
+ map((newTransactions: Transaction[]): Transaction => {
88
+ // @TODO alex
89
+ this.eventDispatcherService.dispatch(
90
+ new AppEvent<Transaction>(AppEventTypeEnum.TRANSACTION_CREATED, newTransactions[0])
91
+ );
92
+
93
+ return newTransactions[0];
94
+ })
95
+ );
96
+ }
97
+
98
+ /**
99
+ * get transactions related with property
100
+ */
101
+ getByPropertyId(propertyId: number): Observable<Transaction[]> {
102
+ return this.get()
103
+ .pipe(
104
+ map((transactions: Transaction[]): Transaction[] => {
105
+ return transactions.filter((transaction: Transaction): boolean => {
106
+ return transaction.property?.id === propertyId;
107
+ });
108
+ })
109
+ );
110
+ }
111
+
112
+ /**
113
+ * get list of transactions with tank type 'Work'
114
+ */
115
+ getWorkTransactions(): Observable<Transaction[]> {
116
+ return this.get()
117
+ .pipe(
118
+ map((transactions: Transaction[]): Transaction[] => {
119
+ return transactions.filter((transaction: Transaction): boolean => transaction.isWorkTank());
120
+ })
121
+ );
122
+ }
123
+
124
+ /**
125
+ * get list of taxable transactions with tank type 'Work'
126
+ */
127
+ getTaxableWorkTransactions(): Observable<Transaction[]> {
128
+ return this.getWorkTransactions()
129
+ .pipe(
130
+ map((transactions: Transaction[]): Transaction[] => {
131
+ return transactions.filter((transaction: Transaction): boolean => !!transaction.chartAccounts.taxReturnItem);
132
+ })
133
+ );
134
+ }
135
+
136
+ /**
137
+ * add multiple transactions
138
+ * @param transactions List of new Transaction instances for saving
139
+ */
140
+ addBatch(transactions: Transaction[]): Observable<Transaction[]> {
141
+ transactions = _.cloneDeep(transactions);
142
+ return this.http.post(`${this.environment.apiV2}/${this.url}`, transactions)
143
+ .pipe(
144
+ map((response: TransactionBase[]) => {
145
+ const addedTransactions: Transaction[] = response.map((item: TransactionBase) => plainToClass(Transaction, item));
146
+
147
+ transactions.forEach((transaction: Transaction, index: number) => {
148
+ // @TODO backend: need to upload file in the same backend endpoint with transaction add/update
149
+ // check if passed receipt and upload file
150
+ if (transaction.file) {
151
+ transaction.id = response[index].id;
152
+ addedTransactions[index].file = transaction.file;
153
+ this.uploadReceipt(addedTransactions[index]);
154
+ }
155
+
156
+ // @TODO Viktor: implement API for saving of nested transactions
157
+ // add child transactions if exist
158
+ if (transaction.transactions.length) {
159
+ transaction.transactions.forEach((childTransaction: Transaction) => {
160
+ childTransaction.parentTransaction = plainToClass(Transaction, {id: addedTransactions[index].id});
161
+ });
162
+ this.addBatch(transaction.transactions).subscribe();
163
+ }
164
+
165
+ // add transfer transaction to cache
166
+ if (transaction.operation === TransactionOperationEnum.TRANSFER) {
167
+ addedTransactions.push(addedTransactions[0].transfer);
168
+ }
169
+ });
170
+
171
+ if (this.cache) {
172
+ this.cache.push(...addedTransactions);
173
+ this.updateCache();
174
+ }
175
+
176
+ this.eventDispatcherService.dispatch(
177
+ new AppEvent<Transaction[]>(AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions)
178
+ );
179
+
180
+ return addedTransactions;
181
+ })
182
+ );
183
+ }
184
+
185
+ /**
186
+ * update existing transaction
187
+ * @param transaction Transaction instance for updating
188
+ */
189
+ update(transaction: Transaction): Observable<Transaction> {
190
+ return this.http.put(`${this.environment.apiV2}/${this.url}/${transaction.id}`, transaction)
191
+ .pipe(
192
+ map((response: TransactionBase) => {
193
+ const updatedTransaction: Transaction = plainToClass(Transaction, response);
194
+
195
+ // @TODO need to upload file in the same backend endpoint with transaction add/update
196
+ // check if passed new receipt and upload file
197
+ if (transaction.file) {
198
+ updatedTransaction.file = transaction.file;
199
+ this.uploadReceipt(updatedTransaction);
200
+ }
201
+
202
+ // @TODO Viktor: implement API for saving of nested transactions
203
+ if (transaction.transactions.length) {
204
+ // add parent transaction to child transactions
205
+ transaction.transactions.forEach((childTransaction: Transaction) => {
206
+ childTransaction.parentTransaction = plainToClass(Transaction, {id: updatedTransaction.id});
207
+ });
208
+ // separate child transactions by id existing to define add or update action.
209
+ const childTransactionsToUpdate: Transaction[] = transaction.transactions.filter((t: Transaction) => t.id);
210
+ const childTransactionsToAdd: Transaction[] = transaction.transactions.filter((t: Transaction) => !t.id);
211
+
212
+ // update child transactions
213
+ if (childTransactionsToUpdate.length) {
214
+ this.updateBatch(childTransactionsToUpdate).subscribe();
215
+ }
216
+
217
+ // add child transactions
218
+ if (childTransactionsToAdd.length) {
219
+ this.addBatch(childTransactionsToAdd).subscribe();
220
+ }
221
+ }
222
+
223
+ replace(this.cache, updatedTransaction);
224
+ this.updateCache();
225
+ return updatedTransaction;
226
+ })
227
+ );
228
+ }
229
+
230
+ /**
231
+ * update multiple transactions
232
+ * @param transactions list of transactions for updating
233
+ */
234
+ updateBatch(transactions: Transaction[]): Observable<Transaction[]> {
235
+ return this.http.put(`${this.environment.apiV2}/${this.url}`, transactions)
236
+ .pipe(
237
+ map((response: TransactionBase[]) => {
238
+ const updatedTransactions: Transaction[] = response.map((item: TransactionBase) => plainToClass(Transaction, item));
239
+
240
+ updatedTransactions.forEach((updatedTransaction: Transaction) => {
241
+ replace(this.cache, updatedTransaction);
242
+ });
243
+
244
+ this.updateCache();
245
+ return updatedTransactions;
246
+ })
247
+ );
248
+ }
249
+
250
+ /**
251
+ * delete transaction and related transactions
252
+ * @param model
253
+ */
254
+ delete(model: Transaction): Observable<void> {
255
+ return this.http.delete(`${this.environment.apiV2}/${this.url}/${model.id}`)
256
+ .pipe(
257
+ map((): void => {
258
+ this.cache = this.cache.filter((transaction: Transaction): boolean => {
259
+ // when delete transfer we delete actually 2 transactions
260
+ if (model.isTransfer) {
261
+ const ids: number[] = [model.id];
262
+
263
+ // get id of related transfer transaction
264
+ if (model.transfer) {
265
+ // just take id if we delete source transaction
266
+ ids.push(model.transfer.id);
267
+ } else {
268
+ // find source transaction id if we delete destination transaction
269
+ ids.push(this.cache.find((t: Transaction): boolean => t.transfer.id === model.id).id);
270
+ }
271
+
272
+ return !ids.includes(transaction.id);
273
+ }
274
+
275
+ return transaction.id !== model.id && transaction.parentTransaction?.id !== model.id;
276
+ });
277
+
278
+ this.eventDispatcherService.dispatch(
279
+ new AppEvent<Transaction>(AppEventTypeEnum.TRANSACTION_DELETED, model)
280
+ );
281
+
282
+ this.updateCache();
283
+ this.transactionDeleted.emit(model);
284
+ })
285
+ );
286
+ }
287
+
288
+ /**
289
+ * upload transaction receipt image
290
+ * @param transaction Еhe transaction for which the receipt will be imported
291
+ */
292
+ uploadReceipt(transaction: Transaction): void {
293
+ const formData: FormData = new FormData();
294
+ formData.append('file', transaction.file);
295
+ transaction.receipt = null;
296
+
297
+ this.http.post(`${this.environment.apiV2}/${this.url}/${transaction.id}/receipts`, formData)
298
+ .subscribe((receiptResponse: any) => {
299
+ // we don't need to keep file after save
300
+ transaction.file = null;
301
+ transaction.receipt = plainToClass(TransactionReceipt, receiptResponse);
302
+ replace(this.cache, transaction);
303
+ this.updateCache();
304
+ });
305
+ }
306
+
307
+ /**
308
+ * calculate gross income amount based on transaction amount and taxes (fees)
309
+ * @param transaction Transaction instance for calculation
310
+ */
311
+ calculateGrossAmount(transaction: Transaction): number {
312
+ let amount: number = transaction.amount || 0;
313
+
314
+ // gross income amount includes amount of fees for property tank and tax for work tank
315
+ if (transaction.isPropertyTank()) {
316
+ amount += transaction.transactions.reduce((sum: number, item: Transaction) => sum + item.amount, 0);
317
+ } else {
318
+ // @TODO Alex: fix logic after TT-641 ready
319
+ amount += (transaction.tax || 0);
320
+ }
321
+
322
+ return amount;
323
+ }
324
+
325
+ /**
326
+ * get label for transaction tax field depended of selected chart account.
327
+ * tax type depends of chart account heading or category.
328
+ */
329
+ getTaxLabel(chartAccounts: ChartAccounts): ChartAccountsTaxLabelsEnum {
330
+ // get simple array of ids from enum with taxable chart accounts headings
331
+ const taxableCAHeadingsIds: number[] = enumToList(ChartAccountsHeadingTaxableEnum)
332
+ .map((item: { label: string, value: number }) => item.value);
333
+ // get simple array of ids from enum with tax deductible chart accounts headings
334
+ const deductibleCAHeadingsIds: number[] = enumToList(ChartAccountsHeadingTaxDeductibleEnum)
335
+ .map((item: { label: string, value: number }) => item.value);
336
+
337
+ // check if one of ids arrays includes current chart accounts heading id and set tax label
338
+ // otherwise label is empty for this class
339
+ switch (true) {
340
+ case taxableCAHeadingsIds.includes(chartAccounts.heading?.id):
341
+ return ChartAccountsTaxLabelsEnum.TAX_PAID;
342
+ case deductibleCAHeadingsIds.includes(chartAccounts.heading?.id):
343
+ return ChartAccountsTaxLabelsEnum.TAX_DEDUCTED;
344
+ case CHART_ACCOUNTS_CATEGORIES.workIncome.includes(chartAccounts.category):
345
+ return ChartAccountsTaxLabelsEnum.TAX_WITHHELD;
346
+ default:
347
+ return null;
348
+ }
349
+ }
350
+
351
+ /**
352
+ * Get transactions related to Vehicle category
353
+ */
354
+ getVehicleTransactions(): Observable<Transaction[]> {
355
+ return this.get().pipe(
356
+ map((transactions: Transaction[]) => {
357
+ return transactions.filter((transaction: Transaction): boolean => transaction.isVehicleTransaction());
358
+ })
359
+ );
360
+ }
361
+
362
+ /**
363
+ * Listen to EventDispatcherService event related to Depreciation changing
364
+ */
365
+ private listenDepreciationChange(): void {
366
+ this.eventDispatcherService.on(AppEventTypeEnum.DEPRECIATION_DELETED).subscribe(() => {
367
+ this.fetch()
368
+ .subscribe((transactions: Transaction[]) => {
369
+ this.cache = transactions;
370
+ this.updateCache();
371
+ });
372
+ });
373
+ }
374
+ }
@@ -0,0 +1,12 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { OccupationService } from './occupation.service';
4
+
5
+ describe('OccupationService', () => {
6
+ beforeEach(() => TestBed.configureTestingModule({}));
7
+
8
+ it('should be created', () => {
9
+ const service: OccupationService = TestBed.get(OccupationService);
10
+ expect(service).toBeTruthy();
11
+ });
12
+ });
@@ -0,0 +1,42 @@
1
+ import { Inject, Injectable } from '@angular/core';
2
+ import { Observable, ReplaySubject } from 'rxjs';
3
+ import { HttpClient } from '@angular/common/http';
4
+ import { map } from 'rxjs/operators';
5
+ import { plainToClass } from 'class-transformer';
6
+ import { Occupation } from '../../models/user/occupation';
7
+
8
+ /**
9
+ * Service that works with Occupations
10
+ */
11
+ @Injectable({
12
+ providedIn: 'root'
13
+ })
14
+ export class OccupationService {
15
+ _occupations: Occupation[];
16
+ occupationsSubject: ReplaySubject<Occupation[]> = new ReplaySubject<Occupation[]>(1);
17
+
18
+ constructor(
19
+ private http: HttpClient,
20
+ @Inject('environment') private environment: any
21
+ ) { }
22
+
23
+ /**
24
+ * Get list of occupations
25
+ */
26
+ getOccupations(): Observable<Occupation[]> {
27
+ if (!this._occupations) {
28
+ this.http.get(`${this.environment.apiV2}/occupations`)
29
+ .pipe(
30
+ map((response: any) => {
31
+ return response.map((item: object) => plainToClass(Occupation, item));
32
+ })
33
+ )
34
+ .subscribe((occupations: Occupation[]) => {
35
+ this._occupations = occupations;
36
+ this.occupationsSubject.next(occupations);
37
+ });
38
+ }
39
+
40
+ return this.occupationsSubject.asObservable();
41
+ }
42
+ }
@@ -0,0 +1,34 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ const KEY = '_switch_user';
4
+
5
+ /**
6
+ * provides user management to managers (users with ROLE_ACCOUNTANT for now, more in future)
7
+ */
8
+ @Injectable({
9
+ providedIn: 'root'
10
+ })
11
+ export class UserSwitcherService {
12
+ /**
13
+ * get switched username
14
+ */
15
+ get(): string {
16
+ return localStorage[KEY];
17
+ }
18
+
19
+ /**
20
+ * switch to user (username should be used for correct work of backend)
21
+ */
22
+ set(username: string): void {
23
+ localStorage[KEY] = username;
24
+ window.location.replace('/client/dashboard');
25
+ }
26
+
27
+ /**
28
+ * go back to original user
29
+ */
30
+ reset(): void {
31
+ localStorage.removeItem(KEY);
32
+ window.location.replace('/firm/dashboard');
33
+ }
34
+ }
@@ -0,0 +1,12 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { UserService } from './user.service';
4
+
5
+ describe('UserService', () => {
6
+ beforeEach(() => TestBed.configureTestingModule({}));
7
+
8
+ it('should be created', () => {
9
+ const service: UserService = TestBed.get(UserService);
10
+ expect(service).toBeTruthy();
11
+ });
12
+ });
@@ -0,0 +1,140 @@
1
+ import { Inject, Injectable } from '@angular/core';
2
+ import { HttpClient } from '@angular/common/http';
3
+ import { Observable, ReplaySubject } from 'rxjs';
4
+ import { User as UserBase } from '../../db/Models/user';
5
+ import { User } from '../../models/user/user';
6
+ import { AppEvent } from '../../models/event/app-event';
7
+ import { AppEventTypeEnum } from '../../models/event/app-event-type.enum';
8
+ import { EventDispatcherService } from '../event/event-dispatcher.service';
9
+ import { JwtService } from '../auth/jwt.service';
10
+ import { map } from 'rxjs/operators';
11
+ import { plainToClass } from 'class-transformer';
12
+
13
+ /**
14
+ * Service to work with user
15
+ */
16
+ @Injectable({
17
+ providedIn: 'root'
18
+ })
19
+ export class UserService {
20
+ cache: User;
21
+ cacheSubject: ReplaySubject<User> = new ReplaySubject<User>(1);
22
+
23
+ constructor(
24
+ private http: HttpClient,
25
+ private jwtService: JwtService,
26
+ private eventDispatcherService: EventDispatcherService,
27
+ @Inject('environment') private environment: any
28
+ ) {
29
+ }
30
+
31
+ /**
32
+ * Get current user
33
+ */
34
+ get(): Observable<User> {
35
+ if (!this.cache) {
36
+ this.http.get(`${this.environment.apiV2}/users/current`)
37
+ .pipe(
38
+ map((userBase: UserBase) => {
39
+ return plainToClass(User, userBase);
40
+ }),
41
+ )
42
+ .subscribe((user: User) => {
43
+ localStorage.setItem('userId', user.id.toString());
44
+ // @TODO remove
45
+ localStorage.setItem('financialYear', user.financialYear.toString());
46
+ this.cache = user;
47
+ this.cacheSubject.next(this.cache);
48
+ });
49
+ }
50
+
51
+ return this.cacheSubject.asObservable();
52
+ }
53
+
54
+ /**
55
+ * Register new user
56
+ */
57
+ register(data: object): Observable<object> {
58
+ return this.http.post(`${this.environment.apiV2}/users/registration`, data);
59
+ }
60
+
61
+ /**
62
+ * Update user
63
+ */
64
+ update(user: User): Observable<void> {
65
+ return this.http.put(`${this.environment.apiV2}/users/${user.id}`, user)
66
+ .pipe(
67
+ map((userBase: UserBase) => {
68
+ this.cache = plainToClass(User, userBase);
69
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.USER_UPDATED, null));
70
+ this.cacheSubject.next(this.cache);
71
+ })
72
+ );
73
+ }
74
+
75
+ /**
76
+ * Change user password
77
+ */
78
+ changePassword(currentPassword: string, newPassword: string): Observable<object> {
79
+ return this.http.put(`${this.environment.apiV2}/users/current/password`, {currentPassword, newPassword});
80
+ }
81
+
82
+ /**
83
+ * Reset user password
84
+ */
85
+ resetPassword(email: string): Observable<object> {
86
+ return this.http.put(`${this.environment.apiV2}/users/reset-password`, {email});
87
+ }
88
+
89
+ /**
90
+ * Confirm registered user
91
+ */
92
+ confirm(verificationCode: string): Observable<object> {
93
+ return this.http.post(`${this.environment.apiV2}/users/confirmation`, {verificationCode});
94
+ }
95
+
96
+ /**
97
+ * Search existing user
98
+ */
99
+ search(email: string): Observable<User> {
100
+ return this.http.get(`${this.environment.apiV2}/users/search?email=${email}`)
101
+ .pipe(
102
+ map((userBase: UserBase) => {
103
+ return plainToClass(User, userBase);
104
+ })
105
+ );
106
+ }
107
+
108
+ /**
109
+ * Finish onboarding process
110
+ */
111
+ finishOnboarding(user: User): Observable<void> {
112
+ return this.http.put(`${this.environment.apiV2}/users/status`, user)
113
+ .pipe(
114
+ map(() => {
115
+ this.cache = user;
116
+ this.cacheSubject.next(this.cache);
117
+ })
118
+ );
119
+ }
120
+
121
+ /**
122
+ * Update user photo
123
+ */
124
+ updatePhoto(photo: FormData): Observable<void> {
125
+ return this.http.post(`${this.environment.apiV2}/users/photo?_method=PUT`, photo)
126
+ .pipe(
127
+ map((photoUrl: string) => {
128
+ this.cache = plainToClass(User, Object.assign(this.cache, {photo: photoUrl}));
129
+ this.cacheSubject.next(this.cache);
130
+ })
131
+ );
132
+ }
133
+
134
+ /**
135
+ * Run forecast update script on backend when user switched financial year
136
+ */
137
+ switchFinancialYear(): Observable<object> {
138
+ return this.http.get(`${this.environment.apiV2}/financial-year/switch`);
139
+ }
140
+ }
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { UserEventSettingService } from './user-event-setting.service';
4
+
5
+ describe('UserEventSettingService', () => {
6
+ let service: UserEventSettingService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(UserEventSettingService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
@@ -0,0 +1,60 @@
1
+ import { Inject, Injectable } from '@angular/core';
2
+ import { HttpClient } from '@angular/common/http';
3
+ import { UserEventSetting } from '../../models/user-event/user-event-setting';
4
+ import { UserEventSetting as UserEventSettingBase } from '../../db/Models/user-event-setting';
5
+ import { EventDispatcherService } from '../event/event-dispatcher.service';
6
+ import { BaseRestService } from '../base-rest.service';
7
+ import { forkJoin, Observable } from 'rxjs';
8
+ import { map } from 'rxjs/operators';
9
+ import { replace } from '../../functions/array';
10
+ import { classToPlain, plainToClass } from 'class-transformer';
11
+
12
+ @Injectable({
13
+ providedIn: 'root'
14
+ })
15
+ export class UserEventSettingService extends BaseRestService<UserEventSettingBase, UserEventSetting> {
16
+ modelClass: typeof UserEventSetting = UserEventSetting;
17
+ url: string = 'user-event-settings';
18
+ isHydra: boolean = true;
19
+
20
+ constructor(
21
+ protected http: HttpClient,
22
+ protected eventDispatcherService: EventDispatcherService,
23
+ @Inject('environment') protected environment: any
24
+ ) {
25
+ super(http, eventDispatcherService, environment);
26
+ }
27
+
28
+ /**
29
+ * Send batch to add/updated settings
30
+ */
31
+ saveBatch(settings: UserEventSetting[]): Observable<void> {
32
+ // batch with post/put requests based on setting id
33
+ const batch: Observable<object>[] = settings.map((setting: UserEventSetting) => {
34
+ setting.isUpdating = true;
35
+
36
+ if (setting.id) {
37
+ return this.http.put(`${this.environment.apiV2}/${this.url}/${setting.id}`, classToPlain(setting));
38
+ }
39
+
40
+ return this.http.post(`${this.environment.apiV2}/${this.url}`, classToPlain(setting));
41
+ });
42
+
43
+ return forkJoin(batch).pipe(
44
+ map((eventSettings: UserEventSetting[]) => {
45
+ eventSettings.forEach((eventSetting: UserEventSetting) => {
46
+ // get setting from cache by saved setting id
47
+ const cachedSetting: UserEventSetting = this.cache.find((setting: UserEventSetting) => setting.id === eventSetting.id);
48
+
49
+ if (cachedSetting) {
50
+ replace(this.cache, eventSetting);
51
+ } else {
52
+ this.cache.push(plainToClass(UserEventSetting, eventSetting));
53
+ }
54
+ });
55
+
56
+ this.updateCache();
57
+ })
58
+ );
59
+ }
60
+ }