taxtank-core 0.30.27 → 0.30.29
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/forms/transaction/allocation-rule-transaction.form.mjs +3 -2
- package/esm2020/lib/forms/transaction/work/work-transaction.form.mjs +3 -1
- package/esm2020/lib/models/chart-accounts/chart-accounts.mjs +4 -1
- package/esm2020/lib/validators/transactions-meta-fields.validator.mjs +34 -0
- package/fesm2015/taxtank-core.mjs +38 -0
- package/fesm2015/taxtank-core.mjs.map +1 -1
- package/fesm2020/taxtank-core.mjs +38 -0
- package/fesm2020/taxtank-core.mjs.map +1 -1
- package/lib/models/chart-accounts/chart-accounts.d.ts +1 -0
- package/lib/validators/transactions-meta-fields.validator.d.ts +5 -0
- package/package.json +1 -1
|
@@ -3077,6 +3077,9 @@ class ChartAccounts extends ChartAccounts$1 {
|
|
|
3077
3077
|
isTransfer() {
|
|
3078
3078
|
return this.id === ChartAccountsListEnum.TRANSFER;
|
|
3079
3079
|
}
|
|
3080
|
+
isDividends() {
|
|
3081
|
+
return this.id === ChartAccountsListEnum.DIVIDENDS;
|
|
3082
|
+
}
|
|
3080
3083
|
}
|
|
3081
3084
|
/**
|
|
3082
3085
|
* Australian GST percent value (VAT)
|
|
@@ -19197,6 +19200,7 @@ class AllocationRuleTransactionForm extends AbstractForm {
|
|
|
19197
19200
|
*/
|
|
19198
19201
|
listenTankTypeChanges() {
|
|
19199
19202
|
this.get('tankType').valueChanges.subscribe(() => {
|
|
19203
|
+
this.get('chartAccounts').reset();
|
|
19200
19204
|
this.childTransactionsArray.reset();
|
|
19201
19205
|
});
|
|
19202
19206
|
}
|
|
@@ -19527,6 +19531,39 @@ class TransactionForm extends TransactionBaseForm {
|
|
|
19527
19531
|
}
|
|
19528
19532
|
}
|
|
19529
19533
|
|
|
19534
|
+
/**
|
|
19535
|
+
* Validator that check fields for transaction meta
|
|
19536
|
+
*/
|
|
19537
|
+
function transactionsMetaFieldsValidator() {
|
|
19538
|
+
return (formGroup) => {
|
|
19539
|
+
const chartAccounts = formGroup.get('chartAccounts').value;
|
|
19540
|
+
if (!chartAccounts) {
|
|
19541
|
+
return null;
|
|
19542
|
+
}
|
|
19543
|
+
const metaFields = chartAccounts.metaFields;
|
|
19544
|
+
if (chartAccounts.isDividends()) {
|
|
19545
|
+
return checkDividends(metaFields, formGroup);
|
|
19546
|
+
}
|
|
19547
|
+
return null;
|
|
19548
|
+
};
|
|
19549
|
+
}
|
|
19550
|
+
/**
|
|
19551
|
+
* the sum of the fields "Franked" and "Unfranked" must equal transactions amount
|
|
19552
|
+
*/
|
|
19553
|
+
function checkDividends(metaFields, formGroup) {
|
|
19554
|
+
const frankedAndUnfrankedIds = [ChartAccountsMetaFieldListEnum.FRANKED, ChartAccountsMetaFieldListEnum.UNFRANKED];
|
|
19555
|
+
const amount = Math.abs(formGroup.get('amount').value);
|
|
19556
|
+
const frankedAndUnfrankedControls = (formGroup.get('metaFields')).controls
|
|
19557
|
+
.filter((control) => frankedAndUnfrankedIds.includes(control.get('chartAccountsMetaField').value.id));
|
|
19558
|
+
const frankedAndUnfrankedAmount = frankedAndUnfrankedControls.reduce((sum, control) => sum + (+control.get('value').value), 0);
|
|
19559
|
+
for (let control of frankedAndUnfrankedControls) {
|
|
19560
|
+
if (control.get('value').value !== null && frankedAndUnfrankedAmount !== amount) {
|
|
19561
|
+
return { metaFields: `Field ${control.get('chartAccountsMetaField').value.label} is required` };
|
|
19562
|
+
}
|
|
19563
|
+
}
|
|
19564
|
+
return amount === frankedAndUnfrankedAmount ? null : { metaFields: 'Please enter the franked and/or unfranked amounts.' };
|
|
19565
|
+
}
|
|
19566
|
+
|
|
19530
19567
|
class WorkTransactionForm extends TransactionForm {
|
|
19531
19568
|
constructor(transaction, registeredForGst, allocations, controls = {}) {
|
|
19532
19569
|
super(transaction, registeredForGst, allocations, Object.assign(controls, {
|
|
@@ -19538,6 +19575,7 @@ class WorkTransactionForm extends TransactionForm {
|
|
|
19538
19575
|
});
|
|
19539
19576
|
}))
|
|
19540
19577
|
}));
|
|
19578
|
+
this.setValidators(transactionsMetaFieldsValidator());
|
|
19541
19579
|
this.listenEvents();
|
|
19542
19580
|
}
|
|
19543
19581
|
listenEvents() {
|