taxtank-core 0.29.19 → 0.29.20
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 +1007 -938
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/subscription/service-price.collection.js +38 -1
- package/esm2015/lib/db/Enums/subscription/service-price-type.enum.js +6 -3
- package/esm2015/lib/db/Models/subscription/service-price.js +1 -1
- package/esm2015/lib/models/service-subscription/service-product.js +2 -1
- package/esm2015/lib/models/service-subscription/service-subscription.js +9 -1
- package/fesm2015/taxtank-core.js +795 -750
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/subscription/service-price.collection.d.ts +10 -0
- package/lib/db/Enums/subscription/service-price-type.enum.d.ts +5 -2
- package/lib/db/Models/subscription/service-price.d.ts +1 -0
- package/lib/models/service-subscription/service-product.d.ts +1 -0
- package/lib/models/service-subscription/service-subscription.d.ts +3 -0
- package/package.json +1 -1
- package/lib/forms/bank/bank-login.form.d.ts.map +0 -1
- package/lib/forms/client/client-income-types.form.d.ts.map +0 -1
- package/lib/forms/depreciation/depreciation.form.d.ts.map +0 -1
- package/lib/forms/depreciation/index.d.ts.map +0 -1
- package/lib/forms/form-validations.enum.d.ts.map +0 -1
- package/lib/forms/index.d.ts.map +0 -1
- package/lib/forms/login/login.form.d.ts.map +0 -1
- package/lib/forms/phone/index.d.ts.map +0 -1
- package/lib/forms/phone/phone.form.d.ts.map +0 -1
- package/lib/forms/property/index.d.ts.map +0 -1
- package/lib/forms/register/register-client.form.d.ts.map +0 -1
- package/lib/forms/register/register-firm.form.d.ts.map +0 -1
- package/lib/forms/sole/bas-report.form.d.ts.map +0 -1
- package/lib/forms/sole/index.d.ts.map +0 -1
- package/lib/forms/transaction/index.d.ts.map +0 -1
- package/lib/forms/transaction/messages.enum.d.ts.map +0 -1
- package/lib/forms/transaction/transaction-base.form.d.ts.map +0 -1
- package/lib/forms/transaction/transaction.form.d.ts.map +0 -1
- package/lib/forms/transaction/work-income.form.d.ts.map +0 -1
- package/lib/forms/user/index.d.ts.map +0 -1
- package/lib/forms/user/password.form.d.ts.map +0 -1
- package/lib/forms/user/reset-password.form.d.ts.map +0 -1
- package/lib/forms/user/user-invite.form.d.ts.map +0 -1
- package/lib/forms/vehicle/index.d.ts.map +0 -1
- package/lib/forms/vehicle/vehicle-claim-details.form.d.ts.map +0 -1
- package/lib/forms/vehicle/vehicle-claim.form.d.ts.map +0 -1
- package/lib/forms/vehicle/vehicle-logbook.form.d.ts.map +0 -1
- package/lib/forms/vehicle/vehicle.form.d.ts.map +0 -1
- package/lib/validators/at-least-one-enabled.validator.d.ts.map +0 -1
- package/lib/validators/date-range.validator.d.ts.map +0 -1
- package/lib/validators/phone-number.validator.d.ts.map +0 -1
- package/lib/validators/required-length.validator.d.ts.map +0 -1
- package/public-api.d.ts.map +0 -1
- package/taxtank-core.d.ts.map +0 -1
|
@@ -2418,6 +2418,7 @@
|
|
|
2418
2418
|
};
|
|
2419
2419
|
return ServiceProduct;
|
|
2420
2420
|
}(ServiceProduct$1));
|
|
2421
|
+
ServiceProduct.quantity = 3;
|
|
2421
2422
|
// const TestEnum = {
|
|
2422
2423
|
// 4: 4,
|
|
2423
2424
|
// 5: 7,
|
|
@@ -2466,279 +2467,399 @@
|
|
|
2466
2467
|
ServiceSubscriptionStatusEnum[ServiceSubscriptionStatusEnum["UNPAID"] = 6] = "UNPAID";
|
|
2467
2468
|
})(exports.ServiceSubscriptionStatusEnum || (exports.ServiceSubscriptionStatusEnum = {}));
|
|
2468
2469
|
|
|
2469
|
-
var
|
|
2470
|
-
__extends(
|
|
2471
|
-
function
|
|
2472
|
-
|
|
2473
|
-
// Number of days after which the trial time will be expired
|
|
2474
|
-
_this.lastTrialDays = 4;
|
|
2475
|
-
return _this;
|
|
2470
|
+
var MessageCollection = /** @class */ (function (_super) {
|
|
2471
|
+
__extends(MessageCollection, _super);
|
|
2472
|
+
function MessageCollection() {
|
|
2473
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2476
2474
|
}
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
return !
|
|
2480
|
-
}
|
|
2481
|
-
|
|
2482
|
-
configurable: true
|
|
2483
|
-
});
|
|
2484
|
-
Object.defineProperty(ServiceSubscription.prototype, "isPaid", {
|
|
2485
|
-
get: function () {
|
|
2486
|
-
return !!this.stripeId;
|
|
2487
|
-
},
|
|
2488
|
-
enumerable: false,
|
|
2489
|
-
configurable: true
|
|
2490
|
-
});
|
|
2491
|
-
Object.defineProperty(ServiceSubscription.prototype, "price", {
|
|
2492
|
-
get: function () {
|
|
2493
|
-
return this.items.reduce(function (sum, item) { return sum + item.total; }, 0);
|
|
2494
|
-
},
|
|
2495
|
-
enumerable: false,
|
|
2496
|
-
configurable: true
|
|
2497
|
-
});
|
|
2498
|
-
Object.defineProperty(ServiceSubscription.prototype, "title", {
|
|
2499
|
-
/**
|
|
2500
|
-
* get title of subscription
|
|
2501
|
-
*/
|
|
2502
|
-
get: function () {
|
|
2503
|
-
return this.items.map(function (item) { return item.price.product.title; }).join(' + ');
|
|
2504
|
-
// return this.isTrial ? 'Trial period' : this.items.map((item) => item.price.product.title).join(' + ');
|
|
2505
|
-
},
|
|
2506
|
-
enumerable: false,
|
|
2507
|
-
configurable: true
|
|
2508
|
-
});
|
|
2509
|
-
Object.defineProperty(ServiceSubscription.prototype, "isActive", {
|
|
2510
|
-
/**
|
|
2511
|
-
* A subscription is considered active if the end date has not yet arrived and its status is "Active" or "Past due"
|
|
2512
|
-
*/
|
|
2513
|
-
get: function () {
|
|
2514
|
-
var isExpired = new Date(this.endDate).getTime() < new Date().getTime();
|
|
2515
|
-
return !isExpired && ([exports.ServiceSubscriptionStatusEnum.ACTIVE, exports.ServiceSubscriptionStatusEnum.PAST_DUE].includes(this.status));
|
|
2516
|
-
},
|
|
2517
|
-
enumerable: false,
|
|
2518
|
-
configurable: true
|
|
2519
|
-
});
|
|
2520
|
-
Object.defineProperty(ServiceSubscription.prototype, "daysRemain", {
|
|
2521
|
-
get: function () {
|
|
2522
|
-
var daysRemains = Math.round((new Date(this.endDate).getTime() - new Date().getTime()) / (1000 * 3600 * 24));
|
|
2523
|
-
return daysRemains > 0 ? daysRemains : 0;
|
|
2524
|
-
},
|
|
2525
|
-
enumerable: false,
|
|
2526
|
-
configurable: true
|
|
2527
|
-
});
|
|
2475
|
+
MessageCollection.prototype.getFirstUnreadMessage = function (user) {
|
|
2476
|
+
return this.items.find(function (message) {
|
|
2477
|
+
return !message.isRead() && message.isFromEmployee() !== user.isEmployee();
|
|
2478
|
+
});
|
|
2479
|
+
};
|
|
2528
2480
|
/**
|
|
2529
|
-
*
|
|
2481
|
+
* Get List of unread chats
|
|
2530
2482
|
*/
|
|
2531
|
-
|
|
2532
|
-
return this.
|
|
2483
|
+
MessageCollection.prototype.getUnread = function () {
|
|
2484
|
+
return this.items.filter(function (message) { return !message.readAt; });
|
|
2533
2485
|
};
|
|
2534
|
-
|
|
2535
|
-
return this.
|
|
2486
|
+
MessageCollection.prototype.getFromActiveChats = function () {
|
|
2487
|
+
return this.filter(function (message) { return message.chat.isActive(); });
|
|
2536
2488
|
};
|
|
2537
|
-
|
|
2538
|
-
|
|
2489
|
+
/**
|
|
2490
|
+
* Get amount of chats that contains unread messages
|
|
2491
|
+
*/
|
|
2492
|
+
MessageCollection.prototype.getUnreadChatsAmount = function (isFromEmployee) {
|
|
2493
|
+
if (isFromEmployee === void 0) { isFromEmployee = false; }
|
|
2494
|
+
// filtered messages for client/employee
|
|
2495
|
+
var filteredMessages = this.filter(function (message) { return isFromEmployee ? message.isFromEmployee() : !message.isFromEmployee(); });
|
|
2496
|
+
return uniqBy__default["default"](filteredMessages.getFromActiveChats().getUnread(), 'chat.id').length;
|
|
2539
2497
|
};
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
return this.items.find(function (item) { return item.price.product.isWorkTank(); });
|
|
2546
|
-
},
|
|
2547
|
-
enumerable: false,
|
|
2548
|
-
configurable: true
|
|
2549
|
-
});
|
|
2550
|
-
Object.defineProperty(ServiceSubscription.prototype, "soleTankItem", {
|
|
2551
|
-
get: function () {
|
|
2552
|
-
return this.items.find(function (item) { return item.price.product.isSoleTank(); });
|
|
2553
|
-
},
|
|
2554
|
-
enumerable: false,
|
|
2555
|
-
configurable: true
|
|
2556
|
-
});
|
|
2557
|
-
Object.defineProperty(ServiceSubscription.prototype, "propertyTankItem", {
|
|
2558
|
-
get: function () {
|
|
2559
|
-
return this.items.find(function (item) { return item.price.product.isProperties(); });
|
|
2560
|
-
},
|
|
2561
|
-
enumerable: false,
|
|
2562
|
-
configurable: true
|
|
2563
|
-
});
|
|
2564
|
-
ServiceSubscription.prototype.hasPropertyTank = function () {
|
|
2565
|
-
return !!this.items.find(function (subscriptionItem) {
|
|
2566
|
-
return subscriptionItem.price.product.role.includes(exports.UserRolesEnum.PROPERTY_TANK);
|
|
2567
|
-
});
|
|
2498
|
+
/**
|
|
2499
|
+
* Check if chat has unread chats
|
|
2500
|
+
*/
|
|
2501
|
+
MessageCollection.prototype.hasUnread = function () {
|
|
2502
|
+
return !!this.getUnread().length;
|
|
2568
2503
|
};
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2504
|
+
return MessageCollection;
|
|
2505
|
+
}(Collection));
|
|
2506
|
+
|
|
2507
|
+
exports.ChatStatusEnum = void 0;
|
|
2508
|
+
(function (ChatStatusEnum) {
|
|
2509
|
+
ChatStatusEnum[ChatStatusEnum["ACTIVE"] = 1] = "ACTIVE";
|
|
2510
|
+
ChatStatusEnum[ChatStatusEnum["INACTIVE"] = 2] = "INACTIVE";
|
|
2511
|
+
})(exports.ChatStatusEnum || (exports.ChatStatusEnum = {}));
|
|
2512
|
+
|
|
2513
|
+
var ChatCollection = /** @class */ (function (_super) {
|
|
2514
|
+
__extends(ChatCollection, _super);
|
|
2515
|
+
function ChatCollection() {
|
|
2516
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2517
|
+
}
|
|
2518
|
+
/**
|
|
2519
|
+
* Sort chats by last messages (newest first) + empty chats in the end
|
|
2520
|
+
*/
|
|
2521
|
+
ChatCollection.prototype.getSortedByNewest = function (messages) {
|
|
2522
|
+
var chatsById = new Dictionary(this.toArray());
|
|
2523
|
+
// get chats array sorted from newest to oldest
|
|
2524
|
+
var chats = uniqBy__default["default"](new MessageCollection(messages)
|
|
2525
|
+
.filterBy('chat.id', this.getIds())
|
|
2526
|
+
.sortBy('createdAt', true)
|
|
2527
|
+
.toArray()
|
|
2528
|
+
.map(function (message) { return chatsById.get(message.chat.id); }), 'id');
|
|
2529
|
+
var emptyChats = differenceBy__default["default"](this.toArray(), chats, 'id');
|
|
2530
|
+
return this.create(__spreadArray(__spreadArray([], __read(chats)), __read(emptyChats)));
|
|
2573
2531
|
};
|
|
2532
|
+
ChatCollection.prototype.getActive = function () {
|
|
2533
|
+
return this.filterBy('status', exports.ChatStatusEnum.ACTIVE);
|
|
2534
|
+
};
|
|
2535
|
+
return ChatCollection;
|
|
2536
|
+
}(Collection));
|
|
2537
|
+
|
|
2538
|
+
/**
|
|
2539
|
+
* Collection of MessageDocument instances
|
|
2540
|
+
*/
|
|
2541
|
+
var MessageDocumentCollection = /** @class */ (function (_super) {
|
|
2542
|
+
__extends(MessageDocumentCollection, _super);
|
|
2543
|
+
function MessageDocumentCollection() {
|
|
2544
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2545
|
+
}
|
|
2574
2546
|
/**
|
|
2575
|
-
*
|
|
2576
|
-
* impossible to update, only prolong or buy new
|
|
2547
|
+
* get list of documents which are not attached to any message
|
|
2577
2548
|
*/
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
return !!this.items.filter(function (item) { return item.price.product.isArchived(); }).length;
|
|
2549
|
+
MessageDocumentCollection.prototype.getUnattached = function () {
|
|
2550
|
+
return new MessageDocumentCollection(this.items.filter(function (doc) { return !doc.message; }));
|
|
2581
2551
|
};
|
|
2552
|
+
return MessageDocumentCollection;
|
|
2553
|
+
}(Collection));
|
|
2554
|
+
|
|
2555
|
+
var LoanCollection = /** @class */ (function (_super) {
|
|
2556
|
+
__extends(LoanCollection, _super);
|
|
2557
|
+
function LoanCollection() {
|
|
2558
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2559
|
+
}
|
|
2582
2560
|
/**
|
|
2583
|
-
*
|
|
2561
|
+
* Get new collection of loans filtered by bank accounts ids
|
|
2562
|
+
* @param ids list of bank accounts ids for filter
|
|
2584
2563
|
*/
|
|
2585
|
-
|
|
2586
|
-
return this.
|
|
2564
|
+
LoanCollection.prototype.getByBankAccountsIds = function (ids) {
|
|
2565
|
+
return new LoanCollection(this.items.filter(function (loan) { var _a; return ids.includes((_a = loan.bankAccount) === null || _a === void 0 ? void 0 : _a.id); }));
|
|
2587
2566
|
};
|
|
2588
2567
|
/**
|
|
2589
|
-
*
|
|
2568
|
+
* Get single loan by bank account id
|
|
2569
|
+
* @param id id of bank account
|
|
2590
2570
|
*/
|
|
2591
|
-
|
|
2592
|
-
return
|
|
2571
|
+
LoanCollection.prototype.getByBankAccountId = function (id) {
|
|
2572
|
+
return this.items.find(function (loan) { var _a; return ((_a = loan.bankAccount) === null || _a === void 0 ? void 0 : _a.id) === id; });
|
|
2593
2573
|
};
|
|
2594
|
-
|
|
2595
|
-
|
|
2574
|
+
/**
|
|
2575
|
+
* Get list of current fin year payments grouped by loan id
|
|
2576
|
+
*/
|
|
2577
|
+
LoanCollection.prototype.groupCurrentYearPaymentsByLoans = function () {
|
|
2578
|
+
var dictionary = new CollectionDictionary(new LoanPaymentCollection([]));
|
|
2579
|
+
this.items.forEach(function (loan) { return dictionary.add(loan.id, new LoanPaymentCollection(loan.payments).getForCurrentYear()); });
|
|
2580
|
+
return dictionary;
|
|
2596
2581
|
};
|
|
2597
2582
|
/**
|
|
2598
|
-
*
|
|
2599
|
-
* based on the property service product and the number of properties the user has
|
|
2583
|
+
* Get list of vehicle loans
|
|
2600
2584
|
*/
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
return Math.max(min, propertiesQty);
|
|
2585
|
+
LoanCollection.prototype.getVehicleLoans = function () {
|
|
2586
|
+
return this.filter(function (loan) { return loan.isVehicle(); });
|
|
2604
2587
|
};
|
|
2605
|
-
return
|
|
2606
|
-
}(
|
|
2607
|
-
__decorate([
|
|
2608
|
-
classTransformer.Type(function () { return Date; })
|
|
2609
|
-
], ServiceSubscription.prototype, "startDate", void 0);
|
|
2610
|
-
__decorate([
|
|
2611
|
-
classTransformer.Type(function () { return Date; })
|
|
2612
|
-
], ServiceSubscription.prototype, "endDate", void 0);
|
|
2613
|
-
__decorate([
|
|
2614
|
-
classTransformer.Type(function () { return ServiceSubscriptionItem; })
|
|
2615
|
-
], ServiceSubscription.prototype, "items", void 0);
|
|
2588
|
+
return LoanCollection;
|
|
2589
|
+
}(Collection));
|
|
2616
2590
|
|
|
2617
|
-
var
|
|
2618
|
-
__extends(
|
|
2619
|
-
function
|
|
2591
|
+
var PropertySaleCollection = /** @class */ (function (_super) {
|
|
2592
|
+
__extends(PropertySaleCollection, _super);
|
|
2593
|
+
function PropertySaleCollection() {
|
|
2620
2594
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
2621
2595
|
}
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
return
|
|
2634
|
-
}
|
|
2635
|
-
|
|
2636
|
-
|
|
2596
|
+
Object.defineProperty(PropertySaleCollection.prototype, "grossCGTAfterLoss", {
|
|
2597
|
+
get: function () {
|
|
2598
|
+
return this.create(this.items.filter(function (propertySale) { return propertySale.grossCGTAfterLoss > 0; })).sumBy('grossCGTAfterLoss');
|
|
2599
|
+
},
|
|
2600
|
+
enumerable: false,
|
|
2601
|
+
configurable: true
|
|
2602
|
+
});
|
|
2603
|
+
/**
|
|
2604
|
+
* Property sales are CGT applicable unless it has "Principle place of residence" exemption type
|
|
2605
|
+
*/
|
|
2606
|
+
PropertySaleCollection.prototype.getCGTApplicable = function () {
|
|
2607
|
+
return this.create(this.items.filter(function (propertySale) { return propertySale.isCGTApplicable(); }));
|
|
2608
|
+
};
|
|
2609
|
+
PropertySaleCollection.prototype.getByPropertyShareIds = function (ids) {
|
|
2610
|
+
return this.filterBy('share.id', ids);
|
|
2611
|
+
};
|
|
2612
|
+
return PropertySaleCollection;
|
|
2613
|
+
}(Collection));
|
|
2637
2614
|
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2615
|
+
exports.TaxExemptionMetadataEnum = void 0;
|
|
2616
|
+
(function (TaxExemptionMetadataEnum) {
|
|
2617
|
+
// principle place of residence
|
|
2618
|
+
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["PPR_DAYS"] = 1] = "PPR_DAYS";
|
|
2619
|
+
// market value once it was moved, decimal
|
|
2620
|
+
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["MARKET_VALUE"] = 2] = "MARKET_VALUE";
|
|
2621
|
+
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["CLAIM_PERCENT"] = 3] = "CLAIM_PERCENT";
|
|
2622
|
+
})(exports.TaxExemptionMetadataEnum || (exports.TaxExemptionMetadataEnum = {}));
|
|
2623
|
+
|
|
2624
|
+
var PropertySaleTaxExemptionMetadataCollection = /** @class */ (function (_super) {
|
|
2625
|
+
__extends(PropertySaleTaxExemptionMetadataCollection, _super);
|
|
2626
|
+
function PropertySaleTaxExemptionMetadataCollection() {
|
|
2641
2627
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
2642
2628
|
}
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2629
|
+
PropertySaleTaxExemptionMetadataCollection.prototype.getPPRDays = function () {
|
|
2630
|
+
var _a, _b;
|
|
2631
|
+
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.PPR_DAYS)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
2632
|
+
};
|
|
2633
|
+
PropertySaleTaxExemptionMetadataCollection.prototype.getMarketValue = function () {
|
|
2634
|
+
var _a, _b;
|
|
2635
|
+
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.MARKET_VALUE)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
2636
|
+
};
|
|
2637
|
+
PropertySaleTaxExemptionMetadataCollection.prototype.getClaimPercent = function () {
|
|
2638
|
+
var _a, _b;
|
|
2639
|
+
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.CLAIM_PERCENT)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 100;
|
|
2640
|
+
};
|
|
2641
|
+
PropertySaleTaxExemptionMetadataCollection.prototype.getByMetadataId = function (id) {
|
|
2642
|
+
return this.items.find(function (metadata) { return metadata.metadata.id === id; });
|
|
2643
|
+
};
|
|
2644
|
+
return PropertySaleTaxExemptionMetadataCollection;
|
|
2645
|
+
}(Collection));
|
|
2648
2646
|
|
|
2649
|
-
/**
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
var SoleBusinessLoss = /** @class */ (function (_super) {
|
|
2654
|
-
__extends(SoleBusinessLoss, _super);
|
|
2655
|
-
function SoleBusinessLoss() {
|
|
2656
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
2657
|
-
_this.openBalance = 0;
|
|
2658
|
-
_this.financialYear = new FinancialYear().year;
|
|
2659
|
-
return _this;
|
|
2647
|
+
var PropertyCollection = /** @class */ (function (_super) {
|
|
2648
|
+
__extends(PropertyCollection, _super);
|
|
2649
|
+
function PropertyCollection() {
|
|
2650
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2660
2651
|
}
|
|
2661
|
-
|
|
2652
|
+
/**
|
|
2653
|
+
* Get new property collection filtered by category id
|
|
2654
|
+
* @param id id of category for filter
|
|
2655
|
+
*/
|
|
2656
|
+
PropertyCollection.prototype.getByCategoryId = function (id) {
|
|
2657
|
+
return new PropertyCollection(this.items.filter(function (property) { return property.category.id === id; }));
|
|
2658
|
+
};
|
|
2659
|
+
/**
|
|
2660
|
+
* Get new property collection filtered by active status
|
|
2661
|
+
*/
|
|
2662
|
+
PropertyCollection.prototype.getActiveProperties = function () {
|
|
2663
|
+
return new PropertyCollection(this.items.filter(function (property) { return property.isActive; }));
|
|
2664
|
+
};
|
|
2665
|
+
PropertyCollection.prototype.getCreatedProperties = function () {
|
|
2666
|
+
return new PropertyCollection(this.items.filter(function (property) { return property.isOwn(); }));
|
|
2667
|
+
};
|
|
2668
|
+
/**
|
|
2669
|
+
* Get new property collection filtered by shared
|
|
2670
|
+
*/
|
|
2671
|
+
PropertyCollection.prototype.getSharedProperties = function () {
|
|
2672
|
+
return new PropertyCollection(this.items.filter(function (property) { return !property.isOwn(); }));
|
|
2673
|
+
};
|
|
2674
|
+
/**
|
|
2675
|
+
* Properties that are taxed and will be included in reports (Tax summary, My tax report, e.t.c.)
|
|
2676
|
+
*/
|
|
2677
|
+
PropertyCollection.prototype.getTaxInclusive = function () {
|
|
2678
|
+
return this.create(this.items.filter(function (property) { return property.category.isTaxInclusive; }));
|
|
2679
|
+
};
|
|
2680
|
+
PropertyCollection.prototype.getUnsold = function () {
|
|
2681
|
+
return this.create(this.items.filter(function (property) { return !property.isSold(); }));
|
|
2682
|
+
};
|
|
2683
|
+
Object.defineProperty(PropertyCollection.prototype, "purchasePrice", {
|
|
2684
|
+
/**
|
|
2685
|
+
* Get total purchase price for all properties in the collection
|
|
2686
|
+
*/
|
|
2687
|
+
get: function () {
|
|
2688
|
+
return this.sumBy('purchasePrice');
|
|
2689
|
+
},
|
|
2690
|
+
enumerable: false,
|
|
2691
|
+
configurable: true
|
|
2692
|
+
});
|
|
2693
|
+
Object.defineProperty(PropertyCollection.prototype, "growthPercent", {
|
|
2694
|
+
get: function () {
|
|
2695
|
+
return this.sumBy('growthPercent');
|
|
2696
|
+
},
|
|
2697
|
+
enumerable: false,
|
|
2698
|
+
configurable: true
|
|
2699
|
+
});
|
|
2700
|
+
Object.defineProperty(PropertyCollection.prototype, "marketValue", {
|
|
2701
|
+
get: function () {
|
|
2702
|
+
return this.sumBy('marketValue');
|
|
2703
|
+
},
|
|
2704
|
+
enumerable: false,
|
|
2705
|
+
configurable: true
|
|
2706
|
+
});
|
|
2707
|
+
Object.defineProperty(PropertyCollection.prototype, "firstForecastYear", {
|
|
2708
|
+
get: function () {
|
|
2709
|
+
return this.items.reduce(function (min, property) {
|
|
2710
|
+
var current = property.firstForecastYear;
|
|
2711
|
+
return min > current ? current : min;
|
|
2712
|
+
}, new FinancialYear().year);
|
|
2713
|
+
},
|
|
2714
|
+
enumerable: false,
|
|
2715
|
+
configurable: true
|
|
2716
|
+
});
|
|
2717
|
+
Object.defineProperty(PropertyCollection.prototype, "marketValueGrowth", {
|
|
2662
2718
|
get: function () {
|
|
2663
|
-
return
|
|
2719
|
+
return (this.marketValue - this.purchasePrice) / this.purchasePrice;
|
|
2664
2720
|
},
|
|
2665
2721
|
enumerable: false,
|
|
2666
2722
|
configurable: true
|
|
2667
2723
|
});
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2724
|
+
/**
|
|
2725
|
+
* list of properties
|
|
2726
|
+
*/
|
|
2727
|
+
PropertyCollection.prototype.getCGTApplicable = function () {
|
|
2728
|
+
return this.create(this.items.filter(function (property) { return property.isCGTApplicable(); }));
|
|
2729
|
+
};
|
|
2730
|
+
PropertyCollection.prototype.getOwnerOccupiedProperties = function () {
|
|
2731
|
+
return new PropertyCollection(this.items.filter(function (property) { return property.category.isOwnerOccupied(); }));
|
|
2732
|
+
};
|
|
2733
|
+
Object.defineProperty(PropertyCollection.prototype, "earliestContractDate", {
|
|
2734
|
+
get: function () {
|
|
2735
|
+
return this.items.reduce(function (min, property) {
|
|
2736
|
+
return min < property.contractDate ? min : property.contractDate;
|
|
2737
|
+
}, new FinancialYear(new Date()).startDate);
|
|
2738
|
+
},
|
|
2739
|
+
enumerable: false,
|
|
2740
|
+
configurable: true
|
|
2741
|
+
});
|
|
2742
|
+
/**
|
|
2743
|
+
* Get list of unique property categories from collection
|
|
2744
|
+
*/
|
|
2745
|
+
PropertyCollection.prototype.getCategories = function () {
|
|
2746
|
+
return uniqBy__default["default"](this.items.map(function (property) { return property.category; }), 'id');
|
|
2747
|
+
};
|
|
2748
|
+
/**
|
|
2749
|
+
* Get property with the highest growth percent
|
|
2750
|
+
*/
|
|
2751
|
+
PropertyCollection.prototype.getBestPerformanceGrowthProperty = function () {
|
|
2752
|
+
return this.items.reduce(function (max, current) {
|
|
2753
|
+
return max.growthPercent < current.growthPercent ? current : max;
|
|
2754
|
+
}, this.first);
|
|
2755
|
+
};
|
|
2756
|
+
/**
|
|
2757
|
+
* Get property with the lowest tax position
|
|
2758
|
+
*/
|
|
2759
|
+
PropertyCollection.prototype.getBestPerformanceTaxProperty = function (transactions, depreciations) {
|
|
2760
|
+
var transactionsByProperty = transactions.groupBy('property.id');
|
|
2761
|
+
var depreciationsByProperty = depreciations.groupBy('property.id');
|
|
2762
|
+
return this.items.reduce(function (min, current) {
|
|
2763
|
+
var minTaxPosition = min.getTaxPosition(transactionsByProperty.get(min.id), depreciationsByProperty.get(min.id));
|
|
2764
|
+
var currentTaxPosition = current.getTaxPosition(transactionsByProperty.get(current.id), depreciationsByProperty.get(current.id));
|
|
2765
|
+
return minTaxPosition > currentTaxPosition ? current : min;
|
|
2766
|
+
}, this.first);
|
|
2767
|
+
};
|
|
2768
|
+
/**
|
|
2769
|
+
* Show best performance properties first
|
|
2770
|
+
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/217677997/Property+Tank+Dashboard
|
|
2771
|
+
*/
|
|
2772
|
+
PropertyCollection.prototype.sortByBestPerformance = function (transactions, depreciations) {
|
|
2773
|
+
var activeProperties = this.getActiveProperties();
|
|
2774
|
+
// nothing to sort when no active properties
|
|
2775
|
+
if (!activeProperties.length) {
|
|
2776
|
+
return this;
|
|
2777
|
+
}
|
|
2778
|
+
var bestProperties = uniqBy__default["default"](this.create([
|
|
2779
|
+
activeProperties.getBestPerformanceGrowthProperty(),
|
|
2780
|
+
activeProperties.getBestPerformanceTaxProperty(transactions, depreciations)
|
|
2781
|
+
]).toArray(), 'id');
|
|
2782
|
+
var newItems = this.remove(bestProperties).toArray();
|
|
2783
|
+
newItems.unshift.apply(newItems, __spreadArray([], __read(bestProperties)));
|
|
2784
|
+
return this.create(newItems);
|
|
2785
|
+
};
|
|
2786
|
+
return PropertyCollection;
|
|
2787
|
+
}(Collection));
|
|
2695
2788
|
|
|
2696
|
-
var
|
|
2697
|
-
|
|
2789
|
+
var PropertyCategoryMovementCollection = /** @class */ (function (_super) {
|
|
2790
|
+
__extends(PropertyCategoryMovementCollection, _super);
|
|
2791
|
+
function PropertyCategoryMovementCollection() {
|
|
2792
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2698
2793
|
}
|
|
2699
|
-
|
|
2700
|
-
|
|
2794
|
+
/**
|
|
2795
|
+
* @TODO TT-2355 Alex refactor propertyForecast, use separated api (then I can remove property from param)
|
|
2796
|
+
*/
|
|
2797
|
+
PropertyCategoryMovementCollection.prototype.getByForecast = function (property, forecast) {
|
|
2798
|
+
var financialYear = new FinancialYear(forecast.financialYear);
|
|
2799
|
+
return this.filterBy('property.id', property.id).filter(function (movement) {
|
|
2800
|
+
return movement.fromDate <= financialYear.endDate && !movement.toDate || movement.toDate >= financialYear.startDate;
|
|
2801
|
+
});
|
|
2802
|
+
};
|
|
2803
|
+
PropertyCategoryMovementCollection.prototype.hasCategory = function (categoryId) {
|
|
2804
|
+
return !!this.findBy('propertyCategory.id', categoryId);
|
|
2805
|
+
};
|
|
2806
|
+
return PropertyCategoryMovementCollection;
|
|
2807
|
+
}(Collection));
|
|
2701
2808
|
|
|
2702
|
-
var
|
|
2703
|
-
__extends(
|
|
2704
|
-
function
|
|
2809
|
+
var PropertyShareCollection = /** @class */ (function (_super) {
|
|
2810
|
+
__extends(PropertyShareCollection, _super);
|
|
2811
|
+
function PropertyShareCollection() {
|
|
2705
2812
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
2706
2813
|
}
|
|
2707
|
-
|
|
2708
|
-
|
|
2814
|
+
/**
|
|
2815
|
+
* Get list of incoming property shares
|
|
2816
|
+
* (initiated not by current user)
|
|
2817
|
+
* @TODO Alex: rename
|
|
2818
|
+
*/
|
|
2819
|
+
PropertyShareCollection.prototype.getIncoming = function () {
|
|
2820
|
+
return this.filter(function (propertyShare) {
|
|
2821
|
+
var _a;
|
|
2822
|
+
return ((_a = propertyShare.user) === null || _a === void 0 ? void 0 : _a.isLoggedIn()) && propertyShare.isPending() && propertyShare.property.user.id !== +localStorage.getItem('userId');
|
|
2823
|
+
});
|
|
2824
|
+
};
|
|
2825
|
+
/**
|
|
2826
|
+
* Get list of outcoming property shares
|
|
2827
|
+
* (initiated by current user)
|
|
2828
|
+
* @TODO Alex: rename
|
|
2829
|
+
*/
|
|
2830
|
+
PropertyShareCollection.prototype.getOutcoming = function () {
|
|
2831
|
+
return this.filter(function (propertyShare) { var _a; return !((_a = propertyShare.user) === null || _a === void 0 ? void 0 : _a.isLoggedIn()); });
|
|
2832
|
+
};
|
|
2833
|
+
return PropertyShareCollection;
|
|
2834
|
+
}(Collection));
|
|
2709
2835
|
|
|
2710
2836
|
/**
|
|
2711
|
-
*
|
|
2837
|
+
* Enum with symbols based on depreciation LVP asset type
|
|
2712
2838
|
*/
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
ROLE_CLIENT: [exports.UserRolesEnum.CLIENT],
|
|
2720
|
-
ROLE_USER_SUBSCRIPTION: [exports.UserRolesEnum.SUBSCRIPTION],
|
|
2721
|
-
ROLE_USER_WORK: [exports.UserRolesEnum.WORK_TANK],
|
|
2722
|
-
ROLE_USER_PROPERTY: [exports.UserRolesEnum.PROPERTY_TANK],
|
|
2723
|
-
ROLE_USER_SOLE: [exports.UserRolesEnum.SOLE_TANK],
|
|
2724
|
-
};
|
|
2839
|
+
exports.DepreciationLvpAssetTypeEnum = void 0;
|
|
2840
|
+
(function (DepreciationLvpAssetTypeEnum) {
|
|
2841
|
+
DepreciationLvpAssetTypeEnum["PRIOR_YEARS"] = "A";
|
|
2842
|
+
DepreciationLvpAssetTypeEnum["FIRST_YEAR"] = "L";
|
|
2843
|
+
DepreciationLvpAssetTypeEnum["WRITTEN_OFF"] = "W";
|
|
2844
|
+
})(exports.DepreciationLvpAssetTypeEnum || (exports.DepreciationLvpAssetTypeEnum = {}));
|
|
2725
2845
|
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
}());
|
|
2846
|
+
exports.DepreciationTypeEnum = void 0;
|
|
2847
|
+
(function (DepreciationTypeEnum) {
|
|
2848
|
+
DepreciationTypeEnum[DepreciationTypeEnum["PLANT_EQUIPMENT"] = 1] = "PLANT_EQUIPMENT";
|
|
2849
|
+
DepreciationTypeEnum[DepreciationTypeEnum["CAPITAL_WORKS"] = 2] = "CAPITAL_WORKS";
|
|
2850
|
+
DepreciationTypeEnum[DepreciationTypeEnum["BULK_DEPRECIATION"] = 3] = "BULK_DEPRECIATION";
|
|
2851
|
+
DepreciationTypeEnum[DepreciationTypeEnum["BORROWING_EXPENSES"] = 4] = "BORROWING_EXPENSES";
|
|
2852
|
+
})(exports.DepreciationTypeEnum || (exports.DepreciationTypeEnum = {}));
|
|
2734
2853
|
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2854
|
+
exports.DepreciationCalculationEnum = void 0;
|
|
2855
|
+
(function (DepreciationCalculationEnum) {
|
|
2856
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["PRIME_COST"] = 1] = "PRIME_COST";
|
|
2857
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["DIMINISHING"] = 2] = "DIMINISHING";
|
|
2858
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["CAPITAL"] = 3] = "CAPITAL";
|
|
2859
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["LVP"] = 4] = "LVP";
|
|
2860
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["AMORTISATION"] = 5] = "AMORTISATION";
|
|
2861
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["SBP"] = 6] = "SBP";
|
|
2862
|
+
})(exports.DepreciationCalculationEnum || (exports.DepreciationCalculationEnum = {}));
|
|
2742
2863
|
|
|
2743
2864
|
exports.DocumentTypeEnum = void 0;
|
|
2744
2865
|
(function (DocumentTypeEnum) {
|
|
@@ -3022,22 +3143,76 @@
|
|
|
3022
3143
|
|
|
3023
3144
|
// @TODO Artem TT-2308 move everything
|
|
3024
3145
|
|
|
3025
|
-
var
|
|
3026
|
-
__extends(
|
|
3027
|
-
function
|
|
3146
|
+
var DepreciationCapitalProject = /** @class */ (function (_super) {
|
|
3147
|
+
__extends(DepreciationCapitalProject, _super);
|
|
3148
|
+
function DepreciationCapitalProject() {
|
|
3028
3149
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3029
3150
|
}
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3151
|
+
return DepreciationCapitalProject;
|
|
3152
|
+
}(DepreciationCapitalProject$1));
|
|
3153
|
+
__decorate([
|
|
3154
|
+
classTransformer.Type(function () { return Date; })
|
|
3155
|
+
], DepreciationCapitalProject.prototype, "effectiveDate", void 0);
|
|
3156
|
+
|
|
3157
|
+
var DepreciationForecast = /** @class */ (function (_super) {
|
|
3158
|
+
__extends(DepreciationForecast, _super);
|
|
3159
|
+
function DepreciationForecast() {
|
|
3160
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3161
|
+
}
|
|
3162
|
+
Object.defineProperty(DepreciationForecast.prototype, "dailyClaimAmount", {
|
|
3163
|
+
get: function () {
|
|
3164
|
+
return this.claimAmount / this.daysApplied;
|
|
3165
|
+
},
|
|
3166
|
+
enumerable: false,
|
|
3167
|
+
configurable: true
|
|
3168
|
+
});
|
|
3169
|
+
Object.defineProperty(DepreciationForecast.prototype, "daysApplied", {
|
|
3170
|
+
get: function () {
|
|
3171
|
+
return moment__namespace(this.toDate).diff(moment__namespace(this.fromDate), 'days');
|
|
3172
|
+
},
|
|
3173
|
+
enumerable: false,
|
|
3174
|
+
configurable: true
|
|
3175
|
+
});
|
|
3176
|
+
DepreciationForecast.prototype.getDaysByMonth = function (month) {
|
|
3177
|
+
// @TODO find a better place
|
|
3178
|
+
var year = this.financialYear - (month > 5 ? 1 : 0);
|
|
3179
|
+
// forecast date intersect by month
|
|
3180
|
+
var range = new momentRange.DateRange(this.fromDate, this.toDate).intersect(new momentRange.DateRange(new Date(year, month, 1), new Date(year, month + 1, 0)));
|
|
3181
|
+
return range ? range.duration('days') + 1 : 0;
|
|
3035
3182
|
};
|
|
3036
|
-
|
|
3037
|
-
|
|
3183
|
+
Object.defineProperty(DepreciationForecast.prototype, "claimOpenBalance", {
|
|
3184
|
+
get: function () {
|
|
3185
|
+
return this.openBalance * this.claimRate;
|
|
3186
|
+
},
|
|
3187
|
+
enumerable: false,
|
|
3188
|
+
configurable: true
|
|
3189
|
+
});
|
|
3190
|
+
Object.defineProperty(DepreciationForecast.prototype, "claimCloseBalance", {
|
|
3191
|
+
get: function () {
|
|
3192
|
+
return this.closeBalance * this.claimRate;
|
|
3193
|
+
},
|
|
3194
|
+
enumerable: false,
|
|
3195
|
+
configurable: true
|
|
3196
|
+
});
|
|
3197
|
+
Object.defineProperty(DepreciationForecast.prototype, "claimAmount", {
|
|
3198
|
+
get: function () {
|
|
3199
|
+
return this.amount * this.claimRate;
|
|
3200
|
+
},
|
|
3201
|
+
enumerable: false,
|
|
3202
|
+
configurable: true
|
|
3203
|
+
});
|
|
3204
|
+
Object.defineProperty(DepreciationForecast.prototype, "claimRate", {
|
|
3205
|
+
get: function () {
|
|
3206
|
+
return this.claimPercent / 100;
|
|
3207
|
+
},
|
|
3208
|
+
enumerable: false,
|
|
3209
|
+
configurable: true
|
|
3210
|
+
});
|
|
3211
|
+
DepreciationForecast.prototype.getClaimAmountByMonth = function (month) {
|
|
3212
|
+
return this.getDaysByMonth(month) * this.dailyClaimAmount;
|
|
3038
3213
|
};
|
|
3039
|
-
return
|
|
3040
|
-
}(
|
|
3214
|
+
return DepreciationForecast;
|
|
3215
|
+
}(DepreciationForecast$1));
|
|
3041
3216
|
|
|
3042
3217
|
/**
|
|
3043
3218
|
* Grouped chart accounts categories for fast work
|
|
@@ -3140,6 +3315,81 @@
|
|
|
3140
3315
|
]
|
|
3141
3316
|
};
|
|
3142
3317
|
|
|
3318
|
+
/**
|
|
3319
|
+
* @TODO Alex/Vik: think and create some new collection type
|
|
3320
|
+
* @TODO Alex: research all constants and make the same structure
|
|
3321
|
+
*/
|
|
3322
|
+
var ChartAccountsCategoryECollection = /** @class */ (function () {
|
|
3323
|
+
function ChartAccountsCategoryECollection(items) {
|
|
3324
|
+
this.items = items || [
|
|
3325
|
+
exports.ChartAccountsCategoryEnum.PROPERTY_INCOME,
|
|
3326
|
+
exports.ChartAccountsCategoryEnum.PROPERTY_EXPENSE,
|
|
3327
|
+
exports.ChartAccountsCategoryEnum.PROPERTY_DEPRECIATION,
|
|
3328
|
+
exports.ChartAccountsCategoryEnum.PROPERTY_CAPITAL_WORKS,
|
|
3329
|
+
exports.ChartAccountsCategoryEnum.WORK_DEPRECIATION,
|
|
3330
|
+
exports.ChartAccountsCategoryEnum.WORK_INCOME,
|
|
3331
|
+
exports.ChartAccountsCategoryEnum.WORK_EXPENSE,
|
|
3332
|
+
exports.ChartAccountsCategoryEnum.OTHER_INCOME,
|
|
3333
|
+
exports.ChartAccountsCategoryEnum.OTHER_EXPENSE,
|
|
3334
|
+
exports.ChartAccountsCategoryEnum.PERSONAL_INCOME,
|
|
3335
|
+
exports.ChartAccountsCategoryEnum.PERSONAL_EXPENSE,
|
|
3336
|
+
exports.ChartAccountsCategoryEnum.SOLE_INCOME,
|
|
3337
|
+
exports.ChartAccountsCategoryEnum.SOLE_EXPENSE,
|
|
3338
|
+
exports.ChartAccountsCategoryEnum.SOLE_DEPRECIATION
|
|
3339
|
+
];
|
|
3340
|
+
}
|
|
3341
|
+
ChartAccountsCategoryECollection.prototype.getByType = function (types) {
|
|
3342
|
+
var _this = this;
|
|
3343
|
+
if (!Array.isArray(types)) {
|
|
3344
|
+
types = [types];
|
|
3345
|
+
}
|
|
3346
|
+
var items = [];
|
|
3347
|
+
types.forEach(function (type) {
|
|
3348
|
+
var filtered = _this.items.filter(function (item) { return exports.ChartAccountsCategoryEnum[item].includes(type.toUpperCase()); });
|
|
3349
|
+
items.push.apply(items, __spreadArray([], __read(filtered)));
|
|
3350
|
+
});
|
|
3351
|
+
return new ChartAccountsCategoryECollection(items);
|
|
3352
|
+
};
|
|
3353
|
+
ChartAccountsCategoryECollection.prototype.getByTankType = function (tankTypes) {
|
|
3354
|
+
var _this = this;
|
|
3355
|
+
if (!Array.isArray(tankTypes)) {
|
|
3356
|
+
tankTypes = [tankTypes];
|
|
3357
|
+
}
|
|
3358
|
+
var items = [];
|
|
3359
|
+
tankTypes.forEach(function (tankType) {
|
|
3360
|
+
var filtered = _this.items.filter(function (item) { return exports.ChartAccountsCategoryEnum[item].includes(tankType.toUpperCase()); });
|
|
3361
|
+
items.push.apply(items, __spreadArray([], __read(filtered)));
|
|
3362
|
+
});
|
|
3363
|
+
return new ChartAccountsCategoryECollection(items);
|
|
3364
|
+
};
|
|
3365
|
+
return ChartAccountsCategoryECollection;
|
|
3366
|
+
}());
|
|
3367
|
+
|
|
3368
|
+
var ChartAccountsHeading = /** @class */ (function (_super) {
|
|
3369
|
+
__extends(ChartAccountsHeading, _super);
|
|
3370
|
+
function ChartAccountsHeading() {
|
|
3371
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3372
|
+
}
|
|
3373
|
+
return ChartAccountsHeading;
|
|
3374
|
+
}(ChartAccountsHeading$1));
|
|
3375
|
+
|
|
3376
|
+
var ChartAccountsMetadata = /** @class */ (function (_super) {
|
|
3377
|
+
__extends(ChartAccountsMetadata, _super);
|
|
3378
|
+
function ChartAccountsMetadata() {
|
|
3379
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3380
|
+
}
|
|
3381
|
+
/**
|
|
3382
|
+
* Check if metadata id is related to SHARE_PERCENTAGE value
|
|
3383
|
+
*/
|
|
3384
|
+
ChartAccountsMetadata.prototype.isSharePercentage = function () {
|
|
3385
|
+
return this.id === exports.ChartAccountsMetadataListEnum.SHARE_PERCENTAGE;
|
|
3386
|
+
};
|
|
3387
|
+
ChartAccountsMetadata.prototype.isHours = function () {
|
|
3388
|
+
return this.id === exports.ChartAccountsMetadataListEnum.HOURS;
|
|
3389
|
+
};
|
|
3390
|
+
return ChartAccountsMetadata;
|
|
3391
|
+
}(ChartAccountsMetadata$1));
|
|
3392
|
+
|
|
3143
3393
|
exports.ChartAccountsTaxLabelsEnum = void 0;
|
|
3144
3394
|
(function (ChartAccountsTaxLabelsEnum) {
|
|
3145
3395
|
ChartAccountsTaxLabelsEnum["TAX_WITHHELD"] = "Tax withheld";
|
|
@@ -3366,6 +3616,46 @@
|
|
|
3366
3616
|
classTransformer.Type(function () { return ChartAccountsMetadata; })
|
|
3367
3617
|
], ChartAccounts.prototype, "metadata", void 0);
|
|
3368
3618
|
|
|
3619
|
+
var ChartAccountsDepreciation = /** @class */ (function (_super) {
|
|
3620
|
+
__extends(ChartAccountsDepreciation, _super);
|
|
3621
|
+
function ChartAccountsDepreciation() {
|
|
3622
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3623
|
+
}
|
|
3624
|
+
return ChartAccountsDepreciation;
|
|
3625
|
+
}(ChartAccountsDepreciation$1));
|
|
3626
|
+
__decorate([
|
|
3627
|
+
classTransformer.Type(function () { return ChartAccounts; })
|
|
3628
|
+
], ChartAccountsDepreciation.prototype, "chartAccounts", void 0);
|
|
3629
|
+
__decorate([
|
|
3630
|
+
classTransformer.Transform(function (_a) {
|
|
3631
|
+
var value = _a.value;
|
|
3632
|
+
return +value;
|
|
3633
|
+
})
|
|
3634
|
+
], ChartAccountsDepreciation.prototype, "limit", void 0);
|
|
3635
|
+
__decorate([
|
|
3636
|
+
classTransformer.Transform(function (_a) {
|
|
3637
|
+
var value = _a.value;
|
|
3638
|
+
return +value;
|
|
3639
|
+
})
|
|
3640
|
+
], ChartAccountsDepreciation.prototype, "effectiveLife", void 0);
|
|
3641
|
+
|
|
3642
|
+
var ChartAccountsValue = /** @class */ (function (_super) {
|
|
3643
|
+
__extends(ChartAccountsValue, _super);
|
|
3644
|
+
function ChartAccountsValue() {
|
|
3645
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3646
|
+
}
|
|
3647
|
+
return ChartAccountsValue;
|
|
3648
|
+
}(ChartAccountsValue$1));
|
|
3649
|
+
|
|
3650
|
+
/**
|
|
3651
|
+
* Enum with income amount types (Net or Gross)
|
|
3652
|
+
*/
|
|
3653
|
+
exports.IncomeAmountTypeEnum = void 0;
|
|
3654
|
+
(function (IncomeAmountTypeEnum) {
|
|
3655
|
+
IncomeAmountTypeEnum[IncomeAmountTypeEnum["NET"] = 0] = "NET";
|
|
3656
|
+
IncomeAmountTypeEnum[IncomeAmountTypeEnum["GROSS"] = 1] = "GROSS";
|
|
3657
|
+
})(exports.IncomeAmountTypeEnum || (exports.IncomeAmountTypeEnum = {}));
|
|
3658
|
+
|
|
3369
3659
|
exports.TransactionTypeEnum = void 0;
|
|
3370
3660
|
(function (TransactionTypeEnum) {
|
|
3371
3661
|
TransactionTypeEnum[TransactionTypeEnum["DEBIT"] = 1] = "DEBIT";
|
|
@@ -3386,24 +3676,6 @@
|
|
|
3386
3676
|
TransactionSourceEnum[TransactionSourceEnum["BANK_TRANSACTION"] = 2] = "BANK_TRANSACTION";
|
|
3387
3677
|
})(exports.TransactionSourceEnum || (exports.TransactionSourceEnum = {}));
|
|
3388
3678
|
|
|
3389
|
-
exports.DepreciationTypeEnum = void 0;
|
|
3390
|
-
(function (DepreciationTypeEnum) {
|
|
3391
|
-
DepreciationTypeEnum[DepreciationTypeEnum["PLANT_EQUIPMENT"] = 1] = "PLANT_EQUIPMENT";
|
|
3392
|
-
DepreciationTypeEnum[DepreciationTypeEnum["CAPITAL_WORKS"] = 2] = "CAPITAL_WORKS";
|
|
3393
|
-
DepreciationTypeEnum[DepreciationTypeEnum["BULK_DEPRECIATION"] = 3] = "BULK_DEPRECIATION";
|
|
3394
|
-
DepreciationTypeEnum[DepreciationTypeEnum["BORROWING_EXPENSES"] = 4] = "BORROWING_EXPENSES";
|
|
3395
|
-
})(exports.DepreciationTypeEnum || (exports.DepreciationTypeEnum = {}));
|
|
3396
|
-
|
|
3397
|
-
exports.DepreciationCalculationEnum = void 0;
|
|
3398
|
-
(function (DepreciationCalculationEnum) {
|
|
3399
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["PRIME_COST"] = 1] = "PRIME_COST";
|
|
3400
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["DIMINISHING"] = 2] = "DIMINISHING";
|
|
3401
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["CAPITAL"] = 3] = "CAPITAL";
|
|
3402
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["LVP"] = 4] = "LVP";
|
|
3403
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["AMORTISATION"] = 5] = "AMORTISATION";
|
|
3404
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["SBP"] = 6] = "SBP";
|
|
3405
|
-
})(exports.DepreciationCalculationEnum || (exports.DepreciationCalculationEnum = {}));
|
|
3406
|
-
|
|
3407
3679
|
/**
|
|
3408
3680
|
* Enum with asset types
|
|
3409
3681
|
*/
|
|
@@ -3417,111 +3689,30 @@
|
|
|
3417
3689
|
AssetTypeEnum["PROPERTY_PHOTO"] = "propertyPhoto";
|
|
3418
3690
|
AssetTypeEnum["DEPRECIATION_RECEIPT"] = "depreciationReceipt";
|
|
3419
3691
|
AssetTypeEnum["FIRM_PHOTO"] = "firmPhoto";
|
|
3420
|
-
})(exports.AssetTypeEnum || (exports.AssetTypeEnum = {}));
|
|
3421
|
-
|
|
3422
|
-
/**
|
|
3423
|
-
* Enum with asset entity types
|
|
3424
|
-
*/
|
|
3425
|
-
exports.AssetEntityTypeEnum = void 0;
|
|
3426
|
-
(function (AssetEntityTypeEnum) {
|
|
3427
|
-
AssetEntityTypeEnum["PROPERTIES"] = "properties";
|
|
3428
|
-
AssetEntityTypeEnum["FOLDERS"] = "folders";
|
|
3429
|
-
AssetEntityTypeEnum["DEPRECIATIONS"] = "depreciations";
|
|
3430
|
-
AssetEntityTypeEnum["TRANSACTIONS"] = "transactions";
|
|
3431
|
-
AssetEntityTypeEnum["MESSAGES"] = "messages";
|
|
3432
|
-
})(exports.AssetEntityTypeEnum || (exports.AssetEntityTypeEnum = {}));
|
|
3433
|
-
|
|
3434
|
-
var TransactionReceipt = /** @class */ (function (_super) {
|
|
3435
|
-
__extends(TransactionReceipt, _super);
|
|
3436
|
-
function TransactionReceipt() {
|
|
3437
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3438
|
-
_this.type = exports.AssetTypeEnum.TRANSACTION_RECEIPT;
|
|
3439
|
-
_this.entityType = exports.AssetEntityTypeEnum.TRANSACTIONS;
|
|
3440
|
-
return _this;
|
|
3441
|
-
}
|
|
3442
|
-
return TransactionReceipt;
|
|
3443
|
-
}(TransactionReceipt$1));
|
|
3444
|
-
|
|
3445
|
-
/**
|
|
3446
|
-
* @TODO Alex/Vik: think and create some new collection type
|
|
3447
|
-
* @TODO Alex: research all constants and make the same structure
|
|
3448
|
-
*/
|
|
3449
|
-
var ChartAccountsCategoryECollection = /** @class */ (function () {
|
|
3450
|
-
function ChartAccountsCategoryECollection(items) {
|
|
3451
|
-
this.items = items || [
|
|
3452
|
-
exports.ChartAccountsCategoryEnum.PROPERTY_INCOME,
|
|
3453
|
-
exports.ChartAccountsCategoryEnum.PROPERTY_EXPENSE,
|
|
3454
|
-
exports.ChartAccountsCategoryEnum.PROPERTY_DEPRECIATION,
|
|
3455
|
-
exports.ChartAccountsCategoryEnum.PROPERTY_CAPITAL_WORKS,
|
|
3456
|
-
exports.ChartAccountsCategoryEnum.WORK_DEPRECIATION,
|
|
3457
|
-
exports.ChartAccountsCategoryEnum.WORK_INCOME,
|
|
3458
|
-
exports.ChartAccountsCategoryEnum.WORK_EXPENSE,
|
|
3459
|
-
exports.ChartAccountsCategoryEnum.OTHER_INCOME,
|
|
3460
|
-
exports.ChartAccountsCategoryEnum.OTHER_EXPENSE,
|
|
3461
|
-
exports.ChartAccountsCategoryEnum.PERSONAL_INCOME,
|
|
3462
|
-
exports.ChartAccountsCategoryEnum.PERSONAL_EXPENSE,
|
|
3463
|
-
exports.ChartAccountsCategoryEnum.SOLE_INCOME,
|
|
3464
|
-
exports.ChartAccountsCategoryEnum.SOLE_EXPENSE,
|
|
3465
|
-
exports.ChartAccountsCategoryEnum.SOLE_DEPRECIATION
|
|
3466
|
-
];
|
|
3467
|
-
}
|
|
3468
|
-
ChartAccountsCategoryECollection.prototype.getByType = function (types) {
|
|
3469
|
-
var _this = this;
|
|
3470
|
-
if (!Array.isArray(types)) {
|
|
3471
|
-
types = [types];
|
|
3472
|
-
}
|
|
3473
|
-
var items = [];
|
|
3474
|
-
types.forEach(function (type) {
|
|
3475
|
-
var filtered = _this.items.filter(function (item) { return exports.ChartAccountsCategoryEnum[item].includes(type.toUpperCase()); });
|
|
3476
|
-
items.push.apply(items, __spreadArray([], __read(filtered)));
|
|
3477
|
-
});
|
|
3478
|
-
return new ChartAccountsCategoryECollection(items);
|
|
3479
|
-
};
|
|
3480
|
-
ChartAccountsCategoryECollection.prototype.getByTankType = function (tankTypes) {
|
|
3481
|
-
var _this = this;
|
|
3482
|
-
if (!Array.isArray(tankTypes)) {
|
|
3483
|
-
tankTypes = [tankTypes];
|
|
3484
|
-
}
|
|
3485
|
-
var items = [];
|
|
3486
|
-
tankTypes.forEach(function (tankType) {
|
|
3487
|
-
var filtered = _this.items.filter(function (item) { return exports.ChartAccountsCategoryEnum[item].includes(tankType.toUpperCase()); });
|
|
3488
|
-
items.push.apply(items, __spreadArray([], __read(filtered)));
|
|
3489
|
-
});
|
|
3490
|
-
return new ChartAccountsCategoryECollection(items);
|
|
3491
|
-
};
|
|
3492
|
-
return ChartAccountsCategoryECollection;
|
|
3493
|
-
}());
|
|
3494
|
-
|
|
3495
|
-
var ChartAccountsDepreciation = /** @class */ (function (_super) {
|
|
3496
|
-
__extends(ChartAccountsDepreciation, _super);
|
|
3497
|
-
function ChartAccountsDepreciation() {
|
|
3498
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3499
|
-
}
|
|
3500
|
-
return ChartAccountsDepreciation;
|
|
3501
|
-
}(ChartAccountsDepreciation$1));
|
|
3502
|
-
__decorate([
|
|
3503
|
-
classTransformer.Type(function () { return ChartAccounts; })
|
|
3504
|
-
], ChartAccountsDepreciation.prototype, "chartAccounts", void 0);
|
|
3505
|
-
__decorate([
|
|
3506
|
-
classTransformer.Transform(function (_a) {
|
|
3507
|
-
var value = _a.value;
|
|
3508
|
-
return +value;
|
|
3509
|
-
})
|
|
3510
|
-
], ChartAccountsDepreciation.prototype, "limit", void 0);
|
|
3511
|
-
__decorate([
|
|
3512
|
-
classTransformer.Transform(function (_a) {
|
|
3513
|
-
var value = _a.value;
|
|
3514
|
-
return +value;
|
|
3515
|
-
})
|
|
3516
|
-
], ChartAccountsDepreciation.prototype, "effectiveLife", void 0);
|
|
3692
|
+
})(exports.AssetTypeEnum || (exports.AssetTypeEnum = {}));
|
|
3517
3693
|
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3694
|
+
/**
|
|
3695
|
+
* Enum with asset entity types
|
|
3696
|
+
*/
|
|
3697
|
+
exports.AssetEntityTypeEnum = void 0;
|
|
3698
|
+
(function (AssetEntityTypeEnum) {
|
|
3699
|
+
AssetEntityTypeEnum["PROPERTIES"] = "properties";
|
|
3700
|
+
AssetEntityTypeEnum["FOLDERS"] = "folders";
|
|
3701
|
+
AssetEntityTypeEnum["DEPRECIATIONS"] = "depreciations";
|
|
3702
|
+
AssetEntityTypeEnum["TRANSACTIONS"] = "transactions";
|
|
3703
|
+
AssetEntityTypeEnum["MESSAGES"] = "messages";
|
|
3704
|
+
})(exports.AssetEntityTypeEnum || (exports.AssetEntityTypeEnum = {}));
|
|
3705
|
+
|
|
3706
|
+
var TransactionReceipt = /** @class */ (function (_super) {
|
|
3707
|
+
__extends(TransactionReceipt, _super);
|
|
3708
|
+
function TransactionReceipt() {
|
|
3709
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3710
|
+
_this.type = exports.AssetTypeEnum.TRANSACTION_RECEIPT;
|
|
3711
|
+
_this.entityType = exports.AssetEntityTypeEnum.TRANSACTIONS;
|
|
3712
|
+
return _this;
|
|
3522
3713
|
}
|
|
3523
|
-
return
|
|
3524
|
-
}(
|
|
3714
|
+
return TransactionReceipt;
|
|
3715
|
+
}(TransactionReceipt$1));
|
|
3525
3716
|
|
|
3526
3717
|
exports.IncomeSourceTypeEnum = void 0;
|
|
3527
3718
|
(function (IncomeSourceTypeEnum) {
|
|
@@ -3848,461 +4039,263 @@
|
|
|
3848
4039
|
classTransformer.Type(function () { return Transaction; })
|
|
3849
4040
|
], TransactionAllocation.prototype, "transaction", void 0);
|
|
3850
4041
|
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
return this.items.filter(function (message) { return !message.readAt; });
|
|
3866
|
-
};
|
|
3867
|
-
MessageCollection.prototype.getFromActiveChats = function () {
|
|
3868
|
-
return this.filter(function (message) { return message.chat.isActive(); });
|
|
3869
|
-
};
|
|
3870
|
-
/**
|
|
3871
|
-
* Get amount of chats that contains unread messages
|
|
3872
|
-
*/
|
|
3873
|
-
MessageCollection.prototype.getUnreadChatsAmount = function (isFromEmployee) {
|
|
3874
|
-
if (isFromEmployee === void 0) { isFromEmployee = false; }
|
|
3875
|
-
// filtered messages for client/employee
|
|
3876
|
-
var filteredMessages = this.filter(function (message) { return isFromEmployee ? message.isFromEmployee() : !message.isFromEmployee(); });
|
|
3877
|
-
return uniqBy__default["default"](filteredMessages.getFromActiveChats().getUnread(), 'chat.id').length;
|
|
3878
|
-
};
|
|
3879
|
-
/**
|
|
3880
|
-
* Check if chat has unread chats
|
|
3881
|
-
*/
|
|
3882
|
-
MessageCollection.prototype.hasUnread = function () {
|
|
3883
|
-
return !!this.getUnread().length;
|
|
3884
|
-
};
|
|
3885
|
-
return MessageCollection;
|
|
3886
|
-
}(Collection));
|
|
3887
|
-
|
|
3888
|
-
exports.ChatStatusEnum = void 0;
|
|
3889
|
-
(function (ChatStatusEnum) {
|
|
3890
|
-
ChatStatusEnum[ChatStatusEnum["ACTIVE"] = 1] = "ACTIVE";
|
|
3891
|
-
ChatStatusEnum[ChatStatusEnum["INACTIVE"] = 2] = "INACTIVE";
|
|
3892
|
-
})(exports.ChatStatusEnum || (exports.ChatStatusEnum = {}));
|
|
3893
|
-
|
|
3894
|
-
var ChatCollection = /** @class */ (function (_super) {
|
|
3895
|
-
__extends(ChatCollection, _super);
|
|
3896
|
-
function ChatCollection() {
|
|
3897
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4042
|
+
// @TODO Alex: refactor: move here allocations methods, netAmount = amount, grossAmount calculation, remove unused methods, etc.
|
|
4043
|
+
var Transaction = /** @class */ (function (_super) {
|
|
4044
|
+
__extends(Transaction, _super);
|
|
4045
|
+
function Transaction() {
|
|
4046
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
4047
|
+
// list of child transactions (fees)
|
|
4048
|
+
_this.transactions = [];
|
|
4049
|
+
_this.metadata = [];
|
|
4050
|
+
_this.allocations = [];
|
|
4051
|
+
_this.tax = 0;
|
|
4052
|
+
_this.operation = exports.TransactionOperationEnum.FIND_AND_MATCH;
|
|
4053
|
+
_this.claimPercent = 100;
|
|
4054
|
+
_this.amount = 0;
|
|
4055
|
+
return _this;
|
|
3898
4056
|
}
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
*/
|
|
3902
|
-
ChatCollection.prototype.getSortedByNewest = function (messages) {
|
|
3903
|
-
var chatsById = new Dictionary(this.toArray());
|
|
3904
|
-
// get chats array sorted from newest to oldest
|
|
3905
|
-
var chats = uniqBy__default["default"](new MessageCollection(messages)
|
|
3906
|
-
.filterBy('chat.id', this.getIds())
|
|
3907
|
-
.sortBy('createdAt', true)
|
|
3908
|
-
.toArray()
|
|
3909
|
-
.map(function (message) { return chatsById.get(message.chat.id); }), 'id');
|
|
3910
|
-
var emptyChats = differenceBy__default["default"](this.toArray(), chats, 'id');
|
|
3911
|
-
return this.create(__spreadArray(__spreadArray([], __read(chats)), __read(emptyChats)));
|
|
3912
|
-
};
|
|
3913
|
-
ChatCollection.prototype.getActive = function () {
|
|
3914
|
-
return this.filterBy('status', exports.ChatStatusEnum.ACTIVE);
|
|
4057
|
+
Transaction.prototype.isDebit = function () {
|
|
4058
|
+
return this.type === exports.TransactionTypeEnum.DEBIT;
|
|
3915
4059
|
};
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
/**
|
|
3920
|
-
* Collection of MessageDocument instances
|
|
3921
|
-
*/
|
|
3922
|
-
var MessageDocumentCollection = /** @class */ (function (_super) {
|
|
3923
|
-
__extends(MessageDocumentCollection, _super);
|
|
3924
|
-
function MessageDocumentCollection() {
|
|
3925
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3926
|
-
}
|
|
3927
|
-
/**
|
|
3928
|
-
* get list of documents which are not attached to any message
|
|
3929
|
-
*/
|
|
3930
|
-
MessageDocumentCollection.prototype.getUnattached = function () {
|
|
3931
|
-
return new MessageDocumentCollection(this.items.filter(function (doc) { return !doc.message; }));
|
|
4060
|
+
Transaction.prototype.isCredit = function () {
|
|
4061
|
+
return this.type === exports.TransactionTypeEnum.CREDIT;
|
|
3932
4062
|
};
|
|
3933
|
-
return MessageDocumentCollection;
|
|
3934
|
-
}(Collection));
|
|
3935
|
-
|
|
3936
|
-
var LoanCollection = /** @class */ (function (_super) {
|
|
3937
|
-
__extends(LoanCollection, _super);
|
|
3938
|
-
function LoanCollection() {
|
|
3939
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3940
|
-
}
|
|
3941
4063
|
/**
|
|
3942
|
-
*
|
|
3943
|
-
* @param ids list of bank accounts ids for filter
|
|
4064
|
+
* @TODO move to base collection
|
|
3944
4065
|
*/
|
|
3945
|
-
|
|
3946
|
-
|
|
4066
|
+
Transaction.prototype.isIncome = function () {
|
|
4067
|
+
// @TODO not used
|
|
4068
|
+
if (!this.chartAccounts) {
|
|
4069
|
+
return this.isCredit();
|
|
4070
|
+
}
|
|
4071
|
+
return CHART_ACCOUNTS_CATEGORIES.income.includes(this.chartAccounts.category);
|
|
3947
4072
|
};
|
|
3948
4073
|
/**
|
|
3949
|
-
*
|
|
3950
|
-
* @param id id of bank account
|
|
4074
|
+
* @TODO move to base collection
|
|
3951
4075
|
*/
|
|
3952
|
-
|
|
3953
|
-
|
|
4076
|
+
Transaction.prototype.isExpense = function () {
|
|
4077
|
+
// @TODO not used
|
|
4078
|
+
if (!this.chartAccounts) {
|
|
4079
|
+
return this.isDebit();
|
|
4080
|
+
}
|
|
4081
|
+
return CHART_ACCOUNTS_CATEGORIES.expense.includes(this.chartAccounts.category);
|
|
3954
4082
|
};
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
*/
|
|
3958
|
-
LoanCollection.prototype.groupCurrentYearPaymentsByLoans = function () {
|
|
3959
|
-
var dictionary = new CollectionDictionary(new LoanPaymentCollection([]));
|
|
3960
|
-
this.items.forEach(function (loan) { return dictionary.add(loan.id, new LoanPaymentCollection(loan.payments).getForCurrentYear()); });
|
|
3961
|
-
return dictionary;
|
|
4083
|
+
Transaction.prototype.isPersonal = function () {
|
|
4084
|
+
return CHART_ACCOUNTS_CATEGORIES.personal.includes(this.chartAccounts.category);
|
|
3962
4085
|
};
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
*/
|
|
3966
|
-
LoanCollection.prototype.getVehicleLoans = function () {
|
|
3967
|
-
return this.filter(function (loan) { return loan.isVehicle(); });
|
|
4086
|
+
Transaction.prototype.isInterest = function () {
|
|
4087
|
+
return this.chartAccounts.id === exports.ChartAccountsListEnum.INTEREST_ON_LOAN;
|
|
3968
4088
|
};
|
|
3969
|
-
|
|
3970
|
-
}(Collection));
|
|
3971
|
-
|
|
3972
|
-
var PropertySaleCollection = /** @class */ (function (_super) {
|
|
3973
|
-
__extends(PropertySaleCollection, _super);
|
|
3974
|
-
function PropertySaleCollection() {
|
|
3975
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3976
|
-
}
|
|
3977
|
-
Object.defineProperty(PropertySaleCollection.prototype, "grossCGTAfterLoss", {
|
|
4089
|
+
Object.defineProperty(Transaction.prototype, "chartAccountsCategories", {
|
|
3978
4090
|
get: function () {
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
};
|
|
3993
|
-
return PropertySaleCollection;
|
|
3994
|
-
}(Collection));
|
|
3995
|
-
|
|
3996
|
-
exports.TaxExemptionMetadataEnum = void 0;
|
|
3997
|
-
(function (TaxExemptionMetadataEnum) {
|
|
3998
|
-
// principle place of residence
|
|
3999
|
-
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["PPR_DAYS"] = 1] = "PPR_DAYS";
|
|
4000
|
-
// market value once it was moved, decimal
|
|
4001
|
-
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["MARKET_VALUE"] = 2] = "MARKET_VALUE";
|
|
4002
|
-
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["CLAIM_PERCENT"] = 3] = "CLAIM_PERCENT";
|
|
4003
|
-
})(exports.TaxExemptionMetadataEnum || (exports.TaxExemptionMetadataEnum = {}));
|
|
4004
|
-
|
|
4005
|
-
var PropertySaleTaxExemptionMetadataCollection = /** @class */ (function (_super) {
|
|
4006
|
-
__extends(PropertySaleTaxExemptionMetadataCollection, _super);
|
|
4007
|
-
function PropertySaleTaxExemptionMetadataCollection() {
|
|
4008
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4009
|
-
}
|
|
4010
|
-
PropertySaleTaxExemptionMetadataCollection.prototype.getPPRDays = function () {
|
|
4011
|
-
var _a, _b;
|
|
4012
|
-
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.PPR_DAYS)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
4013
|
-
};
|
|
4014
|
-
PropertySaleTaxExemptionMetadataCollection.prototype.getMarketValue = function () {
|
|
4015
|
-
var _a, _b;
|
|
4016
|
-
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.MARKET_VALUE)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
4017
|
-
};
|
|
4018
|
-
PropertySaleTaxExemptionMetadataCollection.prototype.getClaimPercent = function () {
|
|
4019
|
-
var _a, _b;
|
|
4020
|
-
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.CLAIM_PERCENT)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 100;
|
|
4021
|
-
};
|
|
4022
|
-
PropertySaleTaxExemptionMetadataCollection.prototype.getByMetadataId = function (id) {
|
|
4023
|
-
return this.items.find(function (metadata) { return metadata.metadata.id === id; });
|
|
4024
|
-
};
|
|
4025
|
-
return PropertySaleTaxExemptionMetadataCollection;
|
|
4026
|
-
}(Collection));
|
|
4027
|
-
|
|
4028
|
-
var PropertyCollection = /** @class */ (function (_super) {
|
|
4029
|
-
__extends(PropertyCollection, _super);
|
|
4030
|
-
function PropertyCollection() {
|
|
4031
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4032
|
-
}
|
|
4033
|
-
/**
|
|
4034
|
-
* Get new property collection filtered by category id
|
|
4035
|
-
* @param id id of category for filter
|
|
4036
|
-
*/
|
|
4037
|
-
PropertyCollection.prototype.getByCategoryId = function (id) {
|
|
4038
|
-
return new PropertyCollection(this.items.filter(function (property) { return property.category.id === id; }));
|
|
4039
|
-
};
|
|
4040
|
-
/**
|
|
4041
|
-
* Get new property collection filtered by active status
|
|
4042
|
-
*/
|
|
4043
|
-
PropertyCollection.prototype.getActiveProperties = function () {
|
|
4044
|
-
return new PropertyCollection(this.items.filter(function (property) { return property.isActive; }));
|
|
4045
|
-
};
|
|
4046
|
-
PropertyCollection.prototype.getCreatedProperties = function () {
|
|
4047
|
-
return new PropertyCollection(this.items.filter(function (property) { return property.isOwn(); }));
|
|
4048
|
-
};
|
|
4091
|
+
switch (true) {
|
|
4092
|
+
case this.isPersonal():
|
|
4093
|
+
return CHART_ACCOUNTS_CATEGORIES.personal;
|
|
4094
|
+
case this.isPropertyTank():
|
|
4095
|
+
return CHART_ACCOUNTS_CATEGORIES.property;
|
|
4096
|
+
case this.isSoleTank():
|
|
4097
|
+
return CHART_ACCOUNTS_CATEGORIES.sole;
|
|
4098
|
+
default:
|
|
4099
|
+
return CHART_ACCOUNTS_CATEGORIES.work;
|
|
4100
|
+
}
|
|
4101
|
+
},
|
|
4102
|
+
enumerable: false,
|
|
4103
|
+
configurable: true
|
|
4104
|
+
});
|
|
4049
4105
|
/**
|
|
4050
|
-
* Get
|
|
4106
|
+
* Get transaction date
|
|
4051
4107
|
*/
|
|
4052
|
-
|
|
4053
|
-
return
|
|
4108
|
+
Transaction.prototype.getDate = function () {
|
|
4109
|
+
return this.date;
|
|
4054
4110
|
};
|
|
4055
4111
|
/**
|
|
4056
|
-
*
|
|
4112
|
+
* Check if transaction type is vehicle
|
|
4057
4113
|
*/
|
|
4058
|
-
|
|
4059
|
-
return this.
|
|
4060
|
-
};
|
|
4061
|
-
PropertyCollection.prototype.getUnsold = function () {
|
|
4062
|
-
return this.create(this.items.filter(function (property) { return !property.isSold(); }));
|
|
4114
|
+
Transaction.prototype.isVehicleTransaction = function () {
|
|
4115
|
+
return this.chartAccounts.isVehicleExpense();
|
|
4063
4116
|
};
|
|
4064
|
-
Object.defineProperty(
|
|
4065
|
-
/**
|
|
4066
|
-
* Get total purchase price for all properties in the collection
|
|
4067
|
-
*/
|
|
4117
|
+
Object.defineProperty(Transaction.prototype, "taxFreeComponent", {
|
|
4068
4118
|
get: function () {
|
|
4069
|
-
return this.
|
|
4119
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.TAX_FREE_COMPONENT);
|
|
4070
4120
|
},
|
|
4071
4121
|
enumerable: false,
|
|
4072
4122
|
configurable: true
|
|
4073
4123
|
});
|
|
4074
|
-
Object.defineProperty(
|
|
4124
|
+
Object.defineProperty(Transaction.prototype, "frankingCredit", {
|
|
4075
4125
|
get: function () {
|
|
4076
|
-
return this.
|
|
4126
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.FRANKING_CREDIT);
|
|
4077
4127
|
},
|
|
4078
4128
|
enumerable: false,
|
|
4079
4129
|
configurable: true
|
|
4080
4130
|
});
|
|
4081
|
-
Object.defineProperty(
|
|
4131
|
+
Object.defineProperty(Transaction.prototype, "eligibleForReduction", {
|
|
4082
4132
|
get: function () {
|
|
4083
|
-
return this.
|
|
4133
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.ELIGIBLE_FOR_REDUCTION);
|
|
4084
4134
|
},
|
|
4085
4135
|
enumerable: false,
|
|
4086
4136
|
configurable: true
|
|
4087
4137
|
});
|
|
4088
|
-
Object.defineProperty(
|
|
4138
|
+
Object.defineProperty(Transaction.prototype, "untaxedElement", {
|
|
4089
4139
|
get: function () {
|
|
4090
|
-
return this.
|
|
4091
|
-
var current = property.firstForecastYear;
|
|
4092
|
-
return min > current ? current : min;
|
|
4093
|
-
}, new FinancialYear().year);
|
|
4140
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.UNTAXED_ELEMENT);
|
|
4094
4141
|
},
|
|
4095
4142
|
enumerable: false,
|
|
4096
4143
|
configurable: true
|
|
4097
4144
|
});
|
|
4098
|
-
Object.defineProperty(
|
|
4145
|
+
Object.defineProperty(Transaction.prototype, "isTransfer", {
|
|
4146
|
+
/**
|
|
4147
|
+
* Check if transaction reconcile operation if TRANSFER
|
|
4148
|
+
* @TODO bad usage of get (and all is* methods), getter should sound like a noun
|
|
4149
|
+
*/
|
|
4099
4150
|
get: function () {
|
|
4100
|
-
return
|
|
4151
|
+
return this.operation === exports.TransactionOperationEnum.TRANSFER;
|
|
4101
4152
|
},
|
|
4102
4153
|
enumerable: false,
|
|
4103
4154
|
configurable: true
|
|
4104
4155
|
});
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
*/
|
|
4108
|
-
PropertyCollection.prototype.getCGTApplicable = function () {
|
|
4109
|
-
return this.create(this.items.filter(function (property) { return property.isCGTApplicable(); }));
|
|
4156
|
+
Transaction.prototype.isFindAndMatch = function () {
|
|
4157
|
+
return this.operation === exports.TransactionOperationEnum.FIND_AND_MATCH;
|
|
4110
4158
|
};
|
|
4111
|
-
|
|
4112
|
-
return
|
|
4159
|
+
Transaction.prototype.isMatchInvoice = function () {
|
|
4160
|
+
return this.operation === exports.TransactionOperationEnum.MATCH_INVOICE;
|
|
4113
4161
|
};
|
|
4114
|
-
Object.defineProperty(
|
|
4162
|
+
Object.defineProperty(Transaction.prototype, "debit", {
|
|
4115
4163
|
get: function () {
|
|
4116
|
-
return this.
|
|
4117
|
-
|
|
4118
|
-
|
|
4164
|
+
return this.isDebit() ? Math.abs(this.grossAmount) : 0;
|
|
4165
|
+
},
|
|
4166
|
+
enumerable: false,
|
|
4167
|
+
configurable: true
|
|
4168
|
+
});
|
|
4169
|
+
Object.defineProperty(Transaction.prototype, "credit", {
|
|
4170
|
+
get: function () {
|
|
4171
|
+
return this.isCredit() ? Math.abs(this.grossAmount) : 0;
|
|
4119
4172
|
},
|
|
4120
4173
|
enumerable: false,
|
|
4121
4174
|
configurable: true
|
|
4122
4175
|
});
|
|
4123
4176
|
/**
|
|
4124
|
-
* Get
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
return uniqBy__default["default"](this.items.map(function (property) { return property.category; }), 'id');
|
|
4128
|
-
};
|
|
4129
|
-
/**
|
|
4130
|
-
* Get property with the highest growth percent
|
|
4131
|
-
*/
|
|
4132
|
-
PropertyCollection.prototype.getBestPerformanceGrowthProperty = function () {
|
|
4133
|
-
return this.items.reduce(function (max, current) {
|
|
4134
|
-
return max.growthPercent < current.growthPercent ? current : max;
|
|
4135
|
-
}, this.first);
|
|
4136
|
-
};
|
|
4137
|
-
/**
|
|
4138
|
-
* Get property with the lowest tax position
|
|
4177
|
+
* Get value of transaction metadata field
|
|
4178
|
+
* @param field for which value should be returned
|
|
4179
|
+
* @Todo modify 'metadata' property from array to Collection
|
|
4139
4180
|
*/
|
|
4140
|
-
|
|
4141
|
-
var
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
var currentTaxPosition = current.getTaxPosition(transactionsByProperty.get(current.id), depreciationsByProperty.get(current.id));
|
|
4146
|
-
return minTaxPosition > currentTaxPosition ? current : min;
|
|
4147
|
-
}, this.first);
|
|
4181
|
+
Transaction.prototype.getMetadataFieldValue = function (field) {
|
|
4182
|
+
var _a;
|
|
4183
|
+
return +((_a = this.metadata.find(function (transactionMetadata) {
|
|
4184
|
+
return transactionMetadata.chartAccountsMetadata.id === field;
|
|
4185
|
+
})) === null || _a === void 0 ? void 0 : _a.value) || 0;
|
|
4148
4186
|
};
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/217677997/Property+Tank+Dashboard
|
|
4152
|
-
*/
|
|
4153
|
-
PropertyCollection.prototype.sortByBestPerformance = function (transactions, depreciations) {
|
|
4154
|
-
var activeProperties = this.getActiveProperties();
|
|
4155
|
-
// nothing to sort when no active properties
|
|
4156
|
-
if (!activeProperties.length) {
|
|
4157
|
-
return this;
|
|
4158
|
-
}
|
|
4159
|
-
var bestProperties = uniqBy__default["default"](this.create([
|
|
4160
|
-
activeProperties.getBestPerformanceGrowthProperty(),
|
|
4161
|
-
activeProperties.getBestPerformanceTaxProperty(transactions, depreciations)
|
|
4162
|
-
]).toArray(), 'id');
|
|
4163
|
-
var newItems = this.remove(bestProperties).toArray();
|
|
4164
|
-
newItems.unshift.apply(newItems, __spreadArray([], __read(bestProperties)));
|
|
4165
|
-
return this.create(newItems);
|
|
4187
|
+
Transaction.prototype.isCash = function () {
|
|
4188
|
+
return this.source === exports.TransactionSourceEnum.CASH;
|
|
4166
4189
|
};
|
|
4167
|
-
return PropertyCollection;
|
|
4168
|
-
}(Collection));
|
|
4169
|
-
|
|
4170
|
-
var PropertyCategoryMovementCollection = /** @class */ (function (_super) {
|
|
4171
|
-
__extends(PropertyCategoryMovementCollection, _super);
|
|
4172
|
-
function PropertyCategoryMovementCollection() {
|
|
4173
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4174
|
-
}
|
|
4175
4190
|
/**
|
|
4176
|
-
*
|
|
4191
|
+
* Create Depreciation instance based on Transaction
|
|
4177
4192
|
*/
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4193
|
+
Transaction.prototype.toDepreciation = function () {
|
|
4194
|
+
return classTransformer.plainToClass(Depreciation, {
|
|
4195
|
+
date: this.date,
|
|
4196
|
+
amount: this.amount,
|
|
4197
|
+
chartAccounts: this.chartAccounts,
|
|
4198
|
+
description: this.description,
|
|
4199
|
+
type: exports.DepreciationTypeEnum.PLANT_EQUIPMENT,
|
|
4200
|
+
claimPercent: this.claimPercent,
|
|
4201
|
+
property: this.property,
|
|
4202
|
+
calculation: this.property ? this.property.depreciationCalculation : exports.DepreciationCalculationEnum.PRIME_COST
|
|
4182
4203
|
});
|
|
4183
4204
|
};
|
|
4184
|
-
PropertyCategoryMovementCollection.prototype.hasCategory = function (categoryId) {
|
|
4185
|
-
return !!this.findBy('propertyCategory.id', categoryId);
|
|
4186
|
-
};
|
|
4187
|
-
return PropertyCategoryMovementCollection;
|
|
4188
|
-
}(Collection));
|
|
4189
|
-
|
|
4190
|
-
var PropertyShareCollection = /** @class */ (function (_super) {
|
|
4191
|
-
__extends(PropertyShareCollection, _super);
|
|
4192
|
-
function PropertyShareCollection() {
|
|
4193
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4194
|
-
}
|
|
4195
4205
|
/**
|
|
4196
|
-
*
|
|
4197
|
-
* (initiated not by current user)
|
|
4198
|
-
* @TODO Alex: rename
|
|
4206
|
+
* Check if transaction is completely allocated
|
|
4199
4207
|
*/
|
|
4200
|
-
|
|
4201
|
-
return this.
|
|
4202
|
-
var _a;
|
|
4203
|
-
return ((_a = propertyShare.user) === null || _a === void 0 ? void 0 : _a.isLoggedIn()) && propertyShare.isPending() && propertyShare.property.user.id !== +localStorage.getItem('userId');
|
|
4204
|
-
});
|
|
4208
|
+
Transaction.prototype.isAllocated = function (allocations) {
|
|
4209
|
+
return this.netAmount === this.getAllocatedAmount(allocations);
|
|
4205
4210
|
};
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
* (initiated by current user)
|
|
4209
|
-
* @TODO Alex: rename
|
|
4210
|
-
*/
|
|
4211
|
-
PropertyShareCollection.prototype.getOutcoming = function () {
|
|
4212
|
-
return this.filter(function (propertyShare) { var _a; return !((_a = propertyShare.user) === null || _a === void 0 ? void 0 : _a.isLoggedIn()); });
|
|
4211
|
+
Transaction.prototype.getAllocatedAmount = function (allocations) {
|
|
4212
|
+
return allocations.filterBy('transaction.id', this.id).sumBy('amount');
|
|
4213
4213
|
};
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
exports.DepreciationLvpAssetTypeEnum = void 0;
|
|
4221
|
-
(function (DepreciationLvpAssetTypeEnum) {
|
|
4222
|
-
DepreciationLvpAssetTypeEnum["PRIOR_YEARS"] = "A";
|
|
4223
|
-
DepreciationLvpAssetTypeEnum["FIRST_YEAR"] = "L";
|
|
4224
|
-
DepreciationLvpAssetTypeEnum["WRITTEN_OFF"] = "W";
|
|
4225
|
-
})(exports.DepreciationLvpAssetTypeEnum || (exports.DepreciationLvpAssetTypeEnum = {}));
|
|
4226
|
-
|
|
4227
|
-
var DepreciationCapitalProject = /** @class */ (function (_super) {
|
|
4228
|
-
__extends(DepreciationCapitalProject, _super);
|
|
4229
|
-
function DepreciationCapitalProject() {
|
|
4230
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4231
|
-
}
|
|
4232
|
-
return DepreciationCapitalProject;
|
|
4233
|
-
}(DepreciationCapitalProject$1));
|
|
4234
|
-
__decorate([
|
|
4235
|
-
classTransformer.Type(function () { return Date; })
|
|
4236
|
-
], DepreciationCapitalProject.prototype, "effectiveDate", void 0);
|
|
4237
|
-
|
|
4238
|
-
var DepreciationForecast = /** @class */ (function (_super) {
|
|
4239
|
-
__extends(DepreciationForecast, _super);
|
|
4240
|
-
function DepreciationForecast() {
|
|
4241
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4242
|
-
}
|
|
4243
|
-
Object.defineProperty(DepreciationForecast.prototype, "dailyClaimAmount", {
|
|
4244
|
-
get: function () {
|
|
4245
|
-
return this.claimAmount / this.daysApplied;
|
|
4246
|
-
},
|
|
4247
|
-
enumerable: false,
|
|
4248
|
-
configurable: true
|
|
4249
|
-
});
|
|
4250
|
-
Object.defineProperty(DepreciationForecast.prototype, "daysApplied", {
|
|
4251
|
-
get: function () {
|
|
4252
|
-
return moment__namespace(this.toDate).diff(moment__namespace(this.fromDate), 'days');
|
|
4253
|
-
},
|
|
4254
|
-
enumerable: false,
|
|
4255
|
-
configurable: true
|
|
4256
|
-
});
|
|
4257
|
-
DepreciationForecast.prototype.getDaysByMonth = function (month) {
|
|
4258
|
-
// @TODO find a better place
|
|
4259
|
-
var year = this.financialYear - (month > 5 ? 1 : 0);
|
|
4260
|
-
// forecast date intersect by month
|
|
4261
|
-
var range = new momentRange.DateRange(this.fromDate, this.toDate).intersect(new momentRange.DateRange(new Date(year, month, 1), new Date(year, month + 1, 0)));
|
|
4262
|
-
return range ? range.duration('days') + 1 : 0;
|
|
4214
|
+
Transaction.prototype.getAllocatedClaimAmount = function (allocations) {
|
|
4215
|
+
var coef = 1;
|
|
4216
|
+
if (this.isSoleTank() && this.isIncome() && this.isGST) {
|
|
4217
|
+
coef = ChartAccounts.GSTCoefficient;
|
|
4218
|
+
}
|
|
4219
|
+
return this.getAllocatedAmount(allocations) * this.claimRatio / coef;
|
|
4263
4220
|
};
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
Object.defineProperty(DepreciationForecast.prototype, "claimCloseBalance", {
|
|
4272
|
-
get: function () {
|
|
4273
|
-
return this.closeBalance * this.claimRate;
|
|
4274
|
-
},
|
|
4275
|
-
enumerable: false,
|
|
4276
|
-
configurable: true
|
|
4277
|
-
});
|
|
4278
|
-
Object.defineProperty(DepreciationForecast.prototype, "claimAmount", {
|
|
4221
|
+
Transaction.prototype.getUnallocatedAmount = function (allocations) {
|
|
4222
|
+
return this.netAmount - this.getAllocatedAmount(allocations);
|
|
4223
|
+
};
|
|
4224
|
+
Object.defineProperty(Transaction.prototype, "grossAmount", {
|
|
4225
|
+
/**
|
|
4226
|
+
* Total transaction amount including taxes and other additional amounts
|
|
4227
|
+
*/
|
|
4279
4228
|
get: function () {
|
|
4280
|
-
|
|
4229
|
+
var grossAmount = _super.prototype.grossAmount + this.tax;
|
|
4230
|
+
if (this.isExpense()) {
|
|
4231
|
+
return grossAmount;
|
|
4232
|
+
}
|
|
4233
|
+
// salary included transactions affect parent transaction amount and as a result grossAmount, skip to avoid double sum
|
|
4234
|
+
grossAmount += new Collection(this.transactions)
|
|
4235
|
+
.filter(function (t) { var _a; return !((_a = t.chartAccounts) === null || _a === void 0 ? void 0 : _a.isSalaryIncluded()); })
|
|
4236
|
+
.sumBy('amount', true);
|
|
4237
|
+
if (this.isWorkTank()) {
|
|
4238
|
+
grossAmount += this.frankingCredit - this.taxFreeComponent - this.eligibleForReduction;
|
|
4239
|
+
}
|
|
4240
|
+
return +(Math.round(grossAmount * 100) / 100).toFixed(2);
|
|
4281
4241
|
},
|
|
4282
4242
|
enumerable: false,
|
|
4283
4243
|
configurable: true
|
|
4284
4244
|
});
|
|
4285
|
-
Object.defineProperty(
|
|
4245
|
+
Object.defineProperty(Transaction.prototype, "netAmount", {
|
|
4246
|
+
/**
|
|
4247
|
+
* @TODO vik confusing logic demanded by Nicole, we need a better ux to fix it
|
|
4248
|
+
* netAmount matches received payment (bankTransaction amount), includes gst and salary included adjustments
|
|
4249
|
+
* ie user received 1000$ salary including 100$ tips. NetAmount=1000$, amount=900$, tips=100$
|
|
4250
|
+
*/
|
|
4286
4251
|
get: function () {
|
|
4287
|
-
return this.
|
|
4252
|
+
return new Collection(this.transactions)
|
|
4253
|
+
.filter(function (t) { var _a; return (_a = t.chartAccounts) === null || _a === void 0 ? void 0 : _a.isSalaryIncluded(); })
|
|
4254
|
+
.sumBy('amount') + this.amountWithGst;
|
|
4288
4255
|
},
|
|
4289
4256
|
enumerable: false,
|
|
4290
4257
|
configurable: true
|
|
4291
4258
|
});
|
|
4292
|
-
|
|
4293
|
-
|
|
4259
|
+
/**
|
|
4260
|
+
* most of the transactions could have only positive or negative amount depends on chartAccounts, so we ignore
|
|
4261
|
+
* user's choice and transform amount, but there are exceptions like advance (negative or positive amount)
|
|
4262
|
+
*/
|
|
4263
|
+
Transaction.prototype.ignoreSign = function () {
|
|
4264
|
+
var _a;
|
|
4265
|
+
return !(((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.id) in exports.ChartAccountsKeepSign);
|
|
4294
4266
|
};
|
|
4295
|
-
return
|
|
4296
|
-
}(
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4267
|
+
return Transaction;
|
|
4268
|
+
}(Transaction$1));
|
|
4269
|
+
__decorate([
|
|
4270
|
+
classTransformer.Type(function () { return Transaction; })
|
|
4271
|
+
], Transaction.prototype, "transactions", void 0);
|
|
4272
|
+
__decorate([
|
|
4273
|
+
classTransformer.Type(function () { return Property; })
|
|
4274
|
+
], Transaction.prototype, "property", void 0);
|
|
4275
|
+
__decorate([
|
|
4276
|
+
classTransformer.Type(function () { return TransactionReceipt; })
|
|
4277
|
+
], Transaction.prototype, "receipt", void 0);
|
|
4278
|
+
__decorate([
|
|
4279
|
+
classTransformer.Type(function () { return ChartAccounts; })
|
|
4280
|
+
], Transaction.prototype, "chartAccounts", void 0);
|
|
4281
|
+
__decorate([
|
|
4282
|
+
classTransformer.Type(function () { return IncomeSource; })
|
|
4283
|
+
], Transaction.prototype, "incomeSource", void 0);
|
|
4284
|
+
__decorate([
|
|
4285
|
+
classTransformer.Type(function () { return TransactionMetadata; })
|
|
4286
|
+
], Transaction.prototype, "metadata", void 0);
|
|
4287
|
+
__decorate([
|
|
4288
|
+
classTransformer.Type(function () { return Transaction; })
|
|
4289
|
+
], Transaction.prototype, "transfer", void 0);
|
|
4290
|
+
__decorate([
|
|
4291
|
+
classTransformer.Type(function () { return Loan; })
|
|
4292
|
+
], Transaction.prototype, "loan", void 0);
|
|
4293
|
+
__decorate([
|
|
4294
|
+
classTransformer.Type(function () { return Date; })
|
|
4295
|
+
], Transaction.prototype, "date", void 0);
|
|
4296
|
+
__decorate([
|
|
4297
|
+
classTransformer.Type(function () { return TransactionAllocation; })
|
|
4298
|
+
], Transaction.prototype, "allocations", void 0);
|
|
4306
4299
|
|
|
4307
4300
|
exports.TransactionCategoryEnum = void 0;
|
|
4308
4301
|
(function (TransactionCategoryEnum) {
|
|
@@ -5388,6 +5381,18 @@
|
|
|
5388
5381
|
return SoleInvoiceCollection;
|
|
5389
5382
|
}(Collection));
|
|
5390
5383
|
|
|
5384
|
+
exports.ServicePriceTypeEnum = void 0;
|
|
5385
|
+
(function (ServicePriceTypeEnum) {
|
|
5386
|
+
ServicePriceTypeEnum[ServicePriceTypeEnum["DEPRECATED"] = 0] = "DEPRECATED";
|
|
5387
|
+
ServicePriceTypeEnum[ServicePriceTypeEnum["MONTHLY"] = 1] = "MONTHLY";
|
|
5388
|
+
ServicePriceTypeEnum[ServicePriceTypeEnum["MONTHLY_PACKAGE"] = 2] = "MONTHLY_PACKAGE";
|
|
5389
|
+
ServicePriceTypeEnum[ServicePriceTypeEnum["YEARLY"] = 3] = "YEARLY";
|
|
5390
|
+
ServicePriceTypeEnum[ServicePriceTypeEnum["YEARLY_PACKAGE"] = 4] = "YEARLY_PACKAGE";
|
|
5391
|
+
})(exports.ServicePriceTypeEnum || (exports.ServicePriceTypeEnum = {}));
|
|
5392
|
+
|
|
5393
|
+
/**
|
|
5394
|
+
* @TODO vik refactor
|
|
5395
|
+
*/
|
|
5391
5396
|
var ServicePriceCollection = /** @class */ (function (_super) {
|
|
5392
5397
|
__extends(ServicePriceCollection, _super);
|
|
5393
5398
|
function ServicePriceCollection() {
|
|
@@ -5396,6 +5401,62 @@
|
|
|
5396
5401
|
ServicePriceCollection.prototype.getActive = function () {
|
|
5397
5402
|
return this.filterBy('isActive', true);
|
|
5398
5403
|
};
|
|
5404
|
+
Object.defineProperty(ServicePriceCollection.prototype, "monthly", {
|
|
5405
|
+
get: function () {
|
|
5406
|
+
return this.filterBy('type', exports.ServicePriceTypeEnum.MONTHLY);
|
|
5407
|
+
},
|
|
5408
|
+
enumerable: false,
|
|
5409
|
+
configurable: true
|
|
5410
|
+
});
|
|
5411
|
+
Object.defineProperty(ServicePriceCollection.prototype, "monthlyPackage", {
|
|
5412
|
+
get: function () {
|
|
5413
|
+
return this.filterBy('type', exports.ServicePriceTypeEnum.MONTHLY_PACKAGE);
|
|
5414
|
+
},
|
|
5415
|
+
enumerable: false,
|
|
5416
|
+
configurable: true
|
|
5417
|
+
});
|
|
5418
|
+
Object.defineProperty(ServicePriceCollection.prototype, "monthlyPackageSum", {
|
|
5419
|
+
get: function () {
|
|
5420
|
+
var property = this.monthlyPackage.findBy('product.id', exports.ServiceProductIdEnum.PROPERTIES);
|
|
5421
|
+
// @TODO move to const
|
|
5422
|
+
return this.monthlyPackage.sumBy('amount') + property.amount * 4;
|
|
5423
|
+
},
|
|
5424
|
+
enumerable: false,
|
|
5425
|
+
configurable: true
|
|
5426
|
+
});
|
|
5427
|
+
Object.defineProperty(ServicePriceCollection.prototype, "annual", {
|
|
5428
|
+
get: function () {
|
|
5429
|
+
return this.filterBy('type', exports.ServicePriceTypeEnum.YEARLY);
|
|
5430
|
+
},
|
|
5431
|
+
enumerable: false,
|
|
5432
|
+
configurable: true
|
|
5433
|
+
});
|
|
5434
|
+
Object.defineProperty(ServicePriceCollection.prototype, "annualPackage", {
|
|
5435
|
+
get: function () {
|
|
5436
|
+
return this.filterBy('type', exports.ServicePriceTypeEnum.YEARLY_PACKAGE);
|
|
5437
|
+
},
|
|
5438
|
+
enumerable: false,
|
|
5439
|
+
configurable: true
|
|
5440
|
+
});
|
|
5441
|
+
Object.defineProperty(ServicePriceCollection.prototype, "annualPackageSum", {
|
|
5442
|
+
get: function () {
|
|
5443
|
+
var property = this.annualPackage.findBy('product.id', exports.ServiceProductIdEnum.PROPERTIES);
|
|
5444
|
+
// @TODO move to const
|
|
5445
|
+
return this.annualPackage.sumBy('amount') + property.amount * 4;
|
|
5446
|
+
},
|
|
5447
|
+
enumerable: false,
|
|
5448
|
+
configurable: true
|
|
5449
|
+
});
|
|
5450
|
+
ServicePriceCollection.prototype.getProperty = function (isAnnual, isPackage) {
|
|
5451
|
+
var type;
|
|
5452
|
+
if (isAnnual) {
|
|
5453
|
+
type = isPackage ? exports.ServicePriceTypeEnum.YEARLY_PACKAGE : exports.ServicePriceTypeEnum.YEARLY;
|
|
5454
|
+
}
|
|
5455
|
+
else {
|
|
5456
|
+
type = isPackage ? exports.ServicePriceTypeEnum.MONTHLY_PACKAGE : exports.ServicePriceTypeEnum.MONTHLY;
|
|
5457
|
+
}
|
|
5458
|
+
return this.filterBy('type', type).findBy('product.id', exports.ServiceProductIdEnum.PROPERTIES);
|
|
5459
|
+
};
|
|
5399
5460
|
return ServicePriceCollection;
|
|
5400
5461
|
}(Collection));
|
|
5401
5462
|
|
|
@@ -6568,263 +6629,277 @@
|
|
|
6568
6629
|
|
|
6569
6630
|
// @TODO Alex move here all collections
|
|
6570
6631
|
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
function Transaction() {
|
|
6632
|
+
var ServiceSubscription = /** @class */ (function (_super) {
|
|
6633
|
+
__extends(ServiceSubscription, _super);
|
|
6634
|
+
function ServiceSubscription() {
|
|
6575
6635
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
6576
|
-
//
|
|
6577
|
-
_this.
|
|
6578
|
-
_this.metadata = [];
|
|
6579
|
-
_this.allocations = [];
|
|
6580
|
-
_this.tax = 0;
|
|
6581
|
-
_this.operation = exports.TransactionOperationEnum.FIND_AND_MATCH;
|
|
6582
|
-
_this.claimPercent = 100;
|
|
6583
|
-
_this.amount = 0;
|
|
6636
|
+
// Number of days after which the trial time will be expired
|
|
6637
|
+
_this.lastTrialDays = 4;
|
|
6584
6638
|
return _this;
|
|
6585
6639
|
}
|
|
6586
|
-
|
|
6587
|
-
return this.type === exports.TransactionTypeEnum.DEBIT;
|
|
6588
|
-
};
|
|
6589
|
-
Transaction.prototype.isCredit = function () {
|
|
6590
|
-
return this.type === exports.TransactionTypeEnum.CREDIT;
|
|
6591
|
-
};
|
|
6592
|
-
/**
|
|
6593
|
-
* @TODO move to base collection
|
|
6594
|
-
*/
|
|
6595
|
-
Transaction.prototype.isIncome = function () {
|
|
6596
|
-
// @TODO not used
|
|
6597
|
-
if (!this.chartAccounts) {
|
|
6598
|
-
return this.isCredit();
|
|
6599
|
-
}
|
|
6600
|
-
return CHART_ACCOUNTS_CATEGORIES.income.includes(this.chartAccounts.category);
|
|
6601
|
-
};
|
|
6602
|
-
/**
|
|
6603
|
-
* @TODO move to base collection
|
|
6604
|
-
*/
|
|
6605
|
-
Transaction.prototype.isExpense = function () {
|
|
6606
|
-
// @TODO not used
|
|
6607
|
-
if (!this.chartAccounts) {
|
|
6608
|
-
return this.isDebit();
|
|
6609
|
-
}
|
|
6610
|
-
return CHART_ACCOUNTS_CATEGORIES.expense.includes(this.chartAccounts.category);
|
|
6611
|
-
};
|
|
6612
|
-
Transaction.prototype.isPersonal = function () {
|
|
6613
|
-
return CHART_ACCOUNTS_CATEGORIES.personal.includes(this.chartAccounts.category);
|
|
6614
|
-
};
|
|
6615
|
-
Transaction.prototype.isInterest = function () {
|
|
6616
|
-
return this.chartAccounts.id === exports.ChartAccountsListEnum.INTEREST_ON_LOAN;
|
|
6617
|
-
};
|
|
6618
|
-
Object.defineProperty(Transaction.prototype, "chartAccountsCategories", {
|
|
6640
|
+
Object.defineProperty(ServiceSubscription.prototype, "isTrial", {
|
|
6619
6641
|
get: function () {
|
|
6620
|
-
|
|
6621
|
-
case this.isPersonal():
|
|
6622
|
-
return CHART_ACCOUNTS_CATEGORIES.personal;
|
|
6623
|
-
case this.isPropertyTank():
|
|
6624
|
-
return CHART_ACCOUNTS_CATEGORIES.property;
|
|
6625
|
-
case this.isSoleTank():
|
|
6626
|
-
return CHART_ACCOUNTS_CATEGORIES.sole;
|
|
6627
|
-
default:
|
|
6628
|
-
return CHART_ACCOUNTS_CATEGORIES.work;
|
|
6629
|
-
}
|
|
6642
|
+
return !this.stripeId;
|
|
6630
6643
|
},
|
|
6631
6644
|
enumerable: false,
|
|
6632
6645
|
configurable: true
|
|
6633
6646
|
});
|
|
6634
|
-
|
|
6635
|
-
* Get transaction date
|
|
6636
|
-
*/
|
|
6637
|
-
Transaction.prototype.getDate = function () {
|
|
6638
|
-
return this.date;
|
|
6639
|
-
};
|
|
6640
|
-
/**
|
|
6641
|
-
* Check if transaction type is vehicle
|
|
6642
|
-
*/
|
|
6643
|
-
Transaction.prototype.isVehicleTransaction = function () {
|
|
6644
|
-
return this.chartAccounts.isVehicleExpense();
|
|
6645
|
-
};
|
|
6646
|
-
Object.defineProperty(Transaction.prototype, "taxFreeComponent", {
|
|
6647
|
+
Object.defineProperty(ServiceSubscription.prototype, "isPaid", {
|
|
6647
6648
|
get: function () {
|
|
6648
|
-
return this.
|
|
6649
|
+
return !!this.stripeId;
|
|
6649
6650
|
},
|
|
6650
6651
|
enumerable: false,
|
|
6651
6652
|
configurable: true
|
|
6652
6653
|
});
|
|
6653
|
-
Object.defineProperty(
|
|
6654
|
+
Object.defineProperty(ServiceSubscription.prototype, "price", {
|
|
6654
6655
|
get: function () {
|
|
6655
|
-
return this.
|
|
6656
|
+
return this.items.reduce(function (sum, item) { return sum + item.total; }, 0);
|
|
6656
6657
|
},
|
|
6657
6658
|
enumerable: false,
|
|
6658
6659
|
configurable: true
|
|
6659
6660
|
});
|
|
6660
|
-
Object.defineProperty(
|
|
6661
|
+
Object.defineProperty(ServiceSubscription.prototype, "title", {
|
|
6662
|
+
/**
|
|
6663
|
+
* get title of subscription
|
|
6664
|
+
*/
|
|
6661
6665
|
get: function () {
|
|
6662
|
-
return this.
|
|
6666
|
+
return this.items.map(function (item) { return item.price.product.title; }).join(' + ');
|
|
6667
|
+
// return this.isTrial ? 'Trial period' : this.items.map((item) => item.price.product.title).join(' + ');
|
|
6663
6668
|
},
|
|
6664
6669
|
enumerable: false,
|
|
6665
6670
|
configurable: true
|
|
6666
6671
|
});
|
|
6667
|
-
Object.defineProperty(
|
|
6672
|
+
Object.defineProperty(ServiceSubscription.prototype, "isActive", {
|
|
6673
|
+
/**
|
|
6674
|
+
* A subscription is considered active if the end date has not yet arrived and its status is "Active" or "Past due"
|
|
6675
|
+
*/
|
|
6668
6676
|
get: function () {
|
|
6669
|
-
|
|
6677
|
+
var isExpired = new Date(this.endDate).getTime() < new Date().getTime();
|
|
6678
|
+
return !isExpired && ([exports.ServiceSubscriptionStatusEnum.ACTIVE, exports.ServiceSubscriptionStatusEnum.PAST_DUE].includes(this.status));
|
|
6670
6679
|
},
|
|
6671
6680
|
enumerable: false,
|
|
6672
6681
|
configurable: true
|
|
6673
6682
|
});
|
|
6674
|
-
Object.defineProperty(
|
|
6675
|
-
/**
|
|
6676
|
-
* Check if transaction reconcile operation if TRANSFER
|
|
6677
|
-
* @TODO bad usage of get (and all is* methods), getter should sound like a noun
|
|
6678
|
-
*/
|
|
6683
|
+
Object.defineProperty(ServiceSubscription.prototype, "daysRemain", {
|
|
6679
6684
|
get: function () {
|
|
6680
|
-
|
|
6685
|
+
var daysRemains = Math.round((new Date(this.endDate).getTime() - new Date().getTime()) / (1000 * 3600 * 24));
|
|
6686
|
+
return daysRemains > 0 ? daysRemains : 0;
|
|
6681
6687
|
},
|
|
6682
6688
|
enumerable: false,
|
|
6683
6689
|
configurable: true
|
|
6684
6690
|
});
|
|
6685
|
-
|
|
6686
|
-
|
|
6691
|
+
/**
|
|
6692
|
+
* Check if trial expired
|
|
6693
|
+
*/
|
|
6694
|
+
ServiceSubscription.prototype.isTrialExpired = function () {
|
|
6695
|
+
return this.daysRemain && this.daysRemain <= 0;
|
|
6687
6696
|
};
|
|
6688
|
-
|
|
6689
|
-
return this.
|
|
6697
|
+
ServiceSubscription.prototype.isTrialExpiring = function () {
|
|
6698
|
+
return this.daysRemain > 0 && this.daysRemain <= this.lastTrialDays;
|
|
6690
6699
|
};
|
|
6691
|
-
|
|
6700
|
+
ServiceSubscription.prototype.isRenewable = function () {
|
|
6701
|
+
return !this.isTrial && this.isActive;
|
|
6702
|
+
};
|
|
6703
|
+
ServiceSubscription.prototype.getItems = function () {
|
|
6704
|
+
return new SubscriptionItemCollection(this.items);
|
|
6705
|
+
};
|
|
6706
|
+
Object.defineProperty(ServiceSubscription.prototype, "workTankItem", {
|
|
6707
|
+
/**
|
|
6708
|
+
* @TODO move to collection
|
|
6709
|
+
*/
|
|
6692
6710
|
get: function () {
|
|
6693
|
-
return this.
|
|
6711
|
+
return this.items.find(function (item) { return item.price.product.isWorkTank(); });
|
|
6712
|
+
},
|
|
6713
|
+
enumerable: false,
|
|
6714
|
+
configurable: true
|
|
6715
|
+
});
|
|
6716
|
+
Object.defineProperty(ServiceSubscription.prototype, "soleTankItem", {
|
|
6717
|
+
get: function () {
|
|
6718
|
+
return this.items.find(function (item) { return item.price.product.isSoleTank(); });
|
|
6694
6719
|
},
|
|
6695
6720
|
enumerable: false,
|
|
6696
6721
|
configurable: true
|
|
6697
6722
|
});
|
|
6698
|
-
Object.defineProperty(
|
|
6723
|
+
Object.defineProperty(ServiceSubscription.prototype, "propertyTankItem", {
|
|
6699
6724
|
get: function () {
|
|
6700
|
-
return this.
|
|
6725
|
+
return this.items.find(function (item) { return item.price.product.isProperties(); });
|
|
6701
6726
|
},
|
|
6702
6727
|
enumerable: false,
|
|
6703
6728
|
configurable: true
|
|
6704
6729
|
});
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
*/
|
|
6710
|
-
Transaction.prototype.getMetadataFieldValue = function (field) {
|
|
6711
|
-
var _a;
|
|
6712
|
-
return +((_a = this.metadata.find(function (transactionMetadata) {
|
|
6713
|
-
return transactionMetadata.chartAccountsMetadata.id === field;
|
|
6714
|
-
})) === null || _a === void 0 ? void 0 : _a.value) || 0;
|
|
6730
|
+
ServiceSubscription.prototype.hasPropertyTank = function () {
|
|
6731
|
+
return !!this.items.find(function (subscriptionItem) {
|
|
6732
|
+
return subscriptionItem.price.product.role.includes(exports.UserRolesEnum.PROPERTY_TANK);
|
|
6733
|
+
});
|
|
6715
6734
|
};
|
|
6716
|
-
|
|
6717
|
-
return this.
|
|
6735
|
+
ServiceSubscription.prototype.hasWorkTank = function () {
|
|
6736
|
+
return !!this.items.find(function (subscriptionItem) {
|
|
6737
|
+
return subscriptionItem.price.product.role.includes(exports.UserRolesEnum.WORK_TANK);
|
|
6738
|
+
});
|
|
6718
6739
|
};
|
|
6719
6740
|
/**
|
|
6720
|
-
*
|
|
6741
|
+
* bought before price updates, active for some time to let customer select a new plan
|
|
6742
|
+
* impossible to update, only prolong or buy new
|
|
6721
6743
|
*/
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
amount: this.amount,
|
|
6726
|
-
chartAccounts: this.chartAccounts,
|
|
6727
|
-
description: this.description,
|
|
6728
|
-
type: exports.DepreciationTypeEnum.PLANT_EQUIPMENT,
|
|
6729
|
-
claimPercent: this.claimPercent,
|
|
6730
|
-
property: this.property,
|
|
6731
|
-
calculation: this.property ? this.property.depreciationCalculation : exports.DepreciationCalculationEnum.PRIME_COST
|
|
6732
|
-
});
|
|
6744
|
+
ServiceSubscription.prototype.isArchived = function () {
|
|
6745
|
+
// subscription with at least one archived product considered as archived
|
|
6746
|
+
return !!this.items.filter(function (item) { return item.price.product.isArchived(); }).length;
|
|
6733
6747
|
};
|
|
6734
6748
|
/**
|
|
6735
|
-
*
|
|
6749
|
+
* Case when payment was failed, but user has a time to update payment method
|
|
6736
6750
|
*/
|
|
6737
|
-
|
|
6738
|
-
return this.
|
|
6751
|
+
ServiceSubscription.prototype.isPastDue = function () {
|
|
6752
|
+
return this.status === exports.ServiceSubscriptionStatusEnum.PAST_DUE;
|
|
6739
6753
|
};
|
|
6740
|
-
|
|
6741
|
-
|
|
6754
|
+
/**
|
|
6755
|
+
* Check if current subscription has provided subscription item
|
|
6756
|
+
*/
|
|
6757
|
+
ServiceSubscription.prototype.hasItem = function (itemToCheck) {
|
|
6758
|
+
return !!this.items.find(function (item) { return item.price.id === itemToCheck.price.id; });
|
|
6742
6759
|
};
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
if (this.isSoleTank() && this.isIncome() && this.isGST) {
|
|
6746
|
-
coef = ChartAccounts.GSTCoefficient;
|
|
6747
|
-
}
|
|
6748
|
-
return this.getAllocatedAmount(allocations) * this.claimRatio / coef;
|
|
6760
|
+
ServiceSubscription.prototype.hasProduct = function (product) {
|
|
6761
|
+
return !!this.items.find(function (item) { return item.price.product.id === product.id; });
|
|
6749
6762
|
};
|
|
6750
|
-
|
|
6751
|
-
return this.
|
|
6763
|
+
ServiceSubscription.prototype.isPackage = function () {
|
|
6764
|
+
return this.items.length === ServiceProduct.quantity;
|
|
6752
6765
|
};
|
|
6753
|
-
Object.defineProperty(Transaction.prototype, "grossAmount", {
|
|
6754
|
-
/**
|
|
6755
|
-
* Total transaction amount including taxes and other additional amounts
|
|
6756
|
-
*/
|
|
6757
|
-
get: function () {
|
|
6758
|
-
var grossAmount = _super.prototype.grossAmount + this.tax;
|
|
6759
|
-
if (this.isExpense()) {
|
|
6760
|
-
return grossAmount;
|
|
6761
|
-
}
|
|
6762
|
-
// salary included transactions affect parent transaction amount and as a result grossAmount, skip to avoid double sum
|
|
6763
|
-
grossAmount += new Collection(this.transactions)
|
|
6764
|
-
.filter(function (t) { var _a; return !((_a = t.chartAccounts) === null || _a === void 0 ? void 0 : _a.isSalaryIncluded()); })
|
|
6765
|
-
.sumBy('amount', true);
|
|
6766
|
-
if (this.isWorkTank()) {
|
|
6767
|
-
grossAmount += this.frankingCredit - this.taxFreeComponent - this.eligibleForReduction;
|
|
6768
|
-
}
|
|
6769
|
-
return +(Math.round(grossAmount * 100) / 100).toFixed(2);
|
|
6770
|
-
},
|
|
6771
|
-
enumerable: false,
|
|
6772
|
-
configurable: true
|
|
6773
|
-
});
|
|
6774
|
-
Object.defineProperty(Transaction.prototype, "netAmount", {
|
|
6775
|
-
/**
|
|
6776
|
-
* @TODO vik confusing logic demanded by Nicole, we need a better ux to fix it
|
|
6777
|
-
* netAmount matches received payment (bankTransaction amount), includes gst and salary included adjustments
|
|
6778
|
-
* ie user received 1000$ salary including 100$ tips. NetAmount=1000$, amount=900$, tips=100$
|
|
6779
|
-
*/
|
|
6780
|
-
get: function () {
|
|
6781
|
-
return new Collection(this.transactions)
|
|
6782
|
-
.filter(function (t) { var _a; return (_a = t.chartAccounts) === null || _a === void 0 ? void 0 : _a.isSalaryIncluded(); })
|
|
6783
|
-
.sumBy('amount') + this.amountWithGst;
|
|
6784
|
-
},
|
|
6785
|
-
enumerable: false,
|
|
6786
|
-
configurable: true
|
|
6787
|
-
});
|
|
6788
6766
|
/**
|
|
6789
|
-
*
|
|
6790
|
-
*
|
|
6767
|
+
* Recommended number of properties to buy,
|
|
6768
|
+
* based on the property service product and the number of properties the user has
|
|
6791
6769
|
*/
|
|
6792
|
-
|
|
6793
|
-
var
|
|
6794
|
-
return
|
|
6770
|
+
ServiceSubscription.prototype.getRecommendedPropertiesQty = function (propertyItem, propertiesQty) {
|
|
6771
|
+
var min = propertyItem.price.product.minQty;
|
|
6772
|
+
return Math.max(min, propertiesQty);
|
|
6795
6773
|
};
|
|
6796
|
-
return
|
|
6797
|
-
}(
|
|
6798
|
-
__decorate([
|
|
6799
|
-
classTransformer.Type(function () { return Transaction; })
|
|
6800
|
-
], Transaction.prototype, "transactions", void 0);
|
|
6774
|
+
return ServiceSubscription;
|
|
6775
|
+
}(ServiceSubscription$1));
|
|
6801
6776
|
__decorate([
|
|
6802
|
-
classTransformer.Type(function () { return
|
|
6803
|
-
],
|
|
6777
|
+
classTransformer.Type(function () { return Date; })
|
|
6778
|
+
], ServiceSubscription.prototype, "startDate", void 0);
|
|
6804
6779
|
__decorate([
|
|
6805
|
-
classTransformer.Type(function () { return
|
|
6806
|
-
],
|
|
6780
|
+
classTransformer.Type(function () { return Date; })
|
|
6781
|
+
], ServiceSubscription.prototype, "endDate", void 0);
|
|
6807
6782
|
__decorate([
|
|
6808
|
-
classTransformer.Type(function () { return
|
|
6809
|
-
],
|
|
6783
|
+
classTransformer.Type(function () { return ServiceSubscriptionItem; })
|
|
6784
|
+
], ServiceSubscription.prototype, "items", void 0);
|
|
6785
|
+
|
|
6786
|
+
var SoleBusinessAllocation = /** @class */ (function (_super) {
|
|
6787
|
+
__extends(SoleBusinessAllocation, _super);
|
|
6788
|
+
function SoleBusinessAllocation() {
|
|
6789
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6790
|
+
}
|
|
6791
|
+
return SoleBusinessAllocation;
|
|
6792
|
+
}(SoleBusinessAllocation$1));
|
|
6810
6793
|
__decorate([
|
|
6811
|
-
classTransformer.Type(function () { return
|
|
6812
|
-
],
|
|
6794
|
+
classTransformer.Type(function () { return BankAccount; })
|
|
6795
|
+
], SoleBusinessAllocation.prototype, "bankAccount", void 0);
|
|
6813
6796
|
__decorate([
|
|
6814
|
-
classTransformer.Type(function () { return
|
|
6815
|
-
],
|
|
6797
|
+
classTransformer.Type(function () { return SoleBusiness; })
|
|
6798
|
+
], SoleBusinessAllocation.prototype, "business", void 0);
|
|
6816
6799
|
__decorate([
|
|
6817
|
-
classTransformer.
|
|
6818
|
-
|
|
6800
|
+
classTransformer.Transform(function (_a) {
|
|
6801
|
+
var value = _a.value;
|
|
6802
|
+
return value || 100;
|
|
6803
|
+
}),
|
|
6804
|
+
classTransformer.Expose()
|
|
6805
|
+
], SoleBusinessAllocation.prototype, "percent", void 0);
|
|
6806
|
+
|
|
6807
|
+
var SoleBusinessLossOffsetRule = /** @class */ (function (_super) {
|
|
6808
|
+
__extends(SoleBusinessLossOffsetRule, _super);
|
|
6809
|
+
function SoleBusinessLossOffsetRule() {
|
|
6810
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6811
|
+
}
|
|
6812
|
+
return SoleBusinessLossOffsetRule;
|
|
6813
|
+
}(SoleBusinessLossOffsetRule$1));
|
|
6819
6814
|
__decorate([
|
|
6820
|
-
classTransformer.Type(function () { return
|
|
6821
|
-
],
|
|
6815
|
+
classTransformer.Type(function () { return SoleBusinessLossOffsetRule; })
|
|
6816
|
+
], SoleBusinessLossOffsetRule.prototype, "parent", void 0);
|
|
6817
|
+
|
|
6818
|
+
/**
|
|
6819
|
+
* If a sole trader business makes a tax loss in a current year, you can generally carry forward that loss and offset profit in future years.
|
|
6820
|
+
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/4641357930/Rules+when+a+business+makes+a+loss+Tax+Summary#Offsetting-current-year-business-losses
|
|
6821
|
+
*/
|
|
6822
|
+
var SoleBusinessLoss = /** @class */ (function (_super) {
|
|
6823
|
+
__extends(SoleBusinessLoss, _super);
|
|
6824
|
+
function SoleBusinessLoss() {
|
|
6825
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
6826
|
+
_this.openBalance = 0;
|
|
6827
|
+
_this.financialYear = new FinancialYear().year;
|
|
6828
|
+
return _this;
|
|
6829
|
+
}
|
|
6830
|
+
Object.defineProperty(SoleBusinessLoss.prototype, "hasOffset", {
|
|
6831
|
+
get: function () {
|
|
6832
|
+
return !!this.offsetRule;
|
|
6833
|
+
},
|
|
6834
|
+
enumerable: false,
|
|
6835
|
+
configurable: true
|
|
6836
|
+
});
|
|
6837
|
+
return SoleBusinessLoss;
|
|
6838
|
+
}(SoleBusinessLoss$1));
|
|
6822
6839
|
__decorate([
|
|
6823
|
-
classTransformer.Type(function () { return
|
|
6824
|
-
],
|
|
6840
|
+
classTransformer.Type(function () { return SoleBusiness; })
|
|
6841
|
+
], SoleBusinessLoss.prototype, "business", void 0);
|
|
6825
6842
|
__decorate([
|
|
6826
|
-
classTransformer.Type(function () { return
|
|
6827
|
-
],
|
|
6843
|
+
classTransformer.Type(function () { return SoleBusinessLossOffsetRule; })
|
|
6844
|
+
], SoleBusinessLoss.prototype, "offsetRule", void 0);
|
|
6845
|
+
|
|
6846
|
+
exports.MyAccountHistoryInitiatedByEnum = void 0;
|
|
6847
|
+
(function (MyAccountHistoryInitiatedByEnum) {
|
|
6848
|
+
MyAccountHistoryInitiatedByEnum[MyAccountHistoryInitiatedByEnum["OWNER"] = 0] = "OWNER";
|
|
6849
|
+
MyAccountHistoryInitiatedByEnum[MyAccountHistoryInitiatedByEnum["ACCOUNTANT"] = 1] = "ACCOUNTANT";
|
|
6850
|
+
})(exports.MyAccountHistoryInitiatedByEnum || (exports.MyAccountHistoryInitiatedByEnum = {}));
|
|
6851
|
+
|
|
6852
|
+
exports.MyAccountHistoryStatusEnum = void 0;
|
|
6853
|
+
(function (MyAccountHistoryStatusEnum) {
|
|
6854
|
+
MyAccountHistoryStatusEnum[MyAccountHistoryStatusEnum["SUCCESS"] = 0] = "SUCCESS";
|
|
6855
|
+
MyAccountHistoryStatusEnum[MyAccountHistoryStatusEnum["ERROR"] = 1] = "ERROR";
|
|
6856
|
+
})(exports.MyAccountHistoryStatusEnum || (exports.MyAccountHistoryStatusEnum = {}));
|
|
6857
|
+
|
|
6858
|
+
exports.MyAccountHistoryTypeEnum = void 0;
|
|
6859
|
+
(function (MyAccountHistoryTypeEnum) {
|
|
6860
|
+
MyAccountHistoryTypeEnum[MyAccountHistoryTypeEnum["REVIEW"] = 0] = "REVIEW";
|
|
6861
|
+
MyAccountHistoryTypeEnum[MyAccountHistoryTypeEnum["UPGRADE_PLAN"] = 1] = "UPGRADE_PLAN";
|
|
6862
|
+
MyAccountHistoryTypeEnum[MyAccountHistoryTypeEnum["UPLOAD_DOCUMENT"] = 2] = "UPLOAD_DOCUMENT";
|
|
6863
|
+
})(exports.MyAccountHistoryTypeEnum || (exports.MyAccountHistoryTypeEnum = {}));
|
|
6864
|
+
|
|
6865
|
+
var MyAccountHistory = /** @class */ (function () {
|
|
6866
|
+
function MyAccountHistory() {
|
|
6867
|
+
}
|
|
6868
|
+
return MyAccountHistory;
|
|
6869
|
+
}());
|
|
6870
|
+
|
|
6871
|
+
var Occupation = /** @class */ (function (_super) {
|
|
6872
|
+
__extends(Occupation, _super);
|
|
6873
|
+
function Occupation() {
|
|
6874
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6875
|
+
}
|
|
6876
|
+
return Occupation;
|
|
6877
|
+
}(Occupation$1));
|
|
6878
|
+
|
|
6879
|
+
/**
|
|
6880
|
+
* role hierarchy
|
|
6881
|
+
*/
|
|
6882
|
+
var USER_ROLES = {
|
|
6883
|
+
ROLE_FIRM_OWNER: [exports.UserRolesEnum.FIRM_OWNER, exports.UserRolesEnum.FIRM_MANAGER, exports.UserRolesEnum.ACCOUNTANT, exports.UserRolesEnum.ADVISOR],
|
|
6884
|
+
ROLE_FIRM_MANAGER: [exports.UserRolesEnum.FIRM_MANAGER, exports.UserRolesEnum.ACCOUNTANT, exports.UserRolesEnum.ADVISOR],
|
|
6885
|
+
ROLE_EMPLOYEE: [exports.UserRolesEnum.ACCOUNTANT, exports.UserRolesEnum.ADVISOR],
|
|
6886
|
+
ROLE_ACCOUNTANT: [exports.UserRolesEnum.ACCOUNTANT],
|
|
6887
|
+
ROLE_ADVISOR: [exports.UserRolesEnum.ADVISOR],
|
|
6888
|
+
ROLE_CLIENT: [exports.UserRolesEnum.CLIENT],
|
|
6889
|
+
ROLE_USER_SUBSCRIPTION: [exports.UserRolesEnum.SUBSCRIPTION],
|
|
6890
|
+
ROLE_USER_WORK: [exports.UserRolesEnum.WORK_TANK],
|
|
6891
|
+
ROLE_USER_PROPERTY: [exports.UserRolesEnum.PROPERTY_TANK],
|
|
6892
|
+
ROLE_USER_SOLE: [exports.UserRolesEnum.SOLE_TANK],
|
|
6893
|
+
};
|
|
6894
|
+
|
|
6895
|
+
/**
|
|
6896
|
+
* Class with basic information about registering user
|
|
6897
|
+
*/
|
|
6898
|
+
var UserToRegister = /** @class */ (function () {
|
|
6899
|
+
function UserToRegister() {
|
|
6900
|
+
}
|
|
6901
|
+
return UserToRegister;
|
|
6902
|
+
}());
|
|
6828
6903
|
|
|
6829
6904
|
var SoleInvoiceItem = /** @class */ (function (_super) {
|
|
6830
6905
|
__extends(SoleInvoiceItem, _super);
|
|
@@ -11406,12 +11481,6 @@
|
|
|
11406
11481
|
ServicePriceRecurringIntervalEnum[ServicePriceRecurringIntervalEnum["YEAR"] = 4] = "YEAR";
|
|
11407
11482
|
})(exports.ServicePriceRecurringIntervalEnum || (exports.ServicePriceRecurringIntervalEnum = {}));
|
|
11408
11483
|
|
|
11409
|
-
exports.ServicePriceTypeEnum = void 0;
|
|
11410
|
-
(function (ServicePriceTypeEnum) {
|
|
11411
|
-
ServicePriceTypeEnum[ServicePriceTypeEnum["ONE_TIME"] = 1] = "ONE_TIME";
|
|
11412
|
-
ServicePriceTypeEnum[ServicePriceTypeEnum["RECURRING"] = 2] = "RECURRING";
|
|
11413
|
-
})(exports.ServicePriceTypeEnum || (exports.ServicePriceTypeEnum = {}));
|
|
11414
|
-
|
|
11415
11484
|
exports.SpareDocumentSpareTypeEnum = void 0;
|
|
11416
11485
|
(function (SpareDocumentSpareTypeEnum) {
|
|
11417
11486
|
SpareDocumentSpareTypeEnum[SpareDocumentSpareTypeEnum["DOCUMENT"] = 1] = "DOCUMENT";
|