taxtank-core 0.31.36 → 0.31.38

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.
@@ -3579,6 +3579,9 @@ class AllocationRuleTransaction extends AllocationRuleTransaction$1 {
3579
3579
  this.tax = 0;
3580
3580
  this.amount = null;
3581
3581
  }
3582
+ get amountPercentCoefficient() {
3583
+ return this.amountPercent ? this.amountPercent / 100 : 1;
3584
+ }
3582
3585
  calculateClaimPercent() {
3583
3586
  if (!this.chartAccounts) {
3584
3587
  return null;
@@ -3596,14 +3599,13 @@ class AllocationRuleTransaction extends AllocationRuleTransaction$1 {
3596
3599
  * If rule transaction has amount then split enabled. There is 0 when split disabled
3597
3600
  */
3598
3601
  isSplit() {
3599
- return !!this.amount;
3602
+ return !!this.amountPercent;
3600
3603
  }
3601
3604
  /**
3602
3605
  * Create Transaction instance based on passed bank transaction and rule transaction
3603
3606
  */
3604
3607
  toTransaction(bankTransaction) {
3605
3608
  const transaction = merge(bankTransaction.toTransaction(this.isGST), {
3606
- amount: this.amount || bankTransaction.amount,
3607
3609
  tax: this.tax,
3608
3610
  claimPercent: this.claimPercent,
3609
3611
  chartAccounts: this.chartAccounts,
@@ -3616,6 +3618,13 @@ class AllocationRuleTransaction extends AllocationRuleTransaction$1 {
3616
3618
  business: this.business,
3617
3619
  operation: TransactionOperationEnum.ALLOCATE,
3618
3620
  });
3621
+ // amount: bankTransaction.amount * (this.amountPercent ? (this.amountPercent / 100) : 1),
3622
+ if (this.amount) {
3623
+ transaction.amount = this.amount;
3624
+ }
3625
+ else if (this.amountPercent) {
3626
+ transaction.amount *= this.amountPercentCoefficient;
3627
+ }
3619
3628
  transaction.allocations = [TransactionAllocation.create(transaction.amountWithGst, bankTransaction)];
3620
3629
  return transaction;
3621
3630
  }
@@ -22779,7 +22788,8 @@ class AllocationRuleTransactionForm extends AbstractForm {
22779
22788
  // Flag to enable transaction GST field
22780
22789
  isGST) {
22781
22790
  super({
22782
- amount: new UntypedFormControl(transaction.amount, Validators.required),
22791
+ amount: new UntypedFormControl(transaction.amount),
22792
+ amountPercent: new UntypedFormControl(transaction.amountPercent, Validators.required),
22783
22793
  tax: new UntypedFormControl(transaction.tax, Validators.required),
22784
22794
  claimPercent: new UntypedFormControl(transaction.claimPercent, [Validators.required, Validators.min(0), Validators.max(100)]),
22785
22795
  chartAccounts: new UntypedFormControl(transaction.chartAccounts, Validators.required),
@@ -22808,7 +22818,7 @@ class AllocationRuleTransactionForm extends AbstractForm {
22808
22818
  return this.get('childTransactions');
22809
22819
  }
22810
22820
  get isSplit() {
22811
- return this.get('amount').enabled;
22821
+ return this.get('amountPercent').enabled;
22812
22822
  }
22813
22823
  addChildTransactionForm() {
22814
22824
  this.childTransactionsArray.push(new UntypedFormGroup({
@@ -22919,7 +22929,7 @@ class AllocationRuleForm extends AbstractForm {
22919
22929
  }
22920
22930
  // Disable transaction amount field when transaction has no amount (non-split)
22921
22931
  if (!rule.transaction?.isSplit()) {
22922
- this.transactionFormGroup.get(['amount']).disable();
22932
+ this.transactionFormGroup.get(['amountPercent']).disable();
22923
22933
  }
22924
22934
  }
22925
22935
  get conditionsArray() {
@@ -22995,6 +23005,8 @@ class AllocationRuleForm extends AbstractForm {
22995
23005
  return 'property';
22996
23006
  case TankTypeEnum.SOLE:
22997
23007
  return 'sole';
23008
+ case TankTypeEnum.HOLDING:
23009
+ return 'holding';
22998
23010
  default:
22999
23011
  return 'personal';
23000
23012
  }
@@ -23007,8 +23019,8 @@ class AllocationRuleForm extends AbstractForm {
23007
23019
  this.get('transferBankAccount').disable({ emitEvent: false });
23008
23020
  // disable transaction amount field when value is empty
23009
23021
  // disable manually because code above enables this field
23010
- if (!this.transactionFormGroup.get(['amount']).value) {
23011
- this.transactionFormGroup.get(['amount']).disable();
23022
+ if (!this.transactionFormGroup.get(['amountPercent']).value) {
23023
+ this.transactionFormGroup.get(['amountPercent']).disable();
23012
23024
  }
23013
23025
  break;
23014
23026
  case AllocationRuleTypeEnum.TRANSFER: