Savings product datatables (#1646)

Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
José Alberto Hernández
2023-01-18 09:15:28 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent b6c5f0e41e
commit 00ceeed3f2
17 changed files with 39 additions and 210 deletions
@@ -120,7 +120,7 @@ export class LoansAccountDetailsStepComponent implements OnInit {
* Returns loans account details form value.
*/
get loansAccountDetails() {
return this.loansAccountDetailsForm.value;
return this.loansAccountDetailsForm.getRawValue();
}
}
@@ -412,7 +412,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
* Returns loans account terms form value.
*/
get loansAccountTerms() {
return this.loansAccountTermsForm.value;
return this.loansAccountTermsForm.getRawValue();
}
get loanCollateral() {
@@ -84,14 +84,6 @@
</mat-step>
<mat-step *ngFor="let datatable of datatables">
<ng-template matStepLabel>{{datatable.registeredTableName}}</ng-template>
<mifosx-loan-product-datatable-step [datatableData]="datatable" #dtloanproduct></mifosx-loan-product-datatable-step>
</mat-step>
<mat-step state="preview" *ngIf="loanProductFormValid" completed>
<ng-template matStepLabel>PREVIEW</ng-template>
@@ -13,7 +13,6 @@ import { LoanProductAccountingStepComponent } from '../loan-product-stepper/loan
/** Custom Services */
import { ProductsService } from 'app/products/products.service';
import { SettingsService } from 'app/settings/settings.service';
import { LoanProductDatatableStepComponent } from '../loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component';
@Component({
selector: 'mifosx-create-loan-product',
@@ -28,10 +27,6 @@ export class CreateLoanProductComponent implements OnInit {
@ViewChild(LoanProductSettingsStepComponent, { static: true }) loanProductSettingsStep: LoanProductSettingsStepComponent;
@ViewChild(LoanProductChargesStepComponent, { static: true }) loanProductChargesStep: LoanProductChargesStepComponent;
@ViewChild(LoanProductAccountingStepComponent, { static: true }) loanProductAccountingStep: LoanProductAccountingStepComponent;
/** Get handle on dtloanproduct tags in the template */
@ViewChildren('dtloanproduct') loanProductDatatables: QueryList<LoanProductDatatableStepComponent>;
datatables: any = [];
loanProductsTemplate: any;
accountingRuleData = ['None', 'Cash', 'Accrual (periodic)', 'Accrual (upfront)'];
@@ -47,10 +42,8 @@ export class CreateLoanProductComponent implements OnInit {
private productsService: ProductsService,
private settingsService: SettingsService,
private router: Router) {
this.route.data.subscribe((data: { loanProductsTemplate: any, loanProductDatatables: any }) => {
this.route.data.subscribe((data: { loanProductsTemplate: any }) => {
this.loanProductsTemplate = data.loanProductsTemplate;
// this.datatables = data.loanProductDatatables;
this.datatables = [];
const assetAccountData = this.loanProductsTemplate.accountingMappingOptions.assetAccountOptions || [];
const liabilityAccountData = this.loanProductsTemplate.accountingMappingOptions.liabilityAccountOptions || [];
this.loanProductsTemplate.accountingMappingOptions.assetAndLiabilityAccountOptions = assetAccountData.concat(liabilityAccountData);
@@ -81,21 +74,13 @@ export class CreateLoanProductComponent implements OnInit {
}
get loanProductFormValid() {
let areValids = (
return (
this.loanProductDetailsForm.valid &&
this.loanProductCurrencyForm.valid &&
this.loanProductTermsForm.valid &&
this.loanProductSettingsForm.valid &&
this.loanProductAccountingForm.valid
);
if (this.datatables.length > 0 && this.loanProductDatatables) {
this.loanProductDatatables.forEach((loanProductDatatable: LoanProductDatatableStepComponent) => {
areValids = areValids && loanProductDatatable.datatableForm.valid;
});
}
return areValids;
}
get loanProduct() {
@@ -120,15 +105,6 @@ export class CreateLoanProductComponent implements OnInit {
delete loanProduct.allowAttributeConfiguration;
delete loanProduct.advancedAccountingRules;
if (this.datatables.length > 0) {
const datatables: any[] = [];
this.loanProductDatatables.forEach((loanProductDatatable: LoanProductDatatableStepComponent) => {
datatables.push(loanProductDatatable.payload);
});
loanProduct['datatables'] = datatables;
}
this.productsService.createLoanProduct(loanProduct)
.subscribe((response: any) => {
this.router.navigate(['../', response.resourceId], { relativeTo: this.route });
@@ -1,51 +0,0 @@
<form [formGroup]="datatableForm">
<div fxLayout="row wrap" fxLayoutGap="2%" fxLayout.lt-md="column">
<div *ngFor="let datatableInput of datatableInputs" fxFlex="48%">
<mat-form-field fxFlex="100%" *ngIf="!isBoolean(datatableInput.columnDisplayType)">
<mat-label>{{getInputName(datatableInput)}}</mat-label>
<mat-select *ngIf="isDropdown(datatableInput.columnDisplayType)" formControlName="{{datatableInput.controlName}}">
<mat-option *ngFor="let code of datatableInput.columnValues" [value]="code.id">
{{ code.value }}
</mat-option>
</mat-select>
<input matInput type="number" *ngIf="isNumeric(datatableInput.columnDisplayType)"
formControlName="{{datatableInput.controlName}}">
<input matInput *ngIf="isString(datatableInput.columnDisplayType)"
formControlName="{{datatableInput.controlName}}">
<textarea matInput *ngIf="isText(datatableInput.columnDisplayType)"
formControlName="{{datatableInput.controlName}}"></textarea>
<span *ngIf="isDate(datatableInput.columnDisplayType)" (click)="datePicker.open()">
<input matInput [matDatepicker]="datePicker" formControlName="{{datatableInput.controlName}}" class="date-picker">
<mat-datepicker-toggle matSuffix [for]="datePicker"></mat-datepicker-toggle>
<mat-datepicker #datePicker></mat-datepicker>
</span>
</mat-form-field>
<mat-checkbox *ngIf="isBoolean(datatableInput.columnDisplayType)" formControlName="{{datatableInput.controlName}}"
labelPosition="before" class="margin-v">
{{getInputName(datatableInput)}}
</mat-checkbox>
</div>
</div>
<div fxLayout="row" class="margin-t" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="2%">
<button mat-raised-button matStepperPrevious disabled>
<fa-icon icon="arrow-left" class="m-r-10"></fa-icon>
Previous
</button>
<button mat-raised-button matStepperNext>
Next&nbsp;&nbsp;
<fa-icon icon="arrow-right"></fa-icon>
</button>
</div>
</form>
@@ -1,7 +0,0 @@
.date-picker {
width: 92%;
}
mat-checkbox {
margin-top: 30px;
}
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoanProductDatatableStepComponent } from './loan-product-datatable-step.component';
describe('LoanProductDatatableStepComponent', () => {
let component: LoanProductDatatableStepComponent;
let fixture: ComponentFixture<LoanProductDatatableStepComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoanProductDatatableStepComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(LoanProductDatatableStepComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,82 +0,0 @@
import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { Datatables } from 'app/core/utils/datatables';
import { SettingsService } from 'app/settings/settings.service';
@Component({
selector: 'mifosx-loan-product-datatable-step',
templateUrl: './loan-product-datatable-step.component.html',
styleUrls: ['./loan-product-datatable-step.component.scss']
})
export class LoanProductDatatableStepComponent implements OnInit {
/** Input Fields Data */
@Input() datatableData: any;
/** Create Input Form */
datatableForm: FormGroup;
datatableInputs: any = [];
constructor(private formBuilder: FormBuilder,
private settingsService: SettingsService,
private datatableService: Datatables) { }
ngOnInit(): void {
this.datatableInputs = this.datatableService.filterSystemColumns(this.datatableData.columnHeaderData);
const inputItems: any = {};
this.datatableInputs.forEach((input: any) => {
input.controlName = this.getInputName(input);
if (!input.isColumnNullable) {
if (this.isNumeric(input.columnDisplayType)) {
inputItems[input.controlName] = new FormControl(0, [Validators.required]);
} else {
inputItems[input.controlName] = new FormControl('', [Validators.required]);
}
} else {
inputItems[input.controlName] = new FormControl('');
}
});
this.datatableForm = this.formBuilder.group(inputItems);
}
getInputName(datatableInput: any): string {
return this.datatableService.getInputName(datatableInput);
}
isNumeric(columnType: string) {
return this.datatableService.isNumeric(columnType);
}
isDate(columnType: string) {
return this.datatableService.isDate(columnType);
}
isBoolean(columnType: string) {
return this.datatableService.isBoolean(columnType);
}
isDropdown(columnType: string) {
return this.datatableService.isDropdown(columnType);
}
isString(columnType: string) {
return this.datatableService.isString(columnType);
}
isText(columnType: string) {
return this.datatableService.isText(columnType);
}
get payload(): any {
const dateFormat = this.settingsService.dateFormat;
const datatableDataValues = this.datatableForm.value;
const data = this.datatableService.buildPayload(this.datatableInputs, datatableDataValues, dateFormat,
{ locale: this.settingsService.language.code });
return {
registeredTableName: this.datatableData.registeredTableName,
data: data
};
}
}
@@ -84,9 +84,15 @@ export class LoanProductSettingsStepComponent implements OnInit {
'holdGuaranteeFunds': this.loanProductsTemplate.holdGuaranteeFunds,
'multiDisburseLoan': this.loanProductsTemplate.multiDisburseLoan,
'maxTrancheCount': this.loanProductsTemplate.maxTrancheCount,
'outstandingLoanBalance': this.loanProductsTemplate.outstandingLoanBalance
'outstandingLoanBalance': this.loanProductsTemplate.outstandingLoanBalance,
});
if (this.loanProductsTemplate.delinquencyBucket) {
this.loanProductSettingsForm.patchValue({
'delinquencyBucketId': this.loanProductsTemplate.delinquencyBucket.id
});
}
if (this.loanProductsTemplate.isInterestRecalculationEnabled) {
this.loanProductSettingsForm.patchValue({
'preClosureInterestCalculationStrategy': this.loanProductsTemplate.interestRecalculationData.preClosureInterestCalculationStrategy.id,
+1 -2
View File
@@ -148,8 +148,7 @@ const routes: Routes = [
component: CreateLoanProductComponent,
data: { title: extract('Create Loan Product'), breadcrumb: 'Create' },
resolve: {
loanProductsTemplate: LoanProductsTemplateResolver,
loanProductDatatables: LoanProductDatatablesResolver
loanProductsTemplate: LoanProductsTemplateResolver
}
},
{
-2
View File
@@ -106,7 +106,6 @@ import { EditRangeComponent } from './manage-delinquency-buckets/delinquency-ran
import { ViewBucketComponent } from './manage-delinquency-buckets/delinquency-bucket/view-bucket/view-bucket.component';
import { CreateBucketComponent } from './manage-delinquency-buckets/delinquency-bucket/create-bucket/create-bucket.component';
import { EditBucketComponent } from './manage-delinquency-buckets/delinquency-bucket/edit-bucket/edit-bucket.component';
import { LoanProductDatatableStepComponent } from './loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component';
import { DatatableTabComponent } from './loan-products/view-loan-product/datatable-tab/datatable-tab.component';
import { GeneralTabComponent } from './loan-products/view-loan-product/general-tab/general-tab.component';
import { SavingProductGeneralTabComponent } from './saving-products/view-saving-product/saving-product-general-tab/saving-product-general-tab.component';
@@ -225,7 +224,6 @@ import { SavingProductDatatableTabComponent } from './saving-products/view-savin
ViewBucketComponent,
CreateBucketComponent,
EditBucketComponent,
LoanProductDatatableStepComponent,
DatatableTabComponent,
GeneralTabComponent,
SavingProductGeneralTabComponent,
@@ -12,7 +12,12 @@ export class ViewSavingProductComponent implements OnInit {
constructor(private route: ActivatedRoute) {
this.route.data.subscribe((data: { savingProductDatatables: any }) => {
this.savingProductDatatables = data.savingProductDatatables;
this.savingProductDatatables = [];
data.savingProductDatatables.forEach((datatable: any) => {
if (datatable.entitySubType === 'Savings Product') {
this.savingProductDatatables.push(datatable);
}
});
});
}
@@ -105,7 +105,7 @@ export class SavingsAccountDetailsStepComponent implements OnInit {
* Returns savings account form value.
*/
get savingsAccountDetails() {
return this.savingsAccountDetailsForm.value;
return this.savingsAccountDetailsForm.getRawValue();
}
}
@@ -146,7 +146,7 @@ export class SavingsAccountTermsStepComponent implements OnChanges, OnInit {
* Returns savings account terms form value.
*/
get savingsAccountTerms() {
return this.savingsAccountTermsForm.value;
return this.savingsAccountTermsForm.getRawValue();
}
}
@@ -14,3 +14,9 @@ export const entitySubTypeData: { displayValue: string, value: string }[] = [
{ displayValue: 'Person', value: 'Person' },
{ displayValue: 'Entity', value: 'Entity' },
];
export const savingsSubTypeData: { displayValue: string, value: string }[] = [
{ displayValue: 'Savings Product', value: 'Savings Product' },
{ displayValue: 'Fixed Deposit', value: 'Fixed Deposit' },
{ displayValue: 'Recurring Deposit', value: 'Recurring Deposit' },
];
@@ -37,6 +37,15 @@
</mat-select>
</mat-form-field>
<mat-form-field fxFlex="20%" *ngIf="showSavingsSubType">
<mat-label>Savings SubType</mat-label>
<mat-select formControlName="entitySubType">
<mat-option *ngFor="let savingsSubType of savingsSubTypeData" [value]="savingsSubType.value">
{{ savingsSubType.displayValue }}
</mat-option>
</mat-select>
</mat-form-field>
<div fxFlex="14%" class="multi-row-wrapper">
<mat-checkbox labelPosition="before" formControlName="multiRow" class="multi-row">Multi Row</mat-checkbox>
</div>
@@ -13,7 +13,7 @@ import { PopoverService } from '../../../configuration-wizard/popover/popover.se
import { ConfigurationWizardService } from '../../../configuration-wizard/configuration-wizard.service';
/** Data Imports */
import { appTableData, entitySubTypeData } from '../app-table-data';
import { appTableData, entitySubTypeData, savingsSubTypeData } from '../app-table-data';
/** Custom Components */
import { ColumnDialogComponent } from '../column-dialog/column-dialog.component';
@@ -38,7 +38,9 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
/** Application Table Data */
appTableData = appTableData;
entitySubTypeData = entitySubTypeData;
savingsSubTypeData = savingsSubTypeData;
showEntitySubType: boolean;
showSavingsSubType: boolean;
/** Column Data */
columnData: DatatableColumn[] = [];
/** Data passed to dialog. */
@@ -97,6 +99,7 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
this.setColumns();
this.dataTableForm.controls.apptableName.valueChanges.subscribe((value: any) => {
this.showEntitySubType = (value === 'm_client');
this.showSavingsSubType = (value === 'm_savings_product');
});
}