Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amount is optional according to the guidelines #4

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not put EUR if data.amount is 0.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @derhuerst ,

If amount is 0 an error is thrown from a few lines above 'data.amount must be >=0.01 and <=999999999.99.'.

Best,
Tamas

data.purposeCode || '',
data.structuredReference || '',
data.unstructuredReference || '',
Expand Down
Loading