diff --git a/src/app/loans/common-resolvers/loans-transaction-reciept.resolver.ts b/src/app/loans/common-resolvers/loans-transaction-reciept.resolver.ts index 9f56f6915..550970566 100644 --- a/src/app/loans/common-resolvers/loans-transaction-reciept.resolver.ts +++ b/src/app/loans/common-resolvers/loans-transaction-reciept.resolver.ts @@ -30,7 +30,7 @@ export class LoansTransactionRecieptResolver implements Resolve { 'output-type': 'PDF', R_transactionId: transactionId }; - return this.reportsService.getPentahoRunReportData({name: 'Loan Transaction Receipt'}, data, 'default', 'en', 'dd MMMM yyyy'); + return this.reportsService.getPentahoRunReportData('Loan Transaction Receipt', data, 'default', 'en', 'dd MMMM yyyy'); } } diff --git a/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.ts b/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.ts index 29fa935a9..35d962a5e 100644 --- a/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.ts +++ b/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.ts @@ -74,7 +74,7 @@ export class ExportTransactionsComponent implements OnInit { R_endDate: this.datePipe.transform(this.transactionsReportForm.value.toDate, 'yyyy-MM-dd'), R_selectLoan: this.loansAccountId }; - this.reportsService.getPentahoRunReportData({ name: 'Client Loan Account Schedule'}, data, 'default', 'en', 'dd MMMM yyyy') + this.reportsService.getPentahoRunReportData('Client Loan Account Schedule', data, 'default', 'en', 'dd MMMM yyyy') .subscribe( (res: any) => { const contentType = res.headers.get('Content-Type'); const file = new Blob([res.body], {type: contentType}); diff --git a/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts b/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts index 6b8fc7f87..6597287d6 100644 --- a/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts +++ b/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts @@ -83,32 +83,34 @@ export class EditBusinessRuleParametersComponent implements OnChanges { } else { // Child Parameter const parent: ReportParameter = this.paramData .find((entry: any) => entry.name === param.parentParameterName); - // TODO: Refactor once Report Parameter Model is updated for multi-child support. - if (parent.childParameter instanceof Array) { - parent.childParameter.push(param); - } else { - parent.childParameter = []; - parent.childParameter.push(param); - } - const parentNames = this.parentParameters.map(parameter => parameter.name); - if (!parentNames.includes(parent.name)) { - this.parentParameters.push(parent); - } else { - const index = parentNames.indexOf(parent.name); - this.parentParameters[index] = parent; - } + parent.childParameters.push(param); + this.updateParentParameters(parent); } }); this.setChildControls(); } + /** + * Updates the array of parent parameters. + * @param {ReportParameter} parent Parent report parameter + */ + updateParentParameters(parent: ReportParameter) { + const parentNames = this.parentParameters.map(parameter => parameter.name); + if (!parentNames.includes(parent.name)) { // Parent's first child. + this.parentParameters.push(parent); + } else { // Parent already has a child + const index = parentNames.indexOf(parent.name); + this.parentParameters[index] = parent; + } + } + /** * Subscribes to changes in parent parameters value, builds child parameter vis-a-vis parent's value. */ setChildControls() { this.parentParameters.forEach((param: ReportParameter) => { this.ReportForm.get(param.name).valueChanges.subscribe((option: any) => { - param.childParameter.forEach((child: ReportParameter) => { + param.childParameters.forEach((child: ReportParameter) => { if (child.displayType === 'none') { this.ReportForm.addControl(child.name, new FormControl(child.defaultVal)); } else { @@ -183,10 +185,10 @@ export class EditBusinessRuleParametersComponent implements OnChanges { * TODO: Replace report object with report name once reports service is refactored. */ getResponseHeaders() { - const report = { name: this.paramValue.reportName }; + const reportName = this.paramValue.reportName; delete this.paramValue.reportName; const formattedResponse = this.formatUserResponse(this.paramValue, true); - this.reportsService.getRunReportData(report, formattedResponse).subscribe( + this.reportsService.getRunReportData(reportName, formattedResponse).subscribe( (response: any) => { this.templateParameters.emit(response.columnHeaders); }, diff --git a/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts b/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts index 66b81a493..8ab0f4bb7 100644 --- a/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts +++ b/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts @@ -69,7 +69,7 @@ export class BusinessRuleParametersComponent implements OnChanges { createRunReportForm() { this.paramData.forEach( (param: any) => { - if (!param.parentParameterName) { // Non Child Parameter + if (!param.parentParameterName) { // Non-Child Parameter this.ReportForm.addControl(param.name, new FormControl('', Validators.required)); if (param.displayType === 'select') { this.fetchSelectOptions(param, param.name); @@ -77,32 +77,34 @@ export class BusinessRuleParametersComponent implements OnChanges { } else { // Child Parameter const parent: ReportParameter = this.paramData .find((entry: any) => entry.name === param.parentParameterName); - // TODO: Refactor once Report Parameter Model is updated for multi-child support. - if (parent.childParameter instanceof Array) { - parent.childParameter.push(param); - } else { - parent.childParameter = []; - parent.childParameter.push(param); - } - const parentNames = this.parentParameters.map(parameter => parameter.name); - if (!parentNames.includes(parent.name)) { - this.parentParameters.push(parent); - } else { - const index = parentNames.indexOf(parent.name); - this.parentParameters[index] = parent; - } + parent.childParameters.push(param); + this.updateParentParameters(parent); } }); this.setChildControls(); } + /** + * Updates the array of parent parameters. + * @param {ReportParameter} parent Parent report parameter + */ + updateParentParameters(parent: ReportParameter) { + const parentNames = this.parentParameters.map(parameter => parameter.name); + if (!parentNames.includes(parent.name)) { // Parent's first child. + this.parentParameters.push(parent); + } else { // Parent already has a child + const index = parentNames.indexOf(parent.name); + this.parentParameters[index] = parent; + } + } + /** * Subscribes to changes in parent parameters value, builds child parameter vis-a-vis parent's value. */ setChildControls() { this.parentParameters.forEach((param: ReportParameter) => { this.ReportForm.get(param.name).valueChanges.subscribe((option: any) => { - param.childParameter.forEach((child: ReportParameter) => { + param.childParameters.forEach((child: ReportParameter) => { if (child.displayType === 'none') { this.ReportForm.addControl(child.name, new FormControl(child.defaultVal)); } else { @@ -168,7 +170,7 @@ export class BusinessRuleParametersComponent implements OnChanges { */ getResponseHeaders() { const formattedresponse = this.formatUserResponse(this.ReportForm.value, true); - this.reportsService.getRunReportData({ name: this.reportName }, formattedresponse).subscribe( + this.reportsService.getRunReportData(this.reportName, formattedresponse).subscribe( (response: any) => { this.templateParameters.emit(response.columnHeaders); }, diff --git a/src/app/pipes/url-to-string.pipe.ts b/src/app/pipes/url-to-string.pipe.ts index f429d341d..cf3b821fc 100644 --- a/src/app/pipes/url-to-string.pipe.ts +++ b/src/app/pipes/url-to-string.pipe.ts @@ -12,11 +12,12 @@ export class UrlToStringPipe implements PipeTransform { transform(url: string): any { url = decodeURIComponent(url); - if (url.includes('search?query')) { - const query = url.substring(url.indexOf('=') + 1, url.indexOf('&')); - return 'Search ' + query; - } const urlSubstrings: string[] = url.slice(1).split('/'); + if (url.includes('?')) { // Query params URL. + const query = urlSubstrings.pop(); + const prefix = query.slice(0, query.indexOf('?')); + urlSubstrings.push(prefix); + } const stringRepresentation = urlSubstrings .map((path: string) => { diff --git a/src/app/reports/common-models/report-parameter.model.ts b/src/app/reports/common-models/report-parameter.model.ts index 38bd53f1d..904fa7565 100644 --- a/src/app/reports/common-models/report-parameter.model.ts +++ b/src/app/reports/common-models/report-parameter.model.ts @@ -12,7 +12,7 @@ export class ReportParameter { parentParameterName: string; inputName: string; selectOptions: any[] = []; - childParameter: any; + childParameters: any[] = []; pentahoName: any; constructor(options: any[]) { diff --git a/src/app/reports/common-resolvers/run-report.resolver.ts b/src/app/reports/common-resolvers/run-report.resolver.ts index 07a18dd99..4a800e849 100644 --- a/src/app/reports/common-resolvers/run-report.resolver.ts +++ b/src/app/reports/common-resolvers/run-report.resolver.ts @@ -20,11 +20,11 @@ export class RunReportResolver implements Resolve { constructor(private reportsService: ReportsService) {} /** - * Returns the reports data. + * Returns the report parameters data. * @returns {Observable} */ resolve(route: ActivatedRouteSnapshot): Observable { - return this.reportsService.getReportParams(route.params['report-name']); + return this.reportsService.getReportParams(route.params['name']); } } diff --git a/src/app/reports/reports-routing.module.ts b/src/app/reports/reports-routing.module.ts index a0ed6357a..ed110dc6c 100644 --- a/src/app/reports/reports-routing.module.ts +++ b/src/app/reports/reports-routing.module.ts @@ -33,35 +33,20 @@ const routes: Routes = [ children: [ { path: '', - component: ReportsComponent, + component: ReportsComponent }, { path: ':filter', data: { routeParamBreadcrumb: 'filter' }, - component: ReportsComponent, - } - ] - }, - { - path: 'run-report', - data: { title: extract('Reports'), breadcrumb: 'Reports' }, - children: [ - { - path: '', - redirectTo: '/reports', pathMatch: 'full' + component: ReportsComponent }, { - path: ':report-name/:report-type/:report-id', - data: { title: extract('Run Report'), routeParamBreadcrumb: 'report-name' }, - children: [ - { - path: '', - component: RunReportComponent, - resolve: { - params: RunReportResolver - } - } - ] + path: 'run/:name', + data: { title: extract('Reports'), routeParamBreadcrumb: 'name' }, + component: RunReportComponent, + resolve: { + reportParameters: RunReportResolver + } } ] }, diff --git a/src/app/reports/reports.component.html b/src/app/reports/reports.component.html index 77f1d602f..572cefbed 100644 --- a/src/app/reports/reports.component.html +++ b/src/app/reports/reports.component.html @@ -28,7 +28,7 @@ - + diff --git a/src/app/reports/reports.service.ts b/src/app/reports/reports.service.ts index f837ac5a1..7f389aa76 100644 --- a/src/app/reports/reports.service.ts +++ b/src/app/reports/reports.service.ts @@ -57,7 +57,7 @@ export class ReportsService { * @param {any} dates start date and end date * @returns {Observable} Mix Report */ - getMixReport(dates: any) { + getMixReport(dates: any): Observable { const httpParams = new HttpParams() .set('startDate', dates.startDate) .set('endDate', dates.endDate); @@ -98,40 +98,40 @@ export class ReportsService { /** * Run Report Data for Table and SMS. - * @param {any} report report object containing 'id', 'name' & 'type' attributes. + * @param {any} reportName report name * @param {object} formData Form Data. * @returns {Observable} */ - getRunReportData(report: any, formData: object): Observable { + getRunReportData(reportName: string, formData: object): Observable { let httpParams = new HttpParams(); for (const [key, value] of Object.entries(formData)) { httpParams = httpParams.set(key, value); } - return this.http.get(`/runreports/${report.name}`, {params: httpParams}); + return this.http.get(`/runreports/${reportName}`, {params: httpParams}); } /** * Run Report Data for Charts. - * @param {any} report report object containing 'id', 'name' & 'type' attributes. + * @param {any} reportName report name * @param {object} formData Form Data. * @returns {Observable} */ - getChartRunReportData(report: any, formData: object): Observable { + getChartRunReportData(reportName: string, formData: object): Observable { let httpParams = new HttpParams(); for (const [key, value] of Object.entries(formData)) { httpParams = httpParams.set(key, value); } - return this.http.get(`/runreports/${report.name}`, {params: httpParams}) + return this.http.get(`/runreports/${reportName}`, {params: httpParams}) .pipe(map((response: any) => new ChartData(response))); } /** * Run Report Data for Pentaho. - * @param {any} report report object containing 'id', 'name' & 'type' attributes. + * @param {any} reportName report name * @param {object} formData Form Data. * @returns {Observable} */ - getPentahoRunReportData(report: any, formData: object, tenantIdentifier: string, locale: string, dateFormat: string): Observable { + getPentahoRunReportData(reportName: string, formData: object, tenantIdentifier: string, locale: string, dateFormat: string): Observable { let httpParams = new HttpParams() .set('tenantIdentifier', tenantIdentifier) .set('locale', locale) @@ -139,7 +139,7 @@ export class ReportsService { for (const [key, value] of Object.entries(formData)) { httpParams = httpParams.set(key, value); } - return this.http.get(`/runreports/${report.name}`, {responseType: 'arraybuffer', observe: 'response', params: httpParams}); + return this.http.get(`/runreports/${reportName}`, {responseType: 'arraybuffer', observe: 'response', params: httpParams}); } } diff --git a/src/app/reports/run-report/chart/chart.component.ts b/src/app/reports/run-report/chart/chart.component.ts index 661c69210..44f05c76b 100644 --- a/src/app/reports/run-report/chart/chart.component.ts +++ b/src/app/reports/run-report/chart/chart.component.ts @@ -43,7 +43,7 @@ export class ChartComponent implements OnChanges { } getRunReportData() { - this.reportsService.getChartRunReportData(this.dataObject.reportData, this.dataObject.formData) + this.reportsService.getChartRunReportData(this.dataObject.report.name, this.dataObject.formData) .subscribe((response: ChartData) => { this.inputData = response; this.setPieChart(this.inputData); diff --git a/src/app/reports/run-report/pentaho/pentaho.component.ts b/src/app/reports/run-report/pentaho/pentaho.component.ts index 73e3765f1..981590158 100644 --- a/src/app/reports/run-report/pentaho/pentaho.component.ts +++ b/src/app/reports/run-report/pentaho/pentaho.component.ts @@ -39,7 +39,7 @@ export class PentahoComponent implements OnChanges { } getRunReportData() { - this.reportsService.getPentahoRunReportData(this.dataObject.reportData, this.dataObject.formData, 'default', 'en', 'dd MMMM yyyy') + this.reportsService.getPentahoRunReportData(this.dataObject.report.name, this.dataObject.formData, 'default', 'en', 'dd MMMM yyyy') .subscribe( (res: any) => { const contentType = res.headers.get('Content-Type'); const file = new Blob([res.body], {type: contentType}); diff --git a/src/app/reports/run-report/run-report.component.html b/src/app/reports/run-report/run-report.component.html index c8d8f433a..63c46c5d8 100644 --- a/src/app/reports/run-report/run-report.component.html +++ b/src/app/reports/run-report/run-report.component.html @@ -2,85 +2,76 @@ -
+ - - -
+ -
- -
- - {{param.label}} - - - {{param.label}} is required - - -
- -
- - {{param.label}} - - - - - {{param.label}} is required - - -
- -
- - {{param.label}} - - + + + + + + {{param.label}} + + + {{param.label}} is required + + + + + {{param.label}} + + + + + {{param.label}} is required + + + + + {{param.label}} + + {{option.name}} - - - - {{param.label}} is required - - -
- -
- -
- -
- - Decimal Places - - 0 - 1 - 2 - 3 - 4 - - -
- -
- - Output Type - - Normal format - Excel format - Excel 2007 format - CSV format - PDF format - - -
+ + + + {{param.label}} is required + + + + + + + + + Decimal Places + + 0 + 1 + 2 + 3 + 4 + + + + + Output Type + + Normal format + Excel format + Excel 2007 format + CSV format + PDF format + +
- diff --git a/src/app/reports/run-report/run-report.component.ts b/src/app/reports/run-report/run-report.component.ts index 123627f6e..494157b69 100644 --- a/src/app/reports/run-report/run-report.component.ts +++ b/src/app/reports/run-report/run-report.component.ts @@ -25,20 +25,23 @@ export class RunReportComponent implements OnInit { minDate = new Date(2000, 0, 1); /** Maximum date allowed. */ maxDate = new Date(); + /** Contains report specifications i.e: name, type and id */ report: any = {}; /** Formatted data post labeling of report parameters fetched from API */ - paramData: any = []; + paramData: ReportParameter[] = []; /** Array of all parent parameters */ parentParameters: any[] = []; /** Parameter data to configure pentaho output */ pentahoReportParameters: any[] = []; /** Data to be passed on to component selectors */ dataObject: any; - /** Initializes new form group 'ReportForm */ - ReportForm = new FormGroup({}); + + /** Initializes new form group eportForm */ + reportForm = new FormGroup({}); /** Static Form control for decimal places in output */ decimalChoice = new FormControl(); + /** Toggles Report form */ isCollapsed = false; /** Toggles Table output. */ @@ -51,18 +54,19 @@ export class RunReportComponent implements OnInit { /** * Fetches report specifications from route params and retrieves report parameters data from `resolve`. * @param {ActivatedRoute} route ActivatedRoute. - * @param {DomSanitizer} sanitizer DomSanitizer. * @param {ReportsService} reportsService ReportsService * @param {DatePipe} datePipe Date Pipe */ constructor(private route: ActivatedRoute, private reportsService: ReportsService, private datePipe: DatePipe) { - this.report.name = this.route.snapshot.params['report-name']; - this.report.type = this.route.snapshot.params['report-type']; - this.report.id = this.route.snapshot.params['report-id']; - this.route.data.subscribe((data: any) => { - this.paramData = data.params; + this.report.name = this.route.snapshot.params['name']; + this.route.queryParams.subscribe((queryParams: { type: any, id: any }) => { + this.report.type = queryParams.type; + this.report.id = queryParams.id; + }); + this.route.data.subscribe((data: { reportParameters: ReportParameter[] }) => { + this.paramData = data.reportParameters; }); } @@ -79,39 +83,39 @@ export class RunReportComponent implements OnInit { */ createRunReportForm() { this.paramData.forEach( - (param: any) => { - if (!param.parentParameterName) { - this.ReportForm.addControl(param.name, new FormControl('', Validators.required)); + (param: ReportParameter) => { + if (!param.parentParameterName) { // Non Child Parameter + this.reportForm.addControl(param.name, new FormControl('', Validators.required)); if (param.displayType === 'select') { this.fetchSelectOptions(param, param.name); } - } else { + } else { // Child Parameter const parent: ReportParameter = this.paramData .find((entry: any) => entry.name === param.parentParameterName); - parent.childParameter = param; - this.parentParameters.push(parent); + parent.childParameters.push(param); + this.updateParentParameters(parent); } }); if (this.report.type === 'Pentaho') { - this.ReportForm.addControl('outputType', new FormControl('')); + this.reportForm.addControl('outputType', new FormControl('')); this.mapPentahoParams(); } this.decimalChoice.patchValue('0'); this.setChildControls(); } - /** - * Fetches Select Dropdown options for param type "Select". - * @param {ReportParameter} param Parameter for which dropdown options are required. - * @param {string} inputstring url substring for API call. - */ - fetchSelectOptions(param: ReportParameter, inputstring: string) { - this.reportsService.getSelectOptions(inputstring).subscribe((options: SelectOption[]) => { - param.selectOptions = options; - if (param.selectAll === 'Y') { - param.selectOptions.push({id: '-1', name: 'All'}); - } - }); + /** + * Updates the array of parent parameters. + * @param {ReportParameter} parent Parent report parameter + */ + updateParentParameters(parent: ReportParameter) { + const parentNames = this.parentParameters.map(parameter => parameter.name); + if (!parentNames.includes(parent.name)) { // Parent's first child. + this.parentParameters.push(parent); + } else { // Parent already has a child + const index = parentNames.indexOf(parent.name); + this.parentParameters[index] = parent; + } } /** @@ -132,16 +136,36 @@ export class RunReportComponent implements OnInit { */ setChildControls() { this.parentParameters.forEach((param: ReportParameter) => { - this.ReportForm.get(param.name).valueChanges.subscribe((option: any) => { - this.ReportForm.addControl(param.childParameter.name, new FormControl('', Validators.required)); - if (param.childParameter.displayType === 'select') { - const inputstring = `${param.childParameter.name}?${param.inputName}=${option.id}`; - this.fetchSelectOptions(param.childParameter, inputstring); - } + this.reportForm.get(param.name).valueChanges.subscribe((option: any) => { + param.childParameters.forEach((child: ReportParameter) => { + if (child.displayType === 'none') { + this.reportForm.addControl(child.name, new FormControl(child.defaultVal)); + } else { + this.reportForm.addControl(child.name, new FormControl('', Validators.required)); + } + if (child.displayType === 'select') { + const inputstring = `${child.name}?${param.inputName}=${option.id}`; + this.fetchSelectOptions(child, inputstring); + } + }); }); }); } + /** + * Fetches Select Dropdown options for param type "Select". + * @param {ReportParameter} param Parameter for which dropdown options are required. + * @param {string} inputstring url substring for API call. + */ + fetchSelectOptions(param: ReportParameter, inputstring: string) { + this.reportsService.getSelectOptions(inputstring).subscribe((options: SelectOption[]) => { + param.selectOptions = options; + if (param.selectAll === 'Y') { + param.selectOptions.push({id: '-1', name: 'All'}); + } + }); + } + /** * Formats user response and readies it for utilization by run report function. * @param {any} response Object containing formcontrol values. @@ -168,6 +192,9 @@ export class RunReportComponent implements OnInit { const dateFormat = 'yyyy-MM-dd'; formattedResponse[newKey] = this.datePipe.transform(value, dateFormat); break; + case 'none': + formattedResponse[newKey] = value; + break; } } return formattedResponse; @@ -178,10 +205,10 @@ export class RunReportComponent implements OnInit { */ run() { this.isCollapsed = true; - const userResponse = this.formatUserResponse(this.ReportForm.value); + const userResponse = this.formatUserResponse(this.reportForm.value); this.dataObject = { formData: userResponse, - reportData: this.report, + report: this.report, decimalChoice: this.decimalChoice.value }; switch (this.report.type) { diff --git a/src/app/reports/run-report/table-and-sms/table-and-sms.component.html b/src/app/reports/run-report/table-and-sms/table-and-sms.component.html index d1869fb3c..e813e6918 100644 --- a/src/app/reports/run-report/table-and-sms/table-and-sms.component.html +++ b/src/app/reports/run-report/table-and-sms/table-and-sms.component.html @@ -1,6 +1,6 @@
-
+
diff --git a/src/app/reports/run-report/table-and-sms/table-and-sms.component.ts b/src/app/reports/run-report/table-and-sms/table-and-sms.component.ts index 0c987c7cf..f612a1fce 100644 --- a/src/app/reports/run-report/table-and-sms/table-and-sms.component.ts +++ b/src/app/reports/run-report/table-and-sms/table-and-sms.component.ts @@ -52,7 +52,7 @@ export class TableAndSmsComponent implements OnChanges { } getRunReportData() { - this.reportsService.getRunReportData(this.dataObject.reportData, this.dataObject.formData) + this.reportsService.getRunReportData(this.dataObject.report.name, this.dataObject.formData) .subscribe( (res: any) => { this.csvData = res.data; this.setOutputTable(res.data); @@ -85,7 +85,7 @@ export class TableAndSmsComponent implements OnChanges { csv = csv.join('\r\n'); const link = document.createElement('a'); link.setAttribute('href', encodeURI(csv)); - link.setAttribute('download', `${this.dataObject.reportData.name}.csv`); + link.setAttribute('download', `${this.dataObject.report.name}.csv`); document.body.appendChild(link); link.click(); document.body.removeChild(link); diff --git a/src/app/reports/xbrl/xbrl.component.ts b/src/app/reports/xbrl/xbrl.component.ts index 36c683620..99553b82e 100644 --- a/src/app/reports/xbrl/xbrl.component.ts +++ b/src/app/reports/xbrl/xbrl.component.ts @@ -44,7 +44,7 @@ export class XBRLComponent implements OnInit, AfterViewInit { private reportService: ReportsService) { this.route.data.subscribe(( data: { mixtaxonomy: any, mixmapping: any, glAccounts: any }) => { this.mixtaxonomyArray = data.mixtaxonomy; - this.mixMappingJson = data.mixmapping.config; + this.mixMappingJson = data.mixmapping.config || JSON.stringify({}); this.glAccounts = data.glAccounts; }); } @@ -67,7 +67,7 @@ export class XBRLComponent implements OnInit, AfterViewInit { * Subscribe to taxonomy's value changes and filters options accordingly. */ ngAfterViewInit() { - this.mixtaxonomyArray.forEach( (taxonomy: any) => { + this.mixtaxonomyArray.forEach((taxonomy: any) => { taxonomy.mapping?.valueChanges.subscribe( (value: string) => { this.filteredGlAccounts = this.applyFilter(value); }); @@ -78,13 +78,11 @@ export class XBRLComponent implements OnInit, AfterViewInit { * Maps Taxonomy to it's value and add's formcontrol. */ createMappings() { - if (this.mixMappingJson !== undefined && this.mixMappingJson.length > 0) { - this.mixtaxonomyArray.forEach( (taxonomy: any) => { - const mapping = JSON.parse(this.mixMappingJson)[taxonomy.id]; - taxonomy.mapping = new FormControl(''); - taxonomy.mapping.value = mapping; - }); - } + this.mixtaxonomyArray.forEach((taxonomy: any) => { + const mapping = JSON.parse(this.mixMappingJson)[taxonomy.id]; + taxonomy.mapping = new FormControl(''); + taxonomy.mapping.value = mapping || ''; + }); } /** diff --git a/src/app/savings/common-resolvers/savings-transaction-reciept.resolver.ts b/src/app/savings/common-resolvers/savings-transaction-reciept.resolver.ts index 4aaa5a2dd..3bfec5425 100644 --- a/src/app/savings/common-resolvers/savings-transaction-reciept.resolver.ts +++ b/src/app/savings/common-resolvers/savings-transaction-reciept.resolver.ts @@ -30,7 +30,7 @@ export class SavingsTransactionRecieptResolver implements Resolve { 'output-type': 'PDF', R_transactionId: transactionId }; - return this.reportsService.getPentahoRunReportData({name: 'Savings Transaction Receipt'}, data, 'default', 'en', 'dd MMMM yyyy'); + return this.reportsService.getPentahoRunReportData('Savings Transaction Receipt', data, 'default', 'en', 'dd MMMM yyyy'); } } diff --git a/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.ts b/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.ts index c8164c226..deff9dc69 100644 --- a/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.ts +++ b/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.ts @@ -74,7 +74,7 @@ export class ExportTransactionsComponent implements OnInit { R_endDate: this.datePipe.transform(this.transactionsReportForm.value.toDate, 'yyyy-MM-dd'), R_savingsAccountId: this.savingsAccountId }; - this.reportsService.getPentahoRunReportData({name: 'Client Saving Transactions'}, data, 'default', 'en', 'dd MMMM yyyy') + this.reportsService.getPentahoRunReportData('Client Saving Transactions', data, 'default', 'en', 'dd MMMM yyyy') .subscribe( (res: any) => { const contentType = res.headers.get('Content-Type'); const file = new Blob([res.body], {type: contentType});