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