taxtank-core 0.28.29 → 0.28.30
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 +483 -359
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/collection.js +23 -1
- package/esm2015/lib/collections/index.js +2 -1
- package/esm2015/lib/collections/tax-summary/tax-return-categories.const.js +6 -2
- package/esm2015/lib/collections/transaction/index.js +4 -0
- package/esm2015/lib/collections/transaction/transaction-base.collection.js +8 -0
- package/esm2015/lib/db/Models/sole/sole-business-loss-offset-rule.js +4 -0
- package/esm2015/lib/db/Models/sole/sole-business-loss.js +1 -1
- package/esm2015/lib/forms/sole/index.js +2 -1
- package/esm2015/lib/forms/sole/sole-business-loss.form.js +25 -0
- package/esm2015/lib/models/endpoint/endpoints.const.js +5 -2
- package/esm2015/lib/models/sole/index.js +2 -1
- package/esm2015/lib/models/sole/sole-business-loss-offset-rule.js +9 -0
- package/esm2015/lib/models/sole/sole-business-loss.js +12 -1
- package/esm2015/lib/models/tax-summary/tax-summary.js +1 -3
- package/esm2015/lib/services/http/sole/index.js +2 -1
- package/esm2015/lib/services/http/sole/sole-business-loss/sole-business-loss-rules/sole-business-loss-offset-rule.service.js +24 -0
- package/esm2015/public-api.js +1 -3
- package/fesm2015/taxtank-core.js +437 -341
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/collection.d.ts +7 -0
- package/lib/collections/index.d.ts +1 -0
- package/lib/collections/transaction/index.d.ts +3 -0
- package/lib/collections/transaction/transaction-base.collection.d.ts +6 -0
- package/lib/db/Models/sole/sole-business-loss-offset-rule.d.ts +7 -0
- package/lib/db/Models/sole/sole-business-loss.d.ts +2 -0
- package/lib/forms/sole/index.d.ts +1 -0
- package/lib/forms/sole/sole-business-loss.form.d.ts +11 -0
- package/lib/models/sole/index.d.ts +1 -0
- package/lib/models/sole/sole-business-loss-offset-rule.d.ts +4 -0
- package/lib/models/sole/sole-business-loss.d.ts +4 -0
- package/lib/models/tax-summary/tax-summary.d.ts +0 -2
- package/lib/services/http/sole/index.d.ts +1 -0
- package/lib/services/http/sole/sole-business-loss/sole-business-loss-rules/sole-business-loss-offset-rule.service.d.ts +13 -0
- package/package.json +1 -1
- package/public-api.d.ts +0 -2
|
@@ -1067,7 +1067,10 @@
|
|
|
1067
1067
|
SOLE_BUSINESSES_GET: new Endpoint('GET', '\\/sole-businesses'),
|
|
1068
1068
|
SOLE_BUSINESSES_POST: new Endpoint('POST', '\\/sole-businesses'),
|
|
1069
1069
|
SOLE_BUSINESSES_PUT: new Endpoint('PUT', '\\/sole-businesses\\/\\d+'),
|
|
1070
|
-
|
|
1070
|
+
SOLE_BUSINESS_LOSSES_GET: new Endpoint('GET', '\\/sole-business-losses'),
|
|
1071
|
+
SOLE_BUSINESS_LOSSES_POST: new Endpoint('POST', '\\/sole-business-losses'),
|
|
1072
|
+
SOLE_BUSINESS_LOSSES_PUT: new Endpoint('PUT', '\\/sole-business-losses\\/\\d+'),
|
|
1073
|
+
SOLE_BUSINESS_LOSS_OFFSET_RULES_GET: new Endpoint('GET', '\\/sole-business-loss-offset-rules'),
|
|
1071
1074
|
SOLE_CONTACTS_POST: new Endpoint('POST', '\\/sole-contacts'),
|
|
1072
1075
|
SOLE_CONTACTS_PUT: new Endpoint('PUT', '\\/sole-contacts\\/\\d+'),
|
|
1073
1076
|
BUSINESS_ACTIVITIES_GET: new Endpoint('GET', '\\/sole-business-activities'),
|
|
@@ -1815,6 +1818,10 @@
|
|
|
1815
1818
|
var Collection = /** @class */ (function () {
|
|
1816
1819
|
function Collection(items) {
|
|
1817
1820
|
if (items === void 0) { items = []; }
|
|
1821
|
+
/**
|
|
1822
|
+
* index of current item, used to iterate over the collection
|
|
1823
|
+
*/
|
|
1824
|
+
this.index = 0;
|
|
1818
1825
|
this.items = items;
|
|
1819
1826
|
}
|
|
1820
1827
|
/**
|
|
@@ -1851,6 +1858,24 @@
|
|
|
1851
1858
|
enumerable: false,
|
|
1852
1859
|
configurable: true
|
|
1853
1860
|
});
|
|
1861
|
+
Collection.prototype.reset = function () {
|
|
1862
|
+
this.index = 0;
|
|
1863
|
+
return this.items[this.index];
|
|
1864
|
+
};
|
|
1865
|
+
Collection.prototype.next = function () {
|
|
1866
|
+
if (this.index < this.length) {
|
|
1867
|
+
this.index++;
|
|
1868
|
+
return this.items[this.index];
|
|
1869
|
+
}
|
|
1870
|
+
return null;
|
|
1871
|
+
};
|
|
1872
|
+
Collection.prototype.back = function () {
|
|
1873
|
+
if (this.index > 0) {
|
|
1874
|
+
this.index--;
|
|
1875
|
+
return this.items[this.index];
|
|
1876
|
+
}
|
|
1877
|
+
return null;
|
|
1878
|
+
};
|
|
1854
1879
|
Collection.prototype.getIds = function () {
|
|
1855
1880
|
return this.items.map(function (item) { return item['id']; });
|
|
1856
1881
|
};
|
|
@@ -2717,16 +2742,47 @@
|
|
|
2717
2742
|
return SoleBusinessLoss;
|
|
2718
2743
|
}(AbstractModel));
|
|
2719
2744
|
|
|
2745
|
+
var SoleBusinessLossOffsetRule$1 = /** @class */ (function (_super) {
|
|
2746
|
+
__extends(SoleBusinessLossOffsetRule, _super);
|
|
2747
|
+
function SoleBusinessLossOffsetRule() {
|
|
2748
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2749
|
+
}
|
|
2750
|
+
return SoleBusinessLossOffsetRule;
|
|
2751
|
+
}(AbstractModel));
|
|
2752
|
+
|
|
2753
|
+
var SoleBusinessLossOffsetRule = /** @class */ (function (_super) {
|
|
2754
|
+
__extends(SoleBusinessLossOffsetRule, _super);
|
|
2755
|
+
function SoleBusinessLossOffsetRule() {
|
|
2756
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2757
|
+
}
|
|
2758
|
+
return SoleBusinessLossOffsetRule;
|
|
2759
|
+
}(SoleBusinessLossOffsetRule$1));
|
|
2760
|
+
__decorate([
|
|
2761
|
+
classTransformer.Type(function () { return SoleBusinessLossOffsetRule; })
|
|
2762
|
+
], SoleBusinessLossOffsetRule.prototype, "parent", void 0);
|
|
2763
|
+
|
|
2720
2764
|
var SoleBusinessLoss = /** @class */ (function (_super) {
|
|
2721
2765
|
__extends(SoleBusinessLoss, _super);
|
|
2722
2766
|
function SoleBusinessLoss() {
|
|
2723
|
-
|
|
2767
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
2768
|
+
_this.openBalance = 0;
|
|
2769
|
+
return _this;
|
|
2724
2770
|
}
|
|
2771
|
+
Object.defineProperty(SoleBusinessLoss.prototype, "hasOffset", {
|
|
2772
|
+
get: function () {
|
|
2773
|
+
return !!this.offsetRule;
|
|
2774
|
+
},
|
|
2775
|
+
enumerable: false,
|
|
2776
|
+
configurable: true
|
|
2777
|
+
});
|
|
2725
2778
|
return SoleBusinessLoss;
|
|
2726
2779
|
}(SoleBusinessLoss$1));
|
|
2727
2780
|
__decorate([
|
|
2728
2781
|
classTransformer.Type(function () { return SoleBusiness; })
|
|
2729
2782
|
], SoleBusinessLoss.prototype, "business", void 0);
|
|
2783
|
+
__decorate([
|
|
2784
|
+
classTransformer.Type(function () { return SoleBusinessLossOffsetRule; })
|
|
2785
|
+
], SoleBusinessLoss.prototype, "offsetRule", void 0);
|
|
2730
2786
|
|
|
2731
2787
|
var SoleInvoice$1 = /** @class */ (function (_super) {
|
|
2732
2788
|
__extends(SoleInvoice, _super);
|
|
@@ -7132,6 +7188,333 @@
|
|
|
7132
7188
|
return PropertyCategoryMovementCollection;
|
|
7133
7189
|
}(Collection));
|
|
7134
7190
|
|
|
7191
|
+
/**
|
|
7192
|
+
* Chart serie class: chart data item
|
|
7193
|
+
* @TODO consider rename to ChartSerieData
|
|
7194
|
+
*/
|
|
7195
|
+
var ChartSerie = /** @class */ (function () {
|
|
7196
|
+
function ChartSerie() {
|
|
7197
|
+
}
|
|
7198
|
+
return ChartSerie;
|
|
7199
|
+
}());
|
|
7200
|
+
|
|
7201
|
+
/**
|
|
7202
|
+
* Chart data class
|
|
7203
|
+
* @TODO consider rename to ChartSerie
|
|
7204
|
+
*/
|
|
7205
|
+
var ChartData = /** @class */ (function () {
|
|
7206
|
+
function ChartData() {
|
|
7207
|
+
}
|
|
7208
|
+
return ChartData;
|
|
7209
|
+
}());
|
|
7210
|
+
__decorate([
|
|
7211
|
+
classTransformer.Type(function () { return ChartSerie; })
|
|
7212
|
+
], ChartData.prototype, "data", void 0);
|
|
7213
|
+
|
|
7214
|
+
var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
|
|
7215
|
+
|
|
7216
|
+
/**
|
|
7217
|
+
* Collection of transactions
|
|
7218
|
+
*/
|
|
7219
|
+
var TransactionCollection = /** @class */ (function (_super) {
|
|
7220
|
+
__extends(TransactionCollection, _super);
|
|
7221
|
+
function TransactionCollection() {
|
|
7222
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
7223
|
+
}
|
|
7224
|
+
Object.defineProperty(TransactionCollection.prototype, "amount", {
|
|
7225
|
+
/**
|
|
7226
|
+
* Get total amount of all transactions in the collection
|
|
7227
|
+
*/
|
|
7228
|
+
get: function () {
|
|
7229
|
+
return +this.items.reduce(function (sum, transaction) { return sum + transaction.getNetAmount(); }, 0).toFixed(2);
|
|
7230
|
+
},
|
|
7231
|
+
enumerable: false,
|
|
7232
|
+
configurable: true
|
|
7233
|
+
});
|
|
7234
|
+
/**
|
|
7235
|
+
* Difference between allocated amount and total amount
|
|
7236
|
+
*/
|
|
7237
|
+
TransactionCollection.prototype.getUnallocatedAmount = function (allocations) {
|
|
7238
|
+
return +(this.amount - allocations.getByTransactionsIds(this.getIds()).amount).toFixed(2);
|
|
7239
|
+
};
|
|
7240
|
+
Object.defineProperty(TransactionCollection.prototype, "cashPosition", {
|
|
7241
|
+
/**
|
|
7242
|
+
* Get cash position
|
|
7243
|
+
* Cash Position = Income - Expenses
|
|
7244
|
+
* Cash position is equal to Total Amount because income is positive and expense is negative,
|
|
7245
|
+
*/
|
|
7246
|
+
get: function () {
|
|
7247
|
+
return this.claimAmount;
|
|
7248
|
+
},
|
|
7249
|
+
enumerable: false,
|
|
7250
|
+
configurable: true
|
|
7251
|
+
});
|
|
7252
|
+
/**
|
|
7253
|
+
* get date of the last transaction
|
|
7254
|
+
*/
|
|
7255
|
+
TransactionCollection.prototype.getLastTransactionDate = function () {
|
|
7256
|
+
return new Date(Math.max.apply(Math, this.items.map(function (transaction) { return transaction.date; })));
|
|
7257
|
+
};
|
|
7258
|
+
Object.defineProperty(TransactionCollection.prototype, "claimAmount", {
|
|
7259
|
+
/**
|
|
7260
|
+
* Get summary of claim amounts
|
|
7261
|
+
*/
|
|
7262
|
+
get: function () {
|
|
7263
|
+
return this.items.reduce(function (sum, transaction) { return sum + transaction.claimAmount; }, 0);
|
|
7264
|
+
},
|
|
7265
|
+
enumerable: false,
|
|
7266
|
+
configurable: true
|
|
7267
|
+
});
|
|
7268
|
+
Object.defineProperty(TransactionCollection.prototype, "grossAmount", {
|
|
7269
|
+
get: function () {
|
|
7270
|
+
return +this.items.reduce(function (sum, transaction) { return sum + transaction.amount; }, 0).toFixed(2);
|
|
7271
|
+
},
|
|
7272
|
+
enumerable: false,
|
|
7273
|
+
configurable: true
|
|
7274
|
+
});
|
|
7275
|
+
TransactionCollection.prototype.getByChartAccountsCategories = function (categories) {
|
|
7276
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return categories.includes(transaction.chartAccounts.category); }));
|
|
7277
|
+
};
|
|
7278
|
+
/**
|
|
7279
|
+
* Get transactions by month
|
|
7280
|
+
* @param monthIndex by which desired month should be taken
|
|
7281
|
+
*/
|
|
7282
|
+
TransactionCollection.prototype.getByMonth = function (monthIndex) {
|
|
7283
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.date.getMonth() === monthIndex; }));
|
|
7284
|
+
};
|
|
7285
|
+
/**
|
|
7286
|
+
* Get collection of transactions metadata
|
|
7287
|
+
*/
|
|
7288
|
+
TransactionCollection.prototype.getTransactionsMetadata = function () {
|
|
7289
|
+
var metadataArray = [];
|
|
7290
|
+
this.items.forEach(function (transaction) {
|
|
7291
|
+
metadataArray.push.apply(metadataArray, __spreadArray([], __read(transaction.metadata)));
|
|
7292
|
+
});
|
|
7293
|
+
return new Collection(metadataArray);
|
|
7294
|
+
};
|
|
7295
|
+
TransactionCollection.prototype.getIncomeTransactions = function () {
|
|
7296
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isIncome(); }));
|
|
7297
|
+
};
|
|
7298
|
+
Object.defineProperty(TransactionCollection.prototype, "claimIncome", {
|
|
7299
|
+
get: function () {
|
|
7300
|
+
return this.getIncomeTransactions().claimAmount;
|
|
7301
|
+
},
|
|
7302
|
+
enumerable: false,
|
|
7303
|
+
configurable: true
|
|
7304
|
+
});
|
|
7305
|
+
TransactionCollection.prototype.getExpenseTransactions = function () {
|
|
7306
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isExpense() && !transaction.isInterest(); }));
|
|
7307
|
+
};
|
|
7308
|
+
Object.defineProperty(TransactionCollection.prototype, "claimExpense", {
|
|
7309
|
+
get: function () {
|
|
7310
|
+
return this.getExpenseTransactions().claimAmount;
|
|
7311
|
+
},
|
|
7312
|
+
enumerable: false,
|
|
7313
|
+
configurable: true
|
|
7314
|
+
});
|
|
7315
|
+
TransactionCollection.prototype.getInterestTransactions = function () {
|
|
7316
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isInterest(); }));
|
|
7317
|
+
};
|
|
7318
|
+
Object.defineProperty(TransactionCollection.prototype, "claimInterest", {
|
|
7319
|
+
get: function () {
|
|
7320
|
+
return this.getInterestTransactions().claimAmount;
|
|
7321
|
+
},
|
|
7322
|
+
enumerable: false,
|
|
7323
|
+
configurable: true
|
|
7324
|
+
});
|
|
7325
|
+
/**
|
|
7326
|
+
* Get collection of transactions and properties filtered by properties ids
|
|
7327
|
+
* @param ids Ids of properties for filter
|
|
7328
|
+
*/
|
|
7329
|
+
TransactionCollection.prototype.getByPropertiesIds = function (ids) {
|
|
7330
|
+
return new TransactionCollection(this.items.filter(function (transaction) {
|
|
7331
|
+
var _a;
|
|
7332
|
+
return ids.includes((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id);
|
|
7333
|
+
}));
|
|
7334
|
+
};
|
|
7335
|
+
/**
|
|
7336
|
+
* Get new collection filtered by income source id
|
|
7337
|
+
* @param id id of income source for filter
|
|
7338
|
+
*/
|
|
7339
|
+
TransactionCollection.prototype.getByIncomeSourceId = function (id) {
|
|
7340
|
+
return new TransactionCollection(this.items.filter(function (transaction) { var _a; return ((_a = transaction.incomeSource) === null || _a === void 0 ? void 0 : _a.id) === id; }));
|
|
7341
|
+
};
|
|
7342
|
+
/**
|
|
7343
|
+
* Get new collection filtered by chart accounts category
|
|
7344
|
+
* @param category Chart accounts category value
|
|
7345
|
+
*/
|
|
7346
|
+
TransactionCollection.prototype.getByChartAccountsCategory = function (category) {
|
|
7347
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.chartAccounts.category === category; }));
|
|
7348
|
+
};
|
|
7349
|
+
/**
|
|
7350
|
+
* Get new collection of property transactions
|
|
7351
|
+
*/
|
|
7352
|
+
TransactionCollection.prototype.getPropertyTransactions = function () {
|
|
7353
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isPropertyTank(); }));
|
|
7354
|
+
};
|
|
7355
|
+
TransactionCollection.prototype.getDebitTransactions = function () {
|
|
7356
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isDebit(); }));
|
|
7357
|
+
};
|
|
7358
|
+
TransactionCollection.prototype.getCreditTransactions = function () {
|
|
7359
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isCredit(); }));
|
|
7360
|
+
};
|
|
7361
|
+
TransactionCollection.prototype.getByAllocations = function (allocations) {
|
|
7362
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return allocations.hasTransaction(transaction); }));
|
|
7363
|
+
};
|
|
7364
|
+
/**
|
|
7365
|
+
* Get transactions related to Vehicle category
|
|
7366
|
+
*/
|
|
7367
|
+
TransactionCollection.prototype.getVehicleTransactions = function () {
|
|
7368
|
+
return this.create(this.items.filter(function (transaction) {
|
|
7369
|
+
return transaction.isVehicleTransaction();
|
|
7370
|
+
}));
|
|
7371
|
+
};
|
|
7372
|
+
/**
|
|
7373
|
+
* Get new transaction collection filtered by tank type
|
|
7374
|
+
*/
|
|
7375
|
+
TransactionCollection.prototype.getByTankType = function (tankType) {
|
|
7376
|
+
return this.create(this.items.filter(function (transaction) {
|
|
7377
|
+
switch (tankType) {
|
|
7378
|
+
case exports.TankTypeEnum.PROPERTY:
|
|
7379
|
+
return transaction.isPropertyTank();
|
|
7380
|
+
case exports.TankTypeEnum.WORK:
|
|
7381
|
+
return transaction.isWorkTank();
|
|
7382
|
+
case exports.TankTypeEnum.SOLE:
|
|
7383
|
+
return transaction.isSoleTank();
|
|
7384
|
+
// Transaction may be not related to any tank type (personal)
|
|
7385
|
+
default:
|
|
7386
|
+
return false;
|
|
7387
|
+
}
|
|
7388
|
+
}));
|
|
7389
|
+
};
|
|
7390
|
+
TransactionCollection.prototype.getExportHeader = function () {
|
|
7391
|
+
return ['Date', 'Description', 'Debit', 'Credit'];
|
|
7392
|
+
};
|
|
7393
|
+
TransactionCollection.prototype.getExportFooter = function () {
|
|
7394
|
+
return [
|
|
7395
|
+
classTransformer.plainToClass(ExportCell, { value: 'Total', type: ExportCellTypeEnum.STRING }),
|
|
7396
|
+
classTransformer.plainToClass(ExportCell, { value: '', type: ExportCellTypeEnum.STRING }),
|
|
7397
|
+
classTransformer.plainToClass(ExportCell, { value: this.sumBy('debit'), type: ExportCellTypeEnum.CURRENCY }),
|
|
7398
|
+
classTransformer.plainToClass(ExportCell, { value: this.sumBy('credit'), type: ExportCellTypeEnum.CURRENCY })
|
|
7399
|
+
];
|
|
7400
|
+
};
|
|
7401
|
+
TransactionCollection.prototype.getExportBody = function () {
|
|
7402
|
+
return this.items.map(function (transaction) {
|
|
7403
|
+
return [
|
|
7404
|
+
classTransformer.plainToClass(ExportCell, { value: transaction.date, type: ExportCellTypeEnum.DATE }),
|
|
7405
|
+
classTransformer.plainToClass(ExportCell, { value: transaction.description, type: ExportCellTypeEnum.STRING }),
|
|
7406
|
+
classTransformer.plainToClass(ExportCell, { value: transaction.debit, type: ExportCellTypeEnum.CURRENCY }),
|
|
7407
|
+
classTransformer.plainToClass(ExportCell, { value: transaction.credit, type: ExportCellTypeEnum.CURRENCY })
|
|
7408
|
+
];
|
|
7409
|
+
});
|
|
7410
|
+
};
|
|
7411
|
+
/**
|
|
7412
|
+
* Get list of vehicle transactions filtered by vehicle claim
|
|
7413
|
+
*/
|
|
7414
|
+
TransactionCollection.prototype.getByVehicleClaim = function (vehicleClaim) {
|
|
7415
|
+
if (!vehicleClaim) {
|
|
7416
|
+
return this.create([]);
|
|
7417
|
+
}
|
|
7418
|
+
return vehicleClaim.isSoleTank()
|
|
7419
|
+
// sole tank may have multiple vehicle claims, so we need to filter by business.id
|
|
7420
|
+
? this.getVehicleTransactions().filterBy('business.id', vehicleClaim.business.id)
|
|
7421
|
+
// work tank may have only one vehicle claim, so we need to filter by tank type
|
|
7422
|
+
: this.getVehicleTransactions().filterBy('tankType', exports.TankTypeEnum.WORK);
|
|
7423
|
+
};
|
|
7424
|
+
/**
|
|
7425
|
+
* Get list of vehicle transactions except KMS transactions
|
|
7426
|
+
*/
|
|
7427
|
+
TransactionCollection.prototype.getLogbookTransactions = function () {
|
|
7428
|
+
return this
|
|
7429
|
+
.getVehicleTransactions()
|
|
7430
|
+
.removeBy('chartAccounts.id', [exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK, exports.ChartAccountsListEnum.KLMS_TRAVELLED]);
|
|
7431
|
+
};
|
|
7432
|
+
/**
|
|
7433
|
+
* Build chart data with transactions cash position.
|
|
7434
|
+
* Cash position = Income - Expenses (include depreciations)
|
|
7435
|
+
* Chart data for each month from fin year start till current month
|
|
7436
|
+
*/
|
|
7437
|
+
TransactionCollection.prototype.getCashPositionChartData = function () {
|
|
7438
|
+
var _this = this;
|
|
7439
|
+
var chartData = [
|
|
7440
|
+
classTransformer.plainToClass(ChartData, { name: 'Income', data: [] }),
|
|
7441
|
+
classTransformer.plainToClass(ChartData, { name: 'Expense', data: [] })
|
|
7442
|
+
];
|
|
7443
|
+
new FinancialYear().getPastMonths().forEach(function (month) {
|
|
7444
|
+
chartData[0].data.push({
|
|
7445
|
+
label: MONTHS[month],
|
|
7446
|
+
value: _this.getIncomeTransactions().getByMonth(month).claimAmount
|
|
7447
|
+
});
|
|
7448
|
+
chartData[1].data.push({
|
|
7449
|
+
label: MONTHS[month],
|
|
7450
|
+
value: Math.abs(_this.getExpenseTransactions().getByMonth(month).claimAmount)
|
|
7451
|
+
});
|
|
7452
|
+
});
|
|
7453
|
+
return chartData;
|
|
7454
|
+
};
|
|
7455
|
+
return TransactionCollection;
|
|
7456
|
+
}(ExportableCollection));
|
|
7457
|
+
|
|
7458
|
+
var TransactionAllocationCollection = /** @class */ (function (_super) {
|
|
7459
|
+
__extends(TransactionAllocationCollection, _super);
|
|
7460
|
+
function TransactionAllocationCollection() {
|
|
7461
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
7462
|
+
}
|
|
7463
|
+
Object.defineProperty(TransactionAllocationCollection.prototype, "amount", {
|
|
7464
|
+
get: function () {
|
|
7465
|
+
return this.sumBy('amount');
|
|
7466
|
+
},
|
|
7467
|
+
enumerable: false,
|
|
7468
|
+
configurable: true
|
|
7469
|
+
});
|
|
7470
|
+
TransactionAllocationCollection.prototype.getByTransactionsIds = function (ids) {
|
|
7471
|
+
return new TransactionAllocationCollection(this.items.filter(function (allocation) { return ids.includes(allocation.transaction.id); }));
|
|
7472
|
+
};
|
|
7473
|
+
TransactionAllocationCollection.prototype.getByBankTransactionsIds = function (ids) {
|
|
7474
|
+
return new TransactionAllocationCollection(this.items.filter(function (allocation) { return ids.includes(allocation.bankTransaction.id); }));
|
|
7475
|
+
};
|
|
7476
|
+
/**
|
|
7477
|
+
* Group allocations by bank account via bank transactions collection
|
|
7478
|
+
*/
|
|
7479
|
+
TransactionAllocationCollection.prototype.groupByBankAccount = function (bankTransactions) {
|
|
7480
|
+
var _this = this;
|
|
7481
|
+
// Group bank transactions by bank account id
|
|
7482
|
+
var bankTransactionsByBankAccount = new CollectionDictionary(bankTransactions, 'bankAccount.id');
|
|
7483
|
+
// Create empty dictionary of transaction allocations
|
|
7484
|
+
var allocationsByBankAccount = new CollectionDictionary(new TransactionAllocationCollection([]));
|
|
7485
|
+
// Fill allocations dictionary with bank transactions dictionary keys and allocations related with each bank transaction collection
|
|
7486
|
+
bankTransactionsByBankAccount.keys.forEach(function (key) {
|
|
7487
|
+
allocationsByBankAccount.add(key, _this.getByBankTransactionsIds(bankTransactionsByBankAccount.get(key).getIds()));
|
|
7488
|
+
});
|
|
7489
|
+
return allocationsByBankAccount;
|
|
7490
|
+
};
|
|
7491
|
+
/**
|
|
7492
|
+
* check if collection includes allocation of passed transaction
|
|
7493
|
+
*/
|
|
7494
|
+
TransactionAllocationCollection.prototype.hasTransaction = function (transaction) {
|
|
7495
|
+
return !!this.items.find(function (allocation) { return allocation.transaction.id === transaction.id; });
|
|
7496
|
+
};
|
|
7497
|
+
/**
|
|
7498
|
+
* Check if bank transaction is related with current allocations
|
|
7499
|
+
*/
|
|
7500
|
+
TransactionAllocationCollection.prototype.hasBankTransaction = function (bankTransaction) {
|
|
7501
|
+
return !!this.items.find(function (allocation) { return allocation.bankTransaction.id === bankTransaction.id; });
|
|
7502
|
+
};
|
|
7503
|
+
return TransactionAllocationCollection;
|
|
7504
|
+
}(Collection));
|
|
7505
|
+
|
|
7506
|
+
var TransactionBaseCollection = /** @class */ (function (_super) {
|
|
7507
|
+
__extends(TransactionBaseCollection, _super);
|
|
7508
|
+
function TransactionBaseCollection() {
|
|
7509
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
7510
|
+
}
|
|
7511
|
+
TransactionBaseCollection.prototype.getClaimAmountByBusiness = function (business) {
|
|
7512
|
+
return this.filterBy('business.id', business.id)
|
|
7513
|
+
.sumBy('claimAmount');
|
|
7514
|
+
};
|
|
7515
|
+
return TransactionBaseCollection;
|
|
7516
|
+
}(Collection));
|
|
7517
|
+
|
|
7135
7518
|
// @TODO Alex move here all collections
|
|
7136
7519
|
|
|
7137
7520
|
var AccountSetupItemCollection = /** @class */ (function (_super) {
|
|
@@ -7497,330 +7880,63 @@
|
|
|
7497
7880
|
}
|
|
7498
7881
|
Object.defineProperty(ClientPortfolioReportCollection.prototype, "marketValue", {
|
|
7499
7882
|
get: function () {
|
|
7500
|
-
return this.sumBy('marketValue');
|
|
7501
|
-
},
|
|
7502
|
-
enumerable: false,
|
|
7503
|
-
configurable: true
|
|
7504
|
-
});
|
|
7505
|
-
Object.defineProperty(ClientPortfolioReportCollection.prototype, "loanBalance", {
|
|
7506
|
-
get: function () {
|
|
7507
|
-
return this.sumBy('loanBalance');
|
|
7508
|
-
},
|
|
7509
|
-
enumerable: false,
|
|
7510
|
-
configurable: true
|
|
7511
|
-
});
|
|
7512
|
-
Object.defineProperty(ClientPortfolioReportCollection.prototype, "equityPosition", {
|
|
7513
|
-
get: function () {
|
|
7514
|
-
return this.sumBy('equityPosition');
|
|
7515
|
-
},
|
|
7516
|
-
enumerable: false,
|
|
7517
|
-
configurable: true
|
|
7518
|
-
});
|
|
7519
|
-
Object.defineProperty(ClientPortfolioReportCollection.prototype, "averageMarketValue", {
|
|
7520
|
-
/**
|
|
7521
|
-
* Get average market value if there are more than 1 item in the collection
|
|
7522
|
-
*/
|
|
7523
|
-
get: function () {
|
|
7524
|
-
return this.items.length > 1 ? this.marketValue / this.items.length : null;
|
|
7525
|
-
},
|
|
7526
|
-
enumerable: false,
|
|
7527
|
-
configurable: true
|
|
7528
|
-
});
|
|
7529
|
-
Object.defineProperty(ClientPortfolioReportCollection.prototype, "averageLoanBalance", {
|
|
7530
|
-
/**
|
|
7531
|
-
* Get average loan balance if there are more than 1 item in the collection
|
|
7532
|
-
*/
|
|
7533
|
-
get: function () {
|
|
7534
|
-
return this.items.length > 1 ? this.loanBalance / this.items.length : null;
|
|
7535
|
-
},
|
|
7536
|
-
enumerable: false,
|
|
7537
|
-
configurable: true
|
|
7538
|
-
});
|
|
7539
|
-
Object.defineProperty(ClientPortfolioReportCollection.prototype, "averageEquityPosition", {
|
|
7540
|
-
/**
|
|
7541
|
-
* Get average equity position if there are more than 1 item in the collection
|
|
7542
|
-
*/
|
|
7543
|
-
get: function () {
|
|
7544
|
-
return this.items.length > 1 ? this.equityPosition / this.items.length : null;
|
|
7545
|
-
},
|
|
7546
|
-
enumerable: false,
|
|
7547
|
-
configurable: true
|
|
7548
|
-
});
|
|
7549
|
-
/**
|
|
7550
|
-
* Return report by provided category name
|
|
7551
|
-
*/
|
|
7552
|
-
ClientPortfolioReportCollection.prototype.getByCategoryName = function (name) {
|
|
7553
|
-
return this.items.find(function (item) { return item.category === name; });
|
|
7554
|
-
};
|
|
7555
|
-
return ClientPortfolioReportCollection;
|
|
7556
|
-
}(Collection));
|
|
7557
|
-
|
|
7558
|
-
/**
|
|
7559
|
-
* Chart serie class: chart data item
|
|
7560
|
-
* @TODO consider rename to ChartSerieData
|
|
7561
|
-
*/
|
|
7562
|
-
var ChartSerie = /** @class */ (function () {
|
|
7563
|
-
function ChartSerie() {
|
|
7564
|
-
}
|
|
7565
|
-
return ChartSerie;
|
|
7566
|
-
}());
|
|
7567
|
-
|
|
7568
|
-
/**
|
|
7569
|
-
* Chart data class
|
|
7570
|
-
* @TODO consider rename to ChartSerie
|
|
7571
|
-
*/
|
|
7572
|
-
var ChartData = /** @class */ (function () {
|
|
7573
|
-
function ChartData() {
|
|
7574
|
-
}
|
|
7575
|
-
return ChartData;
|
|
7576
|
-
}());
|
|
7577
|
-
__decorate([
|
|
7578
|
-
classTransformer.Type(function () { return ChartSerie; })
|
|
7579
|
-
], ChartData.prototype, "data", void 0);
|
|
7580
|
-
|
|
7581
|
-
var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
|
|
7582
|
-
|
|
7583
|
-
/**
|
|
7584
|
-
* Collection of transactions
|
|
7585
|
-
*/
|
|
7586
|
-
var TransactionCollection = /** @class */ (function (_super) {
|
|
7587
|
-
__extends(TransactionCollection, _super);
|
|
7588
|
-
function TransactionCollection() {
|
|
7589
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
7590
|
-
}
|
|
7591
|
-
Object.defineProperty(TransactionCollection.prototype, "amount", {
|
|
7592
|
-
/**
|
|
7593
|
-
* Get total amount of all transactions in the collection
|
|
7594
|
-
*/
|
|
7595
|
-
get: function () {
|
|
7596
|
-
return +this.items.reduce(function (sum, transaction) { return sum + transaction.getNetAmount(); }, 0).toFixed(2);
|
|
7597
|
-
},
|
|
7598
|
-
enumerable: false,
|
|
7599
|
-
configurable: true
|
|
7600
|
-
});
|
|
7601
|
-
/**
|
|
7602
|
-
* Difference between allocated amount and total amount
|
|
7603
|
-
*/
|
|
7604
|
-
TransactionCollection.prototype.getUnallocatedAmount = function (allocations) {
|
|
7605
|
-
return +(this.amount - allocations.getByTransactionsIds(this.getIds()).amount).toFixed(2);
|
|
7606
|
-
};
|
|
7607
|
-
Object.defineProperty(TransactionCollection.prototype, "cashPosition", {
|
|
7608
|
-
/**
|
|
7609
|
-
* Get cash position
|
|
7610
|
-
* Cash Position = Income - Expenses
|
|
7611
|
-
* Cash position is equal to Total Amount because income is positive and expense is negative,
|
|
7612
|
-
*/
|
|
7613
|
-
get: function () {
|
|
7614
|
-
return this.claimAmount;
|
|
7615
|
-
},
|
|
7616
|
-
enumerable: false,
|
|
7617
|
-
configurable: true
|
|
7618
|
-
});
|
|
7619
|
-
/**
|
|
7620
|
-
* get date of the last transaction
|
|
7621
|
-
*/
|
|
7622
|
-
TransactionCollection.prototype.getLastTransactionDate = function () {
|
|
7623
|
-
return new Date(Math.max.apply(Math, this.items.map(function (transaction) { return transaction.date; })));
|
|
7624
|
-
};
|
|
7625
|
-
Object.defineProperty(TransactionCollection.prototype, "claimAmount", {
|
|
7626
|
-
/**
|
|
7627
|
-
* Get summary of claim amounts
|
|
7628
|
-
*/
|
|
7629
|
-
get: function () {
|
|
7630
|
-
return this.items.reduce(function (sum, transaction) { return sum + transaction.claimAmount; }, 0);
|
|
7631
|
-
},
|
|
7632
|
-
enumerable: false,
|
|
7633
|
-
configurable: true
|
|
7634
|
-
});
|
|
7635
|
-
Object.defineProperty(TransactionCollection.prototype, "grossAmount", {
|
|
7636
|
-
get: function () {
|
|
7637
|
-
return +this.items.reduce(function (sum, transaction) { return sum + transaction.amount; }, 0).toFixed(2);
|
|
7638
|
-
},
|
|
7639
|
-
enumerable: false,
|
|
7640
|
-
configurable: true
|
|
7641
|
-
});
|
|
7642
|
-
TransactionCollection.prototype.getByChartAccountsCategories = function (categories) {
|
|
7643
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return categories.includes(transaction.chartAccounts.category); }));
|
|
7644
|
-
};
|
|
7645
|
-
/**
|
|
7646
|
-
* Get transactions by month
|
|
7647
|
-
* @param monthIndex by which desired month should be taken
|
|
7648
|
-
*/
|
|
7649
|
-
TransactionCollection.prototype.getByMonth = function (monthIndex) {
|
|
7650
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.date.getMonth() === monthIndex; }));
|
|
7651
|
-
};
|
|
7652
|
-
/**
|
|
7653
|
-
* Get collection of transactions metadata
|
|
7654
|
-
*/
|
|
7655
|
-
TransactionCollection.prototype.getTransactionsMetadata = function () {
|
|
7656
|
-
var metadataArray = [];
|
|
7657
|
-
this.items.forEach(function (transaction) {
|
|
7658
|
-
metadataArray.push.apply(metadataArray, __spreadArray([], __read(transaction.metadata)));
|
|
7659
|
-
});
|
|
7660
|
-
return new Collection(metadataArray);
|
|
7661
|
-
};
|
|
7662
|
-
TransactionCollection.prototype.getIncomeTransactions = function () {
|
|
7663
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isIncome(); }));
|
|
7664
|
-
};
|
|
7665
|
-
Object.defineProperty(TransactionCollection.prototype, "claimIncome", {
|
|
7883
|
+
return this.sumBy('marketValue');
|
|
7884
|
+
},
|
|
7885
|
+
enumerable: false,
|
|
7886
|
+
configurable: true
|
|
7887
|
+
});
|
|
7888
|
+
Object.defineProperty(ClientPortfolioReportCollection.prototype, "loanBalance", {
|
|
7666
7889
|
get: function () {
|
|
7667
|
-
return this.
|
|
7890
|
+
return this.sumBy('loanBalance');
|
|
7668
7891
|
},
|
|
7669
7892
|
enumerable: false,
|
|
7670
7893
|
configurable: true
|
|
7671
7894
|
});
|
|
7672
|
-
|
|
7673
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isExpense() && !transaction.isInterest(); }));
|
|
7674
|
-
};
|
|
7675
|
-
Object.defineProperty(TransactionCollection.prototype, "claimExpense", {
|
|
7895
|
+
Object.defineProperty(ClientPortfolioReportCollection.prototype, "equityPosition", {
|
|
7676
7896
|
get: function () {
|
|
7677
|
-
return this.
|
|
7897
|
+
return this.sumBy('equityPosition');
|
|
7678
7898
|
},
|
|
7679
7899
|
enumerable: false,
|
|
7680
7900
|
configurable: true
|
|
7681
7901
|
});
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7902
|
+
Object.defineProperty(ClientPortfolioReportCollection.prototype, "averageMarketValue", {
|
|
7903
|
+
/**
|
|
7904
|
+
* Get average market value if there are more than 1 item in the collection
|
|
7905
|
+
*/
|
|
7686
7906
|
get: function () {
|
|
7687
|
-
return this.
|
|
7907
|
+
return this.items.length > 1 ? this.marketValue / this.items.length : null;
|
|
7908
|
+
},
|
|
7909
|
+
enumerable: false,
|
|
7910
|
+
configurable: true
|
|
7911
|
+
});
|
|
7912
|
+
Object.defineProperty(ClientPortfolioReportCollection.prototype, "averageLoanBalance", {
|
|
7913
|
+
/**
|
|
7914
|
+
* Get average loan balance if there are more than 1 item in the collection
|
|
7915
|
+
*/
|
|
7916
|
+
get: function () {
|
|
7917
|
+
return this.items.length > 1 ? this.loanBalance / this.items.length : null;
|
|
7918
|
+
},
|
|
7919
|
+
enumerable: false,
|
|
7920
|
+
configurable: true
|
|
7921
|
+
});
|
|
7922
|
+
Object.defineProperty(ClientPortfolioReportCollection.prototype, "averageEquityPosition", {
|
|
7923
|
+
/**
|
|
7924
|
+
* Get average equity position if there are more than 1 item in the collection
|
|
7925
|
+
*/
|
|
7926
|
+
get: function () {
|
|
7927
|
+
return this.items.length > 1 ? this.equityPosition / this.items.length : null;
|
|
7688
7928
|
},
|
|
7689
7929
|
enumerable: false,
|
|
7690
7930
|
configurable: true
|
|
7691
7931
|
});
|
|
7692
7932
|
/**
|
|
7693
|
-
*
|
|
7694
|
-
* @param ids Ids of properties for filter
|
|
7695
|
-
*/
|
|
7696
|
-
TransactionCollection.prototype.getByPropertiesIds = function (ids) {
|
|
7697
|
-
return new TransactionCollection(this.items.filter(function (transaction) {
|
|
7698
|
-
var _a;
|
|
7699
|
-
return ids.includes((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id);
|
|
7700
|
-
}));
|
|
7701
|
-
};
|
|
7702
|
-
/**
|
|
7703
|
-
* Get new collection filtered by income source id
|
|
7704
|
-
* @param id id of income source for filter
|
|
7705
|
-
*/
|
|
7706
|
-
TransactionCollection.prototype.getByIncomeSourceId = function (id) {
|
|
7707
|
-
return new TransactionCollection(this.items.filter(function (transaction) { var _a; return ((_a = transaction.incomeSource) === null || _a === void 0 ? void 0 : _a.id) === id; }));
|
|
7708
|
-
};
|
|
7709
|
-
/**
|
|
7710
|
-
* Get new collection filtered by chart accounts category
|
|
7711
|
-
* @param category Chart accounts category value
|
|
7712
|
-
*/
|
|
7713
|
-
TransactionCollection.prototype.getByChartAccountsCategory = function (category) {
|
|
7714
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.chartAccounts.category === category; }));
|
|
7715
|
-
};
|
|
7716
|
-
/**
|
|
7717
|
-
* Get new collection of property transactions
|
|
7718
|
-
*/
|
|
7719
|
-
TransactionCollection.prototype.getPropertyTransactions = function () {
|
|
7720
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isPropertyTank(); }));
|
|
7721
|
-
};
|
|
7722
|
-
TransactionCollection.prototype.getDebitTransactions = function () {
|
|
7723
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isDebit(); }));
|
|
7724
|
-
};
|
|
7725
|
-
TransactionCollection.prototype.getCreditTransactions = function () {
|
|
7726
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isCredit(); }));
|
|
7727
|
-
};
|
|
7728
|
-
TransactionCollection.prototype.getByAllocations = function (allocations) {
|
|
7729
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return allocations.hasTransaction(transaction); }));
|
|
7730
|
-
};
|
|
7731
|
-
/**
|
|
7732
|
-
* Get transactions related to Vehicle category
|
|
7733
|
-
*/
|
|
7734
|
-
TransactionCollection.prototype.getVehicleTransactions = function () {
|
|
7735
|
-
return this.create(this.items.filter(function (transaction) {
|
|
7736
|
-
return transaction.isVehicleTransaction();
|
|
7737
|
-
}));
|
|
7738
|
-
};
|
|
7739
|
-
/**
|
|
7740
|
-
* Get new transaction collection filtered by tank type
|
|
7741
|
-
*/
|
|
7742
|
-
TransactionCollection.prototype.getByTankType = function (tankType) {
|
|
7743
|
-
return this.create(this.items.filter(function (transaction) {
|
|
7744
|
-
switch (tankType) {
|
|
7745
|
-
case exports.TankTypeEnum.PROPERTY:
|
|
7746
|
-
return transaction.isPropertyTank();
|
|
7747
|
-
case exports.TankTypeEnum.WORK:
|
|
7748
|
-
return transaction.isWorkTank();
|
|
7749
|
-
case exports.TankTypeEnum.SOLE:
|
|
7750
|
-
return transaction.isSoleTank();
|
|
7751
|
-
// Transaction may be not related to any tank type (personal)
|
|
7752
|
-
default:
|
|
7753
|
-
return false;
|
|
7754
|
-
}
|
|
7755
|
-
}));
|
|
7756
|
-
};
|
|
7757
|
-
TransactionCollection.prototype.getExportHeader = function () {
|
|
7758
|
-
return ['Date', 'Description', 'Debit', 'Credit'];
|
|
7759
|
-
};
|
|
7760
|
-
TransactionCollection.prototype.getExportFooter = function () {
|
|
7761
|
-
return [
|
|
7762
|
-
classTransformer.plainToClass(ExportCell, { value: 'Total', type: ExportCellTypeEnum.STRING }),
|
|
7763
|
-
classTransformer.plainToClass(ExportCell, { value: '', type: ExportCellTypeEnum.STRING }),
|
|
7764
|
-
classTransformer.plainToClass(ExportCell, { value: this.sumBy('debit'), type: ExportCellTypeEnum.CURRENCY }),
|
|
7765
|
-
classTransformer.plainToClass(ExportCell, { value: this.sumBy('credit'), type: ExportCellTypeEnum.CURRENCY })
|
|
7766
|
-
];
|
|
7767
|
-
};
|
|
7768
|
-
TransactionCollection.prototype.getExportBody = function () {
|
|
7769
|
-
return this.items.map(function (transaction) {
|
|
7770
|
-
return [
|
|
7771
|
-
classTransformer.plainToClass(ExportCell, { value: transaction.date, type: ExportCellTypeEnum.DATE }),
|
|
7772
|
-
classTransformer.plainToClass(ExportCell, { value: transaction.description, type: ExportCellTypeEnum.STRING }),
|
|
7773
|
-
classTransformer.plainToClass(ExportCell, { value: transaction.debit, type: ExportCellTypeEnum.CURRENCY }),
|
|
7774
|
-
classTransformer.plainToClass(ExportCell, { value: transaction.credit, type: ExportCellTypeEnum.CURRENCY })
|
|
7775
|
-
];
|
|
7776
|
-
});
|
|
7777
|
-
};
|
|
7778
|
-
/**
|
|
7779
|
-
* Get list of vehicle transactions filtered by vehicle claim
|
|
7780
|
-
*/
|
|
7781
|
-
TransactionCollection.prototype.getByVehicleClaim = function (vehicleClaim) {
|
|
7782
|
-
if (!vehicleClaim) {
|
|
7783
|
-
return this.create([]);
|
|
7784
|
-
}
|
|
7785
|
-
return vehicleClaim.isSoleTank()
|
|
7786
|
-
// sole tank may have multiple vehicle claims, so we need to filter by business.id
|
|
7787
|
-
? this.getVehicleTransactions().filterBy('business.id', vehicleClaim.business.id)
|
|
7788
|
-
// work tank may have only one vehicle claim, so we need to filter by tank type
|
|
7789
|
-
: this.getVehicleTransactions().filterBy('tankType', exports.TankTypeEnum.WORK);
|
|
7790
|
-
};
|
|
7791
|
-
/**
|
|
7792
|
-
* Get list of vehicle transactions except KMS transactions
|
|
7793
|
-
*/
|
|
7794
|
-
TransactionCollection.prototype.getLogbookTransactions = function () {
|
|
7795
|
-
return this
|
|
7796
|
-
.getVehicleTransactions()
|
|
7797
|
-
.removeBy('chartAccounts.id', [exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK, exports.ChartAccountsListEnum.KLMS_TRAVELLED]);
|
|
7798
|
-
};
|
|
7799
|
-
/**
|
|
7800
|
-
* Build chart data with transactions cash position.
|
|
7801
|
-
* Cash position = Income - Expenses (include depreciations)
|
|
7802
|
-
* Chart data for each month from fin year start till current month
|
|
7933
|
+
* Return report by provided category name
|
|
7803
7934
|
*/
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
var chartData = [
|
|
7807
|
-
classTransformer.plainToClass(ChartData, { name: 'Income', data: [] }),
|
|
7808
|
-
classTransformer.plainToClass(ChartData, { name: 'Expense', data: [] })
|
|
7809
|
-
];
|
|
7810
|
-
new FinancialYear().getPastMonths().forEach(function (month) {
|
|
7811
|
-
chartData[0].data.push({
|
|
7812
|
-
label: MONTHS[month],
|
|
7813
|
-
value: _this.getIncomeTransactions().getByMonth(month).claimAmount
|
|
7814
|
-
});
|
|
7815
|
-
chartData[1].data.push({
|
|
7816
|
-
label: MONTHS[month],
|
|
7817
|
-
value: Math.abs(_this.getExpenseTransactions().getByMonth(month).claimAmount)
|
|
7818
|
-
});
|
|
7819
|
-
});
|
|
7820
|
-
return chartData;
|
|
7935
|
+
ClientPortfolioReportCollection.prototype.getByCategoryName = function (name) {
|
|
7936
|
+
return this.items.find(function (item) { return item.category === name; });
|
|
7821
7937
|
};
|
|
7822
|
-
return
|
|
7823
|
-
}(
|
|
7938
|
+
return ClientPortfolioReportCollection;
|
|
7939
|
+
}(Collection));
|
|
7824
7940
|
|
|
7825
7941
|
var DepreciationCollection = /** @class */ (function (_super) {
|
|
7826
7942
|
__extends(DepreciationCollection, _super);
|
|
@@ -8639,7 +8755,11 @@
|
|
|
8639
8755
|
exports.TaxReturnCategoryListEnum.DEPRECIATION_EXPENSES,
|
|
8640
8756
|
exports.TaxReturnCategoryListEnum.MOTOR_VEHICLE_EXPENSES,
|
|
8641
8757
|
exports.TaxReturnCategoryListEnum.ALL_OTHER_EXPENSES
|
|
8642
|
-
]
|
|
8758
|
+
],
|
|
8759
|
+
// @TODO TT-2386 Nikita to move sole tax offsets in separated category
|
|
8760
|
+
taxOffsets: [
|
|
8761
|
+
exports.TaxReturnCategoryListEnum.TAX_OFFSETS
|
|
8762
|
+
],
|
|
8643
8763
|
},
|
|
8644
8764
|
};
|
|
8645
8765
|
|
|
@@ -8701,54 +8821,6 @@
|
|
|
8701
8821
|
return TaxReviewCollection;
|
|
8702
8822
|
}(Collection));
|
|
8703
8823
|
|
|
8704
|
-
var TransactionAllocationCollection = /** @class */ (function (_super) {
|
|
8705
|
-
__extends(TransactionAllocationCollection, _super);
|
|
8706
|
-
function TransactionAllocationCollection() {
|
|
8707
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
8708
|
-
}
|
|
8709
|
-
Object.defineProperty(TransactionAllocationCollection.prototype, "amount", {
|
|
8710
|
-
get: function () {
|
|
8711
|
-
return this.sumBy('amount');
|
|
8712
|
-
},
|
|
8713
|
-
enumerable: false,
|
|
8714
|
-
configurable: true
|
|
8715
|
-
});
|
|
8716
|
-
TransactionAllocationCollection.prototype.getByTransactionsIds = function (ids) {
|
|
8717
|
-
return new TransactionAllocationCollection(this.items.filter(function (allocation) { return ids.includes(allocation.transaction.id); }));
|
|
8718
|
-
};
|
|
8719
|
-
TransactionAllocationCollection.prototype.getByBankTransactionsIds = function (ids) {
|
|
8720
|
-
return new TransactionAllocationCollection(this.items.filter(function (allocation) { return ids.includes(allocation.bankTransaction.id); }));
|
|
8721
|
-
};
|
|
8722
|
-
/**
|
|
8723
|
-
* Group allocations by bank account via bank transactions collection
|
|
8724
|
-
*/
|
|
8725
|
-
TransactionAllocationCollection.prototype.groupByBankAccount = function (bankTransactions) {
|
|
8726
|
-
var _this = this;
|
|
8727
|
-
// Group bank transactions by bank account id
|
|
8728
|
-
var bankTransactionsByBankAccount = new CollectionDictionary(bankTransactions, 'bankAccount.id');
|
|
8729
|
-
// Create empty dictionary of transaction allocations
|
|
8730
|
-
var allocationsByBankAccount = new CollectionDictionary(new TransactionAllocationCollection([]));
|
|
8731
|
-
// Fill allocations dictionary with bank transactions dictionary keys and allocations related with each bank transaction collection
|
|
8732
|
-
bankTransactionsByBankAccount.keys.forEach(function (key) {
|
|
8733
|
-
allocationsByBankAccount.add(key, _this.getByBankTransactionsIds(bankTransactionsByBankAccount.get(key).getIds()));
|
|
8734
|
-
});
|
|
8735
|
-
return allocationsByBankAccount;
|
|
8736
|
-
};
|
|
8737
|
-
/**
|
|
8738
|
-
* check if collection includes allocation of passed transaction
|
|
8739
|
-
*/
|
|
8740
|
-
TransactionAllocationCollection.prototype.hasTransaction = function (transaction) {
|
|
8741
|
-
return !!this.items.find(function (allocation) { return allocation.transaction.id === transaction.id; });
|
|
8742
|
-
};
|
|
8743
|
-
/**
|
|
8744
|
-
* Check if bank transaction is related with current allocations
|
|
8745
|
-
*/
|
|
8746
|
-
TransactionAllocationCollection.prototype.hasBankTransaction = function (bankTransaction) {
|
|
8747
|
-
return !!this.items.find(function (allocation) { return allocation.bankTransaction.id === bankTransaction.id; });
|
|
8748
|
-
};
|
|
8749
|
-
return TransactionAllocationCollection;
|
|
8750
|
-
}(Collection));
|
|
8751
|
-
|
|
8752
8824
|
/**
|
|
8753
8825
|
* Collection of user event settings
|
|
8754
8826
|
*/
|
|
@@ -11652,7 +11724,6 @@
|
|
|
11652
11724
|
});
|
|
11653
11725
|
Object.defineProperty(TaxSummary.prototype, "soleNetCash", {
|
|
11654
11726
|
/**
|
|
11655
|
-
* @TODO Nicole update documentation + check calculations
|
|
11656
11727
|
* Sole Net Cash = gross income – expenses
|
|
11657
11728
|
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/217677990/Dashboard+Main
|
|
11658
11729
|
*/
|
|
@@ -11666,7 +11737,6 @@
|
|
|
11666
11737
|
});
|
|
11667
11738
|
Object.defineProperty(TaxSummary.prototype, "soleNetTotal", {
|
|
11668
11739
|
/**
|
|
11669
|
-
* @TODO Nicole update documentation + check calculations
|
|
11670
11740
|
* Sole Net Total = Gross income - expenses
|
|
11671
11741
|
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/217677990/Dashboard+Main
|
|
11672
11742
|
*/
|
|
@@ -11921,6 +11991,29 @@
|
|
|
11921
11991
|
}]
|
|
11922
11992
|
}] });
|
|
11923
11993
|
|
|
11994
|
+
/**
|
|
11995
|
+
* @TODO vik replace with json when the final list is confirmed
|
|
11996
|
+
*/
|
|
11997
|
+
var SoleBusinessLossOffsetRuleService = /** @class */ (function (_super) {
|
|
11998
|
+
__extends(SoleBusinessLossOffsetRuleService, _super);
|
|
11999
|
+
function SoleBusinessLossOffsetRuleService() {
|
|
12000
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
12001
|
+
_this.modelClass = SoleBusinessLossOffsetRule;
|
|
12002
|
+
_this.url = 'sole-business-loss-offset-rules';
|
|
12003
|
+
_this.isHydra = true;
|
|
12004
|
+
return _this;
|
|
12005
|
+
}
|
|
12006
|
+
return SoleBusinessLossOffsetRuleService;
|
|
12007
|
+
}(RestService));
|
|
12008
|
+
SoleBusinessLossOffsetRuleService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessLossOffsetRuleService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
12009
|
+
SoleBusinessLossOffsetRuleService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessLossOffsetRuleService, providedIn: 'root' });
|
|
12010
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessLossOffsetRuleService, decorators: [{
|
|
12011
|
+
type: i0.Injectable,
|
|
12012
|
+
args: [{
|
|
12013
|
+
providedIn: 'root'
|
|
12014
|
+
}]
|
|
12015
|
+
}] });
|
|
12016
|
+
|
|
11924
12017
|
var SoleContactService = /** @class */ (function (_super) {
|
|
11925
12018
|
__extends(SoleContactService, _super);
|
|
11926
12019
|
function SoleContactService() {
|
|
@@ -17759,6 +17852,33 @@
|
|
|
17759
17852
|
return SoleBusinessAllocationsForm;
|
|
17760
17853
|
}(forms.FormArray));
|
|
17761
17854
|
|
|
17855
|
+
var SoleBusinessLossForm = /** @class */ (function (_super) {
|
|
17856
|
+
__extends(SoleBusinessLossForm, _super);
|
|
17857
|
+
function SoleBusinessLossForm(loss, balance) {
|
|
17858
|
+
var _this = this;
|
|
17859
|
+
var _a;
|
|
17860
|
+
_this = _super.call(this, {
|
|
17861
|
+
openBalance: new forms.FormControl(loss.openBalance, forms.Validators.required),
|
|
17862
|
+
offsetRule: new forms.FormControl((_a = loss.offsetRule) === null || _a === void 0 ? void 0 : _a.id),
|
|
17863
|
+
// sum of depreciations/transactions claim amount - openBalance
|
|
17864
|
+
balance: new forms.FormControl({ value: balance, disabled: true }),
|
|
17865
|
+
}, loss) || this;
|
|
17866
|
+
_this.loss = loss;
|
|
17867
|
+
_this.get('openBalance').valueChanges.subscribe(function (openBalance) {
|
|
17868
|
+
_this.get('balance').setValue(balance - openBalance);
|
|
17869
|
+
});
|
|
17870
|
+
return _this;
|
|
17871
|
+
}
|
|
17872
|
+
/**
|
|
17873
|
+
* radio buttons can't work with object
|
|
17874
|
+
* https://github.com/angular/components/issues/10495
|
|
17875
|
+
*/
|
|
17876
|
+
SoleBusinessLossForm.prototype.submit = function () {
|
|
17877
|
+
return _super.prototype.submit.call(this, { offsetRule: this.get('offsetRule').value ? { id: this.get('offsetRule').value } : null });
|
|
17878
|
+
};
|
|
17879
|
+
return SoleBusinessLossForm;
|
|
17880
|
+
}(AbstractForm));
|
|
17881
|
+
|
|
17762
17882
|
var SoleContactForm = /** @class */ (function (_super) {
|
|
17763
17883
|
__extends(SoleContactForm, _super);
|
|
17764
17884
|
function SoleContactForm(contact) {
|
|
@@ -19281,6 +19401,9 @@
|
|
|
19281
19401
|
exports.SoleBusinessAllocationsForm = SoleBusinessAllocationsForm;
|
|
19282
19402
|
exports.SoleBusinessForm = SoleBusinessForm;
|
|
19283
19403
|
exports.SoleBusinessLoss = SoleBusinessLoss;
|
|
19404
|
+
exports.SoleBusinessLossForm = SoleBusinessLossForm;
|
|
19405
|
+
exports.SoleBusinessLossOffsetRule = SoleBusinessLossOffsetRule;
|
|
19406
|
+
exports.SoleBusinessLossOffsetRuleService = SoleBusinessLossOffsetRuleService;
|
|
19284
19407
|
exports.SoleBusinessLossReport = SoleBusinessLossReport;
|
|
19285
19408
|
exports.SoleBusinessLossService = SoleBusinessLossService;
|
|
19286
19409
|
exports.SoleBusinessService = SoleBusinessService;
|
|
@@ -19325,6 +19448,7 @@
|
|
|
19325
19448
|
exports.TransactionAllocationCollection = TransactionAllocationCollection;
|
|
19326
19449
|
exports.TransactionAllocationService = TransactionAllocationService;
|
|
19327
19450
|
exports.TransactionBase = TransactionBase;
|
|
19451
|
+
exports.TransactionBaseCollection = TransactionBaseCollection;
|
|
19328
19452
|
exports.TransactionCalculationService = TransactionCalculationService;
|
|
19329
19453
|
exports.TransactionCollection = TransactionCollection;
|
|
19330
19454
|
exports.TransactionMetadata = TransactionMetadata;
|