Fixed Recurring Deposit views

This commit is contained in:
Jose Alberto Hernandez
2023-12-13 10:55:01 +01:00
committed by Adam Saghy
parent 927562a872
commit 9766644fb8
21 changed files with 82 additions and 179 deletions
@@ -3,8 +3,7 @@
<mat-form-field fxFlex="48%">
<mat-label>{{"labels.inputs.Charge" | translate }}</mat-label>
<mat-select #charge>
<mat-option *ngFor="let charge of chargeData | chargesFilter:chargesDataSource:currencyCode.value"
[value]="charge">
<mat-option *ngFor="let charge of chargeData" [value]="charge">
{{ charge.name }}
</mat-option>
</mat-select>
@@ -13,6 +13,7 @@ import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
import { Charge, Currency } from 'app/shared/models/general.model';
/**
* Recurring Deposit Account Charges Step
@@ -39,6 +40,8 @@ export class RecurringDepositsAccountChargesStepComponent implements OnInit, OnC
pristine = true;
/** For Edit Recurring Deposits Account Form */
isChargesPatched = false;
/** Currency Code */
currency: Currency | null = null;
constructor(public dialog: MatDialog,
private dateUtils: Dates,
@@ -46,19 +49,23 @@ export class RecurringDepositsAccountChargesStepComponent implements OnInit, OnC
}
ngOnInit() {
this.currencyCode.valueChanges.subscribe(() => {
if (!this.isChargesPatched && this.recurringDepositsAccountTemplate.charges) {
this.chargesDataSource = this.recurringDepositsAccountTemplate.charges.map((charge: any) => ({ ...charge, id: charge.chargeId })) || [];
this.isChargesPatched = true;
} else {
this.chargesDataSource = [];
}
});
this.chargesDataSource = [];
if (this.recurringDepositsAccountTemplate.id && this.recurringDepositsAccountTemplate.charges) {
this.chargesDataSource = this.recurringDepositsAccountTemplate.charges.map((charge: any) => ({...charge, id: charge.chargeId})) || [];
}
}
ngOnChanges() {
if (this.currency == null) {
if (this.recurringDepositsAccountTemplate.currency) {
this.currency = this.recurringDepositsAccountTemplate.currency;
} else if (this.recurringDepositsAccountProductTemplate && this.recurringDepositsAccountProductTemplate.currency) {
this.currency = this.recurringDepositsAccountProductTemplate.currency;
}
}
if (this.recurringDepositsAccountProductTemplate) {
this.chargeData = this.recurringDepositsAccountProductTemplate.chargeOptions;
this.chargeData = this.recurringDepositsAccountProductTemplate.chargeOptions
.filter((c: Charge) => c.currency.code === this.currency.code);
}
}
@@ -1,29 +0,0 @@
<form [formGroup]="recurringDepositAccountCurrencyForm">
<div fxLayout="row wrap" fxLayoutGap="2%" fxLayout.lt-md="column">
<mat-form-field fxFlex="48%">
<mat-label>{{"labels.inputs.Currency" | translate }}</mat-label>
<input type="text" matInput formControlName="currencyCode" matTooltip="Add Currency" matTooltipPosition="above" required>
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>{{"labels.inputs.Decimal Places" | translate }}</mat-label>
<input type="number" matInput formControlName="decimalPlaces" required matTooltip="Add Decimal Places" matTooltipPosition="above">
</mat-form-field>
</div>
<div fxLayout="row" class="margin-t" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="2%">
<button mat-raised-button matStepperPrevious>
<fa-icon icon="arrow-left" class="m-r-10"></fa-icon>
{{"labels.buttons.Previous" | translate }}
</button>
<button mat-raised-button matStepperNext>
{{"labels.buttons.Next" | translate }}
<fa-icon icon="arrow-right" class="m-l-10"></fa-icon>
</button>
</div>
</form>
@@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RecurringDepositsAccountCurrencyStepComponent } from './recurring-deposits-account-currency-step.component';
describe('RecurringDepositsAccountCurrencyStepComponent', () => {
let component: RecurringDepositsAccountCurrencyStepComponent;
let fixture: ComponentFixture<RecurringDepositsAccountCurrencyStepComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ RecurringDepositsAccountCurrencyStepComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(RecurringDepositsAccountCurrencyStepComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,54 +0,0 @@
/** Angular Imports */
import { Component, OnInit, Input, OnChanges } from '@angular/core';
import { UntypedFormGroup, UntypedFormBuilder, Validators } from '@angular/forms';
/**
* Recurring Deposit Account Currency Step
*/
@Component({
selector: 'mifosx-recurring-deposits-account-currency-step',
templateUrl: './recurring-deposits-account-currency-step.component.html',
styleUrls: ['./recurring-deposits-account-currency-step.component.scss']
})
export class RecurringDepositsAccountCurrencyStepComponent implements OnInit, OnChanges {
@Input() recurringDepositsAccountTemplate: any;
@Input() recurringDepositsAccountProductTemplate: any;
/** Recurring Deposit Account Currency Form */
recurringDepositAccountCurrencyForm: UntypedFormGroup;
/** Currency Data */
currencyData: any;
constructor(private formBuilder: UntypedFormBuilder) {
this.createRecurringDepositAccountCurrencyForm();
}
ngOnInit() {
}
ngOnChanges() {
if (this.recurringDepositsAccountProductTemplate) {
this.recurringDepositAccountCurrencyForm.patchValue({
'currencyCode': this.recurringDepositsAccountProductTemplate.currency.code,
'decimalPlaces': this.recurringDepositsAccountProductTemplate.currency.decimalPlaces
});
}
}
createRecurringDepositAccountCurrencyForm() {
this.recurringDepositAccountCurrencyForm = this.formBuilder.group({
'currencyCode': [{ value: '', disabled: true }],
'decimalPlaces': [{ value: '', disabled: true }]
});
}
/**
* Returns Recurring Deposits Account Currency Form
*/
get recurringDepositAccountCurrency() {
return this.recurringDepositAccountCurrencyForm.value;
}
}
@@ -14,7 +14,7 @@
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="48%" (click)="submittedOnDatePicker.open()">
<mat-form-field fxFlex="48%" (click)="submittedOnDatePicker.open()" *ngIf="isProductSelected">
<mat-label>{{"labels.inputs.Submitted On" | translate }}</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="submittedOnDatePicker"
formControlName="submittedOnDate" required>
@@ -25,7 +25,7 @@
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-form-field fxFlex="48%" *ngIf="isProductSelected">
<mat-label>{{"labels.inputs.Field Officer" | translate }}</mat-label>
<mat-select formControlName="fieldOfficerId">
<mat-option *ngFor="let officer of fieldOfficerData" [value]="officer.id">
@@ -34,6 +34,11 @@
</mat-select>
</mat-form-field>
<mat-form-field fxFlex="48%" *ngIf="isProductSelected">
<mat-label>{{"labels.inputs.External id" | translate}}</mat-label>
<input matInput formControlName="externalId" matTooltip="{{ 'tooltips.Provides an external id' | translate}}">
</mat-form-field>
</div>
<div fxLayout="row" class="margin-t" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="2%">
@@ -32,6 +32,8 @@ export class RecurringDepositsAccountDetailsStepComponent implements OnInit {
/** Recurring Deposits Account Details Form */
recurringDepositAccountDetailsForm: UntypedFormGroup;
isProductSelected = false;
/** Recurring Deposits Account Template with product data */
@Output() recurringDepositsAccountProductTemplate = new EventEmitter();
@@ -56,6 +58,7 @@ export class RecurringDepositsAccountDetailsStepComponent implements OnInit {
this.recurringDepositAccountDetailsForm.patchValue({
'productId': this.recurringDepositsAccountTemplate.depositProductId,
'submittedOnDate': this.recurringDepositsAccountTemplate.timeline.submittedOnDate && new Date(this.recurringDepositsAccountTemplate.timeline.submittedOnDate),
'externalId': this.recurringDepositsAccountTemplate.externalId
});
}
}
@@ -68,7 +71,8 @@ export class RecurringDepositsAccountDetailsStepComponent implements OnInit {
this.recurringDepositAccountDetailsForm = this.formBuilder.group({
'productId': ['', Validators.required],
'submittedOnDate': ['', Validators.required],
'fieldOfficerId': ['']
'fieldOfficerId': [''],
'externalId': ['']
});
}
@@ -81,6 +85,7 @@ export class RecurringDepositsAccountDetailsStepComponent implements OnInit {
this.recurringDepositsService.getRecurringDepositsAccountTemplate(clientId, productId).subscribe((response: any) => {
this.recurringDepositsAccountProductTemplate.emit(response);
this.fieldOfficerData = response.fieldOfficerOptions;
this.isProductSelected = true;
if (!this.isFieldOfficerPatched && this.recurringDepositsAccountTemplate.fieldOfficerId) {
this.recurringDepositAccountDetailsForm.get('fieldOfficerId').patchValue(this.recurringDepositsAccountTemplate.fieldOfficerId);
this.isFieldOfficerPatched = true;
@@ -77,9 +77,9 @@
fxFlex="60%">{{ recurringDepositAccountData.lockinPeriodFrequency + ' ' + (recurringDepositAccountData.lockinPeriodFrequencyType | find:recurringDepositsAccountProductTemplate.lockinPeriodFrequencyTypeOptions:'id':'value') }}</span>
</div>
<div fxFlexFill>
<div fxFlexFill *ngIf="recurringDepositAccountData.mandatoryRecommendedDepositAmount">
<span fxFlex="40%">{{"labels.inputs.Recurring Deposit Amount" | translate }}:</span>
<span fxFlex="60%">{{ recurringDepositAccountData?.mandatoryRecommendedDepositAmount}}</span>
<span fxFlex="60%">{{ recurringDepositAccountData.mandatoryRecommendedDepositAmount | formatNumber}}</span>
</div>
<div fxFlexFill>
@@ -38,7 +38,7 @@
<mat-label>{{"labels.inputs.Recurring Deposit Amount" | translate }}</mat-label>
<input type="number" matInput formControlName="mandatoryRecommendedDepositAmount" required>
<mat-error>
{{"labels.inputs.Recurring Deposit Amount" | translate }} {{ "labels.commons.is" |translate}} <strong>{{ "labels.commons.required" |translate}}</strong>
{{"labels.inputs.Recurring Deposit Amount" | translate }} {{ "labels.commons.is" | translate }} <strong>{{ "labels.commons.required" | translate }}</strong>
</mat-error>
</mat-form-field>
@@ -77,7 +77,7 @@
<mat-label>{{"labels.inputs.Deposit Frequency" | translate }}</mat-label>
<input type="number" matInput formControlName="recurringFrequency" required>
<mat-error>
{{"labels.inputs.Deposit Frequency" | translate }} {{ "labels.commons.is" |translate}} <strong>{{ "labels.commons.required" |translate}}</strong>
{{"labels.inputs.Deposit Frequency" | translate }} {{ "labels.commons.is" | translate }} <strong>{{ "labels.commons.required" | translate }}</strong>
</mat-error>
</mat-form-field>
@@ -89,7 +89,7 @@
</mat-option>
</mat-select>
<mat-error>
{{"labels.inputs.Deposit Frequency Type" | translate }} {{ "labels.commons.is" |translate}} <strong>{{ "labels.commons.required" |translate}}</strong>
{{"labels.inputs.Deposit Frequency Type" | translate }} {{ "labels.commons.is" | translate }} <strong>{{ "labels.commons.required" | translate }}</strong>
</mat-error>
</mat-form-field>
</ng-container>
@@ -103,7 +103,7 @@
<mat-label>{{"labels.inputs.Frequency" | translate }}</mat-label>
<input type="number" matInput formControlName="minDepositTerm" required>
<mat-error>
{{"labels.inputs.Minimum Deposit Term Frequency" | translate }} {{ "labels.commons.is" |translate}} <strong>{{ "labels.commons.required" |translate}}</strong>
{{"labels.inputs.Minimum Deposit Term Frequency" | translate }} {{ "labels.commons.is" | translate }} <strong>{{ "labels.commons.required" | translate }}</strong>
</mat-error>
</mat-form-field>
@@ -115,7 +115,7 @@
</mat-option>
</mat-select>
<mat-error>
{{"labels.inputs.Minimum Deposit Term Frequency Type" | translate }} {{ "labels.commons.is" |translate}} <strong>{{ "labels.commons.required" |translate}}</strong>
{{"labels.inputs.Minimum Deposit Term Frequency Type" | translate }} {{ "labels.commons.is" | translate }} <strong>{{ "labels.commons.required" | translate }}</strong>
</mat-error>
</mat-form-field>
@@ -61,6 +61,8 @@ export class RecurringDepositsAccountSettingsStepComponent implements OnInit, On
'preClosurePenalInterest': this.recurringDepositsAccountProductTemplate.preClosurePenalInterest,
'preClosurePenalInterestOnTypeId': this.recurringDepositsAccountProductTemplate.preClosurePenalInterestOnType ? this.recurringDepositsAccountProductTemplate.preClosurePenalInterestOnType.id : '',
'minBalanceForInterestCalculation': this.recurringDepositsAccountProductTemplate.minBalanceForInterestCalculation,
'depositPeriod': this.recurringDepositsAccountProductTemplate.minDepositTerm,
'depositPeriodFrequencyId': this.recurringDepositsAccountProductTemplate.minDepositTermType.id
});
if (this.recurringDepositsAccountProductTemplate.withHoldTax) {
this.recurringDepositAccountSettingsForm.addControl('withHoldTax', new UntypedFormControl(false));
@@ -48,7 +48,7 @@ export class RecurringDepositsAccountTermsStepComponent implements OnInit, OnCha
ngOnInit() {
this.maxDate = this.settingsService.businessDate;
if (this.recurringDepositsAccountTemplate.interestCompoundingPeriodType) {
if (this.recurringDepositsAccountTemplate.id) {
this.recurringDepositAccountTermsForm.patchValue({
'interestCompoundingPeriodType': this.recurringDepositsAccountTemplate.interestCompoundingPeriodType.id,
'interestPostingPeriodType': this.recurringDepositsAccountTemplate.interestPostingPeriodType.id,
@@ -78,6 +78,14 @@ export class RecurringDepositsAccountTermsStepComponent implements OnInit, OnCha
this.interestPostingPeriodTypeData = this.recurringDepositsAccountProductTemplate.interestPostingPeriodTypeOptions;
this.interestCalculationTypeData = this.recurringDepositsAccountProductTemplate.interestCalculationTypeOptions;
this.interestCalculationDaysInYearTypeData = this.recurringDepositsAccountProductTemplate.interestCalculationDaysInYearTypeOptions;
if (!this.recurringDepositsAccountTemplate.id) {
this.recurringDepositAccountTermsForm.patchValue({
'interestCompoundingPeriodType': this.recurringDepositsAccountProductTemplate.interestCompoundingPeriodType.id,
'interestPostingPeriodType': this.recurringDepositsAccountProductTemplate.interestPostingPeriodType.id,
'interestCalculationType': this.recurringDepositsAccountProductTemplate.interestCalculationType.id,
'interestCalculationDaysInYearType': this.recurringDepositsAccountProductTemplate.interestCalculationDaysInYearType.id,
});
}
}
/**