README.md in prawn-swiss_qr_bill-0.4.2 vs README.md in prawn-swiss_qr_bill-0.5.0

- old
+ new

@@ -28,11 +28,11 @@ ```ruby require 'prawn' require 'prawn/swiss_qr_bill' -@qr_data = { +@bill_data = { creditor: { iban: 'CH08 3080 8004 1110 4136 9', address: { name: 'Mischa Schindowski', line1: 'Schybenächerweg 553', @@ -47,25 +47,25 @@ } Prawn::Document.generate('output.pdf', page_size: 'A4') do text 'A Swiss QR bill' - swiss_qr_bill(@qr_data) + swiss_qr_bill(@bill_data) end ``` This will render the Swiss QR-bill at the bottom of the page: ![Swiss QR-bill Example, PDF](./images/sqb_example_01.png) -### Options +### Bill data structure -The following options are available: +The following data structure for the bill can be specified: ```ruby # *: mandatory -@qr_data = { +@bill_data = { creditor: { iban: '<iban>', # * address: { # * type: '<K|S>', # default: K name: '<name>', # * @@ -94,12 +94,40 @@ } ``` If `debtor` or `amount` amount is not given, a box will be printed. +### Options + +Calling `swiss_qr_bill()` method with options: + +```ruby +# ... +Prawn::Document.generate('output.pdf', page_size: 'A4') do + # ... + + # raises InvalidIBANError when @bill_data[:creditor][:iban] is invalid + swiss_qr_bill(@bill_data, validate: true) +end +``` + +Available options: + +| Option | Data type | Description | Default | +| --- | --- | --- | --- | +| `validate` | boolean | Validates IBAN and Reference Number and raises several errors | `false` | + +Errors which can be raised during validation: + +* `MissingIBANError`: When IBAN is missing. +* `InvalidIBANError`: When IBAN is invalid. It checks for CH-IBAN only. +* `InvalidReferenceError`: When reference is invalid. It checks for a valid QRR or SCOR reference + ## Important -This library does not validate (yet) IBAN, reference or the given QR data. +This library can validate IBAN (switzerland only) and reference number (types QRR and SCOR). +It does not however validate, if the given data is fully valid according to the implementation guidelines. + Please refer to the implementation guidelines and the Swiss QR-bill validaton portal by SIX below. ## Contributing