taxtank-core 0.30.3 → 0.30.5
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/esm2020/lib/db-static/chart-accounts/chart-accounts-values.mjs +4 -1
- package/esm2020/lib/forms/abstract.form.mjs +6 -1
- package/esm2020/lib/forms/sole/sole-invoice.form.mjs +3 -3
- package/esm2020/lib/forms/transaction/work/work-expense.form.mjs +9 -2
- package/esm2020/lib/forms/transaction/work/work-transaction.form.mjs +1 -2
- package/esm2020/lib/models/chart-accounts/chart-accounts.mjs +5 -11
- package/esm2020/lib/services/http/income-source/income-source.service.mjs +2 -2
- package/esm2020/lib/services/http/rest/rest-old.service.mjs +14 -24
- package/esm2020/lib/services/http/rest/rest.service.mjs +16 -16
- package/esm2020/lib/services/http/transaction/transaction.service.mjs +11 -12
- package/esm2020/lib/services/pdf/js-pdf.mjs +3 -1
- package/esm2020/lib/services/pdf/pdf-from-dom-element/pdf-from-dom-element.service.mjs +2 -2
- package/esm2020/lib/services/pdf/pdf-from-table/pdf-from-table.service.mjs +1 -1
- package/fesm2015/taxtank-core.mjs +58 -60
- package/fesm2015/taxtank-core.mjs.map +1 -1
- package/fesm2020/taxtank-core.mjs +58 -60
- package/fesm2020/taxtank-core.mjs.map +1 -1
- package/lib/db-static/chart-accounts/chart-accounts-values.d.ts +3 -0
- package/lib/forms/abstract.form.d.ts +5 -1
- package/lib/forms/transaction/work/work-expense.form.d.ts +5 -0
- package/lib/services/http/rest/rest-old.service.d.ts +6 -14
- package/lib/services/http/rest/rest.service.d.ts +3 -3
- package/lib/services/http/transaction/transaction.service.d.ts +1 -1
- package/lib/services/pdf/pdf-from-table/pdf-from-table.service.d.ts +4 -4
- package/package.json +1 -1
|
@@ -33,7 +33,8 @@ import merge from 'lodash/merge';
|
|
|
33
33
|
import { loadStripe } from '@stripe/stripe-js';
|
|
34
34
|
import fromPairs from 'lodash/fromPairs';
|
|
35
35
|
import { jsPDF } from 'jspdf';
|
|
36
|
-
import
|
|
36
|
+
import { applyPlugin } from 'jspdf-autotable';
|
|
37
|
+
import { html2pdf } from 'html2pdf.js';
|
|
37
38
|
import isEqual from 'lodash/isEqual';
|
|
38
39
|
import * as xlsx from 'xlsx';
|
|
39
40
|
import * as FileSaver from 'file-saver';
|
|
@@ -2802,13 +2803,12 @@ var ChartAccountValues = [
|
|
|
2802
2803
|
}
|
|
2803
2804
|
];
|
|
2804
2805
|
|
|
2806
|
+
/**
|
|
2807
|
+
* @TODO vik performance problems, try https://angular.io/guide/dependency-injection-providers?
|
|
2808
|
+
*/
|
|
2805
2809
|
const CHART_ACCOUNTS_VALUES = new CollectionDictionary(new Collection(ChartAccountValues.map((value) => plainToClass(ChartAccountsValue$1, value))), 'chartAccounts.id');
|
|
2806
2810
|
|
|
2807
2811
|
class ChartAccounts extends ChartAccounts$1 {
|
|
2808
|
-
constructor() {
|
|
2809
|
-
super(...arguments);
|
|
2810
|
-
this.values = [];
|
|
2811
|
-
}
|
|
2812
2812
|
/**
|
|
2813
2813
|
* Return name as string
|
|
2814
2814
|
*/
|
|
@@ -2942,7 +2942,6 @@ class ChartAccounts extends ChartAccounts$1 {
|
|
|
2942
2942
|
* Get chart accounts value for current financial year
|
|
2943
2943
|
*/
|
|
2944
2944
|
getCurrentYearValue() {
|
|
2945
|
-
console.log(this);
|
|
2946
2945
|
return this.getValueByYear(new FinancialYear().year);
|
|
2947
2946
|
}
|
|
2948
2947
|
/**
|
|
@@ -3012,10 +3011,9 @@ __decorate([
|
|
|
3012
3011
|
], ChartAccounts.prototype, "metadata", void 0);
|
|
3013
3012
|
__decorate([
|
|
3014
3013
|
Type(() => ChartAccountsValue),
|
|
3015
|
-
Transform(({ obj }) => {
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
}, { toClassOnly: true })
|
|
3014
|
+
Transform(({ obj }) => CHART_ACCOUNTS_VALUES.get(obj.id).toArray(), { toClassOnly: true }),
|
|
3015
|
+
Transform(() => null, { toPlainOnly: true }),
|
|
3016
|
+
Expose()
|
|
3019
3017
|
], ChartAccounts.prototype, "values", void 0);
|
|
3020
3018
|
|
|
3021
3019
|
class ChartAccountsDepreciation extends ChartAccountsDepreciation$1 {
|
|
@@ -8505,9 +8503,9 @@ let RestService$1 = class RestService {
|
|
|
8505
8503
|
*/
|
|
8506
8504
|
post(model) {
|
|
8507
8505
|
this.handleAccessError('post');
|
|
8508
|
-
return this.http.post(this.apiUrl, model)
|
|
8506
|
+
return this.http.post(this.apiUrl, classToPlain(model))
|
|
8509
8507
|
.pipe(map((response) => {
|
|
8510
|
-
const result = this.createModelInstance(
|
|
8508
|
+
const result = this.createModelInstance(response);
|
|
8511
8509
|
this.handleResponse([result], 'post');
|
|
8512
8510
|
return result;
|
|
8513
8511
|
}));
|
|
@@ -8517,9 +8515,9 @@ let RestService$1 = class RestService {
|
|
|
8517
8515
|
*/
|
|
8518
8516
|
postBatch(models) {
|
|
8519
8517
|
this.handleAccessError('postBatch');
|
|
8520
|
-
return this.http.post(this.apiUrl, models)
|
|
8518
|
+
return this.http.post(this.apiUrl, classToPlain(models))
|
|
8521
8519
|
.pipe(map((response) => {
|
|
8522
|
-
const result = response.map((item) => this.createModelInstance(
|
|
8520
|
+
const result = response.map((item) => this.createModelInstance(item));
|
|
8523
8521
|
this.handleResponse(result, 'post');
|
|
8524
8522
|
return result;
|
|
8525
8523
|
}));
|
|
@@ -8529,9 +8527,9 @@ let RestService$1 = class RestService {
|
|
|
8529
8527
|
*/
|
|
8530
8528
|
put(model) {
|
|
8531
8529
|
this.handleAccessError('put');
|
|
8532
|
-
return this.http.put(`${this.apiUrl}/${model.id}`, model)
|
|
8530
|
+
return this.http.put(`${this.apiUrl}/${model.id}`, classToPlain(model))
|
|
8533
8531
|
.pipe(map((response) => {
|
|
8534
|
-
const result = this.createModelInstance(
|
|
8532
|
+
const result = this.createModelInstance(response);
|
|
8535
8533
|
this.handleResponse([result], 'put');
|
|
8536
8534
|
return result;
|
|
8537
8535
|
}));
|
|
@@ -8541,9 +8539,9 @@ let RestService$1 = class RestService {
|
|
|
8541
8539
|
*/
|
|
8542
8540
|
putBatch(models) {
|
|
8543
8541
|
this.handleAccessError('putBatch');
|
|
8544
|
-
return this.http.put(this.apiUrl, models)
|
|
8542
|
+
return this.http.put(this.apiUrl, classToPlain(models))
|
|
8545
8543
|
.pipe(map((response) => {
|
|
8546
|
-
const result = response.map((item) => this.createModelInstance(
|
|
8544
|
+
const result = response.map((item) => this.createModelInstance(item));
|
|
8547
8545
|
this.handleResponse(result, 'put');
|
|
8548
8546
|
return result;
|
|
8549
8547
|
}));
|
|
@@ -8563,7 +8561,7 @@ let RestService$1 = class RestService {
|
|
|
8563
8561
|
*/
|
|
8564
8562
|
deleteBatch(models) {
|
|
8565
8563
|
this.handleAccessError('deleteBatch');
|
|
8566
|
-
return this.http.post(`${this.apiUrl}/delete`, models)
|
|
8564
|
+
return this.http.post(`${this.apiUrl}/delete`, classToPlain(models))
|
|
8567
8565
|
.pipe(map(() => {
|
|
8568
8566
|
this.handleResponse(models, 'delete');
|
|
8569
8567
|
}));
|
|
@@ -8580,7 +8578,7 @@ let RestService$1 = class RestService {
|
|
|
8580
8578
|
fetch() {
|
|
8581
8579
|
return this.http.get(this.apiUrl)
|
|
8582
8580
|
.pipe(map((response) => this.isApiPlatform ? response['hydra:member'] : toArray(response)), map((response) => {
|
|
8583
|
-
const items = response.map((item) => this.createModelInstance(
|
|
8581
|
+
const items = response.map((item) => this.createModelInstance(item));
|
|
8584
8582
|
this.cache = this.createCollectionInstance(this.collectionClass, items);
|
|
8585
8583
|
this.cacheSubject.next(this.cache);
|
|
8586
8584
|
return this.cache;
|
|
@@ -8628,13 +8626,13 @@ let RestService$1 = class RestService {
|
|
|
8628
8626
|
this.eventDispatcherService.dispatch2(new AppEvent2(eventName, items));
|
|
8629
8627
|
}
|
|
8630
8628
|
/**
|
|
8629
|
+
* @TODO use excludeExtraneousValues when all models refactored (exposed all needed properties)
|
|
8631
8630
|
* Create new instance of class
|
|
8632
|
-
* @param model
|
|
8633
|
-
* @param plain Single object or array from which will be created model instance(s)
|
|
8631
|
+
* @param model Single object or array from which will be created model instance(s)
|
|
8634
8632
|
*/
|
|
8635
|
-
createModelInstance(model
|
|
8633
|
+
createModelInstance(model) {
|
|
8636
8634
|
// excludePrefixes - class-transformer option is using to ignore hydra fields
|
|
8637
|
-
return plainToClass(
|
|
8635
|
+
return plainToClass(this.modelClass, model, { excludePrefixes: ['@'] });
|
|
8638
8636
|
}
|
|
8639
8637
|
createCollectionInstance(collectionClass, items) {
|
|
8640
8638
|
return new collectionClass(items);
|
|
@@ -11910,12 +11908,12 @@ class RestService {
|
|
|
11910
11908
|
* add new instance and update cache
|
|
11911
11909
|
*/
|
|
11912
11910
|
create(data, shouldUpdateCache = true) {
|
|
11913
|
-
return this.http.post(`${this.environment.apiV2}/${this.url}`, data)
|
|
11911
|
+
return this.http.post(`${this.environment.apiV2}/${this.url}`, classToPlain(data))
|
|
11914
11912
|
.pipe(map((newItem) => {
|
|
11915
11913
|
if (!shouldUpdateCache) {
|
|
11916
11914
|
return null;
|
|
11917
11915
|
}
|
|
11918
|
-
const newInstance = this.createModelInstance(
|
|
11916
|
+
const newInstance = this.createModelInstance(newItem);
|
|
11919
11917
|
if (this.cache) {
|
|
11920
11918
|
this.cache.push(newInstance);
|
|
11921
11919
|
this.updateCache();
|
|
@@ -11952,7 +11950,7 @@ class RestService {
|
|
|
11952
11950
|
addBatch(models, queryParams = {}) {
|
|
11953
11951
|
return this.http.post(`${this.environment.apiV2}/${this.url}`, classToPlain(models), queryParams)
|
|
11954
11952
|
.pipe(map((newItems) => {
|
|
11955
|
-
const newInstances = newItems.map((item) => this.createModelInstance(
|
|
11953
|
+
const newInstances = newItems.map((item) => this.createModelInstance(item));
|
|
11956
11954
|
if (this.cache) {
|
|
11957
11955
|
this.cache.push(...newInstances);
|
|
11958
11956
|
this.updateCache();
|
|
@@ -11972,7 +11970,7 @@ class RestService {
|
|
|
11972
11970
|
update(model, queryParams = {}) {
|
|
11973
11971
|
return this.http.put(`${this.environment.apiV2}/${this.url}/${model['id']}`, classToPlain(model), queryParams)
|
|
11974
11972
|
.pipe(map((updatedItem) => {
|
|
11975
|
-
const updatedInstance = this.createModelInstance(
|
|
11973
|
+
const updatedInstance = this.createModelInstance(updatedItem);
|
|
11976
11974
|
replace(this.cache, updatedInstance);
|
|
11977
11975
|
this.updateCache();
|
|
11978
11976
|
if (this.messageUpdated) {
|
|
@@ -11990,7 +11988,7 @@ class RestService {
|
|
|
11990
11988
|
updateBatch(models, queryParams = {}) {
|
|
11991
11989
|
return this.http.put(`${this.environment.apiV2}/${this.url}`, classToPlain(models), queryParams)
|
|
11992
11990
|
.pipe(map((updatedItems) => {
|
|
11993
|
-
const updatedInstances = updatedItems.map((item) => this.createModelInstance(
|
|
11991
|
+
const updatedInstances = updatedItems.map((item) => this.createModelInstance(item));
|
|
11994
11992
|
updatedInstances.forEach((instance) => {
|
|
11995
11993
|
replace(this.cache, instance);
|
|
11996
11994
|
});
|
|
@@ -12020,7 +12018,7 @@ class RestService {
|
|
|
12020
12018
|
* @param models Class instances array for deleting
|
|
12021
12019
|
*/
|
|
12022
12020
|
deleteBatch(models) {
|
|
12023
|
-
return this.http.post(`${this.environment.apiV2}/${this.url}/delete`, models)
|
|
12021
|
+
return this.http.post(`${this.environment.apiV2}/${this.url}/delete`, classToPlain(models))
|
|
12024
12022
|
.pipe(map(() => {
|
|
12025
12023
|
const ids = models.map((model) => model['id']);
|
|
12026
12024
|
this.cache = this.cache.filter((item) => !ids.includes(item['id']));
|
|
@@ -12044,7 +12042,7 @@ class RestService {
|
|
|
12044
12042
|
.pipe(map((response) => {
|
|
12045
12043
|
const items = (this.isHydra ? response['hydra:member'] : response)
|
|
12046
12044
|
.map((item) => {
|
|
12047
|
-
return this.createModelInstance(
|
|
12045
|
+
return this.createModelInstance(item);
|
|
12048
12046
|
});
|
|
12049
12047
|
this.cache = items;
|
|
12050
12048
|
this.updateCache();
|
|
@@ -12058,22 +12056,12 @@ class RestService {
|
|
|
12058
12056
|
this.cacheSubject.next(this.cache.slice());
|
|
12059
12057
|
}
|
|
12060
12058
|
/**
|
|
12059
|
+
* @TODO use excludeExtraneousValues when all models refactored (exposed all needed properties)
|
|
12061
12060
|
* Create new instance of class
|
|
12062
|
-
* @param model
|
|
12063
|
-
* @param baseModel base model instance that we will use as constructor options
|
|
12064
|
-
* @param data additional data
|
|
12065
|
-
*/
|
|
12066
|
-
createModelInstance(model, baseModel, data = {}) {
|
|
12067
|
-
return plainToClass(model, Object.assign(data, baseModel), { excludePrefixes: ['@'] });
|
|
12068
|
-
}
|
|
12069
|
-
/**
|
|
12070
|
-
* @TODO Alex is there any point to pass model param instead of this.modelClass?
|
|
12071
|
-
* Create new instance of class
|
|
12072
|
-
* @param baseModel base model instance that we will use as constructor options
|
|
12073
|
-
* @param data additional data
|
|
12061
|
+
* @param model instance that we will use as constructor options
|
|
12074
12062
|
*/
|
|
12075
|
-
|
|
12076
|
-
return plainToClass(this.modelClass,
|
|
12063
|
+
createModelInstance(model) {
|
|
12064
|
+
return plainToClass(this.modelClass, model, { excludePrefixes: ['@'] });
|
|
12077
12065
|
}
|
|
12078
12066
|
/**
|
|
12079
12067
|
* Method that call all listeners. Empty by default. Should be redefined by child services if required
|
|
@@ -12943,7 +12931,7 @@ class IncomeSourceService extends RestService {
|
|
|
12943
12931
|
updateBatch(incomeSources, queryParams = {}) {
|
|
12944
12932
|
return this.http.put(`${this.environment.apiV2}/${this.url}`, incomeSources, queryParams)
|
|
12945
12933
|
.pipe(map((updatedItems) => {
|
|
12946
|
-
const updatedInstances = updatedItems.map((item) => this.createModelInstance(
|
|
12934
|
+
const updatedInstances = updatedItems.map((item) => this.createModelInstance(item));
|
|
12947
12935
|
updatedInstances.forEach((instance) => {
|
|
12948
12936
|
replace(this.cache, instance);
|
|
12949
12937
|
});
|
|
@@ -14426,9 +14414,9 @@ class TransactionService extends RestService {
|
|
|
14426
14414
|
*/
|
|
14427
14415
|
addBatch(transactions) {
|
|
14428
14416
|
transactions = _.cloneDeep(transactions);
|
|
14429
|
-
return this.http.post(`${this.environment.apiV2}/${this.url}`, transactions)
|
|
14417
|
+
return this.http.post(`${this.environment.apiV2}/${this.url}`, classToPlain(transactions))
|
|
14430
14418
|
.pipe(map((response) => {
|
|
14431
|
-
const addedTransactions = response.map((item) => this.
|
|
14419
|
+
const addedTransactions = response.map((item) => this.createModelInstance(item));
|
|
14432
14420
|
transactions.forEach((transaction, index) => {
|
|
14433
14421
|
// @TODO backend: need to upload file in the same backend endpoint with transaction add/update
|
|
14434
14422
|
// check if passed receipt and upload file
|
|
@@ -14441,7 +14429,7 @@ class TransactionService extends RestService {
|
|
|
14441
14429
|
// add child transactions if exist
|
|
14442
14430
|
if (transaction.transactions.length) {
|
|
14443
14431
|
transaction.transactions.forEach((childTransaction) => {
|
|
14444
|
-
childTransaction.parentTransaction = this.
|
|
14432
|
+
childTransaction.parentTransaction = this.createModelInstance({ id: addedTransactions[index].id });
|
|
14445
14433
|
});
|
|
14446
14434
|
this.addBatch(transaction.transactions).subscribe();
|
|
14447
14435
|
}
|
|
@@ -14463,9 +14451,9 @@ class TransactionService extends RestService {
|
|
|
14463
14451
|
* @param transaction Transaction instance for updating
|
|
14464
14452
|
*/
|
|
14465
14453
|
update(transaction) {
|
|
14466
|
-
return this.http.put(`${this.environment.apiV2}/${this.url}/${transaction.id}`, transaction)
|
|
14454
|
+
return this.http.put(`${this.environment.apiV2}/${this.url}/${transaction.id}`, classToPlain(transaction))
|
|
14467
14455
|
.pipe(map((response) => {
|
|
14468
|
-
const updatedTransaction = this.
|
|
14456
|
+
const updatedTransaction = this.createModelInstance(response);
|
|
14469
14457
|
// @TODO need to upload file in the same backend endpoint with transaction add/update
|
|
14470
14458
|
// check if passed new receipt and upload file
|
|
14471
14459
|
if (transaction.file) {
|
|
@@ -14480,7 +14468,7 @@ class TransactionService extends RestService {
|
|
|
14480
14468
|
if (transaction.transactions.length) {
|
|
14481
14469
|
// add parent transaction to child transactions
|
|
14482
14470
|
transaction.transactions.forEach((childTransaction) => {
|
|
14483
|
-
childTransaction.parentTransaction = this.
|
|
14471
|
+
childTransaction.parentTransaction = this.createModelInstance({ id: updatedTransaction.id });
|
|
14484
14472
|
});
|
|
14485
14473
|
// separate child transactions by id existing to define add or update action.
|
|
14486
14474
|
const childTransactionsToUpdate = transaction.transactions.filter((t) => t.id);
|
|
@@ -14503,9 +14491,9 @@ class TransactionService extends RestService {
|
|
|
14503
14491
|
* @param transactions list of transactions for updating
|
|
14504
14492
|
*/
|
|
14505
14493
|
updateBatch(transactions) {
|
|
14506
|
-
return this.http.put(`${this.environment.apiV2}/${this.url}`, transactions)
|
|
14494
|
+
return this.http.put(`${this.environment.apiV2}/${this.url}`, classToPlain(transactions))
|
|
14507
14495
|
.pipe(map((response) => {
|
|
14508
|
-
const updatedTransactions = response.map((item) => this.
|
|
14496
|
+
const updatedTransactions = response.map((item) => this.createModelInstance(item));
|
|
14509
14497
|
updatedTransactions.forEach((updatedTransaction) => {
|
|
14510
14498
|
replace(this.cache, updatedTransaction);
|
|
14511
14499
|
});
|
|
@@ -14543,6 +14531,7 @@ class TransactionService extends RestService {
|
|
|
14543
14531
|
}));
|
|
14544
14532
|
}
|
|
14545
14533
|
/**
|
|
14534
|
+
* @TODO Alex wrong place for this logic, move to model
|
|
14546
14535
|
* calculate gross income amount based on transaction amount and taxes (fees)
|
|
14547
14536
|
* @param transaction Transaction instance for calculation
|
|
14548
14537
|
*/
|
|
@@ -14620,9 +14609,6 @@ class TransactionService extends RestService {
|
|
|
14620
14609
|
this.resetCache();
|
|
14621
14610
|
});
|
|
14622
14611
|
}
|
|
14623
|
-
createModelInstance2(baseModel, data = {}) {
|
|
14624
|
-
return super.createModelInstance2(baseModel, { values: [] });
|
|
14625
|
-
}
|
|
14626
14612
|
}
|
|
14627
14613
|
TransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: TransactionService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }, { token: TransactionReceiptService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
14628
14614
|
TransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: TransactionService, providedIn: 'root' });
|
|
@@ -15431,6 +15417,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImpor
|
|
|
15431
15417
|
args: ['environment']
|
|
15432
15418
|
}] }]; } });
|
|
15433
15419
|
|
|
15420
|
+
applyPlugin(jsPDF);
|
|
15434
15421
|
/**
|
|
15435
15422
|
* jspdf-autotable is a plugin, adding table functionality to jspdf object without new class,
|
|
15436
15423
|
* we need to let ts knows about that by defining an interface and extending jsPdf class (to avoid ts error)
|
|
@@ -16193,6 +16180,7 @@ class AbstractForm extends UntypedFormGroup {
|
|
|
16193
16180
|
this.unsaved = false;
|
|
16194
16181
|
this.onSubmit = new EventEmitter();
|
|
16195
16182
|
this.model = model || this.createModelInstance();
|
|
16183
|
+
// @TODO Alex no idea how it works, since modelClass used in createModelInstance
|
|
16196
16184
|
this.modelClass = this.model.constructor;
|
|
16197
16185
|
this.initialValue = this.value;
|
|
16198
16186
|
if (model && !model['id']) {
|
|
@@ -16233,6 +16221,10 @@ class AbstractForm extends UntypedFormGroup {
|
|
|
16233
16221
|
markAsSaved() {
|
|
16234
16222
|
this.unsaved = false;
|
|
16235
16223
|
}
|
|
16224
|
+
/**
|
|
16225
|
+
* @TODO use excludeExtraneousValues when all models refactored (exposed all needed properties)
|
|
16226
|
+
* @param data
|
|
16227
|
+
*/
|
|
16236
16228
|
createModelInstance(data = {}) {
|
|
16237
16229
|
return plainToClass(this.modelClass, data);
|
|
16238
16230
|
}
|
|
@@ -17101,7 +17093,7 @@ class SoleInvoiceForm extends AbstractForm {
|
|
|
17101
17093
|
*/
|
|
17102
17094
|
get currentValue() {
|
|
17103
17095
|
const formRawValue = this.getRawValue();
|
|
17104
|
-
return
|
|
17096
|
+
return this.createModelInstance(Object.assign({}, this.model, { ...formRawValue.commonData, items: formRawValue.items }));
|
|
17105
17097
|
}
|
|
17106
17098
|
}
|
|
17107
17099
|
|
|
@@ -18492,7 +18484,6 @@ class TransactionForm extends TransactionBaseForm {
|
|
|
18492
18484
|
|
|
18493
18485
|
class WorkTransactionForm extends TransactionForm {
|
|
18494
18486
|
constructor(transaction, registeredForGst, allocations, controls = {}) {
|
|
18495
|
-
console.log(transaction);
|
|
18496
18487
|
super(transaction, registeredForGst, allocations, Object.assign(controls, {
|
|
18497
18488
|
// additional data related to work (like tax instalments)
|
|
18498
18489
|
metadata: new FormArray((transaction.metadata || []).map((transactionMetadata) => {
|
|
@@ -18610,6 +18601,13 @@ class WorkIncomeForm extends WorkTransactionForm {
|
|
|
18610
18601
|
}
|
|
18611
18602
|
|
|
18612
18603
|
class WorkExpenseForm extends WorkTransactionForm {
|
|
18604
|
+
constructor(transaction, registeredForGst, allocations, controls = {}) {
|
|
18605
|
+
super(transaction, registeredForGst, allocations, controls);
|
|
18606
|
+
// amount set automatically for chartAccounts with hours metadata
|
|
18607
|
+
if (transaction.getMetadataFieldValue(ChartAccountsMetadataListEnum.HOURS)) {
|
|
18608
|
+
this.get('amount').disable();
|
|
18609
|
+
}
|
|
18610
|
+
}
|
|
18613
18611
|
listenEvents() {
|
|
18614
18612
|
this.watchChartAccountsMetadata();
|
|
18615
18613
|
}
|
|
@@ -18622,7 +18620,7 @@ class WorkExpenseForm extends WorkTransactionForm {
|
|
|
18622
18620
|
// for home office hours expense amount is a fixed rate per hour
|
|
18623
18621
|
this.get('amount').reset();
|
|
18624
18622
|
this.get('amount').disable();
|
|
18625
|
-
this.get('amount').setValue(this.get('chartAccounts').value.getCurrentYearValue().value * +hoursMetadata.value);
|
|
18623
|
+
this.get('amount').setValue((this.get('chartAccounts').value.getCurrentYearValue().value * +hoursMetadata.value).toFixed(2));
|
|
18626
18624
|
});
|
|
18627
18625
|
}
|
|
18628
18626
|
}
|