diff --git a/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts b/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts index 44b02678f..4e6363a40 100644 --- a/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts +++ b/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts @@ -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(); } } diff --git a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts index 39b23af35..97fde9cdc 100644 --- a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts +++ b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts @@ -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() { diff --git a/src/app/products/loan-products/create-loan-product/create-loan-product.component.html b/src/app/products/loan-products/create-loan-product/create-loan-product.component.html index 8c5f336f7..5db925be8 100644 --- a/src/app/products/loan-products/create-loan-product/create-loan-product.component.html +++ b/src/app/products/loan-products/create-loan-product/create-loan-product.component.html @@ -84,14 +84,6 @@ - - - {{datatable.registeredTableName}} - - - - - PREVIEW diff --git a/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts b/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts index 0dfebc422..e8889492d 100644 --- a/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts +++ b/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts @@ -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; - - 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 }); diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.html b/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.html deleted file mode 100644 index a8107a8f5..000000000 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - {{getInputName(datatableInput)}} - - - - {{ code.value }} - - - - - - - - - - - - - - - - - - {{getInputName(datatableInput)}} - - - - - - - - - Previous - - - Next - - - - - diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.scss b/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.scss deleted file mode 100644 index 8817bcc31..000000000 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.scss +++ /dev/null @@ -1,7 +0,0 @@ -.date-picker { - width: 92%; -} - -mat-checkbox { - margin-top: 30px; -} diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.spec.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.spec.ts deleted file mode 100644 index 69315379d..000000000 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.spec.ts +++ /dev/null @@ -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; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ LoanProductDatatableStepComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(LoanProductDatatableStepComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.ts deleted file mode 100644 index 277104b46..000000000 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-datatable-step/loan-product-datatable-step.component.ts +++ /dev/null @@ -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 - }; - } - -} diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts index 963d88fc3..259f40927 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.ts @@ -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, diff --git a/src/app/products/products-routing.module.ts b/src/app/products/products-routing.module.ts index d3dc12877..cca87e5eb 100644 --- a/src/app/products/products-routing.module.ts +++ b/src/app/products/products-routing.module.ts @@ -148,8 +148,7 @@ const routes: Routes = [ component: CreateLoanProductComponent, data: { title: extract('Create Loan Product'), breadcrumb: 'Create' }, resolve: { - loanProductsTemplate: LoanProductsTemplateResolver, - loanProductDatatables: LoanProductDatatablesResolver + loanProductsTemplate: LoanProductsTemplateResolver } }, { diff --git a/src/app/products/products.module.ts b/src/app/products/products.module.ts index 702061de9..dfddc9d31 100644 --- a/src/app/products/products.module.ts +++ b/src/app/products/products.module.ts @@ -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, diff --git a/src/app/products/saving-products/view-saving-product/view-saving-product.component.ts b/src/app/products/saving-products/view-saving-product/view-saving-product.component.ts index 812ab3de7..3469f1189 100644 --- a/src/app/products/saving-products/view-saving-product/view-saving-product.component.ts +++ b/src/app/products/saving-products/view-saving-product/view-saving-product.component.ts @@ -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); + } + }); }); } diff --git a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts index 44d305b74..4edcb4cfa 100644 --- a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts +++ b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts @@ -105,7 +105,7 @@ export class SavingsAccountDetailsStepComponent implements OnInit { * Returns savings account form value. */ get savingsAccountDetails() { - return this.savingsAccountDetailsForm.value; + return this.savingsAccountDetailsForm.getRawValue(); } } diff --git a/src/app/savings/savings-account-stepper/savings-account-terms-step/savings-account-terms-step.component.ts b/src/app/savings/savings-account-stepper/savings-account-terms-step/savings-account-terms-step.component.ts index 1dc0295fa..5d148d654 100644 --- a/src/app/savings/savings-account-stepper/savings-account-terms-step/savings-account-terms-step.component.ts +++ b/src/app/savings/savings-account-stepper/savings-account-terms-step/savings-account-terms-step.component.ts @@ -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(); } } diff --git a/src/app/system/manage-data-tables/app-table-data.ts b/src/app/system/manage-data-tables/app-table-data.ts index a69839779..88f051502 100644 --- a/src/app/system/manage-data-tables/app-table-data.ts +++ b/src/app/system/manage-data-tables/app-table-data.ts @@ -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' }, + ]; diff --git a/src/app/system/manage-data-tables/create-data-table/create-data-table.component.html b/src/app/system/manage-data-tables/create-data-table/create-data-table.component.html index e3b5e2a04..2a26db3b1 100644 --- a/src/app/system/manage-data-tables/create-data-table/create-data-table.component.html +++ b/src/app/system/manage-data-tables/create-data-table/create-data-table.component.html @@ -37,6 +37,15 @@ + + Savings SubType + + + {{ savingsSubType.displayValue }} + + + + Multi Row diff --git a/src/app/system/manage-data-tables/create-data-table/create-data-table.component.ts b/src/app/system/manage-data-tables/create-data-table/create-data-table.component.ts index 2b35e02c0..c9528f16d 100644 --- a/src/app/system/manage-data-tables/create-data-table/create-data-table.component.ts +++ b/src/app/system/manage-data-tables/create-data-table/create-data-table.component.ts @@ -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'); }); }