qr-bills 0.2.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/locales/qrbills.de.yml +17 -0
- data/config/locales/qrbills.en.yml +17 -0
- data/config/locales/qrbills.fr.yml +17 -0
- data/config/locales/qrbills.it.yml +17 -0
- data/lib/qr-bills/qr-creditor-reference.rb +4 -1
- data/lib/qr-bills/qr-exceptions.rb +1 -1
- data/lib/qr-bills/qr-generator.rb +5 -17
- data/lib/qr-bills/qr-html-layout.rb +18 -18
- data/lib/qr-bills/qr-params.rb +54 -27
- data/lib/qr-bills.rb +18 -27
- metadata +10 -30
- data/config/locales/de.yml +0 -15
- data/config/locales/en.yml +0 -15
- data/config/locales/fr.yml +0 -15
- data/config/locales/it.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c379f6c4844f31719b53df71799350a2954dee43d2dbf30a3e108f69e43c11f
|
4
|
+
data.tar.gz: 5db69665c2ab6dd0cd015142355672df933fdd81341060e1847506bffa52eb65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe5e97015827d9ea7c32be101750a1f590786a5ae1be0feead8f0281c717238e31a039797b493f94d82bb89496e02e981fce36813a6ed5fd67b5eb41ae8dc8ae
|
7
|
+
data.tar.gz: ad2afb28c3790e3e66b4ff201803a452cf5173ff6dd40d408c40f8c506e108349eeda54c41fe7500b04c1b49359a06f5d2b00dbffd8f2d2594fa7235f0b84a8f
|
@@ -0,0 +1,17 @@
|
|
1
|
+
de:
|
2
|
+
qrbills:
|
3
|
+
payment_part: Zahlteil
|
4
|
+
account: Konto
|
5
|
+
payable_to: Zahlbar an
|
6
|
+
reference: Referenz
|
7
|
+
additional_information: zusätzliche Informationen
|
8
|
+
further_information: weitere Informationen
|
9
|
+
currency: Währung
|
10
|
+
amount: Betrag
|
11
|
+
receipt: Empfangsschein
|
12
|
+
acceptance_point: Annahmestelle
|
13
|
+
separate_before_paying_in: Vor der Einzahlung abzutrennen
|
14
|
+
payable_by: Zahlbar durch
|
15
|
+
payable_by_name_addr: Zahlbar durch (Name/Adresse)
|
16
|
+
in_favour_of: Zugunsten
|
17
|
+
name: Name
|
@@ -0,0 +1,17 @@
|
|
1
|
+
en:
|
2
|
+
qrbills:
|
3
|
+
payment_part: payment part
|
4
|
+
account: account
|
5
|
+
payable_to: payable to
|
6
|
+
reference: reference
|
7
|
+
additional_information: additional information
|
8
|
+
further_information: further information
|
9
|
+
currency: currency
|
10
|
+
amount: amount
|
11
|
+
receipt: receipt
|
12
|
+
acceptance_point: acceptance point
|
13
|
+
separate_before_paying_in: separate before paying in
|
14
|
+
payable_by: payable by
|
15
|
+
payable_by_name_addr: payable by (name/address)
|
16
|
+
in_favour_of: in favour of
|
17
|
+
name: nom
|
@@ -0,0 +1,17 @@
|
|
1
|
+
fr:
|
2
|
+
qrbills:
|
3
|
+
payment_part: section paiement
|
4
|
+
account: compte
|
5
|
+
payable_to: payable à
|
6
|
+
reference: référence
|
7
|
+
additional_information: informations additionnelles
|
8
|
+
further_information: informations supplémentaires
|
9
|
+
currency: monnaie
|
10
|
+
amount: montant
|
11
|
+
receipt: récépissé
|
12
|
+
acceptance_point: èpomt de dépôt
|
13
|
+
separate_before_paying_in: à détacher avant le versement
|
14
|
+
payable_by: payable par
|
15
|
+
payable_by_name_addr: payable par (nom/adresse)
|
16
|
+
in_favour_of: en faveur de
|
17
|
+
name: name
|
@@ -0,0 +1,17 @@
|
|
1
|
+
it:
|
2
|
+
qrbills:
|
3
|
+
payment_part: "sezione pagamento"
|
4
|
+
account: conto
|
5
|
+
payable_to: "pagabile a"
|
6
|
+
reference: riferimento
|
7
|
+
additional_information: "informazioni aggiuntive"
|
8
|
+
further_information: "informazioni supplementari"
|
9
|
+
currency: valuta
|
10
|
+
amount: importo
|
11
|
+
receipt: ricevuta
|
12
|
+
acceptance_point: "punto di accettazione"
|
13
|
+
separate_before_paying_in: "da staccare prima del versamento"
|
14
|
+
payable_by: pagabile da
|
15
|
+
payable_by_name_addr: pagabile da (nome/indirizzo)
|
16
|
+
in_favour_of: a favore di
|
17
|
+
name: nome
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'qr-bills/qr-exceptions'
|
2
2
|
|
3
3
|
# implement Creditor Reference ISO 11649 generator
|
4
|
-
|
4
|
+
module QRCreditorReference
|
5
5
|
PREFIX = "RF"
|
6
6
|
|
7
|
+
# chars values to calculate the check code
|
7
8
|
@char_values = {
|
8
9
|
"A": 10,
|
9
10
|
"B": 11,
|
@@ -56,6 +57,8 @@ class QRCreditorReference
|
|
56
57
|
reference_val += @char_values["R".to_sym].to_s + @char_values["F".to_sym].to_s + "00"
|
57
58
|
|
58
59
|
# get check code
|
60
|
+
# when performing the validation of the check code (n % 97)
|
61
|
+
# the remainder must be equal to 1, thus the 98
|
59
62
|
check_code = 98 - (reference_val.to_i % 97)
|
60
63
|
|
61
64
|
if check_code < 10
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'rqrcode'
|
2
|
-
require 'rmagick'
|
3
|
-
include Magick
|
4
2
|
|
5
|
-
|
3
|
+
module QRGenerator
|
6
4
|
# payload:
|
7
5
|
# "SPC\r\n" + # indicator for swiss qr code: SPC (swiss payments code)
|
8
6
|
# "0200\r\n" + # version of the specifications, 0200 = v2.0
|
@@ -39,11 +37,6 @@ class QRGenerator
|
|
39
37
|
# "eBill/B/41010560425610173"; # alternative scheme paramaters, max 100 chars
|
40
38
|
|
41
39
|
def self.create(params, qrcode_path)
|
42
|
-
create_qr(params, qrcode_path)
|
43
|
-
add_swiss_cross(qrcode_path, qrcode_path)
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.create_qr(params, qrcode_path)
|
47
40
|
payload = "SPC\r\n"
|
48
41
|
payload += "0200\r\n"
|
49
42
|
payload += "1\r\n"
|
@@ -76,7 +69,7 @@ class QRGenerator
|
|
76
69
|
payload += "#{params[:bill_params][:additionally_information]}\r\n"
|
77
70
|
payload += "EPD\r\n"
|
78
71
|
payload += "#{params[:bill_params][:bill_information_coded]}\r\n"
|
79
|
-
payload += "#{params[:bill_params][:
|
72
|
+
payload += "#{params[:bill_params][:alternative_scheme_parameters]}\r\n"
|
80
73
|
|
81
74
|
qrcode = RQRCode::QRCode.new(payload)
|
82
75
|
|
@@ -93,13 +86,8 @@ class QRGenerator
|
|
93
86
|
size: 1024,
|
94
87
|
)
|
95
88
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
def self.add_swiss_cross(qrcode_path, final_path)
|
100
|
-
qr_image = Image.read(qrcode_path)[0]
|
101
|
-
swiss_cross = Image.read(File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/images/swiss_cross.png"))[0]
|
102
|
-
final_qr = qr_image.composite(swiss_cross, CenterGravity, OverCompositeOp)
|
103
|
-
final_qr.write(final_path)
|
89
|
+
swiss_cross = ChunkyPNG::Image.from_file(File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/images/swiss_cross.png"))
|
90
|
+
final_qr = png.compose!(swiss_cross, (png.width - swiss_cross.width) / 2, (png.height - swiss_cross.height) / 2)
|
91
|
+
final_qr.save(qrcode_path)
|
104
92
|
end
|
105
93
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'qr-bills/qr-generator'
|
2
2
|
|
3
|
-
|
3
|
+
module QRHTMLLayout
|
4
4
|
|
5
5
|
def self.create(params)
|
6
6
|
QRGenerator.create(params, params[:qrcode_filepath])
|
@@ -10,8 +10,8 @@ class QRHTMLLayout
|
|
10
10
|
def self.html_layout(params)
|
11
11
|
layout = "<div class=\"bill_container\">\n"
|
12
12
|
layout += " <div class=\"receipt_section\">\n"
|
13
|
-
layout += " <div class=\"title\">#{I18n.t(
|
14
|
-
layout += " <div class=\"subtitle payable_to\">#{I18n.t(
|
13
|
+
layout += " <div class=\"title\">#{I18n.t("qrbills.receipt").capitalize}</div>\n"
|
14
|
+
layout += " <div class=\"subtitle payable_to\">#{I18n.t("qrbills.account").capitalize} / #{I18n.t("qrbills.payable_to").capitalize}</div>\n"
|
15
15
|
layout += " <div class=\"qrcontent\">\n"
|
16
16
|
layout += " #{params[:bill_params][:creditor][:iban]}<br/>\n"
|
17
17
|
layout += " #{params[:bill_params][:creditor][:address][:name]}<br/>\n"
|
@@ -21,14 +21,14 @@ class QRHTMLLayout
|
|
21
21
|
layout += " <div><br/></div>\n"
|
22
22
|
|
23
23
|
if !params[:bill_params][:reference].nil? && !params[:bill_params][:reference].empty?
|
24
|
-
layout += " <div class=\"subtitle reference\">#{I18n.t(
|
24
|
+
layout += " <div class=\"subtitle reference\">#{I18n.t("qrbills.reference").capitalize}</div>\n"
|
25
25
|
layout += " <div class=\"reference\">\n"
|
26
26
|
layout += " #{params[:bill_params][:reference]}<br/>\n"
|
27
27
|
layout += " </div>\n"
|
28
28
|
layout += " <div><br/></div>\n"
|
29
29
|
end
|
30
30
|
|
31
|
-
layout += " <div class=\"subtitle payable_by\">#{I18n.t(
|
31
|
+
layout += " <div class=\"subtitle payable_by\">#{I18n.t("qrbills.payable_by").capitalize}</div>\n"
|
32
32
|
layout += " <div class=\"payable_by\">\n"
|
33
33
|
layout += " #{params[:bill_params][:debtor][:address][:name]}<br/>\n"
|
34
34
|
layout += " #{params[:bill_params][:debtor][:address][:line1]} #{params[:bill_params][:debtor][:address][:line2]}<br/>\n"
|
@@ -37,33 +37,33 @@ class QRHTMLLayout
|
|
37
37
|
|
38
38
|
layout += " <div class=\"amount\">\n"
|
39
39
|
layout += " <div class=\"currency\">\n"
|
40
|
-
layout += " <span class=\"amount_header subtitle\">#{I18n.t(
|
40
|
+
layout += " <span class=\"amount_header subtitle\">#{I18n.t("qrbills.currency").capitalize}</span><br/>\n"
|
41
41
|
layout += " #{params[:bill_params][:currency]}<br/>\n"
|
42
42
|
layout += " </div>\n"
|
43
43
|
|
44
44
|
layout += " <div class=\"amount_value\">\n"
|
45
|
-
layout += " <span class=\"amount_header subtitle\">#{I18n.t(
|
45
|
+
layout += " <span class=\"amount_header subtitle\">#{I18n.t("qrbills.amount").capitalize}</span><br/>\n"
|
46
46
|
layout += " #{params[:bill_params][:amount]}<br/>\n"
|
47
47
|
layout += " </div>\n"
|
48
48
|
layout += " </div>\n"
|
49
49
|
|
50
50
|
layout += " <div class=\"acceptance_point\">\n"
|
51
|
-
layout += " #{I18n.t(
|
51
|
+
layout += " #{I18n.t("qrbills.acceptance_point").capitalize}<br/>\n"
|
52
52
|
layout += " </div>\n"
|
53
53
|
|
54
54
|
layout += " </div>\n"
|
55
55
|
layout += " <div class=\"payment_section\">\n"
|
56
56
|
layout += " <div class=\"left_column\">\n"
|
57
|
-
layout += " <div class=\"title\">#{I18n.t(
|
57
|
+
layout += " <div class=\"title\">#{I18n.t("qrbills.payment_part").capitalize}</div>\n"
|
58
58
|
layout += " <div class=\"qr_code\"><img src=\"#{params[:qrcode_filepath]}\" /></div>\n"
|
59
59
|
layout += " <div class=\"amount\">\n"
|
60
60
|
layout += " <div class=\"currency\">\n"
|
61
|
-
layout += " <span class=\"amount_header subtitle\">#{I18n.t(
|
61
|
+
layout += " <span class=\"amount_header subtitle\">#{I18n.t("qrbills.currency").capitalize}</span><br/>\n"
|
62
62
|
layout += " #{params[:bill_params][:currency]}<br/>\n"
|
63
63
|
layout += " </div>\n"
|
64
64
|
|
65
65
|
layout += " <div class=\"amount_value\">\n"
|
66
|
-
layout += " <span class=\"amount_header subtitle\">#{I18n.t(
|
66
|
+
layout += " <span class=\"amount_header subtitle\">#{I18n.t("qrbills.amount").capitalize}</span><br/>\n"
|
67
67
|
layout += " #{params[:bill_params][:amount]}<br/>\n"
|
68
68
|
layout += " </div>\n"
|
69
69
|
layout += " </div>\n"
|
@@ -71,17 +71,17 @@ class QRHTMLLayout
|
|
71
71
|
layout += " <div class=\"further_information\">\n"
|
72
72
|
|
73
73
|
if !params[:bill_params][:bill_information_coded].nil? && !params[:bill_params][:bill_information_coded].empty?
|
74
|
-
layout += " <span class=\"finfo_header\"
|
74
|
+
layout += " <span class=\"finfo_header\">#{I18n.t("qrbills.name").capitalize} AV1:</span> #{params[:bill_params][:bill_information_coded]}\n"
|
75
75
|
end
|
76
76
|
|
77
|
-
if !params[:bill_params][:
|
78
|
-
layout += " <span class=\"finfo_header\"
|
77
|
+
if !params[:bill_params][:alternative_scheme_parameters].nil? && !params[:bill_params][:alternative_scheme_parameters].empty?
|
78
|
+
layout += " <span class=\"finfo_header\">#{I18n.t("qrbills.name").capitalize} AV2:</span> #{params[:bill_params][:alternative_scheme_parameters]}\n"
|
79
79
|
end
|
80
80
|
|
81
81
|
layout += " </div>\n"
|
82
82
|
layout += " </div>\n"
|
83
83
|
layout += " <div class=\"right_column\">\n"
|
84
|
-
layout += " <div class=\"subtitle payable_to\">#{I18n.t(
|
84
|
+
layout += " <div class=\"subtitle payable_to\">#{I18n.t("qrbills.account").capitalize} / #{I18n.t("qrbills.payable_to").capitalize}</div>\n"
|
85
85
|
layout += " <div class=\"qrcontent\">\n"
|
86
86
|
layout += " #{params[:bill_params][:creditor][:iban]}<br/>\n"
|
87
87
|
layout += " #{params[:bill_params][:creditor][:address][:name]}<br/>\n"
|
@@ -91,7 +91,7 @@ class QRHTMLLayout
|
|
91
91
|
layout += " <div><br/></div>\n"
|
92
92
|
|
93
93
|
if !params[:bill_params][:reference].nil? && !params[:bill_params][:reference].empty?
|
94
|
-
layout += " <div class=\"subtitle reference\">#{I18n.t(
|
94
|
+
layout += " <div class=\"subtitle reference\">#{I18n.t("qrbills.reference").capitalize}</div>\n"
|
95
95
|
layout += " <div class=\"reference\">\n"
|
96
96
|
layout += " #{params[:bill_params][:reference]}<br/>\n"
|
97
97
|
layout += " </div>\n"
|
@@ -99,14 +99,14 @@ class QRHTMLLayout
|
|
99
99
|
end
|
100
100
|
|
101
101
|
if !params[:bill_params][:additionally_information].nil? && !params[:bill_params][:additionally_information].empty?
|
102
|
-
layout += " <div class=\"subtitle additional_information\">#{I18n.t(
|
102
|
+
layout += " <div class=\"subtitle additional_information\">#{I18n.t("qrbills.additional_information").capitalize}</div>\n"
|
103
103
|
layout += " <div class=\"additional_information\">\n"
|
104
104
|
layout += " #{params[:bill_params][:additionally_information]}<br/>\n"
|
105
105
|
layout += " </div>\n"
|
106
106
|
layout += " <div><br/></div>\n"
|
107
107
|
end
|
108
108
|
|
109
|
-
layout += " <div class=\"subtitle payable_by\">#{I18n.t(
|
109
|
+
layout += " <div class=\"subtitle payable_by\">#{I18n.t("qrbills.payable_by").capitalize}</div>\n"
|
110
110
|
layout += " <div class=\"payable_by\">\n"
|
111
111
|
layout += " #{params[:bill_params][:debtor][:address][:name]}<br/>\n"
|
112
112
|
layout += " #{params[:bill_params][:debtor][:address][:line1]} #{params[:bill_params][:debtor][:address][:line2]}<br/>\n"
|
data/lib/qr-bills/qr-params.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
module QRParams
|
2
2
|
QR_BILL_WITH_QR_REFERENCE = "orange_with_reference"
|
3
3
|
QR_BILL_WITH_CREDITOR_REFERENCE = "red_with_reference"
|
4
|
-
|
4
|
+
QR_BILL_WITHOUT_REFERENCE = "red_without_reference"
|
5
5
|
|
6
6
|
def self.get_qr_params
|
7
7
|
{
|
@@ -24,7 +24,7 @@ class QRParams
|
|
24
24
|
reference: "", # qr reference or creditor reference (iso-11649)
|
25
25
|
additionally_information: "",
|
26
26
|
bill_information_coded: "",
|
27
|
-
|
27
|
+
alternative_scheme_parameters: "",
|
28
28
|
creditor: {
|
29
29
|
address: {
|
30
30
|
type: "S",
|
@@ -56,43 +56,70 @@ class QRParams
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.valid?(params)
|
59
|
-
|
59
|
+
return false unless params.key?(:bill_type)
|
60
|
+
return false unless QRParams.base_params_valid?(params)
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
return QRParams.qr_bill_with_creditor_reference_valid?(params)
|
69
|
-
elsif params[:bill_type] == QR_BILL_WITOUTH_REFERENCE
|
70
|
-
return QRParams.qr_bill_without_reference_valid?(params)
|
71
|
-
else
|
72
|
-
return false
|
73
|
-
end
|
62
|
+
case params[:bill_type]
|
63
|
+
when QRParams::QR_BILL_WITH_QR_REFERENCE
|
64
|
+
QRParams.qr_bill_with_qr_reference_valid?(params)
|
65
|
+
when QRParams::QR_BILL_WITH_CREDITOR_REFERENCE
|
66
|
+
QRParams.qr_bill_with_creditor_reference_valid?(params)
|
67
|
+
when QRParams::QR_BILL_WITHOUT_REFERENCE
|
68
|
+
QRParams.qr_bill_without_reference_valid?(params)
|
74
69
|
else
|
75
|
-
|
70
|
+
false
|
76
71
|
end
|
77
72
|
end
|
78
|
-
|
73
|
+
|
79
74
|
def self.base_params_valid?(params)
|
80
|
-
|
81
|
-
|
75
|
+
if params[:bill_type] == "" || params[:bill_type] == nil
|
76
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: bill type cannot be blank"
|
77
|
+
end
|
78
|
+
|
79
|
+
if params[:qrcode_filepath] == "" || params[:qrcode_filepath] == nil
|
80
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: qrcode_filepath cannot be blank"
|
81
|
+
end
|
82
|
+
|
83
|
+
if params[:bill_params][:currency] == "" || params[:bill_params][:currency] == nil
|
84
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: currency cannot be blank"
|
85
|
+
end
|
86
|
+
|
87
|
+
true
|
82
88
|
end
|
83
89
|
|
84
90
|
def self.qr_bill_with_qr_reference_valid?(params)
|
85
|
-
|
86
|
-
|
91
|
+
if params[:bill_params][:reference_type] != "QRR"
|
92
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference type must be 'QRR' for QR bill with standard reference"
|
93
|
+
end
|
94
|
+
|
95
|
+
if params[:bill_params][:reference] == "" || params[:bill_params][:reference] == nil
|
96
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference cannot be blank for QR bill with standard reference"
|
97
|
+
end
|
98
|
+
|
99
|
+
true
|
87
100
|
end
|
88
101
|
|
89
102
|
def self.qr_bill_with_creditor_reference_valid?(params)
|
90
|
-
|
91
|
-
|
103
|
+
if params[:bill_params][:reference_type] != "SCOR"
|
104
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference type must be 'SCOR' for QR bill with (new) creditor reference"
|
105
|
+
end
|
106
|
+
|
107
|
+
if params[:bill_params][:reference] == "" || params[:bill_params][:reference] == nil
|
108
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference cannot be blank for QR bill with (new) creditor reference"
|
109
|
+
end
|
110
|
+
|
111
|
+
true
|
92
112
|
end
|
93
113
|
|
94
114
|
def self.qr_bill_without_reference_valid?(params)
|
95
|
-
|
96
|
-
|
115
|
+
if params[:bill_params][:reference_type] != "NON"
|
116
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference type must be 'NON' for QR bill without reference"
|
117
|
+
end
|
118
|
+
|
119
|
+
if params[:bill_params][:reference] != ""
|
120
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference must be blank for QR bill without reference"
|
121
|
+
end
|
122
|
+
|
123
|
+
true
|
97
124
|
end
|
98
125
|
end
|
data/lib/qr-bills.rb
CHANGED
@@ -4,41 +4,32 @@ require 'qr-bills/qr-params'
|
|
4
4
|
require 'qr-bills/qr-html-layout'
|
5
5
|
require 'qr-bills/qr-creditor-reference'
|
6
6
|
|
7
|
-
|
7
|
+
module QRBills
|
8
8
|
def self.generate(qr_params)
|
9
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: bill type param not set" unless qr_params.has_key?(:bill_type)
|
10
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: validation failed" unless QRParams.valid?(qr_params)
|
9
11
|
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
if !QRParams.valid?(qr_params)
|
14
|
-
raise QRExceptions::INVALID_PARAMETERS + ": params validation check failed"
|
15
|
-
end
|
12
|
+
# init translator sets
|
13
|
+
%i[it en de fr].each do |locale|
|
14
|
+
locale_file = File.join(qr_params[:locales][:path], "qrbills.#{locale}.yml")
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
16
|
+
I18n.load_path << locale_file
|
17
|
+
end
|
20
18
|
|
19
|
+
output = case qr_params[:output_params][:format]
|
20
|
+
when 'html'
|
21
|
+
QRHTMLLayout.create(qr_params)
|
22
|
+
when 'qrcode_png'
|
23
|
+
QRGenerator.create(qr_params, qr_params[:qrcode_filepath])
|
21
24
|
else
|
22
|
-
raise QRExceptions::
|
25
|
+
raise ArgumentError, "#{QRExceptions::NOT_SUPPORTED}: #{qr_params[:output_params][:format]} is not yet supported"
|
23
26
|
end
|
24
27
|
|
25
|
-
|
26
|
-
I18n.load_path << File.join(qr_params[:locales][:path], "it.yml")
|
27
|
-
I18n.load_path << File.join(qr_params[:locales][:path], "en.yml")
|
28
|
-
I18n.load_path << File.join(qr_params[:locales][:path], "de.yml")
|
29
|
-
I18n.load_path << File.join(qr_params[:locales][:path], "fr.yml")
|
30
|
-
I18n.default_locale = :it
|
31
|
-
|
32
|
-
bill = {
|
33
|
-
params: qr_params,
|
34
|
-
output: QRHTMLLayout.create(qr_params)
|
35
|
-
}
|
36
|
-
|
37
|
-
return bill
|
28
|
+
{ params: qr_params, output: output }
|
38
29
|
end
|
39
30
|
|
40
31
|
def self.create_creditor_reference(reference)
|
41
|
-
|
32
|
+
QRCreditorReference.create(reference)
|
42
33
|
end
|
43
34
|
|
44
35
|
def self.get_qr_params
|
@@ -54,6 +45,6 @@ class QRBills
|
|
54
45
|
end
|
55
46
|
|
56
47
|
def self.get_qrbill_without_reference_type
|
57
|
-
QRParams::
|
48
|
+
QRParams::QR_BILL_WITHOUT_REFERENCE
|
58
49
|
end
|
59
|
-
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qr-bills
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damiano Radice
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -50,26 +50,6 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '2'
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: rmagick
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: 4.1.2
|
60
|
-
- - "<"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '5'
|
63
|
-
type: :runtime
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 4.1.2
|
70
|
-
- - "<"
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: '5'
|
73
53
|
- !ruby/object:Gem::Dependency
|
74
54
|
name: rspec
|
75
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,15 +80,15 @@ dependencies:
|
|
100
80
|
version: '13.0'
|
101
81
|
description: 'QR-bills support for swiss payments, for full documentation please refer
|
102
82
|
to github repo: https://github.com/damoiser/qr-bills'
|
103
|
-
email:
|
83
|
+
email: dam.radice@gmail.com
|
104
84
|
executables: []
|
105
85
|
extensions: []
|
106
86
|
extra_rdoc_files: []
|
107
87
|
files:
|
108
|
-
- config/locales/de.yml
|
109
|
-
- config/locales/en.yml
|
110
|
-
- config/locales/fr.yml
|
111
|
-
- config/locales/it.yml
|
88
|
+
- config/locales/qrbills.de.yml
|
89
|
+
- config/locales/qrbills.en.yml
|
90
|
+
- config/locales/qrbills.fr.yml
|
91
|
+
- config/locales/qrbills.it.yml
|
112
92
|
- lib/qr-bills.rb
|
113
93
|
- lib/qr-bills/qr-creditor-reference.rb
|
114
94
|
- lib/qr-bills/qr-exceptions.rb
|
@@ -133,7 +113,7 @@ metadata:
|
|
133
113
|
homepage_uri: https://github.com/damoiser/qr-bills
|
134
114
|
source_code_uri: https://github.com/damoiser/qr-bills
|
135
115
|
wiki_uri: https://github.com/damoiser/qr-bills
|
136
|
-
post_install_message:
|
116
|
+
post_install_message:
|
137
117
|
rdoc_options: []
|
138
118
|
require_paths:
|
139
119
|
- lib
|
@@ -149,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
129
|
version: '0'
|
150
130
|
requirements: []
|
151
131
|
rubygems_version: 3.1.2
|
152
|
-
signing_key:
|
132
|
+
signing_key:
|
153
133
|
specification_version: 4
|
154
134
|
summary: QR-bills support for swiss payments
|
155
135
|
test_files: []
|
data/config/locales/de.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
de:
|
2
|
-
payment_part: Zahlteil
|
3
|
-
account: Konto
|
4
|
-
payable_to: Zahlbar an
|
5
|
-
reference: Referenz
|
6
|
-
additional_information: zusätzliche Informationen
|
7
|
-
further_information: weitere Informationen
|
8
|
-
currency: Währung
|
9
|
-
amount: Betrag
|
10
|
-
receipt: Empfangsschein
|
11
|
-
acceptance_point: Annahmestelle
|
12
|
-
separate_before_paying_in: Vor der Einzahlung abzutrennen
|
13
|
-
payable_by: Zahlbar durch
|
14
|
-
payable_by_name_addr: Zahlbar durch (Name/Adresse)
|
15
|
-
in_favour_of: Zugunsten
|
data/config/locales/en.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
en:
|
2
|
-
payment_part: payment part
|
3
|
-
account: account
|
4
|
-
payable_to: payable to
|
5
|
-
reference: reference
|
6
|
-
additional_information: additional information
|
7
|
-
further_information: further information
|
8
|
-
currency: currency
|
9
|
-
amount: amount
|
10
|
-
receipt: receipt
|
11
|
-
acceptance_point: acceptance point
|
12
|
-
separate_before_paying_in: separate before paying in
|
13
|
-
payable_by: payable by
|
14
|
-
payable_by_name_addr: payable by (name/address)
|
15
|
-
in_favour_of: in favour of
|
data/config/locales/fr.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
fr:
|
2
|
-
payment_part: section paiement
|
3
|
-
account: compte
|
4
|
-
payable_to: payable à
|
5
|
-
reference: référence
|
6
|
-
additional_information: informations additionnelles
|
7
|
-
further_information: informations supplémentaires
|
8
|
-
currency: monnaie
|
9
|
-
amount: montant
|
10
|
-
receipt: récépissé
|
11
|
-
acceptance_point: èpomt de dépôt
|
12
|
-
separate_before_paying_in: à détacher avant le versement
|
13
|
-
payable_by: payable par
|
14
|
-
payable_by_name_addr: payable par (nom/adresse)
|
15
|
-
in_favour_of: en faveur de
|
data/config/locales/it.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
it:
|
2
|
-
payment_part: "sezione pagamento"
|
3
|
-
account: conto
|
4
|
-
payable_to: "pagabile a"
|
5
|
-
reference: riferimento
|
6
|
-
additional_information: "informazioni aggiuntive"
|
7
|
-
further_information: "informazioni supplementari"
|
8
|
-
currency: valuta
|
9
|
-
amount: importo
|
10
|
-
receipt: ricevuta
|
11
|
-
acceptance_point: "punto di accettazione"
|
12
|
-
separate_before_paying_in: "da staccare prima del versamento"
|
13
|
-
payable_by: pagabile da
|
14
|
-
payable_by_name_addr: pagabile da (nome/indirizzo)
|
15
|
-
in_favour_of: a favore di
|