diff --git a/src/app/products/products-routing.module.ts b/src/app/products/products-routing.module.ts index 47d504a86..e28ee2001 100644 --- a/src/app/products/products-routing.module.ts +++ b/src/app/products/products-routing.module.ts @@ -21,6 +21,7 @@ import { EditSavingProductComponent } from './saving-products/edit-saving-produc import { ShareProductsComponent } from './share-products/share-products.component'; import { CreateShareProductComponent } from './share-products/create-share-product/create-share-product.component'; import { ViewShareProductComponent } from './share-products/view-share-product/view-share-product.component'; +import { EditShareProductComponent } from './share-products/edit-share-product/edit-share-product.component'; import { ManageTaxConfigurationsComponent } from './manage-tax-configurations/manage-tax-configurations.component'; import { RecurringDepositProductsComponent } from './recurring-deposit-products/recurring-deposit-products.component'; import { ChargesComponent } from './charges/charges.component'; @@ -40,6 +41,7 @@ import { SavingProductAndTemplateResolver } from './saving-products/edit-saving- import { ShareProductsResolver } from './share-products/share-products.resolver'; import { ShareProductsTemplateResolver } from './share-products/share-products-template.resolver'; import { ShareProductResolver } from './share-products/share-product-resolver'; +import { ShareProductAndTemplateResolver } from './share-products/edit-share-product/share-product-and-template.resolver'; import { RecurringDepositProductsResolver } from './recurring-deposit-products/recurring-deposit-products.resolver'; import { ChargesResolver } from './charges/charges.resolver'; import { FixedDepositProductsResolver } from './fixed-deposit-products/fixed-deposit-products.resolver'; @@ -171,6 +173,14 @@ const routes: Routes = [ shareProduct: ShareProductResolver }, }, + { + path: 'edit', + component: EditShareProductComponent, + data: { title: extract('Edit Share Product'), breadcrumb: 'Edit', routeParamBreadcrumb: false }, + resolve: { + shareProductAndTemplate: ShareProductAndTemplateResolver + } + } ] } ] @@ -250,6 +260,7 @@ const routes: Routes = [ ShareProductsResolver, ShareProductsTemplateResolver, ShareProductResolver, + ShareProductAndTemplateResolver, RecurringDepositProductsResolver, ChargesResolver, FixedDepositProductsResolver, diff --git a/src/app/products/products.module.ts b/src/app/products/products.module.ts index fc8fb5310..141035817 100644 --- a/src/app/products/products.module.ts +++ b/src/app/products/products.module.ts @@ -48,6 +48,7 @@ import { ShareProductAccountingStepComponent } from './share-products/share-prod import { ShareProductPreviewStepComponent } from './share-products/share-product-stepper/share-product-preview-step/share-product-preview-step.component'; import { CreateShareProductComponent } from './share-products/create-share-product/create-share-product.component'; import { ViewShareProductComponent } from './share-products/view-share-product/view-share-product.component'; +import { EditShareProductComponent } from './share-products/edit-share-product/edit-share-product.component'; /** * Products Module @@ -100,7 +101,8 @@ import { ViewShareProductComponent } from './share-products/view-share-product/v ShareProductAccountingStepComponent, ShareProductPreviewStepComponent, CreateShareProductComponent, - ViewShareProductComponent + ViewShareProductComponent, + EditShareProductComponent ], entryComponents: [ ], diff --git a/src/app/products/products.service.ts b/src/app/products/products.service.ts index 0c536645b..d15558a8f 100644 --- a/src/app/products/products.service.ts +++ b/src/app/products/products.service.ts @@ -81,8 +81,13 @@ export class ProductsService { return this.http.get('/products/share/template'); } - getShareProduct(shareProductId: string): Observable { - return this.http.get(`/products/share/${shareProductId}`); + getShareProduct(shareProductId: string, template: boolean = false): Observable { + const httpParams = new HttpParams().set('template', template.toString()); + return this.http.get(`/products/share/${shareProductId}`, { params: httpParams }); + } + + updateShareProduct(shareProductId: string, shareProduct: any): Observable { + return this.http.put(`/products/share/${shareProductId}`, shareProduct); } /** diff --git a/src/app/products/share-products/create-share-product/create-share-product.component.html b/src/app/products/share-products/create-share-product/create-share-product.component.html index 2428faafc..70263bb53 100644 --- a/src/app/products/share-products/create-share-product/create-share-product.component.html +++ b/src/app/products/share-products/create-share-product/create-share-product.component.html @@ -54,7 +54,7 @@ - + MARKET PRICE diff --git a/src/app/products/share-products/edit-share-product/edit-share-product.component.html b/src/app/products/share-products/edit-share-product/edit-share-product.component.html new file mode 100644 index 000000000..28eaf84fb --- /dev/null +++ b/src/app/products/share-products/edit-share-product/edit-share-product.component.html @@ -0,0 +1,106 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + DETAILS + + + + + + + + CURRENCY + + + + + + + + TERMS + + + + + + + + SETTINGS + + + + + + + + MARKET PRICE + + + + + + + + CHARGES + + + + + + + + + ACCOUNTING + + + + + + + + + PREVIEW + + + + + + + + +
diff --git a/src/app/products/share-products/edit-share-product/edit-share-product.component.scss b/src/app/products/share-products/edit-share-product/edit-share-product.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/products/share-products/edit-share-product/edit-share-product.component.spec.ts b/src/app/products/share-products/edit-share-product/edit-share-product.component.spec.ts new file mode 100644 index 000000000..700500880 --- /dev/null +++ b/src/app/products/share-products/edit-share-product/edit-share-product.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EditShareProductComponent } from './edit-share-product.component'; + +describe('EditShareProductComponent', () => { + let component: EditShareProductComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EditShareProductComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EditShareProductComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/products/share-products/edit-share-product/edit-share-product.component.ts b/src/app/products/share-products/edit-share-product/edit-share-product.component.ts new file mode 100644 index 000000000..838d8c401 --- /dev/null +++ b/src/app/products/share-products/edit-share-product/edit-share-product.component.ts @@ -0,0 +1,112 @@ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { ShareProductDetailsStepComponent } from '../share-product-stepper/share-product-details-step/share-product-details-step.component'; +import { ShareProductCurrencyStepComponent } from '../share-product-stepper/share-product-currency-step/share-product-currency-step.component'; +import { ShareProductTermsStepComponent } from '../share-product-stepper/share-product-terms-step/share-product-terms-step.component'; +import { ShareProductSettingsStepComponent } from '../share-product-stepper/share-product-settings-step/share-product-settings-step.component'; +import { ShareProductMarketPriceStepComponent } from '../share-product-stepper/share-product-market-price-step/share-product-market-price-step.component'; +import { ShareProductChargesStepComponent } from '../share-product-stepper/share-product-charges-step/share-product-charges-step.component'; +import { ShareProductAccountingStepComponent } from '../share-product-stepper/share-product-accounting-step/share-product-accounting-step.component'; + +import { ProductsService } from 'app/products/products.service'; + +@Component({ + selector: 'mifosx-edit-share-product', + templateUrl: './edit-share-product.component.html', + styleUrls: ['./edit-share-product.component.scss'] +}) +export class EditShareProductComponent implements OnInit { + + @ViewChild(ShareProductDetailsStepComponent) shareProductDetailsStep: ShareProductDetailsStepComponent; + @ViewChild(ShareProductCurrencyStepComponent) shareProductCurrencyStep: ShareProductCurrencyStepComponent; + @ViewChild(ShareProductTermsStepComponent) shareProductTermsStep: ShareProductTermsStepComponent; + @ViewChild(ShareProductSettingsStepComponent) shareProductSettingsStep: ShareProductSettingsStepComponent; + @ViewChild(ShareProductMarketPriceStepComponent) shareProductMarketPriceStep: ShareProductMarketPriceStepComponent; + @ViewChild(ShareProductChargesStepComponent) shareProductChargesStep: ShareProductChargesStepComponent; + @ViewChild(ShareProductAccountingStepComponent) shareProductAccountingStep: ShareProductAccountingStepComponent; + + shareProductAndTemplate: any; + accountingRuleData = ['None', 'Cash']; + + constructor(private route: ActivatedRoute, + private productsService: ProductsService, + private router: Router) { + this.route.data.subscribe((data: { shareProductAndTemplate: any }) => { + this.shareProductAndTemplate = data.shareProductAndTemplate; + }); + } + + ngOnInit() { + } + + get shareProductDetailsForm() { + return this.shareProductDetailsStep.shareProductDetailsForm; + } + + get shareProductCurrencyForm() { + return this.shareProductCurrencyStep.shareProductCurrencyForm; + } + + get shareProductTermsForm() { + return this.shareProductTermsStep.shareProductTermsForm; + } + + get shareProductSettingsForm() { + return this.shareProductSettingsStep.shareProductSettingsForm; + } + + get shareProductMarketPriceForm() { + return this.shareProductMarketPriceStep.shareProductMarketPriceForm; + } + + get shareProductAccountingForm() { + return this.shareProductAccountingStep.shareProductAccountingForm; + } + + get shareProductFormValidAndNotPristine() { + return ( + this.shareProductDetailsForm.valid && + this.shareProductCurrencyForm.valid && + this.shareProductTermsForm.valid && + this.shareProductSettingsForm.valid && + this.shareProductMarketPriceForm.valid && + this.shareProductAccountingForm.valid && + ( + !this.shareProductDetailsForm.pristine || + !this.shareProductCurrencyForm.pristine || + !this.shareProductTermsForm.pristine || + !this.shareProductSettingsForm.pristine || + !this.shareProductMarketPriceForm.pristine || + !this.shareProductChargesStep.pristine || + !this.shareProductAccountingForm.pristine + ) + ); + } + + get shareProduct() { + return { + ...this.shareProductDetailsStep.shareProductDetails, + ...this.shareProductCurrencyStep.shareProductCurrency, + ...this.shareProductTermsStep.shareProductTerms, + ...this.shareProductSettingsStep.shareProductSettings, + ...this.shareProductMarketPriceStep.shareProductMarketPrice, + ...this.shareProductChargesStep.shareProductCharges, + ...this.shareProductAccountingStep.shareProductAccounting + }; + } + + submit() { + // TODO: Update once language and date settings are setup + const shareProduct = { + ...this.shareProduct, + chargesSelected: this.shareProduct.chargesSelected.map((charge: any) => ({ id: charge.id })), + locale: 'en' // locale required for digitsAfterDecimal + }; + this.productsService.updateShareProduct(this.shareProductAndTemplate.id, shareProduct) + .subscribe((response: any) => { + this.router.navigate(['../../', response.resourceId], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/products/share-products/edit-share-product/share-product-and-template.resolver.ts b/src/app/products/share-products/edit-share-product/share-product-and-template.resolver.ts new file mode 100644 index 000000000..59ce7ffac --- /dev/null +++ b/src/app/products/share-products/edit-share-product/share-product-and-template.resolver.ts @@ -0,0 +1,31 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { ProductsService } from '../../products.service'; + +/** + * Share product and template data resolver. + */ +@Injectable() +export class ShareProductAndTemplateResolver implements Resolve { + + /** + * @param {ProductsService} productsService Products service. + */ + constructor(private productsService: ProductsService) {} + + /** + * Returns the share product and template data. + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const shareProductId = route.paramMap.get('id'); + return this.productsService.getShareProduct(shareProductId, true); + } + +} diff --git a/src/app/products/share-products/share-product-stepper/share-product-accounting-step/share-product-accounting-step.component.ts b/src/app/products/share-products/share-product-stepper/share-product-accounting-step/share-product-accounting-step.component.ts index 1badca8d8..0082263c3 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-accounting-step/share-product-accounting-step.component.ts +++ b/src/app/products/share-products/share-product-stepper/share-product-accounting-step/share-product-accounting-step.component.ts @@ -29,6 +29,21 @@ export class ShareProductAccountingStepComponent implements OnInit { this.incomeAccountData = this.shareProductsTemplate.accountingMappingOptions.incomeAccountOptions || []; this.equityAccountData = this.shareProductsTemplate.accountingMappingOptions.equityAccountOptions || []; this.liabilityAccountData = this.shareProductsTemplate.accountingMappingOptions.liabilityAccountOptions || []; + + if (this.shareProductsTemplate.accountingRule) { + this.shareProductAccountingForm.patchValue({ + 'accountingRule': this.shareProductsTemplate.accountingRule.id + }); + + if (this.shareProductsTemplate.accountingRule.id === 2) { + this.shareProductAccountingForm.patchValue({ + 'shareReferenceId': this.shareProductsTemplate.accountingMappings.shareReferenceId.id, + 'shareSuspenseId': this.shareProductsTemplate.accountingMappings.shareSuspenseId.id, + 'shareEquityId': this.shareProductsTemplate.accountingMappings.shareEquityId.id, + 'incomeFromFeeAccountId': this.shareProductsTemplate.accountingMappings.incomeFromFeeAccountId.id + }); + } + } } createShareProductAccountingForm() { diff --git a/src/app/products/share-products/share-product-stepper/share-product-charges-step/share-product-charges-step.component.ts b/src/app/products/share-products/share-product-stepper/share-product-charges-step/share-product-charges-step.component.ts index aebaf5def..9ee1b2b49 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-charges-step/share-product-charges-step.component.ts +++ b/src/app/products/share-products/share-product-stepper/share-product-charges-step/share-product-charges-step.component.ts @@ -19,13 +19,16 @@ export class ShareProductChargesStepComponent implements OnInit { chargesDataSource: {}[]; displayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType', 'action']; + pristine = true; + constructor(public dialog: MatDialog) { } ngOnInit() { this.chargeData = this.shareProductsTemplate.chargeOptions; - this.chargesDataSource = []; + this.chargesDataSource = this.shareProductsTemplate.charges || []; + this.pristine = true; this.currencyCode.valueChanges.subscribe(() => this.chargesDataSource = []); } @@ -33,6 +36,7 @@ export class ShareProductChargesStepComponent implements OnInit { addCharge(charge: any) { this.chargesDataSource = this.chargesDataSource.concat([charge.value]); charge.value = ''; + this.pristine = false; } deleteCharge(charge: any) { @@ -43,6 +47,7 @@ export class ShareProductChargesStepComponent implements OnInit { if (response.delete) { this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1); this.chargesDataSource = this.chargesDataSource.concat([]); + this.pristine = false; } }); } diff --git a/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.ts b/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.ts index dbdc98115..f459f2fe2 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.ts +++ b/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.ts @@ -21,10 +21,18 @@ export class ShareProductCurrencyStepComponent implements OnInit { ngOnInit() { this.currencyData = this.shareProductsTemplate.currencyOptions; - this.shareProductCurrencyForm.patchValue({ - 'currencyCode': this.currencyData[0].code, - 'digitsAfterDecimal': 2 - }); + if (this.shareProductsTemplate.currency) { + this.shareProductCurrencyForm.patchValue({ + 'currencyCode': this.shareProductsTemplate.currency.code, + 'digitsAfterDecimal': this.shareProductsTemplate.currency.decimalPlaces, + 'inMultiplesOf': this.shareProductsTemplate.currency.inMultiplesOf + }); + } else { + this.shareProductCurrencyForm.patchValue({ + 'currencyCode': this.currencyData[0].code, + 'digitsAfterDecimal': 2 + }); + } } createShareProductCurrencyForm() { diff --git a/src/app/products/share-products/share-product-stepper/share-product-details-step/share-product-details-step.component.ts b/src/app/products/share-products/share-product-stepper/share-product-details-step/share-product-details-step.component.ts index f0f364284..74db087b2 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-details-step/share-product-details-step.component.ts +++ b/src/app/products/share-products/share-product-stepper/share-product-details-step/share-product-details-step.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; @Component({ @@ -8,6 +8,8 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms'; }) export class ShareProductDetailsStepComponent implements OnInit { + @Input() shareProductsTemplate: any; + shareProductDetailsForm: FormGroup; constructor(private formBuilder: FormBuilder) { @@ -15,6 +17,13 @@ export class ShareProductDetailsStepComponent implements OnInit { } ngOnInit() { + if (this.shareProductsTemplate) { + this.shareProductDetailsForm.patchValue({ + 'name': this.shareProductsTemplate.name, + 'shortName': this.shareProductsTemplate.shortName, + 'description': this.shareProductsTemplate.description + }); + } } createShareProductDetailsForm() { diff --git a/src/app/products/share-products/share-product-stepper/share-product-market-price-step/share-product-market-price-step.component.ts b/src/app/products/share-products/share-product-stepper/share-product-market-price-step/share-product-market-price-step.component.ts index d061c1c90..91265f636 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-market-price-step/share-product-market-price-step.component.ts +++ b/src/app/products/share-products/share-product-stepper/share-product-market-price-step/share-product-market-price-step.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input } from '@angular/core'; import { DatePipe } from '@angular/common'; import { FormGroup, FormBuilder, FormArray } from '@angular/forms'; import { MatDialog } from '@angular/material'; @@ -17,6 +17,8 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base'; }) export class ShareProductMarketPriceStepComponent implements OnInit { + @Input() shareProductsTemplate: any; + shareProductMarketPriceForm: FormGroup; displayedColumns: string[] = ['fromDate', 'shareValue', 'actions']; @@ -28,6 +30,9 @@ export class ShareProductMarketPriceStepComponent implements OnInit { } ngOnInit() { + if (this.shareProductsTemplate) { + this.shareProductMarketPriceForm.setControl('marketPricePeriods', this.formBuilder.array((this.shareProductsTemplate.marketPrice))); + } } createShareProductMarketPriceForm() { @@ -40,33 +45,42 @@ export class ShareProductMarketPriceStepComponent implements OnInit { return this.shareProductMarketPriceForm.get('marketPricePeriods') as FormArray; } + setShareProductMarketPriceFormDirty() { + if (this.shareProductMarketPriceForm.pristine) { + this.shareProductMarketPriceForm.markAsDirty(); + } + } + addMarketPricePeriod() { const data = this.getData(); - const addVariationsForBorrowerCycleDialogRef = this.dialog.open(FormDialogComponent, { data }); - addVariationsForBorrowerCycleDialogRef.afterClosed().subscribe((response: any) => { + const addMarketPricePeriodDialogRef = this.dialog.open(FormDialogComponent, { data }); + addMarketPricePeriodDialogRef.afterClosed().subscribe((response: any) => { if (response.data) { this.marketPricePeriods.push(response.data); + this.setShareProductMarketPriceFormDirty(); } }); } editMarketPricePeriod(index: number) { const data = { ...this.getData(this.marketPricePeriods.at(index).value), layout: { addButtonText: 'Edit' } }; - const addVariationsForBorrowerCycleDialogRef = this.dialog.open(FormDialogComponent, { data }); - addVariationsForBorrowerCycleDialogRef.afterClosed().subscribe((response: any) => { + const addMarketPricePeriodDialogRef = this.dialog.open(FormDialogComponent, { data }); + addMarketPricePeriodDialogRef.afterClosed().subscribe((response: any) => { if (response.data) { this.marketPricePeriods.at(index).patchValue(response.data.value); + this.setShareProductMarketPriceFormDirty(); } }); } deleteMarketPricePeriod(index: number) { - const deleteVariationsForBorrowerCycleDialogRef = this.dialog.open(DeleteDialogComponent, { + const deleteMarketPricePeriodDialogRef = this.dialog.open(DeleteDialogComponent, { data: { deleteContext: `this` } }); - deleteVariationsForBorrowerCycleDialogRef.afterClosed().subscribe((response: any) => { + deleteMarketPricePeriodDialogRef.afterClosed().subscribe((response: any) => { if (response.delete) { this.marketPricePeriods.removeAt(index); + this.setShareProductMarketPriceFormDirty(); } }); } diff --git a/src/app/products/share-products/share-product-stepper/share-product-settings-step/share-product-settings-step.component.ts b/src/app/products/share-products/share-product-stepper/share-product-settings-step/share-product-settings-step.component.ts index 45e235b5f..290b85a5c 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-settings-step/share-product-settings-step.component.ts +++ b/src/app/products/share-products/share-product-stepper/share-product-settings-step/share-product-settings-step.component.ts @@ -22,6 +22,17 @@ export class ShareProductSettingsStepComponent implements OnInit { ngOnInit() { this.minimumActivePeriodFrequencyTypeData = this.shareProductsTemplate.minimumActivePeriodFrequencyTypeOptions; this.lockinPeriodFrequencyTypeData = this.shareProductsTemplate.lockinPeriodFrequencyTypeOptions; + + this.shareProductSettingsForm.patchValue({ + 'minimumShares': this.shareProductsTemplate.minimumShares, + 'nominalShares': this.shareProductsTemplate.nominalShares, + 'maximumShares': this.shareProductsTemplate.maximumShares, + 'minimumActivePeriodForDividends': this.shareProductsTemplate.minimumActivePeriod, + 'minimumactiveperiodFrequencyType': this.shareProductsTemplate.minimumActivePeriodForDividendsTypeEnum && this.shareProductsTemplate.minimumActivePeriodForDividendsTypeEnum.id, + 'lockinPeriodFrequency': this.shareProductsTemplate.lockinPeriod, + 'lockinPeriodFrequencyType': this.shareProductsTemplate.lockPeriodTypeEnum && this.shareProductsTemplate.lockPeriodTypeEnum.id, + 'allowDividendCalculationForInactiveClients': this.shareProductsTemplate.allowDividendCalculationForInactiveClients + }); } createShareProductSettingsForm() { diff --git a/src/app/products/share-products/share-product-stepper/share-product-terms-step/share-product-terms-step.component.ts b/src/app/products/share-products/share-product-stepper/share-product-terms-step/share-product-terms-step.component.ts index bd90b3372..84ab1d615 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-terms-step/share-product-terms-step.component.ts +++ b/src/app/products/share-products/share-product-stepper/share-product-terms-step/share-product-terms-step.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { combineLatest } from 'rxjs'; @@ -9,6 +9,8 @@ import { combineLatest } from 'rxjs'; }) export class ShareProductTermsStepComponent implements OnInit { + @Input() shareProductsTemplate: any; + shareProductTermsForm: FormGroup; constructor(private formBuilder: FormBuilder) { @@ -22,6 +24,15 @@ export class ShareProductTermsStepComponent implements OnInit { ]).subscribe(([sharesIssued, unitPrice]: number[]) => { this.shareProductTermsForm.get('shareCapital').setValue(sharesIssued * unitPrice); }); + + if (this.shareProductsTemplate) { + this.shareProductTermsForm.patchValue({ + 'totalShares': this.shareProductsTemplate.totalShares, + 'sharesIssued': this.shareProductsTemplate.totalSharesIssued, + 'unitPrice': this.shareProductsTemplate.unitPrice, + 'shareCapital': this.shareProductsTemplate.shareCapital + }); + } } createShareProductTermsForm() { diff --git a/src/app/products/share-products/view-share-product/view-share-product.component.html b/src/app/products/share-products/view-share-product/view-share-product.component.html index dcf77581f..c4f4a7b62 100644 --- a/src/app/products/share-products/view-share-product/view-share-product.component.html +++ b/src/app/products/share-products/view-share-product/view-share-product.component.html @@ -1,5 +1,5 @@
-