taxtank-core 0.28.28 → 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 +587 -456
- 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 +6 -2
- package/esm2015/lib/models/service-subscription/service-subscription.js +7 -1
- 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 +444 -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/service-subscription/service-subscription.d.ts +4 -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
|
@@ -1051,6 +1051,7 @@
|
|
|
1051
1051
|
PROPERTIES_DOCUMENTS_PUT: new Endpoint('PUT', '\\/properties\\/documents\\/\\d+'),
|
|
1052
1052
|
PROPERTIES_DOCUMENTS_DELETE: new Endpoint('DELETE', '\\/properties\\/documents\\/\\d+'),
|
|
1053
1053
|
PROPERTIES_PHOTO_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/photo\.\*'),
|
|
1054
|
+
PROPERTIES_SALES_GET: new Endpoint('GET', '\\/properties\\/sales'),
|
|
1054
1055
|
PROPERTIES_SUGGESTIONS_GET: new Endpoint('GET', '/property\\/\\w+\\/v2\\/.*$'),
|
|
1055
1056
|
PROPERTIES_VALUATIONS_DOCUMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/valuations\\/\\d+\\/documents'),
|
|
1056
1057
|
PRORATION_COST_POST: new Endpoint('POST', '\\/subscriptions\\/proration-cost'),
|
|
@@ -1066,7 +1067,10 @@
|
|
|
1066
1067
|
SOLE_BUSINESSES_GET: new Endpoint('GET', '\\/sole-businesses'),
|
|
1067
1068
|
SOLE_BUSINESSES_POST: new Endpoint('POST', '\\/sole-businesses'),
|
|
1068
1069
|
SOLE_BUSINESSES_PUT: new Endpoint('PUT', '\\/sole-businesses\\/\\d+'),
|
|
1069
|
-
|
|
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'),
|
|
1070
1074
|
SOLE_CONTACTS_POST: new Endpoint('POST', '\\/sole-contacts'),
|
|
1071
1075
|
SOLE_CONTACTS_PUT: new Endpoint('PUT', '\\/sole-contacts\\/\\d+'),
|
|
1072
1076
|
BUSINESS_ACTIVITIES_GET: new Endpoint('GET', '\\/sole-business-activities'),
|
|
@@ -1814,6 +1818,10 @@
|
|
|
1814
1818
|
var Collection = /** @class */ (function () {
|
|
1815
1819
|
function Collection(items) {
|
|
1816
1820
|
if (items === void 0) { items = []; }
|
|
1821
|
+
/**
|
|
1822
|
+
* index of current item, used to iterate over the collection
|
|
1823
|
+
*/
|
|
1824
|
+
this.index = 0;
|
|
1817
1825
|
this.items = items;
|
|
1818
1826
|
}
|
|
1819
1827
|
/**
|
|
@@ -1850,6 +1858,24 @@
|
|
|
1850
1858
|
enumerable: false,
|
|
1851
1859
|
configurable: true
|
|
1852
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
|
+
};
|
|
1853
1879
|
Collection.prototype.getIds = function () {
|
|
1854
1880
|
return this.items.map(function (item) { return item['id']; });
|
|
1855
1881
|
};
|
|
@@ -2660,6 +2686,12 @@
|
|
|
2660
2686
|
ServiceSubscription.prototype.isPastDue = function () {
|
|
2661
2687
|
return this.status === exports.ServiceSubscriptionStatusEnum.PAST_DUE;
|
|
2662
2688
|
};
|
|
2689
|
+
/**
|
|
2690
|
+
* Check if current subscription has provided subscription item
|
|
2691
|
+
*/
|
|
2692
|
+
ServiceSubscription.prototype.hasItem = function (itemToCheck) {
|
|
2693
|
+
return !!this.items.find(function (item) { return item.price.id === itemToCheck.price.id; });
|
|
2694
|
+
};
|
|
2663
2695
|
return ServiceSubscription;
|
|
2664
2696
|
}(ServiceSubscription$1));
|
|
2665
2697
|
__decorate([
|
|
@@ -2710,16 +2742,47 @@
|
|
|
2710
2742
|
return SoleBusinessLoss;
|
|
2711
2743
|
}(AbstractModel));
|
|
2712
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
|
+
|
|
2713
2764
|
var SoleBusinessLoss = /** @class */ (function (_super) {
|
|
2714
2765
|
__extends(SoleBusinessLoss, _super);
|
|
2715
2766
|
function SoleBusinessLoss() {
|
|
2716
|
-
|
|
2767
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
2768
|
+
_this.openBalance = 0;
|
|
2769
|
+
return _this;
|
|
2717
2770
|
}
|
|
2771
|
+
Object.defineProperty(SoleBusinessLoss.prototype, "hasOffset", {
|
|
2772
|
+
get: function () {
|
|
2773
|
+
return !!this.offsetRule;
|
|
2774
|
+
},
|
|
2775
|
+
enumerable: false,
|
|
2776
|
+
configurable: true
|
|
2777
|
+
});
|
|
2718
2778
|
return SoleBusinessLoss;
|
|
2719
2779
|
}(SoleBusinessLoss$1));
|
|
2720
2780
|
__decorate([
|
|
2721
2781
|
classTransformer.Type(function () { return SoleBusiness; })
|
|
2722
2782
|
], SoleBusinessLoss.prototype, "business", void 0);
|
|
2783
|
+
__decorate([
|
|
2784
|
+
classTransformer.Type(function () { return SoleBusinessLossOffsetRule; })
|
|
2785
|
+
], SoleBusinessLoss.prototype, "offsetRule", void 0);
|
|
2723
2786
|
|
|
2724
2787
|
var SoleInvoice$1 = /** @class */ (function (_super) {
|
|
2725
2788
|
__extends(SoleInvoice, _super);
|
|
@@ -7125,156 +7188,483 @@
|
|
|
7125
7188
|
return PropertyCategoryMovementCollection;
|
|
7126
7189
|
}(Collection));
|
|
7127
7190
|
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
_this.sortBy('isCompleted', false);
|
|
7135
|
-
return _this;
|
|
7191
|
+
/**
|
|
7192
|
+
* Chart serie class: chart data item
|
|
7193
|
+
* @TODO consider rename to ChartSerieData
|
|
7194
|
+
*/
|
|
7195
|
+
var ChartSerie = /** @class */ (function () {
|
|
7196
|
+
function ChartSerie() {
|
|
7136
7197
|
}
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
};
|
|
7140
|
-
return AccountSetupItemCollection;
|
|
7141
|
-
}(Collection));
|
|
7198
|
+
return ChartSerie;
|
|
7199
|
+
}());
|
|
7142
7200
|
|
|
7143
7201
|
/**
|
|
7144
|
-
*
|
|
7202
|
+
* Chart data class
|
|
7203
|
+
* @TODO consider rename to ChartSerie
|
|
7145
7204
|
*/
|
|
7146
|
-
var
|
|
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
|
+
|
|
7147
7216
|
/**
|
|
7148
|
-
* Collection of
|
|
7149
|
-
* IMPORTANT: Create this collection based on bank transactions from TransactionAllocationService
|
|
7150
|
-
* @TODO find way to accept interface with allocation instead of bankTransaction to prevent wrong usage
|
|
7151
|
-
* because all amounts calculates with allocated amounts but not from bank transactions amounts.
|
|
7217
|
+
* Collection of transactions
|
|
7152
7218
|
*/
|
|
7153
|
-
var
|
|
7154
|
-
__extends(
|
|
7155
|
-
function
|
|
7219
|
+
var TransactionCollection = /** @class */ (function (_super) {
|
|
7220
|
+
__extends(TransactionCollection, _super);
|
|
7221
|
+
function TransactionCollection() {
|
|
7156
7222
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
7157
7223
|
}
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
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
|
+
});
|
|
7167
7234
|
/**
|
|
7168
|
-
*
|
|
7235
|
+
* Difference between allocated amount and total amount
|
|
7169
7236
|
*/
|
|
7170
|
-
|
|
7171
|
-
return
|
|
7237
|
+
TransactionCollection.prototype.getUnallocatedAmount = function (allocations) {
|
|
7238
|
+
return +(this.amount - allocations.getByTransactionsIds(this.getIds()).amount).toFixed(2);
|
|
7172
7239
|
};
|
|
7173
|
-
Object.defineProperty(
|
|
7240
|
+
Object.defineProperty(TransactionCollection.prototype, "cashPosition", {
|
|
7174
7241
|
/**
|
|
7175
|
-
*
|
|
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,
|
|
7176
7245
|
*/
|
|
7177
7246
|
get: function () {
|
|
7178
|
-
return
|
|
7247
|
+
return this.claimAmount;
|
|
7179
7248
|
},
|
|
7180
7249
|
enumerable: false,
|
|
7181
7250
|
configurable: true
|
|
7182
7251
|
});
|
|
7183
|
-
|
|
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", {
|
|
7184
7259
|
/**
|
|
7185
|
-
*
|
|
7260
|
+
* Get summary of claim amounts
|
|
7186
7261
|
*/
|
|
7187
7262
|
get: function () {
|
|
7188
|
-
return
|
|
7263
|
+
return this.items.reduce(function (sum, transaction) { return sum + transaction.claimAmount; }, 0);
|
|
7189
7264
|
},
|
|
7190
7265
|
enumerable: false,
|
|
7191
7266
|
configurable: true
|
|
7192
7267
|
});
|
|
7193
|
-
Object.defineProperty(
|
|
7194
|
-
/**
|
|
7195
|
-
* get difference between debit and credit transactions amounts
|
|
7196
|
-
*/
|
|
7268
|
+
Object.defineProperty(TransactionCollection.prototype, "grossAmount", {
|
|
7197
7269
|
get: function () {
|
|
7198
|
-
return this.items.reduce(function (sum,
|
|
7270
|
+
return +this.items.reduce(function (sum, transaction) { return sum + transaction.amount; }, 0).toFixed(2);
|
|
7199
7271
|
},
|
|
7200
7272
|
enumerable: false,
|
|
7201
7273
|
configurable: true
|
|
7202
7274
|
});
|
|
7275
|
+
TransactionCollection.prototype.getByChartAccountsCategories = function (categories) {
|
|
7276
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return categories.includes(transaction.chartAccounts.category); }));
|
|
7277
|
+
};
|
|
7203
7278
|
/**
|
|
7204
|
-
*
|
|
7205
|
-
* @param monthIndex
|
|
7279
|
+
* Get transactions by month
|
|
7280
|
+
* @param monthIndex by which desired month should be taken
|
|
7206
7281
|
*/
|
|
7207
|
-
|
|
7208
|
-
return new
|
|
7282
|
+
TransactionCollection.prototype.getByMonth = function (monthIndex) {
|
|
7283
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.date.getMonth() === monthIndex; }));
|
|
7209
7284
|
};
|
|
7210
7285
|
/**
|
|
7211
|
-
*
|
|
7212
|
-
* @param bankAccounts by which transactions should be returned
|
|
7286
|
+
* Get collection of transactions metadata
|
|
7213
7287
|
*/
|
|
7214
|
-
|
|
7215
|
-
var
|
|
7216
|
-
|
|
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(); }));
|
|
7217
7317
|
};
|
|
7318
|
+
Object.defineProperty(TransactionCollection.prototype, "claimInterest", {
|
|
7319
|
+
get: function () {
|
|
7320
|
+
return this.getInterestTransactions().claimAmount;
|
|
7321
|
+
},
|
|
7322
|
+
enumerable: false,
|
|
7323
|
+
configurable: true
|
|
7324
|
+
});
|
|
7218
7325
|
/**
|
|
7219
|
-
*
|
|
7220
|
-
* @param ids of
|
|
7326
|
+
* Get collection of transactions and properties filtered by properties ids
|
|
7327
|
+
* @param ids Ids of properties for filter
|
|
7221
7328
|
*/
|
|
7222
|
-
|
|
7223
|
-
return new
|
|
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
|
+
}));
|
|
7224
7334
|
};
|
|
7225
7335
|
/**
|
|
7226
|
-
*
|
|
7336
|
+
* Get new collection filtered by income source id
|
|
7337
|
+
* @param id id of income source for filter
|
|
7227
7338
|
*/
|
|
7228
|
-
|
|
7229
|
-
return this.items.
|
|
7230
|
-
return item.amount + bankTransaction.amount === 0 &&
|
|
7231
|
-
Math.abs(bankTransaction.date.getTime() - item.date.getTime()) < TRANSACTION_TRANSFER_DELAY;
|
|
7232
|
-
});
|
|
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; }));
|
|
7233
7341
|
};
|
|
7234
7342
|
/**
|
|
7235
|
-
*
|
|
7236
|
-
*
|
|
7343
|
+
* Get new collection filtered by chart accounts category
|
|
7344
|
+
* @param category Chart accounts category value
|
|
7237
7345
|
*/
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
// Group allocations by transaction id
|
|
7241
|
-
var allocationsByTransactions = new CollectionDictionary(allocations, 'transaction.id');
|
|
7242
|
-
// Init an empty dictionary we will fill below
|
|
7243
|
-
var bankTransactionsByTransactions = new CollectionDictionary(new BankTransactionCollection([]));
|
|
7244
|
-
// Fill dictionary with the same keys as at allocationsByTransactions
|
|
7245
|
-
allocationsByTransactions.keys.forEach(function (key) {
|
|
7246
|
-
bankTransactionsByTransactions.add(key, _this.getByAllocations(allocationsByTransactions.get(key)));
|
|
7247
|
-
});
|
|
7248
|
-
return bankTransactionsByTransactions;
|
|
7346
|
+
TransactionCollection.prototype.getByChartAccountsCategory = function (category) {
|
|
7347
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.chartAccounts.category === category; }));
|
|
7249
7348
|
};
|
|
7250
7349
|
/**
|
|
7251
|
-
* Get collection of
|
|
7350
|
+
* Get new collection of property transactions
|
|
7252
7351
|
*/
|
|
7253
|
-
|
|
7254
|
-
return new
|
|
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); }));
|
|
7255
7363
|
};
|
|
7256
7364
|
/**
|
|
7257
|
-
*
|
|
7365
|
+
* Get transactions related to Vehicle category
|
|
7258
7366
|
*/
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
if (salaryAmounts.includes(bankTransaction.amount)) {
|
|
7264
|
-
bankTransaction.operation = exports.TransactionOperationEnum.ALLOCATE;
|
|
7265
|
-
}
|
|
7266
|
-
});
|
|
7367
|
+
TransactionCollection.prototype.getVehicleTransactions = function () {
|
|
7368
|
+
return this.create(this.items.filter(function (transaction) {
|
|
7369
|
+
return transaction.isVehicleTransaction();
|
|
7370
|
+
}));
|
|
7267
7371
|
};
|
|
7268
7372
|
/**
|
|
7269
|
-
* Get collection
|
|
7373
|
+
* Get new transaction collection filtered by tank type
|
|
7270
7374
|
*/
|
|
7271
|
-
|
|
7272
|
-
return
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
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
|
+
|
|
7518
|
+
// @TODO Alex move here all collections
|
|
7519
|
+
|
|
7520
|
+
var AccountSetupItemCollection = /** @class */ (function (_super) {
|
|
7521
|
+
__extends(AccountSetupItemCollection, _super);
|
|
7522
|
+
function AccountSetupItemCollection(items) {
|
|
7523
|
+
var _this = _super.call(this, compact__default["default"](items)) || this;
|
|
7524
|
+
_this.sortBy('isCompleted', false);
|
|
7525
|
+
return _this;
|
|
7526
|
+
}
|
|
7527
|
+
AccountSetupItemCollection.prototype.isCompleted = function () {
|
|
7528
|
+
return this.filterBy('isCompleted', true).length === this.length;
|
|
7529
|
+
};
|
|
7530
|
+
return AccountSetupItemCollection;
|
|
7531
|
+
}(Collection));
|
|
7532
|
+
|
|
7533
|
+
/**
|
|
7534
|
+
* Maximal delay between transfer transactions
|
|
7535
|
+
*/
|
|
7536
|
+
var TRANSACTION_TRANSFER_DELAY = 96 * 3600 * 1000;
|
|
7537
|
+
/**
|
|
7538
|
+
* Collection of bank transactions.
|
|
7539
|
+
* IMPORTANT: Create this collection based on bank transactions from TransactionAllocationService
|
|
7540
|
+
* @TODO find way to accept interface with allocation instead of bankTransaction to prevent wrong usage
|
|
7541
|
+
* because all amounts calculates with allocated amounts but not from bank transactions amounts.
|
|
7542
|
+
*/
|
|
7543
|
+
var BankTransactionCollection = /** @class */ (function (_super) {
|
|
7544
|
+
__extends(BankTransactionCollection, _super);
|
|
7545
|
+
function BankTransactionCollection() {
|
|
7546
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
7547
|
+
}
|
|
7548
|
+
BankTransactionCollection.prototype.getAmount = function () {
|
|
7549
|
+
return this.sumBy('amount');
|
|
7550
|
+
};
|
|
7551
|
+
/**
|
|
7552
|
+
* Difference between total bank transactions amount and sum of allocations for passed bank transactions
|
|
7553
|
+
*/
|
|
7554
|
+
BankTransactionCollection.prototype.getUnallocatedAmount = function (allocations) {
|
|
7555
|
+
return +(this.getAmount() - allocations.getByBankTransactionsIds(this.getIds()).amount).toFixed(2);
|
|
7556
|
+
};
|
|
7557
|
+
/**
|
|
7558
|
+
* get date of the last transaction
|
|
7559
|
+
*/
|
|
7560
|
+
BankTransactionCollection.prototype.getLastTransactionDate = function () {
|
|
7561
|
+
return new Date(Math.max.apply(Math, this.items.map(function (bankTransaction) { return bankTransaction.date; })));
|
|
7562
|
+
};
|
|
7563
|
+
Object.defineProperty(BankTransactionCollection.prototype, "creditTransactions", {
|
|
7564
|
+
/**
|
|
7565
|
+
* get list of credit transactions
|
|
7566
|
+
*/
|
|
7567
|
+
get: function () {
|
|
7568
|
+
return new BankTransactionCollection(this.items.filter(function (bankTransaction) { return bankTransaction.isCredit(); }));
|
|
7569
|
+
},
|
|
7570
|
+
enumerable: false,
|
|
7571
|
+
configurable: true
|
|
7572
|
+
});
|
|
7573
|
+
Object.defineProperty(BankTransactionCollection.prototype, "debitTransactions", {
|
|
7574
|
+
/**
|
|
7575
|
+
* get list of debit transactions
|
|
7576
|
+
*/
|
|
7577
|
+
get: function () {
|
|
7578
|
+
return new BankTransactionCollection(this.items.filter(function (bankTransaction) { return bankTransaction.isDebit(); }));
|
|
7579
|
+
},
|
|
7580
|
+
enumerable: false,
|
|
7581
|
+
configurable: true
|
|
7582
|
+
});
|
|
7583
|
+
Object.defineProperty(BankTransactionCollection.prototype, "balanceAmount", {
|
|
7584
|
+
/**
|
|
7585
|
+
* get difference between debit and credit transactions amounts
|
|
7586
|
+
*/
|
|
7587
|
+
get: function () {
|
|
7588
|
+
return this.items.reduce(function (sum, bankTransaction) { return sum + bankTransaction.balanceAmount; }, 0);
|
|
7589
|
+
},
|
|
7590
|
+
enumerable: false,
|
|
7591
|
+
configurable: true
|
|
7592
|
+
});
|
|
7593
|
+
/**
|
|
7594
|
+
* get list of transactions for passed month
|
|
7595
|
+
* @param monthIndex Month number from 0 to 11
|
|
7596
|
+
*/
|
|
7597
|
+
BankTransactionCollection.prototype.getTransactionsByMonth = function (monthIndex) {
|
|
7598
|
+
return new BankTransactionCollection(this.items.filter(function (bankTransaction) { return bankTransaction.date.getMonth() === monthIndex; }));
|
|
7599
|
+
};
|
|
7600
|
+
/**
|
|
7601
|
+
* get list of transactions by provided bank accounts
|
|
7602
|
+
* @param bankAccounts by which transactions should be returned
|
|
7603
|
+
*/
|
|
7604
|
+
BankTransactionCollection.prototype.getByBankAccounts = function (bankAccounts) {
|
|
7605
|
+
var bankAccountIds = bankAccounts.map(function (bankAccount) { return bankAccount.id; });
|
|
7606
|
+
return this.items.filter(function (bankTransaction) { return bankAccountIds.includes(bankTransaction.bankAccount.id); });
|
|
7607
|
+
};
|
|
7608
|
+
/**
|
|
7609
|
+
* get list of transactions by provided ids of bank accounts
|
|
7610
|
+
* @param ids of bank accounts
|
|
7611
|
+
*/
|
|
7612
|
+
BankTransactionCollection.prototype.getByBankAccountsIds = function (ids) {
|
|
7613
|
+
return new BankTransactionCollection(this.items.filter(function (bankTransaction) { return ids.includes(bankTransaction.bankAccount.id); }));
|
|
7614
|
+
};
|
|
7615
|
+
/**
|
|
7616
|
+
* Find Bank Transaction available for transfer
|
|
7617
|
+
*/
|
|
7618
|
+
BankTransactionCollection.prototype.findTransfer = function (bankTransaction) {
|
|
7619
|
+
return this.items.find(function (item) {
|
|
7620
|
+
return item.amount + bankTransaction.amount === 0 &&
|
|
7621
|
+
Math.abs(bankTransaction.date.getTime() - item.date.getTime()) < TRANSACTION_TRANSFER_DELAY;
|
|
7622
|
+
});
|
|
7623
|
+
};
|
|
7624
|
+
/**
|
|
7625
|
+
* Group bank transactions by transaction id.
|
|
7626
|
+
* Each group is bank transaction collection and contains bank transactions related to transactions via allocations
|
|
7627
|
+
*/
|
|
7628
|
+
BankTransactionCollection.prototype.groupByTransaction = function (allocations) {
|
|
7629
|
+
var _this = this;
|
|
7630
|
+
// Group allocations by transaction id
|
|
7631
|
+
var allocationsByTransactions = new CollectionDictionary(allocations, 'transaction.id');
|
|
7632
|
+
// Init an empty dictionary we will fill below
|
|
7633
|
+
var bankTransactionsByTransactions = new CollectionDictionary(new BankTransactionCollection([]));
|
|
7634
|
+
// Fill dictionary with the same keys as at allocationsByTransactions
|
|
7635
|
+
allocationsByTransactions.keys.forEach(function (key) {
|
|
7636
|
+
bankTransactionsByTransactions.add(key, _this.getByAllocations(allocationsByTransactions.get(key)));
|
|
7637
|
+
});
|
|
7638
|
+
return bankTransactionsByTransactions;
|
|
7639
|
+
};
|
|
7640
|
+
/**
|
|
7641
|
+
* Get collection of bank transactions related with passed allocations
|
|
7642
|
+
*/
|
|
7643
|
+
BankTransactionCollection.prototype.getByAllocations = function (allocations) {
|
|
7644
|
+
return new BankTransactionCollection(this.items.filter(function (bankTransaction) { return allocations.hasBankTransaction(bankTransaction); }));
|
|
7645
|
+
};
|
|
7646
|
+
/**
|
|
7647
|
+
* Set allocate operation for bank transactions with amounts equal to salary
|
|
7648
|
+
*/
|
|
7649
|
+
BankTransactionCollection.prototype.preselectAllocateOperationForSalary = function (salaryIncomeSources) {
|
|
7650
|
+
// incomeSource.salaryForecasts[0] because each income source has only one forecast for current fin year
|
|
7651
|
+
var salaryAmounts = salaryIncomeSources.map(function (incomeSource) { var _a; return ((_a = incomeSource.salaryForecasts[0]) === null || _a === void 0 ? void 0 : _a.netPay) || 0; });
|
|
7652
|
+
this.items.forEach(function (bankTransaction) {
|
|
7653
|
+
if (salaryAmounts.includes(bankTransaction.amount)) {
|
|
7654
|
+
bankTransaction.operation = exports.TransactionOperationEnum.ALLOCATE;
|
|
7655
|
+
}
|
|
7656
|
+
});
|
|
7657
|
+
};
|
|
7658
|
+
/**
|
|
7659
|
+
* Get collection of unallocated bankTransactions
|
|
7660
|
+
*/
|
|
7661
|
+
BankTransactionCollection.prototype.getUnallocated = function (allocations) {
|
|
7662
|
+
return new BankTransactionCollection(this.items.filter(function (bankTransaction) { return !bankTransaction.isAllocated(allocations); }));
|
|
7663
|
+
};
|
|
7664
|
+
return BankTransactionCollection;
|
|
7665
|
+
}(Collection));
|
|
7666
|
+
|
|
7667
|
+
var ChartAccountsCollection = /** @class */ (function (_super) {
|
|
7278
7668
|
__extends(ChartAccountsCollection, _super);
|
|
7279
7669
|
function ChartAccountsCollection() {
|
|
7280
7670
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
@@ -7490,330 +7880,63 @@
|
|
|
7490
7880
|
}
|
|
7491
7881
|
Object.defineProperty(ClientPortfolioReportCollection.prototype, "marketValue", {
|
|
7492
7882
|
get: function () {
|
|
7493
|
-
return this.sumBy('marketValue');
|
|
7494
|
-
},
|
|
7495
|
-
enumerable: false,
|
|
7496
|
-
configurable: true
|
|
7497
|
-
});
|
|
7498
|
-
Object.defineProperty(ClientPortfolioReportCollection.prototype, "loanBalance", {
|
|
7499
|
-
get: function () {
|
|
7500
|
-
return this.sumBy('loanBalance');
|
|
7501
|
-
},
|
|
7502
|
-
enumerable: false,
|
|
7503
|
-
configurable: true
|
|
7504
|
-
});
|
|
7505
|
-
Object.defineProperty(ClientPortfolioReportCollection.prototype, "equityPosition", {
|
|
7506
|
-
get: function () {
|
|
7507
|
-
return this.sumBy('equityPosition');
|
|
7508
|
-
},
|
|
7509
|
-
enumerable: false,
|
|
7510
|
-
configurable: true
|
|
7511
|
-
});
|
|
7512
|
-
Object.defineProperty(ClientPortfolioReportCollection.prototype, "averageMarketValue", {
|
|
7513
|
-
/**
|
|
7514
|
-
* Get average market value if there are more than 1 item in the collection
|
|
7515
|
-
*/
|
|
7516
|
-
get: function () {
|
|
7517
|
-
return this.items.length > 1 ? this.marketValue / this.items.length : null;
|
|
7518
|
-
},
|
|
7519
|
-
enumerable: false,
|
|
7520
|
-
configurable: true
|
|
7521
|
-
});
|
|
7522
|
-
Object.defineProperty(ClientPortfolioReportCollection.prototype, "averageLoanBalance", {
|
|
7523
|
-
/**
|
|
7524
|
-
* Get average loan balance if there are more than 1 item in the collection
|
|
7525
|
-
*/
|
|
7526
|
-
get: function () {
|
|
7527
|
-
return this.items.length > 1 ? this.loanBalance / this.items.length : null;
|
|
7528
|
-
},
|
|
7529
|
-
enumerable: false,
|
|
7530
|
-
configurable: true
|
|
7531
|
-
});
|
|
7532
|
-
Object.defineProperty(ClientPortfolioReportCollection.prototype, "averageEquityPosition", {
|
|
7533
|
-
/**
|
|
7534
|
-
* Get average equity position if there are more than 1 item in the collection
|
|
7535
|
-
*/
|
|
7536
|
-
get: function () {
|
|
7537
|
-
return this.items.length > 1 ? this.equityPosition / this.items.length : null;
|
|
7538
|
-
},
|
|
7539
|
-
enumerable: false,
|
|
7540
|
-
configurable: true
|
|
7541
|
-
});
|
|
7542
|
-
/**
|
|
7543
|
-
* Return report by provided category name
|
|
7544
|
-
*/
|
|
7545
|
-
ClientPortfolioReportCollection.prototype.getByCategoryName = function (name) {
|
|
7546
|
-
return this.items.find(function (item) { return item.category === name; });
|
|
7547
|
-
};
|
|
7548
|
-
return ClientPortfolioReportCollection;
|
|
7549
|
-
}(Collection));
|
|
7550
|
-
|
|
7551
|
-
/**
|
|
7552
|
-
* Chart serie class: chart data item
|
|
7553
|
-
* @TODO consider rename to ChartSerieData
|
|
7554
|
-
*/
|
|
7555
|
-
var ChartSerie = /** @class */ (function () {
|
|
7556
|
-
function ChartSerie() {
|
|
7557
|
-
}
|
|
7558
|
-
return ChartSerie;
|
|
7559
|
-
}());
|
|
7560
|
-
|
|
7561
|
-
/**
|
|
7562
|
-
* Chart data class
|
|
7563
|
-
* @TODO consider rename to ChartSerie
|
|
7564
|
-
*/
|
|
7565
|
-
var ChartData = /** @class */ (function () {
|
|
7566
|
-
function ChartData() {
|
|
7567
|
-
}
|
|
7568
|
-
return ChartData;
|
|
7569
|
-
}());
|
|
7570
|
-
__decorate([
|
|
7571
|
-
classTransformer.Type(function () { return ChartSerie; })
|
|
7572
|
-
], ChartData.prototype, "data", void 0);
|
|
7573
|
-
|
|
7574
|
-
var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
|
|
7575
|
-
|
|
7576
|
-
/**
|
|
7577
|
-
* Collection of transactions
|
|
7578
|
-
*/
|
|
7579
|
-
var TransactionCollection = /** @class */ (function (_super) {
|
|
7580
|
-
__extends(TransactionCollection, _super);
|
|
7581
|
-
function TransactionCollection() {
|
|
7582
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
7583
|
-
}
|
|
7584
|
-
Object.defineProperty(TransactionCollection.prototype, "amount", {
|
|
7585
|
-
/**
|
|
7586
|
-
* Get total amount of all transactions in the collection
|
|
7587
|
-
*/
|
|
7588
|
-
get: function () {
|
|
7589
|
-
return +this.items.reduce(function (sum, transaction) { return sum + transaction.getNetAmount(); }, 0).toFixed(2);
|
|
7590
|
-
},
|
|
7591
|
-
enumerable: false,
|
|
7592
|
-
configurable: true
|
|
7593
|
-
});
|
|
7594
|
-
/**
|
|
7595
|
-
* Difference between allocated amount and total amount
|
|
7596
|
-
*/
|
|
7597
|
-
TransactionCollection.prototype.getUnallocatedAmount = function (allocations) {
|
|
7598
|
-
return +(this.amount - allocations.getByTransactionsIds(this.getIds()).amount).toFixed(2);
|
|
7599
|
-
};
|
|
7600
|
-
Object.defineProperty(TransactionCollection.prototype, "cashPosition", {
|
|
7601
|
-
/**
|
|
7602
|
-
* Get cash position
|
|
7603
|
-
* Cash Position = Income - Expenses
|
|
7604
|
-
* Cash position is equal to Total Amount because income is positive and expense is negative,
|
|
7605
|
-
*/
|
|
7606
|
-
get: function () {
|
|
7607
|
-
return this.claimAmount;
|
|
7608
|
-
},
|
|
7609
|
-
enumerable: false,
|
|
7610
|
-
configurable: true
|
|
7611
|
-
});
|
|
7612
|
-
/**
|
|
7613
|
-
* get date of the last transaction
|
|
7614
|
-
*/
|
|
7615
|
-
TransactionCollection.prototype.getLastTransactionDate = function () {
|
|
7616
|
-
return new Date(Math.max.apply(Math, this.items.map(function (transaction) { return transaction.date; })));
|
|
7617
|
-
};
|
|
7618
|
-
Object.defineProperty(TransactionCollection.prototype, "claimAmount", {
|
|
7619
|
-
/**
|
|
7620
|
-
* Get summary of claim amounts
|
|
7621
|
-
*/
|
|
7622
|
-
get: function () {
|
|
7623
|
-
return this.items.reduce(function (sum, transaction) { return sum + transaction.claimAmount; }, 0);
|
|
7624
|
-
},
|
|
7625
|
-
enumerable: false,
|
|
7626
|
-
configurable: true
|
|
7627
|
-
});
|
|
7628
|
-
Object.defineProperty(TransactionCollection.prototype, "grossAmount", {
|
|
7629
|
-
get: function () {
|
|
7630
|
-
return +this.items.reduce(function (sum, transaction) { return sum + transaction.amount; }, 0).toFixed(2);
|
|
7631
|
-
},
|
|
7632
|
-
enumerable: false,
|
|
7633
|
-
configurable: true
|
|
7634
|
-
});
|
|
7635
|
-
TransactionCollection.prototype.getByChartAccountsCategories = function (categories) {
|
|
7636
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return categories.includes(transaction.chartAccounts.category); }));
|
|
7637
|
-
};
|
|
7638
|
-
/**
|
|
7639
|
-
* Get transactions by month
|
|
7640
|
-
* @param monthIndex by which desired month should be taken
|
|
7641
|
-
*/
|
|
7642
|
-
TransactionCollection.prototype.getByMonth = function (monthIndex) {
|
|
7643
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.date.getMonth() === monthIndex; }));
|
|
7644
|
-
};
|
|
7645
|
-
/**
|
|
7646
|
-
* Get collection of transactions metadata
|
|
7647
|
-
*/
|
|
7648
|
-
TransactionCollection.prototype.getTransactionsMetadata = function () {
|
|
7649
|
-
var metadataArray = [];
|
|
7650
|
-
this.items.forEach(function (transaction) {
|
|
7651
|
-
metadataArray.push.apply(metadataArray, __spreadArray([], __read(transaction.metadata)));
|
|
7652
|
-
});
|
|
7653
|
-
return new Collection(metadataArray);
|
|
7654
|
-
};
|
|
7655
|
-
TransactionCollection.prototype.getIncomeTransactions = function () {
|
|
7656
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isIncome(); }));
|
|
7657
|
-
};
|
|
7658
|
-
Object.defineProperty(TransactionCollection.prototype, "claimIncome", {
|
|
7883
|
+
return this.sumBy('marketValue');
|
|
7884
|
+
},
|
|
7885
|
+
enumerable: false,
|
|
7886
|
+
configurable: true
|
|
7887
|
+
});
|
|
7888
|
+
Object.defineProperty(ClientPortfolioReportCollection.prototype, "loanBalance", {
|
|
7659
7889
|
get: function () {
|
|
7660
|
-
return this.
|
|
7890
|
+
return this.sumBy('loanBalance');
|
|
7661
7891
|
},
|
|
7662
7892
|
enumerable: false,
|
|
7663
7893
|
configurable: true
|
|
7664
7894
|
});
|
|
7665
|
-
|
|
7666
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isExpense() && !transaction.isInterest(); }));
|
|
7667
|
-
};
|
|
7668
|
-
Object.defineProperty(TransactionCollection.prototype, "claimExpense", {
|
|
7895
|
+
Object.defineProperty(ClientPortfolioReportCollection.prototype, "equityPosition", {
|
|
7669
7896
|
get: function () {
|
|
7670
|
-
return this.
|
|
7897
|
+
return this.sumBy('equityPosition');
|
|
7671
7898
|
},
|
|
7672
7899
|
enumerable: false,
|
|
7673
7900
|
configurable: true
|
|
7674
7901
|
});
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7902
|
+
Object.defineProperty(ClientPortfolioReportCollection.prototype, "averageMarketValue", {
|
|
7903
|
+
/**
|
|
7904
|
+
* Get average market value if there are more than 1 item in the collection
|
|
7905
|
+
*/
|
|
7679
7906
|
get: function () {
|
|
7680
|
-
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;
|
|
7681
7928
|
},
|
|
7682
7929
|
enumerable: false,
|
|
7683
7930
|
configurable: true
|
|
7684
7931
|
});
|
|
7685
7932
|
/**
|
|
7686
|
-
*
|
|
7687
|
-
* @param ids Ids of properties for filter
|
|
7688
|
-
*/
|
|
7689
|
-
TransactionCollection.prototype.getByPropertiesIds = function (ids) {
|
|
7690
|
-
return new TransactionCollection(this.items.filter(function (transaction) {
|
|
7691
|
-
var _a;
|
|
7692
|
-
return ids.includes((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id);
|
|
7693
|
-
}));
|
|
7694
|
-
};
|
|
7695
|
-
/**
|
|
7696
|
-
* Get new collection filtered by income source id
|
|
7697
|
-
* @param id id of income source for filter
|
|
7698
|
-
*/
|
|
7699
|
-
TransactionCollection.prototype.getByIncomeSourceId = function (id) {
|
|
7700
|
-
return new TransactionCollection(this.items.filter(function (transaction) { var _a; return ((_a = transaction.incomeSource) === null || _a === void 0 ? void 0 : _a.id) === id; }));
|
|
7701
|
-
};
|
|
7702
|
-
/**
|
|
7703
|
-
* Get new collection filtered by chart accounts category
|
|
7704
|
-
* @param category Chart accounts category value
|
|
7705
|
-
*/
|
|
7706
|
-
TransactionCollection.prototype.getByChartAccountsCategory = function (category) {
|
|
7707
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.chartAccounts.category === category; }));
|
|
7708
|
-
};
|
|
7709
|
-
/**
|
|
7710
|
-
* Get new collection of property transactions
|
|
7711
|
-
*/
|
|
7712
|
-
TransactionCollection.prototype.getPropertyTransactions = function () {
|
|
7713
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isPropertyTank(); }));
|
|
7714
|
-
};
|
|
7715
|
-
TransactionCollection.prototype.getDebitTransactions = function () {
|
|
7716
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isDebit(); }));
|
|
7717
|
-
};
|
|
7718
|
-
TransactionCollection.prototype.getCreditTransactions = function () {
|
|
7719
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isCredit(); }));
|
|
7720
|
-
};
|
|
7721
|
-
TransactionCollection.prototype.getByAllocations = function (allocations) {
|
|
7722
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return allocations.hasTransaction(transaction); }));
|
|
7723
|
-
};
|
|
7724
|
-
/**
|
|
7725
|
-
* Get transactions related to Vehicle category
|
|
7726
|
-
*/
|
|
7727
|
-
TransactionCollection.prototype.getVehicleTransactions = function () {
|
|
7728
|
-
return this.create(this.items.filter(function (transaction) {
|
|
7729
|
-
return transaction.isVehicleTransaction();
|
|
7730
|
-
}));
|
|
7731
|
-
};
|
|
7732
|
-
/**
|
|
7733
|
-
* Get new transaction collection filtered by tank type
|
|
7734
|
-
*/
|
|
7735
|
-
TransactionCollection.prototype.getByTankType = function (tankType) {
|
|
7736
|
-
return this.create(this.items.filter(function (transaction) {
|
|
7737
|
-
switch (tankType) {
|
|
7738
|
-
case exports.TankTypeEnum.PROPERTY:
|
|
7739
|
-
return transaction.isPropertyTank();
|
|
7740
|
-
case exports.TankTypeEnum.WORK:
|
|
7741
|
-
return transaction.isWorkTank();
|
|
7742
|
-
case exports.TankTypeEnum.SOLE:
|
|
7743
|
-
return transaction.isSoleTank();
|
|
7744
|
-
// Transaction may be not related to any tank type (personal)
|
|
7745
|
-
default:
|
|
7746
|
-
return false;
|
|
7747
|
-
}
|
|
7748
|
-
}));
|
|
7749
|
-
};
|
|
7750
|
-
TransactionCollection.prototype.getExportHeader = function () {
|
|
7751
|
-
return ['Date', 'Description', 'Debit', 'Credit'];
|
|
7752
|
-
};
|
|
7753
|
-
TransactionCollection.prototype.getExportFooter = function () {
|
|
7754
|
-
return [
|
|
7755
|
-
classTransformer.plainToClass(ExportCell, { value: 'Total', type: ExportCellTypeEnum.STRING }),
|
|
7756
|
-
classTransformer.plainToClass(ExportCell, { value: '', type: ExportCellTypeEnum.STRING }),
|
|
7757
|
-
classTransformer.plainToClass(ExportCell, { value: this.sumBy('debit'), type: ExportCellTypeEnum.CURRENCY }),
|
|
7758
|
-
classTransformer.plainToClass(ExportCell, { value: this.sumBy('credit'), type: ExportCellTypeEnum.CURRENCY })
|
|
7759
|
-
];
|
|
7760
|
-
};
|
|
7761
|
-
TransactionCollection.prototype.getExportBody = function () {
|
|
7762
|
-
return this.items.map(function (transaction) {
|
|
7763
|
-
return [
|
|
7764
|
-
classTransformer.plainToClass(ExportCell, { value: transaction.date, type: ExportCellTypeEnum.DATE }),
|
|
7765
|
-
classTransformer.plainToClass(ExportCell, { value: transaction.description, type: ExportCellTypeEnum.STRING }),
|
|
7766
|
-
classTransformer.plainToClass(ExportCell, { value: transaction.debit, type: ExportCellTypeEnum.CURRENCY }),
|
|
7767
|
-
classTransformer.plainToClass(ExportCell, { value: transaction.credit, type: ExportCellTypeEnum.CURRENCY })
|
|
7768
|
-
];
|
|
7769
|
-
});
|
|
7770
|
-
};
|
|
7771
|
-
/**
|
|
7772
|
-
* Get list of vehicle transactions filtered by vehicle claim
|
|
7773
|
-
*/
|
|
7774
|
-
TransactionCollection.prototype.getByVehicleClaim = function (vehicleClaim) {
|
|
7775
|
-
if (!vehicleClaim) {
|
|
7776
|
-
return this.create([]);
|
|
7777
|
-
}
|
|
7778
|
-
return vehicleClaim.isSoleTank()
|
|
7779
|
-
// sole tank may have multiple vehicle claims, so we need to filter by business.id
|
|
7780
|
-
? this.getVehicleTransactions().filterBy('business.id', vehicleClaim.business.id)
|
|
7781
|
-
// work tank may have only one vehicle claim, so we need to filter by tank type
|
|
7782
|
-
: this.getVehicleTransactions().filterBy('tankType', exports.TankTypeEnum.WORK);
|
|
7783
|
-
};
|
|
7784
|
-
/**
|
|
7785
|
-
* Get list of vehicle transactions except KMS transactions
|
|
7786
|
-
*/
|
|
7787
|
-
TransactionCollection.prototype.getLogbookTransactions = function () {
|
|
7788
|
-
return this
|
|
7789
|
-
.getVehicleTransactions()
|
|
7790
|
-
.removeBy('chartAccounts.id', [exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK, exports.ChartAccountsListEnum.KLMS_TRAVELLED]);
|
|
7791
|
-
};
|
|
7792
|
-
/**
|
|
7793
|
-
* Build chart data with transactions cash position.
|
|
7794
|
-
* Cash position = Income - Expenses (include depreciations)
|
|
7795
|
-
* Chart data for each month from fin year start till current month
|
|
7933
|
+
* Return report by provided category name
|
|
7796
7934
|
*/
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
var chartData = [
|
|
7800
|
-
classTransformer.plainToClass(ChartData, { name: 'Income', data: [] }),
|
|
7801
|
-
classTransformer.plainToClass(ChartData, { name: 'Expense', data: [] })
|
|
7802
|
-
];
|
|
7803
|
-
new FinancialYear().getPastMonths().forEach(function (month) {
|
|
7804
|
-
chartData[0].data.push({
|
|
7805
|
-
label: MONTHS[month],
|
|
7806
|
-
value: _this.getIncomeTransactions().getByMonth(month).claimAmount
|
|
7807
|
-
});
|
|
7808
|
-
chartData[1].data.push({
|
|
7809
|
-
label: MONTHS[month],
|
|
7810
|
-
value: Math.abs(_this.getExpenseTransactions().getByMonth(month).claimAmount)
|
|
7811
|
-
});
|
|
7812
|
-
});
|
|
7813
|
-
return chartData;
|
|
7935
|
+
ClientPortfolioReportCollection.prototype.getByCategoryName = function (name) {
|
|
7936
|
+
return this.items.find(function (item) { return item.category === name; });
|
|
7814
7937
|
};
|
|
7815
|
-
return
|
|
7816
|
-
}(
|
|
7938
|
+
return ClientPortfolioReportCollection;
|
|
7939
|
+
}(Collection));
|
|
7817
7940
|
|
|
7818
7941
|
var DepreciationCollection = /** @class */ (function (_super) {
|
|
7819
7942
|
__extends(DepreciationCollection, _super);
|
|
@@ -8632,7 +8755,11 @@
|
|
|
8632
8755
|
exports.TaxReturnCategoryListEnum.DEPRECIATION_EXPENSES,
|
|
8633
8756
|
exports.TaxReturnCategoryListEnum.MOTOR_VEHICLE_EXPENSES,
|
|
8634
8757
|
exports.TaxReturnCategoryListEnum.ALL_OTHER_EXPENSES
|
|
8635
|
-
]
|
|
8758
|
+
],
|
|
8759
|
+
// @TODO TT-2386 Nikita to move sole tax offsets in separated category
|
|
8760
|
+
taxOffsets: [
|
|
8761
|
+
exports.TaxReturnCategoryListEnum.TAX_OFFSETS
|
|
8762
|
+
],
|
|
8636
8763
|
},
|
|
8637
8764
|
};
|
|
8638
8765
|
|
|
@@ -8694,54 +8821,6 @@
|
|
|
8694
8821
|
return TaxReviewCollection;
|
|
8695
8822
|
}(Collection));
|
|
8696
8823
|
|
|
8697
|
-
var TransactionAllocationCollection = /** @class */ (function (_super) {
|
|
8698
|
-
__extends(TransactionAllocationCollection, _super);
|
|
8699
|
-
function TransactionAllocationCollection() {
|
|
8700
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
8701
|
-
}
|
|
8702
|
-
Object.defineProperty(TransactionAllocationCollection.prototype, "amount", {
|
|
8703
|
-
get: function () {
|
|
8704
|
-
return this.sumBy('amount');
|
|
8705
|
-
},
|
|
8706
|
-
enumerable: false,
|
|
8707
|
-
configurable: true
|
|
8708
|
-
});
|
|
8709
|
-
TransactionAllocationCollection.prototype.getByTransactionsIds = function (ids) {
|
|
8710
|
-
return new TransactionAllocationCollection(this.items.filter(function (allocation) { return ids.includes(allocation.transaction.id); }));
|
|
8711
|
-
};
|
|
8712
|
-
TransactionAllocationCollection.prototype.getByBankTransactionsIds = function (ids) {
|
|
8713
|
-
return new TransactionAllocationCollection(this.items.filter(function (allocation) { return ids.includes(allocation.bankTransaction.id); }));
|
|
8714
|
-
};
|
|
8715
|
-
/**
|
|
8716
|
-
* Group allocations by bank account via bank transactions collection
|
|
8717
|
-
*/
|
|
8718
|
-
TransactionAllocationCollection.prototype.groupByBankAccount = function (bankTransactions) {
|
|
8719
|
-
var _this = this;
|
|
8720
|
-
// Group bank transactions by bank account id
|
|
8721
|
-
var bankTransactionsByBankAccount = new CollectionDictionary(bankTransactions, 'bankAccount.id');
|
|
8722
|
-
// Create empty dictionary of transaction allocations
|
|
8723
|
-
var allocationsByBankAccount = new CollectionDictionary(new TransactionAllocationCollection([]));
|
|
8724
|
-
// Fill allocations dictionary with bank transactions dictionary keys and allocations related with each bank transaction collection
|
|
8725
|
-
bankTransactionsByBankAccount.keys.forEach(function (key) {
|
|
8726
|
-
allocationsByBankAccount.add(key, _this.getByBankTransactionsIds(bankTransactionsByBankAccount.get(key).getIds()));
|
|
8727
|
-
});
|
|
8728
|
-
return allocationsByBankAccount;
|
|
8729
|
-
};
|
|
8730
|
-
/**
|
|
8731
|
-
* check if collection includes allocation of passed transaction
|
|
8732
|
-
*/
|
|
8733
|
-
TransactionAllocationCollection.prototype.hasTransaction = function (transaction) {
|
|
8734
|
-
return !!this.items.find(function (allocation) { return allocation.transaction.id === transaction.id; });
|
|
8735
|
-
};
|
|
8736
|
-
/**
|
|
8737
|
-
* Check if bank transaction is related with current allocations
|
|
8738
|
-
*/
|
|
8739
|
-
TransactionAllocationCollection.prototype.hasBankTransaction = function (bankTransaction) {
|
|
8740
|
-
return !!this.items.find(function (allocation) { return allocation.bankTransaction.id === bankTransaction.id; });
|
|
8741
|
-
};
|
|
8742
|
-
return TransactionAllocationCollection;
|
|
8743
|
-
}(Collection));
|
|
8744
|
-
|
|
8745
8824
|
/**
|
|
8746
8825
|
* Collection of user event settings
|
|
8747
8826
|
*/
|
|
@@ -11645,7 +11724,6 @@
|
|
|
11645
11724
|
});
|
|
11646
11725
|
Object.defineProperty(TaxSummary.prototype, "soleNetCash", {
|
|
11647
11726
|
/**
|
|
11648
|
-
* @TODO Nicole update documentation + check calculations
|
|
11649
11727
|
* Sole Net Cash = gross income – expenses
|
|
11650
11728
|
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/217677990/Dashboard+Main
|
|
11651
11729
|
*/
|
|
@@ -11659,7 +11737,6 @@
|
|
|
11659
11737
|
});
|
|
11660
11738
|
Object.defineProperty(TaxSummary.prototype, "soleNetTotal", {
|
|
11661
11739
|
/**
|
|
11662
|
-
* @TODO Nicole update documentation + check calculations
|
|
11663
11740
|
* Sole Net Total = Gross income - expenses
|
|
11664
11741
|
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/217677990/Dashboard+Main
|
|
11665
11742
|
*/
|
|
@@ -11914,6 +11991,29 @@
|
|
|
11914
11991
|
}]
|
|
11915
11992
|
}] });
|
|
11916
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
|
+
|
|
11917
12017
|
var SoleContactService = /** @class */ (function (_super) {
|
|
11918
12018
|
__extends(SoleContactService, _super);
|
|
11919
12019
|
function SoleContactService() {
|
|
@@ -17752,6 +17852,33 @@
|
|
|
17752
17852
|
return SoleBusinessAllocationsForm;
|
|
17753
17853
|
}(forms.FormArray));
|
|
17754
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
|
+
|
|
17755
17882
|
var SoleContactForm = /** @class */ (function (_super) {
|
|
17756
17883
|
__extends(SoleContactForm, _super);
|
|
17757
17884
|
function SoleContactForm(contact) {
|
|
@@ -19274,6 +19401,9 @@
|
|
|
19274
19401
|
exports.SoleBusinessAllocationsForm = SoleBusinessAllocationsForm;
|
|
19275
19402
|
exports.SoleBusinessForm = SoleBusinessForm;
|
|
19276
19403
|
exports.SoleBusinessLoss = SoleBusinessLoss;
|
|
19404
|
+
exports.SoleBusinessLossForm = SoleBusinessLossForm;
|
|
19405
|
+
exports.SoleBusinessLossOffsetRule = SoleBusinessLossOffsetRule;
|
|
19406
|
+
exports.SoleBusinessLossOffsetRuleService = SoleBusinessLossOffsetRuleService;
|
|
19277
19407
|
exports.SoleBusinessLossReport = SoleBusinessLossReport;
|
|
19278
19408
|
exports.SoleBusinessLossService = SoleBusinessLossService;
|
|
19279
19409
|
exports.SoleBusinessService = SoleBusinessService;
|
|
@@ -19318,6 +19448,7 @@
|
|
|
19318
19448
|
exports.TransactionAllocationCollection = TransactionAllocationCollection;
|
|
19319
19449
|
exports.TransactionAllocationService = TransactionAllocationService;
|
|
19320
19450
|
exports.TransactionBase = TransactionBase;
|
|
19451
|
+
exports.TransactionBaseCollection = TransactionBaseCollection;
|
|
19321
19452
|
exports.TransactionCalculationService = TransactionCalculationService;
|
|
19322
19453
|
exports.TransactionCollection = TransactionCollection;
|
|
19323
19454
|
exports.TransactionMetadata = TransactionMetadata;
|