taxtank-core 0.28.10 → 0.28.13
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 +1699 -1421
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/collection-dictionary.js +5 -2
- package/esm2015/lib/collections/sole/sole-invoice-item.collection.js +7 -0
- package/esm2015/lib/collections/transaction/transaction.collection.js +26 -1
- package/esm2015/lib/db/Enums/document-type.enum.js +5 -0
- package/esm2015/lib/db/Enums/index.js +3 -0
- package/esm2015/lib/db/Enums/sole-invoice-tax-type.enum.js +7 -0
- package/esm2015/lib/db/Enums/sole-invoice-template-tax-type.enum.js +4 -4
- package/esm2015/lib/db/Models/sole/sole-invoice-item.js +1 -1
- package/esm2015/lib/db/Models/sole/sole-invoice.js +1 -1
- package/esm2015/lib/forms/bank/bank-account/bank-account-add-manual.form.js +10 -6
- package/esm2015/lib/forms/bank/bank-account/bank-account-allocation.form.js +5 -4
- package/esm2015/lib/forms/sole/sole-business.form.js +21 -2
- package/esm2015/lib/forms/sole/sole-invoice-item.form.js +3 -31
- package/esm2015/lib/forms/sole/sole-invoice-template.form.js +4 -5
- package/esm2015/lib/forms/sole/sole-invoice.form.js +93 -18
- package/esm2015/lib/models/depreciation/depreciation.js +2 -2
- package/esm2015/lib/models/dictionary/dictionary.js +2 -2
- package/esm2015/lib/models/document/index.js +3 -0
- package/esm2015/lib/models/income-source/income-source.js +3 -3
- package/esm2015/lib/models/index.js +2 -1
- package/esm2015/lib/models/sole/sole-details.js +1 -3
- package/esm2015/lib/models/sole/sole-invoice-item.js +10 -2
- package/esm2015/lib/models/sole/sole-invoice-template.js +13 -10
- package/esm2015/lib/models/sole/sole-invoice.js +82 -28
- package/esm2015/lib/services/http/document/document-folder/document-folder.service.js +1 -1
- package/esm2015/lib/services/http/document/document.service.js +20 -0
- package/esm2015/lib/services/http/document/index.js +3 -0
- package/esm2015/lib/services/http/income-source/income-source.service.js +2 -1
- package/esm2015/lib/services/http/index.js +2 -1
- package/esm2015/lib/services/http/rest/rest.service.js +23 -7
- package/esm2015/lib/services/http/sole/sole-invoice/sole-invoice.service.js +15 -1
- package/esm2015/lib/services/pdf/pdf-from-dom-element/pdf-from-dom-element.service.js +17 -5
- package/esm2015/lib/services/transaction/transaction-calculation.service.js +13 -1
- package/esm2015/public-api.js +3 -2
- package/fesm2015/taxtank-core.js +1211 -972
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/sole/sole-invoice-item.collection.d.ts +5 -0
- package/lib/collections/transaction/transaction.collection.d.ts +7 -0
- package/lib/db/Enums/document-type.enum.d.ts +3 -0
- package/lib/db/Enums/index.d.ts +1 -0
- package/lib/db/Enums/sole-invoice-tax-type.enum.d.ts +5 -0
- package/lib/db/Enums/sole-invoice-template-tax-type.enum.d.ts +3 -3
- package/lib/db/Models/sole/sole-invoice-item.d.ts +3 -1
- package/lib/db/Models/sole/sole-invoice.d.ts +8 -5
- package/lib/forms/bank/bank-account/bank-account-add-manual.form.d.ts +3 -1
- package/lib/forms/bank/bank-account/bank-account-allocation.form.d.ts +4 -1
- package/lib/forms/sole/sole-business.form.d.ts +10 -1
- package/lib/forms/sole/sole-invoice-item.form.d.ts +2 -7
- package/lib/forms/sole/sole-invoice-template.form.d.ts +2 -3
- package/lib/forms/sole/sole-invoice.form.d.ts +19 -2
- package/lib/models/document/index.d.ts +2 -0
- package/lib/models/index.d.ts +1 -0
- package/lib/models/sole/sole-details.d.ts +0 -2
- package/lib/models/sole/sole-invoice-item.d.ts +7 -1
- package/lib/models/sole/sole-invoice-template.d.ts +10 -3
- package/lib/models/sole/sole-invoice.d.ts +49 -5
- package/lib/services/http/document/document.service.d.ts +10 -0
- package/lib/services/http/document/index.d.ts +2 -0
- package/lib/services/http/index.d.ts +1 -0
- package/lib/services/http/rest/rest.service.d.ts +13 -4
- package/lib/services/http/sole/sole-invoice/sole-invoice.service.d.ts +6 -1
- package/lib/services/pdf/pdf-from-dom-element/pdf-from-dom-element.service.d.ts +5 -1
- package/lib/services/transaction/transaction-calculation.service.d.ts +6 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/get'), require('lodash/last'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('moment'), require('moment-range'), require('lodash/uniqBy'), require('lodash/concat'), require('rxjs/internal/observable/throwError'), require('lodash/cloneDeep'), require('event-source-polyfill/src/eventsource.min.js'), require('lodash/compact'), require('@angular/forms'), require('lodash/isEqual'), require('lodash/fromPairs'), require('lodash'), require('@angular/router'), require('lodash/clone'), require('html2pdf.js'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/get', 'lodash/last', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'moment', 'moment-range', 'lodash/uniqBy', 'lodash/concat', 'rxjs/internal/observable/throwError', 'lodash/cloneDeep', 'event-source-polyfill/src/eventsource.min.js', 'lodash/compact', '@angular/forms', 'lodash/isEqual', 'lodash/fromPairs', 'lodash', '@angular/router', 'lodash/clone', 'html2pdf.js', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.get, global.last, global.flatten, global.hasIn, global.first, global.moment$1, global.momentRange, global.uniqBy, global.concat, global.rxjs["internal/observable/throwError"], global.cloneDeep$1, global.eventsource_min_js, global.compact, global.ng.forms, global.isEqual, global.fromPairs, global._, global.ng.router, global.clone, global.html2pdf, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
|
|
5
|
-
})(this, (function (exports, i0, i1$1, i1, rxjs, operators, classTransformer, angularJwt, get, last, flatten, hasIn, first, moment$1, momentRange, uniqBy, concat, throwError, cloneDeep$1, eventsource_min_js, compact, forms, isEqual, fromPairs, _, i1$2, clone, html2pdf, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/get'), require('lodash/last'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('moment'), require('moment-range'), require('lodash/uniqBy'), require('lodash/concat'), require('rxjs/internal/observable/throwError'), require('lodash/cloneDeep'), require('event-source-polyfill/src/eventsource.min.js'), require('lodash/compact'), require('@angular/forms'), require('lodash/merge'), require('lodash/isEqual'), require('lodash/fromPairs'), require('lodash'), require('@angular/router'), require('lodash/clone'), require('html2pdf.js'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/get', 'lodash/last', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'moment', 'moment-range', 'lodash/uniqBy', 'lodash/concat', 'rxjs/internal/observable/throwError', 'lodash/cloneDeep', 'event-source-polyfill/src/eventsource.min.js', 'lodash/compact', '@angular/forms', 'lodash/merge', 'lodash/isEqual', 'lodash/fromPairs', 'lodash', '@angular/router', 'lodash/clone', 'html2pdf.js', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.get, global.last, global.flatten, global.hasIn, global.first, global.moment$1, global.momentRange, global.uniqBy, global.concat, global.rxjs["internal/observable/throwError"], global.cloneDeep$1, global.eventsource_min_js, global.compact, global.ng.forms, global.merge, global.isEqual, global.fromPairs, global._, global.ng.router, global.clone, global.html2pdf, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
|
|
5
|
+
})(this, (function (exports, i0, i1$1, i1, rxjs, operators, classTransformer, angularJwt, get, last, flatten, hasIn, first, moment$1, momentRange, uniqBy, concat, throwError, cloneDeep$1, eventsource_min_js, compact, forms, merge, isEqual, fromPairs, _, i1$2, clone, html2pdf, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
var concat__default = /*#__PURE__*/_interopDefaultLegacy(concat);
|
|
38
38
|
var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep$1);
|
|
39
39
|
var compact__default = /*#__PURE__*/_interopDefaultLegacy(compact);
|
|
40
|
+
var merge__default = /*#__PURE__*/_interopDefaultLegacy(merge);
|
|
40
41
|
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
41
42
|
var fromPairs__default = /*#__PURE__*/_interopDefaultLegacy(fromPairs);
|
|
42
43
|
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
@@ -1341,12 +1342,11 @@
|
|
|
1341
1342
|
};
|
|
1342
1343
|
/**
|
|
1343
1344
|
* add new instance and update cache
|
|
1344
|
-
* @TODO rename to post
|
|
1345
1345
|
*/
|
|
1346
|
-
RestService.prototype.
|
|
1346
|
+
RestService.prototype.create = function (data, shouldUpdateCache) {
|
|
1347
1347
|
var _this = this;
|
|
1348
1348
|
if (shouldUpdateCache === void 0) { shouldUpdateCache = true; }
|
|
1349
|
-
return this.http.post(this.environment.apiV2 + "/" + this.url,
|
|
1349
|
+
return this.http.post(this.environment.apiV2 + "/" + this.url, data)
|
|
1350
1350
|
.pipe(operators.map(function (newItem) {
|
|
1351
1351
|
if (!shouldUpdateCache) {
|
|
1352
1352
|
return null;
|
|
@@ -1362,11 +1362,30 @@
|
|
|
1362
1362
|
return newInstance;
|
|
1363
1363
|
}));
|
|
1364
1364
|
};
|
|
1365
|
+
/**
|
|
1366
|
+
* @TODO Alex TT-1777 rename to post
|
|
1367
|
+
*/
|
|
1368
|
+
RestService.prototype.add = function (model, shouldUpdateCache) {
|
|
1369
|
+
if (shouldUpdateCache === void 0) { shouldUpdateCache = true; }
|
|
1370
|
+
return this.create(classTransformer.classToPlain(model), shouldUpdateCache);
|
|
1371
|
+
};
|
|
1372
|
+
/**
|
|
1373
|
+
* @TODO Alex TT-1777 rename to upload
|
|
1374
|
+
*/
|
|
1375
|
+
RestService.prototype.postForm = function (file, params) {
|
|
1376
|
+
if (params === void 0) { params = {}; }
|
|
1377
|
+
var formData = new FormData();
|
|
1378
|
+
formData.append('file', file);
|
|
1379
|
+
for (var key in params) {
|
|
1380
|
+
formData.append(key, params[key]);
|
|
1381
|
+
}
|
|
1382
|
+
return this.create(formData);
|
|
1383
|
+
};
|
|
1365
1384
|
/**
|
|
1366
1385
|
* Add several new items
|
|
1367
1386
|
* @param models Array of new items for saving
|
|
1368
1387
|
* @param queryParams query parameters for request
|
|
1369
|
-
* @TODO rename to postBatch
|
|
1388
|
+
* @TODO Alex TT-1777 rename to postBatch
|
|
1370
1389
|
*/
|
|
1371
1390
|
RestService.prototype.addBatch = function (models, queryParams) {
|
|
1372
1391
|
var _this = this;
|
|
@@ -1389,7 +1408,7 @@
|
|
|
1389
1408
|
* Update item
|
|
1390
1409
|
* @param model Existing instance for updating
|
|
1391
1410
|
* @param queryParams query parameters for request
|
|
1392
|
-
* @TODO rename to put
|
|
1411
|
+
* @TODO Alex TT-1777 rename to put
|
|
1393
1412
|
*/
|
|
1394
1413
|
RestService.prototype.update = function (model, queryParams) {
|
|
1395
1414
|
var _this = this;
|
|
@@ -1409,7 +1428,7 @@
|
|
|
1409
1428
|
* Update several items
|
|
1410
1429
|
* @param models Array of items for updating
|
|
1411
1430
|
* @param queryParams query parameters for request
|
|
1412
|
-
* TODO rename to putBatch
|
|
1431
|
+
* TODO Alex TT-1777 rename to putBatch
|
|
1413
1432
|
*/
|
|
1414
1433
|
RestService.prototype.updateBatch = function (models, queryParams) {
|
|
1415
1434
|
var _this = this;
|
|
@@ -1712,7 +1731,10 @@
|
|
|
1712
1731
|
*/
|
|
1713
1732
|
CollectionDictionary.prototype.merge = function (keys) {
|
|
1714
1733
|
var _this = this;
|
|
1715
|
-
|
|
1734
|
+
if (!this.length) {
|
|
1735
|
+
return this.createCollection([]);
|
|
1736
|
+
}
|
|
1737
|
+
return this.createCollection(flatten__default["default"](keys.map(function (key) { return _this.get(key.toString()).items; })));
|
|
1716
1738
|
};
|
|
1717
1739
|
/**
|
|
1718
1740
|
* Create instance of collection
|
|
@@ -3105,573 +3127,591 @@
|
|
|
3105
3127
|
classTransformer.Type(function () { return ChartAccountsMetadata; })
|
|
3106
3128
|
], ChartAccounts.prototype, "metadata", void 0);
|
|
3107
3129
|
|
|
3108
|
-
var
|
|
3109
|
-
__extends(
|
|
3110
|
-
function
|
|
3111
|
-
|
|
3112
|
-
_this.isGST = false;
|
|
3113
|
-
return _this;
|
|
3130
|
+
var TransactionBase = /** @class */ (function (_super) {
|
|
3131
|
+
__extends(TransactionBase, _super);
|
|
3132
|
+
function TransactionBase() {
|
|
3133
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3114
3134
|
}
|
|
3115
|
-
Object.defineProperty(
|
|
3135
|
+
Object.defineProperty(TransactionBase.prototype, "tankType", {
|
|
3116
3136
|
get: function () {
|
|
3117
|
-
|
|
3137
|
+
switch (true) {
|
|
3138
|
+
case this.isPropertyTank():
|
|
3139
|
+
return exports.TankTypeEnum.PROPERTY;
|
|
3140
|
+
case this.isWorkTank():
|
|
3141
|
+
return exports.TankTypeEnum.WORK;
|
|
3142
|
+
case this.isSoleTank():
|
|
3143
|
+
return exports.TankTypeEnum.SOLE;
|
|
3144
|
+
default:
|
|
3145
|
+
return exports.TankTypeEnum.OTHER;
|
|
3146
|
+
}
|
|
3118
3147
|
},
|
|
3119
3148
|
enumerable: false,
|
|
3120
3149
|
configurable: true
|
|
3121
3150
|
});
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3151
|
+
/**
|
|
3152
|
+
* Check if current tank is Property
|
|
3153
|
+
*/
|
|
3154
|
+
TransactionBase.prototype.isPropertyTank = function () {
|
|
3155
|
+
// chart accounts may be empty for new instances
|
|
3156
|
+
if (this.chartAccounts) {
|
|
3157
|
+
return CHART_ACCOUNTS_CATEGORIES.property.includes(this.chartAccounts.category);
|
|
3158
|
+
}
|
|
3159
|
+
return !!this.property;
|
|
3160
|
+
};
|
|
3161
|
+
/**
|
|
3162
|
+
* Check if current tank is Work
|
|
3163
|
+
*/
|
|
3164
|
+
TransactionBase.prototype.isWorkTank = function () {
|
|
3165
|
+
var _a;
|
|
3166
|
+
// chart accounts may be empty for new instances
|
|
3167
|
+
if (this.chartAccounts) {
|
|
3168
|
+
return CHART_ACCOUNTS_CATEGORIES.work.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
|
|
3169
|
+
}
|
|
3170
|
+
return !this.isPropertyTank() && !this.isSoleTank();
|
|
3171
|
+
};
|
|
3172
|
+
/**
|
|
3173
|
+
* Check if current tank is Sole
|
|
3174
|
+
*/
|
|
3175
|
+
TransactionBase.prototype.isSoleTank = function () {
|
|
3176
|
+
var _a;
|
|
3177
|
+
// chart accounts may be empty for new instances
|
|
3178
|
+
if (this.chartAccounts) {
|
|
3179
|
+
return CHART_ACCOUNTS_CATEGORIES.sole.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
|
|
3180
|
+
}
|
|
3181
|
+
return !!this.business;
|
|
3182
|
+
};
|
|
3183
|
+
return TransactionBase;
|
|
3184
|
+
}(AbstractModel));
|
|
3127
3185
|
__decorate([
|
|
3128
|
-
classTransformer.
|
|
3129
|
-
|
|
3186
|
+
classTransformer.Exclude({ toPlainOnly: true }),
|
|
3187
|
+
classTransformer.Type(function () { return Object; }),
|
|
3188
|
+
classTransformer.Transform(function (_b) {
|
|
3189
|
+
var obj = _b.obj;
|
|
3190
|
+
return obj.file;
|
|
3191
|
+
})
|
|
3192
|
+
], TransactionBase.prototype, "file", void 0);
|
|
3130
3193
|
|
|
3131
|
-
var
|
|
3132
|
-
__extends(
|
|
3133
|
-
function
|
|
3194
|
+
var Transaction$1 = /** @class */ (function (_super) {
|
|
3195
|
+
__extends(Transaction, _super);
|
|
3196
|
+
function Transaction() {
|
|
3134
3197
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3135
3198
|
}
|
|
3136
|
-
return
|
|
3137
|
-
}(
|
|
3199
|
+
return Transaction;
|
|
3200
|
+
}(TransactionBase));
|
|
3138
3201
|
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
}
|
|
3145
|
-
Object.defineProperty(SoleContact.prototype, "fullName", {
|
|
3146
|
-
get: function () {
|
|
3147
|
-
return this.firstName + " " + this.lastName;
|
|
3148
|
-
},
|
|
3149
|
-
enumerable: false,
|
|
3150
|
-
configurable: true
|
|
3151
|
-
});
|
|
3152
|
-
SoleContact.prototype.getPhotoPlaceholder = function () {
|
|
3153
|
-
return "" + this.firstName[0].toUpperCase() + this.lastName[0].toUpperCase();
|
|
3154
|
-
};
|
|
3155
|
-
// @TODO Vik: add photo field to SoleContact
|
|
3156
|
-
SoleContact.prototype.getPhoto = function () {
|
|
3157
|
-
return '';
|
|
3158
|
-
};
|
|
3159
|
-
return SoleContact;
|
|
3160
|
-
}(SoleContact$1));
|
|
3161
|
-
__decorate([
|
|
3162
|
-
classTransformer.Type(function () { return User; })
|
|
3163
|
-
], SoleContact.prototype, "user", void 0);
|
|
3164
|
-
__decorate([
|
|
3165
|
-
classTransformer.Type(function () { return Phone; })
|
|
3166
|
-
], SoleContact.prototype, "phone", void 0);
|
|
3167
|
-
__decorate([
|
|
3168
|
-
classTransformer.Type(function () { return Address; })
|
|
3169
|
-
], SoleContact.prototype, "address", void 0);
|
|
3170
|
-
__decorate([
|
|
3171
|
-
classTransformer.Type(function () { return SoleInvoice; })
|
|
3172
|
-
], SoleContact.prototype, "invoices", void 0);
|
|
3202
|
+
exports.TransactionTypeEnum = void 0;
|
|
3203
|
+
(function (TransactionTypeEnum) {
|
|
3204
|
+
TransactionTypeEnum[TransactionTypeEnum["DEBIT"] = 1] = "DEBIT";
|
|
3205
|
+
TransactionTypeEnum[TransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
|
|
3206
|
+
})(exports.TransactionTypeEnum || (exports.TransactionTypeEnum = {}));
|
|
3173
3207
|
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3208
|
+
exports.TransactionOperationEnum = void 0;
|
|
3209
|
+
(function (TransactionOperationEnum) {
|
|
3210
|
+
TransactionOperationEnum[TransactionOperationEnum["ALLOCATE"] = 1] = "ALLOCATE";
|
|
3211
|
+
TransactionOperationEnum[TransactionOperationEnum["FIND_AND_MATCH"] = 2] = "FIND_AND_MATCH";
|
|
3212
|
+
TransactionOperationEnum[TransactionOperationEnum["TRANSFER"] = 3] = "TRANSFER";
|
|
3213
|
+
})(exports.TransactionOperationEnum || (exports.TransactionOperationEnum = {}));
|
|
3214
|
+
|
|
3215
|
+
exports.TransactionSourceEnum = void 0;
|
|
3216
|
+
(function (TransactionSourceEnum) {
|
|
3217
|
+
TransactionSourceEnum[TransactionSourceEnum["CASH"] = 1] = "CASH";
|
|
3218
|
+
TransactionSourceEnum[TransactionSourceEnum["BANK_TRANSACTION"] = 2] = "BANK_TRANSACTION";
|
|
3219
|
+
})(exports.TransactionSourceEnum || (exports.TransactionSourceEnum = {}));
|
|
3220
|
+
|
|
3221
|
+
exports.DepreciationTypeEnum = void 0;
|
|
3222
|
+
(function (DepreciationTypeEnum) {
|
|
3223
|
+
DepreciationTypeEnum[DepreciationTypeEnum["PLANT_EQUIPMENT"] = 1] = "PLANT_EQUIPMENT";
|
|
3224
|
+
DepreciationTypeEnum[DepreciationTypeEnum["CAPITAL_WORKS"] = 2] = "CAPITAL_WORKS";
|
|
3225
|
+
DepreciationTypeEnum[DepreciationTypeEnum["BULK_DEPRECIATION"] = 3] = "BULK_DEPRECIATION";
|
|
3226
|
+
DepreciationTypeEnum[DepreciationTypeEnum["BORROWING_EXPENSES"] = 4] = "BORROWING_EXPENSES";
|
|
3227
|
+
})(exports.DepreciationTypeEnum || (exports.DepreciationTypeEnum = {}));
|
|
3228
|
+
|
|
3229
|
+
exports.DepreciationCalculationEnum = void 0;
|
|
3230
|
+
(function (DepreciationCalculationEnum) {
|
|
3231
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["PRIME_COST"] = 1] = "PRIME_COST";
|
|
3232
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["DIMINISHING"] = 2] = "DIMINISHING";
|
|
3233
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["CAPITAL"] = 3] = "CAPITAL";
|
|
3234
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["LVP"] = 4] = "LVP";
|
|
3235
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["AMORTISATION"] = 5] = "AMORTISATION";
|
|
3236
|
+
DepreciationCalculationEnum[DepreciationCalculationEnum["SBP"] = 6] = "SBP";
|
|
3237
|
+
})(exports.DepreciationCalculationEnum || (exports.DepreciationCalculationEnum = {}));
|
|
3238
|
+
|
|
3239
|
+
var TransactionReceipt$1 = /** @class */ (function (_super) {
|
|
3240
|
+
__extends(TransactionReceipt, _super);
|
|
3241
|
+
function TransactionReceipt() {
|
|
3177
3242
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3178
3243
|
}
|
|
3179
|
-
return
|
|
3244
|
+
return TransactionReceipt;
|
|
3180
3245
|
}(AbstractModel));
|
|
3181
3246
|
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3247
|
+
// @TODO this enum should come from backend
|
|
3248
|
+
/**
|
|
3249
|
+
* Enum with asset types
|
|
3250
|
+
*/
|
|
3251
|
+
exports.AssetTypeEnum = void 0;
|
|
3252
|
+
(function (AssetTypeEnum) {
|
|
3253
|
+
AssetTypeEnum["RECEIPTS"] = "receipts";
|
|
3254
|
+
AssetTypeEnum["DOCUMENTS"] = "documents";
|
|
3255
|
+
AssetTypeEnum["MESSAGE"] = "message";
|
|
3256
|
+
})(exports.AssetTypeEnum || (exports.AssetTypeEnum = {}));
|
|
3188
3257
|
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3258
|
+
/**
|
|
3259
|
+
* Enum with asset entity types
|
|
3260
|
+
*/
|
|
3261
|
+
exports.AssetEntityTypeEnum = void 0;
|
|
3262
|
+
(function (AssetEntityTypeEnum) {
|
|
3263
|
+
AssetEntityTypeEnum["PROPERTIES"] = "properties";
|
|
3264
|
+
AssetEntityTypeEnum["FOLDERS"] = "folders";
|
|
3265
|
+
AssetEntityTypeEnum["DEPRECIATIONS"] = "depreciations";
|
|
3266
|
+
AssetEntityTypeEnum["TRANSACTIONS"] = "transactions";
|
|
3267
|
+
AssetEntityTypeEnum["MESSAGES"] = "messages";
|
|
3268
|
+
})(exports.AssetEntityTypeEnum || (exports.AssetEntityTypeEnum = {}));
|
|
3269
|
+
|
|
3270
|
+
var TransactionReceipt = /** @class */ (function (_super) {
|
|
3271
|
+
__extends(TransactionReceipt, _super);
|
|
3272
|
+
function TransactionReceipt() {
|
|
3192
3273
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3193
|
-
_this.
|
|
3274
|
+
_this.type = exports.AssetTypeEnum.RECEIPTS;
|
|
3275
|
+
_this.entityType = exports.AssetEntityTypeEnum.TRANSACTIONS;
|
|
3194
3276
|
return _this;
|
|
3195
3277
|
}
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
};
|
|
3199
|
-
SoleInvoiceTemplate.prototype.isTaxExclusive = function () {
|
|
3200
|
-
return this.taxType === exports.SoleInvoiceTemplateTaxTypeEnum.EXCLUSIVE;
|
|
3201
|
-
};
|
|
3202
|
-
SoleInvoiceTemplate.prototype.isTaxInclusive = function () {
|
|
3203
|
-
return this.taxType === exports.SoleInvoiceTemplateTaxTypeEnum.INCLUSIVE;
|
|
3204
|
-
};
|
|
3205
|
-
return SoleInvoiceTemplate;
|
|
3206
|
-
}(SoleInvoiceTemplate$1));
|
|
3207
|
-
__decorate([
|
|
3208
|
-
classTransformer.Type(function () { return SoleBusiness; })
|
|
3209
|
-
], SoleInvoiceTemplate.prototype, "business", void 0);
|
|
3210
|
-
__decorate([
|
|
3211
|
-
classTransformer.Type(function () { return BankAccount; })
|
|
3212
|
-
], SoleInvoiceTemplate.prototype, "bankAccount", void 0);
|
|
3213
|
-
|
|
3214
|
-
exports.SoleInvoiceStatusesEnum = void 0;
|
|
3215
|
-
(function (SoleInvoiceStatusesEnum) {
|
|
3216
|
-
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["CANCELED"] = 0] = "CANCELED";
|
|
3217
|
-
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["DRAFT"] = 1] = "DRAFT";
|
|
3218
|
-
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PENDING"] = 2] = "PENDING";
|
|
3219
|
-
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PAID"] = 3] = "PAID";
|
|
3220
|
-
})(exports.SoleInvoiceStatusesEnum || (exports.SoleInvoiceStatusesEnum = {}));
|
|
3278
|
+
return TransactionReceipt;
|
|
3279
|
+
}(TransactionReceipt$1));
|
|
3221
3280
|
|
|
3222
|
-
var
|
|
3223
|
-
__extends(
|
|
3224
|
-
function
|
|
3281
|
+
var IncomeSource$1 = /** @class */ (function (_super) {
|
|
3282
|
+
__extends(IncomeSource, _super);
|
|
3283
|
+
function IncomeSource() {
|
|
3225
3284
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3226
3285
|
}
|
|
3227
|
-
return
|
|
3286
|
+
return IncomeSource;
|
|
3228
3287
|
}(AbstractModel));
|
|
3229
3288
|
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3289
|
+
exports.IncomeSourceTypeEnum = void 0;
|
|
3290
|
+
(function (IncomeSourceTypeEnum) {
|
|
3291
|
+
IncomeSourceTypeEnum[IncomeSourceTypeEnum["WORK"] = 1] = "WORK";
|
|
3292
|
+
IncomeSourceTypeEnum[IncomeSourceTypeEnum["SOLE"] = 2] = "SOLE";
|
|
3293
|
+
IncomeSourceTypeEnum[IncomeSourceTypeEnum["OTHER"] = 3] = "OTHER";
|
|
3294
|
+
})(exports.IncomeSourceTypeEnum || (exports.IncomeSourceTypeEnum = {}));
|
|
3295
|
+
|
|
3296
|
+
var SalaryForecast$1 = /** @class */ (function (_super) {
|
|
3297
|
+
__extends(SalaryForecast, _super);
|
|
3298
|
+
function SalaryForecast() {
|
|
3233
3299
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3234
3300
|
}
|
|
3235
|
-
return
|
|
3236
|
-
}(
|
|
3237
|
-
SoleDetails.GSTPercentMultiplier = 0.1;
|
|
3238
|
-
SoleDetails.GSTPercentDivider = 11;
|
|
3239
|
-
__decorate([
|
|
3240
|
-
classTransformer.Type(function () { return User; })
|
|
3241
|
-
], SoleDetails.prototype, "user", void 0);
|
|
3301
|
+
return SalaryForecast;
|
|
3302
|
+
}(AbstractModel));
|
|
3242
3303
|
|
|
3243
|
-
var
|
|
3244
|
-
__extends(
|
|
3245
|
-
function
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3304
|
+
var SalaryForecast = /** @class */ (function (_super) {
|
|
3305
|
+
__extends(SalaryForecast, _super);
|
|
3306
|
+
function SalaryForecast() {
|
|
3307
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3308
|
+
}
|
|
3309
|
+
return SalaryForecast;
|
|
3310
|
+
}(SalaryForecast$1));
|
|
3311
|
+
__decorate([
|
|
3312
|
+
classTransformer.Transform(function (_a) {
|
|
3313
|
+
var obj = _a.obj;
|
|
3314
|
+
return obj.netPay + obj.tax;
|
|
3315
|
+
}),
|
|
3316
|
+
classTransformer.Expose()
|
|
3317
|
+
], SalaryForecast.prototype, "grossAmount", void 0);
|
|
3318
|
+
__decorate([
|
|
3319
|
+
classTransformer.Type(function () { return IncomeSource; })
|
|
3320
|
+
], SalaryForecast.prototype, "incomeSource", void 0);
|
|
3321
|
+
|
|
3322
|
+
var SoleForecast$1 = /** @class */ (function (_super) {
|
|
3323
|
+
__extends(SoleForecast, _super);
|
|
3324
|
+
function SoleForecast() {
|
|
3325
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3326
|
+
}
|
|
3327
|
+
return SoleForecast;
|
|
3328
|
+
}(AbstractModel));
|
|
3329
|
+
|
|
3330
|
+
var SoleForecast = /** @class */ (function (_super) {
|
|
3331
|
+
__extends(SoleForecast, _super);
|
|
3332
|
+
function SoleForecast() {
|
|
3333
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3250
3334
|
}
|
|
3251
|
-
Object.defineProperty(
|
|
3335
|
+
Object.defineProperty(SoleForecast.prototype, "netPay", {
|
|
3252
3336
|
get: function () {
|
|
3253
|
-
return this.
|
|
3337
|
+
return this.amount;
|
|
3254
3338
|
},
|
|
3255
3339
|
enumerable: false,
|
|
3256
3340
|
configurable: true
|
|
3257
3341
|
});
|
|
3258
|
-
|
|
3259
|
-
|
|
3342
|
+
;
|
|
3343
|
+
return SoleForecast;
|
|
3344
|
+
}(SoleForecast$1));
|
|
3345
|
+
__decorate([
|
|
3346
|
+
classTransformer.Type(function () { return IncomeSource; })
|
|
3347
|
+
], SoleForecast.prototype, "incomeSource", void 0);
|
|
3348
|
+
|
|
3349
|
+
var IncomeSourceForecast$1 = /** @class */ (function (_super) {
|
|
3350
|
+
__extends(IncomeSourceForecast, _super);
|
|
3351
|
+
function IncomeSourceForecast() {
|
|
3352
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3353
|
+
}
|
|
3354
|
+
return IncomeSourceForecast;
|
|
3355
|
+
}(AbstractModel));
|
|
3356
|
+
|
|
3357
|
+
exports.SalaryForecastFrequencyEnum = void 0;
|
|
3358
|
+
(function (SalaryForecastFrequencyEnum) {
|
|
3359
|
+
SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["ANNUAL"] = 1] = "ANNUAL";
|
|
3360
|
+
SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["MONTHLY"] = 12] = "MONTHLY";
|
|
3361
|
+
SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["FORTNIGHTLY"] = 26] = "FORTNIGHTLY";
|
|
3362
|
+
SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["WEEKLY"] = 52] = "WEEKLY";
|
|
3363
|
+
})(exports.SalaryForecastFrequencyEnum || (exports.SalaryForecastFrequencyEnum = {}));
|
|
3364
|
+
|
|
3365
|
+
var IncomeSourceType$1 = /** @class */ (function (_super) {
|
|
3366
|
+
__extends(IncomeSourceType, _super);
|
|
3367
|
+
function IncomeSourceType() {
|
|
3368
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3369
|
+
}
|
|
3370
|
+
return IncomeSourceType;
|
|
3371
|
+
}(AbstractModel));
|
|
3372
|
+
|
|
3373
|
+
exports.IncomeSourceTypeListWorkEnum = void 0;
|
|
3374
|
+
(function (IncomeSourceTypeListWorkEnum) {
|
|
3375
|
+
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["BONUSES"] = 1] = "BONUSES";
|
|
3376
|
+
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIRECTOR_FEES"] = 2] = "DIRECTOR_FEES";
|
|
3377
|
+
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIVIDENDS"] = 3] = "DIVIDENDS";
|
|
3378
|
+
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["INTEREST"] = 4] = "INTEREST";
|
|
3379
|
+
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["PENSIONS_AND_ALLOWANCES"] = 5] = "PENSIONS_AND_ALLOWANCES";
|
|
3380
|
+
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["SUPERANNUATION"] = 8] = "SUPERANNUATION";
|
|
3381
|
+
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["ATTRIBUTED_P_S_I"] = 11] = "ATTRIBUTED_P_S_I";
|
|
3382
|
+
})(exports.IncomeSourceTypeListWorkEnum || (exports.IncomeSourceTypeListWorkEnum = {}));
|
|
3383
|
+
|
|
3384
|
+
exports.IncomeSourceTypeListOtherEnum = void 0;
|
|
3385
|
+
(function (IncomeSourceTypeListOtherEnum) {
|
|
3386
|
+
IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PSI"] = 6] = "PSI";
|
|
3387
|
+
IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
|
|
3388
|
+
IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["TRUSTS"] = 9] = "TRUSTS";
|
|
3389
|
+
IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["OTHER_INCOME"] = 10] = "OTHER_INCOME";
|
|
3390
|
+
IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PARTNERSHIPS"] = 12] = "PARTNERSHIPS";
|
|
3391
|
+
})(exports.IncomeSourceTypeListOtherEnum || (exports.IncomeSourceTypeListOtherEnum = {}));
|
|
3392
|
+
|
|
3393
|
+
exports.IncomeSourceTypeListSoleEnum = void 0;
|
|
3394
|
+
(function (IncomeSourceTypeListSoleEnum) {
|
|
3395
|
+
IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
|
|
3396
|
+
})(exports.IncomeSourceTypeListSoleEnum || (exports.IncomeSourceTypeListSoleEnum = {}));
|
|
3397
|
+
|
|
3398
|
+
var IncomeSourceType = /** @class */ (function (_super) {
|
|
3399
|
+
__extends(IncomeSourceType, _super);
|
|
3400
|
+
function IncomeSourceType() {
|
|
3401
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3402
|
+
}
|
|
3403
|
+
IncomeSourceType.prototype.isBonuses = function () {
|
|
3404
|
+
return this.id === exports.IncomeSourceTypeListWorkEnum.BONUSES;
|
|
3405
|
+
};
|
|
3406
|
+
IncomeSourceType.prototype.isWork = function () {
|
|
3407
|
+
return !!exports.IncomeSourceTypeListWorkEnum[this.id];
|
|
3408
|
+
};
|
|
3409
|
+
IncomeSourceType.prototype.isOther = function () {
|
|
3410
|
+
return !!exports.IncomeSourceTypeListOtherEnum[this.id];
|
|
3260
3411
|
};
|
|
3261
|
-
|
|
3262
|
-
return this.
|
|
3412
|
+
IncomeSourceType.prototype.isSole = function () {
|
|
3413
|
+
return !!exports.IncomeSourceTypeListSoleEnum[this.id];
|
|
3263
3414
|
};
|
|
3264
|
-
Object.defineProperty(
|
|
3415
|
+
Object.defineProperty(IncomeSourceType.prototype, "type", {
|
|
3265
3416
|
get: function () {
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3417
|
+
switch (true) {
|
|
3418
|
+
case this.isWork():
|
|
3419
|
+
return exports.IncomeSourceTypeEnum.WORK;
|
|
3420
|
+
case this.isSole():
|
|
3421
|
+
return exports.IncomeSourceTypeEnum.SOLE;
|
|
3422
|
+
default:
|
|
3423
|
+
return exports.IncomeSourceTypeEnum.OTHER;
|
|
3269
3424
|
}
|
|
3270
|
-
return this.amount;
|
|
3271
3425
|
},
|
|
3272
3426
|
enumerable: false,
|
|
3273
3427
|
configurable: true
|
|
3274
3428
|
});
|
|
3275
|
-
|
|
3429
|
+
return IncomeSourceType;
|
|
3430
|
+
}(IncomeSourceType$1));
|
|
3431
|
+
|
|
3432
|
+
var IncomeSourceForecast = /** @class */ (function (_super) {
|
|
3433
|
+
__extends(IncomeSourceForecast, _super);
|
|
3434
|
+
function IncomeSourceForecast() {
|
|
3435
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3436
|
+
_this.paygIncome = 0;
|
|
3437
|
+
_this.frequency = exports.SalaryForecastFrequencyEnum.ANNUAL;
|
|
3438
|
+
_this.isTaxFree = false;
|
|
3439
|
+
return _this;
|
|
3440
|
+
}
|
|
3441
|
+
Object.defineProperty(IncomeSourceForecast.prototype, "netPay", {
|
|
3442
|
+
/**
|
|
3443
|
+
* Sometimes Income source has Salary & Income source forecasts,
|
|
3444
|
+
* and we need these fields to work with Income source forecasts like with Salary Forecasts
|
|
3445
|
+
*/
|
|
3276
3446
|
get: function () {
|
|
3277
|
-
|
|
3278
|
-
switch (true) {
|
|
3279
|
-
case (_a = this.template) === null || _a === void 0 ? void 0 : _a.isTaxInclusive():
|
|
3280
|
-
return +(this.getGSTItemsAmount() / SoleDetails.GSTPercentDivider).toFixed(2);
|
|
3281
|
-
case (_b = this.template) === null || _b === void 0 ? void 0 : _b.isTaxExclusive():
|
|
3282
|
-
return +(this.getGSTItemsAmount() * SoleDetails.GSTPercentMultiplier).toFixed(2);
|
|
3283
|
-
default:
|
|
3284
|
-
return 0;
|
|
3285
|
-
}
|
|
3447
|
+
return this.amount;
|
|
3286
3448
|
},
|
|
3287
3449
|
enumerable: false,
|
|
3288
3450
|
configurable: true
|
|
3289
3451
|
});
|
|
3290
|
-
Object.defineProperty(
|
|
3452
|
+
Object.defineProperty(IncomeSourceForecast.prototype, "grossAmount", {
|
|
3291
3453
|
get: function () {
|
|
3292
|
-
|
|
3293
|
-
if ((_a = this.template) === null || _a === void 0 ? void 0 : _a.isTaxExclusive()) {
|
|
3294
|
-
return this.amount + this.GSTAmount;
|
|
3295
|
-
}
|
|
3296
|
-
return this.amount;
|
|
3454
|
+
return this.amount + this.tax + this.taxInstalments + this.frankingCredits;
|
|
3297
3455
|
},
|
|
3298
3456
|
enumerable: false,
|
|
3299
3457
|
configurable: true
|
|
3300
3458
|
});
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3459
|
+
return IncomeSourceForecast;
|
|
3460
|
+
}(IncomeSourceForecast$1));
|
|
3461
|
+
__decorate([
|
|
3462
|
+
classTransformer.Type(function () { return IncomeSourceType; })
|
|
3463
|
+
], IncomeSourceForecast.prototype, "incomeSourceType", void 0);
|
|
3464
|
+
__decorate([
|
|
3465
|
+
classTransformer.Type(function () { return IncomeSource; })
|
|
3466
|
+
], IncomeSourceForecast.prototype, "incomeSource", void 0);
|
|
3467
|
+
|
|
3468
|
+
var IncomeSource = /** @class */ (function (_super) {
|
|
3469
|
+
__extends(IncomeSource, _super);
|
|
3470
|
+
function IncomeSource() {
|
|
3471
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3472
|
+
}
|
|
3473
|
+
IncomeSource.prototype.isSalaryIncome = function () {
|
|
3474
|
+
return !!this.salaryForecasts.length;
|
|
3475
|
+
// @TODO Vik: old code
|
|
3476
|
+
// return this.type === IncomeSourceTypeEnum.SALARY;
|
|
3306
3477
|
};
|
|
3307
|
-
|
|
3308
|
-
return this.
|
|
3478
|
+
IncomeSource.prototype.isSoleIncome = function () {
|
|
3479
|
+
return !!this.soleForecasts.length;
|
|
3309
3480
|
};
|
|
3310
|
-
|
|
3311
|
-
return this.
|
|
3481
|
+
IncomeSource.prototype.isWorkIncome = function () {
|
|
3482
|
+
return this.type === exports.IncomeSourceTypeEnum.WORK;
|
|
3312
3483
|
};
|
|
3313
|
-
|
|
3314
|
-
return this.
|
|
3484
|
+
IncomeSource.prototype.isOtherIncome = function () {
|
|
3485
|
+
return this.type === exports.IncomeSourceTypeEnum.OTHER || (!this.isSoleIncome() && !this.isSalaryIncome());
|
|
3315
3486
|
};
|
|
3316
|
-
|
|
3317
|
-
|
|
3487
|
+
Object.defineProperty(IncomeSource.prototype, "forecasts", {
|
|
3488
|
+
/**
|
|
3489
|
+
* Get salary and other income forecasts
|
|
3490
|
+
*/
|
|
3491
|
+
get: function () {
|
|
3492
|
+
return __spreadArray(__spreadArray(__spreadArray([], __read(this.salaryForecasts)), __read(this.incomeSourceForecasts)), __read(this.soleForecasts));
|
|
3493
|
+
},
|
|
3494
|
+
enumerable: false,
|
|
3495
|
+
configurable: true
|
|
3496
|
+
});
|
|
3497
|
+
Object.defineProperty(IncomeSource.prototype, "actualForecast", {
|
|
3498
|
+
/**
|
|
3499
|
+
* Get actual (1st from the list) forecast
|
|
3500
|
+
*/
|
|
3501
|
+
get: function () {
|
|
3502
|
+
return this.forecasts[0];
|
|
3503
|
+
},
|
|
3504
|
+
enumerable: false,
|
|
3505
|
+
configurable: true
|
|
3506
|
+
});
|
|
3507
|
+
/**
|
|
3508
|
+
* Check if user was working in month taken by the index
|
|
3509
|
+
* @param monthIndex by which month should be taken
|
|
3510
|
+
*/
|
|
3511
|
+
IncomeSource.prototype.isWorkedInMonth = function (monthIndex) {
|
|
3512
|
+
var monthDate = new FinancialYear().getMonthDate(monthIndex);
|
|
3513
|
+
return (!this.dateFrom || monthDate >= this.dateFrom) && (!this.dateTo || monthDate < this.dateTo);
|
|
3318
3514
|
};
|
|
3319
|
-
return
|
|
3320
|
-
}(
|
|
3321
|
-
__decorate([
|
|
3322
|
-
classTransformer.Type(function () { return Date; })
|
|
3323
|
-
], SoleInvoice.prototype, "dateFrom", void 0);
|
|
3324
|
-
__decorate([
|
|
3325
|
-
classTransformer.Type(function () { return Date; })
|
|
3326
|
-
], SoleInvoice.prototype, "dateTo", void 0);
|
|
3327
|
-
__decorate([
|
|
3328
|
-
classTransformer.Type(function () { return User; })
|
|
3329
|
-
], SoleInvoice.prototype, "user", void 0);
|
|
3330
|
-
__decorate([
|
|
3331
|
-
classTransformer.Type(function () { return SoleBusiness; })
|
|
3332
|
-
], SoleInvoice.prototype, "business", void 0);
|
|
3515
|
+
return IncomeSource;
|
|
3516
|
+
}(IncomeSource$1));
|
|
3333
3517
|
__decorate([
|
|
3334
|
-
classTransformer.Type(function () { return
|
|
3335
|
-
],
|
|
3518
|
+
classTransformer.Type(function () { return SalaryForecast; })
|
|
3519
|
+
], IncomeSource.prototype, "salaryForecasts", void 0);
|
|
3336
3520
|
__decorate([
|
|
3337
|
-
classTransformer.Type(function () { return
|
|
3338
|
-
],
|
|
3521
|
+
classTransformer.Type(function () { return SoleForecast; })
|
|
3522
|
+
], IncomeSource.prototype, "soleForecasts", void 0);
|
|
3339
3523
|
__decorate([
|
|
3340
|
-
classTransformer.Type(function () { return
|
|
3341
|
-
],
|
|
3342
|
-
|
|
3343
|
-
/**
|
|
3344
|
-
* Class contains traveled kilometers and work usage percent in 12 weeks date range
|
|
3345
|
-
* @TODO Vik: Best period: move this and related logic to backend
|
|
3346
|
-
* @TODO Alex: check if we need this class when calculation refactored with backend
|
|
3347
|
-
*/
|
|
3348
|
-
var LogbookPeriod = /** @class */ (function () {
|
|
3349
|
-
function LogbookPeriod() {
|
|
3350
|
-
}
|
|
3351
|
-
LogbookPeriod.prototype.isEndOfYear = function () {
|
|
3352
|
-
return this.to === new FinancialYear().endDate;
|
|
3353
|
-
};
|
|
3354
|
-
LogbookPeriod.prototype.getWorkUsageByClaim = function (claim) {
|
|
3355
|
-
var claimKilometers = this.logbooks.getByVehicleClaim(claim).getClaimableLogbooks().kilometers;
|
|
3356
|
-
return Math.round(this.workUsage * (claimKilometers / this.kilometers));
|
|
3357
|
-
};
|
|
3358
|
-
return LogbookPeriod;
|
|
3359
|
-
}());
|
|
3524
|
+
classTransformer.Type(function () { return IncomeSourceForecast; })
|
|
3525
|
+
], IncomeSource.prototype, "incomeSourceForecasts", void 0);
|
|
3360
3526
|
__decorate([
|
|
3361
3527
|
classTransformer.Type(function () { return Date; })
|
|
3362
|
-
],
|
|
3528
|
+
], IncomeSource.prototype, "dateFrom", void 0);
|
|
3363
3529
|
__decorate([
|
|
3364
3530
|
classTransformer.Type(function () { return Date; })
|
|
3365
|
-
],
|
|
3531
|
+
], IncomeSource.prototype, "dateTo", void 0);
|
|
3366
3532
|
|
|
3367
|
-
var
|
|
3368
|
-
__extends(
|
|
3369
|
-
function
|
|
3533
|
+
var TransactionMetadata$1 = /** @class */ (function (_super) {
|
|
3534
|
+
__extends(TransactionMetadata, _super);
|
|
3535
|
+
function TransactionMetadata() {
|
|
3370
3536
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3371
3537
|
}
|
|
3372
|
-
return
|
|
3538
|
+
return TransactionMetadata;
|
|
3373
3539
|
}(AbstractModel));
|
|
3374
3540
|
|
|
3375
|
-
var
|
|
3376
|
-
__extends(
|
|
3377
|
-
function
|
|
3541
|
+
var TransactionMetadata = /** @class */ (function (_super) {
|
|
3542
|
+
__extends(TransactionMetadata, _super);
|
|
3543
|
+
function TransactionMetadata() {
|
|
3378
3544
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3379
3545
|
}
|
|
3380
|
-
return
|
|
3546
|
+
return TransactionMetadata;
|
|
3547
|
+
}(TransactionMetadata$1));
|
|
3548
|
+
__decorate([
|
|
3549
|
+
classTransformer.Type(function () { return ChartAccountsMetadata; })
|
|
3550
|
+
], TransactionMetadata.prototype, "metadata", void 0);
|
|
3551
|
+
|
|
3552
|
+
var TransactionAllocation$1 = /** @class */ (function (_super) {
|
|
3553
|
+
__extends(TransactionAllocation, _super);
|
|
3554
|
+
function TransactionAllocation() {
|
|
3555
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3556
|
+
}
|
|
3557
|
+
return TransactionAllocation;
|
|
3381
3558
|
}(AbstractModel));
|
|
3382
3559
|
|
|
3383
|
-
var
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
function VehicleLogbook() {
|
|
3560
|
+
var BankTransaction$1 = /** @class */ (function (_super) {
|
|
3561
|
+
__extends(BankTransaction, _super);
|
|
3562
|
+
function BankTransaction() {
|
|
3387
3563
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3388
3564
|
}
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3565
|
+
return BankTransaction;
|
|
3566
|
+
}(AbstractModel));
|
|
3567
|
+
|
|
3568
|
+
exports.BankTransactionTypeEnum = void 0;
|
|
3569
|
+
(function (BankTransactionTypeEnum) {
|
|
3570
|
+
BankTransactionTypeEnum[BankTransactionTypeEnum["DEBIT"] = 1] = "DEBIT";
|
|
3571
|
+
BankTransactionTypeEnum[BankTransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
|
|
3572
|
+
})(exports.BankTransactionTypeEnum || (exports.BankTransactionTypeEnum = {}));
|
|
3573
|
+
|
|
3574
|
+
var BankTransaction = /** @class */ (function (_super) {
|
|
3575
|
+
__extends(BankTransaction, _super);
|
|
3576
|
+
function BankTransaction() {
|
|
3577
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3578
|
+
// allocated money amount for bank transaction
|
|
3579
|
+
_this.allocatedAmount = 0;
|
|
3580
|
+
_this.unallocatedAmount = 0;
|
|
3581
|
+
return _this;
|
|
3582
|
+
}
|
|
3583
|
+
Object.defineProperty(BankTransaction.prototype, "balanceAmount", {
|
|
3584
|
+
/**
|
|
3585
|
+
* get allocated amount value but with +/- sign
|
|
3586
|
+
*/
|
|
3397
3587
|
get: function () {
|
|
3398
|
-
return this.
|
|
3588
|
+
return this.isCredit() ? this.allocatedAmount : -this.allocatedAmount;
|
|
3399
3589
|
},
|
|
3400
3590
|
enumerable: false,
|
|
3401
3591
|
configurable: true
|
|
3402
3592
|
});
|
|
3403
|
-
|
|
3404
|
-
|
|
3593
|
+
/**
|
|
3594
|
+
* check if bank transaction is debit
|
|
3595
|
+
*/
|
|
3596
|
+
BankTransaction.prototype.isDebit = function () {
|
|
3597
|
+
return this.type === exports.BankTransactionTypeEnum.DEBIT;
|
|
3405
3598
|
};
|
|
3406
|
-
|
|
3407
|
-
|
|
3599
|
+
/**
|
|
3600
|
+
* check if bank transaction is credit
|
|
3601
|
+
*/
|
|
3602
|
+
BankTransaction.prototype.isCredit = function () {
|
|
3603
|
+
return this.type === exports.BankTransactionTypeEnum.CREDIT;
|
|
3408
3604
|
};
|
|
3409
3605
|
/**
|
|
3410
|
-
*
|
|
3606
|
+
* Create Transaction instance based on Bank Transaction
|
|
3411
3607
|
*/
|
|
3412
|
-
|
|
3413
|
-
return
|
|
3608
|
+
BankTransaction.prototype.toTransaction = function () {
|
|
3609
|
+
return classTransformer.plainToClass(Transaction, {
|
|
3610
|
+
amount: +this.amount.toFixed(2),
|
|
3611
|
+
description: this.description,
|
|
3612
|
+
date: this.date,
|
|
3613
|
+
source: exports.TransactionSourceEnum.BANK_TRANSACTION,
|
|
3614
|
+
operation: this.operation,
|
|
3615
|
+
type: this.type,
|
|
3616
|
+
});
|
|
3414
3617
|
};
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3618
|
+
/**
|
|
3619
|
+
* Check if bank transaction is completely allocated
|
|
3620
|
+
*/
|
|
3621
|
+
BankTransaction.prototype.isAllocated = function (allocations) {
|
|
3622
|
+
return this.amount === this.getAllocatedAmount(allocations);
|
|
3623
|
+
};
|
|
3624
|
+
/**
|
|
3625
|
+
* Get bank transaction allocated amount
|
|
3626
|
+
*/
|
|
3627
|
+
BankTransaction.prototype.getAllocatedAmount = function (allocations) {
|
|
3628
|
+
return allocations.getByBankTransactionsIds([this.id]).amount;
|
|
3629
|
+
};
|
|
3630
|
+
/**
|
|
3631
|
+
* Get bank transaction unallocated amount
|
|
3632
|
+
*/
|
|
3633
|
+
BankTransaction.prototype.getUnallocatedAmount = function (allocations) {
|
|
3634
|
+
return this.amount - this.getAllocatedAmount(allocations);
|
|
3635
|
+
};
|
|
3636
|
+
return BankTransaction;
|
|
3637
|
+
}(BankTransaction$1));
|
|
3422
3638
|
__decorate([
|
|
3423
3639
|
classTransformer.Type(function () { return Date; })
|
|
3424
|
-
],
|
|
3425
|
-
__decorate([
|
|
3426
|
-
classTransformer.Type(function () { return SoleBusiness; })
|
|
3427
|
-
], VehicleLogbook.prototype, "business", void 0);
|
|
3640
|
+
], BankTransaction.prototype, "date", void 0);
|
|
3428
3641
|
|
|
3429
|
-
var
|
|
3430
|
-
__extends(
|
|
3431
|
-
function
|
|
3642
|
+
var TransactionAllocation = /** @class */ (function (_super) {
|
|
3643
|
+
__extends(TransactionAllocation, _super);
|
|
3644
|
+
function TransactionAllocation() {
|
|
3432
3645
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3433
3646
|
}
|
|
3434
|
-
|
|
3435
|
-
|
|
3647
|
+
/**
|
|
3648
|
+
* Create a new instance of transaction allocation
|
|
3649
|
+
* transaction could be empty since we can POST allocation inside a new transaction
|
|
3650
|
+
*/
|
|
3651
|
+
TransactionAllocation.create = function (amount, bankTransaction, transaction) {
|
|
3652
|
+
return classTransformer.plainToClass(TransactionAllocation, { amount: amount, transaction: transaction, bankTransaction: bankTransaction });
|
|
3653
|
+
};
|
|
3654
|
+
return TransactionAllocation;
|
|
3655
|
+
}(TransactionAllocation$1));
|
|
3436
3656
|
__decorate([
|
|
3437
|
-
classTransformer.Type(function () { return
|
|
3438
|
-
],
|
|
3657
|
+
classTransformer.Type(function () { return BankTransaction; })
|
|
3658
|
+
], TransactionAllocation.prototype, "bankTransaction", void 0);
|
|
3659
|
+
__decorate([
|
|
3660
|
+
classTransformer.Type(function () { return Transaction; })
|
|
3661
|
+
], TransactionAllocation.prototype, "transaction", void 0);
|
|
3439
3662
|
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3663
|
+
/**
|
|
3664
|
+
* Enum with income amount types (Net or Gross)
|
|
3665
|
+
*/
|
|
3666
|
+
exports.IncomeAmountTypeEnum = void 0;
|
|
3667
|
+
(function (IncomeAmountTypeEnum) {
|
|
3668
|
+
IncomeAmountTypeEnum[IncomeAmountTypeEnum["NET"] = 0] = "NET";
|
|
3669
|
+
IncomeAmountTypeEnum[IncomeAmountTypeEnum["GROSS"] = 1] = "GROSS";
|
|
3670
|
+
})(exports.IncomeAmountTypeEnum || (exports.IncomeAmountTypeEnum = {}));
|
|
3671
|
+
|
|
3672
|
+
var Depreciation$1 = /** @class */ (function (_super) {
|
|
3673
|
+
__extends(Depreciation, _super);
|
|
3674
|
+
function Depreciation() {
|
|
3443
3675
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3444
3676
|
}
|
|
3445
|
-
return
|
|
3446
|
-
}(
|
|
3677
|
+
return Depreciation;
|
|
3678
|
+
}(TransactionBase));
|
|
3447
3679
|
|
|
3448
|
-
var
|
|
3449
|
-
__extends(
|
|
3450
|
-
function
|
|
3680
|
+
var DepreciationCapitalProject$1 = /** @class */ (function (_super) {
|
|
3681
|
+
__extends(DepreciationCapitalProject, _super);
|
|
3682
|
+
function DepreciationCapitalProject() {
|
|
3451
3683
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3452
3684
|
}
|
|
3453
|
-
return
|
|
3685
|
+
return DepreciationCapitalProject;
|
|
3454
3686
|
}(AbstractModel));
|
|
3455
3687
|
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
})(exports.VehicleClaimDetailsMethodEnum || (exports.VehicleClaimDetailsMethodEnum = {}));
|
|
3461
|
-
|
|
3462
|
-
var VehicleClaimDetails = /** @class */ (function (_super) {
|
|
3463
|
-
__extends(VehicleClaimDetails, _super);
|
|
3464
|
-
function VehicleClaimDetails() {
|
|
3465
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3466
|
-
/**
|
|
3467
|
-
* Init default values for the new instances
|
|
3468
|
-
*/
|
|
3469
|
-
_this.isManual = true;
|
|
3470
|
-
_this.method = exports.VehicleClaimDetailsMethodEnum.KMS;
|
|
3471
|
-
_this.financialYear = new FinancialYear().year;
|
|
3472
|
-
return _this;
|
|
3688
|
+
var DepreciationCapitalProject = /** @class */ (function (_super) {
|
|
3689
|
+
__extends(DepreciationCapitalProject, _super);
|
|
3690
|
+
function DepreciationCapitalProject() {
|
|
3691
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3473
3692
|
}
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
};
|
|
3477
|
-
VehicleClaimDetails.prototype.isKmsMethod = function () {
|
|
3478
|
-
return this.method === exports.VehicleClaimDetailsMethodEnum.KMS;
|
|
3479
|
-
};
|
|
3480
|
-
return VehicleClaimDetails;
|
|
3481
|
-
}(VehicleClaimDetails$1));
|
|
3693
|
+
return DepreciationCapitalProject;
|
|
3694
|
+
}(DepreciationCapitalProject$1));
|
|
3482
3695
|
__decorate([
|
|
3483
|
-
classTransformer.Type(function () { return
|
|
3484
|
-
],
|
|
3696
|
+
classTransformer.Type(function () { return Date; })
|
|
3697
|
+
], DepreciationCapitalProject.prototype, "effectiveDate", void 0);
|
|
3485
3698
|
|
|
3486
|
-
var
|
|
3487
|
-
__extends(
|
|
3488
|
-
function
|
|
3489
|
-
|
|
3490
|
-
_this.kilometers = 0;
|
|
3491
|
-
_this.workUsage = 0;
|
|
3492
|
-
return _this;
|
|
3699
|
+
var DepreciationForecast$1 = /** @class */ (function (_super) {
|
|
3700
|
+
__extends(DepreciationForecast, _super);
|
|
3701
|
+
function DepreciationForecast() {
|
|
3702
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3493
3703
|
}
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3704
|
+
return DepreciationForecast;
|
|
3705
|
+
}(AbstractModel));
|
|
3706
|
+
|
|
3707
|
+
var DepreciationForecast = /** @class */ (function (_super) {
|
|
3708
|
+
__extends(DepreciationForecast, _super);
|
|
3709
|
+
function DepreciationForecast() {
|
|
3710
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3711
|
+
}
|
|
3712
|
+
Object.defineProperty(DepreciationForecast.prototype, "dailyClaimAmount", {
|
|
3501
3713
|
get: function () {
|
|
3502
|
-
return this.
|
|
3503
|
-
},
|
|
3504
|
-
enumerable: false,
|
|
3505
|
-
configurable: true
|
|
3506
|
-
});
|
|
3507
|
-
/**
|
|
3508
|
-
* Claim amount for KMs method. Exists only for KMs method.
|
|
3509
|
-
*/
|
|
3510
|
-
VehicleClaim.prototype.getKMSClaimAmount = function (vehicleClaimRate) {
|
|
3511
|
-
return +(this.kilometers * vehicleClaimRate).toFixed(2);
|
|
3512
|
-
};
|
|
3513
|
-
/**
|
|
3514
|
-
* Get logbook claim amount. Exists only for logbook method.
|
|
3515
|
-
* ClaimAmount = WorkUsage * transaction/depreciation amount
|
|
3516
|
-
*/
|
|
3517
|
-
VehicleClaim.prototype.getLogbookClaimAmount = function (transactions) {
|
|
3518
|
-
var transactionsAmount = transactions
|
|
3519
|
-
.getByVehicleClaim(this)
|
|
3520
|
-
.getLogbookTransactions()
|
|
3521
|
-
.sumBy('amount');
|
|
3522
|
-
// Math.abs because amount will be negative (because we sum expenses), but we don't want negative percent value
|
|
3523
|
-
return Math.abs(transactionsAmount) * this.workUsage / 100;
|
|
3524
|
-
};
|
|
3525
|
-
VehicleClaim.prototype.getAverageWeeklyKMS = function () {
|
|
3526
|
-
return this.kilometers / FinancialYear.weeksInYear;
|
|
3527
|
-
};
|
|
3528
|
-
VehicleClaim.getKMSChartAccountsIdByTankType = function (tankType) {
|
|
3529
|
-
return tankType === exports.TankTypeEnum.WORK
|
|
3530
|
-
? exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK
|
|
3531
|
-
: exports.ChartAccountsListEnum.KLMS_TRAVELLED;
|
|
3532
|
-
};
|
|
3533
|
-
return VehicleClaim;
|
|
3534
|
-
}(VehicleClaim$1));
|
|
3535
|
-
/**
|
|
3536
|
-
* limit for kms claim method
|
|
3537
|
-
*/
|
|
3538
|
-
VehicleClaim.totalKmsLimit = 5000;
|
|
3539
|
-
/**
|
|
3540
|
-
* limit for work usage claim method
|
|
3541
|
-
*/
|
|
3542
|
-
VehicleClaim.totalWorkUsagePercent = 100;
|
|
3543
|
-
__decorate([
|
|
3544
|
-
classTransformer.Type(function () { return VehicleClaimDetails; })
|
|
3545
|
-
], VehicleClaim.prototype, "details", void 0);
|
|
3546
|
-
__decorate([
|
|
3547
|
-
classTransformer.Type(function () { return SoleBusiness; })
|
|
3548
|
-
], VehicleClaim.prototype, "business", void 0);
|
|
3549
|
-
|
|
3550
|
-
var TransactionBase = /** @class */ (function (_super) {
|
|
3551
|
-
__extends(TransactionBase, _super);
|
|
3552
|
-
function TransactionBase() {
|
|
3553
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3554
|
-
}
|
|
3555
|
-
Object.defineProperty(TransactionBase.prototype, "tankType", {
|
|
3556
|
-
get: function () {
|
|
3557
|
-
switch (true) {
|
|
3558
|
-
case this.isPropertyTank():
|
|
3559
|
-
return exports.TankTypeEnum.PROPERTY;
|
|
3560
|
-
case this.isWorkTank():
|
|
3561
|
-
return exports.TankTypeEnum.WORK;
|
|
3562
|
-
case this.isSoleTank():
|
|
3563
|
-
return exports.TankTypeEnum.SOLE;
|
|
3564
|
-
default:
|
|
3565
|
-
return exports.TankTypeEnum.OTHER;
|
|
3566
|
-
}
|
|
3567
|
-
},
|
|
3568
|
-
enumerable: false,
|
|
3569
|
-
configurable: true
|
|
3570
|
-
});
|
|
3571
|
-
/**
|
|
3572
|
-
* Check if current tank is Property
|
|
3573
|
-
*/
|
|
3574
|
-
TransactionBase.prototype.isPropertyTank = function () {
|
|
3575
|
-
// chart accounts may be empty for new instances
|
|
3576
|
-
if (this.chartAccounts) {
|
|
3577
|
-
return CHART_ACCOUNTS_CATEGORIES.property.includes(this.chartAccounts.category);
|
|
3578
|
-
}
|
|
3579
|
-
return !!this.property;
|
|
3580
|
-
};
|
|
3581
|
-
/**
|
|
3582
|
-
* Check if current tank is Work
|
|
3583
|
-
*/
|
|
3584
|
-
TransactionBase.prototype.isWorkTank = function () {
|
|
3585
|
-
var _a;
|
|
3586
|
-
// chart accounts may be empty for new instances
|
|
3587
|
-
if (this.chartAccounts) {
|
|
3588
|
-
return CHART_ACCOUNTS_CATEGORIES.work.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
|
|
3589
|
-
}
|
|
3590
|
-
return !this.isPropertyTank() && !this.isSoleTank();
|
|
3591
|
-
};
|
|
3592
|
-
/**
|
|
3593
|
-
* Check if current tank is Sole
|
|
3594
|
-
*/
|
|
3595
|
-
TransactionBase.prototype.isSoleTank = function () {
|
|
3596
|
-
var _a;
|
|
3597
|
-
// chart accounts may be empty for new instances
|
|
3598
|
-
if (this.chartAccounts) {
|
|
3599
|
-
return CHART_ACCOUNTS_CATEGORIES.sole.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
|
|
3600
|
-
}
|
|
3601
|
-
return !!this.business;
|
|
3602
|
-
};
|
|
3603
|
-
return TransactionBase;
|
|
3604
|
-
}(AbstractModel));
|
|
3605
|
-
__decorate([
|
|
3606
|
-
classTransformer.Exclude({ toPlainOnly: true }),
|
|
3607
|
-
classTransformer.Type(function () { return Object; }),
|
|
3608
|
-
classTransformer.Transform(function (_b) {
|
|
3609
|
-
var obj = _b.obj;
|
|
3610
|
-
return obj.file;
|
|
3611
|
-
})
|
|
3612
|
-
], TransactionBase.prototype, "file", void 0);
|
|
3613
|
-
|
|
3614
|
-
var Depreciation$1 = /** @class */ (function (_super) {
|
|
3615
|
-
__extends(Depreciation, _super);
|
|
3616
|
-
function Depreciation() {
|
|
3617
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3618
|
-
}
|
|
3619
|
-
return Depreciation;
|
|
3620
|
-
}(TransactionBase));
|
|
3621
|
-
|
|
3622
|
-
exports.DepreciationTypeEnum = void 0;
|
|
3623
|
-
(function (DepreciationTypeEnum) {
|
|
3624
|
-
DepreciationTypeEnum[DepreciationTypeEnum["PLANT_EQUIPMENT"] = 1] = "PLANT_EQUIPMENT";
|
|
3625
|
-
DepreciationTypeEnum[DepreciationTypeEnum["CAPITAL_WORKS"] = 2] = "CAPITAL_WORKS";
|
|
3626
|
-
DepreciationTypeEnum[DepreciationTypeEnum["BULK_DEPRECIATION"] = 3] = "BULK_DEPRECIATION";
|
|
3627
|
-
DepreciationTypeEnum[DepreciationTypeEnum["BORROWING_EXPENSES"] = 4] = "BORROWING_EXPENSES";
|
|
3628
|
-
})(exports.DepreciationTypeEnum || (exports.DepreciationTypeEnum = {}));
|
|
3629
|
-
|
|
3630
|
-
exports.DepreciationCalculationEnum = void 0;
|
|
3631
|
-
(function (DepreciationCalculationEnum) {
|
|
3632
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["PRIME_COST"] = 1] = "PRIME_COST";
|
|
3633
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["DIMINISHING"] = 2] = "DIMINISHING";
|
|
3634
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["CAPITAL"] = 3] = "CAPITAL";
|
|
3635
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["LVP"] = 4] = "LVP";
|
|
3636
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["AMORTISATION"] = 5] = "AMORTISATION";
|
|
3637
|
-
DepreciationCalculationEnum[DepreciationCalculationEnum["SBP"] = 6] = "SBP";
|
|
3638
|
-
})(exports.DepreciationCalculationEnum || (exports.DepreciationCalculationEnum = {}));
|
|
3639
|
-
|
|
3640
|
-
var DepreciationCapitalProject$1 = /** @class */ (function (_super) {
|
|
3641
|
-
__extends(DepreciationCapitalProject, _super);
|
|
3642
|
-
function DepreciationCapitalProject() {
|
|
3643
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3644
|
-
}
|
|
3645
|
-
return DepreciationCapitalProject;
|
|
3646
|
-
}(AbstractModel));
|
|
3647
|
-
|
|
3648
|
-
var DepreciationCapitalProject = /** @class */ (function (_super) {
|
|
3649
|
-
__extends(DepreciationCapitalProject, _super);
|
|
3650
|
-
function DepreciationCapitalProject() {
|
|
3651
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3652
|
-
}
|
|
3653
|
-
return DepreciationCapitalProject;
|
|
3654
|
-
}(DepreciationCapitalProject$1));
|
|
3655
|
-
__decorate([
|
|
3656
|
-
classTransformer.Type(function () { return Date; })
|
|
3657
|
-
], DepreciationCapitalProject.prototype, "effectiveDate", void 0);
|
|
3658
|
-
|
|
3659
|
-
var DepreciationForecast$1 = /** @class */ (function (_super) {
|
|
3660
|
-
__extends(DepreciationForecast, _super);
|
|
3661
|
-
function DepreciationForecast() {
|
|
3662
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3663
|
-
}
|
|
3664
|
-
return DepreciationForecast;
|
|
3665
|
-
}(AbstractModel));
|
|
3666
|
-
|
|
3667
|
-
var DepreciationForecast = /** @class */ (function (_super) {
|
|
3668
|
-
__extends(DepreciationForecast, _super);
|
|
3669
|
-
function DepreciationForecast() {
|
|
3670
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3671
|
-
}
|
|
3672
|
-
Object.defineProperty(DepreciationForecast.prototype, "dailyClaimAmount", {
|
|
3673
|
-
get: function () {
|
|
3674
|
-
return this.claimAmount / this.daysApplied;
|
|
3714
|
+
return this.claimAmount / this.daysApplied;
|
|
3675
3715
|
},
|
|
3676
3716
|
enumerable: false,
|
|
3677
3717
|
configurable: true
|
|
@@ -3724,886 +3764,951 @@
|
|
|
3724
3764
|
return DepreciationForecast;
|
|
3725
3765
|
}(DepreciationForecast$1));
|
|
3726
3766
|
|
|
3727
|
-
var BankTransaction$1 = /** @class */ (function (_super) {
|
|
3728
|
-
__extends(BankTransaction, _super);
|
|
3729
|
-
function BankTransaction() {
|
|
3730
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3731
|
-
}
|
|
3732
|
-
return BankTransaction;
|
|
3733
|
-
}(AbstractModel));
|
|
3734
|
-
|
|
3735
|
-
exports.BankTransactionTypeEnum = void 0;
|
|
3736
|
-
(function (BankTransactionTypeEnum) {
|
|
3737
|
-
BankTransactionTypeEnum[BankTransactionTypeEnum["DEBIT"] = 1] = "DEBIT";
|
|
3738
|
-
BankTransactionTypeEnum[BankTransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
|
|
3739
|
-
})(exports.BankTransactionTypeEnum || (exports.BankTransactionTypeEnum = {}));
|
|
3740
|
-
|
|
3741
|
-
exports.TransactionSourceEnum = void 0;
|
|
3742
|
-
(function (TransactionSourceEnum) {
|
|
3743
|
-
TransactionSourceEnum[TransactionSourceEnum["CASH"] = 1] = "CASH";
|
|
3744
|
-
TransactionSourceEnum[TransactionSourceEnum["BANK_TRANSACTION"] = 2] = "BANK_TRANSACTION";
|
|
3745
|
-
})(exports.TransactionSourceEnum || (exports.TransactionSourceEnum = {}));
|
|
3746
|
-
|
|
3747
|
-
var Transaction$1 = /** @class */ (function (_super) {
|
|
3748
|
-
__extends(Transaction, _super);
|
|
3749
|
-
function Transaction() {
|
|
3750
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3751
|
-
}
|
|
3752
|
-
return Transaction;
|
|
3753
|
-
}(TransactionBase));
|
|
3754
|
-
|
|
3755
|
-
exports.TransactionTypeEnum = void 0;
|
|
3756
|
-
(function (TransactionTypeEnum) {
|
|
3757
|
-
TransactionTypeEnum[TransactionTypeEnum["DEBIT"] = 1] = "DEBIT";
|
|
3758
|
-
TransactionTypeEnum[TransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
|
|
3759
|
-
})(exports.TransactionTypeEnum || (exports.TransactionTypeEnum = {}));
|
|
3760
|
-
|
|
3761
|
-
exports.TransactionOperationEnum = void 0;
|
|
3762
|
-
(function (TransactionOperationEnum) {
|
|
3763
|
-
TransactionOperationEnum[TransactionOperationEnum["ALLOCATE"] = 1] = "ALLOCATE";
|
|
3764
|
-
TransactionOperationEnum[TransactionOperationEnum["FIND_AND_MATCH"] = 2] = "FIND_AND_MATCH";
|
|
3765
|
-
TransactionOperationEnum[TransactionOperationEnum["TRANSFER"] = 3] = "TRANSFER";
|
|
3766
|
-
})(exports.TransactionOperationEnum || (exports.TransactionOperationEnum = {}));
|
|
3767
|
-
|
|
3768
|
-
var TransactionReceipt$1 = /** @class */ (function (_super) {
|
|
3769
|
-
__extends(TransactionReceipt, _super);
|
|
3770
|
-
function TransactionReceipt() {
|
|
3771
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3772
|
-
}
|
|
3773
|
-
return TransactionReceipt;
|
|
3774
|
-
}(AbstractModel));
|
|
3775
|
-
|
|
3776
|
-
// @TODO this enum should come from backend
|
|
3777
3767
|
/**
|
|
3778
|
-
*
|
|
3779
|
-
*/
|
|
3780
|
-
exports.AssetTypeEnum = void 0;
|
|
3781
|
-
(function (AssetTypeEnum) {
|
|
3782
|
-
AssetTypeEnum["RECEIPTS"] = "receipts";
|
|
3783
|
-
AssetTypeEnum["DOCUMENTS"] = "documents";
|
|
3784
|
-
AssetTypeEnum["MESSAGE"] = "message";
|
|
3785
|
-
})(exports.AssetTypeEnum || (exports.AssetTypeEnum = {}));
|
|
3786
|
-
|
|
3787
|
-
/**
|
|
3788
|
-
* Enum with asset entity types
|
|
3768
|
+
* @TODO Alex: clarify grouping rules and refactor
|
|
3789
3769
|
*/
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
AssetEntityTypeEnum["FOLDERS"] = "folders";
|
|
3794
|
-
AssetEntityTypeEnum["DEPRECIATIONS"] = "depreciations";
|
|
3795
|
-
AssetEntityTypeEnum["TRANSACTIONS"] = "transactions";
|
|
3796
|
-
AssetEntityTypeEnum["MESSAGES"] = "messages";
|
|
3797
|
-
})(exports.AssetEntityTypeEnum || (exports.AssetEntityTypeEnum = {}));
|
|
3798
|
-
|
|
3799
|
-
var TransactionReceipt = /** @class */ (function (_super) {
|
|
3800
|
-
__extends(TransactionReceipt, _super);
|
|
3801
|
-
function TransactionReceipt() {
|
|
3770
|
+
var Depreciation = /** @class */ (function (_super) {
|
|
3771
|
+
__extends(Depreciation, _super);
|
|
3772
|
+
function Depreciation() {
|
|
3802
3773
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3803
|
-
_this.
|
|
3804
|
-
_this.
|
|
3774
|
+
_this.forecasts = [];
|
|
3775
|
+
_this.type = exports.DepreciationTypeEnum.PLANT_EQUIPMENT;
|
|
3776
|
+
/**
|
|
3777
|
+
* @TODO remove after ? signs removed from db models
|
|
3778
|
+
*/
|
|
3779
|
+
_this.amount = 0;
|
|
3805
3780
|
return _this;
|
|
3806
3781
|
}
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
}
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
classTransformer.Expose()
|
|
3846
|
-
], SalaryForecast.prototype, "grossAmount", void 0);
|
|
3847
|
-
__decorate([
|
|
3848
|
-
classTransformer.Type(function () { return IncomeSource; })
|
|
3849
|
-
], SalaryForecast.prototype, "incomeSource", void 0);
|
|
3850
|
-
|
|
3851
|
-
var SoleForecast$1 = /** @class */ (function (_super) {
|
|
3852
|
-
__extends(SoleForecast, _super);
|
|
3853
|
-
function SoleForecast() {
|
|
3854
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3855
|
-
}
|
|
3856
|
-
return SoleForecast;
|
|
3857
|
-
}(AbstractModel));
|
|
3858
|
-
|
|
3859
|
-
var SoleForecast = /** @class */ (function (_super) {
|
|
3860
|
-
__extends(SoleForecast, _super);
|
|
3861
|
-
function SoleForecast() {
|
|
3862
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3863
|
-
}
|
|
3864
|
-
Object.defineProperty(SoleForecast.prototype, "netPay", {
|
|
3782
|
+
// Type checking
|
|
3783
|
+
Depreciation.prototype.isCapital = function () {
|
|
3784
|
+
return this.type === exports.DepreciationTypeEnum.CAPITAL_WORKS;
|
|
3785
|
+
};
|
|
3786
|
+
Depreciation.prototype.isBorrowingExpense = function () {
|
|
3787
|
+
return this.type === exports.DepreciationTypeEnum.BORROWING_EXPENSES;
|
|
3788
|
+
};
|
|
3789
|
+
Depreciation.prototype.isAsset = function () {
|
|
3790
|
+
return this.type === exports.DepreciationTypeEnum.PLANT_EQUIPMENT;
|
|
3791
|
+
};
|
|
3792
|
+
// Calculation checking
|
|
3793
|
+
Depreciation.prototype.isSBPCalculation = function () {
|
|
3794
|
+
return this.calculation === exports.DepreciationCalculationEnum.SBP;
|
|
3795
|
+
};
|
|
3796
|
+
Depreciation.prototype.isPrimeCost = function () {
|
|
3797
|
+
return this.calculation === exports.DepreciationCalculationEnum.PRIME_COST;
|
|
3798
|
+
};
|
|
3799
|
+
Depreciation.prototype.isDiminishing = function () {
|
|
3800
|
+
return this.calculation === exports.DepreciationCalculationEnum.DIMINISHING;
|
|
3801
|
+
};
|
|
3802
|
+
// Pool checking
|
|
3803
|
+
Depreciation.prototype.isPlantEquipmentPool = function () {
|
|
3804
|
+
return this.isAsset() && !this.isSBPCalculation() && !this.isWrittenOff() && !this.isLVP();
|
|
3805
|
+
};
|
|
3806
|
+
Depreciation.prototype.isLVP = function () {
|
|
3807
|
+
return this.isAsset()
|
|
3808
|
+
&& !this.isSBPCalculation()
|
|
3809
|
+
&& this.isDiminishing()
|
|
3810
|
+
&& this.currentYearForecast.closeBalance > Depreciation.WRITTEN_OFF_THRESHOLD
|
|
3811
|
+
&& this.currentYearForecast.closeBalance <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
|
|
3812
|
+
};
|
|
3813
|
+
Depreciation.prototype.isSBP = function () {
|
|
3814
|
+
return this.isAsset() && this.isSBPCalculation() && !this.isWrittenOff();
|
|
3815
|
+
};
|
|
3816
|
+
Depreciation.prototype.isWrittenOff = function () {
|
|
3817
|
+
return this.writeOffYear === new FinancialYear().year;
|
|
3818
|
+
};
|
|
3819
|
+
Object.defineProperty(Depreciation.prototype, "writeOffYear", {
|
|
3865
3820
|
get: function () {
|
|
3866
|
-
|
|
3821
|
+
var _a;
|
|
3822
|
+
if (!this.writeOffManualDate && !this.writeOffDate) {
|
|
3823
|
+
return null;
|
|
3824
|
+
}
|
|
3825
|
+
return (_a = new FinancialYear(this.writeOffManualDate || this.writeOffDate)) === null || _a === void 0 ? void 0 : _a.year;
|
|
3867
3826
|
},
|
|
3868
3827
|
enumerable: false,
|
|
3869
3828
|
configurable: true
|
|
3870
3829
|
});
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3830
|
+
/**
|
|
3831
|
+
* Check if depreciation chart accounts heading related to vehicles category
|
|
3832
|
+
*/
|
|
3833
|
+
Depreciation.prototype.isVehicleDepreciation = function () {
|
|
3834
|
+
var _a;
|
|
3835
|
+
return ((_a = this.chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id) === exports.ChartAccountsHeadingVehicleListEnum.DEPRECIATION_VEHICLES;
|
|
3836
|
+
};
|
|
3837
|
+
/**
|
|
3838
|
+
* Get depreciation purchase date
|
|
3839
|
+
*/
|
|
3840
|
+
Depreciation.prototype.getDate = function () {
|
|
3841
|
+
return this.date;
|
|
3842
|
+
};
|
|
3843
|
+
Object.defineProperty(Depreciation.prototype, "currentYearForecast", {
|
|
3844
|
+
/**
|
|
3845
|
+
* @TODO Vik: Research a problem with depreciations without current year forecast
|
|
3846
|
+
*/
|
|
3847
|
+
get: function () {
|
|
3848
|
+
return this.forecasts.find(function (forecast) {
|
|
3849
|
+
return forecast.financialYear === new FinancialYear().year;
|
|
3850
|
+
}) || classTransformer.plainToClass(DepreciationForecast, {
|
|
3851
|
+
financialYear: new FinancialYear().year,
|
|
3852
|
+
openBalance: 0,
|
|
3853
|
+
closeBalance: 0,
|
|
3854
|
+
amount: 0,
|
|
3855
|
+
claimPercent: 0
|
|
3856
|
+
});
|
|
3857
|
+
},
|
|
3858
|
+
enumerable: false,
|
|
3859
|
+
configurable: true
|
|
3860
|
+
});
|
|
3861
|
+
Depreciation.prototype.getForecastByYear = function (year) {
|
|
3862
|
+
return this.forecasts.find(function (forecast) {
|
|
3863
|
+
return forecast.financialYear === year;
|
|
3864
|
+
});
|
|
3865
|
+
};
|
|
3866
|
+
Depreciation.prototype.getClaimAmountByYear = function (year) {
|
|
3867
|
+
var _a;
|
|
3868
|
+
return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
|
|
3869
|
+
};
|
|
3870
|
+
Depreciation.prototype.getCloseBalanceByYear = function (year) {
|
|
3871
|
+
var _a;
|
|
3872
|
+
return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.closeBalance) || 0;
|
|
3873
|
+
};
|
|
3874
|
+
Depreciation.prototype.isBuildingAtCost = function () {
|
|
3875
|
+
return this.chartAccounts.id === exports.ChartAccountsListEnum.BUILDING_AT_COST;
|
|
3876
|
+
};
|
|
3877
|
+
/**
|
|
3878
|
+
* Create a new transaction from current depreciation
|
|
3879
|
+
*/
|
|
3880
|
+
Depreciation.prototype.toTransaction = function (params) {
|
|
3881
|
+
if (params === void 0) { params = {}; }
|
|
3882
|
+
return classTransformer.plainToClass(Transaction, Object.assign(params, this, { amount: -this.claimAmount, claimAmount: -this.amount * (this.claimPercent / 100) }));
|
|
3883
|
+
};
|
|
3884
|
+
Object.defineProperty(Depreciation.prototype, "claimAmount", {
|
|
3885
|
+
/**
|
|
3886
|
+
* @TODO Michael: remove and check everywhere in reports
|
|
3887
|
+
*/
|
|
3888
|
+
get: function () {
|
|
3889
|
+
var _a;
|
|
3890
|
+
return ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
|
|
3891
|
+
},
|
|
3892
|
+
enumerable: false,
|
|
3893
|
+
configurable: true
|
|
3894
|
+
});
|
|
3895
|
+
return Depreciation;
|
|
3896
|
+
}(Depreciation$1));
|
|
3897
|
+
Depreciation.WRITTEN_OFF_THRESHOLD = 300;
|
|
3898
|
+
Depreciation.LOW_VALUE_POOL_THRESHOLD = 1000;
|
|
3874
3899
|
__decorate([
|
|
3875
|
-
classTransformer.Type(function () { return
|
|
3876
|
-
],
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
(
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["TRUSTS"] = 9] = "TRUSTS";
|
|
3918
|
-
IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["OTHER_INCOME"] = 10] = "OTHER_INCOME";
|
|
3919
|
-
IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PARTNERSHIPS"] = 12] = "PARTNERSHIPS";
|
|
3920
|
-
})(exports.IncomeSourceTypeListOtherEnum || (exports.IncomeSourceTypeListOtherEnum = {}));
|
|
3921
|
-
|
|
3922
|
-
exports.IncomeSourceTypeListSoleEnum = void 0;
|
|
3923
|
-
(function (IncomeSourceTypeListSoleEnum) {
|
|
3924
|
-
IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
|
|
3925
|
-
})(exports.IncomeSourceTypeListSoleEnum || (exports.IncomeSourceTypeListSoleEnum = {}));
|
|
3900
|
+
classTransformer.Type(function () { return Date; })
|
|
3901
|
+
], Depreciation.prototype, "purchaseDate", void 0);
|
|
3902
|
+
__decorate([
|
|
3903
|
+
classTransformer.Type(function () { return Date; })
|
|
3904
|
+
], Depreciation.prototype, "date", void 0);
|
|
3905
|
+
__decorate([
|
|
3906
|
+
classTransformer.Type(function () { return Date; })
|
|
3907
|
+
], Depreciation.prototype, "lowValuePoolDate", void 0);
|
|
3908
|
+
__decorate([
|
|
3909
|
+
classTransformer.Type(function () { return Date; })
|
|
3910
|
+
], Depreciation.prototype, "writeOffManualDate", void 0);
|
|
3911
|
+
__decorate([
|
|
3912
|
+
classTransformer.Type(function () { return Date; })
|
|
3913
|
+
], Depreciation.prototype, "writeOffDate", void 0);
|
|
3914
|
+
__decorate([
|
|
3915
|
+
classTransformer.Type(function () { return DepreciationCapitalProject; })
|
|
3916
|
+
], Depreciation.prototype, "depreciationCapitalProject", void 0);
|
|
3917
|
+
__decorate([
|
|
3918
|
+
classTransformer.Type(function () { return DepreciationForecast; }),
|
|
3919
|
+
classTransformer.Transform(function (_b) {
|
|
3920
|
+
var value = _b.value, obj = _b.obj;
|
|
3921
|
+
// value = array of DepreciationForecast
|
|
3922
|
+
// obj = plain (whole Depreciation object)
|
|
3923
|
+
// Set isLVP flag for each DepreciationForecast
|
|
3924
|
+
// @TODO refactor
|
|
3925
|
+
value.forEach(function (forecast) {
|
|
3926
|
+
forecast.isLVP =
|
|
3927
|
+
forecast.closeBalance < 1000 &&
|
|
3928
|
+
obj.calculation === exports.DepreciationCalculationEnum.DIMINISHING &&
|
|
3929
|
+
obj.type === exports.DepreciationTypeEnum.PLANT_EQUIPMENT &&
|
|
3930
|
+
!(obj.amount > Depreciation.WRITTEN_OFF_THRESHOLD && obj.amount < Depreciation.LOW_VALUE_POOL_THRESHOLD) &&
|
|
3931
|
+
!(obj.writeOffDate && new FinancialYear(new Date(obj.writeOffDate)).year === obj.financialYear);
|
|
3932
|
+
});
|
|
3933
|
+
return value;
|
|
3934
|
+
})
|
|
3935
|
+
], Depreciation.prototype, "forecasts", void 0);
|
|
3936
|
+
__decorate([
|
|
3937
|
+
classTransformer.Type(function () { return ChartAccounts; })
|
|
3938
|
+
], Depreciation.prototype, "chartAccounts", void 0);
|
|
3939
|
+
__decorate([
|
|
3940
|
+
classTransformer.Type(function () { return BankTransaction; })
|
|
3941
|
+
], Depreciation.prototype, "bankTransaction", void 0);
|
|
3926
3942
|
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3943
|
+
// @TODO refactor with baseModel in constructor
|
|
3944
|
+
var Transaction = /** @class */ (function (_super) {
|
|
3945
|
+
__extends(Transaction, _super);
|
|
3946
|
+
function Transaction() {
|
|
3947
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3948
|
+
// list of child transactions (fees)
|
|
3949
|
+
_this.transactions = [];
|
|
3950
|
+
_this.metadata = [];
|
|
3951
|
+
_this.allocations = [];
|
|
3952
|
+
_this.tax = 0;
|
|
3953
|
+
_this.operation = exports.TransactionOperationEnum.FIND_AND_MATCH;
|
|
3954
|
+
_this.claimPercent = 100;
|
|
3955
|
+
_this.amount = 0;
|
|
3956
|
+
return _this;
|
|
3931
3957
|
}
|
|
3932
|
-
|
|
3933
|
-
return this.
|
|
3958
|
+
Transaction.prototype.isDebit = function () {
|
|
3959
|
+
return this.type === exports.TransactionTypeEnum.DEBIT;
|
|
3934
3960
|
};
|
|
3935
|
-
|
|
3936
|
-
return
|
|
3961
|
+
Transaction.prototype.isCredit = function () {
|
|
3962
|
+
return this.type === exports.TransactionTypeEnum.CREDIT;
|
|
3937
3963
|
};
|
|
3938
|
-
|
|
3939
|
-
|
|
3964
|
+
Transaction.prototype.isIncome = function () {
|
|
3965
|
+
if (!this.chartAccounts) {
|
|
3966
|
+
return this.isCredit();
|
|
3967
|
+
}
|
|
3968
|
+
return CHART_ACCOUNTS_CATEGORIES.income.includes(this.chartAccounts.category);
|
|
3940
3969
|
};
|
|
3941
|
-
|
|
3942
|
-
|
|
3970
|
+
Transaction.prototype.isExpense = function () {
|
|
3971
|
+
if (!this.chartAccounts) {
|
|
3972
|
+
return this.isDebit();
|
|
3973
|
+
}
|
|
3974
|
+
return CHART_ACCOUNTS_CATEGORIES.expense.includes(this.chartAccounts.category);
|
|
3943
3975
|
};
|
|
3944
|
-
|
|
3976
|
+
Transaction.prototype.isPersonal = function () {
|
|
3977
|
+
return CHART_ACCOUNTS_CATEGORIES.personal.includes(this.chartAccounts.category);
|
|
3978
|
+
};
|
|
3979
|
+
Object.defineProperty(Transaction.prototype, "chartAccountsCategories", {
|
|
3945
3980
|
get: function () {
|
|
3946
3981
|
switch (true) {
|
|
3947
|
-
case this.
|
|
3948
|
-
return
|
|
3949
|
-
case this.
|
|
3950
|
-
return
|
|
3982
|
+
case this.isPersonal():
|
|
3983
|
+
return CHART_ACCOUNTS_CATEGORIES.personal;
|
|
3984
|
+
case this.isPropertyTank():
|
|
3985
|
+
return CHART_ACCOUNTS_CATEGORIES.property;
|
|
3986
|
+
case this.isSoleTank():
|
|
3987
|
+
return CHART_ACCOUNTS_CATEGORIES.sole;
|
|
3951
3988
|
default:
|
|
3952
|
-
return
|
|
3989
|
+
return CHART_ACCOUNTS_CATEGORIES.work;
|
|
3953
3990
|
}
|
|
3954
3991
|
},
|
|
3955
3992
|
enumerable: false,
|
|
3956
3993
|
configurable: true
|
|
3957
3994
|
});
|
|
3958
|
-
|
|
3959
|
-
|
|
3995
|
+
Object.defineProperty(Transaction.prototype, "isKmsChartAccountsCategory", {
|
|
3996
|
+
/**
|
|
3997
|
+
* Check if transaction has 'Kms travelled for work' chart accounts category
|
|
3998
|
+
*/
|
|
3999
|
+
get: function () {
|
|
4000
|
+
return this.chartAccounts.id === exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK;
|
|
4001
|
+
},
|
|
4002
|
+
enumerable: false,
|
|
4003
|
+
configurable: true
|
|
4004
|
+
});
|
|
4005
|
+
/**
|
|
4006
|
+
* Get transaction date
|
|
4007
|
+
*/
|
|
4008
|
+
Transaction.prototype.getDate = function () {
|
|
4009
|
+
return this.date;
|
|
4010
|
+
};
|
|
4011
|
+
/**
|
|
4012
|
+
* Check if transaction type is vehicle
|
|
4013
|
+
*/
|
|
4014
|
+
Transaction.prototype.isVehicleTransaction = function () {
|
|
4015
|
+
return this.chartAccounts.isVehicleExpense();
|
|
4016
|
+
};
|
|
4017
|
+
/**
|
|
4018
|
+
* Get net amount (clean amount after all deductions)
|
|
4019
|
+
*/
|
|
4020
|
+
Transaction.prototype.getNetAmount = function () {
|
|
4021
|
+
// @TODO fix hack while transactions refactoring (use class-transformer)
|
|
4022
|
+
return +(Math.round(this.getIncomeAmountByType(exports.IncomeAmountTypeEnum.NET) * 100) / 100).toFixed(2);
|
|
4023
|
+
};
|
|
4024
|
+
/**
|
|
4025
|
+
* Get gross income amount
|
|
4026
|
+
*/
|
|
4027
|
+
Transaction.prototype.getGrossIncome = function () {
|
|
4028
|
+
// @TODO fix hack while transactions refactoring (use class-transformer)
|
|
4029
|
+
return +(Math.round(this.getIncomeAmountByType(exports.IncomeAmountTypeEnum.GROSS) * 100) / 100).toFixed(2);
|
|
4030
|
+
};
|
|
4031
|
+
Object.defineProperty(Transaction.prototype, "taxFreeComponent", {
|
|
4032
|
+
get: function () {
|
|
4033
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.TAX_FREE_COMPONENT);
|
|
4034
|
+
},
|
|
4035
|
+
enumerable: false,
|
|
4036
|
+
configurable: true
|
|
4037
|
+
});
|
|
4038
|
+
Object.defineProperty(Transaction.prototype, "frankingCredit", {
|
|
4039
|
+
get: function () {
|
|
4040
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.FRANKING_CREDIT);
|
|
4041
|
+
},
|
|
4042
|
+
enumerable: false,
|
|
4043
|
+
configurable: true
|
|
4044
|
+
});
|
|
4045
|
+
Object.defineProperty(Transaction.prototype, "eligibleForReduction", {
|
|
4046
|
+
get: function () {
|
|
4047
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.ELIGIBLE_FOR_REDUCTION);
|
|
4048
|
+
},
|
|
4049
|
+
enumerable: false,
|
|
4050
|
+
configurable: true
|
|
4051
|
+
});
|
|
4052
|
+
Object.defineProperty(Transaction.prototype, "untaxedElement", {
|
|
4053
|
+
get: function () {
|
|
4054
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.UNTAXED_ELEMENT);
|
|
4055
|
+
},
|
|
4056
|
+
enumerable: false,
|
|
4057
|
+
configurable: true
|
|
4058
|
+
});
|
|
4059
|
+
Object.defineProperty(Transaction.prototype, "isTransfer", {
|
|
4060
|
+
/**
|
|
4061
|
+
* Check if transaction reconcile operation if TRANSFER
|
|
4062
|
+
* @TODO bad usage of get (and all is* methods), getter should sound like a noun
|
|
4063
|
+
*/
|
|
4064
|
+
get: function () {
|
|
4065
|
+
return this.operation === exports.TransactionOperationEnum.TRANSFER;
|
|
4066
|
+
},
|
|
4067
|
+
enumerable: false,
|
|
4068
|
+
configurable: true
|
|
4069
|
+
});
|
|
4070
|
+
Transaction.prototype.isFindAndMatch = function () {
|
|
4071
|
+
return this.operation === exports.TransactionOperationEnum.FIND_AND_MATCH;
|
|
4072
|
+
};
|
|
4073
|
+
Object.defineProperty(Transaction.prototype, "debit", {
|
|
4074
|
+
get: function () {
|
|
4075
|
+
return this.isDebit() ? Math.abs(this.amount) : 0;
|
|
4076
|
+
},
|
|
4077
|
+
enumerable: false,
|
|
4078
|
+
configurable: true
|
|
4079
|
+
});
|
|
4080
|
+
Object.defineProperty(Transaction.prototype, "credit", {
|
|
4081
|
+
get: function () {
|
|
4082
|
+
return this.isCredit() ? Math.abs(this.amount) : 0;
|
|
4083
|
+
},
|
|
4084
|
+
enumerable: false,
|
|
4085
|
+
configurable: true
|
|
4086
|
+
});
|
|
4087
|
+
/**
|
|
4088
|
+
* Get value of transaction metadata field
|
|
4089
|
+
* @param field for which value should be returned
|
|
4090
|
+
* @Todo modify 'metadata' property from array to Collection
|
|
4091
|
+
*/
|
|
4092
|
+
Transaction.prototype.getMetadataFieldValue = function (field) {
|
|
4093
|
+
var _a;
|
|
4094
|
+
return +((_a = this.metadata.find(function (transactionMetadata) {
|
|
4095
|
+
return transactionMetadata.chartAccountsMetadata.id === field;
|
|
4096
|
+
})) === null || _a === void 0 ? void 0 : _a.value) || 0;
|
|
4097
|
+
};
|
|
4098
|
+
/**
|
|
4099
|
+
* Returns Net or Gross income amount based on provided income type
|
|
4100
|
+
* @param incomeType by which amount should be returned
|
|
4101
|
+
*/
|
|
4102
|
+
Transaction.prototype.getIncomeAmountByType = function (incomeType) {
|
|
4103
|
+
// modifier that determines whether the values of the transaction fields will be added or subtracted
|
|
4104
|
+
var modifier = incomeType === exports.IncomeAmountTypeEnum.GROSS ? 1 : -1;
|
|
4105
|
+
switch (true) {
|
|
4106
|
+
case this.isPropertyTank():
|
|
4107
|
+
return this.amount +
|
|
4108
|
+
(this.transactions
|
|
4109
|
+
.reduce(function (sum, transaction) { return sum + Math.abs(transaction.amount); }, 0) * modifier);
|
|
4110
|
+
case this.isWorkTank():
|
|
4111
|
+
return this.amount + ((this.tax + this.frankingCredit - this.taxFreeComponent - this.eligibleForReduction) * modifier);
|
|
4112
|
+
default:
|
|
4113
|
+
return this.amount || 0;
|
|
4114
|
+
}
|
|
4115
|
+
};
|
|
4116
|
+
Transaction.prototype.isInterest = function () {
|
|
4117
|
+
return this.chartAccounts.id === exports.ChartAccountsListEnum.INTEREST_ON_LOAN;
|
|
4118
|
+
};
|
|
4119
|
+
Transaction.prototype.isCash = function () {
|
|
4120
|
+
return this.source === exports.TransactionSourceEnum.CASH;
|
|
4121
|
+
};
|
|
4122
|
+
/**
|
|
4123
|
+
* Create Depreciation instance based on Transaction
|
|
4124
|
+
*/
|
|
4125
|
+
Transaction.prototype.toDepreciation = function () {
|
|
4126
|
+
return classTransformer.plainToClass(Depreciation, {
|
|
4127
|
+
date: this.date,
|
|
4128
|
+
amount: this.amount,
|
|
4129
|
+
chartAccounts: this.chartAccounts,
|
|
4130
|
+
description: this.description,
|
|
4131
|
+
type: exports.DepreciationTypeEnum.PLANT_EQUIPMENT,
|
|
4132
|
+
claimPercent: this.claimPercent,
|
|
4133
|
+
property: this.property,
|
|
4134
|
+
calculation: this.property ? this.property.depreciationCalculation : exports.DepreciationCalculationEnum.PRIME_COST
|
|
4135
|
+
});
|
|
4136
|
+
};
|
|
4137
|
+
/**
|
|
4138
|
+
* Check if transaction is completely allocated
|
|
4139
|
+
*/
|
|
4140
|
+
Transaction.prototype.isAllocated = function (allocations) {
|
|
4141
|
+
return this.getNetAmount() === this.getAllocatedAmount(allocations);
|
|
4142
|
+
};
|
|
4143
|
+
/**
|
|
4144
|
+
* Get transaction allocated amount
|
|
4145
|
+
*/
|
|
4146
|
+
Transaction.prototype.getAllocatedAmount = function (allocations) {
|
|
4147
|
+
return allocations.getByTransactionsIds([this.id]).amount;
|
|
4148
|
+
};
|
|
4149
|
+
/**
|
|
4150
|
+
* Get transaction unallocated amount
|
|
4151
|
+
*/
|
|
4152
|
+
Transaction.prototype.getUnallocatedAmount = function (allocations) {
|
|
4153
|
+
return this.getNetAmount() - this.getAllocatedAmount(allocations);
|
|
4154
|
+
};
|
|
4155
|
+
return Transaction;
|
|
4156
|
+
}(Transaction$1));
|
|
4157
|
+
__decorate([
|
|
4158
|
+
classTransformer.Type(function () { return Transaction; })
|
|
4159
|
+
], Transaction.prototype, "transactions", void 0);
|
|
4160
|
+
__decorate([
|
|
4161
|
+
classTransformer.Type(function () { return Property; })
|
|
4162
|
+
], Transaction.prototype, "property", void 0);
|
|
4163
|
+
__decorate([
|
|
4164
|
+
classTransformer.Type(function () { return TransactionReceipt; })
|
|
4165
|
+
], Transaction.prototype, "receipt", void 0);
|
|
4166
|
+
__decorate([
|
|
4167
|
+
classTransformer.Type(function () { return ChartAccounts; })
|
|
4168
|
+
], Transaction.prototype, "chartAccounts", void 0);
|
|
4169
|
+
__decorate([
|
|
4170
|
+
classTransformer.Type(function () { return IncomeSource; })
|
|
4171
|
+
], Transaction.prototype, "incomeSource", void 0);
|
|
4172
|
+
__decorate([
|
|
4173
|
+
classTransformer.Type(function () { return TransactionMetadata; })
|
|
4174
|
+
], Transaction.prototype, "metadata", void 0);
|
|
4175
|
+
__decorate([
|
|
4176
|
+
classTransformer.Type(function () { return Transaction; })
|
|
4177
|
+
], Transaction.prototype, "transfer", void 0);
|
|
4178
|
+
__decorate([
|
|
4179
|
+
classTransformer.Type(function () { return Loan; })
|
|
4180
|
+
], Transaction.prototype, "loan", void 0);
|
|
4181
|
+
__decorate([
|
|
4182
|
+
classTransformer.Type(function () { return Date; })
|
|
4183
|
+
], Transaction.prototype, "date", void 0);
|
|
4184
|
+
__decorate([
|
|
4185
|
+
classTransformer.Type(function () { return TransactionAllocation; })
|
|
4186
|
+
], Transaction.prototype, "allocations", void 0);
|
|
3960
4187
|
|
|
3961
|
-
var
|
|
3962
|
-
__extends(
|
|
3963
|
-
function
|
|
4188
|
+
var SoleInvoiceItem = /** @class */ (function (_super) {
|
|
4189
|
+
__extends(SoleInvoiceItem, _super);
|
|
4190
|
+
function SoleInvoiceItem() {
|
|
3964
4191
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3965
|
-
_this.
|
|
3966
|
-
_this.frequency = exports.SalaryForecastFrequencyEnum.ANNUAL;
|
|
3967
|
-
_this.isTaxFree = false;
|
|
4192
|
+
_this.isGST = false;
|
|
3968
4193
|
return _this;
|
|
3969
4194
|
}
|
|
3970
|
-
Object.defineProperty(
|
|
3971
|
-
/**
|
|
3972
|
-
* Sometimes Income source has Salary & Income source forecasts,
|
|
3973
|
-
* and we need these fields to work with Income source forecasts like with Salary Forecasts
|
|
3974
|
-
*/
|
|
3975
|
-
get: function () {
|
|
3976
|
-
return this.amount;
|
|
3977
|
-
},
|
|
3978
|
-
enumerable: false,
|
|
3979
|
-
configurable: true
|
|
3980
|
-
});
|
|
3981
|
-
Object.defineProperty(IncomeSourceForecast.prototype, "grossAmount", {
|
|
4195
|
+
Object.defineProperty(SoleInvoiceItem.prototype, "totalPrice", {
|
|
3982
4196
|
get: function () {
|
|
3983
|
-
return this.
|
|
4197
|
+
return this.price * this.quantity;
|
|
3984
4198
|
},
|
|
3985
4199
|
enumerable: false,
|
|
3986
4200
|
configurable: true
|
|
3987
4201
|
});
|
|
3988
|
-
return
|
|
3989
|
-
}(
|
|
4202
|
+
return SoleInvoiceItem;
|
|
4203
|
+
}(SoleInvoiceItem$1));
|
|
4204
|
+
/**
|
|
4205
|
+
* GST percent value
|
|
4206
|
+
*/
|
|
4207
|
+
SoleInvoiceItem.GSTRatio = 0.1;
|
|
3990
4208
|
__decorate([
|
|
3991
|
-
classTransformer.Type(function () { return
|
|
3992
|
-
],
|
|
4209
|
+
classTransformer.Type(function () { return SoleInvoice; })
|
|
4210
|
+
], SoleInvoiceItem.prototype, "invoice", void 0);
|
|
3993
4211
|
__decorate([
|
|
3994
|
-
classTransformer.Type(function () { return
|
|
3995
|
-
],
|
|
4212
|
+
classTransformer.Type(function () { return ChartAccounts; })
|
|
4213
|
+
], SoleInvoiceItem.prototype, "chartAccounts", void 0);
|
|
4214
|
+
__decorate([
|
|
4215
|
+
classTransformer.Type(function () { return Transaction; })
|
|
4216
|
+
], SoleInvoiceItem.prototype, "transaction", void 0);
|
|
3996
4217
|
|
|
3997
|
-
var
|
|
3998
|
-
__extends(
|
|
3999
|
-
function
|
|
4218
|
+
var SoleContact$1 = /** @class */ (function (_super) {
|
|
4219
|
+
__extends(SoleContact, _super);
|
|
4220
|
+
function SoleContact() {
|
|
4000
4221
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
4001
4222
|
}
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
};
|
|
4013
|
-
IncomeSource.prototype.isOtherIncome = function () {
|
|
4014
|
-
return this.type === exports.IncomeSourceTypeEnum.OTHER;
|
|
4015
|
-
};
|
|
4016
|
-
Object.defineProperty(IncomeSource.prototype, "forecasts", {
|
|
4017
|
-
/**
|
|
4018
|
-
* Get salary and other income forecasts
|
|
4019
|
-
*/
|
|
4020
|
-
get: function () {
|
|
4021
|
-
return __spreadArray(__spreadArray(__spreadArray([], __read(this.salaryForecasts)), __read(this.incomeSourceForecasts)), __read(this.soleForecasts));
|
|
4022
|
-
},
|
|
4023
|
-
enumerable: false,
|
|
4024
|
-
configurable: true
|
|
4025
|
-
});
|
|
4026
|
-
Object.defineProperty(IncomeSource.prototype, "actualForecast", {
|
|
4027
|
-
/**
|
|
4028
|
-
* Get actual (1st from the list) forecast
|
|
4029
|
-
*/
|
|
4223
|
+
return SoleContact;
|
|
4224
|
+
}(AbstractModel));
|
|
4225
|
+
|
|
4226
|
+
// @TODO Alex/Vik: Create some base class for User and SoleContact with common methods and properties
|
|
4227
|
+
var SoleContact = /** @class */ (function (_super) {
|
|
4228
|
+
__extends(SoleContact, _super);
|
|
4229
|
+
function SoleContact() {
|
|
4230
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4231
|
+
}
|
|
4232
|
+
Object.defineProperty(SoleContact.prototype, "fullName", {
|
|
4030
4233
|
get: function () {
|
|
4031
|
-
return this.
|
|
4234
|
+
return this.firstName + " " + this.lastName;
|
|
4032
4235
|
},
|
|
4033
4236
|
enumerable: false,
|
|
4034
4237
|
configurable: true
|
|
4035
4238
|
});
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
* @param monthIndex by which month should be taken
|
|
4039
|
-
*/
|
|
4040
|
-
IncomeSource.prototype.isWorkedInMonth = function (monthIndex) {
|
|
4041
|
-
var monthDate = new FinancialYear().getMonthDate(monthIndex);
|
|
4042
|
-
return (!this.dateFrom || monthDate >= this.dateFrom) && (!this.dateTo || monthDate < this.dateTo);
|
|
4239
|
+
SoleContact.prototype.getPhotoPlaceholder = function () {
|
|
4240
|
+
return "" + this.firstName[0].toUpperCase() + this.lastName[0].toUpperCase();
|
|
4043
4241
|
};
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
classTransformer.Type(function () { return SoleForecast; })
|
|
4051
|
-
], IncomeSource.prototype, "soleForecasts", void 0);
|
|
4242
|
+
// @TODO Vik: add photo field to SoleContact
|
|
4243
|
+
SoleContact.prototype.getPhoto = function () {
|
|
4244
|
+
return '';
|
|
4245
|
+
};
|
|
4246
|
+
return SoleContact;
|
|
4247
|
+
}(SoleContact$1));
|
|
4052
4248
|
__decorate([
|
|
4053
|
-
classTransformer.Type(function () { return
|
|
4054
|
-
],
|
|
4249
|
+
classTransformer.Type(function () { return User; })
|
|
4250
|
+
], SoleContact.prototype, "user", void 0);
|
|
4055
4251
|
__decorate([
|
|
4056
|
-
classTransformer.Type(function () { return
|
|
4057
|
-
],
|
|
4252
|
+
classTransformer.Type(function () { return Phone; })
|
|
4253
|
+
], SoleContact.prototype, "phone", void 0);
|
|
4058
4254
|
__decorate([
|
|
4059
|
-
classTransformer.Type(function () { return
|
|
4060
|
-
],
|
|
4061
|
-
|
|
4062
|
-
var TransactionMetadata$1 = /** @class */ (function (_super) {
|
|
4063
|
-
__extends(TransactionMetadata, _super);
|
|
4064
|
-
function TransactionMetadata() {
|
|
4065
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4066
|
-
}
|
|
4067
|
-
return TransactionMetadata;
|
|
4068
|
-
}(AbstractModel));
|
|
4069
|
-
|
|
4070
|
-
var TransactionMetadata = /** @class */ (function (_super) {
|
|
4071
|
-
__extends(TransactionMetadata, _super);
|
|
4072
|
-
function TransactionMetadata() {
|
|
4073
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4074
|
-
}
|
|
4075
|
-
return TransactionMetadata;
|
|
4076
|
-
}(TransactionMetadata$1));
|
|
4255
|
+
classTransformer.Type(function () { return Address; })
|
|
4256
|
+
], SoleContact.prototype, "address", void 0);
|
|
4077
4257
|
__decorate([
|
|
4078
|
-
classTransformer.Type(function () { return
|
|
4079
|
-
],
|
|
4258
|
+
classTransformer.Type(function () { return SoleInvoice; })
|
|
4259
|
+
], SoleContact.prototype, "invoices", void 0);
|
|
4080
4260
|
|
|
4081
|
-
var
|
|
4082
|
-
__extends(
|
|
4083
|
-
function
|
|
4261
|
+
var SoleInvoiceTemplate$1 = /** @class */ (function (_super) {
|
|
4262
|
+
__extends(SoleInvoiceTemplate, _super);
|
|
4263
|
+
function SoleInvoiceTemplate() {
|
|
4084
4264
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
4085
4265
|
}
|
|
4086
|
-
return
|
|
4266
|
+
return SoleInvoiceTemplate;
|
|
4087
4267
|
}(AbstractModel));
|
|
4088
4268
|
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
* Create a new instance of transaction allocation
|
|
4096
|
-
* transaction could be empty since we can POST allocation inside a new transaction
|
|
4097
|
-
*/
|
|
4098
|
-
TransactionAllocation.create = function (amount, bankTransaction, transaction) {
|
|
4099
|
-
return classTransformer.plainToClass(TransactionAllocation, { amount: amount, transaction: transaction, bankTransaction: bankTransaction });
|
|
4100
|
-
};
|
|
4101
|
-
return TransactionAllocation;
|
|
4102
|
-
}(TransactionAllocation$1));
|
|
4103
|
-
__decorate([
|
|
4104
|
-
classTransformer.Type(function () { return BankTransaction; })
|
|
4105
|
-
], TransactionAllocation.prototype, "bankTransaction", void 0);
|
|
4106
|
-
__decorate([
|
|
4107
|
-
classTransformer.Type(function () { return Transaction; })
|
|
4108
|
-
], TransactionAllocation.prototype, "transaction", void 0);
|
|
4109
|
-
|
|
4110
|
-
/**
|
|
4111
|
-
* Enum with income amount types (Net or Gross)
|
|
4112
|
-
*/
|
|
4113
|
-
exports.IncomeAmountTypeEnum = void 0;
|
|
4114
|
-
(function (IncomeAmountTypeEnum) {
|
|
4115
|
-
IncomeAmountTypeEnum[IncomeAmountTypeEnum["NET"] = 0] = "NET";
|
|
4116
|
-
IncomeAmountTypeEnum[IncomeAmountTypeEnum["GROSS"] = 1] = "GROSS";
|
|
4117
|
-
})(exports.IncomeAmountTypeEnum || (exports.IncomeAmountTypeEnum = {}));
|
|
4269
|
+
exports.SoleInvoiceTemplateTaxTypeEnum = void 0;
|
|
4270
|
+
(function (SoleInvoiceTemplateTaxTypeEnum) {
|
|
4271
|
+
SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["TAX_EXCLUSIVE"] = 0] = "TAX_EXCLUSIVE";
|
|
4272
|
+
SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["TAX_INCLUSIVE"] = 1] = "TAX_INCLUSIVE";
|
|
4273
|
+
SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["NO_TAX"] = 2] = "NO_TAX";
|
|
4274
|
+
})(exports.SoleInvoiceTemplateTaxTypeEnum || (exports.SoleInvoiceTemplateTaxTypeEnum = {}));
|
|
4118
4275
|
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
_this.
|
|
4130
|
-
_this
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
return this.type === exports.TransactionTypeEnum.CREDIT;
|
|
4139
|
-
};
|
|
4140
|
-
Transaction.prototype.isIncome = function () {
|
|
4141
|
-
if (!this.chartAccounts) {
|
|
4142
|
-
return this.isCredit();
|
|
4143
|
-
}
|
|
4144
|
-
return CHART_ACCOUNTS_CATEGORIES.income.includes(this.chartAccounts.category);
|
|
4145
|
-
};
|
|
4146
|
-
Transaction.prototype.isExpense = function () {
|
|
4147
|
-
if (!this.chartAccounts) {
|
|
4148
|
-
return this.isDebit();
|
|
4149
|
-
}
|
|
4150
|
-
return CHART_ACCOUNTS_CATEGORIES.expense.includes(this.chartAccounts.category);
|
|
4151
|
-
};
|
|
4152
|
-
Transaction.prototype.isPersonal = function () {
|
|
4153
|
-
return CHART_ACCOUNTS_CATEGORIES.personal.includes(this.chartAccounts.category);
|
|
4154
|
-
};
|
|
4155
|
-
Object.defineProperty(Transaction.prototype, "chartAccountsCategories", {
|
|
4156
|
-
get: function () {
|
|
4157
|
-
switch (true) {
|
|
4158
|
-
case this.isPersonal():
|
|
4159
|
-
return CHART_ACCOUNTS_CATEGORIES.personal;
|
|
4160
|
-
case this.isPropertyTank():
|
|
4161
|
-
return CHART_ACCOUNTS_CATEGORIES.property;
|
|
4162
|
-
case this.isSoleTank():
|
|
4163
|
-
return CHART_ACCOUNTS_CATEGORIES.sole;
|
|
4164
|
-
default:
|
|
4165
|
-
return CHART_ACCOUNTS_CATEGORIES.work;
|
|
4166
|
-
}
|
|
4276
|
+
var SoleInvoiceTemplate = /** @class */ (function (_super) {
|
|
4277
|
+
__extends(SoleInvoiceTemplate, _super);
|
|
4278
|
+
function SoleInvoiceTemplate() {
|
|
4279
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
4280
|
+
/**
|
|
4281
|
+
* Affects to SoleInvoiceItem.isGST flag availability.
|
|
4282
|
+
* When NONE: isGST is unavailable
|
|
4283
|
+
* When EXCLUSIVE: GST amount added additionaly to invoice total price
|
|
4284
|
+
* When INCLUSIVE: GST amount is already included to invoice total price
|
|
4285
|
+
*/
|
|
4286
|
+
_this.taxType = exports.SoleInvoiceTemplateTaxTypeEnum.NO_TAX;
|
|
4287
|
+
return _this;
|
|
4288
|
+
}
|
|
4289
|
+
Object.defineProperty(SoleInvoiceTemplate.prototype, "termTime", {
|
|
4290
|
+
/**
|
|
4291
|
+
* Get term duration in milliseconds
|
|
4292
|
+
*/
|
|
4293
|
+
get: function () {
|
|
4294
|
+
return this.term * 24 * 3600 * 1000;
|
|
4167
4295
|
},
|
|
4168
4296
|
enumerable: false,
|
|
4169
4297
|
configurable: true
|
|
4170
4298
|
});
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4299
|
+
return SoleInvoiceTemplate;
|
|
4300
|
+
}(SoleInvoiceTemplate$1));
|
|
4301
|
+
__decorate([
|
|
4302
|
+
classTransformer.Type(function () { return SoleBusiness; })
|
|
4303
|
+
], SoleInvoiceTemplate.prototype, "business", void 0);
|
|
4304
|
+
__decorate([
|
|
4305
|
+
classTransformer.Type(function () { return BankAccount; })
|
|
4306
|
+
], SoleInvoiceTemplate.prototype, "bankAccount", void 0);
|
|
4307
|
+
|
|
4308
|
+
exports.SoleInvoiceStatusesEnum = void 0;
|
|
4309
|
+
(function (SoleInvoiceStatusesEnum) {
|
|
4310
|
+
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["CANCELED"] = 0] = "CANCELED";
|
|
4311
|
+
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["DRAFT"] = 1] = "DRAFT";
|
|
4312
|
+
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PENDING"] = 2] = "PENDING";
|
|
4313
|
+
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PAID"] = 3] = "PAID";
|
|
4314
|
+
})(exports.SoleInvoiceStatusesEnum || (exports.SoleInvoiceStatusesEnum = {}));
|
|
4315
|
+
|
|
4316
|
+
exports.SoleInvoiceTaxTypeEnum = void 0;
|
|
4317
|
+
(function (SoleInvoiceTaxTypeEnum) {
|
|
4318
|
+
SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["TAX_EXCLUSIVE"] = 0] = "TAX_EXCLUSIVE";
|
|
4319
|
+
SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["TAX_INCLUSIVE"] = 1] = "TAX_INCLUSIVE";
|
|
4320
|
+
SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["NO_TAX"] = 2] = "NO_TAX";
|
|
4321
|
+
})(exports.SoleInvoiceTaxTypeEnum || (exports.SoleInvoiceTaxTypeEnum = {}));
|
|
4322
|
+
|
|
4323
|
+
var SoleInvoiceItemCollection = /** @class */ (function (_super) {
|
|
4324
|
+
__extends(SoleInvoiceItemCollection, _super);
|
|
4325
|
+
function SoleInvoiceItemCollection() {
|
|
4326
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4327
|
+
}
|
|
4328
|
+
Object.defineProperty(SoleInvoiceItemCollection.prototype, "gstPrice", {
|
|
4175
4329
|
get: function () {
|
|
4176
|
-
return this.
|
|
4330
|
+
return this.filterBy('isGST', true).sumBy('totalPrice');
|
|
4177
4331
|
},
|
|
4178
4332
|
enumerable: false,
|
|
4179
4333
|
configurable: true
|
|
4180
4334
|
});
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
Transaction.prototype.getNetAmount = function () {
|
|
4197
|
-
// @TODO fix hack while transactions refactoring (use class-transformer)
|
|
4198
|
-
return +(Math.round(this.getIncomeAmountByType(exports.IncomeAmountTypeEnum.NET) * 100) / 100).toFixed(2);
|
|
4199
|
-
};
|
|
4200
|
-
/**
|
|
4201
|
-
* Get gross income amount
|
|
4202
|
-
*/
|
|
4203
|
-
Transaction.prototype.getGrossIncome = function () {
|
|
4204
|
-
// @TODO fix hack while transactions refactoring (use class-transformer)
|
|
4205
|
-
return +(Math.round(this.getIncomeAmountByType(exports.IncomeAmountTypeEnum.GROSS) * 100) / 100).toFixed(2);
|
|
4206
|
-
};
|
|
4207
|
-
Object.defineProperty(Transaction.prototype, "taxFreeComponent", {
|
|
4335
|
+
return SoleInvoiceItemCollection;
|
|
4336
|
+
}(Collection));
|
|
4337
|
+
|
|
4338
|
+
var SoleInvoice = /** @class */ (function (_super) {
|
|
4339
|
+
__extends(SoleInvoice, _super);
|
|
4340
|
+
function SoleInvoice() {
|
|
4341
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
4342
|
+
_this.status = exports.SoleInvoiceStatusesEnum.DRAFT;
|
|
4343
|
+
_this.taxType = exports.SoleInvoiceTaxTypeEnum.NO_TAX;
|
|
4344
|
+
return _this;
|
|
4345
|
+
}
|
|
4346
|
+
Object.defineProperty(SoleInvoice.prototype, "itemsCollection", {
|
|
4347
|
+
/**
|
|
4348
|
+
* Get items array as collection
|
|
4349
|
+
*/
|
|
4208
4350
|
get: function () {
|
|
4209
|
-
return this.
|
|
4351
|
+
return new SoleInvoiceItemCollection(this.items);
|
|
4210
4352
|
},
|
|
4211
4353
|
enumerable: false,
|
|
4212
4354
|
configurable: true
|
|
4213
4355
|
});
|
|
4214
|
-
Object.defineProperty(
|
|
4356
|
+
Object.defineProperty(SoleInvoice.prototype, "price", {
|
|
4357
|
+
/**
|
|
4358
|
+
* Total price of all items
|
|
4359
|
+
*/
|
|
4215
4360
|
get: function () {
|
|
4216
|
-
return this.
|
|
4361
|
+
return this.itemsCollection.sumBy('totalPrice');
|
|
4217
4362
|
},
|
|
4218
4363
|
enumerable: false,
|
|
4219
4364
|
configurable: true
|
|
4220
4365
|
});
|
|
4221
|
-
Object.defineProperty(
|
|
4366
|
+
Object.defineProperty(SoleInvoice.prototype, "netPrice", {
|
|
4367
|
+
/**
|
|
4368
|
+
* Total invoice price without GST
|
|
4369
|
+
*/
|
|
4222
4370
|
get: function () {
|
|
4223
|
-
|
|
4371
|
+
if (this.isTaxInclusive()) {
|
|
4372
|
+
return this.price - this.GSTAmount;
|
|
4373
|
+
}
|
|
4374
|
+
return this.price;
|
|
4224
4375
|
},
|
|
4225
4376
|
enumerable: false,
|
|
4226
4377
|
configurable: true
|
|
4227
4378
|
});
|
|
4228
|
-
Object.defineProperty(
|
|
4379
|
+
Object.defineProperty(SoleInvoice.prototype, "grossPrice", {
|
|
4380
|
+
/**
|
|
4381
|
+
* Total final price (net + GST)
|
|
4382
|
+
*/
|
|
4229
4383
|
get: function () {
|
|
4230
|
-
|
|
4384
|
+
if (this.isTaxExclusive()) {
|
|
4385
|
+
return this.price + this.GSTAmount;
|
|
4386
|
+
}
|
|
4387
|
+
return this.price;
|
|
4231
4388
|
},
|
|
4232
4389
|
enumerable: false,
|
|
4233
4390
|
configurable: true
|
|
4234
4391
|
});
|
|
4235
|
-
Object.defineProperty(
|
|
4392
|
+
Object.defineProperty(SoleInvoice.prototype, "GSTAmount", {
|
|
4236
4393
|
/**
|
|
4237
|
-
*
|
|
4238
|
-
* @TODO bad usage of get (and all is* methods), getter should sound like a noun
|
|
4394
|
+
* Total GST amount
|
|
4239
4395
|
*/
|
|
4240
4396
|
get: function () {
|
|
4241
|
-
|
|
4397
|
+
switch (this.taxType) {
|
|
4398
|
+
case exports.SoleInvoiceTaxTypeEnum.TAX_INCLUSIVE:
|
|
4399
|
+
return this.inclusiveGSTAmount;
|
|
4400
|
+
case exports.SoleInvoiceTaxTypeEnum.TAX_EXCLUSIVE:
|
|
4401
|
+
return this.exclusiveGSTAmount;
|
|
4402
|
+
case exports.SoleInvoiceTaxTypeEnum.NO_TAX:
|
|
4403
|
+
return 0;
|
|
4404
|
+
}
|
|
4242
4405
|
},
|
|
4243
4406
|
enumerable: false,
|
|
4244
4407
|
configurable: true
|
|
4245
4408
|
});
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4409
|
+
Object.defineProperty(SoleInvoice.prototype, "inclusiveGSTAmount", {
|
|
4410
|
+
/**
|
|
4411
|
+
* When tax inclusive, GST amount is included to total price
|
|
4412
|
+
*/
|
|
4250
4413
|
get: function () {
|
|
4251
|
-
|
|
4414
|
+
var gstPrice = this.itemsCollection.gstPrice;
|
|
4415
|
+
return +(gstPrice - (gstPrice / (1 + SoleInvoiceItem.GSTRatio))).toFixed(2);
|
|
4252
4416
|
},
|
|
4253
4417
|
enumerable: false,
|
|
4254
4418
|
configurable: true
|
|
4255
4419
|
});
|
|
4256
|
-
Object.defineProperty(
|
|
4420
|
+
Object.defineProperty(SoleInvoice.prototype, "exclusiveGSTAmount", {
|
|
4421
|
+
/**
|
|
4422
|
+
* When tax exclusive, GST amount should be added additionally to total price
|
|
4423
|
+
*/
|
|
4257
4424
|
get: function () {
|
|
4258
|
-
return this.
|
|
4425
|
+
return +(this.itemsCollection.gstPrice * SoleInvoiceItem.GSTRatio).toFixed(2);
|
|
4259
4426
|
},
|
|
4260
4427
|
enumerable: false,
|
|
4261
4428
|
configurable: true
|
|
4262
4429
|
});
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
* @param field for which value should be returned
|
|
4266
|
-
* @Todo modify 'metadata' property from array to Collection
|
|
4267
|
-
*/
|
|
4268
|
-
Transaction.prototype.getMetadataFieldValue = function (field) {
|
|
4269
|
-
var _a;
|
|
4270
|
-
return +((_a = this.metadata.find(function (transactionMetadata) {
|
|
4271
|
-
return transactionMetadata.chartAccountsMetadata.id === field;
|
|
4272
|
-
})) === null || _a === void 0 ? void 0 : _a.value) || 0;
|
|
4430
|
+
SoleInvoice.prototype.isDraft = function () {
|
|
4431
|
+
return this.status === exports.SoleInvoiceStatusesEnum.DRAFT;
|
|
4273
4432
|
};
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
* @param incomeType by which amount should be returned
|
|
4277
|
-
*/
|
|
4278
|
-
Transaction.prototype.getIncomeAmountByType = function (incomeType) {
|
|
4279
|
-
// modifier that determines whether the values of the transaction fields will be added or subtracted
|
|
4280
|
-
var modifier = incomeType === exports.IncomeAmountTypeEnum.GROSS ? 1 : -1;
|
|
4281
|
-
switch (true) {
|
|
4282
|
-
case this.isPropertyTank():
|
|
4283
|
-
return this.amount +
|
|
4284
|
-
(this.transactions
|
|
4285
|
-
.reduce(function (sum, transaction) { return sum + Math.abs(transaction.amount); }, 0) * modifier);
|
|
4286
|
-
case this.isWorkTank():
|
|
4287
|
-
return this.amount + ((this.tax + this.frankingCredit - this.taxFreeComponent - this.eligibleForReduction) * modifier);
|
|
4288
|
-
default:
|
|
4289
|
-
return this.amount || 0;
|
|
4290
|
-
}
|
|
4433
|
+
SoleInvoice.prototype.isCancelled = function () {
|
|
4434
|
+
return this.status === exports.SoleInvoiceStatusesEnum.CANCELED;
|
|
4291
4435
|
};
|
|
4292
|
-
|
|
4293
|
-
return this.
|
|
4436
|
+
SoleInvoice.prototype.isPending = function () {
|
|
4437
|
+
return this.status === exports.SoleInvoiceStatusesEnum.PENDING;
|
|
4294
4438
|
};
|
|
4295
|
-
|
|
4296
|
-
return this.
|
|
4439
|
+
SoleInvoice.prototype.isPaid = function () {
|
|
4440
|
+
return this.status === exports.SoleInvoiceStatusesEnum.PAID;
|
|
4297
4441
|
};
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
return
|
|
4303
|
-
date: this.date,
|
|
4304
|
-
amount: this.amount,
|
|
4305
|
-
chartAccounts: this.chartAccounts,
|
|
4306
|
-
description: this.description,
|
|
4307
|
-
type: exports.DepreciationTypeEnum.PLANT_EQUIPMENT,
|
|
4308
|
-
claimPercent: this.claimPercent,
|
|
4309
|
-
property: this.property,
|
|
4310
|
-
calculation: this.property ? this.property.depreciationCalculation : exports.DepreciationCalculationEnum.PRIME_COST
|
|
4311
|
-
});
|
|
4442
|
+
SoleInvoice.prototype.isOverdue = function () {
|
|
4443
|
+
return this.isPending() && this.dateTo < new Date();
|
|
4444
|
+
};
|
|
4445
|
+
SoleInvoice.prototype.isUnpaid = function () {
|
|
4446
|
+
return this.isPending() && this.dateTo >= new Date();
|
|
4312
4447
|
};
|
|
4313
4448
|
/**
|
|
4314
|
-
*
|
|
4449
|
+
* GST is not available for invoices without taxes
|
|
4315
4450
|
*/
|
|
4316
|
-
|
|
4317
|
-
return this.
|
|
4451
|
+
SoleInvoice.prototype.isNoTax = function () {
|
|
4452
|
+
return this.taxType === exports.SoleInvoiceTaxTypeEnum.NO_TAX;
|
|
4318
4453
|
};
|
|
4319
4454
|
/**
|
|
4320
|
-
*
|
|
4455
|
+
* GST amount is not included in items prices for invoices with tax exclusive,
|
|
4456
|
+
* we should add GST amount additionaly to subtotal price to get total price
|
|
4321
4457
|
*/
|
|
4322
|
-
|
|
4323
|
-
return
|
|
4458
|
+
SoleInvoice.prototype.isTaxExclusive = function () {
|
|
4459
|
+
return this.taxType === exports.SoleInvoiceTaxTypeEnum.TAX_EXCLUSIVE;
|
|
4324
4460
|
};
|
|
4325
4461
|
/**
|
|
4326
|
-
*
|
|
4462
|
+
* GST amount already included in items prices for invoices with tax inclusive,
|
|
4463
|
+
* we should subtract GST amount from total price to get subtotal price
|
|
4327
4464
|
*/
|
|
4328
|
-
|
|
4329
|
-
return this.
|
|
4465
|
+
SoleInvoice.prototype.isTaxInclusive = function () {
|
|
4466
|
+
return this.taxType === exports.SoleInvoiceTaxTypeEnum.TAX_INCLUSIVE;
|
|
4330
4467
|
};
|
|
4331
|
-
|
|
4332
|
-
|
|
4468
|
+
SoleInvoice.prototype.getNumber = function () {
|
|
4469
|
+
return String(this.number).padStart(SoleInvoice.NUMBER_LENGTH, '0');
|
|
4470
|
+
};
|
|
4471
|
+
Object.defineProperty(SoleInvoice.prototype, "name", {
|
|
4472
|
+
get: function () {
|
|
4473
|
+
return "invoice-" + this.getNumber() + ".pdf";
|
|
4474
|
+
},
|
|
4475
|
+
enumerable: false,
|
|
4476
|
+
configurable: true
|
|
4477
|
+
});
|
|
4478
|
+
return SoleInvoice;
|
|
4479
|
+
}(SoleInvoice$1));
|
|
4480
|
+
SoleInvoice.NUMBER_LENGTH = 4;
|
|
4333
4481
|
__decorate([
|
|
4334
|
-
classTransformer.Type(function () { return
|
|
4335
|
-
],
|
|
4482
|
+
classTransformer.Type(function () { return Date; })
|
|
4483
|
+
], SoleInvoice.prototype, "dateFrom", void 0);
|
|
4336
4484
|
__decorate([
|
|
4337
|
-
classTransformer.Type(function () { return
|
|
4338
|
-
],
|
|
4485
|
+
classTransformer.Type(function () { return Date; })
|
|
4486
|
+
], SoleInvoice.prototype, "dateTo", void 0);
|
|
4339
4487
|
__decorate([
|
|
4340
|
-
classTransformer.Type(function () { return
|
|
4341
|
-
],
|
|
4488
|
+
classTransformer.Type(function () { return User; })
|
|
4489
|
+
], SoleInvoice.prototype, "user", void 0);
|
|
4342
4490
|
__decorate([
|
|
4343
|
-
classTransformer.Type(function () { return
|
|
4344
|
-
],
|
|
4491
|
+
classTransformer.Type(function () { return SoleBusiness; })
|
|
4492
|
+
], SoleInvoice.prototype, "business", void 0);
|
|
4345
4493
|
__decorate([
|
|
4346
|
-
classTransformer.Type(function () { return
|
|
4347
|
-
],
|
|
4494
|
+
classTransformer.Type(function () { return SoleInvoiceItem; })
|
|
4495
|
+
], SoleInvoice.prototype, "items", void 0);
|
|
4348
4496
|
__decorate([
|
|
4349
|
-
classTransformer.Type(function () { return
|
|
4350
|
-
],
|
|
4497
|
+
classTransformer.Type(function () { return SoleContact; })
|
|
4498
|
+
], SoleInvoice.prototype, "payer", void 0);
|
|
4351
4499
|
__decorate([
|
|
4352
|
-
classTransformer.Type(function () { return
|
|
4353
|
-
],
|
|
4500
|
+
classTransformer.Type(function () { return SoleInvoiceTemplate; })
|
|
4501
|
+
], SoleInvoice.prototype, "template", void 0);
|
|
4354
4502
|
__decorate([
|
|
4355
|
-
classTransformer.Type(function () { return
|
|
4356
|
-
],
|
|
4503
|
+
classTransformer.Type(function () { return BankAccount; })
|
|
4504
|
+
], SoleInvoice.prototype, "bankAccount", void 0);
|
|
4505
|
+
|
|
4506
|
+
/**
|
|
4507
|
+
* Class contains traveled kilometers and work usage percent in 12 weeks date range
|
|
4508
|
+
* @TODO Vik: Best period: move this and related logic to backend
|
|
4509
|
+
* @TODO Alex: check if we need this class when calculation refactored with backend
|
|
4510
|
+
*/
|
|
4511
|
+
var LogbookPeriod = /** @class */ (function () {
|
|
4512
|
+
function LogbookPeriod() {
|
|
4513
|
+
}
|
|
4514
|
+
LogbookPeriod.prototype.isEndOfYear = function () {
|
|
4515
|
+
return this.to === new FinancialYear().endDate;
|
|
4516
|
+
};
|
|
4517
|
+
LogbookPeriod.prototype.getWorkUsageByClaim = function (claim) {
|
|
4518
|
+
var claimKilometers = this.logbooks.getByVehicleClaim(claim).getClaimableLogbooks().kilometers;
|
|
4519
|
+
return Math.round(this.workUsage * (claimKilometers / this.kilometers));
|
|
4520
|
+
};
|
|
4521
|
+
return LogbookPeriod;
|
|
4522
|
+
}());
|
|
4357
4523
|
__decorate([
|
|
4358
4524
|
classTransformer.Type(function () { return Date; })
|
|
4359
|
-
],
|
|
4525
|
+
], LogbookPeriod.prototype, "from", void 0);
|
|
4360
4526
|
__decorate([
|
|
4361
|
-
classTransformer.Type(function () { return
|
|
4362
|
-
],
|
|
4527
|
+
classTransformer.Type(function () { return Date; })
|
|
4528
|
+
], LogbookPeriod.prototype, "to", void 0);
|
|
4363
4529
|
|
|
4364
|
-
var
|
|
4365
|
-
__extends(
|
|
4366
|
-
function
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4530
|
+
var Vehicle$1 = /** @class */ (function (_super) {
|
|
4531
|
+
__extends(Vehicle, _super);
|
|
4532
|
+
function Vehicle() {
|
|
4533
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4534
|
+
}
|
|
4535
|
+
return Vehicle;
|
|
4536
|
+
}(AbstractModel));
|
|
4537
|
+
|
|
4538
|
+
var VehicleLogbook$1 = /** @class */ (function (_super) {
|
|
4539
|
+
__extends(VehicleLogbook, _super);
|
|
4540
|
+
function VehicleLogbook() {
|
|
4541
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4372
4542
|
}
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4543
|
+
return VehicleLogbook;
|
|
4544
|
+
}(AbstractModel));
|
|
4545
|
+
|
|
4546
|
+
var moment = momentRange.extendMoment(moment__namespace);
|
|
4547
|
+
var VehicleLogbook = /** @class */ (function (_super) {
|
|
4548
|
+
__extends(VehicleLogbook, _super);
|
|
4549
|
+
function VehicleLogbook() {
|
|
4550
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4551
|
+
}
|
|
4552
|
+
Object.defineProperty(VehicleLogbook.prototype, "kilometers", {
|
|
4377
4553
|
get: function () {
|
|
4378
|
-
return this.
|
|
4554
|
+
return this.odometerEnd - this.odometerStart;
|
|
4379
4555
|
},
|
|
4380
4556
|
enumerable: false,
|
|
4381
4557
|
configurable: true
|
|
4382
4558
|
});
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
BankTransaction.prototype.isCredit = function () {
|
|
4393
|
-
return this.type === exports.BankTransactionTypeEnum.CREDIT;
|
|
4394
|
-
};
|
|
4395
|
-
/**
|
|
4396
|
-
* Create Transaction instance based on Bank Transaction
|
|
4397
|
-
*/
|
|
4398
|
-
BankTransaction.prototype.toTransaction = function () {
|
|
4399
|
-
return classTransformer.plainToClass(Transaction, {
|
|
4400
|
-
amount: +this.amount.toFixed(2),
|
|
4401
|
-
description: this.description,
|
|
4402
|
-
date: this.date,
|
|
4403
|
-
source: exports.TransactionSourceEnum.BANK_TRANSACTION,
|
|
4404
|
-
operation: this.operation,
|
|
4405
|
-
type: this.type,
|
|
4406
|
-
});
|
|
4407
|
-
};
|
|
4408
|
-
/**
|
|
4409
|
-
* Check if bank transaction is completely allocated
|
|
4410
|
-
*/
|
|
4411
|
-
BankTransaction.prototype.isAllocated = function (allocations) {
|
|
4412
|
-
return this.amount === this.getAllocatedAmount(allocations);
|
|
4559
|
+
Object.defineProperty(VehicleLogbook.prototype, "tankType", {
|
|
4560
|
+
get: function () {
|
|
4561
|
+
return this.isSoleTank() ? exports.TankTypeEnum.SOLE : exports.TankTypeEnum.WORK;
|
|
4562
|
+
},
|
|
4563
|
+
enumerable: false,
|
|
4564
|
+
configurable: true
|
|
4565
|
+
});
|
|
4566
|
+
VehicleLogbook.prototype.isWorkTank = function () {
|
|
4567
|
+
return !this.business;
|
|
4413
4568
|
};
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
*/
|
|
4417
|
-
BankTransaction.prototype.getAllocatedAmount = function (allocations) {
|
|
4418
|
-
return allocations.getByBankTransactionsIds([this.id]).amount;
|
|
4569
|
+
VehicleLogbook.prototype.isSoleTank = function () {
|
|
4570
|
+
return !!this.business;
|
|
4419
4571
|
};
|
|
4420
4572
|
/**
|
|
4421
|
-
* Get
|
|
4573
|
+
* Get logbook period date range from logbook date and weeksInPeriod duration
|
|
4422
4574
|
*/
|
|
4423
|
-
|
|
4424
|
-
return
|
|
4575
|
+
VehicleLogbook.prototype.getPeriod = function () {
|
|
4576
|
+
return moment.rangeFromInterval('milliseconds', VehicleLogbook.bestPeriodDuration, this.date);
|
|
4425
4577
|
};
|
|
4426
|
-
return
|
|
4427
|
-
}(
|
|
4578
|
+
return VehicleLogbook;
|
|
4579
|
+
}(VehicleLogbook$1));
|
|
4580
|
+
/**
|
|
4581
|
+
* Logbook period duration in milliseconds.
|
|
4582
|
+
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/211517441/Logbook+Vehicle
|
|
4583
|
+
*/
|
|
4584
|
+
VehicleLogbook.bestPeriodDuration = 12 * 7 * 24 * 3600 * 1000;
|
|
4428
4585
|
__decorate([
|
|
4429
4586
|
classTransformer.Type(function () { return Date; })
|
|
4430
|
-
],
|
|
4587
|
+
], VehicleLogbook.prototype, "date", void 0);
|
|
4588
|
+
__decorate([
|
|
4589
|
+
classTransformer.Type(function () { return SoleBusiness; })
|
|
4590
|
+
], VehicleLogbook.prototype, "business", void 0);
|
|
4431
4591
|
|
|
4432
|
-
/**
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4592
|
+
var Vehicle = /** @class */ (function (_super) {
|
|
4593
|
+
__extends(Vehicle, _super);
|
|
4594
|
+
function Vehicle() {
|
|
4595
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4596
|
+
}
|
|
4597
|
+
return Vehicle;
|
|
4598
|
+
}(Vehicle$1));
|
|
4599
|
+
__decorate([
|
|
4600
|
+
classTransformer.Type(function () { return VehicleLogbook; })
|
|
4601
|
+
], Vehicle.prototype, "logbook", void 0);
|
|
4602
|
+
|
|
4603
|
+
var VehicleClaim$1 = /** @class */ (function (_super) {
|
|
4604
|
+
__extends(VehicleClaim, _super);
|
|
4605
|
+
function VehicleClaim() {
|
|
4606
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4607
|
+
}
|
|
4608
|
+
return VehicleClaim;
|
|
4609
|
+
}(AbstractModel));
|
|
4610
|
+
|
|
4611
|
+
var VehicleClaimDetails$1 = /** @class */ (function (_super) {
|
|
4612
|
+
__extends(VehicleClaimDetails, _super);
|
|
4613
|
+
function VehicleClaimDetails() {
|
|
4614
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4615
|
+
}
|
|
4616
|
+
return VehicleClaimDetails;
|
|
4617
|
+
}(AbstractModel));
|
|
4618
|
+
|
|
4619
|
+
exports.VehicleClaimDetailsMethodEnum = void 0;
|
|
4620
|
+
(function (VehicleClaimDetailsMethodEnum) {
|
|
4621
|
+
VehicleClaimDetailsMethodEnum[VehicleClaimDetailsMethodEnum["KMS"] = 1] = "KMS";
|
|
4622
|
+
VehicleClaimDetailsMethodEnum[VehicleClaimDetailsMethodEnum["LOGBOOK"] = 2] = "LOGBOOK";
|
|
4623
|
+
})(exports.VehicleClaimDetailsMethodEnum || (exports.VehicleClaimDetailsMethodEnum = {}));
|
|
4624
|
+
|
|
4625
|
+
var VehicleClaimDetails = /** @class */ (function (_super) {
|
|
4626
|
+
__extends(VehicleClaimDetails, _super);
|
|
4627
|
+
function VehicleClaimDetails() {
|
|
4438
4628
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
4439
|
-
_this.forecasts = [];
|
|
4440
|
-
_this.type = exports.DepreciationTypeEnum.PLANT_EQUIPMENT;
|
|
4441
4629
|
/**
|
|
4442
|
-
*
|
|
4630
|
+
* Init default values for the new instances
|
|
4443
4631
|
*/
|
|
4444
|
-
_this.
|
|
4632
|
+
_this.isManual = true;
|
|
4633
|
+
_this.method = exports.VehicleClaimDetailsMethodEnum.KMS;
|
|
4634
|
+
_this.financialYear = new FinancialYear().year;
|
|
4445
4635
|
return _this;
|
|
4446
4636
|
}
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
return this.type === exports.DepreciationTypeEnum.CAPITAL_WORKS;
|
|
4450
|
-
};
|
|
4451
|
-
Depreciation.prototype.isBorrowingExpense = function () {
|
|
4452
|
-
return this.type === exports.DepreciationTypeEnum.BORROWING_EXPENSES;
|
|
4453
|
-
};
|
|
4454
|
-
Depreciation.prototype.isAsset = function () {
|
|
4455
|
-
return this.type === exports.DepreciationTypeEnum.PLANT_EQUIPMENT;
|
|
4456
|
-
};
|
|
4457
|
-
// Calculation checking
|
|
4458
|
-
Depreciation.prototype.isSBPCalculation = function () {
|
|
4459
|
-
return this.calculation === exports.DepreciationCalculationEnum.SBP;
|
|
4460
|
-
};
|
|
4461
|
-
Depreciation.prototype.isPrimeCost = function () {
|
|
4462
|
-
return this.calculation === exports.DepreciationCalculationEnum.PRIME_COST;
|
|
4463
|
-
};
|
|
4464
|
-
Depreciation.prototype.isDiminishing = function () {
|
|
4465
|
-
return this.calculation === exports.DepreciationCalculationEnum.DIMINISHING;
|
|
4466
|
-
};
|
|
4467
|
-
// Pool checking
|
|
4468
|
-
Depreciation.prototype.isPlantEquipmentPool = function () {
|
|
4469
|
-
return this.isAsset() && !this.isSBPCalculation() && !this.isWrittenOff() && !this.isLVP();
|
|
4637
|
+
VehicleClaimDetails.prototype.isLogbookMethod = function () {
|
|
4638
|
+
return this.method === exports.VehicleClaimDetailsMethodEnum.LOGBOOK;
|
|
4470
4639
|
};
|
|
4471
|
-
|
|
4472
|
-
return this.
|
|
4473
|
-
&& !this.isSBPCalculation()
|
|
4474
|
-
&& this.isDiminishing()
|
|
4475
|
-
&& this.currentYearForecast.closeBalance > Depreciation.WRITTEN_OFF_THRESHOLD
|
|
4476
|
-
&& this.currentYearForecast.closeBalance <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
|
|
4640
|
+
VehicleClaimDetails.prototype.isKmsMethod = function () {
|
|
4641
|
+
return this.method === exports.VehicleClaimDetailsMethodEnum.KMS;
|
|
4477
4642
|
};
|
|
4478
|
-
|
|
4479
|
-
|
|
4643
|
+
return VehicleClaimDetails;
|
|
4644
|
+
}(VehicleClaimDetails$1));
|
|
4645
|
+
__decorate([
|
|
4646
|
+
classTransformer.Type(function () { return User; })
|
|
4647
|
+
], VehicleClaimDetails.prototype, "user", void 0);
|
|
4648
|
+
|
|
4649
|
+
var VehicleClaim = /** @class */ (function (_super) {
|
|
4650
|
+
__extends(VehicleClaim, _super);
|
|
4651
|
+
function VehicleClaim() {
|
|
4652
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
4653
|
+
_this.kilometers = 0;
|
|
4654
|
+
_this.workUsage = 0;
|
|
4655
|
+
return _this;
|
|
4656
|
+
}
|
|
4657
|
+
VehicleClaim.prototype.isWorkTank = function () {
|
|
4658
|
+
return !this.business;
|
|
4480
4659
|
};
|
|
4481
|
-
|
|
4482
|
-
return this.
|
|
4660
|
+
VehicleClaim.prototype.isSoleTank = function () {
|
|
4661
|
+
return !!this.business;
|
|
4483
4662
|
};
|
|
4484
|
-
Object.defineProperty(
|
|
4663
|
+
Object.defineProperty(VehicleClaim.prototype, "tankType", {
|
|
4485
4664
|
get: function () {
|
|
4486
|
-
|
|
4487
|
-
if (!this.writeOffManualDate && !this.writeOffDate) {
|
|
4488
|
-
return null;
|
|
4489
|
-
}
|
|
4490
|
-
return (_a = new FinancialYear(this.writeOffManualDate || this.writeOffDate)) === null || _a === void 0 ? void 0 : _a.year;
|
|
4665
|
+
return this.isSoleTank() ? exports.TankTypeEnum.SOLE : exports.TankTypeEnum.WORK;
|
|
4491
4666
|
},
|
|
4492
4667
|
enumerable: false,
|
|
4493
4668
|
configurable: true
|
|
4494
4669
|
});
|
|
4495
4670
|
/**
|
|
4496
|
-
*
|
|
4671
|
+
* Claim amount for KMs method. Exists only for KMs method.
|
|
4497
4672
|
*/
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
return ((_a = this.chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id) === exports.ChartAccountsHeadingVehicleListEnum.DEPRECIATION_VEHICLES;
|
|
4673
|
+
VehicleClaim.prototype.getKMSClaimAmount = function (vehicleClaimRate) {
|
|
4674
|
+
return +(this.kilometers * vehicleClaimRate).toFixed(2);
|
|
4501
4675
|
};
|
|
4502
4676
|
/**
|
|
4503
|
-
* Get
|
|
4677
|
+
* Get logbook claim amount. Exists only for logbook method.
|
|
4678
|
+
* ClaimAmount = WorkUsage * transaction/depreciation amount
|
|
4504
4679
|
*/
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
get: function () {
|
|
4513
|
-
return this.forecasts.find(function (forecast) {
|
|
4514
|
-
return forecast.financialYear === new FinancialYear().year;
|
|
4515
|
-
}) || classTransformer.plainToClass(DepreciationForecast, {
|
|
4516
|
-
financialYear: new FinancialYear().year,
|
|
4517
|
-
openBalance: 0,
|
|
4518
|
-
closeBalance: 0,
|
|
4519
|
-
amount: 0,
|
|
4520
|
-
claimPercent: 0
|
|
4521
|
-
});
|
|
4522
|
-
},
|
|
4523
|
-
enumerable: false,
|
|
4524
|
-
configurable: true
|
|
4525
|
-
});
|
|
4526
|
-
Depreciation.prototype.getForecastByYear = function (year) {
|
|
4527
|
-
return this.forecasts.find(function (forecast) {
|
|
4528
|
-
return forecast.financialYear === year;
|
|
4529
|
-
});
|
|
4530
|
-
};
|
|
4531
|
-
Depreciation.prototype.getClaimAmountByYear = function (year) {
|
|
4532
|
-
var _a;
|
|
4533
|
-
return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
|
|
4534
|
-
};
|
|
4535
|
-
Depreciation.prototype.getCloseBalanceByYear = function (year) {
|
|
4536
|
-
var _a;
|
|
4537
|
-
return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.closeBalance) || 0;
|
|
4538
|
-
};
|
|
4539
|
-
Depreciation.prototype.isBuildingAtCost = function () {
|
|
4540
|
-
return this.chartAccounts.id === exports.ChartAccountsListEnum.BUILDING_AT_COST;
|
|
4680
|
+
VehicleClaim.prototype.getLogbookClaimAmount = function (transactions) {
|
|
4681
|
+
var transactionsAmount = transactions
|
|
4682
|
+
.getByVehicleClaim(this)
|
|
4683
|
+
.getLogbookTransactions()
|
|
4684
|
+
.sumBy('amount');
|
|
4685
|
+
// Math.abs because amount will be negative (because we sum expenses), but we don't want negative percent value
|
|
4686
|
+
return Math.abs(transactionsAmount) * this.workUsage / 100;
|
|
4541
4687
|
};
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
*/
|
|
4545
|
-
Depreciation.prototype.toTransaction = function (params) {
|
|
4546
|
-
if (params === void 0) { params = {}; }
|
|
4547
|
-
return classTransformer.plainToClass(Transaction, Object.assign(params, this, { amount: this.currentYearForecast.amount }));
|
|
4688
|
+
VehicleClaim.prototype.getAverageWeeklyKMS = function () {
|
|
4689
|
+
return this.kilometers / FinancialYear.weeksInYear;
|
|
4548
4690
|
};
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
__decorate([
|
|
4565
|
-
classTransformer.Type(function () { return Date; })
|
|
4566
|
-
], Depreciation.prototype, "purchaseDate", void 0);
|
|
4567
|
-
__decorate([
|
|
4568
|
-
classTransformer.Type(function () { return Date; })
|
|
4569
|
-
], Depreciation.prototype, "date", void 0);
|
|
4570
|
-
__decorate([
|
|
4571
|
-
classTransformer.Type(function () { return Date; })
|
|
4572
|
-
], Depreciation.prototype, "lowValuePoolDate", void 0);
|
|
4573
|
-
__decorate([
|
|
4574
|
-
classTransformer.Type(function () { return Date; })
|
|
4575
|
-
], Depreciation.prototype, "writeOffManualDate", void 0);
|
|
4576
|
-
__decorate([
|
|
4577
|
-
classTransformer.Type(function () { return Date; })
|
|
4578
|
-
], Depreciation.prototype, "writeOffDate", void 0);
|
|
4579
|
-
__decorate([
|
|
4580
|
-
classTransformer.Type(function () { return DepreciationCapitalProject; })
|
|
4581
|
-
], Depreciation.prototype, "depreciationCapitalProject", void 0);
|
|
4582
|
-
__decorate([
|
|
4583
|
-
classTransformer.Type(function () { return DepreciationForecast; }),
|
|
4584
|
-
classTransformer.Transform(function (_b) {
|
|
4585
|
-
var value = _b.value, obj = _b.obj;
|
|
4586
|
-
// value = array of DepreciationForecast
|
|
4587
|
-
// obj = plain (whole Depreciation object)
|
|
4588
|
-
// Set isLVP flag for each DepreciationForecast
|
|
4589
|
-
// @TODO refactor
|
|
4590
|
-
value.forEach(function (forecast) {
|
|
4591
|
-
forecast.isLVP =
|
|
4592
|
-
forecast.closeBalance < 1000 &&
|
|
4593
|
-
obj.calculation === exports.DepreciationCalculationEnum.DIMINISHING &&
|
|
4594
|
-
obj.type === exports.DepreciationTypeEnum.PLANT_EQUIPMENT &&
|
|
4595
|
-
!(obj.amount > Depreciation.WRITTEN_OFF_THRESHOLD && obj.amount < Depreciation.LOW_VALUE_POOL_THRESHOLD) &&
|
|
4596
|
-
!(obj.writeOffDate && new FinancialYear(new Date(obj.writeOffDate)).year === obj.financialYear);
|
|
4597
|
-
});
|
|
4598
|
-
return value;
|
|
4599
|
-
})
|
|
4600
|
-
], Depreciation.prototype, "forecasts", void 0);
|
|
4691
|
+
VehicleClaim.getKMSChartAccountsIdByTankType = function (tankType) {
|
|
4692
|
+
return tankType === exports.TankTypeEnum.WORK
|
|
4693
|
+
? exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK
|
|
4694
|
+
: exports.ChartAccountsListEnum.KLMS_TRAVELLED;
|
|
4695
|
+
};
|
|
4696
|
+
return VehicleClaim;
|
|
4697
|
+
}(VehicleClaim$1));
|
|
4698
|
+
/**
|
|
4699
|
+
* limit for kms claim method
|
|
4700
|
+
*/
|
|
4701
|
+
VehicleClaim.totalKmsLimit = 5000;
|
|
4702
|
+
/**
|
|
4703
|
+
* limit for work usage claim method
|
|
4704
|
+
*/
|
|
4705
|
+
VehicleClaim.totalWorkUsagePercent = 100;
|
|
4601
4706
|
__decorate([
|
|
4602
|
-
classTransformer.Type(function () { return
|
|
4603
|
-
],
|
|
4707
|
+
classTransformer.Type(function () { return VehicleClaimDetails; })
|
|
4708
|
+
], VehicleClaim.prototype, "details", void 0);
|
|
4604
4709
|
__decorate([
|
|
4605
|
-
classTransformer.Type(function () { return
|
|
4606
|
-
],
|
|
4710
|
+
classTransformer.Type(function () { return SoleBusiness; })
|
|
4711
|
+
], VehicleClaim.prototype, "business", void 0);
|
|
4607
4712
|
|
|
4608
4713
|
var SoleBusinessActivity$1 = /** @class */ (function (_super) {
|
|
4609
4714
|
__extends(SoleBusinessActivity, _super);
|
|
@@ -4694,6 +4799,25 @@
|
|
|
4694
4799
|
return SoleDepreciationMethod;
|
|
4695
4800
|
}(SoleDepreciationMethod$1));
|
|
4696
4801
|
|
|
4802
|
+
var SoleDetails$1 = /** @class */ (function (_super) {
|
|
4803
|
+
__extends(SoleDetails, _super);
|
|
4804
|
+
function SoleDetails() {
|
|
4805
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4806
|
+
}
|
|
4807
|
+
return SoleDetails;
|
|
4808
|
+
}(AbstractModel));
|
|
4809
|
+
|
|
4810
|
+
var SoleDetails = /** @class */ (function (_super) {
|
|
4811
|
+
__extends(SoleDetails, _super);
|
|
4812
|
+
function SoleDetails() {
|
|
4813
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4814
|
+
}
|
|
4815
|
+
return SoleDetails;
|
|
4816
|
+
}(SoleDetails$1));
|
|
4817
|
+
__decorate([
|
|
4818
|
+
classTransformer.Type(function () { return User; })
|
|
4819
|
+
], SoleDetails.prototype, "user", void 0);
|
|
4820
|
+
|
|
4697
4821
|
var User = /** @class */ (function (_super) {
|
|
4698
4822
|
__extends(User, _super);
|
|
4699
4823
|
function User() {
|
|
@@ -6555,6 +6679,65 @@
|
|
|
6555
6679
|
}]
|
|
6556
6680
|
}] });
|
|
6557
6681
|
|
|
6682
|
+
var Document$1 = /** @class */ (function (_super) {
|
|
6683
|
+
__extends(Document, _super);
|
|
6684
|
+
function Document() {
|
|
6685
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6686
|
+
}
|
|
6687
|
+
return Document;
|
|
6688
|
+
}(AbstractModel));
|
|
6689
|
+
|
|
6690
|
+
/**
|
|
6691
|
+
* Enum with document types which used to API url prefix
|
|
6692
|
+
*/
|
|
6693
|
+
exports.DocumentApiUrlPrefixEnum = void 0;
|
|
6694
|
+
(function (DocumentApiUrlPrefixEnum) {
|
|
6695
|
+
DocumentApiUrlPrefixEnum["FOLDERS"] = "folders";
|
|
6696
|
+
DocumentApiUrlPrefixEnum["PROPERTIES"] = "properties";
|
|
6697
|
+
})(exports.DocumentApiUrlPrefixEnum || (exports.DocumentApiUrlPrefixEnum = {}));
|
|
6698
|
+
|
|
6699
|
+
var Document = /** @class */ (function (_super) {
|
|
6700
|
+
__extends(Document, _super);
|
|
6701
|
+
function Document() {
|
|
6702
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
6703
|
+
_this.type = exports.AssetTypeEnum.DOCUMENTS;
|
|
6704
|
+
_this.entityType = exports.AssetEntityTypeEnum.FOLDERS;
|
|
6705
|
+
return _this;
|
|
6706
|
+
}
|
|
6707
|
+
/**
|
|
6708
|
+
* Get folder as document parent entity
|
|
6709
|
+
*/
|
|
6710
|
+
Document.prototype.getEntity = function () {
|
|
6711
|
+
return this.folder;
|
|
6712
|
+
};
|
|
6713
|
+
/**
|
|
6714
|
+
* Get API url prefix
|
|
6715
|
+
*/
|
|
6716
|
+
Document.prototype.getApiUrlPrefix = function () {
|
|
6717
|
+
return exports.DocumentApiUrlPrefixEnum.FOLDERS;
|
|
6718
|
+
};
|
|
6719
|
+
return Document;
|
|
6720
|
+
}(Document$1));
|
|
6721
|
+
|
|
6722
|
+
var DocumentFolder$1 = /** @class */ (function (_super) {
|
|
6723
|
+
__extends(DocumentFolder, _super);
|
|
6724
|
+
function DocumentFolder() {
|
|
6725
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6726
|
+
}
|
|
6727
|
+
return DocumentFolder;
|
|
6728
|
+
}(AbstractModel));
|
|
6729
|
+
|
|
6730
|
+
var DocumentFolder = /** @class */ (function (_super) {
|
|
6731
|
+
__extends(DocumentFolder, _super);
|
|
6732
|
+
function DocumentFolder() {
|
|
6733
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6734
|
+
}
|
|
6735
|
+
return DocumentFolder;
|
|
6736
|
+
}(DocumentFolder$1));
|
|
6737
|
+
__decorate([
|
|
6738
|
+
classTransformer.Type(function () { return Document; })
|
|
6739
|
+
], DocumentFolder.prototype, "documents", void 0);
|
|
6740
|
+
|
|
6558
6741
|
var VehicleClaimCollection = /** @class */ (function (_super) {
|
|
6559
6742
|
__extends(VehicleClaimCollection, _super);
|
|
6560
6743
|
function VehicleClaimCollection() {
|
|
@@ -7015,6 +7198,31 @@
|
|
|
7015
7198
|
return ClientPortfolioReportCollection;
|
|
7016
7199
|
}(Collection));
|
|
7017
7200
|
|
|
7201
|
+
/**
|
|
7202
|
+
* Chart serie class: chart data item
|
|
7203
|
+
* @TODO consider rename to ChartSerieData
|
|
7204
|
+
*/
|
|
7205
|
+
var ChartSerie = /** @class */ (function () {
|
|
7206
|
+
function ChartSerie() {
|
|
7207
|
+
}
|
|
7208
|
+
return ChartSerie;
|
|
7209
|
+
}());
|
|
7210
|
+
|
|
7211
|
+
/**
|
|
7212
|
+
* Chart data class
|
|
7213
|
+
* @TODO consider rename to ChartSerie
|
|
7214
|
+
*/
|
|
7215
|
+
var ChartData = /** @class */ (function () {
|
|
7216
|
+
function ChartData() {
|
|
7217
|
+
}
|
|
7218
|
+
return ChartData;
|
|
7219
|
+
}());
|
|
7220
|
+
__decorate([
|
|
7221
|
+
classTransformer.Type(function () { return ChartSerie; })
|
|
7222
|
+
], ChartData.prototype, "data", void 0);
|
|
7223
|
+
|
|
7224
|
+
var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
|
|
7225
|
+
|
|
7018
7226
|
/**
|
|
7019
7227
|
* Collection of transactions
|
|
7020
7228
|
*/
|
|
@@ -7231,6 +7439,29 @@
|
|
|
7231
7439
|
.getVehicleTransactions()
|
|
7232
7440
|
.removeBy('chartAccounts.id', [exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK, exports.ChartAccountsListEnum.KLMS_TRAVELLED]);
|
|
7233
7441
|
};
|
|
7442
|
+
/**
|
|
7443
|
+
* Build chart data with transactions cash position.
|
|
7444
|
+
* Cash position = Income - Expenses (include depreciations)
|
|
7445
|
+
* Chart data for each month from fin year start till current month
|
|
7446
|
+
*/
|
|
7447
|
+
TransactionCollection.prototype.getCashPositionChartData = function () {
|
|
7448
|
+
var _this = this;
|
|
7449
|
+
var chartData = [
|
|
7450
|
+
classTransformer.plainToClass(ChartData, { name: 'Income', data: [] }),
|
|
7451
|
+
classTransformer.plainToClass(ChartData, { name: 'Expense', data: [] })
|
|
7452
|
+
];
|
|
7453
|
+
new FinancialYear().getPastMonths().forEach(function (month) {
|
|
7454
|
+
chartData[0].data.push({
|
|
7455
|
+
label: MONTHS[month],
|
|
7456
|
+
value: _this.getIncomeTransactions().getByMonth(month).claimAmount
|
|
7457
|
+
});
|
|
7458
|
+
chartData[1].data.push({
|
|
7459
|
+
label: MONTHS[month],
|
|
7460
|
+
value: Math.abs(_this.getExpenseTransactions().getByMonth(month).claimAmount)
|
|
7461
|
+
});
|
|
7462
|
+
});
|
|
7463
|
+
return chartData;
|
|
7464
|
+
};
|
|
7234
7465
|
return TransactionCollection;
|
|
7235
7466
|
}(ExportableCollection));
|
|
7236
7467
|
|
|
@@ -8385,6 +8616,13 @@
|
|
|
8385
8616
|
return ChartAccountsCategoryECollection;
|
|
8386
8617
|
}());
|
|
8387
8618
|
|
|
8619
|
+
exports.DocumentTypeEnum = void 0;
|
|
8620
|
+
(function (DocumentTypeEnum) {
|
|
8621
|
+
DocumentTypeEnum[DocumentTypeEnum["INVOICE"] = 1] = "INVOICE";
|
|
8622
|
+
})(exports.DocumentTypeEnum || (exports.DocumentTypeEnum = {}));
|
|
8623
|
+
|
|
8624
|
+
// @TODO Artem TT-2308 move everything
|
|
8625
|
+
|
|
8388
8626
|
exports.ChartAccountsEtpEnum = void 0;
|
|
8389
8627
|
(function (ChartAccountsEtpEnum) {
|
|
8390
8628
|
ChartAccountsEtpEnum[ChartAccountsEtpEnum["ETP_R"] = 549] = "ETP_R";
|
|
@@ -9147,29 +9385,6 @@
|
|
|
9147
9385
|
return BorrowingExpenseLoan;
|
|
9148
9386
|
}(BorrowingExpenseLoan$1));
|
|
9149
9387
|
|
|
9150
|
-
/**
|
|
9151
|
-
* Chart serie class: chart data item
|
|
9152
|
-
* @TODO consider rename to ChartSerieData
|
|
9153
|
-
*/
|
|
9154
|
-
var ChartSerie = /** @class */ (function () {
|
|
9155
|
-
function ChartSerie() {
|
|
9156
|
-
}
|
|
9157
|
-
return ChartSerie;
|
|
9158
|
-
}());
|
|
9159
|
-
|
|
9160
|
-
/**
|
|
9161
|
-
* Chart data class
|
|
9162
|
-
* @TODO consider rename to ChartSerie
|
|
9163
|
-
*/
|
|
9164
|
-
var ChartData = /** @class */ (function () {
|
|
9165
|
-
function ChartData() {
|
|
9166
|
-
}
|
|
9167
|
-
return ChartData;
|
|
9168
|
-
}());
|
|
9169
|
-
__decorate([
|
|
9170
|
-
classTransformer.Type(function () { return ChartSerie; })
|
|
9171
|
-
], ChartData.prototype, "data", void 0);
|
|
9172
|
-
|
|
9173
9388
|
var ChartAccountsDepreciation$1 = /** @class */ (function (_super) {
|
|
9174
9389
|
__extends(ChartAccountsDepreciation, _super);
|
|
9175
9390
|
function ChartAccountsDepreciation() {
|
|
@@ -9612,7 +9827,7 @@
|
|
|
9612
9827
|
this.items[key] = value;
|
|
9613
9828
|
};
|
|
9614
9829
|
Dictionary.prototype.get = function (key) {
|
|
9615
|
-
return this.items[key] ? this.items[key] : null;
|
|
9830
|
+
return this.items[key] !== undefined ? this.items[key] : null;
|
|
9616
9831
|
};
|
|
9617
9832
|
Dictionary.prototype.groupItems = function (items, path) {
|
|
9618
9833
|
var _this = this;
|
|
@@ -9720,50 +9935,10 @@
|
|
|
9720
9935
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
9721
9936
|
_this.type = exports.AssetTypeEnum.RECEIPTS;
|
|
9722
9937
|
_this.entityType = exports.AssetEntityTypeEnum.DEPRECIATIONS;
|
|
9723
|
-
return _this;
|
|
9724
|
-
}
|
|
9725
|
-
return DepreciationReceipt;
|
|
9726
|
-
}(DepreciationReceipt$1));
|
|
9727
|
-
|
|
9728
|
-
var Document$1 = /** @class */ (function (_super) {
|
|
9729
|
-
__extends(Document, _super);
|
|
9730
|
-
function Document() {
|
|
9731
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
9732
|
-
}
|
|
9733
|
-
return Document;
|
|
9734
|
-
}(AbstractModel));
|
|
9735
|
-
|
|
9736
|
-
/**
|
|
9737
|
-
* Enum with document types which used to API url prefix
|
|
9738
|
-
*/
|
|
9739
|
-
exports.DocumentApiUrlPrefixEnum = void 0;
|
|
9740
|
-
(function (DocumentApiUrlPrefixEnum) {
|
|
9741
|
-
DocumentApiUrlPrefixEnum["FOLDERS"] = "folders";
|
|
9742
|
-
DocumentApiUrlPrefixEnum["PROPERTIES"] = "properties";
|
|
9743
|
-
})(exports.DocumentApiUrlPrefixEnum || (exports.DocumentApiUrlPrefixEnum = {}));
|
|
9744
|
-
|
|
9745
|
-
var Document = /** @class */ (function (_super) {
|
|
9746
|
-
__extends(Document, _super);
|
|
9747
|
-
function Document() {
|
|
9748
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
9749
|
-
_this.type = exports.AssetTypeEnum.DOCUMENTS;
|
|
9750
|
-
_this.entityType = exports.AssetEntityTypeEnum.FOLDERS;
|
|
9751
|
-
return _this;
|
|
9752
|
-
}
|
|
9753
|
-
/**
|
|
9754
|
-
* Get folder as document parent entity
|
|
9755
|
-
*/
|
|
9756
|
-
Document.prototype.getEntity = function () {
|
|
9757
|
-
return this.folder;
|
|
9758
|
-
};
|
|
9759
|
-
/**
|
|
9760
|
-
* Get API url prefix
|
|
9761
|
-
*/
|
|
9762
|
-
Document.prototype.getApiUrlPrefix = function () {
|
|
9763
|
-
return exports.DocumentApiUrlPrefixEnum.FOLDERS;
|
|
9764
|
-
};
|
|
9765
|
-
return Document;
|
|
9766
|
-
}(Document$1));
|
|
9938
|
+
return _this;
|
|
9939
|
+
}
|
|
9940
|
+
return DepreciationReceipt;
|
|
9941
|
+
}(DepreciationReceipt$1));
|
|
9767
9942
|
|
|
9768
9943
|
var DOCUMENT_FILE_TYPES = {
|
|
9769
9944
|
image: [
|
|
@@ -9788,25 +9963,6 @@
|
|
|
9788
9963
|
]
|
|
9789
9964
|
};
|
|
9790
9965
|
|
|
9791
|
-
var DocumentFolder$1 = /** @class */ (function (_super) {
|
|
9792
|
-
__extends(DocumentFolder, _super);
|
|
9793
|
-
function DocumentFolder() {
|
|
9794
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
9795
|
-
}
|
|
9796
|
-
return DocumentFolder;
|
|
9797
|
-
}(AbstractModel));
|
|
9798
|
-
|
|
9799
|
-
var DocumentFolder = /** @class */ (function (_super) {
|
|
9800
|
-
__extends(DocumentFolder, _super);
|
|
9801
|
-
function DocumentFolder() {
|
|
9802
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
9803
|
-
}
|
|
9804
|
-
return DocumentFolder;
|
|
9805
|
-
}(DocumentFolder$1));
|
|
9806
|
-
__decorate([
|
|
9807
|
-
classTransformer.Type(function () { return Document; })
|
|
9808
|
-
], DocumentFolder.prototype, "documents", void 0);
|
|
9809
|
-
|
|
9810
9966
|
var EmployeeInvite$1 = /** @class */ (function (_super) {
|
|
9811
9967
|
__extends(EmployeeInvite, _super);
|
|
9812
9968
|
function EmployeeInvite() {
|
|
@@ -9842,8 +9998,6 @@
|
|
|
9842
9998
|
IconsFileEnum["DOC"] = "icon-doc";
|
|
9843
9999
|
})(exports.IconsFileEnum || (exports.IconsFileEnum = {}));
|
|
9844
10000
|
|
|
9845
|
-
var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
|
|
9846
|
-
|
|
9847
10001
|
// Todo extend from the base model when the backend is ready TT-555
|
|
9848
10002
|
var IncomePosition = /** @class */ (function () {
|
|
9849
10003
|
function IncomePosition() {
|
|
@@ -11713,6 +11867,17 @@
|
|
|
11713
11867
|
_this.isHydra = true;
|
|
11714
11868
|
return _this;
|
|
11715
11869
|
}
|
|
11870
|
+
SoleInvoiceService.prototype.updateStatus = function (invoice, status) {
|
|
11871
|
+
// use id only to avoid unexpected changes
|
|
11872
|
+
return this.update(classTransformer.plainToClass(SoleInvoice, merge__default["default"]({}, { id: invoice.id }, { status: status })));
|
|
11873
|
+
};
|
|
11874
|
+
SoleInvoiceService.prototype.publish = function (invoice, document) {
|
|
11875
|
+
// use id only to avoid unexpected changes
|
|
11876
|
+
return this.update(merge__default["default"]({}, invoice, { document: document, status: exports.SoleInvoiceStatusesEnum.PENDING }));
|
|
11877
|
+
};
|
|
11878
|
+
SoleInvoiceService.prototype.sendEmail = function (invoice) {
|
|
11879
|
+
return this.http.post(this.environment.apiV2 + "/" + this.url + "/" + invoice.id + "/send", {});
|
|
11880
|
+
};
|
|
11716
11881
|
return SoleInvoiceService;
|
|
11717
11882
|
}(RestService));
|
|
11718
11883
|
SoleInvoiceService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleInvoiceService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
@@ -12091,6 +12256,99 @@
|
|
|
12091
12256
|
}]
|
|
12092
12257
|
}] });
|
|
12093
12258
|
|
|
12259
|
+
var DocumentService = /** @class */ (function (_super) {
|
|
12260
|
+
__extends(DocumentService, _super);
|
|
12261
|
+
function DocumentService() {
|
|
12262
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
12263
|
+
_this.url = 'documents';
|
|
12264
|
+
_this.modelClass = Document;
|
|
12265
|
+
return _this;
|
|
12266
|
+
}
|
|
12267
|
+
return DocumentService;
|
|
12268
|
+
}(RestService));
|
|
12269
|
+
DocumentService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
12270
|
+
DocumentService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentService, providedIn: 'root' });
|
|
12271
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentService, decorators: [{
|
|
12272
|
+
type: i0.Injectable,
|
|
12273
|
+
args: [{
|
|
12274
|
+
providedIn: 'root'
|
|
12275
|
+
}]
|
|
12276
|
+
}] });
|
|
12277
|
+
|
|
12278
|
+
/**
|
|
12279
|
+
* Service to handle document-folders and depending documents logic
|
|
12280
|
+
*/
|
|
12281
|
+
var DocumentFolderService = /** @class */ (function (_super) {
|
|
12282
|
+
__extends(DocumentFolderService, _super);
|
|
12283
|
+
function DocumentFolderService() {
|
|
12284
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
12285
|
+
_this.url = 'folders';
|
|
12286
|
+
_this.modelClass = DocumentFolder;
|
|
12287
|
+
return _this;
|
|
12288
|
+
}
|
|
12289
|
+
/**
|
|
12290
|
+
* Add new document to the folder
|
|
12291
|
+
* @param file to be uploaded to the folder
|
|
12292
|
+
* @param folder for document
|
|
12293
|
+
*/
|
|
12294
|
+
DocumentFolderService.prototype.addDocument = function (file, folder) {
|
|
12295
|
+
var _this = this;
|
|
12296
|
+
// create formData object with provided file
|
|
12297
|
+
var formDataDocument = new FormData();
|
|
12298
|
+
formDataDocument.append('file', file);
|
|
12299
|
+
return this.http.post(this.environment.apiV2 + "/folders/" + folder.id + "/documents", formDataDocument).pipe(operators.map(function (response) {
|
|
12300
|
+
var updatedFolder = Object.assign(classTransformer.plainToClass(DocumentFolder, {}), folder);
|
|
12301
|
+
updatedFolder.documents.push(classTransformer.plainToClass(Document, response));
|
|
12302
|
+
replace(_this.cache, classTransformer.plainToClass(DocumentFolder, updatedFolder));
|
|
12303
|
+
_this.cacheSubject.next(_this.cache);
|
|
12304
|
+
}));
|
|
12305
|
+
};
|
|
12306
|
+
/**
|
|
12307
|
+
* Edit folder document by moving it from one folder to another
|
|
12308
|
+
* @param editedDocument
|
|
12309
|
+
* @param selectedFolder to move the document to
|
|
12310
|
+
* @param oldFolderId: id of old folder from which need to remove the document
|
|
12311
|
+
*/
|
|
12312
|
+
DocumentFolderService.prototype.updateDocument = function (editedDocument, selectedFolder, oldFolderId) {
|
|
12313
|
+
var _this = this;
|
|
12314
|
+
return this.http.put(this.environment.apiV2 + "/folders/" + selectedFolder.id + "/documents/" + editedDocument.id, editedDocument).pipe(operators.map(function (response) {
|
|
12315
|
+
var oldFolder = _this.cache.find(function (folder) { return folder.id === oldFolderId; });
|
|
12316
|
+
// Remove document from old folder
|
|
12317
|
+
oldFolder.documents = oldFolder.documents.filter(function (deletedDocument) { return deletedDocument.id !== response.id; });
|
|
12318
|
+
// update old folder and replace it in cache
|
|
12319
|
+
response.folder = classTransformer.plainToClass(DocumentFolder, { id: selectedFolder.id, name: selectedFolder.name });
|
|
12320
|
+
replace(_this.cache, classTransformer.plainToClass(DocumentFolder, oldFolder));
|
|
12321
|
+
// update new document folder and replace it in cache
|
|
12322
|
+
selectedFolder.documents.push(classTransformer.plainToClass(Document, response));
|
|
12323
|
+
replace(_this.cache, classTransformer.plainToClass(DocumentFolder, selectedFolder));
|
|
12324
|
+
_this.cacheSubject.next(_this.cache);
|
|
12325
|
+
}));
|
|
12326
|
+
};
|
|
12327
|
+
/**
|
|
12328
|
+
* Delete document from folder
|
|
12329
|
+
* @param document to remove
|
|
12330
|
+
* @param folder from which document should be removed
|
|
12331
|
+
*/
|
|
12332
|
+
DocumentFolderService.prototype.deleteDocument = function (document, folder) {
|
|
12333
|
+
var _this = this;
|
|
12334
|
+
return this.http.delete(this.environment.apiV2 + "/folders/" + folder.id + "/documents/" + document.id).pipe(operators.map(function () {
|
|
12335
|
+
folder.documents = folder.documents
|
|
12336
|
+
.filter(function (deletedDocument) { return deletedDocument.id !== document.id; });
|
|
12337
|
+
replace(_this.cache, classTransformer.plainToClass(DocumentFolder, folder));
|
|
12338
|
+
_this.cacheSubject.next(_this.cache);
|
|
12339
|
+
}));
|
|
12340
|
+
};
|
|
12341
|
+
return DocumentFolderService;
|
|
12342
|
+
}(RestService));
|
|
12343
|
+
DocumentFolderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentFolderService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
12344
|
+
DocumentFolderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentFolderService, providedIn: 'root' });
|
|
12345
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentFolderService, decorators: [{
|
|
12346
|
+
type: i0.Injectable,
|
|
12347
|
+
args: [{
|
|
12348
|
+
providedIn: 'root'
|
|
12349
|
+
}]
|
|
12350
|
+
}] });
|
|
12351
|
+
|
|
12094
12352
|
/**
|
|
12095
12353
|
* Service to work with Rewardful (affiliate program) API
|
|
12096
12354
|
* https://developers.rewardful.com/javascript-api/overview#executing-code-when-rewardful-loads
|
|
@@ -12545,6 +12803,7 @@
|
|
|
12545
12803
|
IncomeSourceService.prototype.listenSoleBusinessCreated = function () {
|
|
12546
12804
|
var _this = this;
|
|
12547
12805
|
this.eventDispatcherService.on(exports.AppEventTypeEnum.SOLE_BUSINESS_CREATED).subscribe(function () {
|
|
12806
|
+
// @TODO Alex/Vik (TT-1777): we clear cache a lot, a better and easier way required, add todo and task to refactor
|
|
12548
12807
|
_this.resetCache();
|
|
12549
12808
|
});
|
|
12550
12809
|
};
|
|
@@ -14600,80 +14859,6 @@
|
|
|
14600
14859
|
}] }];
|
|
14601
14860
|
} });
|
|
14602
14861
|
|
|
14603
|
-
/**
|
|
14604
|
-
* Service to handle document-folders and depending documents logic
|
|
14605
|
-
*/
|
|
14606
|
-
var DocumentFolderService = /** @class */ (function (_super) {
|
|
14607
|
-
__extends(DocumentFolderService, _super);
|
|
14608
|
-
function DocumentFolderService() {
|
|
14609
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
14610
|
-
_this.url = 'folders';
|
|
14611
|
-
_this.modelClass = DocumentFolder;
|
|
14612
|
-
return _this;
|
|
14613
|
-
}
|
|
14614
|
-
/**
|
|
14615
|
-
* Add new document to the folder
|
|
14616
|
-
* @param file to be uploaded to the folder
|
|
14617
|
-
* @param folder for document
|
|
14618
|
-
*/
|
|
14619
|
-
DocumentFolderService.prototype.addDocument = function (file, folder) {
|
|
14620
|
-
var _this = this;
|
|
14621
|
-
// create formData object with provided file
|
|
14622
|
-
var formDataDocument = new FormData();
|
|
14623
|
-
formDataDocument.append('file', file);
|
|
14624
|
-
return this.http.post(this.environment.apiV2 + "/folders/" + folder.id + "/documents", formDataDocument).pipe(operators.map(function (response) {
|
|
14625
|
-
var updatedFolder = Object.assign(classTransformer.plainToClass(DocumentFolder, {}), folder);
|
|
14626
|
-
updatedFolder.documents.push(classTransformer.plainToClass(Document, response));
|
|
14627
|
-
replace(_this.cache, classTransformer.plainToClass(DocumentFolder, updatedFolder));
|
|
14628
|
-
_this.cacheSubject.next(_this.cache);
|
|
14629
|
-
}));
|
|
14630
|
-
};
|
|
14631
|
-
/**
|
|
14632
|
-
* Edit folder document by moving it from one folder to another
|
|
14633
|
-
* @param editedDocument
|
|
14634
|
-
* @param selectedFolder to move the document to
|
|
14635
|
-
* @param oldFolderId: id of old folder from which need to remove the document
|
|
14636
|
-
*/
|
|
14637
|
-
DocumentFolderService.prototype.updateDocument = function (editedDocument, selectedFolder, oldFolderId) {
|
|
14638
|
-
var _this = this;
|
|
14639
|
-
return this.http.put(this.environment.apiV2 + "/folders/" + selectedFolder.id + "/documents/" + editedDocument.id, editedDocument).pipe(operators.map(function (response) {
|
|
14640
|
-
var oldFolder = _this.cache.find(function (folder) { return folder.id === oldFolderId; });
|
|
14641
|
-
// Remove document from old folder
|
|
14642
|
-
oldFolder.documents = oldFolder.documents.filter(function (deletedDocument) { return deletedDocument.id !== response.id; });
|
|
14643
|
-
// update old folder and replace it in cache
|
|
14644
|
-
response.folder = classTransformer.plainToClass(DocumentFolder, { id: selectedFolder.id, name: selectedFolder.name });
|
|
14645
|
-
replace(_this.cache, classTransformer.plainToClass(DocumentFolder, oldFolder));
|
|
14646
|
-
// update new document folder and replace it in cache
|
|
14647
|
-
selectedFolder.documents.push(classTransformer.plainToClass(Document, response));
|
|
14648
|
-
replace(_this.cache, classTransformer.plainToClass(DocumentFolder, selectedFolder));
|
|
14649
|
-
_this.cacheSubject.next(_this.cache);
|
|
14650
|
-
}));
|
|
14651
|
-
};
|
|
14652
|
-
/**
|
|
14653
|
-
* Delete document from folder
|
|
14654
|
-
* @param document to remove
|
|
14655
|
-
* @param folder from which document should be removed
|
|
14656
|
-
*/
|
|
14657
|
-
DocumentFolderService.prototype.deleteDocument = function (document, folder) {
|
|
14658
|
-
var _this = this;
|
|
14659
|
-
return this.http.delete(this.environment.apiV2 + "/folders/" + folder.id + "/documents/" + document.id).pipe(operators.map(function () {
|
|
14660
|
-
folder.documents = folder.documents
|
|
14661
|
-
.filter(function (deletedDocument) { return deletedDocument.id !== document.id; });
|
|
14662
|
-
replace(_this.cache, classTransformer.plainToClass(DocumentFolder, folder));
|
|
14663
|
-
_this.cacheSubject.next(_this.cache);
|
|
14664
|
-
}));
|
|
14665
|
-
};
|
|
14666
|
-
return DocumentFolderService;
|
|
14667
|
-
}(RestService));
|
|
14668
|
-
DocumentFolderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentFolderService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
14669
|
-
DocumentFolderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentFolderService, providedIn: 'root' });
|
|
14670
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentFolderService, decorators: [{
|
|
14671
|
-
type: i0.Injectable,
|
|
14672
|
-
args: [{
|
|
14673
|
-
providedIn: 'root'
|
|
14674
|
-
}]
|
|
14675
|
-
}] });
|
|
14676
|
-
|
|
14677
14862
|
var EmployeeService = /** @class */ (function (_super) {
|
|
14678
14863
|
__extends(EmployeeService, _super);
|
|
14679
14864
|
function EmployeeService() {
|
|
@@ -15398,6 +15583,8 @@
|
|
|
15398
15583
|
};
|
|
15399
15584
|
|
|
15400
15585
|
/**
|
|
15586
|
+
* @TODO mikhail better typehint
|
|
15587
|
+
*
|
|
15401
15588
|
* Service to generate and export PDF file from provided HTML elements
|
|
15402
15589
|
* The file is generated using the html2pdf library in order to get a canvas at the output,
|
|
15403
15590
|
* in which all the styles that the user sees on the page will be saved
|
|
@@ -15405,20 +15592,30 @@
|
|
|
15405
15592
|
var PdfFromDomElementService = /** @class */ (function () {
|
|
15406
15593
|
function PdfFromDomElementService() {
|
|
15407
15594
|
}
|
|
15408
|
-
PdfFromDomElementService.prototype.
|
|
15595
|
+
PdfFromDomElementService.prototype.init = function (elements, fileSettings) {
|
|
15409
15596
|
var options = FILE_SETTINGS$1;
|
|
15410
|
-
|
|
15597
|
+
if (fileSettings) {
|
|
15598
|
+
merge__default["default"](options, fileSettings);
|
|
15599
|
+
}
|
|
15411
15600
|
// HTML container in which the exported DOM elements will be placed
|
|
15412
15601
|
var htmlWrapper = document.createElement('div');
|
|
15413
15602
|
elements.forEach(function (element) {
|
|
15414
15603
|
htmlWrapper.append(element.cloneNode(true));
|
|
15415
15604
|
});
|
|
15416
15605
|
// Set PDF options, save file and return result as Observable
|
|
15417
|
-
return
|
|
15418
|
-
|
|
15606
|
+
return html2pdf__namespace().from(htmlWrapper).set(options);
|
|
15607
|
+
};
|
|
15608
|
+
PdfFromDomElementService.prototype.download = function (elements, fileSettings) {
|
|
15609
|
+
return rxjs.from(this.init(elements, fileSettings)
|
|
15419
15610
|
.save()
|
|
15420
15611
|
.then());
|
|
15421
15612
|
};
|
|
15613
|
+
PdfFromDomElementService.prototype.export = function (elements, filename) {
|
|
15614
|
+
if (filename === void 0) { filename = FILE_SETTINGS$1.filename; }
|
|
15615
|
+
return rxjs.from(this.init(elements)
|
|
15616
|
+
.outputPdf('blob')
|
|
15617
|
+
.then(function (blob) { return new File([blob], filename, { type: 'application/pdf' }); }));
|
|
15618
|
+
};
|
|
15422
15619
|
return PdfFromDomElementService;
|
|
15423
15620
|
}());
|
|
15424
15621
|
PdfFromDomElementService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PdfFromDomElementService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
@@ -16548,6 +16745,17 @@
|
|
|
16548
16745
|
return !_this.isAllocated(transaction, allocations);
|
|
16549
16746
|
}));
|
|
16550
16747
|
};
|
|
16748
|
+
/**
|
|
16749
|
+
* Get invoices allocated amounts grouped bu invoice id
|
|
16750
|
+
*/
|
|
16751
|
+
TransactionCalculationService.prototype.getAllocationsAmountsByInvoiceId = function (allocations, invoices) {
|
|
16752
|
+
var allocationsByTransactionId = allocations.groupBy('transaction.id');
|
|
16753
|
+
var dictionary = new Dictionary([]);
|
|
16754
|
+
invoices.toArray().forEach(function (invoice) {
|
|
16755
|
+
dictionary.add(invoice.id, allocationsByTransactionId.merge(invoice.itemsCollection.mapBy('transaction.id')).amount || 0);
|
|
16756
|
+
});
|
|
16757
|
+
return dictionary;
|
|
16758
|
+
};
|
|
16551
16759
|
return TransactionCalculationService;
|
|
16552
16760
|
}());
|
|
16553
16761
|
TransactionCalculationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionCalculationService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
@@ -17200,7 +17408,7 @@
|
|
|
17200
17408
|
// User have to create income source with new business.
|
|
17201
17409
|
// Income source is not able for edit business
|
|
17202
17410
|
if (!business.id) {
|
|
17203
|
-
// @TODO Alex: move to separated form class
|
|
17411
|
+
// @TODO Alex (TT-2304): move to separated form class
|
|
17204
17412
|
_this.addControl('incomeSource', new forms.FormGroup({
|
|
17205
17413
|
type: new forms.FormControl(exports.IncomeSourceTypeEnum.SOLE, forms.Validators.required),
|
|
17206
17414
|
name: new forms.FormControl(null, forms.Validators.required),
|
|
@@ -17219,9 +17427,18 @@
|
|
|
17219
17427
|
})
|
|
17220
17428
|
]));
|
|
17221
17429
|
}
|
|
17430
|
+
_this.listenEvents();
|
|
17222
17431
|
return _this;
|
|
17223
17432
|
}
|
|
17433
|
+
SoleBusinessForm.prototype.listenEvents = function () {
|
|
17434
|
+
if (this.contains('incomeSource')) {
|
|
17435
|
+
this.listenNameChanges();
|
|
17436
|
+
}
|
|
17437
|
+
};
|
|
17224
17438
|
Object.defineProperty(SoleBusinessForm.prototype, "forecastFormGroup", {
|
|
17439
|
+
/**
|
|
17440
|
+
* We take the first forecast because income sources available only for new business, so we have only one forecast
|
|
17441
|
+
*/
|
|
17225
17442
|
get: function () {
|
|
17226
17443
|
return this.get('incomeSource').get('soleForecasts').at(0);
|
|
17227
17444
|
},
|
|
@@ -17229,12 +17446,23 @@
|
|
|
17229
17446
|
configurable: true
|
|
17230
17447
|
});
|
|
17231
17448
|
Object.defineProperty(SoleBusinessForm.prototype, "lossFormGroup", {
|
|
17449
|
+
/**
|
|
17450
|
+
* We take the first loss because losses available only for new business, so we have only one loss
|
|
17451
|
+
*/
|
|
17232
17452
|
get: function () {
|
|
17233
17453
|
return this.get('losses').at(0);
|
|
17234
17454
|
},
|
|
17235
17455
|
enumerable: false,
|
|
17236
17456
|
configurable: true
|
|
17237
17457
|
});
|
|
17458
|
+
SoleBusinessForm.prototype.listenNameChanges = function () {
|
|
17459
|
+
var _this = this;
|
|
17460
|
+
console.log('subs');
|
|
17461
|
+
this.get('name').valueChanges.subscribe(function (name) {
|
|
17462
|
+
console.log('listenNameChants');
|
|
17463
|
+
_this.get('incomeSource').get('name').setValue(name);
|
|
17464
|
+
});
|
|
17465
|
+
};
|
|
17238
17466
|
return SoleBusinessForm;
|
|
17239
17467
|
}(AbstractForm));
|
|
17240
17468
|
|
|
@@ -17362,55 +17590,38 @@
|
|
|
17362
17590
|
description: new forms.FormControl(item.description, forms.Validators.required),
|
|
17363
17591
|
quantity: new forms.FormControl(item.quantity, forms.Validators.required),
|
|
17364
17592
|
price: new forms.FormControl(item.price, forms.Validators.required),
|
|
17365
|
-
isGST: new forms.FormControl({ value: item.isGST, disabled: !((_a = item.chartAccounts) === null || _a === void 0 ? void 0 : _a.isGST) }),
|
|
17366
|
-
chartAccounts: new forms.FormControl(item.chartAccounts, forms.Validators.required)
|
|
17593
|
+
isGST: new forms.FormControl({ value: item.isGST || false, disabled: !((_a = item.chartAccounts) === null || _a === void 0 ? void 0 : _a.isGST) }),
|
|
17594
|
+
chartAccounts: new forms.FormControl(item.chartAccounts, forms.Validators.required),
|
|
17367
17595
|
}, item) || this;
|
|
17368
|
-
_this.listenEvents();
|
|
17369
17596
|
return _this;
|
|
17370
17597
|
}
|
|
17371
|
-
SoleInvoiceItemForm.prototype.listenEvents = function () {
|
|
17372
|
-
this.listenChartAccountsChanges();
|
|
17373
|
-
};
|
|
17374
|
-
SoleInvoiceItemForm.prototype.onTemplateChanged = function (template) {
|
|
17375
|
-
this.template = template;
|
|
17376
|
-
if (this.template.isNoTax()) {
|
|
17377
|
-
this.get('isGST').setValue(false);
|
|
17378
|
-
this.get('isGST').disable();
|
|
17379
|
-
}
|
|
17380
|
-
else {
|
|
17381
|
-
this.get('isGST').enable();
|
|
17382
|
-
}
|
|
17383
|
-
};
|
|
17384
|
-
SoleInvoiceItemForm.prototype.listenChartAccountsChanges = function () {
|
|
17385
|
-
var _this = this;
|
|
17386
|
-
this.get('chartAccounts').valueChanges.subscribe(function (chartAccounts) {
|
|
17387
|
-
if (_this.template.isNoTax()) {
|
|
17388
|
-
return;
|
|
17389
|
-
}
|
|
17390
|
-
if (chartAccounts.isGST) {
|
|
17391
|
-
_this.get('isGST').enable();
|
|
17392
|
-
}
|
|
17393
|
-
else {
|
|
17394
|
-
_this.get('isGST').setValue(false);
|
|
17395
|
-
_this.get('isGST').disable();
|
|
17396
|
-
}
|
|
17397
|
-
});
|
|
17398
|
-
};
|
|
17399
17598
|
return SoleInvoiceItemForm;
|
|
17400
17599
|
}(AbstractForm));
|
|
17401
17600
|
|
|
17402
17601
|
var SoleInvoiceForm = /** @class */ (function (_super) {
|
|
17403
17602
|
__extends(SoleInvoiceForm, _super);
|
|
17404
|
-
function SoleInvoiceForm(invoice) {
|
|
17603
|
+
function SoleInvoiceForm(invoice, soleDetailsGST) {
|
|
17405
17604
|
var _this = _super.call(this, {
|
|
17406
|
-
dateFrom: new forms.FormControl(invoice.dateFrom, forms.Validators.required),
|
|
17605
|
+
dateFrom: new forms.FormControl(invoice.dateFrom || new Date(), forms.Validators.required),
|
|
17407
17606
|
dateTo: new forms.FormControl(invoice.dateTo, forms.Validators.required),
|
|
17408
|
-
items: new forms.FormArray(invoice.items.map(function (item) { return new SoleInvoiceItemForm(item); })),
|
|
17607
|
+
items: new forms.FormArray((invoice.items || [classTransformer.plainToClass(SoleInvoiceItem, {})]).map(function (item) { return new SoleInvoiceItemForm(item); })),
|
|
17409
17608
|
payer: new forms.FormControl(invoice.payer, forms.Validators.required),
|
|
17410
|
-
|
|
17609
|
+
taxType: new forms.FormControl(invoice.taxType, forms.Validators.required),
|
|
17610
|
+
bankAccount: new forms.FormControl(invoice.bankAccount, forms.Validators.required)
|
|
17411
17611
|
}, invoice) || this;
|
|
17412
|
-
|
|
17413
|
-
|
|
17612
|
+
_this.soleDetailsGST = soleDetailsGST;
|
|
17613
|
+
// we need invoice template only for new invoices
|
|
17614
|
+
if (!invoice.id) {
|
|
17615
|
+
_this.addControl('template', new forms.FormControl(invoice.template));
|
|
17616
|
+
}
|
|
17617
|
+
// invoice.taxType is always NONE ('No Tax') when soleDetails.isGST === false
|
|
17618
|
+
if (!_this.soleDetailsGST) {
|
|
17619
|
+
_this.get('taxType').setValue(exports.SoleInvoiceTaxTypeEnum.NO_TAX);
|
|
17620
|
+
_this.get('taxType').disable();
|
|
17621
|
+
// Items isGST is not available when invoice.taxType === NONE ('No Tax')
|
|
17622
|
+
_this.items.controls.forEach(function (itemForm) {
|
|
17623
|
+
_this.disableItemGST(itemForm);
|
|
17624
|
+
});
|
|
17414
17625
|
}
|
|
17415
17626
|
_this.listenEvents();
|
|
17416
17627
|
return _this;
|
|
@@ -17423,59 +17634,121 @@
|
|
|
17423
17634
|
configurable: true
|
|
17424
17635
|
});
|
|
17425
17636
|
SoleInvoiceForm.prototype.listenEvents = function () {
|
|
17426
|
-
this
|
|
17637
|
+
var _this = this;
|
|
17638
|
+
// no need to listen tax type and items chart accounts changes when soleDetails.isGST === false
|
|
17639
|
+
// because invoice tax type always 'No Tax' in this case and not available for changing
|
|
17640
|
+
if (this.soleDetailsGST) {
|
|
17641
|
+
this.listenTaxTypeChanges();
|
|
17642
|
+
this.items.controls.forEach(function (itemForm) {
|
|
17643
|
+
_this.listenItemChartAccountsChanges(itemForm);
|
|
17644
|
+
});
|
|
17645
|
+
}
|
|
17646
|
+
// nothing to listen if template field is not учшые (edit invoice case)
|
|
17647
|
+
if (this.contains('template')) {
|
|
17648
|
+
this.listenTemplateChanges();
|
|
17649
|
+
}
|
|
17427
17650
|
};
|
|
17428
17651
|
SoleInvoiceForm.prototype.addItem = function () {
|
|
17429
|
-
|
|
17652
|
+
var itemForm = new SoleInvoiceItemForm(classTransformer.plainToClass(SoleInvoiceItem, {}));
|
|
17653
|
+
// no need to listen items chart accounts changes when soleDetails.isGST === false
|
|
17654
|
+
// because invoice tax type always 'No Tax' in this case and not available for changing
|
|
17655
|
+
if (this.soleDetailsGST) {
|
|
17656
|
+
this.listenItemChartAccountsChanges(itemForm);
|
|
17657
|
+
}
|
|
17658
|
+
this.items.push(itemForm);
|
|
17430
17659
|
};
|
|
17431
17660
|
SoleInvoiceForm.prototype.removeItem = function (index) {
|
|
17432
|
-
// do not remove the last item
|
|
17433
|
-
if (this.items.length === 1) {
|
|
17434
|
-
return;
|
|
17435
|
-
}
|
|
17436
17661
|
this.items.removeAt(index);
|
|
17437
17662
|
};
|
|
17438
17663
|
SoleInvoiceForm.prototype.submit = function (data) {
|
|
17439
17664
|
if (data === void 0) { data = {}; }
|
|
17665
|
+
// @TODO Alex TT-2190: move child custom forms submit to Abstract Form
|
|
17440
17666
|
var items = this.items.controls.map(function (control) { return control.submit(); });
|
|
17441
|
-
return _super.prototype.submit.call(this,
|
|
17667
|
+
return _super.prototype.submit.call(this, merge__default["default"](data, { items: items }));
|
|
17442
17668
|
};
|
|
17669
|
+
/**
|
|
17670
|
+
* Update default values from selected invoice template
|
|
17671
|
+
*/
|
|
17443
17672
|
SoleInvoiceForm.prototype.listenTemplateChanges = function () {
|
|
17444
17673
|
var _this = this;
|
|
17445
17674
|
this.get('template').valueChanges.subscribe(function (template) {
|
|
17446
|
-
_this.
|
|
17675
|
+
_this.get('bankAccount').setValue(template.bankAccount);
|
|
17676
|
+
var dateFrom = _this.get('dateFrom').value;
|
|
17677
|
+
if (dateFrom) {
|
|
17678
|
+
_this.get('dateTo').setValue(new Date(dateFrom.getTime() + template.termTime));
|
|
17679
|
+
}
|
|
17680
|
+
// invoice.taxType is always 'No Tax' when soleDetails.isGST = false and not available for changing
|
|
17681
|
+
if (_this.soleDetailsGST) {
|
|
17682
|
+
_this.get('taxType').setValue(template.taxType);
|
|
17683
|
+
}
|
|
17684
|
+
});
|
|
17685
|
+
};
|
|
17686
|
+
/**
|
|
17687
|
+
* GST is not available for items when invoice.taxType === NONE
|
|
17688
|
+
*/
|
|
17689
|
+
SoleInvoiceForm.prototype.listenTaxTypeChanges = function () {
|
|
17690
|
+
var _this = this;
|
|
17691
|
+
this.get('taxType').valueChanges.subscribe(function (type) {
|
|
17692
|
+
_this.items.controls.forEach(function (itemForm) {
|
|
17693
|
+
var chartAccounts = itemForm.get('chartAccounts').value;
|
|
17694
|
+
// Item GST is available when invoice.taxType !== NONE ('No Tax')
|
|
17695
|
+
if (type !== exports.SoleInvoiceTaxTypeEnum.NO_TAX && (chartAccounts === null || chartAccounts === void 0 ? void 0 : chartAccounts.isGST)) {
|
|
17696
|
+
_this.enableItemGST(itemForm);
|
|
17697
|
+
return;
|
|
17698
|
+
}
|
|
17699
|
+
_this.disableItemGST(itemForm);
|
|
17700
|
+
});
|
|
17447
17701
|
});
|
|
17448
17702
|
};
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17703
|
+
/**
|
|
17704
|
+
* GST availability depends of chart accounts isGST flag
|
|
17705
|
+
*/
|
|
17706
|
+
SoleInvoiceForm.prototype.listenItemChartAccountsChanges = function (itemForm) {
|
|
17707
|
+
var _this = this;
|
|
17708
|
+
itemForm.get('chartAccounts').valueChanges.subscribe(function (chartAccounts) {
|
|
17709
|
+
// item.isGST is available only when item.chartAccounts.isGST === true, soleDetails.isGST === true and invoice.taxType !== NONE ('No Tax')
|
|
17710
|
+
if (_this.soleDetailsGST && chartAccounts.isGST && !_this.currentValue.isNoTax()) {
|
|
17711
|
+
_this.enableItemGST(itemForm);
|
|
17712
|
+
return;
|
|
17713
|
+
}
|
|
17714
|
+
_this.disableItemGST(itemForm);
|
|
17452
17715
|
});
|
|
17453
17716
|
};
|
|
17717
|
+
SoleInvoiceForm.prototype.disableItemGST = function (itemForm) {
|
|
17718
|
+
itemForm.get('isGST').setValue(false);
|
|
17719
|
+
itemForm.get('isGST').disable();
|
|
17720
|
+
};
|
|
17721
|
+
/**
|
|
17722
|
+
* Enable GST field for passed item form. Value is always true by default because only case when this field is enabled is
|
|
17723
|
+
* when ChartAccounts.isGST === true, so we just use default value from chartAccounts.isGST
|
|
17724
|
+
*/
|
|
17725
|
+
SoleInvoiceForm.prototype.enableItemGST = function (itemForm) {
|
|
17726
|
+
itemForm.get('isGST').setValue(true);
|
|
17727
|
+
itemForm.get('isGST').enable();
|
|
17728
|
+
};
|
|
17454
17729
|
return SoleInvoiceForm;
|
|
17455
17730
|
}(AbstractForm));
|
|
17456
17731
|
|
|
17457
17732
|
var SoleInvoiceTemplateForm = /** @class */ (function (_super) {
|
|
17458
17733
|
__extends(SoleInvoiceTemplateForm, _super);
|
|
17459
|
-
function SoleInvoiceTemplateForm(invoiceTemplate
|
|
17460
|
-
|
|
17734
|
+
function SoleInvoiceTemplateForm(invoiceTemplate) {
|
|
17735
|
+
return _super.call(this, {
|
|
17461
17736
|
name: new forms.FormControl(invoiceTemplate.name, forms.Validators.required),
|
|
17462
|
-
// taxType always 'No Tax' when
|
|
17463
|
-
taxType: new forms.FormControl(
|
|
17737
|
+
// taxType is always 'No Tax' when soleDetails.isGST === false
|
|
17738
|
+
taxType: new forms.FormControl(invoiceTemplate.taxType, forms.Validators.required),
|
|
17464
17739
|
term: new forms.FormControl(invoiceTemplate.term, [forms.Validators.required, forms.Validators.min(0)]),
|
|
17465
17740
|
bankAccount: new forms.FormControl(invoiceTemplate.bankAccount, [forms.Validators.required])
|
|
17466
17741
|
}, invoiceTemplate) || this;
|
|
17467
|
-
_this.soleDetails = soleDetails;
|
|
17468
|
-
return _this;
|
|
17469
17742
|
}
|
|
17470
17743
|
return SoleInvoiceTemplateForm;
|
|
17471
17744
|
}(AbstractForm));
|
|
17472
17745
|
|
|
17473
17746
|
var BankAccountAllocationForm = /** @class */ (function (_super) {
|
|
17474
17747
|
__extends(BankAccountAllocationForm, _super);
|
|
17475
|
-
function BankAccountAllocationForm(bankAccount) {
|
|
17476
|
-
var _this = _super.call(this, {
|
|
17748
|
+
function BankAccountAllocationForm(bankAccount, controls) {
|
|
17749
|
+
var _this = _super.call(this, merge__default["default"](controls, {
|
|
17477
17750
|
tankType: new forms.FormControl(bankAccount ? bankAccount.tankType : null, forms.Validators.required)
|
|
17478
|
-
}, classTransformer.plainToClass(BankAccount, bankAccount || {})) || this;
|
|
17751
|
+
}), classTransformer.plainToClass(BankAccount, bankAccount || {})) || this;
|
|
17479
17752
|
_this.bankAccount = bankAccount;
|
|
17480
17753
|
if (bankAccount === null || bankAccount === void 0 ? void 0 : bankAccount.isPropertyTank()) {
|
|
17481
17754
|
_this.addControl('bankAccountProperties', new BankAccountPropertiesForm(bankAccount.bankAccountProperties));
|
|
@@ -17535,15 +17808,19 @@
|
|
|
17535
17808
|
var BankAccountAddManualForm = /** @class */ (function (_super) {
|
|
17536
17809
|
__extends(BankAccountAddManualForm, _super);
|
|
17537
17810
|
function BankAccountAddManualForm(connection) {
|
|
17538
|
-
var _this = _super.call(this
|
|
17811
|
+
var _this = _super.call(this, null, {
|
|
17812
|
+
type: new forms.FormControl(null, forms.Validators.required),
|
|
17813
|
+
accountName: new forms.FormControl(null, forms.Validators.required),
|
|
17814
|
+
currentBalance: new forms.FormControl(null, forms.Validators.required),
|
|
17815
|
+
accountNumber: new forms.FormControl(null, [forms.Validators.required, forms.Validators.pattern(BankAccountAddManualForm.accountNumberPattern)])
|
|
17816
|
+
}) || this;
|
|
17539
17817
|
_this.connection = connection;
|
|
17540
|
-
_this.addControl('type', new forms.FormControl(null, forms.Validators.required));
|
|
17541
|
-
_this.addControl('accountName', new forms.FormControl(null, forms.Validators.required));
|
|
17542
|
-
_this.addControl('currentBalance', new forms.FormControl(null, forms.Validators.required));
|
|
17543
|
-
_this.addControl('accountNumber', new forms.FormControl(null, [forms.Validators.required, forms.Validators.pattern(BankAccountAddManualForm.accountNumberPattern)]));
|
|
17544
|
-
_this.listenTypeChanges();
|
|
17545
17818
|
return _this;
|
|
17546
17819
|
}
|
|
17820
|
+
BankAccountAddManualForm.prototype.listenEvents = function () {
|
|
17821
|
+
_super.prototype.listenEvents.call(this);
|
|
17822
|
+
this.listenTypeChanges();
|
|
17823
|
+
};
|
|
17547
17824
|
/**
|
|
17548
17825
|
* Add/Remove loan form depends on selected bank account type
|
|
17549
17826
|
*/
|
|
@@ -18620,6 +18897,7 @@
|
|
|
18620
18897
|
exports.Document = Document;
|
|
18621
18898
|
exports.DocumentFolder = DocumentFolder;
|
|
18622
18899
|
exports.DocumentFolderService = DocumentFolderService;
|
|
18900
|
+
exports.DocumentService = DocumentService;
|
|
18623
18901
|
exports.ENDPOINTS = ENDPOINTS;
|
|
18624
18902
|
exports.EmployeeCollection = EmployeeCollection;
|
|
18625
18903
|
exports.EmployeeDetails = EmployeeDetails;
|