taxtank-core 0.10.3 → 0.10.4
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/bundles/taxtank-core.umd.js +1133 -937
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/collection-dictionary.js +6 -6
- package/esm2015/lib/collections/report/property/property-report-item-depreciation.collection.js +19 -0
- package/esm2015/lib/collections/report/property/property-report-item-transaction.collection.js +19 -0
- package/esm2015/lib/models/depreciation/depreciation.js +3 -3
- package/esm2015/lib/models/report/property/property-report-item-depreciation.js +13 -0
- package/esm2015/lib/models/report/property/property-report-item-transaction.js +12 -0
- package/esm2015/lib/models/report/property/property-report-item.js +18 -0
- package/esm2015/lib/services/report/property/property-transaction-report.service.js +112 -0
- package/esm2015/public-api.js +6 -1
- package/fesm2015/taxtank-core.js +863 -695
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/collection-dictionary.d.ts +1 -1
- package/lib/collections/report/property/property-report-item-depreciation.collection.d.ts +12 -0
- package/lib/collections/report/property/property-report-item-transaction.collection.d.ts +12 -0
- package/lib/models/depreciation/depreciation.d.ts +1 -1
- package/lib/models/report/property/property-report-item-depreciation.d.ts +10 -0
- package/lib/models/report/property/property-report-item-transaction.d.ts +10 -0
- package/lib/models/report/property/property-report-item.d.ts +18 -0
- package/lib/services/report/property/property-transaction-report.service.d.ts +49 -0
- package/package.json +1 -1
- package/public-api.d.ts +5 -0
package/fesm2015/taxtank-core.js
CHANGED
|
@@ -747,7 +747,7 @@ class CollectionDictionary {
|
|
|
747
747
|
* @param path Path to the property to be grouped (Examples: 'transaction', 'property.category')
|
|
748
748
|
* @param prop Optional: Field to group by (Default 'id', Examples: 'id', 'amount', 'date')
|
|
749
749
|
*/
|
|
750
|
-
constructor(collection, path = '
|
|
750
|
+
constructor(collection, path = 'id') {
|
|
751
751
|
/**
|
|
752
752
|
* List of grouped collections
|
|
753
753
|
*/
|
|
@@ -758,10 +758,10 @@ class CollectionDictionary {
|
|
|
758
758
|
return;
|
|
759
759
|
}
|
|
760
760
|
// Check if the first collection item has property by path
|
|
761
|
-
if (!has(collection.items[0], path)
|
|
761
|
+
if (!has(collection.items[0], path)) {
|
|
762
762
|
return;
|
|
763
763
|
}
|
|
764
|
-
this.groupItems(collection, path
|
|
764
|
+
this.groupItems(collection, path);
|
|
765
765
|
}
|
|
766
766
|
/**
|
|
767
767
|
* List of collections keys
|
|
@@ -799,12 +799,12 @@ class CollectionDictionary {
|
|
|
799
799
|
/**
|
|
800
800
|
* Group collection items by passed path into items object
|
|
801
801
|
*/
|
|
802
|
-
groupItems(collection, path
|
|
802
|
+
groupItems(collection, path) {
|
|
803
803
|
// Create empty initial object for groups
|
|
804
804
|
const obj = {};
|
|
805
805
|
// Group collection items
|
|
806
806
|
collection.items.forEach((item) => {
|
|
807
|
-
let key = get(item,
|
|
807
|
+
let key = get(item, path);
|
|
808
808
|
// if object does not have property for grouping it will be grouped as 'other'
|
|
809
809
|
if (key === undefined) {
|
|
810
810
|
key = 'other';
|
|
@@ -3703,8 +3703,8 @@ class Depreciation extends Depreciation$1 {
|
|
|
3703
3703
|
/**
|
|
3704
3704
|
* Create a new transaction from current depreciation
|
|
3705
3705
|
*/
|
|
3706
|
-
toTransaction() {
|
|
3707
|
-
return plainToClass(Transaction, Object.assign(
|
|
3706
|
+
toTransaction(params = {}) {
|
|
3707
|
+
return plainToClass(Transaction, Object.assign(params, this, { amount: this.currentYearForecast.amount }));
|
|
3708
3708
|
}
|
|
3709
3709
|
get claimAmount() {
|
|
3710
3710
|
var _a;
|
|
@@ -3816,6 +3816,78 @@ class DepreciationReportItemCollection extends DepreciationCollection {
|
|
|
3816
3816
|
}
|
|
3817
3817
|
}
|
|
3818
3818
|
|
|
3819
|
+
/**
|
|
3820
|
+
* Class with property transactions report entities
|
|
3821
|
+
*/
|
|
3822
|
+
class PropertyReportItem {
|
|
3823
|
+
constructor(property, chartAccounts) {
|
|
3824
|
+
this.claimPercent = property.claimPercent;
|
|
3825
|
+
this.sharePercent = property.sharePercent;
|
|
3826
|
+
this.subCode = chartAccounts.taxReturnItem.subCode;
|
|
3827
|
+
this.description = chartAccounts.name;
|
|
3828
|
+
}
|
|
3829
|
+
get claimAmount() {
|
|
3830
|
+
return +(this.amount * (this.claimPercent / 100)).toFixed(2);
|
|
3831
|
+
}
|
|
3832
|
+
get shareClaimAmount() {
|
|
3833
|
+
return this.claimAmount * (this.sharePercent / 100);
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
/**
|
|
3838
|
+
* Class with transaction-based property transactions report entities
|
|
3839
|
+
*/
|
|
3840
|
+
class PropertyReportItemTransaction extends PropertyReportItem {
|
|
3841
|
+
constructor(transactions, property, chartAccounts) {
|
|
3842
|
+
super(property, chartAccounts);
|
|
3843
|
+
this.amount = transactions.amount;
|
|
3844
|
+
this.description = chartAccounts.name;
|
|
3845
|
+
}
|
|
3846
|
+
}
|
|
3847
|
+
|
|
3848
|
+
/**
|
|
3849
|
+
* Collection to work with transaction-based property report items
|
|
3850
|
+
*/
|
|
3851
|
+
class PropertyReportItemTransactionCollection extends Collection {
|
|
3852
|
+
constructor(transactions, property, chartAccounts) {
|
|
3853
|
+
super();
|
|
3854
|
+
this.setItems(transactions, property, chartAccounts);
|
|
3855
|
+
}
|
|
3856
|
+
setItems(transactions, property, chartAccounts) {
|
|
3857
|
+
const transactionsDictionary = new CollectionDictionary(transactions, 'chartAccounts.id');
|
|
3858
|
+
this.items = transactionsDictionary.keys.map((chartAccountId) => {
|
|
3859
|
+
return new PropertyReportItemTransaction(transactionsDictionary.get(chartAccountId), property, chartAccounts.getById(+chartAccountId));
|
|
3860
|
+
});
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
|
|
3864
|
+
/**
|
|
3865
|
+
* Class with depreciation-based property transactions report entities
|
|
3866
|
+
*/
|
|
3867
|
+
class PropertyReportItemDepreciation extends PropertyReportItem {
|
|
3868
|
+
constructor(depreciations, property, chartAccounts) {
|
|
3869
|
+
super(property, chartAccounts);
|
|
3870
|
+
this.amount = depreciations.getCurrentYearForecastAmount();
|
|
3871
|
+
this.description = DepreciationTypeEnum[depreciations.first.type];
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
|
|
3875
|
+
/**
|
|
3876
|
+
* Collection to work with depreciation-based property report items
|
|
3877
|
+
*/
|
|
3878
|
+
class PropertyReportItemDepreciationCollection extends Collection {
|
|
3879
|
+
constructor(depreciations, property, chartAccounts) {
|
|
3880
|
+
super();
|
|
3881
|
+
this.setItems(depreciations, property, chartAccounts);
|
|
3882
|
+
}
|
|
3883
|
+
setItems(depreciations, property, chartAccounts) {
|
|
3884
|
+
const depreciationsbyType = new CollectionDictionary(depreciations, 'type');
|
|
3885
|
+
this.items = depreciationsbyType.keys.map((type) => {
|
|
3886
|
+
return new PropertyReportItemDepreciation(depreciationsbyType.get(type), property, chartAccounts.getById(depreciationsbyType.get(type).first.chartAccounts.id));
|
|
3887
|
+
});
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
|
|
3819
3891
|
class ServicePriceCollection extends Collection {
|
|
3820
3892
|
get work() {
|
|
3821
3893
|
return this.items.filter((price) => price.product.isWork())[0];
|
|
@@ -9005,136 +9077,71 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
9005
9077
|
args: ['environment']
|
|
9006
9078
|
}] }]; } });
|
|
9007
9079
|
|
|
9080
|
+
function enumToList(data) {
|
|
9081
|
+
const list = [];
|
|
9082
|
+
for (const key in data) {
|
|
9083
|
+
if (Number(key) >= 0) {
|
|
9084
|
+
list.push({
|
|
9085
|
+
label: data[key],
|
|
9086
|
+
value: Number(key)
|
|
9087
|
+
});
|
|
9088
|
+
}
|
|
9089
|
+
}
|
|
9090
|
+
return list;
|
|
9091
|
+
}
|
|
9092
|
+
|
|
9093
|
+
var MessagesEnum;
|
|
9094
|
+
(function (MessagesEnum) {
|
|
9095
|
+
MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
|
|
9096
|
+
MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
|
|
9097
|
+
MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
|
|
9098
|
+
})(MessagesEnum || (MessagesEnum = {}));
|
|
9099
|
+
|
|
9008
9100
|
/**
|
|
9009
|
-
*
|
|
9010
|
-
* Logic here works like collections methods but for several entities
|
|
9101
|
+
* popup notifications service (toast, snackbar).
|
|
9011
9102
|
*/
|
|
9012
|
-
class
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
return transactions.cashPosition - Math.abs(depreciations.claimAmount);
|
|
9103
|
+
class ToastService {
|
|
9104
|
+
constructor() {
|
|
9105
|
+
this.toast$ = new ReplaySubject(1);
|
|
9016
9106
|
}
|
|
9017
|
-
|
|
9018
|
-
return
|
|
9019
|
-
transactions$,
|
|
9020
|
-
depreciations$
|
|
9021
|
-
]).pipe(map(([transactions, depreciations]) => {
|
|
9022
|
-
return this.getTaxPosition(transactions, depreciations);
|
|
9023
|
-
}));
|
|
9107
|
+
get() {
|
|
9108
|
+
return this.toast$.asObservable();
|
|
9024
9109
|
}
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
// check if taxPosition = 0 to avoid division by zero
|
|
9028
|
-
if (!taxPosition) {
|
|
9029
|
-
return 0;
|
|
9030
|
-
}
|
|
9031
|
-
return (taxPosition - properties.forecastedTaxPosition) / taxPosition;
|
|
9110
|
+
add(toast) {
|
|
9111
|
+
this.toast$.next(toast);
|
|
9032
9112
|
}
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
]).pipe(map(([properties, transactions, depreciations]) => {
|
|
9039
|
-
return this.taxPositionGrowth(properties, transactions, depreciations);
|
|
9113
|
+
success(message) {
|
|
9114
|
+
this.add(plainToClass(Toast, {
|
|
9115
|
+
type: ToastTypeEnum.SUCCESS,
|
|
9116
|
+
title: 'Success!',
|
|
9117
|
+
message,
|
|
9040
9118
|
}));
|
|
9041
9119
|
}
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
return totalAmount + bankAccounts.items
|
|
9048
|
-
.reduce((propertyAmount, bankAccount) => {
|
|
9049
|
-
var _a;
|
|
9050
|
-
return propertyAmount + bankAccount.getPropertyPercentage(property.id) * (((_a = loans.getByBankAccountId(bankAccount.id)) === null || _a === void 0 ? void 0 : _a.amount) || 0);
|
|
9051
|
-
}, 0);
|
|
9052
|
-
}, 0);
|
|
9053
|
-
}
|
|
9054
|
-
getLoanValue(properties, bankAccounts) {
|
|
9055
|
-
return properties.items.reduce((totalAmount, property) => {
|
|
9056
|
-
return totalAmount + bankAccounts.items
|
|
9057
|
-
.reduce((propertyAmount, bankAccount) => {
|
|
9058
|
-
return propertyAmount + bankAccount.getPropertyBalanceAmount(property.id);
|
|
9059
|
-
}, 0);
|
|
9060
|
-
}, 0);
|
|
9061
|
-
}
|
|
9062
|
-
/**
|
|
9063
|
-
* LVR
|
|
9064
|
-
*/
|
|
9065
|
-
getLvr(properties, bankAccounts) {
|
|
9066
|
-
// Math abs is required for correct percentage calculation
|
|
9067
|
-
return Math.abs(this.getLoanValue(properties, bankAccounts)) / properties.marketValue;
|
|
9068
|
-
}
|
|
9069
|
-
getLvr$(properties$, bankAccounts$) {
|
|
9070
|
-
return combineLatest([
|
|
9071
|
-
properties$,
|
|
9072
|
-
bankAccounts$
|
|
9073
|
-
]).pipe(map(([properties, bankAccounts]) => {
|
|
9074
|
-
return this.getLvr(properties, bankAccounts);
|
|
9120
|
+
warning(message) {
|
|
9121
|
+
this.add(plainToClass(Toast, {
|
|
9122
|
+
type: ToastTypeEnum.WARNING,
|
|
9123
|
+
title: 'Warning!',
|
|
9124
|
+
message,
|
|
9075
9125
|
}));
|
|
9076
9126
|
}
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
return combineLatest([
|
|
9083
|
-
properties$,
|
|
9084
|
-
bankAccounts$,
|
|
9085
|
-
loans$
|
|
9086
|
-
]).pipe(map(([properties, bankAccounts, loans]) => {
|
|
9087
|
-
return this.getLvrCommencement(properties, loans, bankAccounts);
|
|
9127
|
+
error(message) {
|
|
9128
|
+
this.add(plainToClass(Toast, {
|
|
9129
|
+
type: ToastTypeEnum.ERROR,
|
|
9130
|
+
title: 'Error!',
|
|
9131
|
+
message,
|
|
9088
9132
|
}));
|
|
9089
9133
|
}
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
}
|
|
9096
|
-
return (lvr - this.getLvrCommencement(properties, loans, bankAccounts)) / lvr;
|
|
9097
|
-
}
|
|
9098
|
-
getLvrGrowth$(properties$, bankAccounts$, loans$) {
|
|
9099
|
-
return combineLatest([
|
|
9100
|
-
properties$,
|
|
9101
|
-
bankAccounts$,
|
|
9102
|
-
loans$
|
|
9103
|
-
]).pipe(map(([properties, bankAccounts, loans]) => {
|
|
9104
|
-
return this.getLvrGrowth(properties, bankAccounts, loans);
|
|
9134
|
+
info(message) {
|
|
9135
|
+
this.add(plainToClass(Toast, {
|
|
9136
|
+
type: ToastTypeEnum.INFO,
|
|
9137
|
+
title: 'Information',
|
|
9138
|
+
message,
|
|
9105
9139
|
}));
|
|
9106
9140
|
}
|
|
9107
|
-
getEquityPosition(properties, bankAccounts) {
|
|
9108
|
-
// Math abs is required for correct percentage calculation
|
|
9109
|
-
return properties.marketValue - Math.abs(this.getLoanValue(properties, bankAccounts));
|
|
9110
|
-
}
|
|
9111
|
-
getPurchaseEquity(properties, bankAccounts, loans) {
|
|
9112
|
-
// Math abs is required for correct percentage calculation
|
|
9113
|
-
return properties.purchasePrice - Math.abs(this.getLoanAmount(properties, bankAccounts, loans));
|
|
9114
|
-
}
|
|
9115
|
-
}
|
|
9116
|
-
PropertyCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyCalculationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9117
|
-
PropertyCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyCalculationService, providedIn: 'root' });
|
|
9118
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyCalculationService, decorators: [{
|
|
9119
|
-
type: Injectable,
|
|
9120
|
-
args: [{
|
|
9121
|
-
providedIn: 'root'
|
|
9122
|
-
}]
|
|
9123
|
-
}] });
|
|
9124
|
-
|
|
9125
|
-
/**
|
|
9126
|
-
* Service for work with Property Categories
|
|
9127
|
-
*/
|
|
9128
|
-
class PropertyCategoryService extends RestService {
|
|
9129
|
-
constructor() {
|
|
9130
|
-
super(...arguments);
|
|
9131
|
-
this.modelClass = PropertyCategory;
|
|
9132
|
-
this.url = 'properties/categories';
|
|
9133
|
-
}
|
|
9134
9141
|
}
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type:
|
|
9142
|
+
ToastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9143
|
+
ToastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ToastService, providedIn: 'root' });
|
|
9144
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ToastService, decorators: [{
|
|
9138
9145
|
type: Injectable,
|
|
9139
9146
|
args: [{
|
|
9140
9147
|
providedIn: 'root'
|
|
@@ -9142,43 +9149,586 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
9142
9149
|
}] });
|
|
9143
9150
|
|
|
9144
9151
|
/**
|
|
9145
|
-
*
|
|
9152
|
+
* Service for transactions business logic
|
|
9146
9153
|
*/
|
|
9147
|
-
class
|
|
9148
|
-
constructor(http, eventDispatcherService, environment) {
|
|
9154
|
+
class TransactionService extends RestService {
|
|
9155
|
+
constructor(http, eventDispatcherService, environment, toastService) {
|
|
9149
9156
|
super(http, eventDispatcherService, environment);
|
|
9150
9157
|
this.http = http;
|
|
9151
9158
|
this.eventDispatcherService = eventDispatcherService;
|
|
9152
9159
|
this.environment = environment;
|
|
9153
|
-
this.
|
|
9154
|
-
|
|
9160
|
+
this.toastService = toastService;
|
|
9161
|
+
// url part for Transaction API
|
|
9162
|
+
this.url = 'transactions';
|
|
9163
|
+
this.modelClass = Transaction;
|
|
9164
|
+
this.transactionDeleted = new EventEmitter();
|
|
9155
9165
|
this.listenEvents();
|
|
9156
9166
|
}
|
|
9157
9167
|
/**
|
|
9158
|
-
*
|
|
9168
|
+
* Listen events from Event Dispatcher services
|
|
9159
9169
|
*/
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
formDataDocument.append('file', file);
|
|
9164
|
-
return this.http.post(`${this.environment.apiV2}/properties/${propertyId}/documents`, formDataDocument).pipe(map((documentBase) => {
|
|
9165
|
-
const newDocument = plainToClass(PropertyDocument, documentBase);
|
|
9166
|
-
if (this.cache) {
|
|
9167
|
-
this.cache.push(newDocument);
|
|
9168
|
-
this.updateCache();
|
|
9169
|
-
}
|
|
9170
|
-
return newDocument;
|
|
9171
|
-
}));
|
|
9170
|
+
listenEvents() {
|
|
9171
|
+
this.listenDepreciationChange();
|
|
9172
|
+
this.listenPropertyShareUpdate();
|
|
9172
9173
|
}
|
|
9173
9174
|
/**
|
|
9174
|
-
*
|
|
9175
|
-
* @param propertyId to get desired documents
|
|
9175
|
+
* get list of all user's TaxTank transactions
|
|
9176
9176
|
*/
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9177
|
+
get() {
|
|
9178
|
+
if (!this.cache) {
|
|
9179
|
+
// set cache as default empty array to avoid multiple backend requests
|
|
9180
|
+
this.cache = [];
|
|
9181
|
+
this.fetch()
|
|
9182
|
+
.subscribe((transactions) => {
|
|
9183
|
+
this.cache = transactions;
|
|
9184
|
+
this.updateCache();
|
|
9185
|
+
});
|
|
9186
|
+
}
|
|
9187
|
+
return this.cacheSubject.asObservable().pipe(
|
|
9188
|
+
// assign child transactions (fees) to parent transactions
|
|
9189
|
+
map((transactions) => {
|
|
9190
|
+
transactions.forEach((transaction) => {
|
|
9191
|
+
transaction.transactions = transactions
|
|
9192
|
+
// get list of child transactions
|
|
9193
|
+
.filter((t) => t.parentTransaction && t.parentTransaction.id === transaction.id);
|
|
9194
|
+
});
|
|
9195
|
+
sort(transactions, 'date', false);
|
|
9196
|
+
return transactions;
|
|
9197
|
+
}));
|
|
9198
|
+
}
|
|
9199
|
+
/**
|
|
9200
|
+
* Add single new transaction
|
|
9201
|
+
* @param model New Transaction instance for saving
|
|
9202
|
+
*/
|
|
9203
|
+
add(model) {
|
|
9204
|
+
// we don't have POST API endpoint for single transaction
|
|
9205
|
+
return this.addBatch([model])
|
|
9206
|
+
.pipe(map((newTransactions) => {
|
|
9207
|
+
// @TODO alex
|
|
9208
|
+
this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTION_CREATED, newTransactions[0]));
|
|
9209
|
+
return newTransactions[0];
|
|
9210
|
+
}));
|
|
9211
|
+
}
|
|
9212
|
+
/**
|
|
9213
|
+
* get transactions related with property
|
|
9214
|
+
*/
|
|
9215
|
+
getByPropertyId(propertyId) {
|
|
9216
|
+
return this.get()
|
|
9217
|
+
.pipe(map((transactions) => {
|
|
9218
|
+
return transactions.filter((transaction) => {
|
|
9219
|
+
var _a;
|
|
9220
|
+
return ((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id) === propertyId;
|
|
9221
|
+
});
|
|
9222
|
+
}));
|
|
9223
|
+
}
|
|
9224
|
+
/**
|
|
9225
|
+
* get list of transactions with tank type 'Work'
|
|
9226
|
+
*/
|
|
9227
|
+
getWorkTransactions() {
|
|
9228
|
+
return this.get()
|
|
9229
|
+
.pipe(map((transactions) => {
|
|
9230
|
+
return transactions.filter((transaction) => transaction.isWorkTank());
|
|
9231
|
+
}));
|
|
9232
|
+
}
|
|
9233
|
+
/**
|
|
9234
|
+
* get list of taxable transactions with tank type 'Work'
|
|
9235
|
+
*/
|
|
9236
|
+
getTaxableWorkTransactions() {
|
|
9237
|
+
return this.getWorkTransactions()
|
|
9238
|
+
.pipe(map((transactions) => {
|
|
9239
|
+
return transactions.filter((transaction) => !!transaction.chartAccounts.taxReturnItem);
|
|
9240
|
+
}));
|
|
9241
|
+
}
|
|
9242
|
+
/**
|
|
9243
|
+
* add multiple transactions
|
|
9244
|
+
* @param transactions List of new Transaction instances for saving
|
|
9245
|
+
*/
|
|
9246
|
+
addBatch(transactions) {
|
|
9247
|
+
transactions = _.cloneDeep(transactions);
|
|
9248
|
+
return this.http.post(`${this.environment.apiV2}/${this.url}`, transactions)
|
|
9249
|
+
.pipe(map((response) => {
|
|
9250
|
+
const addedTransactions = response.map((item) => plainToClass(Transaction, item));
|
|
9251
|
+
transactions.forEach((transaction, index) => {
|
|
9252
|
+
// @TODO backend: need to upload file in the same backend endpoint with transaction add/update
|
|
9253
|
+
// check if passed receipt and upload file
|
|
9254
|
+
if (transaction.file) {
|
|
9255
|
+
transaction.id = response[index].id;
|
|
9256
|
+
addedTransactions[index].file = transaction.file;
|
|
9257
|
+
this.uploadReceipt(addedTransactions[index]);
|
|
9258
|
+
}
|
|
9259
|
+
// @TODO Viktor: implement API for saving of nested transactions
|
|
9260
|
+
// add child transactions if exist
|
|
9261
|
+
if (transaction.transactions.length) {
|
|
9262
|
+
transaction.transactions.forEach((childTransaction) => {
|
|
9263
|
+
childTransaction.parentTransaction = plainToClass(Transaction, { id: addedTransactions[index].id });
|
|
9264
|
+
});
|
|
9265
|
+
this.addBatch(transaction.transactions).subscribe();
|
|
9266
|
+
}
|
|
9267
|
+
// add transfer transaction to cache
|
|
9268
|
+
if (transaction.operation === TransactionOperationEnum.TRANSFER) {
|
|
9269
|
+
addedTransactions.push(addedTransactions[0].transfer);
|
|
9270
|
+
}
|
|
9271
|
+
});
|
|
9272
|
+
if (this.cache) {
|
|
9273
|
+
this.cache.push(...addedTransactions);
|
|
9274
|
+
this.updateCache();
|
|
9275
|
+
}
|
|
9276
|
+
this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
|
|
9277
|
+
this.toastService.success(MessagesEnum.CREATED_MESSAGE);
|
|
9278
|
+
return addedTransactions;
|
|
9279
|
+
}));
|
|
9280
|
+
}
|
|
9281
|
+
/**
|
|
9282
|
+
* update existing transaction
|
|
9283
|
+
* @param transaction Transaction instance for updating
|
|
9284
|
+
*/
|
|
9285
|
+
update(transaction) {
|
|
9286
|
+
return this.http.put(`${this.environment.apiV2}/${this.url}/${transaction.id}`, transaction)
|
|
9287
|
+
.pipe(map((response) => {
|
|
9288
|
+
const updatedTransaction = plainToClass(Transaction, response);
|
|
9289
|
+
// @TODO need to upload file in the same backend endpoint with transaction add/update
|
|
9290
|
+
// check if passed new receipt and upload file
|
|
9291
|
+
if (transaction.file) {
|
|
9292
|
+
updatedTransaction.file = transaction.file;
|
|
9293
|
+
this.uploadReceipt(updatedTransaction);
|
|
9294
|
+
}
|
|
9295
|
+
// @TODO Viktor: implement API for saving of nested transactions
|
|
9296
|
+
if (transaction.transactions.length) {
|
|
9297
|
+
// add parent transaction to child transactions
|
|
9298
|
+
transaction.transactions.forEach((childTransaction) => {
|
|
9299
|
+
childTransaction.parentTransaction = plainToClass(Transaction, { id: updatedTransaction.id });
|
|
9300
|
+
});
|
|
9301
|
+
// separate child transactions by id existing to define add or update action.
|
|
9302
|
+
const childTransactionsToUpdate = transaction.transactions.filter((t) => t.id);
|
|
9303
|
+
const childTransactionsToAdd = transaction.transactions.filter((t) => !t.id);
|
|
9304
|
+
// update child transactions
|
|
9305
|
+
if (childTransactionsToUpdate.length) {
|
|
9306
|
+
this.updateBatch(childTransactionsToUpdate).subscribe();
|
|
9307
|
+
}
|
|
9308
|
+
// add child transactions
|
|
9309
|
+
if (childTransactionsToAdd.length) {
|
|
9310
|
+
this.addBatch(childTransactionsToAdd).subscribe();
|
|
9311
|
+
}
|
|
9312
|
+
}
|
|
9313
|
+
this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
|
|
9314
|
+
replace(this.cache, updatedTransaction);
|
|
9315
|
+
this.updateCache();
|
|
9316
|
+
return updatedTransaction;
|
|
9317
|
+
}));
|
|
9318
|
+
}
|
|
9319
|
+
/**
|
|
9320
|
+
* update multiple transactions
|
|
9321
|
+
* @param transactions list of transactions for updating
|
|
9322
|
+
*/
|
|
9323
|
+
updateBatch(transactions) {
|
|
9324
|
+
return this.http.put(`${this.environment.apiV2}/${this.url}`, transactions)
|
|
9325
|
+
.pipe(map((response) => {
|
|
9326
|
+
const updatedTransactions = response.map((item) => plainToClass(Transaction, item));
|
|
9327
|
+
updatedTransactions.forEach((updatedTransaction) => {
|
|
9328
|
+
replace(this.cache, updatedTransaction);
|
|
9329
|
+
});
|
|
9330
|
+
this.updateCache();
|
|
9331
|
+
return updatedTransactions;
|
|
9332
|
+
}));
|
|
9333
|
+
}
|
|
9334
|
+
/**
|
|
9335
|
+
* delete transaction and related transactions
|
|
9336
|
+
* @param model
|
|
9337
|
+
*/
|
|
9338
|
+
delete(model) {
|
|
9339
|
+
return this.http.delete(`${this.environment.apiV2}/${this.url}/${model.id}`)
|
|
9340
|
+
.pipe(map(() => {
|
|
9341
|
+
this.cache = this.cache.filter((transaction) => {
|
|
9342
|
+
var _a;
|
|
9343
|
+
// when delete transfer we delete actually 2 transactions
|
|
9344
|
+
if (model.isTransfer) {
|
|
9345
|
+
const ids = [model.id];
|
|
9346
|
+
// get id of related transfer transaction
|
|
9347
|
+
if (model.transfer) {
|
|
9348
|
+
// just take id if we delete source transaction
|
|
9349
|
+
ids.push(model.transfer.id);
|
|
9350
|
+
}
|
|
9351
|
+
else {
|
|
9352
|
+
// find source transaction id if we delete destination transaction
|
|
9353
|
+
ids.push(this.cache.find((t) => t.transfer.id === model.id).id);
|
|
9354
|
+
}
|
|
9355
|
+
return !ids.includes(transaction.id);
|
|
9356
|
+
}
|
|
9357
|
+
return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
|
|
9358
|
+
});
|
|
9359
|
+
this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTION_DELETED, model));
|
|
9360
|
+
this.toastService.success(MessagesEnum.DELETED_MESSAGE);
|
|
9361
|
+
this.updateCache();
|
|
9362
|
+
this.transactionDeleted.emit(model);
|
|
9363
|
+
}));
|
|
9364
|
+
}
|
|
9365
|
+
/**
|
|
9366
|
+
* upload transaction receipt image
|
|
9367
|
+
* @param transaction Еhe transaction for which the receipt will be imported
|
|
9368
|
+
*/
|
|
9369
|
+
uploadReceipt(transaction) {
|
|
9370
|
+
const formData = new FormData();
|
|
9371
|
+
formData.append('file', transaction.file);
|
|
9372
|
+
transaction.receipt = null;
|
|
9373
|
+
this.http.post(`${this.environment.apiV2}/${this.url}/${transaction.id}/receipts`, formData)
|
|
9374
|
+
.subscribe((receiptResponse) => {
|
|
9375
|
+
// we don't need to keep file after save
|
|
9376
|
+
transaction.file = null;
|
|
9377
|
+
transaction.receipt = plainToClass(TransactionReceipt, receiptResponse);
|
|
9378
|
+
replace(this.cache, transaction);
|
|
9379
|
+
this.updateCache();
|
|
9380
|
+
});
|
|
9381
|
+
}
|
|
9382
|
+
/**
|
|
9383
|
+
* calculate gross income amount based on transaction amount and taxes (fees)
|
|
9384
|
+
* @param transaction Transaction instance for calculation
|
|
9385
|
+
*/
|
|
9386
|
+
calculateGrossAmount(transaction) {
|
|
9387
|
+
let amount = transaction.amount || 0;
|
|
9388
|
+
// gross income amount includes amount of fees for property tank and tax for work tank
|
|
9389
|
+
if (transaction.isPropertyTank()) {
|
|
9390
|
+
amount += transaction.transactions.reduce((sum, item) => sum + item.amount, 0);
|
|
9391
|
+
}
|
|
9392
|
+
else {
|
|
9393
|
+
// @TODO Alex: fix logic after TT-641 ready
|
|
9394
|
+
amount += (transaction.tax || 0);
|
|
9395
|
+
}
|
|
9396
|
+
return amount;
|
|
9397
|
+
}
|
|
9398
|
+
/**
|
|
9399
|
+
* get label for transaction tax field depended of selected chart account.
|
|
9400
|
+
* tax type depends of chart account heading or category.
|
|
9401
|
+
*/
|
|
9402
|
+
getTaxLabel(chartAccounts) {
|
|
9403
|
+
var _a, _b;
|
|
9404
|
+
// get simple array of ids from enum with taxable chart accounts headings
|
|
9405
|
+
const taxableCAHeadingsIds = enumToList(ChartAccountsHeadingTaxableEnum)
|
|
9406
|
+
.map((item) => item.value);
|
|
9407
|
+
// get simple array of ids from enum with tax deductible chart accounts headings
|
|
9408
|
+
const deductibleCAHeadingsIds = enumToList(ChartAccountsHeadingTaxDeductibleEnum)
|
|
9409
|
+
.map((item) => item.value);
|
|
9410
|
+
// check if one of ids arrays includes current chart accounts heading id and set tax label
|
|
9411
|
+
// otherwise label is empty for this class
|
|
9412
|
+
switch (true) {
|
|
9413
|
+
case taxableCAHeadingsIds.includes((_a = chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id):
|
|
9414
|
+
return ChartAccountsTaxLabelsEnum.TAX_PAID;
|
|
9415
|
+
case deductibleCAHeadingsIds.includes((_b = chartAccounts.heading) === null || _b === void 0 ? void 0 : _b.id):
|
|
9416
|
+
return ChartAccountsTaxLabelsEnum.TAX_DEDUCTED;
|
|
9417
|
+
case CHART_ACCOUNTS_CATEGORIES.workIncome.includes(chartAccounts.category):
|
|
9418
|
+
return ChartAccountsTaxLabelsEnum.TAX_WITHHELD;
|
|
9419
|
+
default:
|
|
9420
|
+
return null;
|
|
9421
|
+
}
|
|
9422
|
+
}
|
|
9423
|
+
/**
|
|
9424
|
+
* Get transactions related to Vehicle category
|
|
9425
|
+
*/
|
|
9426
|
+
getVehicleTransactions() {
|
|
9427
|
+
return this.get().pipe(map((transactions) => {
|
|
9428
|
+
return transactions.filter((transaction) => transaction.isVehicleTransaction());
|
|
9429
|
+
}));
|
|
9430
|
+
}
|
|
9431
|
+
/**
|
|
9432
|
+
* Listen to EventDispatcherService event related to Depreciation changing
|
|
9433
|
+
*/
|
|
9434
|
+
listenDepreciationChange() {
|
|
9435
|
+
this.eventDispatcherService.on(AppEventTypeEnum.DEPRECIATION_DELETED).subscribe(() => {
|
|
9436
|
+
this.fetch()
|
|
9437
|
+
.subscribe((transactions) => {
|
|
9438
|
+
this.cache = transactions;
|
|
9439
|
+
this.updateCache();
|
|
9440
|
+
});
|
|
9441
|
+
});
|
|
9442
|
+
}
|
|
9443
|
+
/**
|
|
9444
|
+
* Listen to EventDispatcherService event related to Property Share changing
|
|
9445
|
+
*/
|
|
9446
|
+
listenPropertyShareUpdate() {
|
|
9447
|
+
this.eventDispatcherService.on(AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(() => this.resetCache());
|
|
9448
|
+
}
|
|
9449
|
+
}
|
|
9450
|
+
TransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9451
|
+
TransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, providedIn: 'root' });
|
|
9452
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TransactionService, decorators: [{
|
|
9453
|
+
type: Injectable,
|
|
9454
|
+
args: [{
|
|
9455
|
+
providedIn: 'root'
|
|
9456
|
+
}]
|
|
9457
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
9458
|
+
type: Inject,
|
|
9459
|
+
args: ['environment']
|
|
9460
|
+
}] }, { type: ToastService }]; } });
|
|
9461
|
+
|
|
9462
|
+
/**
|
|
9463
|
+
* Service to handle Property transactions report items data (get income / expense report items, e.t.c.)
|
|
9464
|
+
*/
|
|
9465
|
+
class PropertyTransactionReportService {
|
|
9466
|
+
constructor(propertyService, transactionService, depreciationService, chartAccountsService) {
|
|
9467
|
+
this.propertyService = propertyService;
|
|
9468
|
+
this.transactionService = transactionService;
|
|
9469
|
+
this.depreciationService = depreciationService;
|
|
9470
|
+
this.chartAccountsService = chartAccountsService;
|
|
9471
|
+
}
|
|
9472
|
+
/**
|
|
9473
|
+
* Get collections dictionary of income report items, grouped by property id
|
|
9474
|
+
*/
|
|
9475
|
+
getIncomes() {
|
|
9476
|
+
return combineLatest([
|
|
9477
|
+
this.getProperties(),
|
|
9478
|
+
this.getTransactions(),
|
|
9479
|
+
this.getChartAccounts(),
|
|
9480
|
+
]).pipe(map(([properties, transactions, chartAccounts]) => {
|
|
9481
|
+
return this.initIncomeItemsData(transactions, properties, chartAccounts);
|
|
9482
|
+
}));
|
|
9483
|
+
}
|
|
9484
|
+
/**
|
|
9485
|
+
* Get collections dictionary of expense report items, grouped by property id
|
|
9486
|
+
*/
|
|
9487
|
+
getExpenses() {
|
|
9488
|
+
return combineLatest([
|
|
9489
|
+
this.getProperties(),
|
|
9490
|
+
this.getTransactions(),
|
|
9491
|
+
this.getDepreciations(),
|
|
9492
|
+
this.getChartAccounts()
|
|
9493
|
+
]).pipe(map(([properties, transactions, depreciations, chartAccounts]) => {
|
|
9494
|
+
return this.initExpenseItemsData(transactions, depreciations, properties, chartAccounts);
|
|
9495
|
+
}));
|
|
9496
|
+
}
|
|
9497
|
+
initIncomeItemsData(transactions, properties, chartAccounts) {
|
|
9498
|
+
// empty collection dictionary to be filled with income report items
|
|
9499
|
+
const incomesByProperty = new CollectionDictionary(new Collection([]), 'property.id');
|
|
9500
|
+
const incomeTransactionsByProperty = new CollectionDictionary(transactions.getIncomeTransactions(), 'property.id');
|
|
9501
|
+
incomeTransactionsByProperty.keys.forEach((propertyId) => {
|
|
9502
|
+
incomesByProperty.add(propertyId, new PropertyReportItemTransactionCollection(incomeTransactionsByProperty.get(propertyId), properties.getById(+propertyId), chartAccounts));
|
|
9503
|
+
});
|
|
9504
|
+
return incomesByProperty;
|
|
9505
|
+
}
|
|
9506
|
+
initExpenseItemsData(transactions, depreciations, properties, chartAccounts) {
|
|
9507
|
+
// empty collection dictionary to be filled with expense report items
|
|
9508
|
+
const expensesByProperty = new CollectionDictionary(new Collection([]), 'property.id');
|
|
9509
|
+
const transactionsByProperty = new CollectionDictionary(transactions.getExpenseTransactions(), 'property.id');
|
|
9510
|
+
const depreciationsByProperty = new CollectionDictionary(depreciations, 'property.id');
|
|
9511
|
+
transactionsByProperty.keys.forEach((propertyId) => {
|
|
9512
|
+
expensesByProperty.add(propertyId, new Collection([
|
|
9513
|
+
...new PropertyReportItemTransactionCollection(transactionsByProperty.get(propertyId), properties.getById(+propertyId), chartAccounts).items,
|
|
9514
|
+
...new PropertyReportItemDepreciationCollection(depreciationsByProperty.get(propertyId), properties.getById(+propertyId), chartAccounts).items
|
|
9515
|
+
]));
|
|
9516
|
+
});
|
|
9517
|
+
return expensesByProperty;
|
|
9518
|
+
}
|
|
9519
|
+
/**
|
|
9520
|
+
* Get colection of property transactions
|
|
9521
|
+
*/
|
|
9522
|
+
getTransactions() {
|
|
9523
|
+
return this.transactionService.get().pipe(map((transactions) => {
|
|
9524
|
+
return new TransactionCollection(transactions)
|
|
9525
|
+
.getByChartAccountsCategories(CHART_ACCOUNTS_CATEGORIES.property);
|
|
9526
|
+
}));
|
|
9527
|
+
}
|
|
9528
|
+
/**
|
|
9529
|
+
* Get list of asset & capital property depreciations
|
|
9530
|
+
*/
|
|
9531
|
+
getDepreciations() {
|
|
9532
|
+
return this.depreciationService.get().pipe(map((depreciations) => {
|
|
9533
|
+
return new DepreciationCollection(depreciations)
|
|
9534
|
+
.getByChartAccountsCategories(CHART_ACCOUNTS_CATEGORIES.property)
|
|
9535
|
+
.getWithoutBorrowingExpenses();
|
|
9536
|
+
}));
|
|
9537
|
+
}
|
|
9538
|
+
getProperties() {
|
|
9539
|
+
return this.propertyService.get().pipe(map((properties) => {
|
|
9540
|
+
return new PropertyCollection(properties);
|
|
9541
|
+
}));
|
|
9542
|
+
}
|
|
9543
|
+
getChartAccounts() {
|
|
9544
|
+
return this.chartAccountsService.getChartAccounts().pipe(map((chartAccounts) => {
|
|
9545
|
+
return new Collection(chartAccounts);
|
|
9546
|
+
}));
|
|
9547
|
+
}
|
|
9548
|
+
}
|
|
9549
|
+
PropertyTransactionReportService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyTransactionReportService, deps: [{ token: PropertyService }, { token: TransactionService }, { token: DepreciationService }, { token: ChartAccountsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9550
|
+
PropertyTransactionReportService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyTransactionReportService, providedIn: 'root' });
|
|
9551
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyTransactionReportService, decorators: [{
|
|
9552
|
+
type: Injectable,
|
|
9553
|
+
args: [{
|
|
9554
|
+
providedIn: 'root'
|
|
9555
|
+
}]
|
|
9556
|
+
}], ctorParameters: function () { return [{ type: PropertyService }, { type: TransactionService }, { type: DepreciationService }, { type: ChartAccountsService }]; } });
|
|
9557
|
+
|
|
9558
|
+
/**
|
|
9559
|
+
* Service with calculations methods for properties related with other entities.
|
|
9560
|
+
* Logic here works like collections methods but for several entities
|
|
9561
|
+
*/
|
|
9562
|
+
class PropertyCalculationService {
|
|
9563
|
+
getTaxPosition(transactions, depreciations) {
|
|
9564
|
+
// @TODO hack: math abs added because we have mismatching of real values signs
|
|
9565
|
+
return transactions.cashPosition - Math.abs(depreciations.claimAmount);
|
|
9566
|
+
}
|
|
9567
|
+
getTaxPosition$(transactions$, depreciations$) {
|
|
9568
|
+
return combineLatest([
|
|
9569
|
+
transactions$,
|
|
9570
|
+
depreciations$
|
|
9571
|
+
]).pipe(map(([transactions, depreciations]) => {
|
|
9572
|
+
return this.getTaxPosition(transactions, depreciations);
|
|
9573
|
+
}));
|
|
9574
|
+
}
|
|
9575
|
+
taxPositionGrowth(properties, transactions, depreciations) {
|
|
9576
|
+
const taxPosition = this.getTaxPosition(transactions, depreciations);
|
|
9577
|
+
// check if taxPosition = 0 to avoid division by zero
|
|
9578
|
+
if (!taxPosition) {
|
|
9579
|
+
return 0;
|
|
9580
|
+
}
|
|
9581
|
+
return (taxPosition - properties.forecastedTaxPosition) / taxPosition;
|
|
9582
|
+
}
|
|
9583
|
+
taxPositionGrowth$(properties$, transactions$, depreciations$) {
|
|
9584
|
+
return combineLatest([
|
|
9585
|
+
properties$,
|
|
9586
|
+
transactions$,
|
|
9587
|
+
depreciations$
|
|
9588
|
+
]).pipe(map(([properties, transactions, depreciations]) => {
|
|
9589
|
+
return this.taxPositionGrowth(properties, transactions, depreciations);
|
|
9590
|
+
}));
|
|
9591
|
+
}
|
|
9592
|
+
getRentalReturn(properties, transactions) {
|
|
9593
|
+
return transactions.claimIncome / properties.marketValue;
|
|
9594
|
+
}
|
|
9595
|
+
getLoanAmount(properties, bankAccounts, loans) {
|
|
9596
|
+
return properties.items.reduce((totalAmount, property) => {
|
|
9597
|
+
return totalAmount + bankAccounts.items
|
|
9598
|
+
.reduce((propertyAmount, bankAccount) => {
|
|
9599
|
+
var _a;
|
|
9600
|
+
return propertyAmount + bankAccount.getPropertyPercentage(property.id) * (((_a = loans.getByBankAccountId(bankAccount.id)) === null || _a === void 0 ? void 0 : _a.amount) || 0);
|
|
9601
|
+
}, 0);
|
|
9602
|
+
}, 0);
|
|
9603
|
+
}
|
|
9604
|
+
getLoanValue(properties, bankAccounts) {
|
|
9605
|
+
return properties.items.reduce((totalAmount, property) => {
|
|
9606
|
+
return totalAmount + bankAccounts.items
|
|
9607
|
+
.reduce((propertyAmount, bankAccount) => {
|
|
9608
|
+
return propertyAmount + bankAccount.getPropertyBalanceAmount(property.id);
|
|
9609
|
+
}, 0);
|
|
9610
|
+
}, 0);
|
|
9611
|
+
}
|
|
9612
|
+
/**
|
|
9613
|
+
* LVR
|
|
9614
|
+
*/
|
|
9615
|
+
getLvr(properties, bankAccounts) {
|
|
9616
|
+
// Math abs is required for correct percentage calculation
|
|
9617
|
+
return Math.abs(this.getLoanValue(properties, bankAccounts)) / properties.marketValue;
|
|
9618
|
+
}
|
|
9619
|
+
getLvr$(properties$, bankAccounts$) {
|
|
9620
|
+
return combineLatest([
|
|
9621
|
+
properties$,
|
|
9622
|
+
bankAccounts$
|
|
9623
|
+
]).pipe(map(([properties, bankAccounts]) => {
|
|
9624
|
+
return this.getLvr(properties, bankAccounts);
|
|
9625
|
+
}));
|
|
9626
|
+
}
|
|
9627
|
+
getLvrCommencement(properties, loans, bankAccounts) {
|
|
9628
|
+
// Math abs is required for correct percentage calculation
|
|
9629
|
+
return Math.abs(this.getLoanAmount(properties, bankAccounts, loans)) / properties.purchasePrice;
|
|
9630
|
+
}
|
|
9631
|
+
getLvrCommencement$(properties$, bankAccounts$, loans$) {
|
|
9632
|
+
return combineLatest([
|
|
9633
|
+
properties$,
|
|
9634
|
+
bankAccounts$,
|
|
9635
|
+
loans$
|
|
9636
|
+
]).pipe(map(([properties, bankAccounts, loans]) => {
|
|
9637
|
+
return this.getLvrCommencement(properties, loans, bankAccounts);
|
|
9638
|
+
}));
|
|
9639
|
+
}
|
|
9640
|
+
getLvrGrowth(properties, bankAccounts, loans) {
|
|
9641
|
+
const lvr = this.getLvr(properties, bankAccounts);
|
|
9642
|
+
if (!lvr) {
|
|
9643
|
+
// check if lvr = 0 to avoid division by zero
|
|
9644
|
+
return 0;
|
|
9645
|
+
}
|
|
9646
|
+
return (lvr - this.getLvrCommencement(properties, loans, bankAccounts)) / lvr;
|
|
9647
|
+
}
|
|
9648
|
+
getLvrGrowth$(properties$, bankAccounts$, loans$) {
|
|
9649
|
+
return combineLatest([
|
|
9650
|
+
properties$,
|
|
9651
|
+
bankAccounts$,
|
|
9652
|
+
loans$
|
|
9653
|
+
]).pipe(map(([properties, bankAccounts, loans]) => {
|
|
9654
|
+
return this.getLvrGrowth(properties, bankAccounts, loans);
|
|
9655
|
+
}));
|
|
9656
|
+
}
|
|
9657
|
+
getEquityPosition(properties, bankAccounts) {
|
|
9658
|
+
// Math abs is required for correct percentage calculation
|
|
9659
|
+
return properties.marketValue - Math.abs(this.getLoanValue(properties, bankAccounts));
|
|
9660
|
+
}
|
|
9661
|
+
getPurchaseEquity(properties, bankAccounts, loans) {
|
|
9662
|
+
// Math abs is required for correct percentage calculation
|
|
9663
|
+
return properties.purchasePrice - Math.abs(this.getLoanAmount(properties, bankAccounts, loans));
|
|
9664
|
+
}
|
|
9665
|
+
}
|
|
9666
|
+
PropertyCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyCalculationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9667
|
+
PropertyCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyCalculationService, providedIn: 'root' });
|
|
9668
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyCalculationService, decorators: [{
|
|
9669
|
+
type: Injectable,
|
|
9670
|
+
args: [{
|
|
9671
|
+
providedIn: 'root'
|
|
9672
|
+
}]
|
|
9673
|
+
}] });
|
|
9674
|
+
|
|
9675
|
+
/**
|
|
9676
|
+
* Service for work with Property Categories
|
|
9677
|
+
*/
|
|
9678
|
+
class PropertyCategoryService extends RestService {
|
|
9679
|
+
constructor() {
|
|
9680
|
+
super(...arguments);
|
|
9681
|
+
this.modelClass = PropertyCategory;
|
|
9682
|
+
this.url = 'properties/categories';
|
|
9683
|
+
}
|
|
9684
|
+
}
|
|
9685
|
+
PropertyCategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyCategoryService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
9686
|
+
PropertyCategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyCategoryService, providedIn: 'root' });
|
|
9687
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PropertyCategoryService, decorators: [{
|
|
9688
|
+
type: Injectable,
|
|
9689
|
+
args: [{
|
|
9690
|
+
providedIn: 'root'
|
|
9691
|
+
}]
|
|
9692
|
+
}] });
|
|
9693
|
+
|
|
9694
|
+
/**
|
|
9695
|
+
* Class for work with Property Documents
|
|
9696
|
+
*/
|
|
9697
|
+
class PropertyDocumentService extends RestService {
|
|
9698
|
+
constructor(http, eventDispatcherService, environment) {
|
|
9699
|
+
super(http, eventDispatcherService, environment);
|
|
9700
|
+
this.http = http;
|
|
9701
|
+
this.eventDispatcherService = eventDispatcherService;
|
|
9702
|
+
this.environment = environment;
|
|
9703
|
+
this.modelClass = PropertyDocument;
|
|
9704
|
+
this.url = 'properties/documents';
|
|
9705
|
+
this.listenEvents();
|
|
9706
|
+
}
|
|
9707
|
+
/**
|
|
9708
|
+
* Add new Property Document
|
|
9709
|
+
*/
|
|
9710
|
+
upload(file, propertyId) {
|
|
9711
|
+
// create formData object with provided file
|
|
9712
|
+
const formDataDocument = new FormData();
|
|
9713
|
+
formDataDocument.append('file', file);
|
|
9714
|
+
return this.http.post(`${this.environment.apiV2}/properties/${propertyId}/documents`, formDataDocument).pipe(map((documentBase) => {
|
|
9715
|
+
const newDocument = plainToClass(PropertyDocument, documentBase);
|
|
9716
|
+
if (this.cache) {
|
|
9717
|
+
this.cache.push(newDocument);
|
|
9718
|
+
this.updateCache();
|
|
9719
|
+
}
|
|
9720
|
+
return newDocument;
|
|
9721
|
+
}));
|
|
9722
|
+
}
|
|
9723
|
+
/**
|
|
9724
|
+
* Get documents by property id
|
|
9725
|
+
* @param propertyId to get desired documents
|
|
9726
|
+
*/
|
|
9727
|
+
getByPropertyId(propertyId) {
|
|
9728
|
+
return this.get()
|
|
9729
|
+
.pipe(map((documents) => {
|
|
9730
|
+
return documents
|
|
9731
|
+
.filter((document) => document.property.id === propertyId);
|
|
9182
9732
|
}));
|
|
9183
9733
|
}
|
|
9184
9734
|
listenEvents() {
|
|
@@ -9489,615 +10039,233 @@ class SubscriptionService {
|
|
|
9489
10039
|
*/
|
|
9490
10040
|
billingRedirect(returnUrl) {
|
|
9491
10041
|
this.http.get(`${this.environment.apiV2}/stripe/billing-portal-session`, {
|
|
9492
|
-
params: { returnUrl }
|
|
9493
|
-
}).subscribe((response) => {
|
|
9494
|
-
window.location.replace(response.url);
|
|
9495
|
-
});
|
|
9496
|
-
}
|
|
9497
|
-
getPayments() {
|
|
9498
|
-
if (!this._servicePayments) {
|
|
9499
|
-
this.http.get(`${this.environment.apiV2}/service-payments`).subscribe((response) => {
|
|
9500
|
-
this._servicePayments = response.map((item) => plainToClass(ServicePayment, item));
|
|
9501
|
-
this.servicePaymentsSubject.next(this._servicePayments);
|
|
9502
|
-
});
|
|
9503
|
-
}
|
|
9504
|
-
return this.servicePaymentsSubject.asObservable();
|
|
9505
|
-
}
|
|
9506
|
-
/**
|
|
9507
|
-
* Get difference between current subscription and selected new subscription
|
|
9508
|
-
*/
|
|
9509
|
-
getProrationCost(items) {
|
|
9510
|
-
return this.http.post(`${this.environment.apiV2}/subscriptions/proration-cost`, items).pipe(map((prorationCost) => {
|
|
9511
|
-
return prorationCost;
|
|
9512
|
-
}));
|
|
9513
|
-
}
|
|
9514
|
-
/**
|
|
9515
|
-
* Change subscription plan
|
|
9516
|
-
*/
|
|
9517
|
-
changeSubscription(items) {
|
|
9518
|
-
return this.http.put(`${this.environment.apiV2}/subscriptions/items`, items);
|
|
9519
|
-
}
|
|
9520
|
-
listenSubscriptions() {
|
|
9521
|
-
this.sseService.on(`serviceSubscriptions`)
|
|
9522
|
-
.pipe(map((event) => plainToClass(ServiceSubscription, event)))
|
|
9523
|
-
.subscribe((subscription) => {
|
|
9524
|
-
this.getSubscription(true).subscribe();
|
|
9525
|
-
this.subscriptionChangeSubject.next(subscription);
|
|
9526
|
-
this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED, null));
|
|
9527
|
-
});
|
|
9528
|
-
}
|
|
9529
|
-
}
|
|
9530
|
-
SubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SubscriptionService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9531
|
-
SubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SubscriptionService, providedIn: 'root' });
|
|
9532
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SubscriptionService, decorators: [{
|
|
9533
|
-
type: Injectable,
|
|
9534
|
-
args: [{
|
|
9535
|
-
providedIn: 'root'
|
|
9536
|
-
}]
|
|
9537
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
|
|
9538
|
-
type: Inject,
|
|
9539
|
-
args: ['environment']
|
|
9540
|
-
}] }]; } });
|
|
9541
|
-
|
|
9542
|
-
/**
|
|
9543
|
-
* Service to work with tax review
|
|
9544
|
-
*/
|
|
9545
|
-
class TaxReviewService extends RestService {
|
|
9546
|
-
constructor(http, eventDispatcherService, environment) {
|
|
9547
|
-
super(http, eventDispatcherService, environment);
|
|
9548
|
-
this.http = http;
|
|
9549
|
-
this.eventDispatcherService = eventDispatcherService;
|
|
9550
|
-
this.environment = environment;
|
|
9551
|
-
this.url = 'tax-reviews';
|
|
9552
|
-
this.modelClass = TaxReview;
|
|
9553
|
-
this.listenEvents();
|
|
9554
|
-
}
|
|
9555
|
-
/**
|
|
9556
|
-
* Listen events from SSE and Event Dispatcher services
|
|
9557
|
-
*/
|
|
9558
|
-
listenEvents() {
|
|
9559
|
-
this.listenFirmChanges();
|
|
9560
|
-
this.listenClientTransfer();
|
|
9561
|
-
}
|
|
9562
|
-
/**
|
|
9563
|
-
* Add new Tax Review (request from client to firm)
|
|
9564
|
-
* @param finYear
|
|
9565
|
-
*/
|
|
9566
|
-
request(finYear) {
|
|
9567
|
-
return this.http.post(`${this.environment.apiV2}/${this.url}?financialYear=${finYear}`, {})
|
|
9568
|
-
.pipe(map((newTaxReview) => {
|
|
9569
|
-
const taxReview = plainToClass(TaxReview, newTaxReview);
|
|
9570
|
-
const tempCache = _.cloneDeep(this.cache);
|
|
9571
|
-
tempCache.push(taxReview);
|
|
9572
|
-
this.cache = tempCache;
|
|
9573
|
-
this.updateCache();
|
|
9574
|
-
return taxReview;
|
|
9575
|
-
}));
|
|
9576
|
-
}
|
|
9577
|
-
/**
|
|
9578
|
-
* Update tax review
|
|
9579
|
-
* @param taxReview to be updated
|
|
9580
|
-
*/
|
|
9581
|
-
update(taxReview) {
|
|
9582
|
-
return this.http.put(`${this.environment.apiV2}/${this.url}/${taxReview.id}`, taxReview)
|
|
9583
|
-
.pipe(map((updatedTaxReview) => {
|
|
9584
|
-
const updatedInstance = plainToClass(TaxReview, updatedTaxReview);
|
|
9585
|
-
this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TAX_REVIEW_UPDATED, updatedInstance));
|
|
9586
|
-
const tempCache = _.cloneDeep(this.cache);
|
|
9587
|
-
replace(tempCache, updatedInstance);
|
|
9588
|
-
this.cache = tempCache;
|
|
9589
|
-
this.updateCache();
|
|
9590
|
-
return updatedInstance;
|
|
9591
|
-
}));
|
|
9592
|
-
}
|
|
9593
|
-
/**
|
|
9594
|
-
* Clear cache when user reject firm
|
|
9595
|
-
*/
|
|
9596
|
-
listenFirmChanges() {
|
|
9597
|
-
this.eventDispatcherService.on([AppEventTypeEnum.CLIENT_MOVEMENT_CLOSED, AppEventTypeEnum.CLIENT_INVITE_ACCEPTED])
|
|
9598
|
-
.subscribe(() => {
|
|
9599
|
-
this.cache = [];
|
|
9600
|
-
this.updateCache();
|
|
9601
|
-
});
|
|
9602
|
-
}
|
|
9603
|
-
/**
|
|
9604
|
-
* Update firm for all transferred clients
|
|
9605
|
-
* @private
|
|
9606
|
-
*/
|
|
9607
|
-
listenClientTransfer() {
|
|
9608
|
-
this.eventDispatcherService.on(AppEventTypeEnum.CLIENT_TRANSFER_TO_OTHER_EMPLOYEE)
|
|
9609
|
-
.subscribe((transferredClients) => {
|
|
9610
|
-
const tempCache = _.cloneDeep(this.cache);
|
|
9611
|
-
transferredClients.forEach((transferredClient) => {
|
|
9612
|
-
const taxReviewIndex = tempCache.findIndex((taxReview) => taxReview.id === transferredClient.id);
|
|
9613
|
-
// @TODO vik
|
|
9614
|
-
// tempCache[taxReviewIndex].employee = transferredClient.accountant;
|
|
9615
|
-
});
|
|
9616
|
-
this.cache = tempCache;
|
|
9617
|
-
this.updateCache();
|
|
9618
|
-
});
|
|
9619
|
-
}
|
|
9620
|
-
}
|
|
9621
|
-
TaxReviewService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9622
|
-
TaxReviewService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewService, providedIn: 'root' });
|
|
9623
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewService, decorators: [{
|
|
9624
|
-
type: Injectable,
|
|
9625
|
-
args: [{
|
|
9626
|
-
providedIn: 'root'
|
|
9627
|
-
}]
|
|
9628
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
9629
|
-
type: Inject,
|
|
9630
|
-
args: ['environment']
|
|
9631
|
-
}] }]; } });
|
|
9632
|
-
|
|
9633
|
-
/**
|
|
9634
|
-
* Service to work with tax review history
|
|
9635
|
-
*/
|
|
9636
|
-
class TaxReviewHistoryService extends RestService {
|
|
9637
|
-
constructor(http, eventDispatcherService, environment) {
|
|
9638
|
-
super(http, eventDispatcherService, environment);
|
|
9639
|
-
this.http = http;
|
|
9640
|
-
this.eventDispatcherService = eventDispatcherService;
|
|
9641
|
-
this.environment = environment;
|
|
9642
|
-
this.url = 'tax-reviews/history';
|
|
9643
|
-
this.modelClass = TaxReview;
|
|
9644
|
-
// subscribe on tax review updating
|
|
9645
|
-
eventDispatcherService.on(AppEventTypeEnum.TAX_REVIEW_UPDATED).subscribe((taxReview) => {
|
|
9646
|
-
const tempCache = _.cloneDeep(this.cache);
|
|
9647
|
-
// insert element at the beginning of the array
|
|
9648
|
-
tempCache.unshift(taxReview);
|
|
9649
|
-
this.cache = tempCache;
|
|
9650
|
-
this.updateCache();
|
|
9651
|
-
});
|
|
9652
|
-
}
|
|
9653
|
-
}
|
|
9654
|
-
TaxReviewHistoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewHistoryService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9655
|
-
TaxReviewHistoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewHistoryService, providedIn: 'root' });
|
|
9656
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewHistoryService, decorators: [{
|
|
9657
|
-
type: Injectable,
|
|
9658
|
-
args: [{
|
|
9659
|
-
providedIn: 'root'
|
|
9660
|
-
}]
|
|
9661
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
9662
|
-
type: Inject,
|
|
9663
|
-
args: ['environment']
|
|
9664
|
-
}] }]; } });
|
|
9665
|
-
|
|
9666
|
-
/**
|
|
9667
|
-
* Service to work with tax summary logic
|
|
9668
|
-
*/
|
|
9669
|
-
class TaxSummaryService {
|
|
9670
|
-
constructor(http, eventDispatcherService, environment) {
|
|
9671
|
-
this.http = http;
|
|
9672
|
-
this.eventDispatcherService = eventDispatcherService;
|
|
9673
|
-
this.environment = environment;
|
|
9674
|
-
this.taxSummaryActualsSubject = new ReplaySubject(1);
|
|
9675
|
-
this.taxSummaryForecastsSubject = new ReplaySubject(1);
|
|
9676
|
-
this.listenEvents();
|
|
9677
|
-
}
|
|
9678
|
-
listenEvents() {
|
|
9679
|
-
this.listenToIncomeSourceForecastsEvents();
|
|
9680
|
-
}
|
|
9681
|
-
/**
|
|
9682
|
-
* Get actual tax summary items
|
|
9683
|
-
*/
|
|
9684
|
-
getActuals() {
|
|
9685
|
-
this.http.get(`${this.environment.apiV2}/tax-summary/${TaxSummaryTypeEnum.ACTUALS}`, {})
|
|
9686
|
-
.subscribe((response) => {
|
|
9687
|
-
const taxSummary = plainToClass(TaxSummary, response);
|
|
9688
|
-
this.taxSummaryActualsSubject.next(taxSummary);
|
|
9689
|
-
return taxSummary;
|
|
10042
|
+
params: { returnUrl }
|
|
10043
|
+
}).subscribe((response) => {
|
|
10044
|
+
window.location.replace(response.url);
|
|
9690
10045
|
});
|
|
9691
|
-
|
|
10046
|
+
}
|
|
10047
|
+
getPayments() {
|
|
10048
|
+
if (!this._servicePayments) {
|
|
10049
|
+
this.http.get(`${this.environment.apiV2}/service-payments`).subscribe((response) => {
|
|
10050
|
+
this._servicePayments = response.map((item) => plainToClass(ServicePayment, item));
|
|
10051
|
+
this.servicePaymentsSubject.next(this._servicePayments);
|
|
10052
|
+
});
|
|
10053
|
+
}
|
|
10054
|
+
return this.servicePaymentsSubject.asObservable();
|
|
9692
10055
|
}
|
|
9693
10056
|
/**
|
|
9694
|
-
* Get
|
|
10057
|
+
* Get difference between current subscription and selected new subscription
|
|
9695
10058
|
*/
|
|
9696
|
-
|
|
9697
|
-
this.http.
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
this.taxSummaryForecastsSubject.next(taxSummary);
|
|
9701
|
-
return taxSummary;
|
|
9702
|
-
});
|
|
9703
|
-
return this.taxSummaryForecastsSubject.asObservable();
|
|
10059
|
+
getProrationCost(items) {
|
|
10060
|
+
return this.http.post(`${this.environment.apiV2}/subscriptions/proration-cost`, items).pipe(map((prorationCost) => {
|
|
10061
|
+
return prorationCost;
|
|
10062
|
+
}));
|
|
9704
10063
|
}
|
|
9705
10064
|
/**
|
|
9706
|
-
*
|
|
10065
|
+
* Change subscription plan
|
|
9707
10066
|
*/
|
|
9708
|
-
|
|
9709
|
-
this.
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
10067
|
+
changeSubscription(items) {
|
|
10068
|
+
return this.http.put(`${this.environment.apiV2}/subscriptions/items`, items);
|
|
10069
|
+
}
|
|
10070
|
+
listenSubscriptions() {
|
|
10071
|
+
this.sseService.on(`serviceSubscriptions`)
|
|
10072
|
+
.pipe(map((event) => plainToClass(ServiceSubscription, event)))
|
|
10073
|
+
.subscribe((subscription) => {
|
|
10074
|
+
this.getSubscription(true).subscribe();
|
|
10075
|
+
this.subscriptionChangeSubject.next(subscription);
|
|
10076
|
+
this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED, null));
|
|
9713
10077
|
});
|
|
9714
10078
|
}
|
|
9715
10079
|
}
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type:
|
|
10080
|
+
SubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SubscriptionService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10081
|
+
SubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SubscriptionService, providedIn: 'root' });
|
|
10082
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SubscriptionService, decorators: [{
|
|
9719
10083
|
type: Injectable,
|
|
9720
10084
|
args: [{
|
|
9721
10085
|
providedIn: 'root'
|
|
9722
10086
|
}]
|
|
9723
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
10087
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
|
|
9724
10088
|
type: Inject,
|
|
9725
10089
|
args: ['environment']
|
|
9726
10090
|
}] }]; } });
|
|
9727
10091
|
|
|
9728
10092
|
/**
|
|
9729
|
-
*
|
|
9730
|
-
*/
|
|
9731
|
-
class ToastService {
|
|
9732
|
-
constructor() {
|
|
9733
|
-
this.toast$ = new ReplaySubject(1);
|
|
9734
|
-
}
|
|
9735
|
-
get() {
|
|
9736
|
-
return this.toast$.asObservable();
|
|
9737
|
-
}
|
|
9738
|
-
add(toast) {
|
|
9739
|
-
this.toast$.next(toast);
|
|
9740
|
-
}
|
|
9741
|
-
success(message) {
|
|
9742
|
-
this.add(plainToClass(Toast, {
|
|
9743
|
-
type: ToastTypeEnum.SUCCESS,
|
|
9744
|
-
title: 'Success!',
|
|
9745
|
-
message,
|
|
9746
|
-
}));
|
|
9747
|
-
}
|
|
9748
|
-
warning(message) {
|
|
9749
|
-
this.add(plainToClass(Toast, {
|
|
9750
|
-
type: ToastTypeEnum.WARNING,
|
|
9751
|
-
title: 'Warning!',
|
|
9752
|
-
message,
|
|
9753
|
-
}));
|
|
9754
|
-
}
|
|
9755
|
-
error(message) {
|
|
9756
|
-
this.add(plainToClass(Toast, {
|
|
9757
|
-
type: ToastTypeEnum.ERROR,
|
|
9758
|
-
title: 'Error!',
|
|
9759
|
-
message,
|
|
9760
|
-
}));
|
|
9761
|
-
}
|
|
9762
|
-
info(message) {
|
|
9763
|
-
this.add(plainToClass(Toast, {
|
|
9764
|
-
type: ToastTypeEnum.INFO,
|
|
9765
|
-
title: 'Information',
|
|
9766
|
-
message,
|
|
9767
|
-
}));
|
|
9768
|
-
}
|
|
9769
|
-
}
|
|
9770
|
-
ToastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9771
|
-
ToastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ToastService, providedIn: 'root' });
|
|
9772
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ToastService, decorators: [{
|
|
9773
|
-
type: Injectable,
|
|
9774
|
-
args: [{
|
|
9775
|
-
providedIn: 'root'
|
|
9776
|
-
}]
|
|
9777
|
-
}] });
|
|
9778
|
-
|
|
9779
|
-
function enumToList(data) {
|
|
9780
|
-
const list = [];
|
|
9781
|
-
for (const key in data) {
|
|
9782
|
-
if (Number(key) >= 0) {
|
|
9783
|
-
list.push({
|
|
9784
|
-
label: data[key],
|
|
9785
|
-
value: Number(key)
|
|
9786
|
-
});
|
|
9787
|
-
}
|
|
9788
|
-
}
|
|
9789
|
-
return list;
|
|
9790
|
-
}
|
|
9791
|
-
|
|
9792
|
-
var MessagesEnum;
|
|
9793
|
-
(function (MessagesEnum) {
|
|
9794
|
-
MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
|
|
9795
|
-
MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
|
|
9796
|
-
MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
|
|
9797
|
-
})(MessagesEnum || (MessagesEnum = {}));
|
|
9798
|
-
|
|
9799
|
-
/**
|
|
9800
|
-
* Service for transactions business logic
|
|
10093
|
+
* Service to work with tax review
|
|
9801
10094
|
*/
|
|
9802
|
-
class
|
|
9803
|
-
constructor(http, eventDispatcherService, environment
|
|
10095
|
+
class TaxReviewService extends RestService {
|
|
10096
|
+
constructor(http, eventDispatcherService, environment) {
|
|
9804
10097
|
super(http, eventDispatcherService, environment);
|
|
9805
10098
|
this.http = http;
|
|
9806
10099
|
this.eventDispatcherService = eventDispatcherService;
|
|
9807
10100
|
this.environment = environment;
|
|
9808
|
-
this.
|
|
9809
|
-
|
|
9810
|
-
this.url = 'transactions';
|
|
9811
|
-
this.modelClass = Transaction;
|
|
9812
|
-
this.transactionDeleted = new EventEmitter();
|
|
10101
|
+
this.url = 'tax-reviews';
|
|
10102
|
+
this.modelClass = TaxReview;
|
|
9813
10103
|
this.listenEvents();
|
|
9814
10104
|
}
|
|
9815
10105
|
/**
|
|
9816
|
-
* Listen events from Event Dispatcher services
|
|
10106
|
+
* Listen events from SSE and Event Dispatcher services
|
|
9817
10107
|
*/
|
|
9818
10108
|
listenEvents() {
|
|
9819
|
-
this.
|
|
9820
|
-
this.
|
|
9821
|
-
}
|
|
9822
|
-
/**
|
|
9823
|
-
* get list of all user's TaxTank transactions
|
|
9824
|
-
*/
|
|
9825
|
-
get() {
|
|
9826
|
-
if (!this.cache) {
|
|
9827
|
-
// set cache as default empty array to avoid multiple backend requests
|
|
9828
|
-
this.cache = [];
|
|
9829
|
-
this.fetch()
|
|
9830
|
-
.subscribe((transactions) => {
|
|
9831
|
-
this.cache = transactions;
|
|
9832
|
-
this.updateCache();
|
|
9833
|
-
});
|
|
9834
|
-
}
|
|
9835
|
-
return this.cacheSubject.asObservable().pipe(
|
|
9836
|
-
// assign child transactions (fees) to parent transactions
|
|
9837
|
-
map((transactions) => {
|
|
9838
|
-
transactions.forEach((transaction) => {
|
|
9839
|
-
transaction.transactions = transactions
|
|
9840
|
-
// get list of child transactions
|
|
9841
|
-
.filter((t) => t.parentTransaction && t.parentTransaction.id === transaction.id);
|
|
9842
|
-
});
|
|
9843
|
-
sort(transactions, 'date', false);
|
|
9844
|
-
return transactions;
|
|
9845
|
-
}));
|
|
9846
|
-
}
|
|
9847
|
-
/**
|
|
9848
|
-
* Add single new transaction
|
|
9849
|
-
* @param model New Transaction instance for saving
|
|
9850
|
-
*/
|
|
9851
|
-
add(model) {
|
|
9852
|
-
// we don't have POST API endpoint for single transaction
|
|
9853
|
-
return this.addBatch([model])
|
|
9854
|
-
.pipe(map((newTransactions) => {
|
|
9855
|
-
// @TODO alex
|
|
9856
|
-
this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTION_CREATED, newTransactions[0]));
|
|
9857
|
-
return newTransactions[0];
|
|
9858
|
-
}));
|
|
9859
|
-
}
|
|
9860
|
-
/**
|
|
9861
|
-
* get transactions related with property
|
|
9862
|
-
*/
|
|
9863
|
-
getByPropertyId(propertyId) {
|
|
9864
|
-
return this.get()
|
|
9865
|
-
.pipe(map((transactions) => {
|
|
9866
|
-
return transactions.filter((transaction) => {
|
|
9867
|
-
var _a;
|
|
9868
|
-
return ((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id) === propertyId;
|
|
9869
|
-
});
|
|
9870
|
-
}));
|
|
9871
|
-
}
|
|
9872
|
-
/**
|
|
9873
|
-
* get list of transactions with tank type 'Work'
|
|
9874
|
-
*/
|
|
9875
|
-
getWorkTransactions() {
|
|
9876
|
-
return this.get()
|
|
9877
|
-
.pipe(map((transactions) => {
|
|
9878
|
-
return transactions.filter((transaction) => transaction.isWorkTank());
|
|
9879
|
-
}));
|
|
9880
|
-
}
|
|
9881
|
-
/**
|
|
9882
|
-
* get list of taxable transactions with tank type 'Work'
|
|
9883
|
-
*/
|
|
9884
|
-
getTaxableWorkTransactions() {
|
|
9885
|
-
return this.getWorkTransactions()
|
|
9886
|
-
.pipe(map((transactions) => {
|
|
9887
|
-
return transactions.filter((transaction) => !!transaction.chartAccounts.taxReturnItem);
|
|
9888
|
-
}));
|
|
10109
|
+
this.listenFirmChanges();
|
|
10110
|
+
this.listenClientTransfer();
|
|
9889
10111
|
}
|
|
9890
10112
|
/**
|
|
9891
|
-
*
|
|
9892
|
-
* @param
|
|
10113
|
+
* Add new Tax Review (request from client to firm)
|
|
10114
|
+
* @param finYear
|
|
9893
10115
|
*/
|
|
9894
|
-
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
const
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
transaction.id = response[index].id;
|
|
9904
|
-
addedTransactions[index].file = transaction.file;
|
|
9905
|
-
this.uploadReceipt(addedTransactions[index]);
|
|
9906
|
-
}
|
|
9907
|
-
// @TODO Viktor: implement API for saving of nested transactions
|
|
9908
|
-
// add child transactions if exist
|
|
9909
|
-
if (transaction.transactions.length) {
|
|
9910
|
-
transaction.transactions.forEach((childTransaction) => {
|
|
9911
|
-
childTransaction.parentTransaction = plainToClass(Transaction, { id: addedTransactions[index].id });
|
|
9912
|
-
});
|
|
9913
|
-
this.addBatch(transaction.transactions).subscribe();
|
|
9914
|
-
}
|
|
9915
|
-
// add transfer transaction to cache
|
|
9916
|
-
if (transaction.operation === TransactionOperationEnum.TRANSFER) {
|
|
9917
|
-
addedTransactions.push(addedTransactions[0].transfer);
|
|
9918
|
-
}
|
|
9919
|
-
});
|
|
9920
|
-
if (this.cache) {
|
|
9921
|
-
this.cache.push(...addedTransactions);
|
|
9922
|
-
this.updateCache();
|
|
9923
|
-
}
|
|
9924
|
-
this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
|
|
9925
|
-
this.toastService.success(MessagesEnum.CREATED_MESSAGE);
|
|
9926
|
-
return addedTransactions;
|
|
10116
|
+
request(finYear) {
|
|
10117
|
+
return this.http.post(`${this.environment.apiV2}/${this.url}?financialYear=${finYear}`, {})
|
|
10118
|
+
.pipe(map((newTaxReview) => {
|
|
10119
|
+
const taxReview = plainToClass(TaxReview, newTaxReview);
|
|
10120
|
+
const tempCache = _.cloneDeep(this.cache);
|
|
10121
|
+
tempCache.push(taxReview);
|
|
10122
|
+
this.cache = tempCache;
|
|
10123
|
+
this.updateCache();
|
|
10124
|
+
return taxReview;
|
|
9927
10125
|
}));
|
|
9928
10126
|
}
|
|
9929
10127
|
/**
|
|
9930
|
-
*
|
|
9931
|
-
* @param
|
|
10128
|
+
* Update tax review
|
|
10129
|
+
* @param taxReview to be updated
|
|
9932
10130
|
*/
|
|
9933
|
-
update(
|
|
9934
|
-
return this.http.put(`${this.environment.apiV2}/${this.url}/${
|
|
9935
|
-
.pipe(map((
|
|
9936
|
-
const
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
this.uploadReceipt(updatedTransaction);
|
|
9942
|
-
}
|
|
9943
|
-
// @TODO Viktor: implement API for saving of nested transactions
|
|
9944
|
-
if (transaction.transactions.length) {
|
|
9945
|
-
// add parent transaction to child transactions
|
|
9946
|
-
transaction.transactions.forEach((childTransaction) => {
|
|
9947
|
-
childTransaction.parentTransaction = plainToClass(Transaction, { id: updatedTransaction.id });
|
|
9948
|
-
});
|
|
9949
|
-
// separate child transactions by id existing to define add or update action.
|
|
9950
|
-
const childTransactionsToUpdate = transaction.transactions.filter((t) => t.id);
|
|
9951
|
-
const childTransactionsToAdd = transaction.transactions.filter((t) => !t.id);
|
|
9952
|
-
// update child transactions
|
|
9953
|
-
if (childTransactionsToUpdate.length) {
|
|
9954
|
-
this.updateBatch(childTransactionsToUpdate).subscribe();
|
|
9955
|
-
}
|
|
9956
|
-
// add child transactions
|
|
9957
|
-
if (childTransactionsToAdd.length) {
|
|
9958
|
-
this.addBatch(childTransactionsToAdd).subscribe();
|
|
9959
|
-
}
|
|
9960
|
-
}
|
|
9961
|
-
this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
|
|
9962
|
-
replace(this.cache, updatedTransaction);
|
|
10131
|
+
update(taxReview) {
|
|
10132
|
+
return this.http.put(`${this.environment.apiV2}/${this.url}/${taxReview.id}`, taxReview)
|
|
10133
|
+
.pipe(map((updatedTaxReview) => {
|
|
10134
|
+
const updatedInstance = plainToClass(TaxReview, updatedTaxReview);
|
|
10135
|
+
this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.TAX_REVIEW_UPDATED, updatedInstance));
|
|
10136
|
+
const tempCache = _.cloneDeep(this.cache);
|
|
10137
|
+
replace(tempCache, updatedInstance);
|
|
10138
|
+
this.cache = tempCache;
|
|
9963
10139
|
this.updateCache();
|
|
9964
|
-
return
|
|
10140
|
+
return updatedInstance;
|
|
9965
10141
|
}));
|
|
9966
10142
|
}
|
|
9967
10143
|
/**
|
|
9968
|
-
*
|
|
9969
|
-
* @param transactions list of transactions for updating
|
|
10144
|
+
* Clear cache when user reject firm
|
|
9970
10145
|
*/
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
.
|
|
9974
|
-
|
|
9975
|
-
updatedTransactions.forEach((updatedTransaction) => {
|
|
9976
|
-
replace(this.cache, updatedTransaction);
|
|
9977
|
-
});
|
|
10146
|
+
listenFirmChanges() {
|
|
10147
|
+
this.eventDispatcherService.on([AppEventTypeEnum.CLIENT_MOVEMENT_CLOSED, AppEventTypeEnum.CLIENT_INVITE_ACCEPTED])
|
|
10148
|
+
.subscribe(() => {
|
|
10149
|
+
this.cache = [];
|
|
9978
10150
|
this.updateCache();
|
|
9979
|
-
|
|
9980
|
-
}));
|
|
10151
|
+
});
|
|
9981
10152
|
}
|
|
9982
10153
|
/**
|
|
9983
|
-
*
|
|
9984
|
-
* @
|
|
10154
|
+
* Update firm for all transferred clients
|
|
10155
|
+
* @private
|
|
9985
10156
|
*/
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
.
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
// get id of related transfer transaction
|
|
9995
|
-
if (model.transfer) {
|
|
9996
|
-
// just take id if we delete source transaction
|
|
9997
|
-
ids.push(model.transfer.id);
|
|
9998
|
-
}
|
|
9999
|
-
else {
|
|
10000
|
-
// find source transaction id if we delete destination transaction
|
|
10001
|
-
ids.push(this.cache.find((t) => t.transfer.id === model.id).id);
|
|
10002
|
-
}
|
|
10003
|
-
return !ids.includes(transaction.id);
|
|
10004
|
-
}
|
|
10005
|
-
return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
|
|
10157
|
+
listenClientTransfer() {
|
|
10158
|
+
this.eventDispatcherService.on(AppEventTypeEnum.CLIENT_TRANSFER_TO_OTHER_EMPLOYEE)
|
|
10159
|
+
.subscribe((transferredClients) => {
|
|
10160
|
+
const tempCache = _.cloneDeep(this.cache);
|
|
10161
|
+
transferredClients.forEach((transferredClient) => {
|
|
10162
|
+
const taxReviewIndex = tempCache.findIndex((taxReview) => taxReview.id === transferredClient.id);
|
|
10163
|
+
// @TODO vik
|
|
10164
|
+
// tempCache[taxReviewIndex].employee = transferredClient.accountant;
|
|
10006
10165
|
});
|
|
10007
|
-
this.
|
|
10008
|
-
this.toastService.success(MessagesEnum.DELETED_MESSAGE);
|
|
10166
|
+
this.cache = tempCache;
|
|
10009
10167
|
this.updateCache();
|
|
10010
|
-
|
|
10011
|
-
}));
|
|
10168
|
+
});
|
|
10012
10169
|
}
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
|
|
10025
|
-
|
|
10026
|
-
|
|
10170
|
+
}
|
|
10171
|
+
TaxReviewService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10172
|
+
TaxReviewService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewService, providedIn: 'root' });
|
|
10173
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewService, decorators: [{
|
|
10174
|
+
type: Injectable,
|
|
10175
|
+
args: [{
|
|
10176
|
+
providedIn: 'root'
|
|
10177
|
+
}]
|
|
10178
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
10179
|
+
type: Inject,
|
|
10180
|
+
args: ['environment']
|
|
10181
|
+
}] }]; } });
|
|
10182
|
+
|
|
10183
|
+
/**
|
|
10184
|
+
* Service to work with tax review history
|
|
10185
|
+
*/
|
|
10186
|
+
class TaxReviewHistoryService extends RestService {
|
|
10187
|
+
constructor(http, eventDispatcherService, environment) {
|
|
10188
|
+
super(http, eventDispatcherService, environment);
|
|
10189
|
+
this.http = http;
|
|
10190
|
+
this.eventDispatcherService = eventDispatcherService;
|
|
10191
|
+
this.environment = environment;
|
|
10192
|
+
this.url = 'tax-reviews/history';
|
|
10193
|
+
this.modelClass = TaxReview;
|
|
10194
|
+
// subscribe on tax review updating
|
|
10195
|
+
eventDispatcherService.on(AppEventTypeEnum.TAX_REVIEW_UPDATED).subscribe((taxReview) => {
|
|
10196
|
+
const tempCache = _.cloneDeep(this.cache);
|
|
10197
|
+
// insert element at the beginning of the array
|
|
10198
|
+
tempCache.unshift(taxReview);
|
|
10199
|
+
this.cache = tempCache;
|
|
10027
10200
|
this.updateCache();
|
|
10028
10201
|
});
|
|
10029
10202
|
}
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10203
|
+
}
|
|
10204
|
+
TaxReviewHistoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewHistoryService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10205
|
+
TaxReviewHistoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewHistoryService, providedIn: 'root' });
|
|
10206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxReviewHistoryService, decorators: [{
|
|
10207
|
+
type: Injectable,
|
|
10208
|
+
args: [{
|
|
10209
|
+
providedIn: 'root'
|
|
10210
|
+
}]
|
|
10211
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
10212
|
+
type: Inject,
|
|
10213
|
+
args: ['environment']
|
|
10214
|
+
}] }]; } });
|
|
10215
|
+
|
|
10216
|
+
/**
|
|
10217
|
+
* Service to work with tax summary logic
|
|
10218
|
+
*/
|
|
10219
|
+
class TaxSummaryService {
|
|
10220
|
+
constructor(http, eventDispatcherService, environment) {
|
|
10221
|
+
this.http = http;
|
|
10222
|
+
this.eventDispatcherService = eventDispatcherService;
|
|
10223
|
+
this.environment = environment;
|
|
10224
|
+
this.taxSummaryActualsSubject = new ReplaySubject(1);
|
|
10225
|
+
this.taxSummaryForecastsSubject = new ReplaySubject(1);
|
|
10226
|
+
this.listenEvents();
|
|
10045
10227
|
}
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
* tax type depends of chart account heading or category.
|
|
10049
|
-
*/
|
|
10050
|
-
getTaxLabel(chartAccounts) {
|
|
10051
|
-
var _a, _b;
|
|
10052
|
-
// get simple array of ids from enum with taxable chart accounts headings
|
|
10053
|
-
const taxableCAHeadingsIds = enumToList(ChartAccountsHeadingTaxableEnum)
|
|
10054
|
-
.map((item) => item.value);
|
|
10055
|
-
// get simple array of ids from enum with tax deductible chart accounts headings
|
|
10056
|
-
const deductibleCAHeadingsIds = enumToList(ChartAccountsHeadingTaxDeductibleEnum)
|
|
10057
|
-
.map((item) => item.value);
|
|
10058
|
-
// check if one of ids arrays includes current chart accounts heading id and set tax label
|
|
10059
|
-
// otherwise label is empty for this class
|
|
10060
|
-
switch (true) {
|
|
10061
|
-
case taxableCAHeadingsIds.includes((_a = chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id):
|
|
10062
|
-
return ChartAccountsTaxLabelsEnum.TAX_PAID;
|
|
10063
|
-
case deductibleCAHeadingsIds.includes((_b = chartAccounts.heading) === null || _b === void 0 ? void 0 : _b.id):
|
|
10064
|
-
return ChartAccountsTaxLabelsEnum.TAX_DEDUCTED;
|
|
10065
|
-
case CHART_ACCOUNTS_CATEGORIES.workIncome.includes(chartAccounts.category):
|
|
10066
|
-
return ChartAccountsTaxLabelsEnum.TAX_WITHHELD;
|
|
10067
|
-
default:
|
|
10068
|
-
return null;
|
|
10069
|
-
}
|
|
10228
|
+
listenEvents() {
|
|
10229
|
+
this.listenToIncomeSourceForecastsEvents();
|
|
10070
10230
|
}
|
|
10071
10231
|
/**
|
|
10072
|
-
* Get
|
|
10232
|
+
* Get actual tax summary items
|
|
10073
10233
|
*/
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10234
|
+
getActuals() {
|
|
10235
|
+
this.http.get(`${this.environment.apiV2}/tax-summary/${TaxSummaryTypeEnum.ACTUALS}`, {})
|
|
10236
|
+
.subscribe((response) => {
|
|
10237
|
+
const taxSummary = plainToClass(TaxSummary, response);
|
|
10238
|
+
this.taxSummaryActualsSubject.next(taxSummary);
|
|
10239
|
+
return taxSummary;
|
|
10240
|
+
});
|
|
10241
|
+
return this.taxSummaryActualsSubject.asObservable();
|
|
10078
10242
|
}
|
|
10079
10243
|
/**
|
|
10080
|
-
*
|
|
10244
|
+
* Get forecast tax summary items
|
|
10081
10245
|
*/
|
|
10082
|
-
|
|
10083
|
-
this.
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
10087
|
-
|
|
10088
|
-
});
|
|
10246
|
+
getForecast() {
|
|
10247
|
+
this.http.get(`${this.environment.apiV2}/tax-summary/${TaxSummaryTypeEnum.FORECASTS}`, {})
|
|
10248
|
+
.subscribe((response) => {
|
|
10249
|
+
const taxSummary = plainToClass(TaxSummary, response);
|
|
10250
|
+
this.taxSummaryForecastsSubject.next(taxSummary);
|
|
10251
|
+
return taxSummary;
|
|
10089
10252
|
});
|
|
10253
|
+
return this.taxSummaryForecastsSubject.asObservable();
|
|
10090
10254
|
}
|
|
10091
10255
|
/**
|
|
10092
|
-
* Listen to EventDispatcherService
|
|
10256
|
+
* Listen to EventDispatcherService events related to Income source forecasts
|
|
10093
10257
|
*/
|
|
10094
|
-
|
|
10095
|
-
this.eventDispatcherService
|
|
10258
|
+
listenToIncomeSourceForecastsEvents() {
|
|
10259
|
+
this.eventDispatcherService
|
|
10260
|
+
.on([AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED])
|
|
10261
|
+
.subscribe(() => {
|
|
10262
|
+
this.getForecast().subscribe();
|
|
10263
|
+
});
|
|
10096
10264
|
}
|
|
10097
10265
|
}
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type:
|
|
10266
|
+
TaxSummaryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxSummaryService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10267
|
+
TaxSummaryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxSummaryService, providedIn: 'root' });
|
|
10268
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TaxSummaryService, decorators: [{
|
|
10101
10269
|
type: Injectable,
|
|
10102
10270
|
args: [{
|
|
10103
10271
|
providedIn: 'root'
|
|
@@ -10105,7 +10273,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
10105
10273
|
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
10106
10274
|
type: Inject,
|
|
10107
10275
|
args: ['environment']
|
|
10108
|
-
}] }
|
|
10276
|
+
}] }]; } });
|
|
10109
10277
|
|
|
10110
10278
|
// @TODO Don't look at the commented code. Will be refactored/removed during TT-1503
|
|
10111
10279
|
/**
|
|
@@ -10888,5 +11056,5 @@ class ResetPasswordForm extends AbstractForm {
|
|
|
10888
11056
|
* Generated bundle index. Do not edit.
|
|
10889
11057
|
*/
|
|
10890
11058
|
|
|
10891
|
-
export { AbstractForm, Address, AddressService, AddressTypeEnum, AlphabetColorsEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Bank, BankAccount, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqConfig, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, ChartAccounts, ChartAccountsCategoryEnum, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, ChartAccountsHeadingTaxDeductibleEnum, ChartAccountsHeadingTaxableEnum, ChartAccountsHeadingVehicleListEnum, ChartAccountsListEnum, ChartAccountsMetadata, ChartAccountsMetadataListEnum, ChartAccountsMetadataTypeEnum, ChartAccountsService, ChartAccountsTaxLabelsEnum, ChartAccountsTypeEnum, ChartData, ChartSerie, Chat, ChatService, ChatStatusEnum, ChatViewTypeEnum, ClientCollection, ClientDetails, ClientDetailsMedicareExemptionEnum, ClientDetailsWorkDepreciationCalculationEnum, ClientDetailsWorkingHolidayMakerEnum, ClientInvite, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, Collection, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEFAULT_VEHICLE_EXPENSE, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCapitalProjectService, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationLvpAssetTypeEnum, DepreciationLvpReportItem, DepreciationLvpReportItemCollection, DepreciationReceipt, DepreciationReportItem, DepreciationReportItemCollection, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EquityPositionChartService, EventDispatcherService, ExportFormatEnum, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSalaryEnum, IncomeSourceTypeListWorkEnum, InterceptorsModule, IntercomService, InviteStatusEnum, JwtService, KompassifyService, Loan, LoanBankTypeEnum, LoanCollection, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookCollection, LogbookPeriod, LoginForm, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, Notification, Occupation, OccupationService, PasswordForm, PdfService, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCategory, PropertyCategoryMovement, PropertyCategoryMovementService, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertySale, PropertySaleService, PropertySaleTaxExemptionMetadata, PropertyService, PropertyShare, PropertyShareAccessEnum, PropertyShareService, PropertyShareStatusEnum, PropertySubscription, PropertyValuation, RegisterClientForm, RegisterFirmForm, RegistrationInvite, RegistrationInviteStatusEnum, ReportItem, ReportItemCollection, ReportItemDetails, ResetPasswordForm, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceCollection, ServicePriceRecurringIntervalEnum, ServicePriceTypeEnum, ServiceProduct, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, ShareFilterOptionsEnum, SoleForecast, SoleForecastService, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, TYPE_LOAN, TankTypeEnum, TaxCalculationMedicareExemptionEnum, TaxCalculationTypeEnum, TaxExemption, TaxExemptionEnum, TaxExemptionMetadata, TaxExemptionMetadataEnum, TaxExemptionService, TaxReturnCategoryListEnum, TaxReturnCategorySectionEnum, TaxReview, TaxReviewCollection, TaxReviewHistoryService, TaxReviewService, TaxReviewStatusEnum, TaxSummary, TaxSummaryListEnum, TaxSummarySection, TaxSummarySectionEnum, TaxSummaryService, TaxSummaryTaxSummaryEnum, TaxSummaryTypeEnum, TicketFeedbackEnum, TicketStatusEnum, TicketTypesEnum, Toast, ToastService, ToastTypeEnum, Transaction, TransactionAllocation, TransactionAllocationCollection, TransactionAllocationService, TransactionBase, TransactionCalculationService, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, Vehicle, VehicleClaim, VehicleClaimMethodEnum, VehicleLogbook, VehicleLogbookPurposeEnum, VehicleService, WORK_TANK_LOGBOOK_PURPOSE_OPTIONS, XlsxService, cloneDeep, compare, compareMatOptions, createDate, displayMatOptions, enumToList, getDocIcon, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
|
|
11059
|
+
export { AbstractForm, Address, AddressService, AddressTypeEnum, AlphabetColorsEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Bank, BankAccount, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqConfig, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, ChartAccounts, ChartAccountsCategoryEnum, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, ChartAccountsHeadingTaxDeductibleEnum, ChartAccountsHeadingTaxableEnum, ChartAccountsHeadingVehicleListEnum, ChartAccountsListEnum, ChartAccountsMetadata, ChartAccountsMetadataListEnum, ChartAccountsMetadataTypeEnum, ChartAccountsService, ChartAccountsTaxLabelsEnum, ChartAccountsTypeEnum, ChartData, ChartSerie, Chat, ChatService, ChatStatusEnum, ChatViewTypeEnum, ClientCollection, ClientDetails, ClientDetailsMedicareExemptionEnum, ClientDetailsWorkDepreciationCalculationEnum, ClientDetailsWorkingHolidayMakerEnum, ClientInvite, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, Collection, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEFAULT_VEHICLE_EXPENSE, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCapitalProjectService, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationLvpAssetTypeEnum, DepreciationLvpReportItem, DepreciationLvpReportItemCollection, DepreciationReceipt, DepreciationReportItem, DepreciationReportItemCollection, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EquityPositionChartService, EventDispatcherService, ExportFormatEnum, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSalaryEnum, IncomeSourceTypeListWorkEnum, InterceptorsModule, IntercomService, InviteStatusEnum, JwtService, KompassifyService, Loan, LoanBankTypeEnum, LoanCollection, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookCollection, LogbookPeriod, LoginForm, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, Notification, Occupation, OccupationService, PasswordForm, PdfService, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCategory, PropertyCategoryMovement, PropertyCategoryMovementService, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertyReportItem, PropertyReportItemDepreciationCollection, PropertyReportItemTransaction, PropertyReportItemTransactionCollection, PropertySale, PropertySaleService, PropertySaleTaxExemptionMetadata, PropertyService, PropertyShare, PropertyShareAccessEnum, PropertyShareService, PropertyShareStatusEnum, PropertySubscription, PropertyTransactionReportService, PropertyValuation, RegisterClientForm, RegisterFirmForm, RegistrationInvite, RegistrationInviteStatusEnum, ReportItem, ReportItemCollection, ReportItemDetails, ResetPasswordForm, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceCollection, ServicePriceRecurringIntervalEnum, ServicePriceTypeEnum, ServiceProduct, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, ShareFilterOptionsEnum, SoleForecast, SoleForecastService, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, TYPE_LOAN, TankTypeEnum, TaxCalculationMedicareExemptionEnum, TaxCalculationTypeEnum, TaxExemption, TaxExemptionEnum, TaxExemptionMetadata, TaxExemptionMetadataEnum, TaxExemptionService, TaxReturnCategoryListEnum, TaxReturnCategorySectionEnum, TaxReview, TaxReviewCollection, TaxReviewHistoryService, TaxReviewService, TaxReviewStatusEnum, TaxSummary, TaxSummaryListEnum, TaxSummarySection, TaxSummarySectionEnum, TaxSummaryService, TaxSummaryTaxSummaryEnum, TaxSummaryTypeEnum, TicketFeedbackEnum, TicketStatusEnum, TicketTypesEnum, Toast, ToastService, ToastTypeEnum, Transaction, TransactionAllocation, TransactionAllocationCollection, TransactionAllocationService, TransactionBase, TransactionCalculationService, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, Vehicle, VehicleClaim, VehicleClaimMethodEnum, VehicleLogbook, VehicleLogbookPurposeEnum, VehicleService, WORK_TANK_LOGBOOK_PURPOSE_OPTIONS, XlsxService, cloneDeep, compare, compareMatOptions, createDate, displayMatOptions, enumToList, getDocIcon, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
|
|
10892
11060
|
//# sourceMappingURL=taxtank-core.js.map
|