upn-library-v2 1.0.2 → 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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/index.js +8 -8
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Function params:
|
|
|
32
32
|
|
|
33
33
|
{
|
|
34
34
|
price: Number, // *required* - amount to be paid
|
|
35
|
-
title_code: String, // *required* -
|
|
35
|
+
title_code: String, // *required* - default COST
|
|
36
36
|
title: String, // *required* - title of the payment "Payment for x"
|
|
37
37
|
due_date: Date, // *required* - payment due date
|
|
38
38
|
reference: String, // *required* - payment reference
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -13,8 +13,8 @@ function formatPrice(price) {
|
|
|
13
13
|
return ((price * 100) + "").padStart(11, "0")
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function
|
|
17
|
-
return
|
|
16
|
+
function stripSpaces(text) {
|
|
17
|
+
return text.replace(/\s/g, '')
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function calculateControlSum(fields) {
|
|
@@ -59,24 +59,24 @@ export async function generateUPNQR(options, size = 300) {
|
|
|
59
59
|
|
|
60
60
|
let fields = [
|
|
61
61
|
"UPNQR",
|
|
62
|
-
|
|
62
|
+
stripSpaces(options.payer.iban ?? ""),
|
|
63
63
|
"",
|
|
64
64
|
"",
|
|
65
65
|
"",
|
|
66
|
-
options.payer.name
|
|
66
|
+
`${options.payer.name} ${options.payer.surname}`,
|
|
67
67
|
options.payer.address + "",
|
|
68
|
-
options.payer.zip
|
|
68
|
+
`${options.payer.zip} ${options.payer.city}`,
|
|
69
69
|
formatPrice(options.price) + "",
|
|
70
70
|
formatDate(options.payment_date),
|
|
71
71
|
"",
|
|
72
72
|
options.title_code ?? 'COST',
|
|
73
73
|
options.title + "",
|
|
74
74
|
formatDate(options.due_date) + "",
|
|
75
|
-
|
|
76
|
-
options.reference + "",
|
|
75
|
+
stripSpaces(options.payee.iban) + "",
|
|
76
|
+
stripSpaces(options.reference) + "",
|
|
77
77
|
options.payee.title + "",
|
|
78
78
|
options.payee.address + "",
|
|
79
|
-
options.payee.zip
|
|
79
|
+
`${options.payee.zip} ${options.payee.city}`
|
|
80
80
|
]
|
|
81
81
|
|
|
82
82
|
let text = generateText(fields)
|