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 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* - example COST
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "upn-library-v2",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "main": "src/index.js",
5
5
  "keywords": [
6
6
  "UPN",
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 formatIban(iban) {
17
- return iban.replace(/\s/g, '')
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
- formatIban(options.payer.iban ?? ""),
62
+ stripSpaces(options.payer.iban ?? ""),
63
63
  "",
64
64
  "",
65
65
  "",
66
- options.payer.name + " " + options.payer.surname + "",
66
+ `${options.payer.name} ${options.payer.surname}`,
67
67
  options.payer.address + "",
68
- options.payer.zip + " " + options.payer.city + "",
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
- formatIban(options.payee.iban) + "",
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 + " " + options.payee.city + "",
79
+ `${options.payee.zip} ${options.payee.city}`
80
80
  ]
81
81
 
82
82
  let text = generateText(fields)