qr-bills 0.3 → 1.0
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/lib/qr-bills/qr-creditor-reference.rb +3 -0
- data/lib/qr-bills/qr-generator.rb +1 -1
- data/lib/qr-bills/qr-html-layout.rb +2 -2
- data/lib/qr-bills/qr-params.rb +37 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5b13afc587aab384d5e9a030f42108e2b9110fcc7990e6f1ae0b7ce94069d04c
|
|
4
|
+
data.tar.gz: 8052cd236374ecf1bc14ba7f41b7cd42295fc983a3034e3dec39b23af794c862
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f513cd9212d3469f6be2b9b254b7fd39fb3b61d712896d90f70250c5e05426d8bf87800940288c699649b19d3ae3cc71d6e17726e9a9ddbc15f49614402291a2
|
|
7
|
+
data.tar.gz: 455577fd45fcc3fe7be24f14ee32275e2d5e6e8d5257f4c7eeaee184616596f6a5f42c09e72d2fe01fe42d3ccf774a0711e0e60516e46438216fefad453d1967
|
|
@@ -4,6 +4,7 @@ require 'qr-bills/qr-exceptions'
|
|
|
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 @@ module 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
|
|
@@ -69,7 +69,7 @@ module QRGenerator
|
|
|
69
69
|
payload += "#{params[:bill_params][:additionally_information]}\r\n"
|
|
70
70
|
payload += "EPD\r\n"
|
|
71
71
|
payload += "#{params[:bill_params][:bill_information_coded]}\r\n"
|
|
72
|
-
payload += "#{params[:bill_params][:
|
|
72
|
+
payload += "#{params[:bill_params][:alternative_scheme_parameters]}\r\n"
|
|
73
73
|
|
|
74
74
|
qrcode = RQRCode::QRCode.new(payload)
|
|
75
75
|
|
|
@@ -74,8 +74,8 @@ module QRHTMLLayout
|
|
|
74
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\">#{I18n.t("qrbills.name").capitalize} AV2:</span> #{params[:bill_params][:
|
|
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"
|
data/lib/qr-bills/qr-params.rb
CHANGED
|
@@ -24,7 +24,7 @@ module 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",
|
|
@@ -72,22 +72,54 @@ module QRParams
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def self.base_params_valid?(params)
|
|
75
|
-
|
|
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
|
+
|
|
76
87
|
true
|
|
77
88
|
end
|
|
78
89
|
|
|
79
90
|
def self.qr_bill_with_qr_reference_valid?(params)
|
|
80
|
-
|
|
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
|
+
|
|
81
99
|
true
|
|
82
100
|
end
|
|
83
101
|
|
|
84
102
|
def self.qr_bill_with_creditor_reference_valid?(params)
|
|
85
|
-
|
|
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
|
+
|
|
86
111
|
true
|
|
87
112
|
end
|
|
88
113
|
|
|
89
114
|
def self.qr_bill_without_reference_valid?(params)
|
|
90
|
-
|
|
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
|
+
|
|
91
123
|
true
|
|
92
124
|
end
|
|
93
125
|
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'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Damiano Radice
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-04-
|
|
11
|
+
date: 2021-04-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: i18n
|