Skip to content

Commit

Permalink
Amount is optional according to https://www.europeanpaymentscouncil.e…
Browse files Browse the repository at this point in the history
  • Loading branch information
moltam89 committed Oct 20, 2023
1 parent 390c9bc commit 785184a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ const generateQrCode = data => {
}

// > AT-04 Amount of the Credit Transfer in Euro
if ('number' !== typeof data.amount) throw new Error('data.amount must be a number.')
if (data.amount < 0.01 || data.amount > 999999999.99) {
throw new Error('data.amount must be >=0.01 and <=999999999.99.')
if ('amount' in data) {
if ('number' !== typeof data.amount) throw new Error('data.amount must be a number.')
if (data.amount < 0.01 || data.amount > 999999999.99) {
throw new Error('data.amount must be >=0.01 and <=999999999.99.')
}
}

// > AT-44 Purpose of the Credit Transfer
Expand Down Expand Up @@ -77,7 +79,7 @@ const generateQrCode = data => {
data.bic,
data.name,
serializeIBAN(data.iban),
'EUR' + data.amount.toFixed(2),
data.amount ? 'EUR' + data.amount.toFixed(2) : data.amount,
data.purposeCode || '',
data.structuredReference || '',
data.unstructuredReference || '',
Expand Down

0 comments on commit 785184a

Please sign in to comment.