taxtank-core 0.28.42 → 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 +155 -60
- 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/tax-summary/report-item.collection.js +34 -4
- package/esm2015/lib/collections/tax-summary/tax-return-categories.const.js +7 -2
- package/esm2015/lib/collections/transaction/transaction-base.collection.js +9 -3
- package/esm2015/lib/db/Enums/tax-return-category-list.enum.js +4 -1
- 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/esm2015/lib/models/tax-summary/tax-summary.js +7 -5
- package/esm2015/lib/services/http/sole/sole-invoice/sole-invoice.service.js +3 -3
- package/fesm2015/taxtank-core.js +128 -52
- 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/tax-summary/report-item.collection.d.ts +12 -1
- package/lib/collections/transaction/transaction-base.collection.d.ts +5 -2
- package/lib/db/Enums/tax-return-category-list.enum.d.ts +4 -1
- 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";
|
|
@@ -8893,11 +8930,34 @@
|
|
|
8893
8930
|
}
|
|
8894
8931
|
return this.create(result);
|
|
8895
8932
|
};
|
|
8933
|
+
ReportItemCollection.prototype.getByCategory = function (categoryId) {
|
|
8934
|
+
var e_2, _a;
|
|
8935
|
+
var result = [];
|
|
8936
|
+
try {
|
|
8937
|
+
for (var _b = __values(this.items), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8938
|
+
var reportItem = _c.value;
|
|
8939
|
+
if (reportItem.taxReturnCategory.id === categoryId) {
|
|
8940
|
+
result.push(reportItem);
|
|
8941
|
+
}
|
|
8942
|
+
else if (reportItem.items && reportItem.items.getByCategory(categoryId).length) {
|
|
8943
|
+
result.push.apply(result, __spreadArray([], __read(reportItem.items.getByCategory(categoryId))));
|
|
8944
|
+
}
|
|
8945
|
+
}
|
|
8946
|
+
}
|
|
8947
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
8948
|
+
finally {
|
|
8949
|
+
try {
|
|
8950
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8951
|
+
}
|
|
8952
|
+
finally { if (e_2) throw e_2.error; }
|
|
8953
|
+
}
|
|
8954
|
+
return result;
|
|
8955
|
+
};
|
|
8896
8956
|
/**
|
|
8897
8957
|
* Recursively find report item by Tax Return Category ID
|
|
8898
8958
|
*/
|
|
8899
8959
|
ReportItemCollection.prototype.findByCategory = function (categoryId) {
|
|
8900
|
-
var
|
|
8960
|
+
var e_3, _a;
|
|
8901
8961
|
var result;
|
|
8902
8962
|
try {
|
|
8903
8963
|
for (var _b = __values(this.items), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -8913,35 +8973,54 @@
|
|
|
8913
8973
|
}
|
|
8914
8974
|
}
|
|
8915
8975
|
}
|
|
8916
|
-
catch (
|
|
8976
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
8917
8977
|
finally {
|
|
8918
8978
|
try {
|
|
8919
8979
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8920
8980
|
}
|
|
8921
|
-
finally { if (
|
|
8981
|
+
finally { if (e_3) throw e_3.error; }
|
|
8922
8982
|
}
|
|
8923
8983
|
return result;
|
|
8924
8984
|
};
|
|
8925
8985
|
/**
|
|
8926
|
-
*
|
|
8986
|
+
* get Collection of report items by Tax Return Categories IDs (one item per category)
|
|
8927
8987
|
*/
|
|
8928
|
-
ReportItemCollection.prototype.
|
|
8988
|
+
ReportItemCollection.prototype.findByCategories = function (categories) {
|
|
8929
8989
|
var _this = this;
|
|
8930
8990
|
return this.create(compact__default["default"](categories.map(function (category) { return _this.findByCategory(category); })));
|
|
8931
8991
|
};
|
|
8992
|
+
/**
|
|
8993
|
+
* Get Collection of report items by Tax Return Categories IDs (all items per category)
|
|
8994
|
+
*/
|
|
8995
|
+
ReportItemCollection.prototype.getByCategories = function (categories) {
|
|
8996
|
+
var _this = this;
|
|
8997
|
+
var reportItems = [];
|
|
8998
|
+
categories.forEach(function (category) {
|
|
8999
|
+
reportItems.push.apply(reportItems, __spreadArray([], __read(_this.getByCategory(category))));
|
|
9000
|
+
});
|
|
9001
|
+
return this.create(reportItems);
|
|
9002
|
+
};
|
|
8932
9003
|
/**
|
|
8933
9004
|
* A short call to a chain of methods that we often use.
|
|
8934
9005
|
* Get total amount of report items by Tax Return categories and Tax Summary Section.
|
|
8935
9006
|
*/
|
|
8936
9007
|
ReportItemCollection.prototype.sumByCategoriesAndSection = function (categories, section) {
|
|
8937
|
-
return this.
|
|
9008
|
+
return this.findByCategories(categories).getBySection(section).sumBy('amount');
|
|
9009
|
+
};
|
|
9010
|
+
/**
|
|
9011
|
+
* @TODO vik refactor once Nicole approved
|
|
9012
|
+
* unlike sumByCategoriesAndSection, which find just one reportItem per category,
|
|
9013
|
+
* this method will search for recursively for all matches
|
|
9014
|
+
*/
|
|
9015
|
+
ReportItemCollection.prototype.sumByCategories = function (categories) {
|
|
9016
|
+
return this.getByCategories(categories).sumBy('amount');
|
|
8938
9017
|
};
|
|
8939
9018
|
/**
|
|
8940
9019
|
* Get collection of all report item details related to passed income source
|
|
8941
9020
|
* @TODO Alex: consider to create and move to ReportItemDetailsCollection
|
|
8942
9021
|
*/
|
|
8943
9022
|
ReportItemCollection.prototype.getDetailsByIncomeSource = function (incomeSource) {
|
|
8944
|
-
var
|
|
9023
|
+
var e_4, _a;
|
|
8945
9024
|
var result = [];
|
|
8946
9025
|
try {
|
|
8947
9026
|
for (var _b = __values(this.items), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -8954,12 +9033,12 @@
|
|
|
8954
9033
|
}
|
|
8955
9034
|
}
|
|
8956
9035
|
}
|
|
8957
|
-
catch (
|
|
9036
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
8958
9037
|
finally {
|
|
8959
9038
|
try {
|
|
8960
9039
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8961
9040
|
}
|
|
8962
|
-
finally { if (
|
|
9041
|
+
finally { if (e_4) throw e_4.error; }
|
|
8963
9042
|
}
|
|
8964
9043
|
return new Collection(result);
|
|
8965
9044
|
};
|
|
@@ -9027,6 +9106,9 @@
|
|
|
9027
9106
|
TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["TAX_OFFSETS_MIDDLE"] = 62] = "TAX_OFFSETS_MIDDLE";
|
|
9028
9107
|
TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["TAX_OFFSETS_SOLE"] = 63] = "TAX_OFFSETS_SOLE";
|
|
9029
9108
|
TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["TAX_PAYABLE"] = 28] = "TAX_PAYABLE";
|
|
9109
|
+
TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["BUSINESS_INCOME_OR_LOSS"] = 59] = "BUSINESS_INCOME_OR_LOSS";
|
|
9110
|
+
TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["DEFERRED_BUSINESS_LOSSES_FROM_PRIOR_YEAR"] = 64] = "DEFERRED_BUSINESS_LOSSES_FROM_PRIOR_YEAR";
|
|
9111
|
+
TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["DEFERRED_BUSINESS_LOSSES"] = 60] = "DEFERRED_BUSINESS_LOSSES";
|
|
9030
9112
|
})(exports.TaxReturnCategoryListEnum || (exports.TaxReturnCategoryListEnum = {}));
|
|
9031
9113
|
|
|
9032
9114
|
var TAX_RETURN_CATEGORIES = {
|
|
@@ -9112,10 +9194,15 @@
|
|
|
9112
9194
|
exports.TaxReturnCategoryListEnum.RENT_EXPENSES,
|
|
9113
9195
|
exports.TaxReturnCategoryListEnum.INTEREST_EXPENSES_WITHIN_AUSTRALIA,
|
|
9114
9196
|
exports.TaxReturnCategoryListEnum.INTEREST_EXPENSES_OVERSEAS,
|
|
9115
|
-
exports.TaxReturnCategoryListEnum.DEPRECIATION_EXPENSES,
|
|
9116
9197
|
exports.TaxReturnCategoryListEnum.MOTOR_VEHICLE_EXPENSES,
|
|
9117
9198
|
exports.TaxReturnCategoryListEnum.ALL_OTHER_EXPENSES
|
|
9118
9199
|
],
|
|
9200
|
+
depreciation: [
|
|
9201
|
+
exports.TaxReturnCategoryListEnum.DEPRECIATION_EXPENSES,
|
|
9202
|
+
],
|
|
9203
|
+
loss: [
|
|
9204
|
+
exports.TaxReturnCategoryListEnum.DEFERRED_BUSINESS_LOSSES_FROM_PRIOR_YEAR,
|
|
9205
|
+
],
|
|
9119
9206
|
taxOffsets: [
|
|
9120
9207
|
exports.TaxReturnCategoryListEnum.TAX_OFFSETS_SOLE
|
|
9121
9208
|
],
|
|
@@ -11361,11 +11448,15 @@
|
|
|
11361
11448
|
}());
|
|
11362
11449
|
|
|
11363
11450
|
/**
|
|
11364
|
-
*
|
|
11451
|
+
* Sole business losses report
|
|
11452
|
+
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/4644110466/Tax+Return+MyTax+-+Online+Form ("Losses" section)
|
|
11365
11453
|
*/
|
|
11366
11454
|
var MyTaxLosses = /** @class */ (function () {
|
|
11367
|
-
function MyTaxLosses(transactions) {
|
|
11368
|
-
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);
|
|
11369
11460
|
}
|
|
11370
11461
|
return MyTaxLosses;
|
|
11371
11462
|
}());
|
|
@@ -11855,7 +11946,7 @@
|
|
|
11855
11946
|
get: function () {
|
|
11856
11947
|
var income = this.sole.items.sumByCategoriesAndSection(TAX_RETURN_CATEGORIES.sole.income, exports.TaxSummarySectionEnum.SOLE_TANK);
|
|
11857
11948
|
var expenses = this.sole.items.sumByCategoriesAndSection(TAX_RETURN_CATEGORIES.sole.expenses, exports.TaxSummarySectionEnum.SOLE_TANK);
|
|
11858
|
-
return income
|
|
11949
|
+
return income + expenses;
|
|
11859
11950
|
},
|
|
11860
11951
|
enumerable: false,
|
|
11861
11952
|
configurable: true
|
|
@@ -11866,9 +11957,11 @@
|
|
|
11866
11957
|
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/217677990/Dashboard+Main
|
|
11867
11958
|
*/
|
|
11868
11959
|
get: function () {
|
|
11869
|
-
var income = this.sole.items.
|
|
11870
|
-
var expenses = this.sole.items.
|
|
11871
|
-
|
|
11960
|
+
var income = this.sole.items.sumByCategories(TAX_RETURN_CATEGORIES.sole.income);
|
|
11961
|
+
var expenses = this.sole.items.sumByCategories(TAX_RETURN_CATEGORIES.sole.expenses);
|
|
11962
|
+
var depreciation = this.sole.items.sumByCategories(TAX_RETURN_CATEGORIES.sole.expenses);
|
|
11963
|
+
var loss = this.sole.items.sumByCategories(TAX_RETURN_CATEGORIES.sole.loss);
|
|
11964
|
+
return income + expenses + depreciation - loss;
|
|
11872
11965
|
},
|
|
11873
11966
|
enumerable: false,
|
|
11874
11967
|
configurable: true
|
|
@@ -12297,8 +12390,9 @@
|
|
|
12297
12390
|
return _this;
|
|
12298
12391
|
}
|
|
12299
12392
|
SoleInvoiceService.prototype.updateStatus = function (invoice, status) {
|
|
12393
|
+
var updatedInvoice = Object.assign({}, invoice, { status: status });
|
|
12300
12394
|
// use id only to avoid unexpected changes
|
|
12301
|
-
return this.update(
|
|
12395
|
+
return this.update(updatedInvoice);
|
|
12302
12396
|
};
|
|
12303
12397
|
SoleInvoiceService.prototype.publish = function (invoice, document) {
|
|
12304
12398
|
// use id only to avoid unexpected changes
|
|
@@ -19201,13 +19295,13 @@
|
|
|
19201
19295
|
return MyTaxInterestForm;
|
|
19202
19296
|
}(AbstractForm));
|
|
19203
19297
|
|
|
19204
|
-
/**
|
|
19205
|
-
* @Todo waiting for Sole tank implementation
|
|
19206
|
-
*/
|
|
19207
19298
|
var MyTaxLossesForm = /** @class */ (function (_super) {
|
|
19208
19299
|
__extends(MyTaxLossesForm, _super);
|
|
19209
19300
|
function MyTaxLossesForm(losses) {
|
|
19210
|
-
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;
|
|
19211
19305
|
}
|
|
19212
19306
|
return MyTaxLossesForm;
|
|
19213
19307
|
}(AbstractForm));
|
|
@@ -19736,6 +19830,7 @@
|
|
|
19736
19830
|
exports.SoleBusinessLossOffsetRuleService = SoleBusinessLossOffsetRuleService;
|
|
19737
19831
|
exports.SoleBusinessLossReport = SoleBusinessLossReport;
|
|
19738
19832
|
exports.SoleBusinessLossService = SoleBusinessLossService;
|
|
19833
|
+
exports.SoleBusinessLossesCollection = SoleBusinessLossesCollection;
|
|
19739
19834
|
exports.SoleBusinessService = SoleBusinessService;
|
|
19740
19835
|
exports.SoleContact = SoleContact;
|
|
19741
19836
|
exports.SoleContactForm = SoleContactForm;
|