resolved bug in Creating Tax Components (#2367)

This commit is contained in:
Jayesh Savaliya
2025-03-28 01:52:49 -06:00
committed by GitHub
parent 8f3f803cc1
commit 9a1bfa3239
5 changed files with 17 additions and 13 deletions
@@ -44,7 +44,7 @@
[inputFormControl]="taxComponentForm.controls.debitAcountId" [inputFormControl]="taxComponentForm.controls.debitAcountId"
[glAccountList]="debitAccountData" [glAccountList]="debitAccountData"
[required]="false" [required]="false"
[inputLabel]="'Credit Account'" [inputLabel]="'Debit Account'"
> >
</mifosx-gl-account-selector> </mifosx-gl-account-selector>
@@ -113,15 +113,15 @@ export class CreateTaxComponentComponent implements OnInit {
getAccountsData(accountTypeId: number) { getAccountsData(accountTypeId: number) {
switch (accountTypeId) { switch (accountTypeId) {
case 1: case 1:
return this.taxComponentTemplateData.glAccountOptions.assetAccountOptions; return this.taxComponentTemplateData.glAccountOptions.assetAccountOptions || [];
case 2: case 2:
return this.taxComponentTemplateData.glAccountOptions.liabilityAccountOptions; return this.taxComponentTemplateData.glAccountOptions.liabilityAccountOptions || [];
case 3: case 3:
return this.taxComponentTemplateData.glAccountOptions.equityAccountOptions; return this.taxComponentTemplateData.glAccountOptions.equityAccountOptions || [];
case 4: case 4:
return this.taxComponentTemplateData.glAccountOptions.incomeAccountOptions; return this.taxComponentTemplateData.glAccountOptions.incomeAccountOptions || [];
case 5: case 5:
return this.taxComponentTemplateData.glAccountOptions.expenseAccountOptions; return this.taxComponentTemplateData.glAccountOptions.expenseAccountOptions || [];
} }
} }
@@ -21,12 +21,12 @@
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="taxComponentData.creditAccountType.value"> <mat-form-field *ngIf="taxComponentData?.creditAccountType?.value">
<mat-label>{{ 'labels.inputs.Credit Account Type' | translate }}</mat-label> <mat-label>{{ 'labels.inputs.Credit Account Type' | translate }}</mat-label>
<input matInput formControlName="creditAccountType" /> <input matInput formControlName="creditAccountType" />
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="taxComponentData.creditAccount.name"> <mat-form-field *ngIf="taxComponentData?.creditAccount?.name">
<mat-label>{{ 'labels.inputs.Credit Account' | translate }}</mat-label> <mat-label>{{ 'labels.inputs.Credit Account' | translate }}</mat-label>
<input matInput formControlName="creditAccount" /> <input matInput formControlName="creditAccount" />
</mat-form-field> </mat-form-field>
@@ -63,6 +63,12 @@ export class EditTaxComponentComponent implements OnInit {
* Edit tax component form. * Edit tax component form.
*/ */
editTaxComponent() { editTaxComponent() {
const creditAccountTypeValue = this.taxComponentData?.creditAccountType?.value
? this.translateService.instant(`labels.inputs.accounting.${this.taxComponentData.creditAccountType.value}`)
: null;
const creditAccountName = this.taxComponentData?.creditAccount?.name ?? null;
this.taxComponentForm = this.formBuilder.group({ this.taxComponentForm = this.formBuilder.group({
name: [ name: [
this.taxComponentData.name, this.taxComponentData.name,
@@ -78,13 +84,11 @@ export class EditTaxComponentComponent implements OnInit {
startDate: [this.taxComponentData.startDate && new Date(this.taxComponentData.startDate)], startDate: [this.taxComponentData.startDate && new Date(this.taxComponentData.startDate)],
creditAccountType: [ creditAccountType: [
{ {
value: this.translateService.instant( value: creditAccountTypeValue,
'labels.inputs.accounting.' + this.taxComponentData.creditAccountType.value
),
disabled: true disabled: true
} }
], ],
creditAccount: [{ value: this.taxComponentData.creditAccount.name, disabled: true }] creditAccount: [{ value: creditAccountName, disabled: true }]
}); });
} }
@@ -33,7 +33,7 @@
<ng-container matColumnDef="glAccount"> <ng-container matColumnDef="glAccount">
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Account' | translate }}</th> <th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Account' | translate }}</th>
<td mat-cell *matCellDef="let taxComponent"> <td mat-cell *matCellDef="let taxComponent">
({{ taxComponent.creditAccount.glCode }}) {{ taxComponent.creditAccount.name }} ({{ taxComponent.creditAccount?.glCode || '' }}) {{ taxComponent.creditAccount?.name || '' }}
</td> </td>
</ng-container> </ng-container>