taxtank-core 0.17.11 → 0.17.14
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 +51 -28
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/property/property.collection.js +20 -1
- package/esm2015/lib/models/chat/chat.js +4 -1
- package/esm2015/lib/models/depreciation/depreciation.js +11 -2
- package/esm2015/lib/models/property/property.js +4 -1
- package/esm2015/lib/services/http/chat/chat.service.js +16 -1
- package/esm2015/lib/services/http/depreciation/depreciation.service.js +1 -25
- package/esm2015/lib/services/http/property/property.service.js +2 -2
- package/fesm2015/taxtank-core.js +50 -26
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/property/property.collection.d.ts +10 -0
- package/lib/models/chat/chat.d.ts +1 -0
- package/lib/models/depreciation/depreciation.d.ts +4 -1
- package/lib/models/property/property.d.ts +3 -0
- package/lib/services/http/chat/chat.service.d.ts +4 -0
- package/lib/services/http/depreciation/depreciation.service.d.ts +0 -6
- package/package.json +1 -1
package/fesm2015/taxtank-core.js
CHANGED
|
@@ -1885,6 +1885,25 @@ class PropertyCollection extends Collection {
|
|
|
1885
1885
|
getCategories() {
|
|
1886
1886
|
return uniqBy(this.items.map((property) => property.category), 'id');
|
|
1887
1887
|
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Get property with the highest growth percent
|
|
1890
|
+
*/
|
|
1891
|
+
getBestPerformanceGrowthProperty() {
|
|
1892
|
+
return this.items.reduce((max, current) => {
|
|
1893
|
+
return max.growthPercent < current.growthPercent ? current : max;
|
|
1894
|
+
}, this.first);
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Get property with the lowest tax position
|
|
1898
|
+
*/
|
|
1899
|
+
getBestPerformanceTaxProperty(transactions, depreciations) {
|
|
1900
|
+
return this.items.reduce((min, current) => {
|
|
1901
|
+
return min.getTaxPosition(transactions.getBy('property.id', min.id), depreciations.getBy('property.id', min.id))
|
|
1902
|
+
> current.getTaxPosition(transactions.getBy('property.id', current.id), depreciations.getBy('property.id', current.id))
|
|
1903
|
+
? current
|
|
1904
|
+
: min;
|
|
1905
|
+
}, this.first);
|
|
1906
|
+
}
|
|
1888
1907
|
}
|
|
1889
1908
|
|
|
1890
1909
|
/**
|
|
@@ -3237,6 +3256,9 @@ class Property extends Property$1 {
|
|
|
3237
3256
|
getOwnershipDuration(sale, unitOfTime = 'days') {
|
|
3238
3257
|
return moment(sale.contractDate).diff(moment(this.contractDate), unitOfTime);
|
|
3239
3258
|
}
|
|
3259
|
+
getTaxPosition(transactions, depreciations) {
|
|
3260
|
+
return transactions.cashPosition - Math.abs(depreciations.claimAmount);
|
|
3261
|
+
}
|
|
3240
3262
|
}
|
|
3241
3263
|
__decorate([
|
|
3242
3264
|
Type(() => Date)
|
|
@@ -3890,11 +3912,17 @@ class Depreciation extends Depreciation$1 {
|
|
|
3890
3912
|
return this.date;
|
|
3891
3913
|
}
|
|
3892
3914
|
/**
|
|
3893
|
-
* @TODO
|
|
3915
|
+
* @TODO Vik: Research a problem with depreciations without current year forecast
|
|
3894
3916
|
*/
|
|
3895
3917
|
get currentYearForecast() {
|
|
3896
3918
|
return this.forecasts.find((forecast) => {
|
|
3897
3919
|
return forecast.financialYear === new FinancialYear().year;
|
|
3920
|
+
}) || plainToClass(DepreciationForecast, {
|
|
3921
|
+
financialYear: new FinancialYear().year,
|
|
3922
|
+
openBalance: 0,
|
|
3923
|
+
closeBalance: 0,
|
|
3924
|
+
amount: 0,
|
|
3925
|
+
claimPercent: 0
|
|
3898
3926
|
});
|
|
3899
3927
|
}
|
|
3900
3928
|
getForecastByYear(year) {
|
|
@@ -3919,6 +3947,9 @@ class Depreciation extends Depreciation$1 {
|
|
|
3919
3947
|
toTransaction(params = {}) {
|
|
3920
3948
|
return plainToClass(Transaction, Object.assign(params, this, { amount: this.currentYearForecast.amount }));
|
|
3921
3949
|
}
|
|
3950
|
+
/**
|
|
3951
|
+
* @TODO Michael: remove and check everywhere in reports
|
|
3952
|
+
*/
|
|
3922
3953
|
get claimAmount() {
|
|
3923
3954
|
var _a;
|
|
3924
3955
|
return ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
|
|
@@ -5490,6 +5521,9 @@ __decorate([
|
|
|
5490
5521
|
__decorate([
|
|
5491
5522
|
Type(() => User)
|
|
5492
5523
|
], Chat.prototype, "client", void 0);
|
|
5524
|
+
__decorate([
|
|
5525
|
+
Type(() => Date)
|
|
5526
|
+
], Chat.prototype, "updatedAt", void 0);
|
|
5493
5527
|
|
|
5494
5528
|
var ChatViewTypeEnum;
|
|
5495
5529
|
(function (ChatViewTypeEnum) {
|
|
@@ -7414,7 +7448,7 @@ class PropertyService extends RestService {
|
|
|
7414
7448
|
* Activate deactivated property
|
|
7415
7449
|
*/
|
|
7416
7450
|
activate(property) {
|
|
7417
|
-
return this.http.post(`${this.environment.apiV2}/property-subscriptions`, {
|
|
7451
|
+
return this.http.post(`${this.environment.apiV2}/property-subscriptions`, { property })
|
|
7418
7452
|
.pipe(map((propertySubscriptionBase) => {
|
|
7419
7453
|
const newPropertySubscription = plainToClass(PropertySubscription, propertySubscriptionBase);
|
|
7420
7454
|
const activatedProperty = plainToClass(Property, Object.assign({}, property, { subscriptions: [newPropertySubscription] }));
|
|
@@ -8825,6 +8859,7 @@ class ChatService extends RestService {
|
|
|
8825
8859
|
this.url = 'chats';
|
|
8826
8860
|
this.isHydra = true;
|
|
8827
8861
|
this.listenChats();
|
|
8862
|
+
this.listenMessages();
|
|
8828
8863
|
}
|
|
8829
8864
|
/**
|
|
8830
8865
|
* Listen chats events
|
|
@@ -8859,6 +8894,19 @@ class ChatService extends RestService {
|
|
|
8859
8894
|
this.updateCache();
|
|
8860
8895
|
});
|
|
8861
8896
|
}
|
|
8897
|
+
/**
|
|
8898
|
+
* Update chat's 'updatedAt' field with the last chat's message date for chat list sorting
|
|
8899
|
+
*/
|
|
8900
|
+
listenMessages() {
|
|
8901
|
+
this.eventDispatcherService.on(AppEventTypeEnum.MESSAGE_CREATED).subscribe((message) => {
|
|
8902
|
+
const cache = cloneDeep$1(this.cache);
|
|
8903
|
+
const updatedChat = cache.find((chat) => chat.id === message.chat.id);
|
|
8904
|
+
updatedChat.updatedAt = message.createdAt;
|
|
8905
|
+
replace(cache, updatedChat);
|
|
8906
|
+
this.cache = cache;
|
|
8907
|
+
this.updateCache();
|
|
8908
|
+
});
|
|
8909
|
+
}
|
|
8862
8910
|
}
|
|
8863
8911
|
ChatService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ChatService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }, { token: SseService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
8864
8912
|
ChatService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ChatService, providedIn: 'root' });
|
|
@@ -9324,30 +9372,6 @@ class DepreciationService extends RestService {
|
|
|
9324
9372
|
return response || 0;
|
|
9325
9373
|
}));
|
|
9326
9374
|
}
|
|
9327
|
-
/**
|
|
9328
|
-
* @TODO wrong place, move to collection model
|
|
9329
|
-
*/
|
|
9330
|
-
calculateSummaryAmount(depreciationList) {
|
|
9331
|
-
return depreciationList.reduce((sum, depreciation) => {
|
|
9332
|
-
// depreciation may not have forecast item for current financial year
|
|
9333
|
-
if (!depreciation.currentYearForecast) {
|
|
9334
|
-
return sum;
|
|
9335
|
-
}
|
|
9336
|
-
return sum + depreciation.currentYearForecast.claimAmount;
|
|
9337
|
-
}, 0);
|
|
9338
|
-
}
|
|
9339
|
-
calculateBorrowingExpenses(depreciationList) {
|
|
9340
|
-
return this.getByIds(depreciationList)
|
|
9341
|
-
.pipe(map((depreciations) => {
|
|
9342
|
-
return this.calculateSummaryAmount(depreciations.filter((depreciation) => depreciation.isBorrowingExpense()));
|
|
9343
|
-
}));
|
|
9344
|
-
}
|
|
9345
|
-
calculateDepreciations(depreciationList) {
|
|
9346
|
-
return this.getByIds(depreciationList)
|
|
9347
|
-
.pipe(map((depreciations) => {
|
|
9348
|
-
return this.calculateSummaryAmount(depreciations.filter((depreciation) => !depreciation.isBorrowingExpense()));
|
|
9349
|
-
}));
|
|
9350
|
-
}
|
|
9351
9375
|
/**
|
|
9352
9376
|
* Upload depreciation receipt
|
|
9353
9377
|
* @param depreciation for which will be uploaded receipt
|