Skip to content

Commit

Permalink
Fixed invalid amount field when the second decimal place is a zero
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Jun 27, 2020
1 parent 0ba0130 commit a42665e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."); }
}


Expand Down Expand Up @@ -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";
}
Expand Down

0 comments on commit a42665e

Please sign in to comment.