From a42665e463e21dc1edab4cce0e8ef493e161d493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Sch=C3=B6nb=C3=A4chler?= Date: Sat, 27 Jun 2020 19:41:51 +0200 Subject: [PATCH] Fixed invalid amount field when the second decimal place is a zero --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 31cfa9e..65c639d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -769,7 +769,7 @@ module SwissQRBill { if(this._data.amount !== undefined){ if(typeof this._data.amount !== "number"){ throw new Error("Amount must be a number."); } - if(this._data.amount.toString().length > 12){ throw new Error("Amount must be a maximum of 12 digits."); } + if(this._data.amount.toFixed(2).toString().length > 12){ throw new Error("Amount must be a maximum of 12 digits."); } } @@ -974,7 +974,7 @@ module SwissQRBill { //-- Amount if(this._data.amount !== undefined){ - qrString += this._data.amount + "\n"; + qrString += this._data.amount.toFixed(2) + "\n"; } else { qrString += "\n"; }