qr-bills 0.1.1 → 0.3
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.rb +20 -24
- data/lib/qr-bills/qr-creditor-reference.rb +75 -0
- data/lib/qr-bills/qr-exceptions.rb +1 -1
- data/lib/qr-bills/qr-generator.rb +4 -16
- data/lib/qr-bills/qr-html-layout.rb +20 -20
- data/lib/qr-bills/qr-params.rb +24 -26
- metadata +11 -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: f0f5417c130ea2bb955adc879dabbc2e93f470c3990bd7b79cc5c9d069a92aca
|
4
|
+
data.tar.gz: 412fd936ffa901e2d83909215c5dfe5e700945d76ae0ca8b3b4e4ea3d48f8740
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1448d54d8fddc9ae2e11fa8d900fa21f0a2c0d501360a6386636a9650200c53f3b487c0aa05d1acfb8909e2ab816ee57c1c70ce88d08f84ecfe903c1f09883e
|
7
|
+
data.tar.gz: 5787cc90e6a2546736376f7268bc13e044cfd06b0783b4876e77d12ff1d8f465c02cc804377e6cfe64074ac329e3f5025837f5de221d3f2391f6d169d8820209
|
@@ -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
|
data/lib/qr-bills.rb
CHANGED
@@ -2,38 +2,34 @@ require 'i18n'
|
|
2
2
|
require 'qr-bills/qr-exceptions'
|
3
3
|
require 'qr-bills/qr-params'
|
4
4
|
require 'qr-bills/qr-html-layout'
|
5
|
+
require 'qr-bills/qr-creditor-reference'
|
5
6
|
|
6
|
-
|
7
|
+
module QRBills
|
7
8
|
def self.generate(qr_params)
|
8
|
-
#
|
9
|
-
|
10
|
-
I18n.load_path << "#{File.expand_path("#{File.dirname(__FILE__)}/../config/locales/en.yml")}"
|
11
|
-
I18n.load_path << "#{File.expand_path("#{File.dirname(__FILE__)}/../config/locales/de.yml")}"
|
12
|
-
I18n.load_path << "#{File.expand_path("#{File.dirname(__FILE__)}/../config/locales/fr.yml")}"
|
13
|
-
I18n.default_locale = :it
|
14
|
-
|
15
|
-
bill = {
|
16
|
-
params: qr_params,
|
17
|
-
output: nil
|
18
|
-
}
|
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)
|
19
11
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
raise QRExceptions::INVALID_PARAMETERS + ": params validation check failed"
|
24
|
-
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")
|
25
15
|
|
26
|
-
|
27
|
-
|
28
|
-
else
|
29
|
-
raise QRExceptions::NOT_SUPPORTED + ": html is the only output format supported so far"
|
30
|
-
end
|
16
|
+
I18n.load_path << locale_file
|
17
|
+
end
|
31
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])
|
32
24
|
else
|
33
|
-
raise QRExceptions::
|
25
|
+
raise ArgumentError, "#{QRExceptions::NOT_SUPPORTED}: #{qr_params[:output_params][:format]} is not yet supported"
|
34
26
|
end
|
35
27
|
|
36
|
-
|
28
|
+
{ params: qr_params, output: output }
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.create_creditor_reference(reference)
|
32
|
+
QRCreditorReference.create(reference)
|
37
33
|
end
|
38
34
|
|
39
35
|
def self.get_qr_params
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'qr-bills/qr-exceptions'
|
2
|
+
|
3
|
+
# implement Creditor Reference ISO 11649 generator
|
4
|
+
module QRCreditorReference
|
5
|
+
PREFIX = "RF"
|
6
|
+
|
7
|
+
@char_values = {
|
8
|
+
"A": 10,
|
9
|
+
"B": 11,
|
10
|
+
"C": 12,
|
11
|
+
"D": 13,
|
12
|
+
"E": 14,
|
13
|
+
"F": 15,
|
14
|
+
"G": 16,
|
15
|
+
"H": 17,
|
16
|
+
"I": 18,
|
17
|
+
"J": 19,
|
18
|
+
"K": 20,
|
19
|
+
"L": 21,
|
20
|
+
"M": 22,
|
21
|
+
"N": 23,
|
22
|
+
"O": 24,
|
23
|
+
"P": 25,
|
24
|
+
"Q": 26,
|
25
|
+
"R": 27,
|
26
|
+
"S": 28,
|
27
|
+
"T": 29,
|
28
|
+
"U": 30,
|
29
|
+
"V": 31,
|
30
|
+
"W": 32,
|
31
|
+
"X": 33,
|
32
|
+
"Y": 34,
|
33
|
+
"Z": 35
|
34
|
+
}
|
35
|
+
|
36
|
+
def self.create(reference)
|
37
|
+
reference = reference.delete(' ')
|
38
|
+
chars = reference.split('')
|
39
|
+
|
40
|
+
if chars.size == 0
|
41
|
+
raise QRExceptions::INVALID_PARAMETERS + ": provided reference too short: must be at least one char"
|
42
|
+
end
|
43
|
+
|
44
|
+
# max 25 chars: 2 chars (RF) + 2 chars (check code) + 21 chars (reference)
|
45
|
+
if chars.size > 21
|
46
|
+
raise QRExceptions::INVALID_PARAMETERS + ": provided reference too long: must be less than 21 chars"
|
47
|
+
end
|
48
|
+
|
49
|
+
reference_val = ""
|
50
|
+
|
51
|
+
chars.each do |c|
|
52
|
+
reference_val += get_char_value(c).to_s
|
53
|
+
end
|
54
|
+
|
55
|
+
# put RF+00 at the end to resolve check code
|
56
|
+
reference_val += @char_values["R".to_sym].to_s + @char_values["F".to_sym].to_s + "00"
|
57
|
+
|
58
|
+
# get check code
|
59
|
+
check_code = 98 - (reference_val.to_i % 97)
|
60
|
+
|
61
|
+
if check_code < 10
|
62
|
+
check_code = "0" + check_code.to_s
|
63
|
+
end
|
64
|
+
|
65
|
+
return PREFIX + check_code.to_s + reference
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.get_char_value(char)
|
69
|
+
if char =~ /[0-9]/
|
70
|
+
return char.to_i
|
71
|
+
end
|
72
|
+
|
73
|
+
return @char_values[char.upcase.to_sym]
|
74
|
+
end
|
75
|
+
end
|
@@ -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"
|
@@ -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,25 +10,25 @@ 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"
|
18
18
|
layout += " #{params[:bill_params][:creditor][:address][:line1]} #{params[:bill_params][:creditor][:address][:line2]}<br/>\n"
|
19
19
|
layout += " #{params[:bill_params][:creditor][:address][:postal_code]} #{params[:bill_params][:creditor][:address][:town]}<br/>\n"
|
20
|
-
layout += " </div
|
21
|
-
layout += " <div><br/></div
|
20
|
+
layout += " </div>\n"
|
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
77
|
if !params[:bill_params][:alternative_scheme_paramters].nil? && !params[:bill_params][:alternative_scheme_paramters].empty?
|
78
|
-
layout += " <span class=\"finfo_header\"
|
78
|
+
layout += " <span class=\"finfo_header\">#{I18n.t("qrbills.name").capitalize} AV2:</span> #{params[:bill_params][:alternative_scheme_paramters]}\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"
|
@@ -151,7 +151,7 @@ class QRHTMLLayout
|
|
151
151
|
layout += " }\n"
|
152
152
|
|
153
153
|
layout += " .payment_section {\n"
|
154
|
-
layout += " width:
|
154
|
+
layout += " width: 137mm;\n"
|
155
155
|
layout += " height: 95mm;\n"
|
156
156
|
layout += " float: left;\n"
|
157
157
|
layout += " padding: 5mm;\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
|
{
|
@@ -13,6 +13,9 @@ class QRParams
|
|
13
13
|
ttf: File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/fonts/LiberationSans-Regular.ttf"),
|
14
14
|
svg: File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/fonts/LiberationSans-Regular.svg")
|
15
15
|
},
|
16
|
+
locales: {
|
17
|
+
path: File.expand_path("#{File.dirname(__FILE__)}/../../config/locales")
|
18
|
+
},
|
16
19
|
bill_params: {
|
17
20
|
language: "it",
|
18
21
|
amount: 0.0,
|
@@ -53,43 +56,38 @@ class QRParams
|
|
53
56
|
end
|
54
57
|
|
55
58
|
def self.valid?(params)
|
56
|
-
|
57
|
-
|
58
|
-
if !QRParams.base_params_valid?(params)
|
59
|
-
return false
|
60
|
-
end
|
59
|
+
return false unless params.key?(:bill_type)
|
60
|
+
return false unless QRParams.base_params_valid?(params)
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
return false
|
70
|
-
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)
|
71
69
|
else
|
72
|
-
|
70
|
+
false
|
73
71
|
end
|
74
72
|
end
|
75
|
-
|
73
|
+
|
76
74
|
def self.base_params_valid?(params)
|
77
|
-
#
|
78
|
-
|
75
|
+
# TODO
|
76
|
+
true
|
79
77
|
end
|
80
78
|
|
81
79
|
def self.qr_bill_with_qr_reference_valid?(params)
|
82
|
-
#
|
83
|
-
|
80
|
+
# TODO
|
81
|
+
true
|
84
82
|
end
|
85
83
|
|
86
84
|
def self.qr_bill_with_creditor_reference_valid?(params)
|
87
|
-
#
|
88
|
-
|
85
|
+
# TODO
|
86
|
+
true
|
89
87
|
end
|
90
88
|
|
91
89
|
def self.qr_bill_without_reference_valid?(params)
|
92
|
-
#
|
93
|
-
|
90
|
+
# TODO
|
91
|
+
true
|
94
92
|
end
|
95
93
|
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: '0.3'
|
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-04-07 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,16 +80,17 @@ 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
|
93
|
+
- lib/qr-bills/qr-creditor-reference.rb
|
113
94
|
- lib/qr-bills/qr-exceptions.rb
|
114
95
|
- lib/qr-bills/qr-generator.rb
|
115
96
|
- lib/qr-bills/qr-html-layout.rb
|
@@ -132,7 +113,7 @@ metadata:
|
|
132
113
|
homepage_uri: https://github.com/damoiser/qr-bills
|
133
114
|
source_code_uri: https://github.com/damoiser/qr-bills
|
134
115
|
wiki_uri: https://github.com/damoiser/qr-bills
|
135
|
-
post_install_message:
|
116
|
+
post_install_message:
|
136
117
|
rdoc_options: []
|
137
118
|
require_paths:
|
138
119
|
- lib
|
@@ -148,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
129
|
version: '0'
|
149
130
|
requirements: []
|
150
131
|
rubygems_version: 3.1.2
|
151
|
-
signing_key:
|
132
|
+
signing_key:
|
152
133
|
specification_version: 4
|
153
134
|
summary: QR-bills support for swiss payments
|
154
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
|