taxtank-core 0.28.43 → 0.28.44
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 +87 -45
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/sole/index.js +2 -1
- package/esm2015/lib/collections/sole/sole-business-losses.collection.js +28 -0
- package/esm2015/lib/collections/transaction/transaction-base.collection.js +9 -3
- package/esm2015/lib/forms/report/my-tax/my-tax-losses.form.js +6 -5
- package/esm2015/lib/models/report/my-tax/my-tax-losses/my-tax-losses.js +8 -5
- package/fesm2015/taxtank-core.js +78 -43
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/sole/index.d.ts +1 -0
- package/lib/collections/sole/sole-business-losses.collection.d.ts +9 -0
- package/lib/collections/transaction/transaction-base.collection.d.ts +5 -2
- package/lib/forms/report/my-tax/my-tax-losses.form.d.ts +0 -3
- package/lib/models/report/my-tax/my-tax-losses/my-tax-losses.d.ts +14 -4
- package/package.json +1 -1
|
@@ -7341,6 +7341,73 @@
|
|
|
7341
7341
|
return VehicleLogbookCollection;
|
|
7342
7342
|
}(Collection));
|
|
7343
7343
|
|
|
7344
|
+
/**
|
|
7345
|
+
* List of objects grouped by passed property
|
|
7346
|
+
*/
|
|
7347
|
+
var Dictionary = /** @class */ (function () {
|
|
7348
|
+
function Dictionary(items, path) {
|
|
7349
|
+
if (path === void 0) { path = 'id'; }
|
|
7350
|
+
this.items = {};
|
|
7351
|
+
if (!items.length) {
|
|
7352
|
+
return;
|
|
7353
|
+
}
|
|
7354
|
+
// Do nothing if provided path was not found in the 1st item
|
|
7355
|
+
if (!hasIn__default["default"](items[0], path.split('.')[0])) {
|
|
7356
|
+
return;
|
|
7357
|
+
}
|
|
7358
|
+
this.groupItems(items, path);
|
|
7359
|
+
}
|
|
7360
|
+
Dictionary.prototype.add = function (key, value) {
|
|
7361
|
+
this.items[key] = value;
|
|
7362
|
+
};
|
|
7363
|
+
Dictionary.prototype.get = function (key) {
|
|
7364
|
+
return this.items[key] !== undefined ? this.items[key] : null;
|
|
7365
|
+
};
|
|
7366
|
+
Dictionary.prototype.groupItems = function (items, path) {
|
|
7367
|
+
var _this = this;
|
|
7368
|
+
items.forEach(function (item) {
|
|
7369
|
+
var key = get__default["default"](item, path);
|
|
7370
|
+
// if object does not have property for grouping it will be grouped as 'other'
|
|
7371
|
+
if (key === undefined) {
|
|
7372
|
+
key = 'other';
|
|
7373
|
+
}
|
|
7374
|
+
_this.items[key] = item;
|
|
7375
|
+
});
|
|
7376
|
+
};
|
|
7377
|
+
return Dictionary;
|
|
7378
|
+
}());
|
|
7379
|
+
|
|
7380
|
+
var SoleBusinessLossesCollection = /** @class */ (function (_super) {
|
|
7381
|
+
__extends(SoleBusinessLossesCollection, _super);
|
|
7382
|
+
function SoleBusinessLossesCollection() {
|
|
7383
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
7384
|
+
}
|
|
7385
|
+
/**
|
|
7386
|
+
* Calculate business losses applied to the current year
|
|
7387
|
+
*/
|
|
7388
|
+
SoleBusinessLossesCollection.prototype.calculateBusinessLossApplied = function (transactions) {
|
|
7389
|
+
var _this = this;
|
|
7390
|
+
var transactionsByBusinessIds = new CollectionDictionary(transactions, 'business.id');
|
|
7391
|
+
// Dictionary with pairs key = business id, value = business claim amount
|
|
7392
|
+
var claimAmountsByBusinessId = new Dictionary([]);
|
|
7393
|
+
transactionsByBusinessIds.keys.forEach(function (businessId) {
|
|
7394
|
+
var businessClaimAmount = transactionsByBusinessIds
|
|
7395
|
+
.get(businessId)
|
|
7396
|
+
.getClaimAmountByBusinessId(+businessId);
|
|
7397
|
+
// only businesses with positive income are included in the calculation
|
|
7398
|
+
if (businessClaimAmount > 0) {
|
|
7399
|
+
claimAmountsByBusinessId.add(businessId, businessClaimAmount);
|
|
7400
|
+
}
|
|
7401
|
+
});
|
|
7402
|
+
return Object.keys(claimAmountsByBusinessId.items).reduce(function (sum, businessId) {
|
|
7403
|
+
var _a;
|
|
7404
|
+
var lossOpenBalance = ((_a = _this.findBy('business.id', +businessId)) === null || _a === void 0 ? void 0 : _a.openBalance) || 0;
|
|
7405
|
+
return sum + Math.min(lossOpenBalance, claimAmountsByBusinessId.get(businessId));
|
|
7406
|
+
}, 0);
|
|
7407
|
+
};
|
|
7408
|
+
return SoleBusinessLossesCollection;
|
|
7409
|
+
}(Collection));
|
|
7410
|
+
|
|
7344
7411
|
var SoleInvoiceCollection = /** @class */ (function (_super) {
|
|
7345
7412
|
__extends(SoleInvoiceCollection, _super);
|
|
7346
7413
|
function SoleInvoiceCollection() {
|
|
@@ -7864,8 +7931,14 @@
|
|
|
7864
7931
|
function TransactionBaseCollection() {
|
|
7865
7932
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
7866
7933
|
}
|
|
7867
|
-
TransactionBaseCollection.prototype.
|
|
7868
|
-
return +this.filterBy('business.id',
|
|
7934
|
+
TransactionBaseCollection.prototype.getClaimAmountByBusinessId = function (businessId) {
|
|
7935
|
+
return +this.filterBy('business.id', businessId).items.map(function (transaction) { return transaction instanceof Depreciation ? -transaction.claimAmount : transaction['claimAmount']; }).reduce(function (sum, claimAmount) { return sum + claimAmount; }, 0).toFixed(2);
|
|
7936
|
+
};
|
|
7937
|
+
/**
|
|
7938
|
+
* Get business related transactions
|
|
7939
|
+
*/
|
|
7940
|
+
TransactionBaseCollection.prototype.getWithBusiness = function () {
|
|
7941
|
+
return this.filter(function (transaction) { return !!transaction.business; });
|
|
7869
7942
|
};
|
|
7870
7943
|
return TransactionBaseCollection;
|
|
7871
7944
|
}(Collection));
|
|
@@ -8071,42 +8144,6 @@
|
|
|
8071
8144
|
return MessageCollection;
|
|
8072
8145
|
}(Collection));
|
|
8073
8146
|
|
|
8074
|
-
/**
|
|
8075
|
-
* List of objects grouped by passed property
|
|
8076
|
-
*/
|
|
8077
|
-
var Dictionary = /** @class */ (function () {
|
|
8078
|
-
function Dictionary(items, path) {
|
|
8079
|
-
if (path === void 0) { path = 'id'; }
|
|
8080
|
-
this.items = {};
|
|
8081
|
-
if (!items.length) {
|
|
8082
|
-
return;
|
|
8083
|
-
}
|
|
8084
|
-
// Do nothing if provided path was not found in the 1st item
|
|
8085
|
-
if (!hasIn__default["default"](items[0], path.split('.')[0])) {
|
|
8086
|
-
return;
|
|
8087
|
-
}
|
|
8088
|
-
this.groupItems(items, path);
|
|
8089
|
-
}
|
|
8090
|
-
Dictionary.prototype.add = function (key, value) {
|
|
8091
|
-
this.items[key] = value;
|
|
8092
|
-
};
|
|
8093
|
-
Dictionary.prototype.get = function (key) {
|
|
8094
|
-
return this.items[key] !== undefined ? this.items[key] : null;
|
|
8095
|
-
};
|
|
8096
|
-
Dictionary.prototype.groupItems = function (items, path) {
|
|
8097
|
-
var _this = this;
|
|
8098
|
-
items.forEach(function (item) {
|
|
8099
|
-
var key = get__default["default"](item, path);
|
|
8100
|
-
// if object does not have property for grouping it will be grouped as 'other'
|
|
8101
|
-
if (key === undefined) {
|
|
8102
|
-
key = 'other';
|
|
8103
|
-
}
|
|
8104
|
-
_this.items[key] = item;
|
|
8105
|
-
});
|
|
8106
|
-
};
|
|
8107
|
-
return Dictionary;
|
|
8108
|
-
}());
|
|
8109
|
-
|
|
8110
8147
|
exports.ChatStatusEnum = void 0;
|
|
8111
8148
|
(function (ChatStatusEnum) {
|
|
8112
8149
|
ChatStatusEnum[ChatStatusEnum["ACTIVE"] = 1] = "ACTIVE";
|
|
@@ -11411,11 +11448,15 @@
|
|
|
11411
11448
|
}());
|
|
11412
11449
|
|
|
11413
11450
|
/**
|
|
11414
|
-
*
|
|
11451
|
+
* Sole business losses report
|
|
11452
|
+
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/4644110466/Tax+Return+MyTax+-+Online+Form ("Losses" section)
|
|
11415
11453
|
*/
|
|
11416
11454
|
var MyTaxLosses = /** @class */ (function () {
|
|
11417
|
-
function MyTaxLosses(transactions) {
|
|
11418
|
-
this.transactions = transactions
|
|
11455
|
+
function MyTaxLosses(transactions, businessLosses) {
|
|
11456
|
+
this.transactions = transactions;
|
|
11457
|
+
this.businessLosses = businessLosses;
|
|
11458
|
+
this.businessLossDeferred = businessLosses.sumBy('openBalance');
|
|
11459
|
+
this.businessLossApplied = businessLosses.calculateBusinessLossApplied(transactions);
|
|
11419
11460
|
}
|
|
11420
11461
|
return MyTaxLosses;
|
|
11421
11462
|
}());
|
|
@@ -19254,13 +19295,13 @@
|
|
|
19254
19295
|
return MyTaxInterestForm;
|
|
19255
19296
|
}(AbstractForm));
|
|
19256
19297
|
|
|
19257
|
-
/**
|
|
19258
|
-
* @Todo waiting for Sole tank implementation
|
|
19259
|
-
*/
|
|
19260
19298
|
var MyTaxLossesForm = /** @class */ (function (_super) {
|
|
19261
19299
|
__extends(MyTaxLossesForm, _super);
|
|
19262
19300
|
function MyTaxLossesForm(losses) {
|
|
19263
|
-
return _super.call(this, {
|
|
19301
|
+
return _super.call(this, {
|
|
19302
|
+
businessLossDeferred: new forms.FormControl(losses.businessLossDeferred),
|
|
19303
|
+
businessLossApplied: new forms.FormControl(losses.businessLossApplied)
|
|
19304
|
+
}) || this;
|
|
19264
19305
|
}
|
|
19265
19306
|
return MyTaxLossesForm;
|
|
19266
19307
|
}(AbstractForm));
|
|
@@ -19789,6 +19830,7 @@
|
|
|
19789
19830
|
exports.SoleBusinessLossOffsetRuleService = SoleBusinessLossOffsetRuleService;
|
|
19790
19831
|
exports.SoleBusinessLossReport = SoleBusinessLossReport;
|
|
19791
19832
|
exports.SoleBusinessLossService = SoleBusinessLossService;
|
|
19833
|
+
exports.SoleBusinessLossesCollection = SoleBusinessLossesCollection;
|
|
19792
19834
|
exports.SoleBusinessService = SoleBusinessService;
|
|
19793
19835
|
exports.SoleContact = SoleContact;
|
|
19794
19836
|
exports.SoleContactForm = SoleContactForm;
|