Skip to content

Commit

Permalink
fix(core/forms): form-to-pdf: fix printing of formula fields
Browse files Browse the repository at this point in the history
  • Loading branch information
robzan8 committed Mar 21, 2022
1 parent fae8241 commit 65fd4a7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions projects/core/forms/src/form-to-pdf/form-to-pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,16 @@ function fieldToPdf(
{table: {widths: ['*'], body: [[lookupString(field.name)]]}, margin: [5, 0, 0, 5]},
];
case AjfFieldType.Formula:
const formula = ((field as AjfFormulaField).formula as AjfFormula).formula;
const value = evaluateExpression(formula, context);
const formulaField = field as AjfFormulaField;
let value = lookupString(formulaField.name);
if (value === ' ') {
// If the value of the field is not in the context, recompute the formula.
const formula = formulaField.formula as AjfFormula;
value = String(evaluateExpression(formula.formula, context));
}
return [
borderlessCell(translate(field.label)),
{table: {widths: ['*'], body: [[String(value)]]}, margin: [5, 0, 0, 5]},
{table: {widths: ['*'], body: [[value]]}, margin: [5, 0, 0, 5]},
];
case AjfFieldType.Number:
case AjfFieldType.Boolean:
Expand Down

0 comments on commit 65fd4a7

Please sign in to comment.