taxtank-core 0.10.1 → 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 +1135 -939
- 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/endpoint/endpoints.const.js +2 -2
- 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/http/depreciation/depreciation.service.js +2 -2
- 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 +865 -697
- 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
|
@@ -845,7 +845,7 @@
|
|
|
845
845
|
CLIENT_MOVEMENTS_GET: new Endpoint('GET', '\\/client-movements'),
|
|
846
846
|
CLIENT_MOVEMENTS_POST: new Endpoint('POST', '\\/client-movements'),
|
|
847
847
|
COUNTRIES_GET: new Endpoint('GET', '\\/countries'),
|
|
848
|
-
|
|
848
|
+
DEPRECIATIONS_OPENING_GET: new Endpoint('GET', '\\/depreciations\\/\\opening-balance\.\*'),
|
|
849
849
|
DEPRECIATIONS_GET: new Endpoint('GET', '\\/depreciations'),
|
|
850
850
|
DEPRECIATIONS_POST: new Endpoint('POST', '\\/depreciations'),
|
|
851
851
|
DEPRECIATIONS_PUT: new Endpoint('PUT', '\\/depreciations\\/\\d+'),
|
|
@@ -1129,9 +1129,8 @@
|
|
|
1129
1129
|
* @param path Path to the property to be grouped (Examples: 'transaction', 'property.category')
|
|
1130
1130
|
* @param prop Optional: Field to group by (Default 'id', Examples: 'id', 'amount', 'date')
|
|
1131
1131
|
*/
|
|
1132
|
-
function CollectionDictionary(collection, path
|
|
1133
|
-
if (path === void 0) { path = ''; }
|
|
1134
|
-
if (prop === void 0) { prop = 'id'; }
|
|
1132
|
+
function CollectionDictionary(collection, path) {
|
|
1133
|
+
if (path === void 0) { path = 'id'; }
|
|
1135
1134
|
/**
|
|
1136
1135
|
* List of grouped collections
|
|
1137
1136
|
*/
|
|
@@ -1142,10 +1141,10 @@
|
|
|
1142
1141
|
return;
|
|
1143
1142
|
}
|
|
1144
1143
|
// Check if the first collection item has property by path
|
|
1145
|
-
if (!has__default["default"](collection.items[0], path)
|
|
1144
|
+
if (!has__default["default"](collection.items[0], path)) {
|
|
1146
1145
|
return;
|
|
1147
1146
|
}
|
|
1148
|
-
this.groupItems(collection, path
|
|
1147
|
+
this.groupItems(collection, path);
|
|
1149
1148
|
}
|
|
1150
1149
|
Object.defineProperty(CollectionDictionary.prototype, "keys", {
|
|
1151
1150
|
/**
|
|
@@ -1189,13 +1188,13 @@
|
|
|
1189
1188
|
/**
|
|
1190
1189
|
* Group collection items by passed path into items object
|
|
1191
1190
|
*/
|
|
1192
|
-
CollectionDictionary.prototype.groupItems = function (collection, path
|
|
1191
|
+
CollectionDictionary.prototype.groupItems = function (collection, path) {
|
|
1193
1192
|
var _this = this;
|
|
1194
1193
|
// Create empty initial object for groups
|
|
1195
1194
|
var obj = {};
|
|
1196
1195
|
// Group collection items
|
|
1197
1196
|
collection.items.forEach(function (item) {
|
|
1198
|
-
var key = get__default["default"](item,
|
|
1197
|
+
var key = get__default["default"](item, path);
|
|
1199
1198
|
// if object does not have property for grouping it will be grouped as 'other'
|
|
1200
1199
|
if (key === undefined) {
|
|
1201
1200
|
key = 'other';
|
|
@@ -4907,8 +4906,9 @@
|
|
|
4907
4906
|
/**
|
|
4908
4907
|
* Create a new transaction from current depreciation
|
|
4909
4908
|
*/
|
|
4910
|
-
Depreciation.prototype.toTransaction = function () {
|
|
4911
|
-
|
|
4909
|
+
Depreciation.prototype.toTransaction = function (params) {
|
|
4910
|
+
if (params === void 0) { params = {}; }
|
|
4911
|
+
return classTransformer.plainToClass(Transaction, Object.assign(params, this, { amount: this.currentYearForecast.amount }));
|
|
4912
4912
|
};
|
|
4913
4913
|
Object.defineProperty(Depreciation.prototype, "claimAmount", {
|
|
4914
4914
|
get: function () {
|
|
@@ -5059,6 +5059,99 @@
|
|
|
5059
5059
|
return DepreciationReportItemCollection;
|
|
5060
5060
|
}(DepreciationCollection));
|
|
5061
5061
|
|
|
5062
|
+
/**
|
|
5063
|
+
* Class with property transactions report entities
|
|
5064
|
+
*/
|
|
5065
|
+
var PropertyReportItem = /** @class */ (function () {
|
|
5066
|
+
function PropertyReportItem(property, chartAccounts) {
|
|
5067
|
+
this.claimPercent = property.claimPercent;
|
|
5068
|
+
this.sharePercent = property.sharePercent;
|
|
5069
|
+
this.subCode = chartAccounts.taxReturnItem.subCode;
|
|
5070
|
+
this.description = chartAccounts.name;
|
|
5071
|
+
}
|
|
5072
|
+
Object.defineProperty(PropertyReportItem.prototype, "claimAmount", {
|
|
5073
|
+
get: function () {
|
|
5074
|
+
return +(this.amount * (this.claimPercent / 100)).toFixed(2);
|
|
5075
|
+
},
|
|
5076
|
+
enumerable: false,
|
|
5077
|
+
configurable: true
|
|
5078
|
+
});
|
|
5079
|
+
Object.defineProperty(PropertyReportItem.prototype, "shareClaimAmount", {
|
|
5080
|
+
get: function () {
|
|
5081
|
+
return this.claimAmount * (this.sharePercent / 100);
|
|
5082
|
+
},
|
|
5083
|
+
enumerable: false,
|
|
5084
|
+
configurable: true
|
|
5085
|
+
});
|
|
5086
|
+
return PropertyReportItem;
|
|
5087
|
+
}());
|
|
5088
|
+
|
|
5089
|
+
/**
|
|
5090
|
+
* Class with transaction-based property transactions report entities
|
|
5091
|
+
*/
|
|
5092
|
+
var PropertyReportItemTransaction = /** @class */ (function (_super) {
|
|
5093
|
+
__extends(PropertyReportItemTransaction, _super);
|
|
5094
|
+
function PropertyReportItemTransaction(transactions, property, chartAccounts) {
|
|
5095
|
+
var _this = _super.call(this, property, chartAccounts) || this;
|
|
5096
|
+
_this.amount = transactions.amount;
|
|
5097
|
+
_this.description = chartAccounts.name;
|
|
5098
|
+
return _this;
|
|
5099
|
+
}
|
|
5100
|
+
return PropertyReportItemTransaction;
|
|
5101
|
+
}(PropertyReportItem));
|
|
5102
|
+
|
|
5103
|
+
/**
|
|
5104
|
+
* Collection to work with transaction-based property report items
|
|
5105
|
+
*/
|
|
5106
|
+
var PropertyReportItemTransactionCollection = /** @class */ (function (_super) {
|
|
5107
|
+
__extends(PropertyReportItemTransactionCollection, _super);
|
|
5108
|
+
function PropertyReportItemTransactionCollection(transactions, property, chartAccounts) {
|
|
5109
|
+
var _this = _super.call(this) || this;
|
|
5110
|
+
_this.setItems(transactions, property, chartAccounts);
|
|
5111
|
+
return _this;
|
|
5112
|
+
}
|
|
5113
|
+
PropertyReportItemTransactionCollection.prototype.setItems = function (transactions, property, chartAccounts) {
|
|
5114
|
+
var transactionsDictionary = new CollectionDictionary(transactions, 'chartAccounts.id');
|
|
5115
|
+
this.items = transactionsDictionary.keys.map(function (chartAccountId) {
|
|
5116
|
+
return new PropertyReportItemTransaction(transactionsDictionary.get(chartAccountId), property, chartAccounts.getById(+chartAccountId));
|
|
5117
|
+
});
|
|
5118
|
+
};
|
|
5119
|
+
return PropertyReportItemTransactionCollection;
|
|
5120
|
+
}(Collection));
|
|
5121
|
+
|
|
5122
|
+
/**
|
|
5123
|
+
* Class with depreciation-based property transactions report entities
|
|
5124
|
+
*/
|
|
5125
|
+
var PropertyReportItemDepreciation = /** @class */ (function (_super) {
|
|
5126
|
+
__extends(PropertyReportItemDepreciation, _super);
|
|
5127
|
+
function PropertyReportItemDepreciation(depreciations, property, chartAccounts) {
|
|
5128
|
+
var _this = _super.call(this, property, chartAccounts) || this;
|
|
5129
|
+
_this.amount = depreciations.getCurrentYearForecastAmount();
|
|
5130
|
+
_this.description = exports.DepreciationTypeEnum[depreciations.first.type];
|
|
5131
|
+
return _this;
|
|
5132
|
+
}
|
|
5133
|
+
return PropertyReportItemDepreciation;
|
|
5134
|
+
}(PropertyReportItem));
|
|
5135
|
+
|
|
5136
|
+
/**
|
|
5137
|
+
* Collection to work with depreciation-based property report items
|
|
5138
|
+
*/
|
|
5139
|
+
var PropertyReportItemDepreciationCollection = /** @class */ (function (_super) {
|
|
5140
|
+
__extends(PropertyReportItemDepreciationCollection, _super);
|
|
5141
|
+
function PropertyReportItemDepreciationCollection(depreciations, property, chartAccounts) {
|
|
5142
|
+
var _this = _super.call(this) || this;
|
|
5143
|
+
_this.setItems(depreciations, property, chartAccounts);
|
|
5144
|
+
return _this;
|
|
5145
|
+
}
|
|
5146
|
+
PropertyReportItemDepreciationCollection.prototype.setItems = function (depreciations, property, chartAccounts) {
|
|
5147
|
+
var depreciationsbyType = new CollectionDictionary(depreciations, 'type');
|
|
5148
|
+
this.items = depreciationsbyType.keys.map(function (type) {
|
|
5149
|
+
return new PropertyReportItemDepreciation(depreciationsbyType.get(type), property, chartAccounts.getById(depreciationsbyType.get(type).first.chartAccounts.id));
|
|
5150
|
+
});
|
|
5151
|
+
};
|
|
5152
|
+
return PropertyReportItemDepreciationCollection;
|
|
5153
|
+
}(Collection));
|
|
5154
|
+
|
|
5062
5155
|
var ServicePriceCollection = /** @class */ (function (_super) {
|
|
5063
5156
|
__extends(ServicePriceCollection, _super);
|
|
5064
5157
|
function ServicePriceCollection() {
|
|
@@ -9816,7 +9909,7 @@
|
|
|
9816
9909
|
}));
|
|
9817
9910
|
};
|
|
9818
9911
|
DepreciationService.prototype.getOpenBalance = function (depreciation) {
|
|
9819
|
-
return this.http.post(this.environment.apiV2 + "/" + this.url + "/
|
|
9912
|
+
return this.http.post(this.environment.apiV2 + "/" + this.url + "/opening-balance?financialYear=" + new FinancialYear().year, depreciation)
|
|
9820
9913
|
.pipe(operators.map(function (response) {
|
|
9821
9914
|
return response || 0;
|
|
9822
9915
|
}));
|
|
@@ -11048,152 +11141,72 @@
|
|
|
11048
11141
|
}] }];
|
|
11049
11142
|
} });
|
|
11050
11143
|
|
|
11144
|
+
function enumToList(data) {
|
|
11145
|
+
var list = [];
|
|
11146
|
+
for (var key in data) {
|
|
11147
|
+
if (Number(key) >= 0) {
|
|
11148
|
+
list.push({
|
|
11149
|
+
label: data[key],
|
|
11150
|
+
value: Number(key)
|
|
11151
|
+
});
|
|
11152
|
+
}
|
|
11153
|
+
}
|
|
11154
|
+
return list;
|
|
11155
|
+
}
|
|
11156
|
+
|
|
11157
|
+
var MessagesEnum;
|
|
11158
|
+
(function (MessagesEnum) {
|
|
11159
|
+
MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
|
|
11160
|
+
MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
|
|
11161
|
+
MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
|
|
11162
|
+
})(MessagesEnum || (MessagesEnum = {}));
|
|
11163
|
+
|
|
11051
11164
|
/**
|
|
11052
|
-
*
|
|
11053
|
-
* Logic here works like collections methods but for several entities
|
|
11165
|
+
* popup notifications service (toast, snackbar).
|
|
11054
11166
|
*/
|
|
11055
|
-
var
|
|
11056
|
-
function
|
|
11167
|
+
var ToastService = /** @class */ (function () {
|
|
11168
|
+
function ToastService() {
|
|
11169
|
+
this.toast$ = new rxjs.ReplaySubject(1);
|
|
11057
11170
|
}
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
return transactions.cashPosition - Math.abs(depreciations.claimAmount);
|
|
11061
|
-
};
|
|
11062
|
-
PropertyCalculationService.prototype.getTaxPosition$ = function (transactions$, depreciations$) {
|
|
11063
|
-
var _this = this;
|
|
11064
|
-
return rxjs.combineLatest([
|
|
11065
|
-
transactions$,
|
|
11066
|
-
depreciations$
|
|
11067
|
-
]).pipe(operators.map(function (_b) {
|
|
11068
|
-
var _c = __read(_b, 2), transactions = _c[0], depreciations = _c[1];
|
|
11069
|
-
return _this.getTaxPosition(transactions, depreciations);
|
|
11070
|
-
}));
|
|
11171
|
+
ToastService.prototype.get = function () {
|
|
11172
|
+
return this.toast$.asObservable();
|
|
11071
11173
|
};
|
|
11072
|
-
|
|
11073
|
-
|
|
11074
|
-
// check if taxPosition = 0 to avoid division by zero
|
|
11075
|
-
if (!taxPosition) {
|
|
11076
|
-
return 0;
|
|
11077
|
-
}
|
|
11078
|
-
return (taxPosition - properties.forecastedTaxPosition) / taxPosition;
|
|
11174
|
+
ToastService.prototype.add = function (toast) {
|
|
11175
|
+
this.toast$.next(toast);
|
|
11079
11176
|
};
|
|
11080
|
-
|
|
11081
|
-
|
|
11082
|
-
|
|
11083
|
-
|
|
11084
|
-
|
|
11085
|
-
depreciations$
|
|
11086
|
-
]).pipe(operators.map(function (_b) {
|
|
11087
|
-
var _c = __read(_b, 3), properties = _c[0], transactions = _c[1], depreciations = _c[2];
|
|
11088
|
-
return _this.taxPositionGrowth(properties, transactions, depreciations);
|
|
11177
|
+
ToastService.prototype.success = function (message) {
|
|
11178
|
+
this.add(classTransformer.plainToClass(Toast, {
|
|
11179
|
+
type: exports.ToastTypeEnum.SUCCESS,
|
|
11180
|
+
title: 'Success!',
|
|
11181
|
+
message: message,
|
|
11089
11182
|
}));
|
|
11090
11183
|
};
|
|
11091
|
-
|
|
11092
|
-
|
|
11093
|
-
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
return totalAmount + bankAccounts.items
|
|
11097
|
-
.reduce(function (propertyAmount, bankAccount) {
|
|
11098
|
-
var _a;
|
|
11099
|
-
return propertyAmount + bankAccount.getPropertyPercentage(property.id) * (((_a = loans.getByBankAccountId(bankAccount.id)) === null || _a === void 0 ? void 0 : _a.amount) || 0);
|
|
11100
|
-
}, 0);
|
|
11101
|
-
}, 0);
|
|
11102
|
-
};
|
|
11103
|
-
PropertyCalculationService.prototype.getLoanValue = function (properties, bankAccounts) {
|
|
11104
|
-
return properties.items.reduce(function (totalAmount, property) {
|
|
11105
|
-
return totalAmount + bankAccounts.items
|
|
11106
|
-
.reduce(function (propertyAmount, bankAccount) {
|
|
11107
|
-
return propertyAmount + bankAccount.getPropertyBalanceAmount(property.id);
|
|
11108
|
-
}, 0);
|
|
11109
|
-
}, 0);
|
|
11110
|
-
};
|
|
11111
|
-
/**
|
|
11112
|
-
* LVR
|
|
11113
|
-
*/
|
|
11114
|
-
PropertyCalculationService.prototype.getLvr = function (properties, bankAccounts) {
|
|
11115
|
-
// Math abs is required for correct percentage calculation
|
|
11116
|
-
return Math.abs(this.getLoanValue(properties, bankAccounts)) / properties.marketValue;
|
|
11117
|
-
};
|
|
11118
|
-
PropertyCalculationService.prototype.getLvr$ = function (properties$, bankAccounts$) {
|
|
11119
|
-
var _this = this;
|
|
11120
|
-
return rxjs.combineLatest([
|
|
11121
|
-
properties$,
|
|
11122
|
-
bankAccounts$
|
|
11123
|
-
]).pipe(operators.map(function (_b) {
|
|
11124
|
-
var _c = __read(_b, 2), properties = _c[0], bankAccounts = _c[1];
|
|
11125
|
-
return _this.getLvr(properties, bankAccounts);
|
|
11184
|
+
ToastService.prototype.warning = function (message) {
|
|
11185
|
+
this.add(classTransformer.plainToClass(Toast, {
|
|
11186
|
+
type: exports.ToastTypeEnum.WARNING,
|
|
11187
|
+
title: 'Warning!',
|
|
11188
|
+
message: message,
|
|
11126
11189
|
}));
|
|
11127
11190
|
};
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
var _this = this;
|
|
11134
|
-
return rxjs.combineLatest([
|
|
11135
|
-
properties$,
|
|
11136
|
-
bankAccounts$,
|
|
11137
|
-
loans$
|
|
11138
|
-
]).pipe(operators.map(function (_b) {
|
|
11139
|
-
var _c = __read(_b, 3), properties = _c[0], bankAccounts = _c[1], loans = _c[2];
|
|
11140
|
-
return _this.getLvrCommencement(properties, loans, bankAccounts);
|
|
11191
|
+
ToastService.prototype.error = function (message) {
|
|
11192
|
+
this.add(classTransformer.plainToClass(Toast, {
|
|
11193
|
+
type: exports.ToastTypeEnum.ERROR,
|
|
11194
|
+
title: 'Error!',
|
|
11195
|
+
message: message,
|
|
11141
11196
|
}));
|
|
11142
11197
|
};
|
|
11143
|
-
|
|
11144
|
-
|
|
11145
|
-
|
|
11146
|
-
|
|
11147
|
-
|
|
11148
|
-
}
|
|
11149
|
-
return (lvr - this.getLvrCommencement(properties, loans, bankAccounts)) / lvr;
|
|
11150
|
-
};
|
|
11151
|
-
PropertyCalculationService.prototype.getLvrGrowth$ = function (properties$, bankAccounts$, loans$) {
|
|
11152
|
-
var _this = this;
|
|
11153
|
-
return rxjs.combineLatest([
|
|
11154
|
-
properties$,
|
|
11155
|
-
bankAccounts$,
|
|
11156
|
-
loans$
|
|
11157
|
-
]).pipe(operators.map(function (_b) {
|
|
11158
|
-
var _c = __read(_b, 3), properties = _c[0], bankAccounts = _c[1], loans = _c[2];
|
|
11159
|
-
return _this.getLvrGrowth(properties, bankAccounts, loans);
|
|
11198
|
+
ToastService.prototype.info = function (message) {
|
|
11199
|
+
this.add(classTransformer.plainToClass(Toast, {
|
|
11200
|
+
type: exports.ToastTypeEnum.INFO,
|
|
11201
|
+
title: 'Information',
|
|
11202
|
+
message: message,
|
|
11160
11203
|
}));
|
|
11161
11204
|
};
|
|
11162
|
-
|
|
11163
|
-
// Math abs is required for correct percentage calculation
|
|
11164
|
-
return properties.marketValue - Math.abs(this.getLoanValue(properties, bankAccounts));
|
|
11165
|
-
};
|
|
11166
|
-
PropertyCalculationService.prototype.getPurchaseEquity = function (properties, bankAccounts, loans) {
|
|
11167
|
-
// Math abs is required for correct percentage calculation
|
|
11168
|
-
return properties.purchasePrice - Math.abs(this.getLoanAmount(properties, bankAccounts, loans));
|
|
11169
|
-
};
|
|
11170
|
-
return PropertyCalculationService;
|
|
11205
|
+
return ToastService;
|
|
11171
11206
|
}());
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
11175
|
-
type: i0.Injectable,
|
|
11176
|
-
args: [{
|
|
11177
|
-
providedIn: 'root'
|
|
11178
|
-
}]
|
|
11179
|
-
}] });
|
|
11180
|
-
|
|
11181
|
-
/**
|
|
11182
|
-
* Service for work with Property Categories
|
|
11183
|
-
*/
|
|
11184
|
-
var PropertyCategoryService = /** @class */ (function (_super) {
|
|
11185
|
-
__extends(PropertyCategoryService, _super);
|
|
11186
|
-
function PropertyCategoryService() {
|
|
11187
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
11188
|
-
_this.modelClass = PropertyCategory;
|
|
11189
|
-
_this.url = 'properties/categories';
|
|
11190
|
-
return _this;
|
|
11191
|
-
}
|
|
11192
|
-
return PropertyCategoryService;
|
|
11193
|
-
}(RestService));
|
|
11194
|
-
PropertyCategoryService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11195
|
-
PropertyCategoryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryService, providedIn: 'root' });
|
|
11196
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryService, decorators: [{
|
|
11207
|
+
ToastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11208
|
+
ToastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, providedIn: 'root' });
|
|
11209
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, decorators: [{
|
|
11197
11210
|
type: i0.Injectable,
|
|
11198
11211
|
args: [{
|
|
11199
11212
|
providedIn: 'root'
|
|
@@ -11201,534 +11214,638 @@
|
|
|
11201
11214
|
}] });
|
|
11202
11215
|
|
|
11203
11216
|
/**
|
|
11204
|
-
*
|
|
11217
|
+
* Service for transactions business logic
|
|
11205
11218
|
*/
|
|
11206
|
-
var
|
|
11207
|
-
__extends(
|
|
11208
|
-
function
|
|
11219
|
+
var TransactionService = /** @class */ (function (_super) {
|
|
11220
|
+
__extends(TransactionService, _super);
|
|
11221
|
+
function TransactionService(http, eventDispatcherService, environment, toastService) {
|
|
11209
11222
|
var _this = _super.call(this, http, eventDispatcherService, environment) || this;
|
|
11210
11223
|
_this.http = http;
|
|
11211
11224
|
_this.eventDispatcherService = eventDispatcherService;
|
|
11212
11225
|
_this.environment = environment;
|
|
11213
|
-
_this.
|
|
11214
|
-
|
|
11226
|
+
_this.toastService = toastService;
|
|
11227
|
+
// url part for Transaction API
|
|
11228
|
+
_this.url = 'transactions';
|
|
11229
|
+
_this.modelClass = Transaction;
|
|
11230
|
+
_this.transactionDeleted = new i0.EventEmitter();
|
|
11215
11231
|
_this.listenEvents();
|
|
11216
11232
|
return _this;
|
|
11217
11233
|
}
|
|
11218
11234
|
/**
|
|
11219
|
-
*
|
|
11235
|
+
* Listen events from Event Dispatcher services
|
|
11220
11236
|
*/
|
|
11221
|
-
|
|
11237
|
+
TransactionService.prototype.listenEvents = function () {
|
|
11238
|
+
this.listenDepreciationChange();
|
|
11239
|
+
this.listenPropertyShareUpdate();
|
|
11240
|
+
};
|
|
11241
|
+
/**
|
|
11242
|
+
* get list of all user's TaxTank transactions
|
|
11243
|
+
*/
|
|
11244
|
+
TransactionService.prototype.get = function () {
|
|
11222
11245
|
var _this = this;
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
_this.cache.push(newDocument);
|
|
11246
|
+
if (!this.cache) {
|
|
11247
|
+
// set cache as default empty array to avoid multiple backend requests
|
|
11248
|
+
this.cache = [];
|
|
11249
|
+
this.fetch()
|
|
11250
|
+
.subscribe(function (transactions) {
|
|
11251
|
+
_this.cache = transactions;
|
|
11230
11252
|
_this.updateCache();
|
|
11231
|
-
}
|
|
11232
|
-
|
|
11253
|
+
});
|
|
11254
|
+
}
|
|
11255
|
+
return this.cacheSubject.asObservable().pipe(
|
|
11256
|
+
// assign child transactions (fees) to parent transactions
|
|
11257
|
+
operators.map(function (transactions) {
|
|
11258
|
+
transactions.forEach(function (transaction) {
|
|
11259
|
+
transaction.transactions = transactions
|
|
11260
|
+
// get list of child transactions
|
|
11261
|
+
.filter(function (t) { return t.parentTransaction && t.parentTransaction.id === transaction.id; });
|
|
11262
|
+
});
|
|
11263
|
+
sort(transactions, 'date', false);
|
|
11264
|
+
return transactions;
|
|
11233
11265
|
}));
|
|
11234
11266
|
};
|
|
11235
11267
|
/**
|
|
11236
|
-
*
|
|
11237
|
-
* @param
|
|
11268
|
+
* Add single new transaction
|
|
11269
|
+
* @param model New Transaction instance for saving
|
|
11238
11270
|
*/
|
|
11239
|
-
|
|
11240
|
-
return this.get()
|
|
11241
|
-
.pipe(operators.map(function (documents) {
|
|
11242
|
-
return documents
|
|
11243
|
-
.filter(function (document) { return document.property.id === propertyId; });
|
|
11244
|
-
}));
|
|
11245
|
-
};
|
|
11246
|
-
PropertyDocumentService.prototype.listenEvents = function () {
|
|
11247
|
-
this.listenPropertyUpdateWithDocument();
|
|
11248
|
-
};
|
|
11249
|
-
PropertyDocumentService.prototype.listenPropertyUpdateWithDocument = function () {
|
|
11271
|
+
TransactionService.prototype.add = function (model) {
|
|
11250
11272
|
var _this = this;
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11273
|
+
// we don't have POST API endpoint for single transaction
|
|
11274
|
+
return this.addBatch([model])
|
|
11275
|
+
.pipe(operators.map(function (newTransactions) {
|
|
11276
|
+
// @TODO alex
|
|
11277
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_CREATED, newTransactions[0]));
|
|
11278
|
+
return newTransactions[0];
|
|
11279
|
+
}));
|
|
11254
11280
|
};
|
|
11255
|
-
return PropertyDocumentService;
|
|
11256
|
-
}(RestService));
|
|
11257
|
-
PropertyDocumentService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyDocumentService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11258
|
-
PropertyDocumentService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyDocumentService, providedIn: 'root' });
|
|
11259
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyDocumentService, decorators: [{
|
|
11260
|
-
type: i0.Injectable,
|
|
11261
|
-
args: [{
|
|
11262
|
-
providedIn: 'root'
|
|
11263
|
-
}]
|
|
11264
|
-
}], ctorParameters: function () {
|
|
11265
|
-
return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
11266
|
-
type: i0.Inject,
|
|
11267
|
-
args: ['environment']
|
|
11268
|
-
}] }];
|
|
11269
|
-
} });
|
|
11270
|
-
|
|
11271
|
-
// @TODO check and improve logic during refactoring
|
|
11272
|
-
var PropertyShareService = /** @class */ (function (_super) {
|
|
11273
|
-
__extends(PropertyShareService, _super);
|
|
11274
|
-
function PropertyShareService(http, eventDispatcherService, environment) {
|
|
11275
|
-
var _this = _super.call(this, http, eventDispatcherService, environment) || this;
|
|
11276
|
-
_this.http = http;
|
|
11277
|
-
_this.eventDispatcherService = eventDispatcherService;
|
|
11278
|
-
_this.environment = environment;
|
|
11279
|
-
// api url parameter for properties shares
|
|
11280
|
-
_this.url = 'properties/shares';
|
|
11281
|
-
_this.modelClass = PropertyShare;
|
|
11282
|
-
_this.listenEvents();
|
|
11283
|
-
return _this;
|
|
11284
|
-
}
|
|
11285
11281
|
/**
|
|
11286
|
-
*
|
|
11282
|
+
* get transactions related with property
|
|
11287
11283
|
*/
|
|
11288
|
-
|
|
11289
|
-
this.
|
|
11284
|
+
TransactionService.prototype.getByPropertyId = function (propertyId) {
|
|
11285
|
+
return this.get()
|
|
11286
|
+
.pipe(operators.map(function (transactions) {
|
|
11287
|
+
return transactions.filter(function (transaction) {
|
|
11288
|
+
var _a;
|
|
11289
|
+
return ((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id) === propertyId;
|
|
11290
|
+
});
|
|
11291
|
+
}));
|
|
11290
11292
|
};
|
|
11291
11293
|
/**
|
|
11292
|
-
*
|
|
11294
|
+
* get list of transactions with tank type 'Work'
|
|
11293
11295
|
*/
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
.
|
|
11298
|
-
var updatedPropertyShare = classTransformer.plainToClass(PropertyShare, updatedPropertyShareBase);
|
|
11299
|
-
// if loan type is NOT vehicle - fire EventDispatcher event
|
|
11300
|
-
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_SHARE_UPDATED, null));
|
|
11301
|
-
replace(_this.cache, updatedPropertyShare);
|
|
11302
|
-
_this.updateCache();
|
|
11303
|
-
return updatedPropertyShare;
|
|
11296
|
+
TransactionService.prototype.getWorkTransactions = function () {
|
|
11297
|
+
return this.get()
|
|
11298
|
+
.pipe(operators.map(function (transactions) {
|
|
11299
|
+
return transactions.filter(function (transaction) { return transaction.isWorkTank(); });
|
|
11304
11300
|
}));
|
|
11305
11301
|
};
|
|
11306
11302
|
/**
|
|
11307
|
-
*
|
|
11308
|
-
* @param share user to share property
|
|
11303
|
+
* get list of taxable transactions with tank type 'Work'
|
|
11309
11304
|
*/
|
|
11310
|
-
|
|
11311
|
-
return this.
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
return this.get()
|
|
11315
|
-
.pipe(operators.map(function (propertyShares) {
|
|
11316
|
-
var propertySharesIncoming = [];
|
|
11317
|
-
propertyShares.forEach(function (propertyShare) {
|
|
11318
|
-
var _a;
|
|
11319
|
-
if (((_a = propertyShare.user) === null || _a === void 0 ? void 0 : _a.isLoggedIn()) && propertyShare.isPending() && propertyShare.property.user.id !== +localStorage.getItem('userId')) {
|
|
11320
|
-
propertySharesIncoming.push(propertyShare);
|
|
11321
|
-
}
|
|
11322
|
-
});
|
|
11323
|
-
return propertySharesIncoming;
|
|
11305
|
+
TransactionService.prototype.getTaxableWorkTransactions = function () {
|
|
11306
|
+
return this.getWorkTransactions()
|
|
11307
|
+
.pipe(operators.map(function (transactions) {
|
|
11308
|
+
return transactions.filter(function (transaction) { return !!transaction.chartAccounts.taxReturnItem; });
|
|
11324
11309
|
}));
|
|
11325
11310
|
};
|
|
11326
11311
|
/**
|
|
11327
|
-
*
|
|
11312
|
+
* add multiple transactions
|
|
11313
|
+
* @param transactions List of new Transaction instances for saving
|
|
11328
11314
|
*/
|
|
11329
|
-
|
|
11315
|
+
TransactionService.prototype.addBatch = function (transactions) {
|
|
11330
11316
|
var _this = this;
|
|
11331
|
-
|
|
11332
|
-
|
|
11317
|
+
transactions = ___default["default"].cloneDeep(transactions);
|
|
11318
|
+
return this.http.post(this.environment.apiV2 + "/" + this.url, transactions)
|
|
11319
|
+
.pipe(operators.map(function (response) {
|
|
11320
|
+
var _c;
|
|
11321
|
+
var addedTransactions = response.map(function (item) { return classTransformer.plainToClass(Transaction, item); });
|
|
11322
|
+
transactions.forEach(function (transaction, index) {
|
|
11323
|
+
// @TODO backend: need to upload file in the same backend endpoint with transaction add/update
|
|
11324
|
+
// check if passed receipt and upload file
|
|
11325
|
+
if (transaction.file) {
|
|
11326
|
+
transaction.id = response[index].id;
|
|
11327
|
+
addedTransactions[index].file = transaction.file;
|
|
11328
|
+
_this.uploadReceipt(addedTransactions[index]);
|
|
11329
|
+
}
|
|
11330
|
+
// @TODO Viktor: implement API for saving of nested transactions
|
|
11331
|
+
// add child transactions if exist
|
|
11332
|
+
if (transaction.transactions.length) {
|
|
11333
|
+
transaction.transactions.forEach(function (childTransaction) {
|
|
11334
|
+
childTransaction.parentTransaction = classTransformer.plainToClass(Transaction, { id: addedTransactions[index].id });
|
|
11335
|
+
});
|
|
11336
|
+
_this.addBatch(transaction.transactions).subscribe();
|
|
11337
|
+
}
|
|
11338
|
+
// add transfer transaction to cache
|
|
11339
|
+
if (transaction.operation === exports.TransactionOperationEnum.TRANSFER) {
|
|
11340
|
+
addedTransactions.push(addedTransactions[0].transfer);
|
|
11341
|
+
}
|
|
11342
|
+
});
|
|
11343
|
+
if (_this.cache) {
|
|
11344
|
+
(_c = _this.cache).push.apply(_c, __spreadArray([], __read(addedTransactions)));
|
|
11345
|
+
_this.updateCache();
|
|
11346
|
+
}
|
|
11347
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
|
|
11348
|
+
_this.toastService.success(MessagesEnum.CREATED_MESSAGE);
|
|
11349
|
+
return addedTransactions;
|
|
11333
11350
|
}));
|
|
11334
11351
|
};
|
|
11335
11352
|
/**
|
|
11336
|
-
*
|
|
11353
|
+
* update existing transaction
|
|
11354
|
+
* @param transaction Transaction instance for updating
|
|
11337
11355
|
*/
|
|
11338
|
-
|
|
11339
|
-
var
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11356
|
+
TransactionService.prototype.update = function (transaction) {
|
|
11357
|
+
var _this = this;
|
|
11358
|
+
return this.http.put(this.environment.apiV2 + "/" + this.url + "/" + transaction.id, transaction)
|
|
11359
|
+
.pipe(operators.map(function (response) {
|
|
11360
|
+
var updatedTransaction = classTransformer.plainToClass(Transaction, response);
|
|
11361
|
+
// @TODO need to upload file in the same backend endpoint with transaction add/update
|
|
11362
|
+
// check if passed new receipt and upload file
|
|
11363
|
+
if (transaction.file) {
|
|
11364
|
+
updatedTransaction.file = transaction.file;
|
|
11365
|
+
_this.uploadReceipt(updatedTransaction);
|
|
11344
11366
|
}
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11367
|
+
// @TODO Viktor: implement API for saving of nested transactions
|
|
11368
|
+
if (transaction.transactions.length) {
|
|
11369
|
+
// add parent transaction to child transactions
|
|
11370
|
+
transaction.transactions.forEach(function (childTransaction) {
|
|
11371
|
+
childTransaction.parentTransaction = classTransformer.plainToClass(Transaction, { id: updatedTransaction.id });
|
|
11372
|
+
});
|
|
11373
|
+
// separate child transactions by id existing to define add or update action.
|
|
11374
|
+
var childTransactionsToUpdate = transaction.transactions.filter(function (t) { return t.id; });
|
|
11375
|
+
var childTransactionsToAdd = transaction.transactions.filter(function (t) { return !t.id; });
|
|
11376
|
+
// update child transactions
|
|
11377
|
+
if (childTransactionsToUpdate.length) {
|
|
11378
|
+
_this.updateBatch(childTransactionsToUpdate).subscribe();
|
|
11379
|
+
}
|
|
11380
|
+
// add child transactions
|
|
11381
|
+
if (childTransactionsToAdd.length) {
|
|
11382
|
+
_this.addBatch(childTransactionsToAdd).subscribe();
|
|
11383
|
+
}
|
|
11384
|
+
}
|
|
11385
|
+
_this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
|
|
11386
|
+
replace(_this.cache, updatedTransaction);
|
|
11387
|
+
_this.updateCache();
|
|
11388
|
+
return updatedTransaction;
|
|
11352
11389
|
}));
|
|
11353
11390
|
};
|
|
11354
11391
|
/**
|
|
11355
|
-
*
|
|
11392
|
+
* update multiple transactions
|
|
11393
|
+
* @param transactions list of transactions for updating
|
|
11356
11394
|
*/
|
|
11357
|
-
|
|
11395
|
+
TransactionService.prototype.updateBatch = function (transactions) {
|
|
11358
11396
|
var _this = this;
|
|
11359
|
-
this.
|
|
11360
|
-
.
|
|
11361
|
-
|
|
11362
|
-
|
|
11363
|
-
_this.
|
|
11397
|
+
return this.http.put(this.environment.apiV2 + "/" + this.url, transactions)
|
|
11398
|
+
.pipe(operators.map(function (response) {
|
|
11399
|
+
var updatedTransactions = response.map(function (item) { return classTransformer.plainToClass(Transaction, item); });
|
|
11400
|
+
updatedTransactions.forEach(function (updatedTransaction) {
|
|
11401
|
+
replace(_this.cache, updatedTransaction);
|
|
11364
11402
|
});
|
|
11365
|
-
|
|
11403
|
+
_this.updateCache();
|
|
11404
|
+
return updatedTransactions;
|
|
11405
|
+
}));
|
|
11366
11406
|
};
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
|
|
11380
|
-
|
|
11381
|
-
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
|
|
11390
|
-
|
|
11391
|
-
|
|
11392
|
-
}(RestService));
|
|
11393
|
-
PropertySaleService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertySaleService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11394
|
-
PropertySaleService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertySaleService, providedIn: 'root' });
|
|
11395
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertySaleService, decorators: [{
|
|
11396
|
-
type: i0.Injectable,
|
|
11397
|
-
args: [{
|
|
11398
|
-
providedIn: 'root'
|
|
11399
|
-
}]
|
|
11400
|
-
}] });
|
|
11401
|
-
|
|
11402
|
-
/**
|
|
11403
|
-
* Service for get property equity position half-year history chart data
|
|
11404
|
-
*/
|
|
11405
|
-
var EquityPositionChartService = /** @class */ (function () {
|
|
11406
|
-
function EquityPositionChartService(http, environment) {
|
|
11407
|
-
this.http = http;
|
|
11408
|
-
this.environment = environment;
|
|
11409
|
-
}
|
|
11410
|
-
EquityPositionChartService.prototype.get = function () {
|
|
11411
|
-
// @TODO refactor backend
|
|
11412
|
-
return this.http.get(this.environment.apiV2 + "/properties/categories/equity")
|
|
11413
|
-
.pipe(operators.map(function (response) {
|
|
11414
|
-
return response.map(function (item) {
|
|
11415
|
-
return classTransformer.plainToClass(ChartData, {
|
|
11416
|
-
name: item.category.name,
|
|
11417
|
-
data: item.equity.map(function (serie) {
|
|
11418
|
-
return classTransformer.plainToClass(ChartSerie, {
|
|
11419
|
-
label: serie.date,
|
|
11420
|
-
value: serie.amount
|
|
11421
|
-
});
|
|
11422
|
-
})
|
|
11423
|
-
});
|
|
11407
|
+
/**
|
|
11408
|
+
* delete transaction and related transactions
|
|
11409
|
+
* @param model
|
|
11410
|
+
*/
|
|
11411
|
+
TransactionService.prototype.delete = function (model) {
|
|
11412
|
+
var _this = this;
|
|
11413
|
+
return this.http.delete(this.environment.apiV2 + "/" + this.url + "/" + model.id)
|
|
11414
|
+
.pipe(operators.map(function () {
|
|
11415
|
+
_this.cache = _this.cache.filter(function (transaction) {
|
|
11416
|
+
var _a;
|
|
11417
|
+
// when delete transfer we delete actually 2 transactions
|
|
11418
|
+
if (model.isTransfer) {
|
|
11419
|
+
var ids = [model.id];
|
|
11420
|
+
// get id of related transfer transaction
|
|
11421
|
+
if (model.transfer) {
|
|
11422
|
+
// just take id if we delete source transaction
|
|
11423
|
+
ids.push(model.transfer.id);
|
|
11424
|
+
}
|
|
11425
|
+
else {
|
|
11426
|
+
// find source transaction id if we delete destination transaction
|
|
11427
|
+
ids.push(_this.cache.find(function (t) { return t.transfer.id === model.id; }).id);
|
|
11428
|
+
}
|
|
11429
|
+
return !ids.includes(transaction.id);
|
|
11430
|
+
}
|
|
11431
|
+
return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
|
|
11424
11432
|
});
|
|
11433
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_DELETED, model));
|
|
11434
|
+
_this.toastService.success(MessagesEnum.DELETED_MESSAGE);
|
|
11435
|
+
_this.updateCache();
|
|
11436
|
+
_this.transactionDeleted.emit(model);
|
|
11425
11437
|
}));
|
|
11426
11438
|
};
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11439
|
+
/**
|
|
11440
|
+
* upload transaction receipt image
|
|
11441
|
+
* @param transaction Еhe transaction for which the receipt will be imported
|
|
11442
|
+
*/
|
|
11443
|
+
TransactionService.prototype.uploadReceipt = function (transaction) {
|
|
11444
|
+
var _this = this;
|
|
11445
|
+
var formData = new FormData();
|
|
11446
|
+
formData.append('file', transaction.file);
|
|
11447
|
+
transaction.receipt = null;
|
|
11448
|
+
this.http.post(this.environment.apiV2 + "/" + this.url + "/" + transaction.id + "/receipts", formData)
|
|
11449
|
+
.subscribe(function (receiptResponse) {
|
|
11450
|
+
// we don't need to keep file after save
|
|
11451
|
+
transaction.file = null;
|
|
11452
|
+
transaction.receipt = classTransformer.plainToClass(TransactionReceipt, receiptResponse);
|
|
11453
|
+
replace(_this.cache, transaction);
|
|
11454
|
+
_this.updateCache();
|
|
11455
|
+
});
|
|
11456
|
+
};
|
|
11457
|
+
/**
|
|
11458
|
+
* calculate gross income amount based on transaction amount and taxes (fees)
|
|
11459
|
+
* @param transaction Transaction instance for calculation
|
|
11460
|
+
*/
|
|
11461
|
+
TransactionService.prototype.calculateGrossAmount = function (transaction) {
|
|
11462
|
+
var amount = transaction.amount || 0;
|
|
11463
|
+
// gross income amount includes amount of fees for property tank and tax for work tank
|
|
11464
|
+
if (transaction.isPropertyTank()) {
|
|
11465
|
+
amount += transaction.transactions.reduce(function (sum, item) { return sum + item.amount; }, 0);
|
|
11466
|
+
}
|
|
11467
|
+
else {
|
|
11468
|
+
// @TODO Alex: fix logic after TT-641 ready
|
|
11469
|
+
amount += (transaction.tax || 0);
|
|
11470
|
+
}
|
|
11471
|
+
return amount;
|
|
11472
|
+
};
|
|
11473
|
+
/**
|
|
11474
|
+
* get label for transaction tax field depended of selected chart account.
|
|
11475
|
+
* tax type depends of chart account heading or category.
|
|
11476
|
+
*/
|
|
11477
|
+
TransactionService.prototype.getTaxLabel = function (chartAccounts) {
|
|
11478
|
+
var _a, _b;
|
|
11479
|
+
// get simple array of ids from enum with taxable chart accounts headings
|
|
11480
|
+
var taxableCAHeadingsIds = enumToList(exports.ChartAccountsHeadingTaxableEnum)
|
|
11481
|
+
.map(function (item) { return item.value; });
|
|
11482
|
+
// get simple array of ids from enum with tax deductible chart accounts headings
|
|
11483
|
+
var deductibleCAHeadingsIds = enumToList(exports.ChartAccountsHeadingTaxDeductibleEnum)
|
|
11484
|
+
.map(function (item) { return item.value; });
|
|
11485
|
+
// check if one of ids arrays includes current chart accounts heading id and set tax label
|
|
11486
|
+
// otherwise label is empty for this class
|
|
11487
|
+
switch (true) {
|
|
11488
|
+
case taxableCAHeadingsIds.includes((_a = chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id):
|
|
11489
|
+
return exports.ChartAccountsTaxLabelsEnum.TAX_PAID;
|
|
11490
|
+
case deductibleCAHeadingsIds.includes((_b = chartAccounts.heading) === null || _b === void 0 ? void 0 : _b.id):
|
|
11491
|
+
return exports.ChartAccountsTaxLabelsEnum.TAX_DEDUCTED;
|
|
11492
|
+
case CHART_ACCOUNTS_CATEGORIES.workIncome.includes(chartAccounts.category):
|
|
11493
|
+
return exports.ChartAccountsTaxLabelsEnum.TAX_WITHHELD;
|
|
11494
|
+
default:
|
|
11495
|
+
return null;
|
|
11496
|
+
}
|
|
11497
|
+
};
|
|
11498
|
+
/**
|
|
11499
|
+
* Get transactions related to Vehicle category
|
|
11500
|
+
*/
|
|
11501
|
+
TransactionService.prototype.getVehicleTransactions = function () {
|
|
11502
|
+
return this.get().pipe(operators.map(function (transactions) {
|
|
11503
|
+
return transactions.filter(function (transaction) { return transaction.isVehicleTransaction(); });
|
|
11504
|
+
}));
|
|
11505
|
+
};
|
|
11506
|
+
/**
|
|
11507
|
+
* Listen to EventDispatcherService event related to Depreciation changing
|
|
11508
|
+
*/
|
|
11509
|
+
TransactionService.prototype.listenDepreciationChange = function () {
|
|
11510
|
+
var _this = this;
|
|
11511
|
+
this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATION_DELETED).subscribe(function () {
|
|
11512
|
+
_this.fetch()
|
|
11513
|
+
.subscribe(function (transactions) {
|
|
11514
|
+
_this.cache = transactions;
|
|
11515
|
+
_this.updateCache();
|
|
11516
|
+
});
|
|
11517
|
+
});
|
|
11518
|
+
};
|
|
11519
|
+
/**
|
|
11520
|
+
* Listen to EventDispatcherService event related to Property Share changing
|
|
11521
|
+
*/
|
|
11522
|
+
TransactionService.prototype.listenPropertyShareUpdate = function () {
|
|
11523
|
+
var _this = this;
|
|
11524
|
+
this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(function () { return _this.resetCache(); });
|
|
11525
|
+
};
|
|
11526
|
+
return TransactionService;
|
|
11527
|
+
}(RestService));
|
|
11528
|
+
TransactionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11529
|
+
TransactionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, providedIn: 'root' });
|
|
11530
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, decorators: [{
|
|
11432
11531
|
type: i0.Injectable,
|
|
11433
11532
|
args: [{
|
|
11434
11533
|
providedIn: 'root'
|
|
11435
11534
|
}]
|
|
11436
11535
|
}], ctorParameters: function () {
|
|
11437
|
-
return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
|
|
11536
|
+
return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
11438
11537
|
type: i0.Inject,
|
|
11439
11538
|
args: ['environment']
|
|
11440
|
-
}] }];
|
|
11539
|
+
}] }, { type: ToastService }];
|
|
11441
11540
|
} });
|
|
11442
11541
|
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11542
|
+
/**
|
|
11543
|
+
* Service to handle Property transactions report items data (get income / expense report items, e.t.c.)
|
|
11544
|
+
*/
|
|
11545
|
+
var PropertyTransactionReportService = /** @class */ (function () {
|
|
11546
|
+
function PropertyTransactionReportService(propertyService, transactionService, depreciationService, chartAccountsService) {
|
|
11547
|
+
this.propertyService = propertyService;
|
|
11548
|
+
this.transactionService = transactionService;
|
|
11549
|
+
this.depreciationService = depreciationService;
|
|
11550
|
+
this.chartAccountsService = chartAccountsService;
|
|
11450
11551
|
}
|
|
11451
|
-
|
|
11552
|
+
/**
|
|
11553
|
+
* Get collections dictionary of income report items, grouped by property id
|
|
11554
|
+
*/
|
|
11555
|
+
PropertyTransactionReportService.prototype.getIncomes = function () {
|
|
11452
11556
|
var _this = this;
|
|
11453
|
-
return
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11557
|
+
return rxjs.combineLatest([
|
|
11558
|
+
this.getProperties(),
|
|
11559
|
+
this.getTransactions(),
|
|
11560
|
+
this.getChartAccounts(),
|
|
11561
|
+
]).pipe(operators.map(function (_a) {
|
|
11562
|
+
var _b = __read(_a, 3), properties = _b[0], transactions = _b[1], chartAccounts = _b[2];
|
|
11563
|
+
return _this.initIncomeItemsData(transactions, properties, chartAccounts);
|
|
11457
11564
|
}));
|
|
11458
11565
|
};
|
|
11459
|
-
|
|
11566
|
+
/**
|
|
11567
|
+
* Get collections dictionary of expense report items, grouped by property id
|
|
11568
|
+
*/
|
|
11569
|
+
PropertyTransactionReportService.prototype.getExpenses = function () {
|
|
11460
11570
|
var _this = this;
|
|
11461
|
-
return
|
|
11462
|
-
|
|
11463
|
-
|
|
11571
|
+
return rxjs.combineLatest([
|
|
11572
|
+
this.getProperties(),
|
|
11573
|
+
this.getTransactions(),
|
|
11574
|
+
this.getDepreciations(),
|
|
11575
|
+
this.getChartAccounts()
|
|
11576
|
+
]).pipe(operators.map(function (_a) {
|
|
11577
|
+
var _b = __read(_a, 4), properties = _b[0], transactions = _b[1], depreciations = _b[2], chartAccounts = _b[3];
|
|
11578
|
+
return _this.initExpenseItemsData(transactions, depreciations, properties, chartAccounts);
|
|
11579
|
+
}));
|
|
11580
|
+
};
|
|
11581
|
+
PropertyTransactionReportService.prototype.initIncomeItemsData = function (transactions, properties, chartAccounts) {
|
|
11582
|
+
// empty collection dictionary to be filled with income report items
|
|
11583
|
+
var incomesByProperty = new CollectionDictionary(new Collection([]), 'property.id');
|
|
11584
|
+
var incomeTransactionsByProperty = new CollectionDictionary(transactions.getIncomeTransactions(), 'property.id');
|
|
11585
|
+
incomeTransactionsByProperty.keys.forEach(function (propertyId) {
|
|
11586
|
+
incomesByProperty.add(propertyId, new PropertyReportItemTransactionCollection(incomeTransactionsByProperty.get(propertyId), properties.getById(+propertyId), chartAccounts));
|
|
11587
|
+
});
|
|
11588
|
+
return incomesByProperty;
|
|
11589
|
+
};
|
|
11590
|
+
PropertyTransactionReportService.prototype.initExpenseItemsData = function (transactions, depreciations, properties, chartAccounts) {
|
|
11591
|
+
// empty collection dictionary to be filled with expense report items
|
|
11592
|
+
var expensesByProperty = new CollectionDictionary(new Collection([]), 'property.id');
|
|
11593
|
+
var transactionsByProperty = new CollectionDictionary(transactions.getExpenseTransactions(), 'property.id');
|
|
11594
|
+
var depreciationsByProperty = new CollectionDictionary(depreciations, 'property.id');
|
|
11595
|
+
transactionsByProperty.keys.forEach(function (propertyId) {
|
|
11596
|
+
expensesByProperty.add(propertyId, new Collection(__spreadArray(__spreadArray([], __read(new PropertyReportItemTransactionCollection(transactionsByProperty.get(propertyId), properties.getById(+propertyId), chartAccounts).items)), __read(new PropertyReportItemDepreciationCollection(depreciationsByProperty.get(propertyId), properties.getById(+propertyId), chartAccounts).items))));
|
|
11597
|
+
});
|
|
11598
|
+
return expensesByProperty;
|
|
11599
|
+
};
|
|
11600
|
+
/**
|
|
11601
|
+
* Get colection of property transactions
|
|
11602
|
+
*/
|
|
11603
|
+
PropertyTransactionReportService.prototype.getTransactions = function () {
|
|
11604
|
+
return this.transactionService.get().pipe(operators.map(function (transactions) {
|
|
11605
|
+
return new TransactionCollection(transactions)
|
|
11606
|
+
.getByChartAccountsCategories(CHART_ACCOUNTS_CATEGORIES.property);
|
|
11464
11607
|
}));
|
|
11465
11608
|
};
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11609
|
+
/**
|
|
11610
|
+
* Get list of asset & capital property depreciations
|
|
11611
|
+
*/
|
|
11612
|
+
PropertyTransactionReportService.prototype.getDepreciations = function () {
|
|
11613
|
+
return this.depreciationService.get().pipe(operators.map(function (depreciations) {
|
|
11614
|
+
return new DepreciationCollection(depreciations)
|
|
11615
|
+
.getByChartAccountsCategories(CHART_ACCOUNTS_CATEGORIES.property)
|
|
11616
|
+
.getWithoutBorrowingExpenses();
|
|
11470
11617
|
}));
|
|
11471
11618
|
};
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
return movements.filter(function (movement) { return movement.property.id === id; });
|
|
11619
|
+
PropertyTransactionReportService.prototype.getProperties = function () {
|
|
11620
|
+
return this.propertyService.get().pipe(operators.map(function (properties) {
|
|
11621
|
+
return new PropertyCollection(properties);
|
|
11476
11622
|
}));
|
|
11477
11623
|
};
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11624
|
+
PropertyTransactionReportService.prototype.getChartAccounts = function () {
|
|
11625
|
+
return this.chartAccountsService.getChartAccounts().pipe(operators.map(function (chartAccounts) {
|
|
11626
|
+
return new Collection(chartAccounts);
|
|
11627
|
+
}));
|
|
11628
|
+
};
|
|
11629
|
+
return PropertyTransactionReportService;
|
|
11630
|
+
}());
|
|
11631
|
+
PropertyTransactionReportService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyTransactionReportService, deps: [{ token: PropertyService }, { token: TransactionService }, { token: DepreciationService }, { token: ChartAccountsService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11632
|
+
PropertyTransactionReportService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyTransactionReportService, providedIn: 'root' });
|
|
11633
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyTransactionReportService, decorators: [{
|
|
11483
11634
|
type: i0.Injectable,
|
|
11484
11635
|
args: [{
|
|
11485
11636
|
providedIn: 'root'
|
|
11486
11637
|
}]
|
|
11487
|
-
}] });
|
|
11638
|
+
}], ctorParameters: function () { return [{ type: PropertyService }, { type: TransactionService }, { type: DepreciationService }, { type: ChartAccountsService }]; } });
|
|
11488
11639
|
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
this.serviceSubscriptionSubject = new rxjs.ReplaySubject(1);
|
|
11496
|
-
this.serviceSubscriptionsSubject = new rxjs.ReplaySubject(1);
|
|
11497
|
-
this.servicePaymentsSubject = new rxjs.ReplaySubject(1);
|
|
11498
|
-
this.subscriptionChangeSubject = new rxjs.BehaviorSubject(null);
|
|
11499
|
-
this.listenEvents();
|
|
11640
|
+
/**
|
|
11641
|
+
* Service with calculations methods for properties related with other entities.
|
|
11642
|
+
* Logic here works like collections methods but for several entities
|
|
11643
|
+
*/
|
|
11644
|
+
var PropertyCalculationService = /** @class */ (function () {
|
|
11645
|
+
function PropertyCalculationService() {
|
|
11500
11646
|
}
|
|
11501
|
-
|
|
11502
|
-
|
|
11647
|
+
PropertyCalculationService.prototype.getTaxPosition = function (transactions, depreciations) {
|
|
11648
|
+
// @TODO hack: math abs added because we have mismatching of real values signs
|
|
11649
|
+
return transactions.cashPosition - Math.abs(depreciations.claimAmount);
|
|
11503
11650
|
};
|
|
11504
|
-
|
|
11651
|
+
PropertyCalculationService.prototype.getTaxPosition$ = function (transactions$, depreciations$) {
|
|
11505
11652
|
var _this = this;
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
/**
|
|
11520
|
-
* @TODO right now we have only monthly prices, the function should be refactored to support other options in future
|
|
11521
|
-
*
|
|
11522
|
-
* create available subscription plans based on existing products
|
|
11523
|
-
*/
|
|
11524
|
-
SubscriptionService.prototype.getSubscriptionPlans = function () {
|
|
11525
|
-
var _this = this;
|
|
11526
|
-
if (!this._serviceSubscriptions) {
|
|
11527
|
-
this.http.get(this.environment.apiV2 + "/service-prices")
|
|
11528
|
-
.pipe(operators.map(function (response) {
|
|
11529
|
-
return new ServicePriceCollection(response['hydra:member'].map(function (item) { return classTransformer.plainToClass(ServicePrice, item); }));
|
|
11530
|
-
}))
|
|
11531
|
-
.subscribe(function (prices) {
|
|
11532
|
-
_this._serviceSubscriptions = new ServiceSubscriptionCollection([
|
|
11533
|
-
classTransformer.plainToClass(ServiceSubscription, { items: [] }),
|
|
11534
|
-
classTransformer.plainToClass(ServiceSubscription, {
|
|
11535
|
-
items: [classTransformer.plainToClass(ServiceSubscriptionItem, {
|
|
11536
|
-
price: prices.property,
|
|
11537
|
-
quantity: 2
|
|
11538
|
-
})]
|
|
11539
|
-
}),
|
|
11540
|
-
classTransformer.plainToClass(ServiceSubscription, {
|
|
11541
|
-
items: [classTransformer.plainToClass(ServiceSubscriptionItem, {
|
|
11542
|
-
price: prices.property,
|
|
11543
|
-
quantity: 3
|
|
11544
|
-
})]
|
|
11545
|
-
})
|
|
11546
|
-
]);
|
|
11547
|
-
_this._serviceSubscriptions.items.forEach(function (subscription) {
|
|
11548
|
-
subscription.items.push(classTransformer.plainToClass(ServiceSubscriptionItem, { price: prices.work, quantity: 1 }));
|
|
11549
|
-
});
|
|
11550
|
-
_this.serviceSubscriptionsSubject.next(_this._serviceSubscriptions);
|
|
11551
|
-
});
|
|
11653
|
+
return rxjs.combineLatest([
|
|
11654
|
+
transactions$,
|
|
11655
|
+
depreciations$
|
|
11656
|
+
]).pipe(operators.map(function (_b) {
|
|
11657
|
+
var _c = __read(_b, 2), transactions = _c[0], depreciations = _c[1];
|
|
11658
|
+
return _this.getTaxPosition(transactions, depreciations);
|
|
11659
|
+
}));
|
|
11660
|
+
};
|
|
11661
|
+
PropertyCalculationService.prototype.taxPositionGrowth = function (properties, transactions, depreciations) {
|
|
11662
|
+
var taxPosition = this.getTaxPosition(transactions, depreciations);
|
|
11663
|
+
// check if taxPosition = 0 to avoid division by zero
|
|
11664
|
+
if (!taxPosition) {
|
|
11665
|
+
return 0;
|
|
11552
11666
|
}
|
|
11553
|
-
return
|
|
11667
|
+
return (taxPosition - properties.forecastedTaxPosition) / taxPosition;
|
|
11554
11668
|
};
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11669
|
+
PropertyCalculationService.prototype.taxPositionGrowth$ = function (properties$, transactions$, depreciations$) {
|
|
11670
|
+
var _this = this;
|
|
11671
|
+
return rxjs.combineLatest([
|
|
11672
|
+
properties$,
|
|
11673
|
+
transactions$,
|
|
11674
|
+
depreciations$
|
|
11675
|
+
]).pipe(operators.map(function (_b) {
|
|
11676
|
+
var _c = __read(_b, 3), properties = _c[0], transactions = _c[1], depreciations = _c[2];
|
|
11677
|
+
return _this.taxPositionGrowth(properties, transactions, depreciations);
|
|
11678
|
+
}));
|
|
11679
|
+
};
|
|
11680
|
+
PropertyCalculationService.prototype.getRentalReturn = function (properties, transactions) {
|
|
11681
|
+
return transactions.claimIncome / properties.marketValue;
|
|
11682
|
+
};
|
|
11683
|
+
PropertyCalculationService.prototype.getLoanAmount = function (properties, bankAccounts, loans) {
|
|
11684
|
+
return properties.items.reduce(function (totalAmount, property) {
|
|
11685
|
+
return totalAmount + bankAccounts.items
|
|
11686
|
+
.reduce(function (propertyAmount, bankAccount) {
|
|
11687
|
+
var _a;
|
|
11688
|
+
return propertyAmount + bankAccount.getPropertyPercentage(property.id) * (((_a = loans.getByBankAccountId(bankAccount.id)) === null || _a === void 0 ? void 0 : _a.amount) || 0);
|
|
11689
|
+
}, 0);
|
|
11690
|
+
}, 0);
|
|
11691
|
+
};
|
|
11692
|
+
PropertyCalculationService.prototype.getLoanValue = function (properties, bankAccounts) {
|
|
11693
|
+
return properties.items.reduce(function (totalAmount, property) {
|
|
11694
|
+
return totalAmount + bankAccounts.items
|
|
11695
|
+
.reduce(function (propertyAmount, bankAccount) {
|
|
11696
|
+
return propertyAmount + bankAccount.getPropertyBalanceAmount(property.id);
|
|
11697
|
+
}, 0);
|
|
11698
|
+
}, 0);
|
|
11582
11699
|
};
|
|
11583
11700
|
/**
|
|
11584
|
-
*
|
|
11701
|
+
* LVR
|
|
11585
11702
|
*/
|
|
11586
|
-
|
|
11587
|
-
|
|
11588
|
-
|
|
11589
|
-
}).subscribe(function (response) {
|
|
11590
|
-
window.location.replace(response.url);
|
|
11591
|
-
});
|
|
11703
|
+
PropertyCalculationService.prototype.getLvr = function (properties, bankAccounts) {
|
|
11704
|
+
// Math abs is required for correct percentage calculation
|
|
11705
|
+
return Math.abs(this.getLoanValue(properties, bankAccounts)) / properties.marketValue;
|
|
11592
11706
|
};
|
|
11593
|
-
|
|
11707
|
+
PropertyCalculationService.prototype.getLvr$ = function (properties$, bankAccounts$) {
|
|
11594
11708
|
var _this = this;
|
|
11595
|
-
|
|
11596
|
-
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
|
|
11601
|
-
|
|
11709
|
+
return rxjs.combineLatest([
|
|
11710
|
+
properties$,
|
|
11711
|
+
bankAccounts$
|
|
11712
|
+
]).pipe(operators.map(function (_b) {
|
|
11713
|
+
var _c = __read(_b, 2), properties = _c[0], bankAccounts = _c[1];
|
|
11714
|
+
return _this.getLvr(properties, bankAccounts);
|
|
11715
|
+
}));
|
|
11602
11716
|
};
|
|
11603
|
-
|
|
11604
|
-
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
|
|
11717
|
+
PropertyCalculationService.prototype.getLvrCommencement = function (properties, loans, bankAccounts) {
|
|
11718
|
+
// Math abs is required for correct percentage calculation
|
|
11719
|
+
return Math.abs(this.getLoanAmount(properties, bankAccounts, loans)) / properties.purchasePrice;
|
|
11720
|
+
};
|
|
11721
|
+
PropertyCalculationService.prototype.getLvrCommencement$ = function (properties$, bankAccounts$, loans$) {
|
|
11722
|
+
var _this = this;
|
|
11723
|
+
return rxjs.combineLatest([
|
|
11724
|
+
properties$,
|
|
11725
|
+
bankAccounts$,
|
|
11726
|
+
loans$
|
|
11727
|
+
]).pipe(operators.map(function (_b) {
|
|
11728
|
+
var _c = __read(_b, 3), properties = _c[0], bankAccounts = _c[1], loans = _c[2];
|
|
11729
|
+
return _this.getLvrCommencement(properties, loans, bankAccounts);
|
|
11609
11730
|
}));
|
|
11610
11731
|
};
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
|
|
11732
|
+
PropertyCalculationService.prototype.getLvrGrowth = function (properties, bankAccounts, loans) {
|
|
11733
|
+
var lvr = this.getLvr(properties, bankAccounts);
|
|
11734
|
+
if (!lvr) {
|
|
11735
|
+
// check if lvr = 0 to avoid division by zero
|
|
11736
|
+
return 0;
|
|
11737
|
+
}
|
|
11738
|
+
return (lvr - this.getLvrCommencement(properties, loans, bankAccounts)) / lvr;
|
|
11616
11739
|
};
|
|
11617
|
-
|
|
11740
|
+
PropertyCalculationService.prototype.getLvrGrowth$ = function (properties$, bankAccounts$, loans$) {
|
|
11618
11741
|
var _this = this;
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11742
|
+
return rxjs.combineLatest([
|
|
11743
|
+
properties$,
|
|
11744
|
+
bankAccounts$,
|
|
11745
|
+
loans$
|
|
11746
|
+
]).pipe(operators.map(function (_b) {
|
|
11747
|
+
var _c = __read(_b, 3), properties = _c[0], bankAccounts = _c[1], loans = _c[2];
|
|
11748
|
+
return _this.getLvrGrowth(properties, bankAccounts, loans);
|
|
11749
|
+
}));
|
|
11626
11750
|
};
|
|
11627
|
-
|
|
11751
|
+
PropertyCalculationService.prototype.getEquityPosition = function (properties, bankAccounts) {
|
|
11752
|
+
// Math abs is required for correct percentage calculation
|
|
11753
|
+
return properties.marketValue - Math.abs(this.getLoanValue(properties, bankAccounts));
|
|
11754
|
+
};
|
|
11755
|
+
PropertyCalculationService.prototype.getPurchaseEquity = function (properties, bankAccounts, loans) {
|
|
11756
|
+
// Math abs is required for correct percentage calculation
|
|
11757
|
+
return properties.purchasePrice - Math.abs(this.getLoanAmount(properties, bankAccounts, loans));
|
|
11758
|
+
};
|
|
11759
|
+
return PropertyCalculationService;
|
|
11628
11760
|
}());
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
11761
|
+
PropertyCalculationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCalculationService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11762
|
+
PropertyCalculationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCalculationService, providedIn: 'root' });
|
|
11763
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCalculationService, decorators: [{
|
|
11632
11764
|
type: i0.Injectable,
|
|
11633
11765
|
args: [{
|
|
11634
11766
|
providedIn: 'root'
|
|
11635
11767
|
}]
|
|
11636
|
-
}]
|
|
11637
|
-
return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
|
|
11638
|
-
type: i0.Inject,
|
|
11639
|
-
args: ['environment']
|
|
11640
|
-
}] }];
|
|
11641
|
-
} });
|
|
11768
|
+
}] });
|
|
11642
11769
|
|
|
11643
11770
|
/**
|
|
11644
|
-
* Service
|
|
11771
|
+
* Service for work with Property Categories
|
|
11645
11772
|
*/
|
|
11646
|
-
var
|
|
11647
|
-
__extends(
|
|
11648
|
-
function
|
|
11773
|
+
var PropertyCategoryService = /** @class */ (function (_super) {
|
|
11774
|
+
__extends(PropertyCategoryService, _super);
|
|
11775
|
+
function PropertyCategoryService() {
|
|
11776
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
11777
|
+
_this.modelClass = PropertyCategory;
|
|
11778
|
+
_this.url = 'properties/categories';
|
|
11779
|
+
return _this;
|
|
11780
|
+
}
|
|
11781
|
+
return PropertyCategoryService;
|
|
11782
|
+
}(RestService));
|
|
11783
|
+
PropertyCategoryService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11784
|
+
PropertyCategoryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryService, providedIn: 'root' });
|
|
11785
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryService, decorators: [{
|
|
11786
|
+
type: i0.Injectable,
|
|
11787
|
+
args: [{
|
|
11788
|
+
providedIn: 'root'
|
|
11789
|
+
}]
|
|
11790
|
+
}] });
|
|
11791
|
+
|
|
11792
|
+
/**
|
|
11793
|
+
* Class for work with Property Documents
|
|
11794
|
+
*/
|
|
11795
|
+
var PropertyDocumentService = /** @class */ (function (_super) {
|
|
11796
|
+
__extends(PropertyDocumentService, _super);
|
|
11797
|
+
function PropertyDocumentService(http, eventDispatcherService, environment) {
|
|
11649
11798
|
var _this = _super.call(this, http, eventDispatcherService, environment) || this;
|
|
11650
11799
|
_this.http = http;
|
|
11651
11800
|
_this.eventDispatcherService = eventDispatcherService;
|
|
11652
11801
|
_this.environment = environment;
|
|
11653
|
-
_this.
|
|
11654
|
-
_this.
|
|
11802
|
+
_this.modelClass = PropertyDocument;
|
|
11803
|
+
_this.url = 'properties/documents';
|
|
11655
11804
|
_this.listenEvents();
|
|
11656
11805
|
return _this;
|
|
11657
11806
|
}
|
|
11658
11807
|
/**
|
|
11659
|
-
*
|
|
11808
|
+
* Add new Property Document
|
|
11660
11809
|
*/
|
|
11661
|
-
|
|
11662
|
-
this
|
|
11663
|
-
|
|
11810
|
+
PropertyDocumentService.prototype.upload = function (file, propertyId) {
|
|
11811
|
+
var _this = this;
|
|
11812
|
+
// create formData object with provided file
|
|
11813
|
+
var formDataDocument = new FormData();
|
|
11814
|
+
formDataDocument.append('file', file);
|
|
11815
|
+
return this.http.post(this.environment.apiV2 + "/properties/" + propertyId + "/documents", formDataDocument).pipe(operators.map(function (documentBase) {
|
|
11816
|
+
var newDocument = classTransformer.plainToClass(PropertyDocument, documentBase);
|
|
11817
|
+
if (_this.cache) {
|
|
11818
|
+
_this.cache.push(newDocument);
|
|
11819
|
+
_this.updateCache();
|
|
11820
|
+
}
|
|
11821
|
+
return newDocument;
|
|
11822
|
+
}));
|
|
11664
11823
|
};
|
|
11665
11824
|
/**
|
|
11666
|
-
*
|
|
11667
|
-
* @param
|
|
11668
|
-
*/
|
|
11669
|
-
TaxReviewService.prototype.request = function (finYear) {
|
|
11670
|
-
var _this = this;
|
|
11671
|
-
return this.http.post(this.environment.apiV2 + "/" + this.url + "?financialYear=" + finYear, {})
|
|
11672
|
-
.pipe(operators.map(function (newTaxReview) {
|
|
11673
|
-
var taxReview = classTransformer.plainToClass(TaxReview, newTaxReview);
|
|
11674
|
-
var tempCache = ___default["default"].cloneDeep(_this.cache);
|
|
11675
|
-
tempCache.push(taxReview);
|
|
11676
|
-
_this.cache = tempCache;
|
|
11677
|
-
_this.updateCache();
|
|
11678
|
-
return taxReview;
|
|
11679
|
-
}));
|
|
11680
|
-
};
|
|
11681
|
-
/**
|
|
11682
|
-
* Update tax review
|
|
11683
|
-
* @param taxReview to be updated
|
|
11825
|
+
* Get documents by property id
|
|
11826
|
+
* @param propertyId to get desired documents
|
|
11684
11827
|
*/
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TAX_REVIEW_UPDATED, updatedInstance));
|
|
11691
|
-
var tempCache = ___default["default"].cloneDeep(_this.cache);
|
|
11692
|
-
replace(tempCache, updatedInstance);
|
|
11693
|
-
_this.cache = tempCache;
|
|
11694
|
-
_this.updateCache();
|
|
11695
|
-
return updatedInstance;
|
|
11828
|
+
PropertyDocumentService.prototype.getByPropertyId = function (propertyId) {
|
|
11829
|
+
return this.get()
|
|
11830
|
+
.pipe(operators.map(function (documents) {
|
|
11831
|
+
return documents
|
|
11832
|
+
.filter(function (document) { return document.property.id === propertyId; });
|
|
11696
11833
|
}));
|
|
11697
11834
|
};
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
*/
|
|
11701
|
-
TaxReviewService.prototype.listenFirmChanges = function () {
|
|
11702
|
-
var _this = this;
|
|
11703
|
-
this.eventDispatcherService.on([exports.AppEventTypeEnum.CLIENT_MOVEMENT_CLOSED, exports.AppEventTypeEnum.CLIENT_INVITE_ACCEPTED])
|
|
11704
|
-
.subscribe(function () {
|
|
11705
|
-
_this.cache = [];
|
|
11706
|
-
_this.updateCache();
|
|
11707
|
-
});
|
|
11835
|
+
PropertyDocumentService.prototype.listenEvents = function () {
|
|
11836
|
+
this.listenPropertyUpdateWithDocument();
|
|
11708
11837
|
};
|
|
11709
|
-
|
|
11710
|
-
* Update firm for all transferred clients
|
|
11711
|
-
* @private
|
|
11712
|
-
*/
|
|
11713
|
-
TaxReviewService.prototype.listenClientTransfer = function () {
|
|
11838
|
+
PropertyDocumentService.prototype.listenPropertyUpdateWithDocument = function () {
|
|
11714
11839
|
var _this = this;
|
|
11715
|
-
this.eventDispatcherService.on(exports.AppEventTypeEnum.
|
|
11716
|
-
.
|
|
11717
|
-
var tempCache = ___default["default"].cloneDeep(_this.cache);
|
|
11718
|
-
transferredClients.forEach(function (transferredClient) {
|
|
11719
|
-
var taxReviewIndex = tempCache.findIndex(function (taxReview) { return taxReview.id === transferredClient.id; });
|
|
11720
|
-
// @TODO vik
|
|
11721
|
-
// tempCache[taxReviewIndex].employee = transferredClient.accountant;
|
|
11722
|
-
});
|
|
11723
|
-
_this.cache = tempCache;
|
|
11724
|
-
_this.updateCache();
|
|
11840
|
+
this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_UPDATED_WITH_DOCUMENT).subscribe(function (property) {
|
|
11841
|
+
_this.upload(property.documentFile, property.id).subscribe();
|
|
11725
11842
|
});
|
|
11726
11843
|
};
|
|
11727
|
-
return
|
|
11844
|
+
return PropertyDocumentService;
|
|
11728
11845
|
}(RestService));
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
11846
|
+
PropertyDocumentService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyDocumentService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11847
|
+
PropertyDocumentService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyDocumentService, providedIn: 'root' });
|
|
11848
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyDocumentService, decorators: [{
|
|
11732
11849
|
type: i0.Injectable,
|
|
11733
11850
|
args: [{
|
|
11734
11851
|
providedIn: 'root'
|
|
@@ -11740,101 +11857,107 @@
|
|
|
11740
11857
|
}] }];
|
|
11741
11858
|
} });
|
|
11742
11859
|
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
__extends(TaxReviewHistoryService, _super);
|
|
11748
|
-
function TaxReviewHistoryService(http, eventDispatcherService, environment) {
|
|
11860
|
+
// @TODO check and improve logic during refactoring
|
|
11861
|
+
var PropertyShareService = /** @class */ (function (_super) {
|
|
11862
|
+
__extends(PropertyShareService, _super);
|
|
11863
|
+
function PropertyShareService(http, eventDispatcherService, environment) {
|
|
11749
11864
|
var _this = _super.call(this, http, eventDispatcherService, environment) || this;
|
|
11750
11865
|
_this.http = http;
|
|
11751
11866
|
_this.eventDispatcherService = eventDispatcherService;
|
|
11752
11867
|
_this.environment = environment;
|
|
11753
|
-
|
|
11754
|
-
_this.
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
var tempCache = ___default["default"].cloneDeep(_this.cache);
|
|
11758
|
-
// insert element at the beginning of the array
|
|
11759
|
-
tempCache.unshift(taxReview);
|
|
11760
|
-
_this.cache = tempCache;
|
|
11761
|
-
_this.updateCache();
|
|
11762
|
-
});
|
|
11868
|
+
// api url parameter for properties shares
|
|
11869
|
+
_this.url = 'properties/shares';
|
|
11870
|
+
_this.modelClass = PropertyShare;
|
|
11871
|
+
_this.listenEvents();
|
|
11763
11872
|
return _this;
|
|
11764
11873
|
}
|
|
11765
|
-
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
|
|
11769
|
-
|
|
11770
|
-
type: i0.Injectable,
|
|
11771
|
-
args: [{
|
|
11772
|
-
providedIn: 'root'
|
|
11773
|
-
}]
|
|
11774
|
-
}], ctorParameters: function () {
|
|
11775
|
-
return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
11776
|
-
type: i0.Inject,
|
|
11777
|
-
args: ['environment']
|
|
11778
|
-
}] }];
|
|
11779
|
-
} });
|
|
11780
|
-
|
|
11781
|
-
/**
|
|
11782
|
-
* Service to work with tax summary logic
|
|
11783
|
-
*/
|
|
11784
|
-
var TaxSummaryService = /** @class */ (function () {
|
|
11785
|
-
function TaxSummaryService(http, eventDispatcherService, environment) {
|
|
11786
|
-
this.http = http;
|
|
11787
|
-
this.eventDispatcherService = eventDispatcherService;
|
|
11788
|
-
this.environment = environment;
|
|
11789
|
-
this.taxSummaryActualsSubject = new rxjs.ReplaySubject(1);
|
|
11790
|
-
this.taxSummaryForecastsSubject = new rxjs.ReplaySubject(1);
|
|
11791
|
-
this.listenEvents();
|
|
11792
|
-
}
|
|
11793
|
-
TaxSummaryService.prototype.listenEvents = function () {
|
|
11794
|
-
this.listenToIncomeSourceForecastsEvents();
|
|
11874
|
+
/**
|
|
11875
|
+
* Listen to Event Dispatcher events
|
|
11876
|
+
*/
|
|
11877
|
+
PropertyShareService.prototype.listenEvents = function () {
|
|
11878
|
+
this.listenUserUpdated();
|
|
11795
11879
|
};
|
|
11796
11880
|
/**
|
|
11797
|
-
*
|
|
11881
|
+
* Updated loan
|
|
11798
11882
|
*/
|
|
11799
|
-
|
|
11883
|
+
PropertyShareService.prototype.update = function (propertyShare) {
|
|
11800
11884
|
var _this = this;
|
|
11801
|
-
this.http.
|
|
11802
|
-
.
|
|
11803
|
-
var
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
|
|
11807
|
-
|
|
11885
|
+
return this.http.put(this.environment.apiV2 + "/" + this.url + "/" + propertyShare.id, propertyShare)
|
|
11886
|
+
.pipe(operators.map(function (updatedPropertyShareBase) {
|
|
11887
|
+
var updatedPropertyShare = classTransformer.plainToClass(PropertyShare, updatedPropertyShareBase);
|
|
11888
|
+
// if loan type is NOT vehicle - fire EventDispatcher event
|
|
11889
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_SHARE_UPDATED, null));
|
|
11890
|
+
replace(_this.cache, updatedPropertyShare);
|
|
11891
|
+
_this.updateCache();
|
|
11892
|
+
return updatedPropertyShare;
|
|
11893
|
+
}));
|
|
11808
11894
|
};
|
|
11809
11895
|
/**
|
|
11810
|
-
*
|
|
11896
|
+
* Re-invite property share
|
|
11897
|
+
* @param share user to share property
|
|
11811
11898
|
*/
|
|
11812
|
-
|
|
11899
|
+
PropertyShareService.prototype.reinvite = function (share) {
|
|
11900
|
+
return this.http.post(this.environment.apiV2 + "/" + this.url + "/" + share.id + "/reinvite", {});
|
|
11901
|
+
};
|
|
11902
|
+
PropertyShareService.prototype.getIncoming = function () {
|
|
11903
|
+
return this.get()
|
|
11904
|
+
.pipe(operators.map(function (propertyShares) {
|
|
11905
|
+
var propertySharesIncoming = [];
|
|
11906
|
+
propertyShares.forEach(function (propertyShare) {
|
|
11907
|
+
var _a;
|
|
11908
|
+
if (((_a = propertyShare.user) === null || _a === void 0 ? void 0 : _a.isLoggedIn()) && propertyShare.isPending() && propertyShare.property.user.id !== +localStorage.getItem('userId')) {
|
|
11909
|
+
propertySharesIncoming.push(propertyShare);
|
|
11910
|
+
}
|
|
11911
|
+
});
|
|
11912
|
+
return propertySharesIncoming;
|
|
11913
|
+
}));
|
|
11914
|
+
};
|
|
11915
|
+
/**
|
|
11916
|
+
* Get outcoming property shares list
|
|
11917
|
+
*/
|
|
11918
|
+
PropertyShareService.prototype.getOutcoming = function () {
|
|
11813
11919
|
var _this = this;
|
|
11814
|
-
this.
|
|
11815
|
-
.
|
|
11816
|
-
|
|
11817
|
-
|
|
11818
|
-
|
|
11920
|
+
return this.get().pipe(operators.map(function (propertyShares) {
|
|
11921
|
+
return _this.filterOutcoming(propertyShares);
|
|
11922
|
+
}));
|
|
11923
|
+
};
|
|
11924
|
+
/**
|
|
11925
|
+
* Filter outcoming property shares
|
|
11926
|
+
*/
|
|
11927
|
+
PropertyShareService.prototype.filterOutcoming = function (propertyShares) {
|
|
11928
|
+
var propertySharesOutcoming = [];
|
|
11929
|
+
propertyShares.forEach(function (propertyShare) {
|
|
11930
|
+
var _a;
|
|
11931
|
+
if (!((_a = propertyShare.user) === null || _a === void 0 ? void 0 : _a.isLoggedIn())) {
|
|
11932
|
+
propertySharesOutcoming.push(propertyShare);
|
|
11933
|
+
}
|
|
11819
11934
|
});
|
|
11820
|
-
return
|
|
11935
|
+
return propertySharesOutcoming;
|
|
11936
|
+
};
|
|
11937
|
+
PropertyShareService.prototype.getByPropertyId = function (propertyId) {
|
|
11938
|
+
return this.get()
|
|
11939
|
+
.pipe(operators.map(function (propertyShares) {
|
|
11940
|
+
return propertyShares.filter(function (propertyShare) { return propertyShare.property.id === propertyId; });
|
|
11941
|
+
}));
|
|
11821
11942
|
};
|
|
11822
11943
|
/**
|
|
11823
|
-
* Listen to
|
|
11944
|
+
* Listen to User updated event
|
|
11824
11945
|
*/
|
|
11825
|
-
|
|
11946
|
+
PropertyShareService.prototype.listenUserUpdated = function () {
|
|
11826
11947
|
var _this = this;
|
|
11827
|
-
this.eventDispatcherService
|
|
11828
|
-
.on([exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED])
|
|
11948
|
+
this.eventDispatcherService.on(exports.AppEventTypeEnum.USER_UPDATED)
|
|
11829
11949
|
.subscribe(function () {
|
|
11830
|
-
_this.
|
|
11950
|
+
_this.fetch().subscribe(function (propertyShares) {
|
|
11951
|
+
_this.cache = propertyShares;
|
|
11952
|
+
_this.updateCache();
|
|
11953
|
+
});
|
|
11831
11954
|
});
|
|
11832
11955
|
};
|
|
11833
|
-
return
|
|
11834
|
-
}());
|
|
11835
|
-
|
|
11836
|
-
|
|
11837
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
11956
|
+
return PropertyShareService;
|
|
11957
|
+
}(RestService));
|
|
11958
|
+
PropertyShareService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyShareService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11959
|
+
PropertyShareService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyShareService, providedIn: 'root' });
|
|
11960
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyShareService, decorators: [{
|
|
11838
11961
|
type: i0.Injectable,
|
|
11839
11962
|
args: [{
|
|
11840
11963
|
providedIn: 'root'
|
|
@@ -11846,393 +11969,461 @@
|
|
|
11846
11969
|
}] }];
|
|
11847
11970
|
} });
|
|
11848
11971
|
|
|
11972
|
+
var PropertySaleService = /** @class */ (function (_super) {
|
|
11973
|
+
__extends(PropertySaleService, _super);
|
|
11974
|
+
function PropertySaleService() {
|
|
11975
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
11976
|
+
_this.modelClass = PropertySale;
|
|
11977
|
+
_this.url = 'properties/sales';
|
|
11978
|
+
return _this;
|
|
11979
|
+
}
|
|
11980
|
+
return PropertySaleService;
|
|
11981
|
+
}(RestService));
|
|
11982
|
+
PropertySaleService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertySaleService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11983
|
+
PropertySaleService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertySaleService, providedIn: 'root' });
|
|
11984
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertySaleService, decorators: [{
|
|
11985
|
+
type: i0.Injectable,
|
|
11986
|
+
args: [{
|
|
11987
|
+
providedIn: 'root'
|
|
11988
|
+
}]
|
|
11989
|
+
}] });
|
|
11990
|
+
|
|
11849
11991
|
/**
|
|
11850
|
-
*
|
|
11992
|
+
* Service for get property equity position half-year history chart data
|
|
11851
11993
|
*/
|
|
11852
|
-
var
|
|
11853
|
-
function
|
|
11854
|
-
this.
|
|
11994
|
+
var EquityPositionChartService = /** @class */ (function () {
|
|
11995
|
+
function EquityPositionChartService(http, environment) {
|
|
11996
|
+
this.http = http;
|
|
11997
|
+
this.environment = environment;
|
|
11855
11998
|
}
|
|
11856
|
-
|
|
11857
|
-
|
|
11858
|
-
|
|
11859
|
-
|
|
11860
|
-
|
|
11999
|
+
EquityPositionChartService.prototype.get = function () {
|
|
12000
|
+
// @TODO refactor backend
|
|
12001
|
+
return this.http.get(this.environment.apiV2 + "/properties/categories/equity")
|
|
12002
|
+
.pipe(operators.map(function (response) {
|
|
12003
|
+
return response.map(function (item) {
|
|
12004
|
+
return classTransformer.plainToClass(ChartData, {
|
|
12005
|
+
name: item.category.name,
|
|
12006
|
+
data: item.equity.map(function (serie) {
|
|
12007
|
+
return classTransformer.plainToClass(ChartSerie, {
|
|
12008
|
+
label: serie.date,
|
|
12009
|
+
value: serie.amount
|
|
12010
|
+
});
|
|
12011
|
+
})
|
|
12012
|
+
});
|
|
12013
|
+
});
|
|
12014
|
+
}));
|
|
11861
12015
|
};
|
|
11862
|
-
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
|
|
11866
|
-
|
|
12016
|
+
return EquityPositionChartService;
|
|
12017
|
+
}());
|
|
12018
|
+
EquityPositionChartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: EquityPositionChartService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
12019
|
+
EquityPositionChartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: EquityPositionChartService, providedIn: 'root' });
|
|
12020
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: EquityPositionChartService, decorators: [{
|
|
12021
|
+
type: i0.Injectable,
|
|
12022
|
+
args: [{
|
|
12023
|
+
providedIn: 'root'
|
|
12024
|
+
}]
|
|
12025
|
+
}], ctorParameters: function () {
|
|
12026
|
+
return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
|
|
12027
|
+
type: i0.Inject,
|
|
12028
|
+
args: ['environment']
|
|
12029
|
+
}] }];
|
|
12030
|
+
} });
|
|
12031
|
+
|
|
12032
|
+
var PropertyCategoryMovementService = /** @class */ (function (_super) {
|
|
12033
|
+
__extends(PropertyCategoryMovementService, _super);
|
|
12034
|
+
function PropertyCategoryMovementService() {
|
|
12035
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
12036
|
+
_this.modelClass = PropertyCategoryMovement;
|
|
12037
|
+
_this.url = 'properties/category-movements';
|
|
12038
|
+
return _this;
|
|
12039
|
+
}
|
|
12040
|
+
PropertyCategoryMovementService.prototype.add = function (model) {
|
|
12041
|
+
var _this = this;
|
|
12042
|
+
return _super.prototype.add.call(this, model).pipe(operators.map(function (newMovement) {
|
|
12043
|
+
// @TODO Alex: we need to teach restService to dispatch events + limit list of methods (not all services have all 4 or even more considering batch requests) + collections
|
|
12044
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED, null));
|
|
12045
|
+
return newMovement;
|
|
11867
12046
|
}));
|
|
11868
12047
|
};
|
|
11869
|
-
|
|
11870
|
-
this
|
|
11871
|
-
|
|
11872
|
-
|
|
11873
|
-
|
|
12048
|
+
PropertyCategoryMovementService.prototype.update = function (model) {
|
|
12049
|
+
var _this = this;
|
|
12050
|
+
return _super.prototype.update.call(this, model).pipe(operators.map(function (updatedMovement) {
|
|
12051
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED, null));
|
|
12052
|
+
return updatedMovement;
|
|
11874
12053
|
}));
|
|
11875
12054
|
};
|
|
11876
|
-
|
|
11877
|
-
this
|
|
11878
|
-
|
|
11879
|
-
|
|
11880
|
-
message: message,
|
|
12055
|
+
PropertyCategoryMovementService.prototype.delete = function (model) {
|
|
12056
|
+
var _this = this;
|
|
12057
|
+
return _super.prototype.delete.call(this, model).pipe(operators.map(function () {
|
|
12058
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED, null));
|
|
11881
12059
|
}));
|
|
11882
12060
|
};
|
|
11883
|
-
|
|
11884
|
-
|
|
11885
|
-
|
|
11886
|
-
|
|
11887
|
-
message: message,
|
|
12061
|
+
// @TODO Alex: Move to collection
|
|
12062
|
+
PropertyCategoryMovementService.prototype.getByPropertyId = function (id) {
|
|
12063
|
+
return this.get().pipe(operators.map(function (movements) {
|
|
12064
|
+
return movements.filter(function (movement) { return movement.property.id === id; });
|
|
11888
12065
|
}));
|
|
11889
12066
|
};
|
|
11890
|
-
return
|
|
11891
|
-
}());
|
|
11892
|
-
|
|
11893
|
-
|
|
11894
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
12067
|
+
return PropertyCategoryMovementService;
|
|
12068
|
+
}(RestService));
|
|
12069
|
+
PropertyCategoryMovementService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryMovementService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
12070
|
+
PropertyCategoryMovementService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryMovementService, providedIn: 'root' });
|
|
12071
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryMovementService, decorators: [{
|
|
11895
12072
|
type: i0.Injectable,
|
|
11896
12073
|
args: [{
|
|
11897
12074
|
providedIn: 'root'
|
|
11898
12075
|
}]
|
|
11899
12076
|
}] });
|
|
11900
12077
|
|
|
11901
|
-
function
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
}
|
|
11913
|
-
|
|
11914
|
-
var MessagesEnum;
|
|
11915
|
-
(function (MessagesEnum) {
|
|
11916
|
-
MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
|
|
11917
|
-
MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
|
|
11918
|
-
MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
|
|
11919
|
-
})(MessagesEnum || (MessagesEnum = {}));
|
|
11920
|
-
|
|
11921
|
-
/**
|
|
11922
|
-
* Service for transactions business logic
|
|
11923
|
-
*/
|
|
11924
|
-
var TransactionService = /** @class */ (function (_super) {
|
|
11925
|
-
__extends(TransactionService, _super);
|
|
11926
|
-
function TransactionService(http, eventDispatcherService, environment, toastService) {
|
|
11927
|
-
var _this = _super.call(this, http, eventDispatcherService, environment) || this;
|
|
11928
|
-
_this.http = http;
|
|
11929
|
-
_this.eventDispatcherService = eventDispatcherService;
|
|
11930
|
-
_this.environment = environment;
|
|
11931
|
-
_this.toastService = toastService;
|
|
11932
|
-
// url part for Transaction API
|
|
11933
|
-
_this.url = 'transactions';
|
|
11934
|
-
_this.modelClass = Transaction;
|
|
11935
|
-
_this.transactionDeleted = new i0.EventEmitter();
|
|
11936
|
-
_this.listenEvents();
|
|
11937
|
-
return _this;
|
|
12078
|
+
var SubscriptionService = /** @class */ (function () {
|
|
12079
|
+
function SubscriptionService(http, eventDispatcherService, sseService, environment) {
|
|
12080
|
+
this.http = http;
|
|
12081
|
+
this.eventDispatcherService = eventDispatcherService;
|
|
12082
|
+
this.sseService = sseService;
|
|
12083
|
+
this.environment = environment;
|
|
12084
|
+
this.serviceSubscriptionSubject = new rxjs.ReplaySubject(1);
|
|
12085
|
+
this.serviceSubscriptionsSubject = new rxjs.ReplaySubject(1);
|
|
12086
|
+
this.servicePaymentsSubject = new rxjs.ReplaySubject(1);
|
|
12087
|
+
this.subscriptionChangeSubject = new rxjs.BehaviorSubject(null);
|
|
12088
|
+
this.listenEvents();
|
|
11938
12089
|
}
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
*/
|
|
11942
|
-
TransactionService.prototype.listenEvents = function () {
|
|
11943
|
-
this.listenDepreciationChange();
|
|
11944
|
-
this.listenPropertyShareUpdate();
|
|
12090
|
+
SubscriptionService.prototype.listenEvents = function () {
|
|
12091
|
+
this.listenSubscriptions();
|
|
11945
12092
|
};
|
|
11946
|
-
|
|
11947
|
-
* get list of all user's TaxTank transactions
|
|
11948
|
-
*/
|
|
11949
|
-
TransactionService.prototype.get = function () {
|
|
12093
|
+
SubscriptionService.prototype.getSubscription = function (force) {
|
|
11950
12094
|
var _this = this;
|
|
11951
|
-
if (
|
|
11952
|
-
|
|
11953
|
-
this.
|
|
11954
|
-
|
|
11955
|
-
.
|
|
11956
|
-
|
|
11957
|
-
|
|
12095
|
+
if (force === void 0) { force = false; }
|
|
12096
|
+
if (!this._serviceSubscription || force) {
|
|
12097
|
+
this.http.get(this.environment.apiV2 + "/subscriptions/last")
|
|
12098
|
+
.pipe(operators.map(function (response) {
|
|
12099
|
+
return classTransformer.plainToClass(ServiceSubscription, response);
|
|
12100
|
+
}))
|
|
12101
|
+
.subscribe(function (subsciption) {
|
|
12102
|
+
_this._serviceSubscription = subsciption;
|
|
12103
|
+
_this.serviceSubscriptionSubject.next(_this._serviceSubscription);
|
|
11958
12104
|
});
|
|
11959
12105
|
}
|
|
11960
|
-
return this.
|
|
11961
|
-
// assign child transactions (fees) to parent transactions
|
|
11962
|
-
operators.map(function (transactions) {
|
|
11963
|
-
transactions.forEach(function (transaction) {
|
|
11964
|
-
transaction.transactions = transactions
|
|
11965
|
-
// get list of child transactions
|
|
11966
|
-
.filter(function (t) { return t.parentTransaction && t.parentTransaction.id === transaction.id; });
|
|
11967
|
-
});
|
|
11968
|
-
sort(transactions, 'date', false);
|
|
11969
|
-
return transactions;
|
|
11970
|
-
}));
|
|
12106
|
+
return this.serviceSubscriptionSubject.asObservable();
|
|
11971
12107
|
};
|
|
11972
12108
|
/**
|
|
11973
|
-
*
|
|
11974
|
-
*
|
|
12109
|
+
* @TODO right now we have only monthly prices, the function should be refactored to support other options in future
|
|
12110
|
+
*
|
|
12111
|
+
* create available subscription plans based on existing products
|
|
11975
12112
|
*/
|
|
11976
|
-
|
|
12113
|
+
SubscriptionService.prototype.getSubscriptionPlans = function () {
|
|
11977
12114
|
var _this = this;
|
|
11978
|
-
|
|
11979
|
-
|
|
11980
|
-
|
|
11981
|
-
|
|
11982
|
-
|
|
11983
|
-
|
|
11984
|
-
|
|
12115
|
+
if (!this._serviceSubscriptions) {
|
|
12116
|
+
this.http.get(this.environment.apiV2 + "/service-prices")
|
|
12117
|
+
.pipe(operators.map(function (response) {
|
|
12118
|
+
return new ServicePriceCollection(response['hydra:member'].map(function (item) { return classTransformer.plainToClass(ServicePrice, item); }));
|
|
12119
|
+
}))
|
|
12120
|
+
.subscribe(function (prices) {
|
|
12121
|
+
_this._serviceSubscriptions = new ServiceSubscriptionCollection([
|
|
12122
|
+
classTransformer.plainToClass(ServiceSubscription, { items: [] }),
|
|
12123
|
+
classTransformer.plainToClass(ServiceSubscription, {
|
|
12124
|
+
items: [classTransformer.plainToClass(ServiceSubscriptionItem, {
|
|
12125
|
+
price: prices.property,
|
|
12126
|
+
quantity: 2
|
|
12127
|
+
})]
|
|
12128
|
+
}),
|
|
12129
|
+
classTransformer.plainToClass(ServiceSubscription, {
|
|
12130
|
+
items: [classTransformer.plainToClass(ServiceSubscriptionItem, {
|
|
12131
|
+
price: prices.property,
|
|
12132
|
+
quantity: 3
|
|
12133
|
+
})]
|
|
12134
|
+
})
|
|
12135
|
+
]);
|
|
12136
|
+
_this._serviceSubscriptions.items.forEach(function (subscription) {
|
|
12137
|
+
subscription.items.push(classTransformer.plainToClass(ServiceSubscriptionItem, { price: prices.work, quantity: 1 }));
|
|
12138
|
+
});
|
|
12139
|
+
_this.serviceSubscriptionsSubject.next(_this._serviceSubscriptions);
|
|
12140
|
+
});
|
|
12141
|
+
}
|
|
12142
|
+
return this.serviceSubscriptionsSubject.asObservable();
|
|
11985
12143
|
};
|
|
11986
12144
|
/**
|
|
11987
|
-
*
|
|
12145
|
+
* redirect to stripe payment page
|
|
11988
12146
|
*/
|
|
11989
|
-
|
|
11990
|
-
return this
|
|
11991
|
-
|
|
11992
|
-
return
|
|
11993
|
-
|
|
11994
|
-
|
|
12147
|
+
SubscriptionService.prototype.checkoutRedirect = function (subscription, successUrl, cancelUrl) {
|
|
12148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12149
|
+
var stripe, lineItems;
|
|
12150
|
+
return __generator(this, function (_a) {
|
|
12151
|
+
switch (_a.label) {
|
|
12152
|
+
case 0: return [4 /*yield*/, stripeJs.loadStripe(this.environment.stripePk)];
|
|
12153
|
+
case 1:
|
|
12154
|
+
stripe = _a.sent();
|
|
12155
|
+
lineItems = subscription.items.map(function (item) {
|
|
12156
|
+
return { servicePriceId: item.price.id, quantity: item.quantity };
|
|
12157
|
+
});
|
|
12158
|
+
this.http.post(this.environment.apiV2 + "/stripe/checkout-session", {
|
|
12159
|
+
lineItems: lineItems,
|
|
12160
|
+
successUrl: successUrl,
|
|
12161
|
+
cancelUrl: cancelUrl
|
|
12162
|
+
})
|
|
12163
|
+
.subscribe(function (session) {
|
|
12164
|
+
// @Todo remove user TRIAL status
|
|
12165
|
+
stripe.redirectToCheckout({ sessionId: session });
|
|
12166
|
+
});
|
|
12167
|
+
return [2 /*return*/];
|
|
12168
|
+
}
|
|
11995
12169
|
});
|
|
11996
|
-
})
|
|
12170
|
+
});
|
|
11997
12171
|
};
|
|
11998
12172
|
/**
|
|
11999
|
-
*
|
|
12173
|
+
* redirect to stripe billing page
|
|
12000
12174
|
*/
|
|
12001
|
-
|
|
12002
|
-
|
|
12003
|
-
|
|
12004
|
-
|
|
12005
|
-
|
|
12175
|
+
SubscriptionService.prototype.billingRedirect = function (returnUrl) {
|
|
12176
|
+
this.http.get(this.environment.apiV2 + "/stripe/billing-portal-session", {
|
|
12177
|
+
params: { returnUrl: returnUrl }
|
|
12178
|
+
}).subscribe(function (response) {
|
|
12179
|
+
window.location.replace(response.url);
|
|
12180
|
+
});
|
|
12006
12181
|
};
|
|
12007
|
-
|
|
12008
|
-
|
|
12009
|
-
|
|
12010
|
-
|
|
12011
|
-
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
}
|
|
12182
|
+
SubscriptionService.prototype.getPayments = function () {
|
|
12183
|
+
var _this = this;
|
|
12184
|
+
if (!this._servicePayments) {
|
|
12185
|
+
this.http.get(this.environment.apiV2 + "/service-payments").subscribe(function (response) {
|
|
12186
|
+
_this._servicePayments = response.map(function (item) { return classTransformer.plainToClass(ServicePayment, item); });
|
|
12187
|
+
_this.servicePaymentsSubject.next(_this._servicePayments);
|
|
12188
|
+
});
|
|
12189
|
+
}
|
|
12190
|
+
return this.servicePaymentsSubject.asObservable();
|
|
12015
12191
|
};
|
|
12016
12192
|
/**
|
|
12017
|
-
*
|
|
12018
|
-
* @param transactions List of new Transaction instances for saving
|
|
12193
|
+
* Get difference between current subscription and selected new subscription
|
|
12019
12194
|
*/
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12023
|
-
return this.http.post(this.environment.apiV2 + "/" + this.url, transactions)
|
|
12024
|
-
.pipe(operators.map(function (response) {
|
|
12025
|
-
var _c;
|
|
12026
|
-
var addedTransactions = response.map(function (item) { return classTransformer.plainToClass(Transaction, item); });
|
|
12027
|
-
transactions.forEach(function (transaction, index) {
|
|
12028
|
-
// @TODO backend: need to upload file in the same backend endpoint with transaction add/update
|
|
12029
|
-
// check if passed receipt and upload file
|
|
12030
|
-
if (transaction.file) {
|
|
12031
|
-
transaction.id = response[index].id;
|
|
12032
|
-
addedTransactions[index].file = transaction.file;
|
|
12033
|
-
_this.uploadReceipt(addedTransactions[index]);
|
|
12034
|
-
}
|
|
12035
|
-
// @TODO Viktor: implement API for saving of nested transactions
|
|
12036
|
-
// add child transactions if exist
|
|
12037
|
-
if (transaction.transactions.length) {
|
|
12038
|
-
transaction.transactions.forEach(function (childTransaction) {
|
|
12039
|
-
childTransaction.parentTransaction = classTransformer.plainToClass(Transaction, { id: addedTransactions[index].id });
|
|
12040
|
-
});
|
|
12041
|
-
_this.addBatch(transaction.transactions).subscribe();
|
|
12042
|
-
}
|
|
12043
|
-
// add transfer transaction to cache
|
|
12044
|
-
if (transaction.operation === exports.TransactionOperationEnum.TRANSFER) {
|
|
12045
|
-
addedTransactions.push(addedTransactions[0].transfer);
|
|
12046
|
-
}
|
|
12047
|
-
});
|
|
12048
|
-
if (_this.cache) {
|
|
12049
|
-
(_c = _this.cache).push.apply(_c, __spreadArray([], __read(addedTransactions)));
|
|
12050
|
-
_this.updateCache();
|
|
12051
|
-
}
|
|
12052
|
-
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
|
|
12053
|
-
_this.toastService.success(MessagesEnum.CREATED_MESSAGE);
|
|
12054
|
-
return addedTransactions;
|
|
12195
|
+
SubscriptionService.prototype.getProrationCost = function (items) {
|
|
12196
|
+
return this.http.post(this.environment.apiV2 + "/subscriptions/proration-cost", items).pipe(operators.map(function (prorationCost) {
|
|
12197
|
+
return prorationCost;
|
|
12055
12198
|
}));
|
|
12056
12199
|
};
|
|
12057
12200
|
/**
|
|
12058
|
-
*
|
|
12059
|
-
* @param transaction Transaction instance for updating
|
|
12201
|
+
* Change subscription plan
|
|
12060
12202
|
*/
|
|
12061
|
-
|
|
12203
|
+
SubscriptionService.prototype.changeSubscription = function (items) {
|
|
12204
|
+
return this.http.put(this.environment.apiV2 + "/subscriptions/items", items);
|
|
12205
|
+
};
|
|
12206
|
+
SubscriptionService.prototype.listenSubscriptions = function () {
|
|
12062
12207
|
var _this = this;
|
|
12063
|
-
|
|
12064
|
-
.pipe(operators.map(function (
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
|
|
12087
|
-
|
|
12088
|
-
|
|
12089
|
-
|
|
12090
|
-
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12208
|
+
this.sseService.on("serviceSubscriptions")
|
|
12209
|
+
.pipe(operators.map(function (event) { return classTransformer.plainToClass(ServiceSubscription, event); }))
|
|
12210
|
+
.subscribe(function (subscription) {
|
|
12211
|
+
_this.getSubscription(true).subscribe();
|
|
12212
|
+
_this.subscriptionChangeSubject.next(subscription);
|
|
12213
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED, null));
|
|
12214
|
+
});
|
|
12215
|
+
};
|
|
12216
|
+
return SubscriptionService;
|
|
12217
|
+
}());
|
|
12218
|
+
SubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
12219
|
+
SubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, providedIn: 'root' });
|
|
12220
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, decorators: [{
|
|
12221
|
+
type: i0.Injectable,
|
|
12222
|
+
args: [{
|
|
12223
|
+
providedIn: 'root'
|
|
12224
|
+
}]
|
|
12225
|
+
}], ctorParameters: function () {
|
|
12226
|
+
return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
|
|
12227
|
+
type: i0.Inject,
|
|
12228
|
+
args: ['environment']
|
|
12229
|
+
}] }];
|
|
12230
|
+
} });
|
|
12231
|
+
|
|
12232
|
+
/**
|
|
12233
|
+
* Service to work with tax review
|
|
12234
|
+
*/
|
|
12235
|
+
var TaxReviewService = /** @class */ (function (_super) {
|
|
12236
|
+
__extends(TaxReviewService, _super);
|
|
12237
|
+
function TaxReviewService(http, eventDispatcherService, environment) {
|
|
12238
|
+
var _this = _super.call(this, http, eventDispatcherService, environment) || this;
|
|
12239
|
+
_this.http = http;
|
|
12240
|
+
_this.eventDispatcherService = eventDispatcherService;
|
|
12241
|
+
_this.environment = environment;
|
|
12242
|
+
_this.url = 'tax-reviews';
|
|
12243
|
+
_this.modelClass = TaxReview;
|
|
12244
|
+
_this.listenEvents();
|
|
12245
|
+
return _this;
|
|
12246
|
+
}
|
|
12247
|
+
/**
|
|
12248
|
+
* Listen events from SSE and Event Dispatcher services
|
|
12249
|
+
*/
|
|
12250
|
+
TaxReviewService.prototype.listenEvents = function () {
|
|
12251
|
+
this.listenFirmChanges();
|
|
12252
|
+
this.listenClientTransfer();
|
|
12095
12253
|
};
|
|
12096
12254
|
/**
|
|
12097
|
-
*
|
|
12098
|
-
* @param
|
|
12255
|
+
* Add new Tax Review (request from client to firm)
|
|
12256
|
+
* @param finYear
|
|
12099
12257
|
*/
|
|
12100
|
-
|
|
12258
|
+
TaxReviewService.prototype.request = function (finYear) {
|
|
12101
12259
|
var _this = this;
|
|
12102
|
-
return this.http.
|
|
12103
|
-
.pipe(operators.map(function (
|
|
12104
|
-
var
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12260
|
+
return this.http.post(this.environment.apiV2 + "/" + this.url + "?financialYear=" + finYear, {})
|
|
12261
|
+
.pipe(operators.map(function (newTaxReview) {
|
|
12262
|
+
var taxReview = classTransformer.plainToClass(TaxReview, newTaxReview);
|
|
12263
|
+
var tempCache = ___default["default"].cloneDeep(_this.cache);
|
|
12264
|
+
tempCache.push(taxReview);
|
|
12265
|
+
_this.cache = tempCache;
|
|
12108
12266
|
_this.updateCache();
|
|
12109
|
-
return
|
|
12267
|
+
return taxReview;
|
|
12110
12268
|
}));
|
|
12111
12269
|
};
|
|
12112
12270
|
/**
|
|
12113
|
-
*
|
|
12114
|
-
* @param
|
|
12271
|
+
* Update tax review
|
|
12272
|
+
* @param taxReview to be updated
|
|
12115
12273
|
*/
|
|
12116
|
-
|
|
12274
|
+
TaxReviewService.prototype.update = function (taxReview) {
|
|
12117
12275
|
var _this = this;
|
|
12118
|
-
return this.http.
|
|
12119
|
-
.pipe(operators.map(function () {
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
// get id of related transfer transaction
|
|
12126
|
-
if (model.transfer) {
|
|
12127
|
-
// just take id if we delete source transaction
|
|
12128
|
-
ids.push(model.transfer.id);
|
|
12129
|
-
}
|
|
12130
|
-
else {
|
|
12131
|
-
// find source transaction id if we delete destination transaction
|
|
12132
|
-
ids.push(_this.cache.find(function (t) { return t.transfer.id === model.id; }).id);
|
|
12133
|
-
}
|
|
12134
|
-
return !ids.includes(transaction.id);
|
|
12135
|
-
}
|
|
12136
|
-
return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
|
|
12137
|
-
});
|
|
12138
|
-
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_DELETED, model));
|
|
12139
|
-
_this.toastService.success(MessagesEnum.DELETED_MESSAGE);
|
|
12276
|
+
return this.http.put(this.environment.apiV2 + "/" + this.url + "/" + taxReview.id, taxReview)
|
|
12277
|
+
.pipe(operators.map(function (updatedTaxReview) {
|
|
12278
|
+
var updatedInstance = classTransformer.plainToClass(TaxReview, updatedTaxReview);
|
|
12279
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TAX_REVIEW_UPDATED, updatedInstance));
|
|
12280
|
+
var tempCache = ___default["default"].cloneDeep(_this.cache);
|
|
12281
|
+
replace(tempCache, updatedInstance);
|
|
12282
|
+
_this.cache = tempCache;
|
|
12140
12283
|
_this.updateCache();
|
|
12141
|
-
|
|
12284
|
+
return updatedInstance;
|
|
12142
12285
|
}));
|
|
12143
12286
|
};
|
|
12144
12287
|
/**
|
|
12145
|
-
*
|
|
12146
|
-
* @param transaction Еhe transaction for which the receipt will be imported
|
|
12288
|
+
* Clear cache when user reject firm
|
|
12147
12289
|
*/
|
|
12148
|
-
|
|
12290
|
+
TaxReviewService.prototype.listenFirmChanges = function () {
|
|
12149
12291
|
var _this = this;
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
this.http.post(this.environment.apiV2 + "/" + this.url + "/" + transaction.id + "/receipts", formData)
|
|
12154
|
-
.subscribe(function (receiptResponse) {
|
|
12155
|
-
// we don't need to keep file after save
|
|
12156
|
-
transaction.file = null;
|
|
12157
|
-
transaction.receipt = classTransformer.plainToClass(TransactionReceipt, receiptResponse);
|
|
12158
|
-
replace(_this.cache, transaction);
|
|
12292
|
+
this.eventDispatcherService.on([exports.AppEventTypeEnum.CLIENT_MOVEMENT_CLOSED, exports.AppEventTypeEnum.CLIENT_INVITE_ACCEPTED])
|
|
12293
|
+
.subscribe(function () {
|
|
12294
|
+
_this.cache = [];
|
|
12159
12295
|
_this.updateCache();
|
|
12160
12296
|
});
|
|
12161
12297
|
};
|
|
12162
12298
|
/**
|
|
12163
|
-
*
|
|
12164
|
-
* @
|
|
12299
|
+
* Update firm for all transferred clients
|
|
12300
|
+
* @private
|
|
12165
12301
|
*/
|
|
12166
|
-
|
|
12167
|
-
var
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12302
|
+
TaxReviewService.prototype.listenClientTransfer = function () {
|
|
12303
|
+
var _this = this;
|
|
12304
|
+
this.eventDispatcherService.on(exports.AppEventTypeEnum.CLIENT_TRANSFER_TO_OTHER_EMPLOYEE)
|
|
12305
|
+
.subscribe(function (transferredClients) {
|
|
12306
|
+
var tempCache = ___default["default"].cloneDeep(_this.cache);
|
|
12307
|
+
transferredClients.forEach(function (transferredClient) {
|
|
12308
|
+
var taxReviewIndex = tempCache.findIndex(function (taxReview) { return taxReview.id === transferredClient.id; });
|
|
12309
|
+
// @TODO vik
|
|
12310
|
+
// tempCache[taxReviewIndex].employee = transferredClient.accountant;
|
|
12311
|
+
});
|
|
12312
|
+
_this.cache = tempCache;
|
|
12313
|
+
_this.updateCache();
|
|
12314
|
+
});
|
|
12177
12315
|
};
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
12200
|
-
|
|
12201
|
-
|
|
12316
|
+
return TaxReviewService;
|
|
12317
|
+
}(RestService));
|
|
12318
|
+
TaxReviewService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
12319
|
+
TaxReviewService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewService, providedIn: 'root' });
|
|
12320
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewService, decorators: [{
|
|
12321
|
+
type: i0.Injectable,
|
|
12322
|
+
args: [{
|
|
12323
|
+
providedIn: 'root'
|
|
12324
|
+
}]
|
|
12325
|
+
}], ctorParameters: function () {
|
|
12326
|
+
return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
12327
|
+
type: i0.Inject,
|
|
12328
|
+
args: ['environment']
|
|
12329
|
+
}] }];
|
|
12330
|
+
} });
|
|
12331
|
+
|
|
12332
|
+
/**
|
|
12333
|
+
* Service to work with tax review history
|
|
12334
|
+
*/
|
|
12335
|
+
var TaxReviewHistoryService = /** @class */ (function (_super) {
|
|
12336
|
+
__extends(TaxReviewHistoryService, _super);
|
|
12337
|
+
function TaxReviewHistoryService(http, eventDispatcherService, environment) {
|
|
12338
|
+
var _this = _super.call(this, http, eventDispatcherService, environment) || this;
|
|
12339
|
+
_this.http = http;
|
|
12340
|
+
_this.eventDispatcherService = eventDispatcherService;
|
|
12341
|
+
_this.environment = environment;
|
|
12342
|
+
_this.url = 'tax-reviews/history';
|
|
12343
|
+
_this.modelClass = TaxReview;
|
|
12344
|
+
// subscribe on tax review updating
|
|
12345
|
+
eventDispatcherService.on(exports.AppEventTypeEnum.TAX_REVIEW_UPDATED).subscribe(function (taxReview) {
|
|
12346
|
+
var tempCache = ___default["default"].cloneDeep(_this.cache);
|
|
12347
|
+
// insert element at the beginning of the array
|
|
12348
|
+
tempCache.unshift(taxReview);
|
|
12349
|
+
_this.cache = tempCache;
|
|
12350
|
+
_this.updateCache();
|
|
12351
|
+
});
|
|
12352
|
+
return _this;
|
|
12353
|
+
}
|
|
12354
|
+
return TaxReviewHistoryService;
|
|
12355
|
+
}(RestService));
|
|
12356
|
+
TaxReviewHistoryService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewHistoryService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
12357
|
+
TaxReviewHistoryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewHistoryService, providedIn: 'root' });
|
|
12358
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewHistoryService, decorators: [{
|
|
12359
|
+
type: i0.Injectable,
|
|
12360
|
+
args: [{
|
|
12361
|
+
providedIn: 'root'
|
|
12362
|
+
}]
|
|
12363
|
+
}], ctorParameters: function () {
|
|
12364
|
+
return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
12365
|
+
type: i0.Inject,
|
|
12366
|
+
args: ['environment']
|
|
12367
|
+
}] }];
|
|
12368
|
+
} });
|
|
12369
|
+
|
|
12370
|
+
/**
|
|
12371
|
+
* Service to work with tax summary logic
|
|
12372
|
+
*/
|
|
12373
|
+
var TaxSummaryService = /** @class */ (function () {
|
|
12374
|
+
function TaxSummaryService(http, eventDispatcherService, environment) {
|
|
12375
|
+
this.http = http;
|
|
12376
|
+
this.eventDispatcherService = eventDispatcherService;
|
|
12377
|
+
this.environment = environment;
|
|
12378
|
+
this.taxSummaryActualsSubject = new rxjs.ReplaySubject(1);
|
|
12379
|
+
this.taxSummaryForecastsSubject = new rxjs.ReplaySubject(1);
|
|
12380
|
+
this.listenEvents();
|
|
12381
|
+
}
|
|
12382
|
+
TaxSummaryService.prototype.listenEvents = function () {
|
|
12383
|
+
this.listenToIncomeSourceForecastsEvents();
|
|
12202
12384
|
};
|
|
12203
12385
|
/**
|
|
12204
|
-
* Get
|
|
12386
|
+
* Get actual tax summary items
|
|
12205
12387
|
*/
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
|
|
12388
|
+
TaxSummaryService.prototype.getActuals = function () {
|
|
12389
|
+
var _this = this;
|
|
12390
|
+
this.http.get(this.environment.apiV2 + "/tax-summary/" + exports.TaxSummaryTypeEnum.ACTUALS, {})
|
|
12391
|
+
.subscribe(function (response) {
|
|
12392
|
+
var taxSummary = classTransformer.plainToClass(TaxSummary, response);
|
|
12393
|
+
_this.taxSummaryActualsSubject.next(taxSummary);
|
|
12394
|
+
return taxSummary;
|
|
12395
|
+
});
|
|
12396
|
+
return this.taxSummaryActualsSubject.asObservable();
|
|
12210
12397
|
};
|
|
12211
12398
|
/**
|
|
12212
|
-
*
|
|
12399
|
+
* Get forecast tax summary items
|
|
12213
12400
|
*/
|
|
12214
|
-
|
|
12401
|
+
TaxSummaryService.prototype.getForecast = function () {
|
|
12215
12402
|
var _this = this;
|
|
12216
|
-
this.
|
|
12217
|
-
|
|
12218
|
-
|
|
12219
|
-
|
|
12220
|
-
|
|
12221
|
-
});
|
|
12403
|
+
this.http.get(this.environment.apiV2 + "/tax-summary/" + exports.TaxSummaryTypeEnum.FORECASTS, {})
|
|
12404
|
+
.subscribe(function (response) {
|
|
12405
|
+
var taxSummary = classTransformer.plainToClass(TaxSummary, response);
|
|
12406
|
+
_this.taxSummaryForecastsSubject.next(taxSummary);
|
|
12407
|
+
return taxSummary;
|
|
12222
12408
|
});
|
|
12409
|
+
return this.taxSummaryForecastsSubject.asObservable();
|
|
12223
12410
|
};
|
|
12224
12411
|
/**
|
|
12225
|
-
* Listen to EventDispatcherService
|
|
12412
|
+
* Listen to EventDispatcherService events related to Income source forecasts
|
|
12226
12413
|
*/
|
|
12227
|
-
|
|
12414
|
+
TaxSummaryService.prototype.listenToIncomeSourceForecastsEvents = function () {
|
|
12228
12415
|
var _this = this;
|
|
12229
|
-
this.eventDispatcherService
|
|
12416
|
+
this.eventDispatcherService
|
|
12417
|
+
.on([exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED])
|
|
12418
|
+
.subscribe(function () {
|
|
12419
|
+
_this.getForecast().subscribe();
|
|
12420
|
+
});
|
|
12230
12421
|
};
|
|
12231
|
-
return
|
|
12232
|
-
}(
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
12422
|
+
return TaxSummaryService;
|
|
12423
|
+
}());
|
|
12424
|
+
TaxSummaryService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxSummaryService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
12425
|
+
TaxSummaryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxSummaryService, providedIn: 'root' });
|
|
12426
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxSummaryService, decorators: [{
|
|
12236
12427
|
type: i0.Injectable,
|
|
12237
12428
|
args: [{
|
|
12238
12429
|
providedIn: 'root'
|
|
@@ -12241,7 +12432,7 @@
|
|
|
12241
12432
|
return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
12242
12433
|
type: i0.Inject,
|
|
12243
12434
|
args: ['environment']
|
|
12244
|
-
}] }
|
|
12435
|
+
}] }];
|
|
12245
12436
|
} });
|
|
12246
12437
|
|
|
12247
12438
|
// @TODO Don't look at the commented code. Will be refactored/removed during TT-1503
|
|
@@ -13239,6 +13430,10 @@
|
|
|
13239
13430
|
exports.PropertyEquityChartData = PropertyEquityChartData;
|
|
13240
13431
|
exports.PropertyEquityChartItem = PropertyEquityChartItem;
|
|
13241
13432
|
exports.PropertyForecast = PropertyForecast;
|
|
13433
|
+
exports.PropertyReportItem = PropertyReportItem;
|
|
13434
|
+
exports.PropertyReportItemDepreciationCollection = PropertyReportItemDepreciationCollection;
|
|
13435
|
+
exports.PropertyReportItemTransaction = PropertyReportItemTransaction;
|
|
13436
|
+
exports.PropertyReportItemTransactionCollection = PropertyReportItemTransactionCollection;
|
|
13242
13437
|
exports.PropertySale = PropertySale;
|
|
13243
13438
|
exports.PropertySaleService = PropertySaleService;
|
|
13244
13439
|
exports.PropertySaleTaxExemptionMetadata = PropertySaleTaxExemptionMetadata;
|
|
@@ -13246,6 +13441,7 @@
|
|
|
13246
13441
|
exports.PropertyShare = PropertyShare;
|
|
13247
13442
|
exports.PropertyShareService = PropertyShareService;
|
|
13248
13443
|
exports.PropertySubscription = PropertySubscription;
|
|
13444
|
+
exports.PropertyTransactionReportService = PropertyTransactionReportService;
|
|
13249
13445
|
exports.PropertyValuation = PropertyValuation;
|
|
13250
13446
|
exports.RegisterClientForm = RegisterClientForm;
|
|
13251
13447
|
exports.RegisterFirmForm = RegisterFirmForm;
|