diff --git a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts index bb81e269d9b3f8186ab10d25827336913ec0edb3..dd842382b884388bd15995e072e128773a338fd9 100644 --- a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts +++ b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts @@ -5,6 +5,7 @@ import { ApplicationSetupService } from "../../services/app-setup/app-setup.serv import { I18nService } from "../../services/internationalisation/internationalisation.service"; import { sprintf } from "sprintf-js"; +import { round } from "jalhyd"; @Component({ selector: "dialog-generate-pab", @@ -28,9 +29,9 @@ export class DialogGeneratePABComponent { @Inject(MAT_DIALOG_DATA) public data: any ) { const nDigits = this.appSetupService.displayDigits; - this.coteAmont = Number(data.coteAmont.toFixed(nDigits)); - this.debit = Number(data.debit.toFixed(nDigits)); - this.chute = Number(data.chute.toFixed(nDigits)); + this.coteAmont = round(data.coteAmont, nDigits); + this.debit = round(data.debit, nDigits); + this.chute = round(data.chute, nDigits); } public generatePAB() { diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts index cf4561da10fcce41d95e7ab5b6cfad5a9c1e0a81..edb78086f53ff176ba4522ae3daa7ee2f1ee6bc3 100644 --- a/src/app/components/pab-table/pab-table.component.ts +++ b/src/app/components/pab-table/pab-table.component.ts @@ -11,7 +11,8 @@ import { Nub, Structure, ParallelStructure, - ParamDefinition + ParamDefinition, + round } from "jalhyd"; import { sprintf } from "sprintf-js"; @@ -435,6 +436,21 @@ export class PabTableComponent implements AfterViewInit, OnInit { private refresh() { const maxNbDevices = this.findMaxNumberOfDevices(); + // adjuste precision once before anything else + const nDigits = this.appSetupService.displayDigits; + for (const c of this.model.children) { + for (const p of c.parameterIterator) { + if (p.visible) { + p.singleValue = round(p.singleValue, nDigits); + } + } + } + for (const p of this.model.downWall.parameterIterator) { + if (p.visible) { + p.singleValue = round(p.singleValue, nDigits); + } + } + // 0. build spanned headers over real columns this.headers = []; // 1 header for basin @@ -1146,7 +1162,7 @@ export class PabTableComponent implements AfterViewInit, OnInit { let currentValue: number = result.variableDetails.first; for (let i = 0; i < result.variableDetails.occurrences - 2; i++) { currentValue += step; - interpolatedValues.push(Number(currentValue.toFixed(nDigits))); + interpolatedValues.push(round(currentValue, nDigits)); } interpolatedValues.push(result.variableDetails.last); // apply