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.
- package/.browserslistrc +16 -0
- package/karma.conf.js +44 -0
- package/ng-package.json +12 -0
- package/package.json +13 -12
- package/src/lib/collections/abstract.collection.ts +83 -0
- package/src/lib/collections/bank-account.collection.ts +171 -0
- package/src/lib/collections/bank-transaction.collection.ts +153 -0
- package/src/lib/collections/client-movement.collection.ts +42 -0
- package/src/lib/collections/client-portfolio-report.collection.ts +47 -0
- package/src/lib/collections/client.collection.ts +5 -0
- package/src/lib/collections/collection-dictionary.ts +112 -0
- package/src/lib/collections/depreciation-forecast.collection.ts +25 -0
- package/src/lib/collections/depreciation.collection.ts +113 -0
- package/src/lib/collections/employee.collection.ts +14 -0
- package/src/lib/collections/income-source.collection.ts +44 -0
- package/src/lib/collections/loan.collection.ts +22 -0
- package/src/lib/collections/logbook.collection.ts +129 -0
- package/src/lib/collections/message-document.collection.ts +16 -0
- package/src/lib/collections/message.collection.ts +27 -0
- package/src/lib/collections/property.collection.ts +88 -0
- package/src/lib/collections/service-price.collection.ts +13 -0
- package/src/lib/collections/service-subscription.collection.ts +20 -0
- package/src/lib/collections/tax-return-category-item.collection.ts +148 -0
- package/src/lib/collections/tax-review.collection.ts +64 -0
- package/src/lib/collections/transaction-allocation.collection.ts +54 -0
- package/src/lib/collections/transaction.collection.ts +170 -0
- package/src/lib/collections/user-event-setting.collection.ts +70 -0
- package/src/lib/db/Enums/address-type.enum.ts +4 -0
- package/src/lib/db/Enums/bank-account-status.enum.ts +4 -0
- package/src/lib/db/Enums/bank-account-type.enum.ts +10 -0
- package/src/lib/db/Enums/bank-connection-status.enum.ts +5 -0
- package/src/lib/db/Enums/bank-transaction-type.enum.ts +4 -0
- package/src/lib/db/Enums/chart-accounts-category.enum.ts +13 -0
- package/src/lib/db/Enums/chart-accounts-etp.enum.ts +7 -0
- package/src/lib/db/Enums/chart-accounts-heading-tax-deductible.enum.ts +6 -0
- package/src/lib/db/Enums/chart-accounts-heading-taxable.enum.ts +6 -0
- package/src/lib/db/Enums/chart-accounts-heading-vehicle-list.enum.ts +4 -0
- package/src/lib/db/Enums/chart-accounts-list.enum.ts +19 -0
- package/src/lib/db/Enums/chart-accounts-metadata-list.enum.ts +14 -0
- package/src/lib/db/Enums/chart-accounts-metadata-type.enum.ts +4 -0
- package/src/lib/db/Enums/chart-accounts-type.enum.ts +4 -0
- package/src/lib/db/Enums/chat-status.enum.ts +4 -0
- package/src/lib/db/Enums/client-details-medicare-exemption.enum.ts +5 -0
- package/src/lib/db/Enums/client-details-work-depreciation-calculation.enum.ts +4 -0
- package/src/lib/db/Enums/client-details-working-holiday-maker.enum.ts +5 -0
- package/src/lib/db/Enums/client-invite-status.enum.ts +4 -0
- package/src/lib/db/Enums/client-invite-type.enum.ts +4 -0
- package/src/lib/db/Enums/depreciation-calculation-percent.enum.ts +7 -0
- package/src/lib/db/Enums/depreciation-calculation.enum.ts +7 -0
- package/src/lib/db/Enums/depreciation-type.enum.ts +6 -0
- package/src/lib/db/Enums/depreciation-write-off-amount.enum.ts +4 -0
- package/src/lib/db/Enums/firm-type.enum.ts +4 -0
- package/src/lib/db/Enums/income-source-type-list-other.enum.ts +6 -0
- package/src/lib/db/Enums/income-source-type-list-salary.enum.ts +3 -0
- package/src/lib/db/Enums/income-source-type-list-work.enum.ts +8 -0
- package/src/lib/db/Enums/income-source-type.enum.ts +5 -0
- package/src/lib/db/Enums/invite-status.enum.ts +5 -0
- package/src/lib/db/Enums/loan-bank-type.enum.ts +10 -0
- package/src/lib/db/Enums/loan-frequency.enum.ts +6 -0
- package/src/lib/db/Enums/loan-interest-type.enum.ts +4 -0
- package/src/lib/db/Enums/loan-payout-type.enum.ts +4 -0
- package/src/lib/db/Enums/loan-repayment-frequency.enum.ts +5 -0
- package/src/lib/db/Enums/loan-repayment-type.enum.ts +4 -0
- package/src/lib/db/Enums/loan-type.enum.ts +12 -0
- package/src/lib/db/Enums/loan-vehicle-type.enum.ts +5 -0
- package/src/lib/db/Enums/phone-type.enum.ts +4 -0
- package/src/lib/db/Enums/property-depreciation-calculation.enum.ts +4 -0
- package/src/lib/db/Enums/property-owner-access.enum.ts +4 -0
- package/src/lib/db/Enums/property-owner-status.enum.ts +5 -0
- package/src/lib/db/Enums/registration-invite-status.enum.ts +4 -0
- package/src/lib/db/Enums/salary-forecast-frequency.enum.ts +6 -0
- package/src/lib/db/Enums/service-notification-status.enum.ts +5 -0
- package/src/lib/db/Enums/service-notification-type.enum.ts +4 -0
- package/src/lib/db/Enums/service-payment-status.enum.ts +4 -0
- package/src/lib/db/Enums/service-price-recurring-interval.enum.ts +6 -0
- package/src/lib/db/Enums/service-price-type.enum.ts +4 -0
- package/src/lib/db/Enums/service-subscription-status.enum.ts +8 -0
- package/src/lib/db/Enums/spare-document-spare-type.enum.ts +4 -0
- package/src/lib/db/Enums/tank-type.enum.ts +5 -0
- package/src/lib/db/Enums/tax-calculation-medicare-exemption.enum.ts +4 -0
- package/src/lib/db/Enums/tax-calculation-type.enum.ts +12 -0
- package/src/lib/db/Enums/tax-return-category-list.enum.ts +26 -0
- package/src/lib/db/Enums/tax-return-category-section.enum.ts +6 -0
- package/src/lib/db/Enums/tax-review-status.enum.ts +11 -0
- package/src/lib/db/Enums/tax-summary-list.enum.ts +15 -0
- package/src/lib/db/Enums/tax-summary-section.enum.ts +6 -0
- package/src/lib/db/Enums/tax-summary-tax-summary.enum.ts +15 -0
- package/src/lib/db/Enums/ticket-feedback.enum.ts +4 -0
- package/src/lib/db/Enums/ticket-status.enum.ts +7 -0
- package/src/lib/db/Enums/ticket-types.enum.ts +3 -0
- package/src/lib/db/Enums/transaction-operation.enum.ts +5 -0
- package/src/lib/db/Enums/transaction-source.enum.ts +4 -0
- package/src/lib/db/Enums/transaction-type.enum.ts +4 -0
- package/src/lib/db/Enums/user-event-status.enum.ts +6 -0
- package/src/lib/db/Enums/user-event-type-frequency.enum.ts +6 -0
- package/src/lib/db/Enums/user-event-type-reminder-type.enum.ts +6 -0
- package/src/lib/db/Enums/user-event-type-reminder.enum.ts +5 -0
- package/src/lib/db/Enums/user-event-type-type.enum.ts +33 -0
- package/src/lib/db/Enums/user-medicare-exemption.enum.ts +5 -0
- package/src/lib/db/Enums/user-roles.enum.ts +13 -0
- package/src/lib/db/Enums/user-status.enum.ts +6 -0
- package/src/lib/db/Enums/user-title.enum.ts +7 -0
- package/src/lib/db/Enums/user-work-depreciation-calculation.enum.ts +4 -0
- package/src/lib/db/Enums/user-working-holiday-maker.enum.ts +5 -0
- package/src/lib/db/Enums/vehicle-claim-method.enum.ts +4 -0
- package/src/lib/db/Enums/vehicle-logbook-purpose.enum.ts +4 -0
- package/src/lib/db/Models/address.ts +20 -0
- package/src/lib/db/Models/bank-account-balance.ts +13 -0
- package/src/lib/db/Models/bank-account-property.ts +9 -0
- package/src/lib/db/Models/bank-account.ts +34 -0
- package/src/lib/db/Models/bank-connection.ts +15 -0
- package/src/lib/db/Models/bank-provider-account.ts +13 -0
- package/src/lib/db/Models/bank-transaction-import.ts +12 -0
- package/src/lib/db/Models/bank-transaction-rule.ts +26 -0
- package/src/lib/db/Models/bank-transaction.ts +17 -0
- package/src/lib/db/Models/bank.ts +12 -0
- package/src/lib/db/Models/basiq-job.ts +9 -0
- package/src/lib/db/Models/borrowing-expense-loan.ts +15 -0
- package/src/lib/db/Models/borrowing-expense.ts +7 -0
- package/src/lib/db/Models/capital-cost-property.ts +14 -0
- package/src/lib/db/Models/capital-cost.ts +4 -0
- package/src/lib/db/Models/chart-accounts-depreciation.ts +11 -0
- package/src/lib/db/Models/chart-accounts-heading.ts +7 -0
- package/src/lib/db/Models/chart-accounts-metadata.ts +12 -0
- package/src/lib/db/Models/chart-accounts-value.ts +13 -0
- package/src/lib/db/Models/chart-accounts.ts +24 -0
- package/src/lib/db/Models/chat.ts +18 -0
- package/src/lib/db/Models/client-details.ts +30 -0
- package/src/lib/db/Models/client-invite.ts +17 -0
- package/src/lib/db/Models/client-movement.ts +13 -0
- package/src/lib/db/Models/country.ts +5 -0
- package/src/lib/db/Models/depreciation-capital-project.ts +14 -0
- package/src/lib/db/Models/depreciation-forecast.ts +19 -0
- package/src/lib/db/Models/depreciation-receipt.ts +12 -0
- package/src/lib/db/Models/depreciation.ts +43 -0
- package/src/lib/db/Models/document-base.ts +10 -0
- package/src/lib/db/Models/document-folder.ts +10 -0
- package/src/lib/db/Models/document.ts +12 -0
- package/src/lib/db/Models/employee-details.ts +8 -0
- package/src/lib/db/Models/employee-invite.ts +10 -0
- package/src/lib/db/Models/financial-data-system.ts +10 -0
- package/src/lib/db/Models/firm-invite.ts +15 -0
- package/src/lib/db/Models/firm.ts +29 -0
- package/src/lib/db/Models/income-source-forecast.ts +13 -0
- package/src/lib/db/Models/income-source-type.ts +9 -0
- package/src/lib/db/Models/income-source.ts +21 -0
- package/src/lib/db/Models/loan-payout.ts +13 -0
- package/src/lib/db/Models/loan.ts +34 -0
- package/src/lib/db/Models/message-document.ts +16 -0
- package/src/lib/db/Models/message.ts +16 -0
- package/src/lib/db/Models/occupation.ts +5 -0
- package/src/lib/db/Models/phone.ts +13 -0
- package/src/lib/db/Models/property-capital-cost.ts +14 -0
- package/src/lib/db/Models/property-category-movement.ts +18 -0
- package/src/lib/db/Models/property-category.ts +14 -0
- package/src/lib/db/Models/property-document.ts +14 -0
- package/src/lib/db/Models/property-forecast.ts +15 -0
- package/src/lib/db/Models/property-owner.ts +21 -0
- package/src/lib/db/Models/property-sold.ts +13 -0
- package/src/lib/db/Models/property-subscription.ts +10 -0
- package/src/lib/db/Models/property-valuation.ts +13 -0
- package/src/lib/db/Models/property.ts +42 -0
- package/src/lib/db/Models/registration-invite.ts +13 -0
- package/src/lib/db/Models/salary-forecast.ts +16 -0
- package/src/lib/db/Models/service-notification.ts +14 -0
- package/src/lib/db/Models/service-payment.ts +12 -0
- package/src/lib/db/Models/service-price.ts +16 -0
- package/src/lib/db/Models/service-product.ts +13 -0
- package/src/lib/db/Models/service-subscription-item.ts +10 -0
- package/src/lib/db/Models/service-subscription.ts +15 -0
- package/src/lib/db/Models/spare-document-category.ts +6 -0
- package/src/lib/db/Models/spare-document.ts +16 -0
- package/src/lib/db/Models/tax-calculation.ts +19 -0
- package/src/lib/db/Models/tax-return-category.ts +13 -0
- package/src/lib/db/Models/tax-return-item.ts +16 -0
- package/src/lib/db/Models/tax-return.ts +9 -0
- package/src/lib/db/Models/tax-review.ts +14 -0
- package/src/lib/db/Models/ticket.ts +20 -0
- package/src/lib/db/Models/transaction-allocation.ts +9 -0
- package/src/lib/db/Models/transaction-base.ts +33 -0
- package/src/lib/db/Models/transaction-metadata.ts +12 -0
- package/src/lib/db/Models/transaction-receipt.ts +12 -0
- package/src/lib/db/Models/transaction.ts +44 -0
- package/src/lib/db/Models/user-event-setting.ts +11 -0
- package/src/lib/db/Models/user-event-type.ts +16 -0
- package/src/lib/db/Models/user-event.ts +14 -0
- package/src/lib/db/Models/user.ts +52 -0
- package/src/lib/db/Models/vehicle-claim.ts +12 -0
- package/src/lib/db/Models/vehicle-logbook.ts +17 -0
- package/src/lib/db/Models/vehicle.ts +9 -0
- package/src/lib/functions/array/index.ts +3 -0
- package/src/lib/functions/array/replace.ts +5 -0
- package/src/lib/functions/array/sort-deep.ts +19 -0
- package/src/lib/functions/array/sort.ts +8 -0
- package/src/lib/functions/clone-deep.ts +4 -0
- package/src/lib/functions/create-date.ts +7 -0
- package/src/lib/functions/enum-to-list.ts +16 -0
- package/src/lib/functions/get-doc-icon.ts +21 -0
- package/src/lib/functions/mat-options-functions.ts +11 -0
- package/src/lib/functions/mat-sort-options.ts +9 -0
- package/src/lib/functions/round-to.ts +9 -0
- package/src/lib/functions/tax-review-filter-predicate.ts +11 -0
- package/src/lib/interfaces/asset-entity-type.enum.ts +10 -0
- package/src/lib/interfaces/asset-type.enum.ts +9 -0
- package/src/lib/interfaces/asset.interface.ts +18 -0
- package/src/lib/interfaces/chart-data.interface.ts +11 -0
- package/src/lib/interfaces/chart-serie.interface.ts +8 -0
- package/src/lib/interfaces/document.interface.ts +20 -0
- package/src/lib/interfaces/documentable.interface.ts +9 -0
- package/src/lib/interfaces/event-listener.interface.ts +9 -0
- package/src/lib/interfaces/income-source-forecast.interface.ts +7 -0
- package/src/lib/interfaces/option.interface.ts +4 -0
- package/src/lib/interfaces/photoable.ts +14 -0
- package/src/lib/interfaces/receipt.interface.ts +13 -0
- package/src/lib/interfaces/salary-forecast.interface.ts +17 -0
- package/src/lib/interfaces/tank.interface.ts +9 -0
- package/src/lib/models/address/address.ts +24 -0
- package/src/lib/models/address/country.ts +17 -0
- package/src/lib/models/bank/bank-account-chart-data.ts +42 -0
- package/src/lib/models/bank/bank-account-property.ts +8 -0
- package/src/lib/models/bank/bank-account-types.const.ts +15 -0
- package/src/lib/models/bank/bank-account.ts +136 -0
- package/src/lib/models/bank/bank-connection.ts +12 -0
- package/src/lib/models/bank/bank-transaction-chart-data.ts +132 -0
- package/src/lib/models/bank/bank-transaction-summary-fields.enum.ts +4 -0
- package/src/lib/models/bank/bank-transaction.ts +74 -0
- package/src/lib/models/bank/bank.ts +21 -0
- package/src/lib/models/bank/basiq-job.ts +4 -0
- package/src/lib/models/bank/basiq-token.ts +16 -0
- package/src/lib/models/bank/type-loan.const.ts +7 -0
- package/src/lib/models/borrowing-expense/borrowing-expense-loan.ts +4 -0
- package/src/lib/models/borrowing-expense/borrowing-expense.ts +4 -0
- package/src/lib/models/chart/chart-data.ts +13 -0
- package/src/lib/models/chart/chart-serie.ts +8 -0
- package/src/lib/models/chart-accounts/chart-accounts-categories.const.ts +85 -0
- package/src/lib/models/chart-accounts/chart-accounts-depreciation.ts +14 -0
- package/src/lib/models/chart-accounts/chart-accounts-heading.ts +6 -0
- package/src/lib/models/chart-accounts/chart-accounts-metadata.ts +15 -0
- package/src/lib/models/chart-accounts/chart-accounts-tax-labels.enum.ts +5 -0
- package/src/lib/models/chart-accounts/chart-accounts.ts +137 -0
- package/src/lib/models/chat/chat-view-type.enum.ts +4 -0
- package/src/lib/models/chat/chat.ts +23 -0
- package/src/lib/models/chat/message-document.ts +18 -0
- package/src/lib/models/chat/message.ts +40 -0
- package/src/lib/models/client/client-details.ts +4 -0
- package/src/lib/models/client/client-invite.ts +70 -0
- package/src/lib/models/client/client-movement.ts +25 -0
- package/src/lib/models/client/client-portfolio-chart-data.ts +65 -0
- package/src/lib/models/client/client-portfolio-report.ts +10 -0
- package/src/lib/models/depreciation/depreciation-capital-project.ts +10 -0
- package/src/lib/models/depreciation/depreciation-forecast.ts +31 -0
- package/src/lib/models/depreciation/depreciation-group-item.ts +20 -0
- package/src/lib/models/depreciation/depreciation-group.enum.ts +7 -0
- package/src/lib/models/depreciation/depreciation-group.ts +25 -0
- package/src/lib/models/depreciation/depreciation-groups.const.ts +35 -0
- package/src/lib/models/depreciation/depreciation-receipt.ts +9 -0
- package/src/lib/models/depreciation/depreciation.ts +174 -0
- package/src/lib/models/document/document-api-url-prefix.enum.ts +7 -0
- package/src/lib/models/document/document-file-types.const.ts +22 -0
- package/src/lib/models/document/document-folder.ts +11 -0
- package/src/lib/models/document/document.ts +29 -0
- package/src/lib/models/employee/employee-details.ts +8 -0
- package/src/lib/models/employee/employee-invite.ts +12 -0
- package/src/lib/models/endpoint/endpoint.ts +35 -0
- package/src/lib/models/endpoint/endpoints.const.ts +157 -0
- package/src/lib/models/event/app-event-type.enum.ts +37 -0
- package/src/lib/models/event/app-event.ts +9 -0
- package/src/lib/models/file/icons-file.enum.ts +5 -0
- package/src/lib/models/financial-year/financial-year.ts +57 -0
- package/src/lib/models/financial-year/month-name-short.enum.ts +19 -0
- package/src/lib/models/financial-year/month-number.enum.ts +19 -0
- package/src/lib/models/financial-year/months.const.ts +1 -0
- package/src/lib/models/firm/firm.ts +31 -0
- package/src/lib/models/income-position/income-position.ts +13 -0
- package/src/lib/models/income-source/income-source-chart-data.ts +57 -0
- package/src/lib/models/income-source/income-source-forecast.ts +35 -0
- package/src/lib/models/income-source/income-source-type.ts +30 -0
- package/src/lib/models/income-source/income-source.ts +57 -0
- package/src/lib/models/income-source/salary-forecast.ts +23 -0
- package/src/lib/models/loan/loan-max-number-of-payments.enum.ts +8 -0
- package/src/lib/models/loan/loan-payment.ts +17 -0
- package/src/lib/models/loan/loan-payout.ts +13 -0
- package/src/lib/models/loan/loan.ts +38 -0
- package/src/lib/models/logbook/default-vehicle-expense.ts +20 -0
- package/src/lib/models/logbook/logbook-period.ts +12 -0
- package/src/lib/models/logbook/logbook-purpose-options.const.ts +6 -0
- package/src/lib/models/logbook/vehicle-claim.ts +27 -0
- package/src/lib/models/logbook/vehicle-logbook.ts +16 -0
- package/src/lib/models/logbook/vehicle.ts +46 -0
- package/src/lib/models/notification/notification-event-types.const.ts +43 -0
- package/src/lib/models/notification/notification.ts +66 -0
- package/src/lib/models/phone/phone.ts +10 -0
- package/src/lib/models/property/calculation-form-item.ts +24 -0
- package/src/lib/models/property/calculation-form-type.enum.ts +7 -0
- package/src/lib/models/property/capital-costs-itmes.const.ts +57 -0
- package/src/lib/models/property/corelogic-suggestion.ts +18 -0
- package/src/lib/models/property/ownership-filter-options.enum.ts +8 -0
- package/src/lib/models/property/property-capital-cost.ts +4 -0
- package/src/lib/models/property/property-category-movement.ts +18 -0
- package/src/lib/models/property/property-category.ts +9 -0
- package/src/lib/models/property/property-document.ts +21 -0
- package/src/lib/models/property/property-equity-chart-data.ts +188 -0
- package/src/lib/models/property/property-equity-chart-item.ts +35 -0
- package/src/lib/models/property/property-equity-chart-type.enum.ts +4 -0
- package/src/lib/models/property/property-forecast.ts +55 -0
- package/src/lib/models/property/property-owner.ts +50 -0
- package/src/lib/models/property/property-sold.ts +10 -0
- package/src/lib/models/property/property-subscription.ts +11 -0
- package/src/lib/models/property/property-valuation.ts +24 -0
- package/src/lib/models/property/property.ts +157 -0
- package/src/lib/models/registration-invite/registration-invite.ts +12 -0
- package/src/lib/models/service-subscription/module-url-list.const.ts +11 -0
- package/src/lib/models/service-subscription/service-payment.ts +8 -0
- package/src/lib/models/service-subscription/service-price.ts +8 -0
- package/src/lib/models/service-subscription/service-product.ts +11 -0
- package/src/lib/models/service-subscription/service-subscription-item.ts +12 -0
- package/src/lib/models/service-subscription/service-subscription.ts +151 -0
- package/src/lib/models/service-subscription/subscription-description.const.ts +8 -0
- package/src/lib/models/service-subscription/subscription-title.const.ts +8 -0
- package/src/lib/models/service-subscription/subscription-type.enum.ts +6 -0
- package/src/lib/models/tax-review/tax-review.ts +96 -0
- package/src/lib/models/tax-summary/tax-return-category-item-details.ts +14 -0
- package/src/lib/models/tax-summary/tax-return-category-item.ts +22 -0
- package/src/lib/models/tax-summary/tax-summary-section.ts +32 -0
- package/src/lib/models/tax-summary/tax-summary-type.enum.ts +7 -0
- package/src/lib/models/tax-summary/tax-summary.ts +79 -0
- package/src/lib/models/transaction/income-amount-type.enum.ts +7 -0
- package/src/lib/models/transaction/transaction-allocation.ts +20 -0
- package/src/lib/models/transaction/transaction-metadata.ts +8 -0
- package/src/lib/models/transaction/transaction-receipt.ts +9 -0
- package/src/lib/models/transaction/transaction.ts +241 -0
- package/src/lib/models/user/my-account-history-initiated-by.enum.ts +4 -0
- package/src/lib/models/user/my-account-history-status.enum.ts +4 -0
- package/src/lib/models/user/my-account-history-type.enum.ts +5 -0
- package/src/lib/models/user/my-account-history.ts +12 -0
- package/src/lib/models/user/occupation.ts +4 -0
- package/src/lib/models/user/user-roles.const.ts +13 -0
- package/src/lib/models/user/user-to-register.ts +7 -0
- package/src/lib/models/user/user-work-position.const.ts +7 -0
- package/src/lib/models/user/user.ts +160 -0
- package/src/lib/models/user-event/user-event-category.enum.ts +9 -0
- package/src/lib/models/user-event/user-event-category.ts +9 -0
- package/src/lib/models/user-event/user-event-setting-field.enum.ts +8 -0
- package/src/lib/models/user-event/user-event-setting.ts +11 -0
- package/src/lib/models/user-event/user-event-type.ts +22 -0
- package/src/lib/services/address/address.service.spec.ts +12 -0
- package/src/lib/services/address/address.service.ts +36 -0
- package/src/lib/services/asset/assets.service.spec.ts +12 -0
- package/src/lib/services/asset/assets.service.ts +51 -0
- package/src/lib/services/auth/auth.service.ts +48 -0
- package/src/lib/services/auth/jwt.service.ts +37 -0
- package/src/lib/services/bank/bank-account-calculation.service.spec.ts +16 -0
- package/src/lib/services/bank/bank-account-calculation.service.ts +38 -0
- package/src/lib/services/bank/bank-account.service.spec.ts +12 -0
- package/src/lib/services/bank/bank-account.service.ts +120 -0
- package/src/lib/services/bank/bank-connection.service.spec.ts +12 -0
- package/src/lib/services/bank/bank-connection.service.ts +42 -0
- package/src/lib/services/bank/bank-transaction-calculation.service.spec.ts +16 -0
- package/src/lib/services/bank/bank-transaction-calculation.service.ts +71 -0
- package/src/lib/services/bank/bank-transaction.service.spec.ts +12 -0
- package/src/lib/services/bank/bank-transaction.service.ts +97 -0
- package/src/lib/services/bank/bank.service.spec.ts +12 -0
- package/src/lib/services/bank/bank.service.ts +16 -0
- package/src/lib/services/bank/basiq.service.spec.ts +12 -0
- package/src/lib/services/bank/basiq.service.ts +103 -0
- package/src/lib/services/base-rest.service.spec.ts +13 -0
- package/src/lib/services/base-rest.service.ts +229 -0
- package/src/lib/services/borrowing-expense/borrowing-expense.service.spec.ts +12 -0
- package/src/lib/services/borrowing-expense/borrowing-expense.service.ts +82 -0
- package/src/lib/services/chart-accounts/chart-accounts-depreciations.service.spec.ts +16 -0
- package/src/lib/services/chart-accounts/chart-accounts-depreciations.service.ts +34 -0
- package/src/lib/services/chart-accounts/chart-accounts.service.spec.ts +12 -0
- package/src/lib/services/chart-accounts/chart-accounts.service.ts +101 -0
- package/src/lib/services/chat/chat.service.spec.ts +16 -0
- package/src/lib/services/chat/chat.service.ts +79 -0
- package/src/lib/services/chat/message-document.service.spec.ts +16 -0
- package/src/lib/services/chat/message-document.service.ts +133 -0
- package/src/lib/services/chat/message.service.spec.ts +16 -0
- package/src/lib/services/chat/message.service.ts +61 -0
- package/src/lib/services/client/client-invite.service.spec.ts +16 -0
- package/src/lib/services/client/client-invite.service.ts +111 -0
- package/src/lib/services/client/client-movement.service.spec.ts +16 -0
- package/src/lib/services/client/client-movement.service.ts +114 -0
- package/src/lib/services/client/client-portfolio-report.service.spec.ts +16 -0
- package/src/lib/services/client/client-portfolio-report.service.ts +34 -0
- package/src/lib/services/depreciation/capital-project.service.spec.ts +16 -0
- package/src/lib/services/depreciation/capital-project.service.ts +69 -0
- package/src/lib/services/depreciation/depreciation.service.spec.ts +12 -0
- package/src/lib/services/depreciation/depreciation.service.ts +171 -0
- package/src/lib/services/document/document-folder.service.spec.ts +16 -0
- package/src/lib/services/document/document-folder.service.ts +95 -0
- package/src/lib/services/employee/employee-invite.service.spec.ts +16 -0
- package/src/lib/services/employee/employee-invite.service.ts +53 -0
- package/src/lib/services/employee/employee.service.spec.ts +16 -0
- package/src/lib/services/employee/employee.service.ts +35 -0
- package/src/lib/services/event/event-dispatcher.service.spec.ts +16 -0
- package/src/lib/services/event/event-dispatcher.service.ts +29 -0
- package/src/lib/services/event/sse.service.spec.ts +16 -0
- package/src/lib/services/event/sse.service.ts +42 -0
- package/src/lib/services/firm/firm.service.spec.ts +16 -0
- package/src/lib/services/firm/firm.service.ts +93 -0
- package/src/lib/services/header-title/header-title.service.spec.ts +12 -0
- package/src/lib/services/header-title/header-title.service.ts +31 -0
- package/src/lib/services/income-source/income-source-forecast.service.spec.ts +16 -0
- package/src/lib/services/income-source/income-source-forecast.service.ts +91 -0
- package/src/lib/services/income-source/income-source.service.spec.ts +12 -0
- package/src/lib/services/income-source/income-source.service.ts +127 -0
- package/src/lib/services/income-source/salary-forecast.service.spec.ts +16 -0
- package/src/lib/services/income-source/salary-forecast.service.ts +92 -0
- package/src/lib/services/intercom/intercom.service.spec.ts +16 -0
- package/src/lib/services/intercom/intercom.service.ts +37 -0
- package/src/lib/services/loan/loan.service.spec.ts +12 -0
- package/src/lib/services/loan/loan.service.ts +166 -0
- package/src/lib/services/notification/notification.service.spec.ts +12 -0
- package/src/lib/services/notification/notification.service.ts +60 -0
- package/src/lib/services/preloader/preloader.service.spec.ts +16 -0
- package/src/lib/services/preloader/preloader.service.ts +28 -0
- package/src/lib/services/property/corelogic.service.spec.ts +12 -0
- package/src/lib/services/property/corelogic.service.ts +47 -0
- package/src/lib/services/property/property-calculation.service.spec.ts +16 -0
- package/src/lib/services/property/property-calculation.service.ts +166 -0
- package/src/lib/services/property/property-capital-cost.service.ts +42 -0
- package/src/lib/services/property/property-category.service.spec.ts +16 -0
- package/src/lib/services/property/property-category.service.ts +15 -0
- package/src/lib/services/property/property-document.service.spec.ts +16 -0
- package/src/lib/services/property/property-document.service.ts +74 -0
- package/src/lib/services/property/property-owner.service.spec.ts +12 -0
- package/src/lib/services/property/property-owner.service.ts +134 -0
- package/src/lib/services/property/property-sold.service.spec.ts +16 -0
- package/src/lib/services/property/property-sold.service.ts +15 -0
- package/src/lib/services/property/property.service.spec.ts +12 -0
- package/src/lib/services/property/property.service.ts +136 -0
- package/src/lib/services/subscription/subscription.service.spec.ts +12 -0
- package/src/lib/services/subscription/subscription.service.ts +153 -0
- package/src/lib/services/tax-review/tax-review-history.service.spec.ts +16 -0
- package/src/lib/services/tax-review/tax-review-history.service.ts +35 -0
- package/src/lib/services/tax-review/tax-review.service.spec.ts +16 -0
- package/src/lib/services/tax-review/tax-review.service.ts +114 -0
- package/src/lib/services/tax-summary/tax-summary.service.ts +70 -0
- package/src/lib/services/transaction/transaction-allocation.service.spec.ts +12 -0
- package/src/lib/services/transaction/transaction-allocation.service.ts +92 -0
- package/src/lib/services/transaction/transaction-calculation.service.spec.ts +16 -0
- package/src/lib/services/transaction/transaction-calculation.service.ts +50 -0
- package/src/lib/services/transaction/transaction.service.spec.ts +12 -0
- package/src/lib/services/transaction/transaction.service.ts +374 -0
- package/src/lib/services/user/occupation.service.spec.ts +12 -0
- package/src/lib/services/user/occupation.service.ts +42 -0
- package/src/lib/services/user/user-switcher.service.ts +34 -0
- package/src/lib/services/user/user.service.spec.ts +12 -0
- package/src/lib/services/user/user.service.ts +140 -0
- package/src/lib/services/user-event/user-event-setting.service.spec.ts +16 -0
- package/src/lib/services/user-event/user-event-setting.service.ts +60 -0
- package/src/lib/services/user-event/user-event-type.service.spec.ts +16 -0
- package/src/lib/services/user-event/user-event-type.service.ts +24 -0
- package/src/lib/services/work/work-tank.service.spec.ts +12 -0
- package/src/lib/services/work/work-tank.service.ts +277 -0
- package/src/lib/tt-core.module.ts +22 -0
- package/src/lib/tt-core.service.spec.ts +16 -0
- package/src/lib/tt-core.service.ts +17 -0
- package/src/public-api.ts +425 -0
- package/src/test.ts +27 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/bundles/taxtank-core.umd.js +0 -97
- package/bundles/taxtank-core.umd.js.map +0 -1
- package/esm2015/lib/tt-core.module.js +0 -33
- package/esm2015/lib/tt-core.service.js +0 -23
- package/esm2015/public-api.js +0 -6
- package/esm2015/taxtank-core.js +0 -5
- package/fesm2015/taxtank-core.js +0 -64
- package/fesm2015/taxtank-core.js.map +0 -1
- package/lib/tt-core.module.d.ts +0 -9
- package/lib/tt-core.service.d.ts +0 -8
- package/public-api.d.ts +0 -2
- package/taxtank-core.d.ts +0 -5
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Inject, Injectable } from '@angular/core';
|
|
2
|
+
import { BankTransaction as BankTransactionBase } from '../../db/Models/bank-transaction';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { map } from 'rxjs/operators';
|
|
5
|
+
import { BaseRestService } from '../base-rest.service';
|
|
6
|
+
import { plainToClass } from 'class-transformer';
|
|
7
|
+
import { HttpClient } from '@angular/common/http';
|
|
8
|
+
import { UserEventTypeTypeEnum } from '../../db/Enums/user-event-type-type.enum';
|
|
9
|
+
import { BankTransaction } from '../../models/bank/bank-transaction';
|
|
10
|
+
import { EventDispatcherService } from '../event/event-dispatcher.service';
|
|
11
|
+
import { FinancialYear } from '../../models/financial-year/financial-year';
|
|
12
|
+
import { AppEventTypeEnum } from '../../models/event/app-event-type.enum';
|
|
13
|
+
import { Notification } from '../../models/notification/notification';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Service for bank transactions business logic
|
|
17
|
+
*/
|
|
18
|
+
@Injectable({
|
|
19
|
+
providedIn: 'root'
|
|
20
|
+
})
|
|
21
|
+
export class BankTransactionService extends BaseRestService<BankTransactionBase, BankTransaction> {
|
|
22
|
+
// url part for BankTransaction API
|
|
23
|
+
url: string = 'bank-transactions';
|
|
24
|
+
modelClass = BankTransaction;
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
protected http: HttpClient,
|
|
28
|
+
protected eventDispatcherService: EventDispatcherService,
|
|
29
|
+
@Inject('environment') protected environment: any
|
|
30
|
+
) {
|
|
31
|
+
super(http, eventDispatcherService, environment);
|
|
32
|
+
this.listenEvents();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private listenEvents(): void {
|
|
36
|
+
this.listenBankTransactionsImport();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* get list of bank transactions for passed bank account id
|
|
41
|
+
* @param bankAccountId Id of bank account we search bank transactions for
|
|
42
|
+
*/
|
|
43
|
+
getByBankAccountId(bankAccountId: number): Observable<BankTransaction[]> {
|
|
44
|
+
return this.get()
|
|
45
|
+
.pipe(
|
|
46
|
+
map((bankTransactions: BankTransaction[]) => {
|
|
47
|
+
return bankTransactions.filter((bankTransaction: BankTransaction) => bankTransaction.bankAccount.id === bankAccountId);
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get list of bank transactions for provided financial year
|
|
54
|
+
* @TODO VIK/Alex: consider to use one endpoint to get bank transactions for 2 fin years
|
|
55
|
+
*/
|
|
56
|
+
getTransactionsByYear(finYear: number): Observable<BankTransaction[]> {
|
|
57
|
+
return this.http.get(`${this.environment.apiV2}/bank-transactions?financialYear=${finYear}`)
|
|
58
|
+
.pipe(
|
|
59
|
+
map((bankTransactionsBase: BankTransactionBase[]) => {
|
|
60
|
+
return bankTransactionsBase.map((bankTransaction: BankTransaction) => plainToClass(BankTransaction, bankTransaction));
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* import bank transactions from csv file
|
|
67
|
+
* @param bankAccountId Bank account id we import bank transactions for
|
|
68
|
+
* @param file File with bank transactions for import
|
|
69
|
+
*/
|
|
70
|
+
import(bankAccountId: number, file: File): Observable<BankTransaction[]> {
|
|
71
|
+
const formData: FormData = new FormData();
|
|
72
|
+
formData.append('file', file);
|
|
73
|
+
|
|
74
|
+
return this.http.post(`${this.environment.apiV2}/bank-accounts/${bankAccountId}/bank-transaction-imports`, formData)
|
|
75
|
+
.pipe(
|
|
76
|
+
map((response: BankTransactionBase[]) => {
|
|
77
|
+
const newBankTransactions: BankTransaction[] = response.map((bankTransaction: BankTransactionBase) => plainToClass(BankTransaction, bankTransaction));
|
|
78
|
+
// push new items to cache only if we already have cache. Otherwise cache will contain only new items.
|
|
79
|
+
if (this.cache) {
|
|
80
|
+
// just current year's transactions should be added
|
|
81
|
+
this.cache.push(...newBankTransactions.filter((bt: BankTransaction) => new FinancialYear().includes(bt.date)));
|
|
82
|
+
this.updateCache();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return newBankTransactions;
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private listenBankTransactionsImport(): void {
|
|
91
|
+
this.eventDispatcherService.on(AppEventTypeEnum.NOTIFICATION_ADDED).subscribe((notification: Notification) => {
|
|
92
|
+
if (!notification.isRead && notification.eventType === UserEventTypeTypeEnum.BASIQ_FIRST_IMPORT_COMPLETE) {
|
|
93
|
+
this.resetCache();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { BankService } from './bank.service';
|
|
4
|
+
|
|
5
|
+
describe('BankService', () => {
|
|
6
|
+
beforeEach(() => TestBed.configureTestingModule({}));
|
|
7
|
+
|
|
8
|
+
it('should be created', () => {
|
|
9
|
+
const service: BankService = TestBed.get(BankService);
|
|
10
|
+
expect(service).toBeTruthy();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { Bank as BankBase } from '../../db/Models/bank';
|
|
3
|
+
import { Bank } from '../../models/bank/bank';
|
|
4
|
+
import { BaseRestService } from '../base-rest.service';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Service that handling banks logic
|
|
8
|
+
*/
|
|
9
|
+
@Injectable({
|
|
10
|
+
providedIn: 'root'
|
|
11
|
+
})
|
|
12
|
+
export class BankService extends BaseRestService<BankBase, Bank> {
|
|
13
|
+
modelClass: typeof Bank = Bank;
|
|
14
|
+
url: string = 'banks';
|
|
15
|
+
isHydra: boolean = true;
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { BasiqService } from './basiq.service';
|
|
4
|
+
|
|
5
|
+
describe('BasiqService', () => {
|
|
6
|
+
beforeEach(() => TestBed.configureTestingModule({}));
|
|
7
|
+
|
|
8
|
+
it('should be created', () => {
|
|
9
|
+
const service: BasiqService = TestBed.get(BasiqService);
|
|
10
|
+
expect(service).toBeTruthy();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Inject, Injectable } from '@angular/core';
|
|
2
|
+
import { HttpClient } from '@angular/common/http';
|
|
3
|
+
import { Observable, ReplaySubject } from 'rxjs';
|
|
4
|
+
import { map } from 'rxjs/operators';
|
|
5
|
+
import { BankAccount as BankAccountBase } from '../../db/Models/bank-account';
|
|
6
|
+
import { UserEventTypeTypeEnum } from '../../db/Enums/user-event-type-type.enum';
|
|
7
|
+
import { BaseRestService } from '../base-rest.service';
|
|
8
|
+
import { BankAccount } from '../../models/bank/bank-account';
|
|
9
|
+
import { BasiqToken } from '../../models/bank/basiq-token';
|
|
10
|
+
import { EventDispatcherService } from '../event/event-dispatcher.service';
|
|
11
|
+
import { AppEventTypeEnum } from '../../models/event/app-event-type.enum';
|
|
12
|
+
import { BankConnection } from '../../models/bank/bank-connection';
|
|
13
|
+
import { Notification } from '../../models/notification/notification';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* basiq is a middleman between bank and user
|
|
17
|
+
* service is responsible for fetching bank related information
|
|
18
|
+
*/
|
|
19
|
+
@Injectable({
|
|
20
|
+
providedIn: 'root'
|
|
21
|
+
})
|
|
22
|
+
export class BasiqService extends BaseRestService<BankAccountBase, BankAccount> {
|
|
23
|
+
token: BasiqToken;
|
|
24
|
+
tokenSubject: ReplaySubject<BasiqToken> = new ReplaySubject<BasiqToken>();
|
|
25
|
+
url: string = 'basiq/accounts';
|
|
26
|
+
modelClass = BankAccount;
|
|
27
|
+
|
|
28
|
+
constructor(
|
|
29
|
+
protected http: HttpClient,
|
|
30
|
+
protected eventDispatcherService: EventDispatcherService,
|
|
31
|
+
@Inject('environment') protected environment: any
|
|
32
|
+
) {
|
|
33
|
+
super(http, eventDispatcherService, environment);
|
|
34
|
+
this.listenEvents();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Listen events from Event Dispatcher service
|
|
39
|
+
*/
|
|
40
|
+
listenEvents(): void {
|
|
41
|
+
this.listenToBankConnectionAdded();
|
|
42
|
+
this.listenNotifications();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* access token to use basiq connect ui iframe
|
|
47
|
+
*/
|
|
48
|
+
getToken(): Observable<BasiqToken> {
|
|
49
|
+
if (!this.token || this.token.isExpired()) {
|
|
50
|
+
this.http.get(`${this.environment.apiV2}/basiq/tokens`)
|
|
51
|
+
.pipe(
|
|
52
|
+
map((response: object) => {
|
|
53
|
+
const now: number = new Date().getTime();
|
|
54
|
+
|
|
55
|
+
return new BasiqToken(response['access_token'], new Date(now + response['expires_in'] * 1000));
|
|
56
|
+
})
|
|
57
|
+
)
|
|
58
|
+
.subscribe((token: BasiqToken) => {
|
|
59
|
+
this.tokenSubject.next(token);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return this.tokenSubject.asObservable();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getConnections(): Observable<BankConnection[]> {
|
|
67
|
+
return this.get().pipe(
|
|
68
|
+
map((bankAccounts: BankAccount[]) => {
|
|
69
|
+
// get all connections
|
|
70
|
+
const connections: BankConnection[] = bankAccounts.map((bankAccount: BankAccount) => {
|
|
71
|
+
return bankAccount.bankConnection;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// return without duplicates
|
|
75
|
+
return [...new Map(connections.map((connection: BankConnection) => [connection.id, connection])).values()];
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Listen to EventDispatcherService event related to added Bank connection
|
|
82
|
+
*/
|
|
83
|
+
private listenToBankConnectionAdded(): void {
|
|
84
|
+
this.eventDispatcherService.on(AppEventTypeEnum.BANK_CONNECTION_ADDED).subscribe(() => {
|
|
85
|
+
this.fetch().subscribe((bankAccounts: BankAccount[]) => {
|
|
86
|
+
this.cache = bankAccounts;
|
|
87
|
+
this.updateCache();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* listen to notifications to update basiq accounts list
|
|
94
|
+
*/
|
|
95
|
+
private listenNotifications(): void {
|
|
96
|
+
this.eventDispatcherService.on(AppEventTypeEnum.NOTIFICATION_ADDED).subscribe((notification: Notification): void => {
|
|
97
|
+
if (!notification.isRead && notification.eventType === UserEventTypeTypeEnum.BASIQ_NEW_ACCOUNTS) {
|
|
98
|
+
this.resetCache();
|
|
99
|
+
this.get().subscribe();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @Todo fix tests
|
|
2
|
+
// import { TestBed } from '@angular/core/testing';
|
|
3
|
+
//
|
|
4
|
+
// import { BaseRestService } from './base-rest.service';
|
|
5
|
+
//
|
|
6
|
+
// describe('BaseService', () => {
|
|
7
|
+
// beforeEach(() => TestBed.configureTestingModule({}));
|
|
8
|
+
//
|
|
9
|
+
// it('should be created', () => {
|
|
10
|
+
// const service: BaseRestService = TestBed.get(BaseRestService);
|
|
11
|
+
// expect(service).toBeTruthy();
|
|
12
|
+
// });
|
|
13
|
+
// });
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { Inject, Injectable } from '@angular/core';
|
|
2
|
+
import { Observable, ReplaySubject } from 'rxjs';
|
|
3
|
+
import { map } from 'rxjs/operators';
|
|
4
|
+
import { replace } from '../functions/array';
|
|
5
|
+
import { HttpClient } from '@angular/common/http';
|
|
6
|
+
import { EventDispatcherService } from './event/event-dispatcher.service';
|
|
7
|
+
import { classToPlain, plainToClass } from 'class-transformer';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Abstract base service that implements common services functionality
|
|
11
|
+
* and describe abstract methods/properties that have to be implemented in child services
|
|
12
|
+
* Model - entity service is working with
|
|
13
|
+
* BaseModel - base entity model that extends by Model
|
|
14
|
+
*/
|
|
15
|
+
@Injectable({
|
|
16
|
+
providedIn: 'root'
|
|
17
|
+
})
|
|
18
|
+
export abstract class BaseRestService<BaseModel, Model extends BaseModel> {
|
|
19
|
+
// url part for service entity API. Have to be defined in extended classes
|
|
20
|
+
abstract url: string;
|
|
21
|
+
// Model class for instances creating
|
|
22
|
+
abstract modelClass;
|
|
23
|
+
// @TODO Make cache Readonly
|
|
24
|
+
// cached array of service class instances
|
|
25
|
+
protected cache: Model[];
|
|
26
|
+
// subject for service cache
|
|
27
|
+
protected cacheSubject: ReplaySubject<Model[]> = new ReplaySubject<Model[]>(1);
|
|
28
|
+
// flag for work with API platform
|
|
29
|
+
protected isHydra: boolean;
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
protected http: HttpClient,
|
|
33
|
+
protected eventDispatcherService: EventDispatcherService,
|
|
34
|
+
@Inject('environment') protected environment: any
|
|
35
|
+
) {
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* get cached list of all instances
|
|
40
|
+
*/
|
|
41
|
+
get(): Observable<Model[]> {
|
|
42
|
+
if (!this.cache) {
|
|
43
|
+
this.fetch().subscribe();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return this.cacheSubject.asObservable();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* get instance by id from cache
|
|
51
|
+
* @param id ID of required item
|
|
52
|
+
*/
|
|
53
|
+
getById(id: number): Observable<Model> {
|
|
54
|
+
return this.get()
|
|
55
|
+
.pipe(
|
|
56
|
+
map((items: Model[]) => {
|
|
57
|
+
return items.find((item: Model) => item['id'] === id);
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* get list of items filtered by id.
|
|
64
|
+
* @param models Array of objects contains required items ids
|
|
65
|
+
*/
|
|
66
|
+
getByIds(models: Model[]): Observable<Model[]> {
|
|
67
|
+
const idsArray: number[] = models.map((model: Model) => model['id']);
|
|
68
|
+
|
|
69
|
+
return this.get()
|
|
70
|
+
.pipe(
|
|
71
|
+
map((items: Model[]) => {
|
|
72
|
+
return items.filter((item: Model) => idsArray.includes(item['id']));
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* add new instance and update cache
|
|
79
|
+
* @TODO rename to post
|
|
80
|
+
*/
|
|
81
|
+
add(model: Model, shouldUpdateCache: boolean = true): Observable<Model> {
|
|
82
|
+
return this.http.post(`${this.environment.apiV2}/${this.url}`, classToPlain(model))
|
|
83
|
+
.pipe(
|
|
84
|
+
map((newItem: BaseModel) => {
|
|
85
|
+
if (!shouldUpdateCache) {
|
|
86
|
+
return null
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const newInstance: Model = this.createModelInstance(this.modelClass, newItem);
|
|
90
|
+
if (this.cache) {
|
|
91
|
+
this.cache.push(newInstance);
|
|
92
|
+
this.updateCache();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return newInstance;
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Add several new items
|
|
102
|
+
* @param models Array of new items for saving
|
|
103
|
+
* @param queryParams query parameters for request
|
|
104
|
+
* @TODO rename to postBatch
|
|
105
|
+
*/
|
|
106
|
+
addBatch(models: Model[], queryParams: object = {}): Observable<Model[]> {
|
|
107
|
+
return this.http.post(`${this.environment.apiV2}/${this.url}`, classToPlain(models), queryParams)
|
|
108
|
+
.pipe(
|
|
109
|
+
map((newItems: BaseModel[]) => {
|
|
110
|
+
const newInstances: Model[] = newItems.map((item: BaseModel) => this.createModelInstance(this.modelClass, item));
|
|
111
|
+
if (this.cache) {
|
|
112
|
+
this.cache.push(...newInstances);
|
|
113
|
+
this.updateCache();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return newInstances;
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Update item
|
|
123
|
+
* @param model Existing instance for updating
|
|
124
|
+
* @param queryParams query parameters for request
|
|
125
|
+
* @TODO rename to put
|
|
126
|
+
*/
|
|
127
|
+
update(model: Model, queryParams: object = {}): Observable<Model> {
|
|
128
|
+
return this.http.put(`${this.environment.apiV2}/${this.url}/${model['id']}`, classToPlain(model), queryParams)
|
|
129
|
+
.pipe(
|
|
130
|
+
map((updatedItem: BaseModel) => {
|
|
131
|
+
const updatedInstance: Model = this.createModelInstance(this.modelClass, updatedItem);
|
|
132
|
+
replace(this.cache, updatedInstance);
|
|
133
|
+
this.updateCache();
|
|
134
|
+
|
|
135
|
+
return updatedInstance;
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Update several items
|
|
142
|
+
* @param models Array of items for updating
|
|
143
|
+
* @param queryParams query parameters for request
|
|
144
|
+
* TODO rename to putBatch
|
|
145
|
+
*/
|
|
146
|
+
updateBatch(models: Model[], queryParams: object = {}): Observable<Model[]> {
|
|
147
|
+
return this.http.put(`${this.environment.apiV2}/${this.url}`, classToPlain(models), queryParams)
|
|
148
|
+
.pipe(
|
|
149
|
+
map((updatedItems: BaseModel[]) => {
|
|
150
|
+
const updatedInstances: Model[] = updatedItems.map((item: BaseModel) => this.createModelInstance(this.modelClass, item));
|
|
151
|
+
updatedInstances.forEach((instance: Model) => {
|
|
152
|
+
replace(this.cache, instance);
|
|
153
|
+
});
|
|
154
|
+
this.updateCache();
|
|
155
|
+
return updatedInstances;
|
|
156
|
+
})
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* delete instance of class
|
|
162
|
+
* @param model Class instance for deleting
|
|
163
|
+
*/
|
|
164
|
+
delete(model: Model): Observable<void> {
|
|
165
|
+
return this.http.delete(`${this.environment.apiV2}/${this.url}/${model['id']}`)
|
|
166
|
+
.pipe(
|
|
167
|
+
map(() => {
|
|
168
|
+
this.cache = this.cache.filter((item: Model) => item['id'] !== model['id']);
|
|
169
|
+
this.updateCache();
|
|
170
|
+
})
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* delete multiple instances of class
|
|
176
|
+
* @param models Class instances array for deleting
|
|
177
|
+
*/
|
|
178
|
+
deleteBatch(models: Model[]): Observable<void> {
|
|
179
|
+
return this.http.post(`${this.environment.apiV2}/${this.url}/delete`, models)
|
|
180
|
+
.pipe(
|
|
181
|
+
map(() => {
|
|
182
|
+
const ids: number[] = models.map((model: Model): number => model['id']);
|
|
183
|
+
this.cache = this.cache.filter((item: Model) => !ids.includes(item['id']));
|
|
184
|
+
this.updateCache();
|
|
185
|
+
})
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* clear service cache
|
|
191
|
+
*/
|
|
192
|
+
resetCache(): void {
|
|
193
|
+
this.fetch().subscribe();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* get list of base class instances directly from backend
|
|
198
|
+
*/
|
|
199
|
+
protected fetch(): Observable<Model[]> {
|
|
200
|
+
return this.http.get(`${this.environment.apiV2}/${this.url}`)
|
|
201
|
+
.pipe(
|
|
202
|
+
map((response: BaseModel[]): Model[] => {
|
|
203
|
+
const items: Model[] = (this.isHydra ? response['hydra:member'] : response)
|
|
204
|
+
.map((item: BaseModel): Model => {
|
|
205
|
+
return this.createModelInstance(this.modelClass, item);
|
|
206
|
+
});
|
|
207
|
+
this.cache = items;
|
|
208
|
+
this.updateCache();
|
|
209
|
+
return items;
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Update cache subject with current cache array value
|
|
216
|
+
*/
|
|
217
|
+
protected updateCache(): void {
|
|
218
|
+
this.cacheSubject.next(this.cache.slice());
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Create new instance of class
|
|
223
|
+
* @param model The class for which you want to create an instance
|
|
224
|
+
* @param baseModel base model instance that we will use as constructor options
|
|
225
|
+
*/
|
|
226
|
+
protected createModelInstance(model: new(bm: BaseModel) => Model, baseModel: BaseModel): Model {
|
|
227
|
+
return plainToClass(model, baseModel, { excludePrefixes: ['@'] });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { BorrowingExpenseService } from './borrowing-expense.service';
|
|
4
|
+
|
|
5
|
+
describe('BorrowingExpenseService', () => {
|
|
6
|
+
beforeEach(() => TestBed.configureTestingModule({}));
|
|
7
|
+
|
|
8
|
+
it('should be created', () => {
|
|
9
|
+
const service: BorrowingExpenseService = TestBed.get(BorrowingExpenseService);
|
|
10
|
+
expect(service).toBeTruthy();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Inject, Injectable } from '@angular/core';
|
|
2
|
+
import { Observable, ReplaySubject } from 'rxjs';
|
|
3
|
+
import { map } from 'rxjs/operators';
|
|
4
|
+
import { HttpClient } from '@angular/common/http';
|
|
5
|
+
import { plainToClass } from 'class-transformer';
|
|
6
|
+
import { BorrowingExpense } from '../../models/borrowing-expense/borrowing-expense';
|
|
7
|
+
import { Loan } from '../../models/loan/loan';
|
|
8
|
+
import { BorrowingExpenseLoan } from '../../models/borrowing-expense/borrowing-expense-loan';
|
|
9
|
+
|
|
10
|
+
@Injectable({
|
|
11
|
+
providedIn: 'root'
|
|
12
|
+
})
|
|
13
|
+
export class BorrowingExpenseService {
|
|
14
|
+
_borrowingExpenses: BorrowingExpense[];
|
|
15
|
+
borrowingExpensesSubject: ReplaySubject<BorrowingExpense[]> = new ReplaySubject<BorrowingExpense[]>(1);
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
private http: HttpClient,
|
|
19
|
+
@Inject('environment') protected environment: any
|
|
20
|
+
) { }
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get borrowing expenses
|
|
24
|
+
*/
|
|
25
|
+
get(): Observable<BorrowingExpense[]> {
|
|
26
|
+
if (!this._borrowingExpenses) {
|
|
27
|
+
this.http.get(`${this.environment.apiV2}/borrowing-expenses`)
|
|
28
|
+
.pipe(
|
|
29
|
+
map((response: any) => {
|
|
30
|
+
return response.map((item: any) => plainToClass(BorrowingExpense, item));
|
|
31
|
+
})
|
|
32
|
+
)
|
|
33
|
+
.subscribe((borrowingExpenses: BorrowingExpense[]) => {
|
|
34
|
+
this._borrowingExpenses = borrowingExpenses;
|
|
35
|
+
this.borrowingExpensesSubject.next(this._borrowingExpenses);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return this.borrowingExpensesSubject.asObservable();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getLoanBorrowingExpenses(loan?: Loan): Observable<any> {
|
|
43
|
+
return this.get()
|
|
44
|
+
.pipe(
|
|
45
|
+
map((borrowingExpenses: BorrowingExpense[]) => {
|
|
46
|
+
// Loan borrowing expenses array
|
|
47
|
+
const borrowingExpensesLoan: BorrowingExpenseLoan[] = [];
|
|
48
|
+
// Combined array of borrowing expenses list & loan borrowing expenses
|
|
49
|
+
const combinedBorrowingExpenses: BorrowingExpenseLoan[] = [];
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
borrowingExpenses.forEach((borrowingExpense: BorrowingExpense, index: number) => {
|
|
53
|
+
// Fill borrowingExpensesLoan with values based on borrowingExpenses list
|
|
54
|
+
borrowingExpensesLoan.push(plainToClass(BorrowingExpenseLoan, {
|
|
55
|
+
borrowingExpense: borrowingExpense,
|
|
56
|
+
loan: loan,
|
|
57
|
+
amount: 0,
|
|
58
|
+
id: null,
|
|
59
|
+
createdAt: null,
|
|
60
|
+
updatedAt: null,
|
|
61
|
+
createdBy: null,
|
|
62
|
+
updatedBy: null
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
combinedBorrowingExpenses
|
|
66
|
+
.push(Object.assign(plainToClass(BorrowingExpenseLoan, {} as BorrowingExpenseLoan), borrowingExpenses[index], borrowingExpensesLoan[index]));
|
|
67
|
+
|
|
68
|
+
// Find current loan borrowing expense in loan object by index
|
|
69
|
+
const targetBorrowingExpense: any = loan.borrowingExpenses.find((updBorrowingExpensesLoan: BorrowingExpenseLoan) =>
|
|
70
|
+
updBorrowingExpensesLoan.borrowingExpense.id === borrowingExpensesLoan[index].borrowingExpense.id);
|
|
71
|
+
|
|
72
|
+
// ... and set its value to current loan borrowing expense in combinedBorrowingExpenses array
|
|
73
|
+
combinedBorrowingExpenses[index].amount = targetBorrowingExpense ? targetBorrowingExpense.amount : 0;
|
|
74
|
+
|
|
75
|
+
return combinedBorrowingExpenses;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return combinedBorrowingExpenses;
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ChartAccountsDepreciationService } from './chart-accounts-depreciations.service';
|
|
4
|
+
|
|
5
|
+
describe('ChartAccountsDepreciationService', () => {
|
|
6
|
+
let service: ChartAccountsDepreciationService;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
TestBed.configureTestingModule({});
|
|
10
|
+
service = TestBed.inject(ChartAccountsDepreciationService);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should be created', () => {
|
|
14
|
+
expect(service).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { BaseRestService } from '../base-rest.service';
|
|
3
|
+
import { ChartAccountsDepreciation as ChartAccountsDepreciationBase } from '../../db/Models/chart-accounts-depreciation';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { map } from 'rxjs/operators';
|
|
6
|
+
import { ChartAccountsDepreciation } from '../../models/chart-accounts/chart-accounts-depreciation';
|
|
7
|
+
import { FinancialYear } from '../../models/financial-year/financial-year';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Service to work with depreciation chart accounts
|
|
11
|
+
*/
|
|
12
|
+
@Injectable({
|
|
13
|
+
providedIn: 'root'
|
|
14
|
+
})
|
|
15
|
+
export class ChartAccountsDepreciationService extends BaseRestService<ChartAccountsDepreciationBase, ChartAccountsDepreciation> {
|
|
16
|
+
url: string = 'chart-accounts-depreciations';
|
|
17
|
+
modelClass: typeof ChartAccountsDepreciation = ChartAccountsDepreciation;
|
|
18
|
+
isHydra: boolean = true;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get depreciation chart accounts for current financial year
|
|
22
|
+
*/
|
|
23
|
+
getCurrent(): Observable<ChartAccountsDepreciation> {
|
|
24
|
+
return this.get()
|
|
25
|
+
.pipe(
|
|
26
|
+
map((chartAccountsDepreciations: ChartAccountsDepreciation[]) => {
|
|
27
|
+
return chartAccountsDepreciations
|
|
28
|
+
.find((chartAccountsDepreciation: ChartAccountsDepreciation): boolean => {
|
|
29
|
+
return chartAccountsDepreciation.effectiveYear === new FinancialYear().year;
|
|
30
|
+
});
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ChartAccountsService } from './chart-accounts.service';
|
|
4
|
+
|
|
5
|
+
describe('ChartAccountService', () => {
|
|
6
|
+
beforeEach(() => TestBed.configureTestingModule({}));
|
|
7
|
+
|
|
8
|
+
it('should be created', () => {
|
|
9
|
+
const service: ChartAccountsService = TestBed.get(ChartAccountsService);
|
|
10
|
+
expect(service).toBeTruthy();
|
|
11
|
+
});
|
|
12
|
+
});
|