taxtank-core 0.10.4 → 0.10.5
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 +926 -1122
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/collection-dictionary.js +6 -6
- package/esm2015/lib/models/depreciation/depreciation.js +3 -3
- package/esm2015/public-api.js +1 -6
- package/fesm2015/taxtank-core.js +675 -843
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/collection-dictionary.d.ts +1 -1
- package/lib/models/depreciation/depreciation.d.ts +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +0 -5
- package/esm2015/lib/collections/report/property/property-report-item-depreciation.collection.js +0 -19
- package/esm2015/lib/collections/report/property/property-report-item-transaction.collection.js +0 -19
- package/esm2015/lib/models/report/property/property-report-item-depreciation.js +0 -13
- package/esm2015/lib/models/report/property/property-report-item-transaction.js +0 -12
- package/esm2015/lib/models/report/property/property-report-item.js +0 -18
- package/esm2015/lib/services/report/property/property-transaction-report.service.js +0 -112
- package/lib/collections/report/property/property-report-item-depreciation.collection.d.ts +0 -12
- package/lib/collections/report/property/property-report-item-transaction.collection.d.ts +0 -12
- package/lib/models/report/property/property-report-item-depreciation.d.ts +0 -10
- package/lib/models/report/property/property-report-item-transaction.d.ts +0 -10
- package/lib/models/report/property/property-report-item.d.ts +0 -18
- package/lib/services/report/property/property-transaction-report.service.d.ts +0 -49
|
@@ -1129,8 +1129,9 @@
|
|
|
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 = '
|
|
1132
|
+
function CollectionDictionary(collection, path, prop) {
|
|
1133
|
+
if (path === void 0) { path = ''; }
|
|
1134
|
+
if (prop === void 0) { prop = 'id'; }
|
|
1134
1135
|
/**
|
|
1135
1136
|
* List of grouped collections
|
|
1136
1137
|
*/
|
|
@@ -1141,10 +1142,10 @@
|
|
|
1141
1142
|
return;
|
|
1142
1143
|
}
|
|
1143
1144
|
// Check if the first collection item has property by path
|
|
1144
|
-
if (!has__default["default"](collection.items[0], path)) {
|
|
1145
|
+
if (!has__default["default"](collection.items[0], path) && path) {
|
|
1145
1146
|
return;
|
|
1146
1147
|
}
|
|
1147
|
-
this.groupItems(collection, path);
|
|
1148
|
+
this.groupItems(collection, path, prop);
|
|
1148
1149
|
}
|
|
1149
1150
|
Object.defineProperty(CollectionDictionary.prototype, "keys", {
|
|
1150
1151
|
/**
|
|
@@ -1188,13 +1189,13 @@
|
|
|
1188
1189
|
/**
|
|
1189
1190
|
* Group collection items by passed path into items object
|
|
1190
1191
|
*/
|
|
1191
|
-
CollectionDictionary.prototype.groupItems = function (collection, path) {
|
|
1192
|
+
CollectionDictionary.prototype.groupItems = function (collection, path, prop) {
|
|
1192
1193
|
var _this = this;
|
|
1193
1194
|
// Create empty initial object for groups
|
|
1194
1195
|
var obj = {};
|
|
1195
1196
|
// Group collection items
|
|
1196
1197
|
collection.items.forEach(function (item) {
|
|
1197
|
-
var key = get__default["default"](item, path);
|
|
1198
|
+
var key = get__default["default"](item, "" + (path ? path + '.' : '') + prop);
|
|
1198
1199
|
// if object does not have property for grouping it will be grouped as 'other'
|
|
1199
1200
|
if (key === undefined) {
|
|
1200
1201
|
key = 'other';
|
|
@@ -4906,9 +4907,8 @@
|
|
|
4906
4907
|
/**
|
|
4907
4908
|
* Create a new transaction from current depreciation
|
|
4908
4909
|
*/
|
|
4909
|
-
Depreciation.prototype.toTransaction = function (
|
|
4910
|
-
|
|
4911
|
-
return classTransformer.plainToClass(Transaction, Object.assign(params, this, { amount: this.currentYearForecast.amount }));
|
|
4910
|
+
Depreciation.prototype.toTransaction = function () {
|
|
4911
|
+
return classTransformer.plainToClass(Transaction, Object.assign({}, this, { amount: this.currentYearForecast.amount }));
|
|
4912
4912
|
};
|
|
4913
4913
|
Object.defineProperty(Depreciation.prototype, "claimAmount", {
|
|
4914
4914
|
get: function () {
|
|
@@ -5059,99 +5059,6 @@
|
|
|
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
|
-
|
|
5155
5062
|
var ServicePriceCollection = /** @class */ (function (_super) {
|
|
5156
5063
|
__extends(ServicePriceCollection, _super);
|
|
5157
5064
|
function ServicePriceCollection() {
|
|
@@ -11141,72 +11048,130 @@
|
|
|
11141
11048
|
}] }];
|
|
11142
11049
|
} });
|
|
11143
11050
|
|
|
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
|
-
|
|
11164
11051
|
/**
|
|
11165
|
-
*
|
|
11052
|
+
* Service with calculations methods for properties related with other entities.
|
|
11053
|
+
* Logic here works like collections methods but for several entities
|
|
11166
11054
|
*/
|
|
11167
|
-
var
|
|
11168
|
-
function
|
|
11169
|
-
this.toast$ = new rxjs.ReplaySubject(1);
|
|
11055
|
+
var PropertyCalculationService = /** @class */ (function () {
|
|
11056
|
+
function PropertyCalculationService() {
|
|
11170
11057
|
}
|
|
11171
|
-
|
|
11172
|
-
|
|
11058
|
+
PropertyCalculationService.prototype.getTaxPosition = function (transactions, depreciations) {
|
|
11059
|
+
// @TODO hack: math abs added because we have mismatching of real values signs
|
|
11060
|
+
return transactions.cashPosition - Math.abs(depreciations.claimAmount);
|
|
11173
11061
|
};
|
|
11174
|
-
|
|
11175
|
-
this
|
|
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
|
+
}));
|
|
11176
11071
|
};
|
|
11177
|
-
|
|
11178
|
-
this.
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
|
|
11072
|
+
PropertyCalculationService.prototype.taxPositionGrowth = function (properties, transactions, depreciations) {
|
|
11073
|
+
var taxPosition = this.getTaxPosition(transactions, depreciations);
|
|
11074
|
+
// check if taxPosition = 0 to avoid division by zero
|
|
11075
|
+
if (!taxPosition) {
|
|
11076
|
+
return 0;
|
|
11077
|
+
}
|
|
11078
|
+
return (taxPosition - properties.forecastedTaxPosition) / taxPosition;
|
|
11079
|
+
};
|
|
11080
|
+
PropertyCalculationService.prototype.taxPositionGrowth$ = function (properties$, transactions$, depreciations$) {
|
|
11081
|
+
var _this = this;
|
|
11082
|
+
return rxjs.combineLatest([
|
|
11083
|
+
properties$,
|
|
11084
|
+
transactions$,
|
|
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);
|
|
11182
11089
|
}));
|
|
11183
11090
|
};
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11091
|
+
PropertyCalculationService.prototype.getRentalReturn = function (properties, transactions) {
|
|
11092
|
+
return transactions.claimIncome / properties.marketValue;
|
|
11093
|
+
};
|
|
11094
|
+
PropertyCalculationService.prototype.getLoanAmount = function (properties, bankAccounts, loans) {
|
|
11095
|
+
return properties.items.reduce(function (totalAmount, property) {
|
|
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);
|
|
11189
11126
|
}));
|
|
11190
11127
|
};
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11128
|
+
PropertyCalculationService.prototype.getLvrCommencement = function (properties, loans, bankAccounts) {
|
|
11129
|
+
// Math abs is required for correct percentage calculation
|
|
11130
|
+
return Math.abs(this.getLoanAmount(properties, bankAccounts, loans)) / properties.purchasePrice;
|
|
11131
|
+
};
|
|
11132
|
+
PropertyCalculationService.prototype.getLvrCommencement$ = function (properties$, bankAccounts$, loans$) {
|
|
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);
|
|
11196
11141
|
}));
|
|
11197
11142
|
};
|
|
11198
|
-
|
|
11199
|
-
this.
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11143
|
+
PropertyCalculationService.prototype.getLvrGrowth = function (properties, bankAccounts, loans) {
|
|
11144
|
+
var lvr = this.getLvr(properties, bankAccounts);
|
|
11145
|
+
if (!lvr) {
|
|
11146
|
+
// check if lvr = 0 to avoid division by zero
|
|
11147
|
+
return 0;
|
|
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);
|
|
11203
11160
|
}));
|
|
11204
11161
|
};
|
|
11205
|
-
|
|
11162
|
+
PropertyCalculationService.prototype.getEquityPosition = function (properties, bankAccounts) {
|
|
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;
|
|
11206
11171
|
}());
|
|
11207
|
-
|
|
11208
|
-
|
|
11209
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
11172
|
+
PropertyCalculationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCalculationService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11173
|
+
PropertyCalculationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCalculationService, providedIn: 'root' });
|
|
11174
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCalculationService, decorators: [{
|
|
11210
11175
|
type: i0.Injectable,
|
|
11211
11176
|
args: [{
|
|
11212
11177
|
providedIn: 'root'
|
|
@@ -11214,320 +11179,196 @@
|
|
|
11214
11179
|
}] });
|
|
11215
11180
|
|
|
11216
11181
|
/**
|
|
11217
|
-
* Service for
|
|
11182
|
+
* Service for work with Property Categories
|
|
11218
11183
|
*/
|
|
11219
|
-
var
|
|
11220
|
-
__extends(
|
|
11221
|
-
function
|
|
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: [{
|
|
11197
|
+
type: i0.Injectable,
|
|
11198
|
+
args: [{
|
|
11199
|
+
providedIn: 'root'
|
|
11200
|
+
}]
|
|
11201
|
+
}] });
|
|
11202
|
+
|
|
11203
|
+
/**
|
|
11204
|
+
* Class for work with Property Documents
|
|
11205
|
+
*/
|
|
11206
|
+
var PropertyDocumentService = /** @class */ (function (_super) {
|
|
11207
|
+
__extends(PropertyDocumentService, _super);
|
|
11208
|
+
function PropertyDocumentService(http, eventDispatcherService, environment) {
|
|
11222
11209
|
var _this = _super.call(this, http, eventDispatcherService, environment) || this;
|
|
11223
11210
|
_this.http = http;
|
|
11224
11211
|
_this.eventDispatcherService = eventDispatcherService;
|
|
11225
11212
|
_this.environment = environment;
|
|
11226
|
-
_this.
|
|
11227
|
-
|
|
11228
|
-
_this.url = 'transactions';
|
|
11229
|
-
_this.modelClass = Transaction;
|
|
11230
|
-
_this.transactionDeleted = new i0.EventEmitter();
|
|
11213
|
+
_this.modelClass = PropertyDocument;
|
|
11214
|
+
_this.url = 'properties/documents';
|
|
11231
11215
|
_this.listenEvents();
|
|
11232
11216
|
return _this;
|
|
11233
11217
|
}
|
|
11234
11218
|
/**
|
|
11235
|
-
*
|
|
11236
|
-
*/
|
|
11237
|
-
TransactionService.prototype.listenEvents = function () {
|
|
11238
|
-
this.listenDepreciationChange();
|
|
11239
|
-
this.listenPropertyShareUpdate();
|
|
11240
|
-
};
|
|
11241
|
-
/**
|
|
11242
|
-
* get list of all user's TaxTank transactions
|
|
11219
|
+
* Add new Property Document
|
|
11243
11220
|
*/
|
|
11244
|
-
|
|
11221
|
+
PropertyDocumentService.prototype.upload = function (file, propertyId) {
|
|
11245
11222
|
var _this = this;
|
|
11246
|
-
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11223
|
+
// create formData object with provided file
|
|
11224
|
+
var formDataDocument = new FormData();
|
|
11225
|
+
formDataDocument.append('file', file);
|
|
11226
|
+
return this.http.post(this.environment.apiV2 + "/properties/" + propertyId + "/documents", formDataDocument).pipe(operators.map(function (documentBase) {
|
|
11227
|
+
var newDocument = classTransformer.plainToClass(PropertyDocument, documentBase);
|
|
11228
|
+
if (_this.cache) {
|
|
11229
|
+
_this.cache.push(newDocument);
|
|
11252
11230
|
_this.updateCache();
|
|
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;
|
|
11265
|
-
}));
|
|
11266
|
-
};
|
|
11267
|
-
/**
|
|
11268
|
-
* Add single new transaction
|
|
11269
|
-
* @param model New Transaction instance for saving
|
|
11270
|
-
*/
|
|
11271
|
-
TransactionService.prototype.add = function (model) {
|
|
11272
|
-
var _this = this;
|
|
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];
|
|
11231
|
+
}
|
|
11232
|
+
return newDocument;
|
|
11279
11233
|
}));
|
|
11280
11234
|
};
|
|
11281
11235
|
/**
|
|
11282
|
-
*
|
|
11236
|
+
* Get documents by property id
|
|
11237
|
+
* @param propertyId to get desired documents
|
|
11283
11238
|
*/
|
|
11284
|
-
|
|
11239
|
+
PropertyDocumentService.prototype.getByPropertyId = function (propertyId) {
|
|
11285
11240
|
return this.get()
|
|
11286
|
-
.pipe(operators.map(function (
|
|
11287
|
-
return
|
|
11288
|
-
|
|
11289
|
-
return ((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id) === propertyId;
|
|
11290
|
-
});
|
|
11241
|
+
.pipe(operators.map(function (documents) {
|
|
11242
|
+
return documents
|
|
11243
|
+
.filter(function (document) { return document.property.id === propertyId; });
|
|
11291
11244
|
}));
|
|
11292
11245
|
};
|
|
11246
|
+
PropertyDocumentService.prototype.listenEvents = function () {
|
|
11247
|
+
this.listenPropertyUpdateWithDocument();
|
|
11248
|
+
};
|
|
11249
|
+
PropertyDocumentService.prototype.listenPropertyUpdateWithDocument = function () {
|
|
11250
|
+
var _this = this;
|
|
11251
|
+
this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_UPDATED_WITH_DOCUMENT).subscribe(function (property) {
|
|
11252
|
+
_this.upload(property.documentFile, property.id).subscribe();
|
|
11253
|
+
});
|
|
11254
|
+
};
|
|
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
|
+
}
|
|
11293
11285
|
/**
|
|
11294
|
-
*
|
|
11286
|
+
* Listen to Event Dispatcher events
|
|
11295
11287
|
*/
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
.pipe(operators.map(function (transactions) {
|
|
11299
|
-
return transactions.filter(function (transaction) { return transaction.isWorkTank(); });
|
|
11300
|
-
}));
|
|
11288
|
+
PropertyShareService.prototype.listenEvents = function () {
|
|
11289
|
+
this.listenUserUpdated();
|
|
11301
11290
|
};
|
|
11302
11291
|
/**
|
|
11303
|
-
*
|
|
11292
|
+
* Updated loan
|
|
11304
11293
|
*/
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11294
|
+
PropertyShareService.prototype.update = function (propertyShare) {
|
|
11295
|
+
var _this = this;
|
|
11296
|
+
return this.http.put(this.environment.apiV2 + "/" + this.url + "/" + propertyShare.id, propertyShare)
|
|
11297
|
+
.pipe(operators.map(function (updatedPropertyShareBase) {
|
|
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;
|
|
11309
11304
|
}));
|
|
11310
11305
|
};
|
|
11311
11306
|
/**
|
|
11312
|
-
*
|
|
11313
|
-
* @param
|
|
11307
|
+
* Re-invite property share
|
|
11308
|
+
* @param share user to share property
|
|
11314
11309
|
*/
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
var
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
|
|
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);
|
|
11310
|
+
PropertyShareService.prototype.reinvite = function (share) {
|
|
11311
|
+
return this.http.post(this.environment.apiV2 + "/" + this.url + "/" + share.id + "/reinvite", {});
|
|
11312
|
+
};
|
|
11313
|
+
PropertyShareService.prototype.getIncoming = function () {
|
|
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);
|
|
11341
11321
|
}
|
|
11342
11322
|
});
|
|
11343
|
-
|
|
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;
|
|
11323
|
+
return propertySharesIncoming;
|
|
11350
11324
|
}));
|
|
11351
11325
|
};
|
|
11352
11326
|
/**
|
|
11353
|
-
*
|
|
11354
|
-
* @param transaction Transaction instance for updating
|
|
11327
|
+
* Get outcoming property shares list
|
|
11355
11328
|
*/
|
|
11356
|
-
|
|
11329
|
+
PropertyShareService.prototype.getOutcoming = function () {
|
|
11357
11330
|
var _this = this;
|
|
11358
|
-
return this.
|
|
11359
|
-
.
|
|
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);
|
|
11366
|
-
}
|
|
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;
|
|
11331
|
+
return this.get().pipe(operators.map(function (propertyShares) {
|
|
11332
|
+
return _this.filterOutcoming(propertyShares);
|
|
11389
11333
|
}));
|
|
11390
11334
|
};
|
|
11391
11335
|
/**
|
|
11392
|
-
*
|
|
11393
|
-
* @param transactions list of transactions for updating
|
|
11336
|
+
* Filter outcoming property shares
|
|
11394
11337
|
*/
|
|
11395
|
-
|
|
11396
|
-
var
|
|
11397
|
-
|
|
11398
|
-
|
|
11399
|
-
|
|
11400
|
-
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
|
|
11338
|
+
PropertyShareService.prototype.filterOutcoming = function (propertyShares) {
|
|
11339
|
+
var propertySharesOutcoming = [];
|
|
11340
|
+
propertyShares.forEach(function (propertyShare) {
|
|
11341
|
+
var _a;
|
|
11342
|
+
if (!((_a = propertyShare.user) === null || _a === void 0 ? void 0 : _a.isLoggedIn())) {
|
|
11343
|
+
propertySharesOutcoming.push(propertyShare);
|
|
11344
|
+
}
|
|
11345
|
+
});
|
|
11346
|
+
return propertySharesOutcoming;
|
|
11347
|
+
};
|
|
11348
|
+
PropertyShareService.prototype.getByPropertyId = function (propertyId) {
|
|
11349
|
+
return this.get()
|
|
11350
|
+
.pipe(operators.map(function (propertyShares) {
|
|
11351
|
+
return propertyShares.filter(function (propertyShare) { return propertyShare.property.id === propertyId; });
|
|
11405
11352
|
}));
|
|
11406
11353
|
};
|
|
11407
11354
|
/**
|
|
11408
|
-
*
|
|
11409
|
-
* @param model
|
|
11355
|
+
* Listen to User updated event
|
|
11410
11356
|
*/
|
|
11411
|
-
|
|
11357
|
+
PropertyShareService.prototype.listenUserUpdated = function () {
|
|
11412
11358
|
var _this = this;
|
|
11413
|
-
|
|
11414
|
-
.
|
|
11415
|
-
_this.
|
|
11416
|
-
|
|
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;
|
|
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);
|
|
11437
|
-
}));
|
|
11438
|
-
};
|
|
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;
|
|
11359
|
+
this.eventDispatcherService.on(exports.AppEventTypeEnum.USER_UPDATED)
|
|
11360
|
+
.subscribe(function () {
|
|
11361
|
+
_this.fetch().subscribe(function (propertyShares) {
|
|
11362
|
+
_this.cache = propertyShares;
|
|
11515
11363
|
_this.updateCache();
|
|
11516
11364
|
});
|
|
11517
11365
|
});
|
|
11518
11366
|
};
|
|
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;
|
|
11367
|
+
return PropertyShareService;
|
|
11527
11368
|
}(RestService));
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
11369
|
+
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 });
|
|
11370
|
+
PropertyShareService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyShareService, providedIn: 'root' });
|
|
11371
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyShareService, decorators: [{
|
|
11531
11372
|
type: i0.Injectable,
|
|
11532
11373
|
args: [{
|
|
11533
11374
|
providedIn: 'root'
|
|
@@ -11536,316 +11377,358 @@
|
|
|
11536
11377
|
return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
11537
11378
|
type: i0.Inject,
|
|
11538
11379
|
args: ['environment']
|
|
11539
|
-
}] }
|
|
11380
|
+
}] }];
|
|
11540
11381
|
} });
|
|
11541
11382
|
|
|
11383
|
+
var PropertySaleService = /** @class */ (function (_super) {
|
|
11384
|
+
__extends(PropertySaleService, _super);
|
|
11385
|
+
function PropertySaleService() {
|
|
11386
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
11387
|
+
_this.modelClass = PropertySale;
|
|
11388
|
+
_this.url = 'properties/sales';
|
|
11389
|
+
return _this;
|
|
11390
|
+
}
|
|
11391
|
+
return PropertySaleService;
|
|
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
|
+
|
|
11542
11402
|
/**
|
|
11543
|
-
* Service
|
|
11403
|
+
* Service for get property equity position half-year history chart data
|
|
11544
11404
|
*/
|
|
11545
|
-
var
|
|
11546
|
-
function
|
|
11547
|
-
this.
|
|
11548
|
-
this.
|
|
11549
|
-
this.depreciationService = depreciationService;
|
|
11550
|
-
this.chartAccountsService = chartAccountsService;
|
|
11405
|
+
var EquityPositionChartService = /** @class */ (function () {
|
|
11406
|
+
function EquityPositionChartService(http, environment) {
|
|
11407
|
+
this.http = http;
|
|
11408
|
+
this.environment = environment;
|
|
11551
11409
|
}
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
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
|
+
});
|
|
11424
|
+
});
|
|
11564
11425
|
}));
|
|
11565
11426
|
};
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
11427
|
+
return EquityPositionChartService;
|
|
11428
|
+
}());
|
|
11429
|
+
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 });
|
|
11430
|
+
EquityPositionChartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: EquityPositionChartService, providedIn: 'root' });
|
|
11431
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: EquityPositionChartService, decorators: [{
|
|
11432
|
+
type: i0.Injectable,
|
|
11433
|
+
args: [{
|
|
11434
|
+
providedIn: 'root'
|
|
11435
|
+
}]
|
|
11436
|
+
}], ctorParameters: function () {
|
|
11437
|
+
return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
|
|
11438
|
+
type: i0.Inject,
|
|
11439
|
+
args: ['environment']
|
|
11440
|
+
}] }];
|
|
11441
|
+
} });
|
|
11442
|
+
|
|
11443
|
+
var PropertyCategoryMovementService = /** @class */ (function (_super) {
|
|
11444
|
+
__extends(PropertyCategoryMovementService, _super);
|
|
11445
|
+
function PropertyCategoryMovementService() {
|
|
11446
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
11447
|
+
_this.modelClass = PropertyCategoryMovement;
|
|
11448
|
+
_this.url = 'properties/category-movements';
|
|
11449
|
+
return _this;
|
|
11450
|
+
}
|
|
11451
|
+
PropertyCategoryMovementService.prototype.add = function (model) {
|
|
11570
11452
|
var _this = this;
|
|
11571
|
-
return
|
|
11572
|
-
|
|
11573
|
-
|
|
11574
|
-
|
|
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);
|
|
11453
|
+
return _super.prototype.add.call(this, model).pipe(operators.map(function (newMovement) {
|
|
11454
|
+
// @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
|
|
11455
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED, null));
|
|
11456
|
+
return newMovement;
|
|
11607
11457
|
}));
|
|
11608
11458
|
};
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
return new DepreciationCollection(depreciations)
|
|
11615
|
-
.getByChartAccountsCategories(CHART_ACCOUNTS_CATEGORIES.property)
|
|
11616
|
-
.getWithoutBorrowingExpenses();
|
|
11459
|
+
PropertyCategoryMovementService.prototype.update = function (model) {
|
|
11460
|
+
var _this = this;
|
|
11461
|
+
return _super.prototype.update.call(this, model).pipe(operators.map(function (updatedMovement) {
|
|
11462
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED, null));
|
|
11463
|
+
return updatedMovement;
|
|
11617
11464
|
}));
|
|
11618
11465
|
};
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11466
|
+
PropertyCategoryMovementService.prototype.delete = function (model) {
|
|
11467
|
+
var _this = this;
|
|
11468
|
+
return _super.prototype.delete.call(this, model).pipe(operators.map(function () {
|
|
11469
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED, null));
|
|
11622
11470
|
}));
|
|
11623
11471
|
};
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11472
|
+
// @TODO Alex: Move to collection
|
|
11473
|
+
PropertyCategoryMovementService.prototype.getByPropertyId = function (id) {
|
|
11474
|
+
return this.get().pipe(operators.map(function (movements) {
|
|
11475
|
+
return movements.filter(function (movement) { return movement.property.id === id; });
|
|
11627
11476
|
}));
|
|
11628
11477
|
};
|
|
11629
|
-
return
|
|
11630
|
-
}());
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
11478
|
+
return PropertyCategoryMovementService;
|
|
11479
|
+
}(RestService));
|
|
11480
|
+
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 });
|
|
11481
|
+
PropertyCategoryMovementService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryMovementService, providedIn: 'root' });
|
|
11482
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryMovementService, decorators: [{
|
|
11634
11483
|
type: i0.Injectable,
|
|
11635
11484
|
args: [{
|
|
11636
11485
|
providedIn: 'root'
|
|
11637
11486
|
}]
|
|
11638
|
-
}]
|
|
11487
|
+
}] });
|
|
11639
11488
|
|
|
11640
|
-
/**
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
11489
|
+
var SubscriptionService = /** @class */ (function () {
|
|
11490
|
+
function SubscriptionService(http, eventDispatcherService, sseService, environment) {
|
|
11491
|
+
this.http = http;
|
|
11492
|
+
this.eventDispatcherService = eventDispatcherService;
|
|
11493
|
+
this.sseService = sseService;
|
|
11494
|
+
this.environment = environment;
|
|
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();
|
|
11646
11500
|
}
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
return transactions.cashPosition - Math.abs(depreciations.claimAmount);
|
|
11501
|
+
SubscriptionService.prototype.listenEvents = function () {
|
|
11502
|
+
this.listenSubscriptions();
|
|
11650
11503
|
};
|
|
11651
|
-
|
|
11504
|
+
SubscriptionService.prototype.getSubscription = function (force) {
|
|
11652
11505
|
var _this = this;
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
|
|
11663
|
-
// check if taxPosition = 0 to avoid division by zero
|
|
11664
|
-
if (!taxPosition) {
|
|
11665
|
-
return 0;
|
|
11506
|
+
if (force === void 0) { force = false; }
|
|
11507
|
+
if (!this._serviceSubscription || force) {
|
|
11508
|
+
this.http.get(this.environment.apiV2 + "/subscriptions/last")
|
|
11509
|
+
.pipe(operators.map(function (response) {
|
|
11510
|
+
return classTransformer.plainToClass(ServiceSubscription, response);
|
|
11511
|
+
}))
|
|
11512
|
+
.subscribe(function (subsciption) {
|
|
11513
|
+
_this._serviceSubscription = subsciption;
|
|
11514
|
+
_this.serviceSubscriptionSubject.next(_this._serviceSubscription);
|
|
11515
|
+
});
|
|
11666
11516
|
}
|
|
11667
|
-
return (
|
|
11668
|
-
};
|
|
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);
|
|
11517
|
+
return this.serviceSubscriptionSubject.asObservable();
|
|
11699
11518
|
};
|
|
11700
11519
|
/**
|
|
11701
|
-
*
|
|
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
|
|
11702
11523
|
*/
|
|
11703
|
-
|
|
11704
|
-
// Math abs is required for correct percentage calculation
|
|
11705
|
-
return Math.abs(this.getLoanValue(properties, bankAccounts)) / properties.marketValue;
|
|
11706
|
-
};
|
|
11707
|
-
PropertyCalculationService.prototype.getLvr$ = function (properties$, bankAccounts$) {
|
|
11524
|
+
SubscriptionService.prototype.getSubscriptionPlans = function () {
|
|
11708
11525
|
var _this = this;
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
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
|
+
});
|
|
11552
|
+
}
|
|
11553
|
+
return this.serviceSubscriptionsSubject.asObservable();
|
|
11716
11554
|
};
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11555
|
+
/**
|
|
11556
|
+
* redirect to stripe payment page
|
|
11557
|
+
*/
|
|
11558
|
+
SubscriptionService.prototype.checkoutRedirect = function (subscription, successUrl, cancelUrl) {
|
|
11559
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11560
|
+
var stripe, lineItems;
|
|
11561
|
+
return __generator(this, function (_a) {
|
|
11562
|
+
switch (_a.label) {
|
|
11563
|
+
case 0: return [4 /*yield*/, stripeJs.loadStripe(this.environment.stripePk)];
|
|
11564
|
+
case 1:
|
|
11565
|
+
stripe = _a.sent();
|
|
11566
|
+
lineItems = subscription.items.map(function (item) {
|
|
11567
|
+
return { servicePriceId: item.price.id, quantity: item.quantity };
|
|
11568
|
+
});
|
|
11569
|
+
this.http.post(this.environment.apiV2 + "/stripe/checkout-session", {
|
|
11570
|
+
lineItems: lineItems,
|
|
11571
|
+
successUrl: successUrl,
|
|
11572
|
+
cancelUrl: cancelUrl
|
|
11573
|
+
})
|
|
11574
|
+
.subscribe(function (session) {
|
|
11575
|
+
// @Todo remove user TRIAL status
|
|
11576
|
+
stripe.redirectToCheckout({ sessionId: session });
|
|
11577
|
+
});
|
|
11578
|
+
return [2 /*return*/];
|
|
11579
|
+
}
|
|
11580
|
+
});
|
|
11581
|
+
});
|
|
11720
11582
|
};
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
}));
|
|
11583
|
+
/**
|
|
11584
|
+
* redirect to stripe billing page
|
|
11585
|
+
*/
|
|
11586
|
+
SubscriptionService.prototype.billingRedirect = function (returnUrl) {
|
|
11587
|
+
this.http.get(this.environment.apiV2 + "/stripe/billing-portal-session", {
|
|
11588
|
+
params: { returnUrl: returnUrl }
|
|
11589
|
+
}).subscribe(function (response) {
|
|
11590
|
+
window.location.replace(response.url);
|
|
11591
|
+
});
|
|
11731
11592
|
};
|
|
11732
|
-
|
|
11733
|
-
var
|
|
11734
|
-
if (!
|
|
11735
|
-
|
|
11736
|
-
|
|
11593
|
+
SubscriptionService.prototype.getPayments = function () {
|
|
11594
|
+
var _this = this;
|
|
11595
|
+
if (!this._servicePayments) {
|
|
11596
|
+
this.http.get(this.environment.apiV2 + "/service-payments").subscribe(function (response) {
|
|
11597
|
+
_this._servicePayments = response.map(function (item) { return classTransformer.plainToClass(ServicePayment, item); });
|
|
11598
|
+
_this.servicePaymentsSubject.next(_this._servicePayments);
|
|
11599
|
+
});
|
|
11737
11600
|
}
|
|
11738
|
-
return
|
|
11601
|
+
return this.servicePaymentsSubject.asObservable();
|
|
11739
11602
|
};
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
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);
|
|
11603
|
+
/**
|
|
11604
|
+
* Get difference between current subscription and selected new subscription
|
|
11605
|
+
*/
|
|
11606
|
+
SubscriptionService.prototype.getProrationCost = function (items) {
|
|
11607
|
+
return this.http.post(this.environment.apiV2 + "/subscriptions/proration-cost", items).pipe(operators.map(function (prorationCost) {
|
|
11608
|
+
return prorationCost;
|
|
11749
11609
|
}));
|
|
11750
11610
|
};
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11611
|
+
/**
|
|
11612
|
+
* Change subscription plan
|
|
11613
|
+
*/
|
|
11614
|
+
SubscriptionService.prototype.changeSubscription = function (items) {
|
|
11615
|
+
return this.http.put(this.environment.apiV2 + "/subscriptions/items", items);
|
|
11754
11616
|
};
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11617
|
+
SubscriptionService.prototype.listenSubscriptions = function () {
|
|
11618
|
+
var _this = this;
|
|
11619
|
+
this.sseService.on("serviceSubscriptions")
|
|
11620
|
+
.pipe(operators.map(function (event) { return classTransformer.plainToClass(ServiceSubscription, event); }))
|
|
11621
|
+
.subscribe(function (subscription) {
|
|
11622
|
+
_this.getSubscription(true).subscribe();
|
|
11623
|
+
_this.subscriptionChangeSubject.next(subscription);
|
|
11624
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED, null));
|
|
11625
|
+
});
|
|
11758
11626
|
};
|
|
11759
|
-
return
|
|
11627
|
+
return SubscriptionService;
|
|
11760
11628
|
}());
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
11764
|
-
type: i0.Injectable,
|
|
11765
|
-
args: [{
|
|
11766
|
-
providedIn: 'root'
|
|
11767
|
-
}]
|
|
11768
|
-
}] });
|
|
11769
|
-
|
|
11770
|
-
/**
|
|
11771
|
-
* Service for work with Property Categories
|
|
11772
|
-
*/
|
|
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: [{
|
|
11629
|
+
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 });
|
|
11630
|
+
SubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, providedIn: 'root' });
|
|
11631
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, decorators: [{
|
|
11786
11632
|
type: i0.Injectable,
|
|
11787
11633
|
args: [{
|
|
11788
11634
|
providedIn: 'root'
|
|
11789
11635
|
}]
|
|
11790
|
-
}]
|
|
11636
|
+
}], ctorParameters: function () {
|
|
11637
|
+
return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
|
|
11638
|
+
type: i0.Inject,
|
|
11639
|
+
args: ['environment']
|
|
11640
|
+
}] }];
|
|
11641
|
+
} });
|
|
11791
11642
|
|
|
11792
11643
|
/**
|
|
11793
|
-
*
|
|
11644
|
+
* Service to work with tax review
|
|
11794
11645
|
*/
|
|
11795
|
-
var
|
|
11796
|
-
__extends(
|
|
11797
|
-
function
|
|
11646
|
+
var TaxReviewService = /** @class */ (function (_super) {
|
|
11647
|
+
__extends(TaxReviewService, _super);
|
|
11648
|
+
function TaxReviewService(http, eventDispatcherService, environment) {
|
|
11798
11649
|
var _this = _super.call(this, http, eventDispatcherService, environment) || this;
|
|
11799
11650
|
_this.http = http;
|
|
11800
11651
|
_this.eventDispatcherService = eventDispatcherService;
|
|
11801
11652
|
_this.environment = environment;
|
|
11802
|
-
_this.
|
|
11803
|
-
_this.
|
|
11653
|
+
_this.url = 'tax-reviews';
|
|
11654
|
+
_this.modelClass = TaxReview;
|
|
11804
11655
|
_this.listenEvents();
|
|
11805
11656
|
return _this;
|
|
11806
11657
|
}
|
|
11807
11658
|
/**
|
|
11808
|
-
*
|
|
11659
|
+
* Listen events from SSE and Event Dispatcher services
|
|
11809
11660
|
*/
|
|
11810
|
-
|
|
11661
|
+
TaxReviewService.prototype.listenEvents = function () {
|
|
11662
|
+
this.listenFirmChanges();
|
|
11663
|
+
this.listenClientTransfer();
|
|
11664
|
+
};
|
|
11665
|
+
/**
|
|
11666
|
+
* Add new Tax Review (request from client to firm)
|
|
11667
|
+
* @param finYear
|
|
11668
|
+
*/
|
|
11669
|
+
TaxReviewService.prototype.request = function (finYear) {
|
|
11811
11670
|
var _this = this;
|
|
11812
|
-
|
|
11813
|
-
|
|
11814
|
-
|
|
11815
|
-
|
|
11816
|
-
|
|
11817
|
-
|
|
11818
|
-
|
|
11819
|
-
|
|
11820
|
-
}
|
|
11821
|
-
return newDocument;
|
|
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;
|
|
11822
11679
|
}));
|
|
11823
11680
|
};
|
|
11824
11681
|
/**
|
|
11825
|
-
*
|
|
11826
|
-
* @param
|
|
11682
|
+
* Update tax review
|
|
11683
|
+
* @param taxReview to be updated
|
|
11827
11684
|
*/
|
|
11828
|
-
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
|
|
11832
|
-
|
|
11685
|
+
TaxReviewService.prototype.update = function (taxReview) {
|
|
11686
|
+
var _this = this;
|
|
11687
|
+
return this.http.put(this.environment.apiV2 + "/" + this.url + "/" + taxReview.id, taxReview)
|
|
11688
|
+
.pipe(operators.map(function (updatedTaxReview) {
|
|
11689
|
+
var updatedInstance = classTransformer.plainToClass(TaxReview, updatedTaxReview);
|
|
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;
|
|
11833
11696
|
}));
|
|
11834
11697
|
};
|
|
11835
|
-
|
|
11836
|
-
|
|
11698
|
+
/**
|
|
11699
|
+
* Clear cache when user reject firm
|
|
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
|
+
});
|
|
11837
11708
|
};
|
|
11838
|
-
|
|
11709
|
+
/**
|
|
11710
|
+
* Update firm for all transferred clients
|
|
11711
|
+
* @private
|
|
11712
|
+
*/
|
|
11713
|
+
TaxReviewService.prototype.listenClientTransfer = function () {
|
|
11839
11714
|
var _this = this;
|
|
11840
|
-
this.eventDispatcherService.on(exports.AppEventTypeEnum.
|
|
11841
|
-
|
|
11715
|
+
this.eventDispatcherService.on(exports.AppEventTypeEnum.CLIENT_TRANSFER_TO_OTHER_EMPLOYEE)
|
|
11716
|
+
.subscribe(function (transferredClients) {
|
|
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();
|
|
11842
11725
|
});
|
|
11843
11726
|
};
|
|
11844
|
-
return
|
|
11727
|
+
return TaxReviewService;
|
|
11845
11728
|
}(RestService));
|
|
11846
|
-
|
|
11847
|
-
|
|
11848
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
11729
|
+
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 });
|
|
11730
|
+
TaxReviewService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewService, providedIn: 'root' });
|
|
11731
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewService, decorators: [{
|
|
11849
11732
|
type: i0.Injectable,
|
|
11850
11733
|
args: [{
|
|
11851
11734
|
providedIn: 'root'
|
|
@@ -11857,107 +11740,101 @@
|
|
|
11857
11740
|
}] }];
|
|
11858
11741
|
} });
|
|
11859
11742
|
|
|
11860
|
-
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11743
|
+
/**
|
|
11744
|
+
* Service to work with tax review history
|
|
11745
|
+
*/
|
|
11746
|
+
var TaxReviewHistoryService = /** @class */ (function (_super) {
|
|
11747
|
+
__extends(TaxReviewHistoryService, _super);
|
|
11748
|
+
function TaxReviewHistoryService(http, eventDispatcherService, environment) {
|
|
11864
11749
|
var _this = _super.call(this, http, eventDispatcherService, environment) || this;
|
|
11865
11750
|
_this.http = http;
|
|
11866
11751
|
_this.eventDispatcherService = eventDispatcherService;
|
|
11867
11752
|
_this.environment = environment;
|
|
11868
|
-
|
|
11869
|
-
_this.
|
|
11870
|
-
|
|
11871
|
-
|
|
11753
|
+
_this.url = 'tax-reviews/history';
|
|
11754
|
+
_this.modelClass = TaxReview;
|
|
11755
|
+
// subscribe on tax review updating
|
|
11756
|
+
eventDispatcherService.on(exports.AppEventTypeEnum.TAX_REVIEW_UPDATED).subscribe(function (taxReview) {
|
|
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
|
+
});
|
|
11872
11763
|
return _this;
|
|
11873
11764
|
}
|
|
11874
|
-
|
|
11875
|
-
|
|
11876
|
-
|
|
11877
|
-
|
|
11878
|
-
|
|
11765
|
+
return TaxReviewHistoryService;
|
|
11766
|
+
}(RestService));
|
|
11767
|
+
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 });
|
|
11768
|
+
TaxReviewHistoryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewHistoryService, providedIn: 'root' });
|
|
11769
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewHistoryService, decorators: [{
|
|
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();
|
|
11879
11795
|
};
|
|
11880
11796
|
/**
|
|
11881
|
-
*
|
|
11797
|
+
* Get actual tax summary items
|
|
11882
11798
|
*/
|
|
11883
|
-
|
|
11799
|
+
TaxSummaryService.prototype.getActuals = function () {
|
|
11884
11800
|
var _this = this;
|
|
11885
|
-
|
|
11886
|
-
.
|
|
11887
|
-
var
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
return updatedPropertyShare;
|
|
11893
|
-
}));
|
|
11894
|
-
};
|
|
11895
|
-
/**
|
|
11896
|
-
* Re-invite property share
|
|
11897
|
-
* @param share user to share property
|
|
11898
|
-
*/
|
|
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
|
-
}));
|
|
11801
|
+
this.http.get(this.environment.apiV2 + "/tax-summary/" + exports.TaxSummaryTypeEnum.ACTUALS, {})
|
|
11802
|
+
.subscribe(function (response) {
|
|
11803
|
+
var taxSummary = classTransformer.plainToClass(TaxSummary, response);
|
|
11804
|
+
_this.taxSummaryActualsSubject.next(taxSummary);
|
|
11805
|
+
return taxSummary;
|
|
11806
|
+
});
|
|
11807
|
+
return this.taxSummaryActualsSubject.asObservable();
|
|
11914
11808
|
};
|
|
11915
11809
|
/**
|
|
11916
|
-
* Get
|
|
11810
|
+
* Get forecast tax summary items
|
|
11917
11811
|
*/
|
|
11918
|
-
|
|
11812
|
+
TaxSummaryService.prototype.getForecast = function () {
|
|
11919
11813
|
var _this = this;
|
|
11920
|
-
|
|
11921
|
-
|
|
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
|
-
}
|
|
11814
|
+
this.http.get(this.environment.apiV2 + "/tax-summary/" + exports.TaxSummaryTypeEnum.FORECASTS, {})
|
|
11815
|
+
.subscribe(function (response) {
|
|
11816
|
+
var taxSummary = classTransformer.plainToClass(TaxSummary, response);
|
|
11817
|
+
_this.taxSummaryForecastsSubject.next(taxSummary);
|
|
11818
|
+
return taxSummary;
|
|
11934
11819
|
});
|
|
11935
|
-
return
|
|
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
|
-
}));
|
|
11820
|
+
return this.taxSummaryForecastsSubject.asObservable();
|
|
11942
11821
|
};
|
|
11943
11822
|
/**
|
|
11944
|
-
* Listen to
|
|
11823
|
+
* Listen to EventDispatcherService events related to Income source forecasts
|
|
11945
11824
|
*/
|
|
11946
|
-
|
|
11825
|
+
TaxSummaryService.prototype.listenToIncomeSourceForecastsEvents = function () {
|
|
11947
11826
|
var _this = this;
|
|
11948
|
-
this.eventDispatcherService
|
|
11827
|
+
this.eventDispatcherService
|
|
11828
|
+
.on([exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED])
|
|
11949
11829
|
.subscribe(function () {
|
|
11950
|
-
_this.
|
|
11951
|
-
_this.cache = propertyShares;
|
|
11952
|
-
_this.updateCache();
|
|
11953
|
-
});
|
|
11830
|
+
_this.getForecast().subscribe();
|
|
11954
11831
|
});
|
|
11955
11832
|
};
|
|
11956
|
-
return
|
|
11957
|
-
}(
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
11833
|
+
return TaxSummaryService;
|
|
11834
|
+
}());
|
|
11835
|
+
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 });
|
|
11836
|
+
TaxSummaryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxSummaryService, providedIn: 'root' });
|
|
11837
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxSummaryService, decorators: [{
|
|
11961
11838
|
type: i0.Injectable,
|
|
11962
11839
|
args: [{
|
|
11963
11840
|
providedIn: 'root'
|
|
@@ -11969,461 +11846,393 @@
|
|
|
11969
11846
|
}] }];
|
|
11970
11847
|
} });
|
|
11971
11848
|
|
|
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
|
-
|
|
11991
11849
|
/**
|
|
11992
|
-
*
|
|
11850
|
+
* popup notifications service (toast, snackbar).
|
|
11993
11851
|
*/
|
|
11994
|
-
var
|
|
11995
|
-
function
|
|
11996
|
-
this.
|
|
11997
|
-
this.environment = environment;
|
|
11852
|
+
var ToastService = /** @class */ (function () {
|
|
11853
|
+
function ToastService() {
|
|
11854
|
+
this.toast$ = new rxjs.ReplaySubject(1);
|
|
11998
11855
|
}
|
|
11999
|
-
|
|
12000
|
-
|
|
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
|
-
}));
|
|
11856
|
+
ToastService.prototype.get = function () {
|
|
11857
|
+
return this.toast$.asObservable();
|
|
12015
11858
|
};
|
|
12016
|
-
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
type:
|
|
12022
|
-
|
|
12023
|
-
|
|
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;
|
|
11859
|
+
ToastService.prototype.add = function (toast) {
|
|
11860
|
+
this.toast$.next(toast);
|
|
11861
|
+
};
|
|
11862
|
+
ToastService.prototype.success = function (message) {
|
|
11863
|
+
this.add(classTransformer.plainToClass(Toast, {
|
|
11864
|
+
type: exports.ToastTypeEnum.SUCCESS,
|
|
11865
|
+
title: 'Success!',
|
|
11866
|
+
message: message,
|
|
12046
11867
|
}));
|
|
12047
11868
|
};
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
11869
|
+
ToastService.prototype.warning = function (message) {
|
|
11870
|
+
this.add(classTransformer.plainToClass(Toast, {
|
|
11871
|
+
type: exports.ToastTypeEnum.WARNING,
|
|
11872
|
+
title: 'Warning!',
|
|
11873
|
+
message: message,
|
|
12053
11874
|
}));
|
|
12054
11875
|
};
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
11876
|
+
ToastService.prototype.error = function (message) {
|
|
11877
|
+
this.add(classTransformer.plainToClass(Toast, {
|
|
11878
|
+
type: exports.ToastTypeEnum.ERROR,
|
|
11879
|
+
title: 'Error!',
|
|
11880
|
+
message: message,
|
|
12059
11881
|
}));
|
|
12060
11882
|
};
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
11883
|
+
ToastService.prototype.info = function (message) {
|
|
11884
|
+
this.add(classTransformer.plainToClass(Toast, {
|
|
11885
|
+
type: exports.ToastTypeEnum.INFO,
|
|
11886
|
+
title: 'Information',
|
|
11887
|
+
message: message,
|
|
12065
11888
|
}));
|
|
12066
11889
|
};
|
|
12067
|
-
return
|
|
12068
|
-
}(
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
11890
|
+
return ToastService;
|
|
11891
|
+
}());
|
|
11892
|
+
ToastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
11893
|
+
ToastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, providedIn: 'root' });
|
|
11894
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, decorators: [{
|
|
12072
11895
|
type: i0.Injectable,
|
|
12073
11896
|
args: [{
|
|
12074
11897
|
providedIn: 'root'
|
|
12075
11898
|
}]
|
|
12076
11899
|
}] });
|
|
12077
11900
|
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
this.serviceSubscriptionsSubject = new rxjs.ReplaySubject(1);
|
|
12086
|
-
this.servicePaymentsSubject = new rxjs.ReplaySubject(1);
|
|
12087
|
-
this.subscriptionChangeSubject = new rxjs.BehaviorSubject(null);
|
|
12088
|
-
this.listenEvents();
|
|
12089
|
-
}
|
|
12090
|
-
SubscriptionService.prototype.listenEvents = function () {
|
|
12091
|
-
this.listenSubscriptions();
|
|
12092
|
-
};
|
|
12093
|
-
SubscriptionService.prototype.getSubscription = function (force) {
|
|
12094
|
-
var _this = this;
|
|
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);
|
|
11901
|
+
function enumToList(data) {
|
|
11902
|
+
var list = [];
|
|
11903
|
+
for (var key in data) {
|
|
11904
|
+
if (Number(key) >= 0) {
|
|
11905
|
+
list.push({
|
|
11906
|
+
label: data[key],
|
|
11907
|
+
value: Number(key)
|
|
12104
11908
|
});
|
|
12105
11909
|
}
|
|
12106
|
-
|
|
11910
|
+
}
|
|
11911
|
+
return list;
|
|
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;
|
|
11938
|
+
}
|
|
11939
|
+
/**
|
|
11940
|
+
* Listen events from Event Dispatcher services
|
|
11941
|
+
*/
|
|
11942
|
+
TransactionService.prototype.listenEvents = function () {
|
|
11943
|
+
this.listenDepreciationChange();
|
|
11944
|
+
this.listenPropertyShareUpdate();
|
|
12107
11945
|
};
|
|
12108
11946
|
/**
|
|
12109
|
-
*
|
|
12110
|
-
*
|
|
12111
|
-
* create available subscription plans based on existing products
|
|
11947
|
+
* get list of all user's TaxTank transactions
|
|
12112
11948
|
*/
|
|
12113
|
-
|
|
11949
|
+
TransactionService.prototype.get = function () {
|
|
12114
11950
|
var _this = this;
|
|
12115
|
-
if (!this.
|
|
12116
|
-
|
|
12117
|
-
|
|
12118
|
-
|
|
12119
|
-
|
|
12120
|
-
.
|
|
12121
|
-
_this.
|
|
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);
|
|
11951
|
+
if (!this.cache) {
|
|
11952
|
+
// set cache as default empty array to avoid multiple backend requests
|
|
11953
|
+
this.cache = [];
|
|
11954
|
+
this.fetch()
|
|
11955
|
+
.subscribe(function (transactions) {
|
|
11956
|
+
_this.cache = transactions;
|
|
11957
|
+
_this.updateCache();
|
|
12140
11958
|
});
|
|
12141
11959
|
}
|
|
12142
|
-
return this.
|
|
11960
|
+
return this.cacheSubject.asObservable().pipe(
|
|
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
|
+
}));
|
|
12143
11971
|
};
|
|
12144
11972
|
/**
|
|
12145
|
-
*
|
|
11973
|
+
* Add single new transaction
|
|
11974
|
+
* @param model New Transaction instance for saving
|
|
12146
11975
|
*/
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
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
|
-
}
|
|
12169
|
-
});
|
|
12170
|
-
});
|
|
11976
|
+
TransactionService.prototype.add = function (model) {
|
|
11977
|
+
var _this = this;
|
|
11978
|
+
// we don't have POST API endpoint for single transaction
|
|
11979
|
+
return this.addBatch([model])
|
|
11980
|
+
.pipe(operators.map(function (newTransactions) {
|
|
11981
|
+
// @TODO alex
|
|
11982
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_CREATED, newTransactions[0]));
|
|
11983
|
+
return newTransactions[0];
|
|
11984
|
+
}));
|
|
12171
11985
|
};
|
|
12172
11986
|
/**
|
|
12173
|
-
*
|
|
11987
|
+
* get transactions related with property
|
|
12174
11988
|
*/
|
|
12175
|
-
|
|
12176
|
-
this.
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
};
|
|
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);
|
|
11989
|
+
TransactionService.prototype.getByPropertyId = function (propertyId) {
|
|
11990
|
+
return this.get()
|
|
11991
|
+
.pipe(operators.map(function (transactions) {
|
|
11992
|
+
return transactions.filter(function (transaction) {
|
|
11993
|
+
var _a;
|
|
11994
|
+
return ((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id) === propertyId;
|
|
12188
11995
|
});
|
|
12189
|
-
}
|
|
12190
|
-
return this.servicePaymentsSubject.asObservable();
|
|
11996
|
+
}));
|
|
12191
11997
|
};
|
|
12192
11998
|
/**
|
|
12193
|
-
*
|
|
11999
|
+
* get list of transactions with tank type 'Work'
|
|
12194
12000
|
*/
|
|
12195
|
-
|
|
12196
|
-
return this.
|
|
12197
|
-
|
|
12001
|
+
TransactionService.prototype.getWorkTransactions = function () {
|
|
12002
|
+
return this.get()
|
|
12003
|
+
.pipe(operators.map(function (transactions) {
|
|
12004
|
+
return transactions.filter(function (transaction) { return transaction.isWorkTank(); });
|
|
12198
12005
|
}));
|
|
12199
12006
|
};
|
|
12200
12007
|
/**
|
|
12201
|
-
*
|
|
12008
|
+
* get list of taxable transactions with tank type 'Work'
|
|
12202
12009
|
*/
|
|
12203
|
-
|
|
12204
|
-
return this.
|
|
12010
|
+
TransactionService.prototype.getTaxableWorkTransactions = function () {
|
|
12011
|
+
return this.getWorkTransactions()
|
|
12012
|
+
.pipe(operators.map(function (transactions) {
|
|
12013
|
+
return transactions.filter(function (transaction) { return !!transaction.chartAccounts.taxReturnItem; });
|
|
12014
|
+
}));
|
|
12205
12015
|
};
|
|
12206
|
-
|
|
12016
|
+
/**
|
|
12017
|
+
* add multiple transactions
|
|
12018
|
+
* @param transactions List of new Transaction instances for saving
|
|
12019
|
+
*/
|
|
12020
|
+
TransactionService.prototype.addBatch = function (transactions) {
|
|
12207
12021
|
var _this = this;
|
|
12208
|
-
|
|
12209
|
-
|
|
12210
|
-
.
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12022
|
+
transactions = ___default["default"].cloneDeep(transactions);
|
|
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;
|
|
12055
|
+
}));
|
|
12215
12056
|
};
|
|
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
12057
|
/**
|
|
12248
|
-
*
|
|
12058
|
+
* update existing transaction
|
|
12059
|
+
* @param transaction Transaction instance for updating
|
|
12249
12060
|
*/
|
|
12250
|
-
|
|
12251
|
-
this
|
|
12252
|
-
this.
|
|
12061
|
+
TransactionService.prototype.update = function (transaction) {
|
|
12062
|
+
var _this = this;
|
|
12063
|
+
return this.http.put(this.environment.apiV2 + "/" + this.url + "/" + transaction.id, transaction)
|
|
12064
|
+
.pipe(operators.map(function (response) {
|
|
12065
|
+
var updatedTransaction = classTransformer.plainToClass(Transaction, response);
|
|
12066
|
+
// @TODO need to upload file in the same backend endpoint with transaction add/update
|
|
12067
|
+
// check if passed new receipt and upload file
|
|
12068
|
+
if (transaction.file) {
|
|
12069
|
+
updatedTransaction.file = transaction.file;
|
|
12070
|
+
_this.uploadReceipt(updatedTransaction);
|
|
12071
|
+
}
|
|
12072
|
+
// @TODO Viktor: implement API for saving of nested transactions
|
|
12073
|
+
if (transaction.transactions.length) {
|
|
12074
|
+
// add parent transaction to child transactions
|
|
12075
|
+
transaction.transactions.forEach(function (childTransaction) {
|
|
12076
|
+
childTransaction.parentTransaction = classTransformer.plainToClass(Transaction, { id: updatedTransaction.id });
|
|
12077
|
+
});
|
|
12078
|
+
// separate child transactions by id existing to define add or update action.
|
|
12079
|
+
var childTransactionsToUpdate = transaction.transactions.filter(function (t) { return t.id; });
|
|
12080
|
+
var childTransactionsToAdd = transaction.transactions.filter(function (t) { return !t.id; });
|
|
12081
|
+
// update child transactions
|
|
12082
|
+
if (childTransactionsToUpdate.length) {
|
|
12083
|
+
_this.updateBatch(childTransactionsToUpdate).subscribe();
|
|
12084
|
+
}
|
|
12085
|
+
// add child transactions
|
|
12086
|
+
if (childTransactionsToAdd.length) {
|
|
12087
|
+
_this.addBatch(childTransactionsToAdd).subscribe();
|
|
12088
|
+
}
|
|
12089
|
+
}
|
|
12090
|
+
_this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
|
|
12091
|
+
replace(_this.cache, updatedTransaction);
|
|
12092
|
+
_this.updateCache();
|
|
12093
|
+
return updatedTransaction;
|
|
12094
|
+
}));
|
|
12253
12095
|
};
|
|
12254
12096
|
/**
|
|
12255
|
-
*
|
|
12256
|
-
* @param
|
|
12097
|
+
* update multiple transactions
|
|
12098
|
+
* @param transactions list of transactions for updating
|
|
12257
12099
|
*/
|
|
12258
|
-
|
|
12100
|
+
TransactionService.prototype.updateBatch = function (transactions) {
|
|
12259
12101
|
var _this = this;
|
|
12260
|
-
return this.http.
|
|
12261
|
-
.pipe(operators.map(function (
|
|
12262
|
-
var
|
|
12263
|
-
|
|
12264
|
-
|
|
12265
|
-
|
|
12102
|
+
return this.http.put(this.environment.apiV2 + "/" + this.url, transactions)
|
|
12103
|
+
.pipe(operators.map(function (response) {
|
|
12104
|
+
var updatedTransactions = response.map(function (item) { return classTransformer.plainToClass(Transaction, item); });
|
|
12105
|
+
updatedTransactions.forEach(function (updatedTransaction) {
|
|
12106
|
+
replace(_this.cache, updatedTransaction);
|
|
12107
|
+
});
|
|
12266
12108
|
_this.updateCache();
|
|
12267
|
-
return
|
|
12109
|
+
return updatedTransactions;
|
|
12268
12110
|
}));
|
|
12269
12111
|
};
|
|
12270
12112
|
/**
|
|
12271
|
-
*
|
|
12272
|
-
* @param
|
|
12113
|
+
* delete transaction and related transactions
|
|
12114
|
+
* @param model
|
|
12273
12115
|
*/
|
|
12274
|
-
|
|
12116
|
+
TransactionService.prototype.delete = function (model) {
|
|
12275
12117
|
var _this = this;
|
|
12276
|
-
return this.http.
|
|
12277
|
-
.pipe(operators.map(function (
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12118
|
+
return this.http.delete(this.environment.apiV2 + "/" + this.url + "/" + model.id)
|
|
12119
|
+
.pipe(operators.map(function () {
|
|
12120
|
+
_this.cache = _this.cache.filter(function (transaction) {
|
|
12121
|
+
var _a;
|
|
12122
|
+
// when delete transfer we delete actually 2 transactions
|
|
12123
|
+
if (model.isTransfer) {
|
|
12124
|
+
var ids = [model.id];
|
|
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);
|
|
12283
12140
|
_this.updateCache();
|
|
12284
|
-
|
|
12141
|
+
_this.transactionDeleted.emit(model);
|
|
12285
12142
|
}));
|
|
12286
12143
|
};
|
|
12287
12144
|
/**
|
|
12288
|
-
*
|
|
12145
|
+
* upload transaction receipt image
|
|
12146
|
+
* @param transaction Еhe transaction for which the receipt will be imported
|
|
12289
12147
|
*/
|
|
12290
|
-
|
|
12148
|
+
TransactionService.prototype.uploadReceipt = function (transaction) {
|
|
12291
12149
|
var _this = this;
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12150
|
+
var formData = new FormData();
|
|
12151
|
+
formData.append('file', transaction.file);
|
|
12152
|
+
transaction.receipt = null;
|
|
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);
|
|
12295
12159
|
_this.updateCache();
|
|
12296
12160
|
});
|
|
12297
12161
|
};
|
|
12298
12162
|
/**
|
|
12299
|
-
*
|
|
12300
|
-
* @
|
|
12163
|
+
* calculate gross income amount based on transaction amount and taxes (fees)
|
|
12164
|
+
* @param transaction Transaction instance for calculation
|
|
12301
12165
|
*/
|
|
12302
|
-
|
|
12303
|
-
var
|
|
12304
|
-
|
|
12305
|
-
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
|
|
12313
|
-
_this.updateCache();
|
|
12314
|
-
});
|
|
12166
|
+
TransactionService.prototype.calculateGrossAmount = function (transaction) {
|
|
12167
|
+
var amount = transaction.amount || 0;
|
|
12168
|
+
// gross income amount includes amount of fees for property tank and tax for work tank
|
|
12169
|
+
if (transaction.isPropertyTank()) {
|
|
12170
|
+
amount += transaction.transactions.reduce(function (sum, item) { return sum + item.amount; }, 0);
|
|
12171
|
+
}
|
|
12172
|
+
else {
|
|
12173
|
+
// @TODO Alex: fix logic after TT-641 ready
|
|
12174
|
+
amount += (transaction.tax || 0);
|
|
12175
|
+
}
|
|
12176
|
+
return amount;
|
|
12315
12177
|
};
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12335
|
-
|
|
12336
|
-
|
|
12337
|
-
|
|
12338
|
-
|
|
12339
|
-
|
|
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();
|
|
12178
|
+
/**
|
|
12179
|
+
* get label for transaction tax field depended of selected chart account.
|
|
12180
|
+
* tax type depends of chart account heading or category.
|
|
12181
|
+
*/
|
|
12182
|
+
TransactionService.prototype.getTaxLabel = function (chartAccounts) {
|
|
12183
|
+
var _a, _b;
|
|
12184
|
+
// get simple array of ids from enum with taxable chart accounts headings
|
|
12185
|
+
var taxableCAHeadingsIds = enumToList(exports.ChartAccountsHeadingTaxableEnum)
|
|
12186
|
+
.map(function (item) { return item.value; });
|
|
12187
|
+
// get simple array of ids from enum with tax deductible chart accounts headings
|
|
12188
|
+
var deductibleCAHeadingsIds = enumToList(exports.ChartAccountsHeadingTaxDeductibleEnum)
|
|
12189
|
+
.map(function (item) { return item.value; });
|
|
12190
|
+
// check if one of ids arrays includes current chart accounts heading id and set tax label
|
|
12191
|
+
// otherwise label is empty for this class
|
|
12192
|
+
switch (true) {
|
|
12193
|
+
case taxableCAHeadingsIds.includes((_a = chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id):
|
|
12194
|
+
return exports.ChartAccountsTaxLabelsEnum.TAX_PAID;
|
|
12195
|
+
case deductibleCAHeadingsIds.includes((_b = chartAccounts.heading) === null || _b === void 0 ? void 0 : _b.id):
|
|
12196
|
+
return exports.ChartAccountsTaxLabelsEnum.TAX_DEDUCTED;
|
|
12197
|
+
case CHART_ACCOUNTS_CATEGORIES.workIncome.includes(chartAccounts.category):
|
|
12198
|
+
return exports.ChartAccountsTaxLabelsEnum.TAX_WITHHELD;
|
|
12199
|
+
default:
|
|
12200
|
+
return null;
|
|
12201
|
+
}
|
|
12384
12202
|
};
|
|
12385
12203
|
/**
|
|
12386
|
-
* Get
|
|
12204
|
+
* Get transactions related to Vehicle category
|
|
12387
12205
|
*/
|
|
12388
|
-
|
|
12389
|
-
|
|
12390
|
-
|
|
12391
|
-
|
|
12392
|
-
var taxSummary = classTransformer.plainToClass(TaxSummary, response);
|
|
12393
|
-
_this.taxSummaryActualsSubject.next(taxSummary);
|
|
12394
|
-
return taxSummary;
|
|
12395
|
-
});
|
|
12396
|
-
return this.taxSummaryActualsSubject.asObservable();
|
|
12206
|
+
TransactionService.prototype.getVehicleTransactions = function () {
|
|
12207
|
+
return this.get().pipe(operators.map(function (transactions) {
|
|
12208
|
+
return transactions.filter(function (transaction) { return transaction.isVehicleTransaction(); });
|
|
12209
|
+
}));
|
|
12397
12210
|
};
|
|
12398
12211
|
/**
|
|
12399
|
-
*
|
|
12212
|
+
* Listen to EventDispatcherService event related to Depreciation changing
|
|
12400
12213
|
*/
|
|
12401
|
-
|
|
12214
|
+
TransactionService.prototype.listenDepreciationChange = function () {
|
|
12402
12215
|
var _this = this;
|
|
12403
|
-
this.
|
|
12404
|
-
.
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12216
|
+
this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATION_DELETED).subscribe(function () {
|
|
12217
|
+
_this.fetch()
|
|
12218
|
+
.subscribe(function (transactions) {
|
|
12219
|
+
_this.cache = transactions;
|
|
12220
|
+
_this.updateCache();
|
|
12221
|
+
});
|
|
12408
12222
|
});
|
|
12409
|
-
return this.taxSummaryForecastsSubject.asObservable();
|
|
12410
12223
|
};
|
|
12411
12224
|
/**
|
|
12412
|
-
* Listen to EventDispatcherService
|
|
12225
|
+
* Listen to EventDispatcherService event related to Property Share changing
|
|
12413
12226
|
*/
|
|
12414
|
-
|
|
12227
|
+
TransactionService.prototype.listenPropertyShareUpdate = function () {
|
|
12415
12228
|
var _this = this;
|
|
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
|
-
});
|
|
12229
|
+
this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(function () { return _this.resetCache(); });
|
|
12421
12230
|
};
|
|
12422
|
-
return
|
|
12423
|
-
}());
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
12231
|
+
return TransactionService;
|
|
12232
|
+
}(RestService));
|
|
12233
|
+
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 });
|
|
12234
|
+
TransactionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, providedIn: 'root' });
|
|
12235
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, decorators: [{
|
|
12427
12236
|
type: i0.Injectable,
|
|
12428
12237
|
args: [{
|
|
12429
12238
|
providedIn: 'root'
|
|
@@ -12432,7 +12241,7 @@
|
|
|
12432
12241
|
return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
|
|
12433
12242
|
type: i0.Inject,
|
|
12434
12243
|
args: ['environment']
|
|
12435
|
-
}] }];
|
|
12244
|
+
}] }, { type: ToastService }];
|
|
12436
12245
|
} });
|
|
12437
12246
|
|
|
12438
12247
|
// @TODO Don't look at the commented code. Will be refactored/removed during TT-1503
|
|
@@ -13430,10 +13239,6 @@
|
|
|
13430
13239
|
exports.PropertyEquityChartData = PropertyEquityChartData;
|
|
13431
13240
|
exports.PropertyEquityChartItem = PropertyEquityChartItem;
|
|
13432
13241
|
exports.PropertyForecast = PropertyForecast;
|
|
13433
|
-
exports.PropertyReportItem = PropertyReportItem;
|
|
13434
|
-
exports.PropertyReportItemDepreciationCollection = PropertyReportItemDepreciationCollection;
|
|
13435
|
-
exports.PropertyReportItemTransaction = PropertyReportItemTransaction;
|
|
13436
|
-
exports.PropertyReportItemTransactionCollection = PropertyReportItemTransactionCollection;
|
|
13437
13242
|
exports.PropertySale = PropertySale;
|
|
13438
13243
|
exports.PropertySaleService = PropertySaleService;
|
|
13439
13244
|
exports.PropertySaleTaxExemptionMetadata = PropertySaleTaxExemptionMetadata;
|
|
@@ -13441,7 +13246,6 @@
|
|
|
13441
13246
|
exports.PropertyShare = PropertyShare;
|
|
13442
13247
|
exports.PropertyShareService = PropertyShareService;
|
|
13443
13248
|
exports.PropertySubscription = PropertySubscription;
|
|
13444
|
-
exports.PropertyTransactionReportService = PropertyTransactionReportService;
|
|
13445
13249
|
exports.PropertyValuation = PropertyValuation;
|
|
13446
13250
|
exports.RegisterClientForm = RegisterClientForm;
|
|
13447
13251
|
exports.RegisterFirmForm = RegisterFirmForm;
|