summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/qrbill/qrbill.dtx
blob: aa632a6845505b0b0e6f24104ba9410ddeff467c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
% \iffalse meta-comment
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright (C) 2020–2022 by Marei Peischl (peiTeX) <marei@peitex.de>
%
% This work is a collaboration of
%   Marei Peischl (peiTeX) and Alex Antener (foobar LLC).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is
%   Marei Peischl <qrbill@peitex.de>.
%
% This work consists of the files
% qrbill.dtx and qrbill.ins, qrbill-vocab.csv
% and the derived files
% qrbill.sty, swiss.qrbill-cfg.tex, epc.qrbill-cfg.tex,
% qrbill-letter-demo.tex, qrbill-standalone-demo.tex.
%
% The development repository can be found at
% https://github.com/peitex/qrbill
% Please use the issue tracker for feedback!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \fi
% \iffalse
%<*package>
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%</package>
% \fi
% \iffalse
%<*driver>
\ProvidesFile{qrbill.dtx}[2022/09/15 v1.05 \ create QR-bills based on the Swiss standard]
\documentclass[english, parskip=half-]{scrartcl}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\fi
\usepackage[hyperref=false]{doc}
\usepackage[cache, langlinenos]{minted}
% Need to set the style here so that it is defined and brought in here.
% If the style is set later, then docstrip interferes with any comments in
% the style definition so that they appear as literal text in the document.

\setminted{style=default, tabsize=4}
\newminted{latex}{gobble=4,escapeinside=||}

\newenvironment{doccode}{
  \VerbatimEnvironment
  \begin{VerbatimOut}[gobble=1, tabsize=4]{minted.doc.out}}
  {\end{VerbatimOut}
  \inputminted[autogobble, escapeinside=||,tabsize=4]{latex}{minted.doc.out}
}

\usepackage{babel}
\usepackage[babel]{csquotes}

\PageIndex
\RecordChanges
\newmintinline{latex}{}

\newcommand*\repl[1]{\meta{#1}}
\newcommand*\opt[1]{\colorbox{black!20}{\meta{#1}}}
\newcommand*\marg[1]{%
        {\ttfamily\char`\{}\repl{#1}{\ttfamily\char`\}}}
\newcommand*\oarg[1]{%
        {\ttfamily[}\opt{#1}{\ttfamily]}
}
\newcommand*{\sarg}{\texttt{*}}

\usepackage{xparse}

\OnlyDescription
\makeatletter

\def\qrbill@optionNoDefault #1(#2) (#3){%
	\vspace{0.1in}%
	\leavevmode%
	\marginpar{\raggedleft\small\ttfamily#1\ }%
	\kern-\parindent\textsf{(#2)}\hfill#3\\}


\def\qrbill@option #1 (#2) (#3){%
	\qrbill@optionNoDefault#1(#2) ({(default: \texttt{#3})})%
}

\ExplSyntaxOn

\newcommand*\qrbill@nextopt{}%
\newenvironment{optionlist}%
{%
	\par\vspace{-.5\baselineskip}
	\def\pipechar{|}%
	\let\|\pipechar%
	\RenewDocumentCommand{\item}{sr[]}{%
		\qrbill@nextopt%
		\renewcommand*\qrbill@nextopt{\par}%
		\IfBooleanTF {##1}%
		{\qrbill@optionNoDefault ##2}%
		{\qrbill@option ##2}%
}}
{%
	\par}
\ExplSyntaxOff



% Create a short verbatim pipe that handles quotation marks properly
\begingroup
\catcode`\|=\active
\gdef\pipe@active@verbatim{%
	\begingroup
	\let\do\@makeother\dospecials
	\catcode`\|=\active
	\catcode`\`=\active
	\catcode`\'=\active
	\catcode`\<=\active
	\catcode`\>=\active
	\catcode`\-=\active
	\catcode`\,=\active
	\catcode`\ =\active
	\pipe@active@verbatim@i}
\gdef\pipe@active@verbatim@i#1|{%
	\endgroup
	\begingroup
	\def\FV@SV@pipe@active@verbatim{%
		\FV@Gobble
		\expandafter\FV@ProcessLine\expandafter{#1}}%
	\BUseVerbatim{pipe@active@verbatim}%
	\endgroup}
\AtBeginDocument{\let|\pipe@active@verbatim}
\endgroup
\makeatother

\usepackage{array}
\usepackage{booktabs}

\usepackage{qrbill}

\usepackage[hidelinks]{hyperref}

\begin{document}
\DocInput{qrbill.dtx}
\end{document}
%</driver>
%\fi
%
% \changes{v1.00}{2020/06/28}{First official version}
%
% \GetFileInfo{qrbill.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
% \title{qrbill v1.03}
% \subtitle{\LaTeX-package to create QR-bills based on the Swiss payments standards}
% \author{Marei Peischl \href{mailto:marei@peitex.de}{<marei@peitex.de>}}
% \publishers{A collaborative project of pei\TeX{} and foobar LLC}
% \date{\filedate}
% \maketitle
% \tableofcontents
% \section{Introduction}
% qrbill.sty, the \LaTeX-package, is the Free Software and Open Source answer to the launch of the swiss payments conversion, introduced mid 2020, replacing the former payment order slip by a restructured, QR enhanced slip. The published source code is based on the payment standard guidelines issued for Switzerland and intentionally has a modular structure to enable further development and adaptation for international use.
%
% By means of the \LaTeX{} framework, the qrbill can simply be integrated into existing accounting environments and automated billing systems.
% \iffalse
%    \begin{macrocode}
%<*qrbill.sty>
%    \end{macrocode}
% \fi
% \section{Example of use}
% The easies way to use the qrbill package is to create a bill with the standalone documentclass:
% 
% \begin{doccode}
% \documentclass{standalone}
% \usepackage[ngerman]{babel}
% 
% \usepackage{xcolor}
% \usepackage{qrbill}
% 
% \begin{document}
% 	
% \QRbill[
% creditor={foobar LLC\\
% 	Postfach 404\\
% 	2342 Zurich\\
% 	CH},
% Account=CH1280808005649899718,
% % insert additional data here
% ]
% 
% \end{document}
% \end{doccode}
%
% \DescribeMacro{\QRbill}\oarg{Data Setup}
% The macro \latexinline{\QRbill} creates a box of 210\,mm${}\times{}$105\,mm size. It will include a qrbill as described in the design guide \cite{qrbill-design} and insert all available data.
%
% There is also an example in the appendix showing all data fields (see appendix \ref{standalone-complete} on page \pageref{standalone-complete}).
%
% The headings are provided in German, English, Italian and French and will be translated using the document's language setup. The terms have been taken from the official guidelines.
%
% \section{Technical Requirements}
% qrbill has been built for \TeX Live 2020. Currently it is not possible to ensure it's functionality with older Releases of \TeX Distributions.
%
% The packages loaded by qrbill are:
% \begin{itemize}
% \item expl3
% \item fontspec (except one is using a custom font setup)
% \item graphicx
% \item scrbase (which is part of the koma-script bundle)
% \item qrcode
% \item iftex
% \item l3keys2e
% \item numprint
% \end{itemize}
%
% As a default font \enquote{Liberation Sans} will be used. This will be loaded using fontspec, which would require the use of Lua\LaTeX{} or Xe\LaTeX{} as a compiler. To have a workaround for this, see the \latexinline{font} option on page  \pageref{opt:font} for a custom font setup.
%
% \section{Package options}
%
% \begin{optionlist}
%
% \item[billinginfo (true/false) (true)]
% Activate/deactivate the automatic fill of the BillingInformation. If this is set to \latexinline{false} one still can add data to this field using the \latexinline{BillingInformation} key, as Described in section \ref{sec:data-setup}.
%
% \item[creditorprefix\\debtorprefix (String) (CR-/UD-)]
% For custom setups the predefined prefixes for the debtor and creditoraddress can be changes. The initial configuration is a requirement of the Swiss standards.
%
% \item[data-to-string (true/false) (false)]
% Converts data to be used to setup the billing QRcode into a string. This option has to be updated if the data should not be treated as ordinary \LaTeX{} code.
% You can use this to automatically escape special characters.\changes{v1.05}{2022/09/15}{add data-to-string option}
%
% \item[font (Frutiger/Arial/Helvetica/Liberation Sans/custom) (Liberation Sans)]
% \label{opt:font}
% The official guideline for the Swiss qrbill limits the choice of the font to the first four values of this option. The font selection and sizes currently hardcoded to fit to the size. Custom setups might be provided in the future.
%
% In case one wants to use a custom font, you can set the option \latexinline{font=custom}. This will disable all font setup and not prevent the fontspec package from being loaded. You can redefine the macro \latexinline{qrbillfont} to use any font available on your system, for example:
% \begin{doccode}
% \usepackage{fontspec}
% % The Laconic font has to be installed
% \renewcommand*{\qrbillfont}{\fontspec{Laconic}}
% \end{doccode}
%
% \item[frame (true/false/top/bottom/none) (true)]
% Switch to disable the frame around the created QRbill. The top/bottom options should be prefered when the bill is embedded into a document of a4 papersize.
% The option none also disables the vertical line inside the bill as this may be included on preprinted paper.
%
% \changes{v1.02}{2020/08/25}{add ibanseparator option}
% \item[ibanseparator (tokenlist) (\textbackslash,)]
% Set the tokenlist to separate the account numbers. See option \latexinline{sep-iban} for
% further information.
%
% \item[icon (swiss-cross/filename) (<empty>)]
% The swiss standard describes the placement of a swiss-cross icon in the center of the QRcode. This can be achieved using this option. The default is set empty, so no icon will be placed. If this option holds another string than \enquote{swiss-cross} it will be interpreted as filename and try to load a custom image.
%
% \item[iconwidth (length) (7mm)]
% This option allows custom scaling for custom icons.
%
% \item[qrmode (package/lua) (package)] Selects the mechanism for QRcode generation.
% With Version 2.0 the package supports usage of the the luaqrcode library \cite{luaqrcode}. This can be enabled by using the \latexinline{qmode=lua} option.
% In that case the luaqrcode libary has to be installed within the \verb+$LUAINPUTS+.
%
% \item[qrscheme (Name of a custom QRbill scheme) (swiss)]
% Loads the definitions for the QRcode and the BillingInformation. Currently only the
% swiss qrbill scheme is available, but one can define own variants based on this file.
% Users can copy the file swiss.qrbill-cfg.tex as an example.
%
% \changes{v1.02}{2020/08/25}{add referenceseparator option}
% \item[referenceseparator (tokenlist) (\textbackslash,)]
% Set the tokenlist to separate the reference codes. See option \latexinline{sep-reference} for
% further information.
%
% \changes{v1.02}{2020/08/25}{add sep-iban/sep-reference option}
% \item[sep-iban\\sep-reference (integer) (0)]
% Set the size of character groups to separate these. Positive values will be counted left to right. Negative ones the other way round.
% The most variants of the Swiss QRbill use values of \latexinline{sep-iban=4} and \latexinline{sep-reference=-5} e.\,g.:
%
% \ExplSyntaxOn
% \begingroup
% \keys_set:nn {qrbill} {sep-iban=4,sep-reference=-5}
% Iban:~\__qrbill_sep_tl:nn {iban} {CH1280808005649899718}\\
% Reference:~\__qrbill_sep_tl:nn {reference} {000000000000000000000000152}
% \endgroup
% \ExplSyntaxOff
%
% \changes{v1.01}{2020/06/29}{Add separate option to modify the top rule of the QR bill}
% \changes{v1.02}{2020/08/25}{Fix placement issue with separate option}
% \item[separate (false/text/symbol) (text)]
% Setup the separation rule between the document and the qrbill. If the value is text or symbol the Info \enquote{\qrbillseparatename} or the corresponding translation will be printed on top of the frame. This option will be ignored it the frame has no top rule.
%
% \item[replace-tilde\\replace-umlauts (true/false) (false)]
% Add automatic string replacements for \latexinline{~} and Umlauts.
% In general the Data has either to be parsed as string or be expandable.
% There are some specials about active characters like \latexinline{~}.
% The option \latexinline{replace-tilde=true} will replace this by an ordinary space within the data string for the QRcode.
%
% Similarly the replace-umlauts options is mapping Umlauts to the two character representation. This can be used  if UTF-8 is not supported.
% Custom replacements can be set up using \latexinline{\QRbillAddCustomReplacement} as described in section \ref{sec:custom-replacement}.
% \changes{v1.05}{2022/09/15}{Add replace-tilde/replace-umlauts options}
% 
% \end{optionlist}
%
% \section{Data setup}
% \label{sec:data-setup}
% \changes{v1.04}{2022/07/02}{Add starrred variant of qrbillsetdata}
% \DescribeMacro{\qrbillsetdata}\sarg\marg{data}
% The data fields can be filled either using the optional argument of \latexinline{\QRbill} or using the macro \latexinline{\qrbillsetdata}. Section \ref{sec:data-complete} shows a list of all available fields and appendix \ref{standalone-complete} provides an example of use. For further information on the construction of the QRcode see the specification \cite{qrbill-spec}.
%
% To simplify the usage qrbill provides an interface to use the different types of address data and is able to create a \enquote{billing information} string as described in \cite{qrbill-spec} using the single data elements.
%
% Version 1.04 adds a starred variant to expand the argument before setting the data. This might be usefull for using counters or other variables inside the command.
%
% \section{Parsing dates}
% In version v1.04 qrbill introduced the functionality to parse dates. For the swiss data scheme the fields \latexinline{invoicedate} and \latexinline{vatdate} are prefilled with the compilation date.
% \changes{v1.04}{2022/07/02}{Add date parsing mechanisms}
% \DescribeMacro{\QRbillParseDate}\marg{year}\marg{month}\marg{day}
% To be compatible with language specific setups the usage of \latexinline{\today} is not allowed directly but one can use
% \begin{doccode}
%	\qrbillsetdata*{
%		invoicedate=\QRbillParseDate{\the\year}{\the\month}{\the\day}
%	}
% \end{doccode}
% By default this setting will return the ISO date (YYYY-MM-DD) but the swiss scheme is already changing this to the desired (YYMMDD) structure.
%
% \section{String replacements}\label{sec:custom-replacement}
% \changes{v1.05}{2022/09/15}{Add support for custom string replacements}
% Following a feature request qrbill received support for custom replacements.
% Those allow the use of special characters within the data fields.
% The corresponding options \latexinline{replace-tilde} and \latexinline{replace-umlauts} provide preset variants for the most common replacements.
% In case you want to add another you can use the following structure:
% \begin{doccode}
%	\AddQRbillCustomReplacement{Ä}{Ae}
% \end{doccode}
%
% \section{Setup for the preconfigured Swiss QR-bill}
% \subsection{Preconfigured data}
% \changes{v1.03}{2021/05/07}{Update to swiss qrbill standard version 2.2}
% The initial configuration which uses the Swiss standard already adds the following data:
% \begin{doccode}
% \SetupQrBill{
%   QRType=SPC,
%   Version=0200,
%   CodingType=1,
%   Trailer=EPD,
% }
% \end{doccode}
% These fields are required to use these values for Version 2.2 of the QRbill standard. If any future changes on the standard would require changes, they can be overwritten or redefined by using a custom implementation file, similar to swiss.qrbill-cfg.tex.
%
% \changes{v1.02}{2020/08/25}{Note the version number inconsistency in the official guidelines}
% Be aware that version 2.1 of the standard requested to use the versioncode \latexinline{0210}.
% With the update to version 2.2 of the standard this was changed to \latexinline{0200}.
% This change was caused by a discrepancy between the standard and the commong implementation.
% Most of them continued to use the version code \latexinline{0200} therefore SIX decided to keep this error and created a workaround with finally documenting this change in version 2.2 of the guildelines.
% \begin{quote}
%Note: In collaboration with representatives of the financial center, SIX has decided that only the version designation “0200” is permitted in master version 02. From master version 03 onwards, depiction of subversions is enabled.\\\hspace*{\fill}\cite{qrbill-spec}
% \end{quote}
% The corresponding issue and discussion concerning this especially for version 2.1 can be found at \url{https://github.com/peiTeX/qrbill/issues/3}.
%
% Additionally the Currency has been initialized to use \enquote{CHF}. This also can be overwritten. Currently the Swiss standards only allow the values \latexinline{CHF} or \latexinline{EUR}.
% \subsection{Address data}
% The Swiss payment standards for QR-bills require the following data for the address of creditor (Prefix \latexinline{CR-})  and debtor (Prefix \latexinline{UD-}):
% \begin{center}
% \begin{tabular}{@{}>{\ttfamily}l>{\centering}p{.25\linewidth}>{\centering\arraybackslash}p{.25\linewidth}@{}}
% \toprule
% AddressType&S&K\\\cmidrule(r){1-1}\cmidrule(l){2-3}
% Name& \multicolumn{2}{c}{Name}\\\cmidrule(r){1-1}\cmidrule(l){2-3}
% Address1&Street&Street with number\\\cmidrule(r){1-1}\cmidrule(l){2-3}
% Address2&Number&Postal code with City\\\cmidrule(r){1-1}\cmidrule(l){2-3}
% ZIP&Postal code& Enforced Empty\\\cmidrule(r){1-1}\cmidrule(l){2-3}
% City& City& Enforced Empty\\\cmidrule(r){1-1}\cmidrule(l){2-3}
% Country& \multicolumn{2}{c}{Country Code}\\\bottomrule
% \end{tabular}
% \end{center}
% To set an address of type \enquote{K} one can use they option key \latexinline{debtor} or \latexinline{creditor}. Type \enquote{S} can be achieved using the starred variant (\latexinline{debtor*}/\latexinline{creditor*}).
%
% \begin{minipage}{.5\linewidth}
% \begin{doccode}
% creditor={Name\\
% Street Nr.\\
% PostalCode City\\
% CountryCode},
% \end{doccode}
% \end{minipage}%
% \begin{minipage}{.5\linewidth}
% \begin{doccode}
% creditor*={Name\\
% Street\\
% Nr.\\
% PostalCode\\
% City\\
% CountryCode},
% \end{doccode}
% \end{minipage}
%
% \subsection{Billing information}
% The billing information is a string which can consist of the following data elements:
% \begin{tabular}{@{}>{\ttfamily}ll@{}}
%   invoicenum & invoice number\\
%   invoicedate & invoice data \\
%   customerref & customer reference \\
%   vat & VAT number\\
%   vatdate& VAT date\\
%   vatdetails& VAT percentage / details\\
%   importvat& import VAT\\
%   conditions& payment conditions\\
% \end{tabular}
% The data has to be in the required format. qrbill might add features to automatically validate this in the future.
%
% Beside setting the data fields all on their own, qrbill can also handle a complete billing information string. One could simply set it by
%
% \begin{doccode}
% BillingInfo=//S1/10/10201409/11/190512/20/1400.000-53/30/106017086
%   /31/180508/32/7.7/40/2:10;0:30
% \end{doccode}
% \subsection{AV-Parameters}
% The QRcode can use 2 AV Parameters. They have to carry the Prefix of \enquote{Name AV1:}/\enquote{Name AV2:}. This will be automatically added if the keys \latexinline{AV1}/\latexinline{AV2} are used instead of \latexinline{AV1-Parameters}/\latexinline{AV2-Parameters}.
%
% \subsection{Remaining data elements}
% The remaining data elements should be set directly.
% For restrictions on the content see the specification. Currently there is no validation taking place.
% The remaining for the preconfigures Swiss standard are:
%   Account,
%   Amount,
%   ReferenceType,
%   Reference,
%   Message,
%
% \subsection{The Swiss cross icon}
% \cite{qrbill-design} reguires a swiss cross of 7\,mm size to be placed in the center of the QRcode.
% This package supports this by using the package option for the icon:
% \begin{doccode}
% \usepackage[icon=swiss-cross, …]{qrbill}
% \end{doccode}
% This setting is not activated by default.
%
%
% \subsection{Overview over all data fields}
% \label{sec:data-complete}
% Data fields which are used in the QRcode:\par
% \ExplSyntaxOn
% \seq_use:Nn \g__qrbill_qrscheme_seq {\\}
% \ExplSyntaxOff
% \par\medskip
% Data fields, which are custom created by the qrbill package to simplify the use:\par
% creditor and creditor*\\
% debtor and debtor*\\
% AV1 and AV2
% \par\medskip
% Data fields to automatically create the BillingInfo string. The key in parentheses indicates the prefix to be used to construct the string.\par
% \ExplSyntaxOn
% \prop_map_inline:Nn \g__qrbill_billing_info_prop {#2~(#1)\\}
% \ExplSyntaxOff
%
% \section{Setup for EPC QR codes}
% EPC QR codes can be used for SEPA credit transfer (SCT).
% They do not include any data about the debtor or tax information.
% Therefore they may only be used with the starred variant of \latexinline{\QRbill*} or the user has to provide additional data interfaces.
% \subsection{Preconfigured data}
% \changes{v1.04}{2022/07/01}{Add basic support for EPC QR codes}
% The epc qrscheme provided by this package preset the following data:
% \begin{doccode}
% \SetupQrBill{
%	   QRType=BCD,
%	   Version=002,
%	   CodingType=1,% UTF-8, 2 would be ISO
%	   Trailer=SCT,
%	 }
% \end{doccode}
% These fields are required to use these values for the current version of the EPC QR code.
%
% \subsection{Required data}
% The data fields required by the EPC QRcode can be set directly. A full example for an easy EPC qrcode would be
% \begin{doccode}
%   \QRbill*[
%     BIC=BYLADEM1GLS,
%     Account=DE68430609671013251700,
%     Name=peiTeX,
%     Amount=EUR123.42,
%     Message={Invoice 2022:1337, customer 1337}
%   ]
% \end{doccode}
% \iffalse
% \section{Implementation}
%    \begin{macrocode}
\RequirePackage{expl3}
\ProvidesExplPackage{qrbill}{2022/09/15}{1.05}{
  Template for QR-bills based on the Swiss Payment Standards
}
\RequirePackage{iftex}
\RequirePackage{l3keys2e}

\tl_new:N \g__qrbill_font_tl
\bool_new:N \g__qrbill_top_frame_bool
\bool_new:N \g__qrbill_bottom_frame_bool
\bool_new:N \g__qrbill_left_frame_bool
\bool_new:N \g__qrbill_right_frame_bool
\bool_new:N \g__qrbill_vrule_bool
\bool_new:N \g__qrbill_separateinfo_bool
\prop_new:N \g__qrbill_replacement_prop

\msg_new:nnn {qrbill} {typo-in-option} {
	A~typo~within~the~option~#1~was~removed.\\
	The~correct~name~for~the~option~is~#2.\\
	Please~use~#2~instead~of~#1,~which~only\\
	exists~for~backwards~compatibility~and~will~be~removed.
}

\keys_define:nn {qrbill} {
  font .choices:nn = {Frutiger, Arial, Helvetica, Liberation Sans} {
    \tl_gset_eq:NN \g__qrbill_font_tl \l_keys_choice_tl
  },
  font .initial:n = Liberation Sans,
  font / custom .code:n = {\tl_gclear:N \g__qrbill_font_tl},
  qrscheme .tl_gset:N = \g__qrbill_qrscheme_tl,
  qrscheme .initial:n = swiss,
  creditorprefix .tl_gset:N = \g__qrbill_creditorprefix_tl,
  creditorprefix .initial:n = CR-,
  debtorprefix .tl_gset:N = \g__qrbill_debtorprefix_tl,
  debtorprefix .initial:n = UD-,
  qrmode .choice:,
  qrmode / package .code:n = \bool_gset_false:N \g__qrbill_luamode_bool,
  qrmode / lua .code:n = \bool_gset_true:N \g__qrbill_luamode_bool,
  qrmode .initial:n = package,
  frame .choice:,
  frame / false .code:n = {
    \bool_gset_false:N \g__qrbill_top_frame_bool
    \bool_gset_false:N \g__qrbill_bottom_frame_bool
    \bool_gset_false:N \g__qrbill_left_frame_bool
    \bool_gset_false:N \g__qrbill_right_frame_bool
    \bool_gset_true:N \g__qrbill_vrule_bool
  },
  frame / true .code:n = {
    \bool_gset_true:N \g__qrbill_top_frame_bool
    \bool_gset_true:N \g__qrbill_bottom_frame_bool
    \bool_gset_true:N \g__qrbill_left_frame_bool
    \bool_gset_true:N \g__qrbill_right_frame_bool
    \bool_gset_true:N \g__qrbill_vrule_bool
  },
  frame / top .code:n = {
    \bool_gset_true:N \g__qrbill_top_frame_bool
    \bool_gset_false:N \g__qrbill_bottom_frame_bool
    \bool_gset_false:N \g__qrbill_left_frame_bool
    \bool_gset_false:N \g__qrbill_right_frame_bool
    \bool_gset_true:N \g__qrbill_vrule_bool
  },
  frame / bottom .code:n = {
    \bool_gset_false:N \g__qrbill_top_frame_bool
    \bool_gset_true:N \g__qrbill_bottom_frame_bool
    \bool_gset_false:N \g__qrbill_left_frame_bool
    \bool_gset_false:N \g__qrbill_right_frame_bool
    \bool_gset_true:N \g__qrbill_vrule_bool
  },
  frame / none .code:n = {
    \bool_gset_false:N \g__qrbill_top_frame_bool
    \bool_gset_false:N \g__qrbill_bottom_frame_bool
    \bool_gset_false:N \g__qrbill_left_frame_bool
    \bool_gset_false:N \g__qrbill_right_frame_bool
    \bool_gset_false:N \g__qrbill_vrule_bool
  },

  frame .initial:n = true,
  billinginfo .bool_gset:N = \g__grbill_billinginfo_auto_bool,
  billinginfo .default:n = true,
  billinginfo .initial:n = true,
  icon .choice:,
  icon / swiss-cross .meta:n = {icon=qrbill_swiss-cross.pdf},
  icon / unknown .code:n = \tl_gset:Nn \g_qrbill_icon_tl {#1},
  icon .initial:n =,
  iconwidth .dim_gset:N = \g_qrbill_iconwidth_dim,
  iconwidth .initial:n = 7mm,
  separate .choice:,
  separate / symbol .code:n = {
    \bool_gset_true:N \g__qrbill_separateinfo_bool
    \RequirePackage{marvosym}
    \cs_set:Nn \qrbill_print_separate_info: {
      \par\leaders\vbox_to_ht:nn {1sp} {
        \smash{
        \hbox_to_wd:nn {\c_qrbill_width_dim }{
            \leaders\hbox{\rule{1mm}{\g__qrbill_rule_dim}\hspace{1mm}}\hskip 0pt\@plus1 fill\relax
            \llap{\raisebox{-.5\height}{\LeftScissors}}
            \leaders\hbox{\rule{1mm}{\g__qrbill_rule_dim}\hspace{1mm}}\hskip 0pt\@plus4 fill\relax
        }
        }
      }
      \vskip 1sp
      \vskip -1sp
    }
    },
  separate / text .code:n = {
    \bool_gset_true:N \g__qrbill_separateinfo_bool
    \cs_set:Nn \qrbill_print_separate_info: {
        \centerline{\raisebox{\dimexpr\depth+.3ex\relax}[0pt][0pt]{\footnotesize\qrbillseparatename}}
    \par\nointerlineskip
    \rule{\c_qrbill_width_dim}{\g__qrbill_rule_dim}
    }
  }
  ,
  separate / false .code:n = {\bool_gset_false:N \g__qrbill_separateinfo_bool},
  separate .initial:n = text,
  sep-iban .int_gset:N = \g__qrbill_ibansep_int,
  sep-iban .initial:n = 0,
  ibanseparator .tl_gset:N = \g__qrbill_ibansep_tl,
  ibanseparator .initial:n = {\,},
  ibanseperator .code:n = \keys_set:nn {qrbill} {ibanseparator=#1}\msg_warning:nnnn {qrbill} {typo-in-option} {ibanseperator} {ibanseparator},
  sep-reference .int_gset:N = \g__qrbill_referencesep_int,
  sep-reference .initial:n = 0,
  referenceseparator .tl_gset:N = \g__qrbill_referencesep_tl,
  referenceseparator .initial:n = {\,},
  referenceseperator .code:n = \keys_set:nn {qrbill} {referenceseparator=#1}\msg_warning:nnnn {qrbill} {typo-in-option} {referenceseperator} {referenceseparator},
  replace-tilde .choice:,
  replace-tilde / true .code:n = \prop_gput:Nxx \g__qrbill_replacement_prop  {\char_generate:nn {126} {12}} {\ },
  replace-tilde / false  .code:n = \exp_args:NNx \prop_gremove:Nn \g__qrbill_replacement_prop  {\char_generate:nn {126} {12}},
  replace-umlauts .choice:,
  replace-umlauts / true .code:n = \prop_gput_from_keyval:Nn \g__qrbill_replacement_prop {ä=ae,Ä=AE,ü=ue,Ü=UE,ö=oe,Ö=OE,ß=ss,ẞ=SS},
  replace-umlauts / false .code:n = \clist_map_inline:nn {ä,Ä,ü,Ü,ö,Ö,ß,ẞ} {\prop_gremove:Nn \g__qrbill_replacement_prop {##1}},
  data-to-string .bool_gset:N = \g__qrbill_to_string_bool,
}

\ProcessKeysOptions{qrbill}

\newcommand*{\qrbillsetup}[1]{\keys_set:nn {qrbill}{#1}}
\NewDocumentCommand{\qrbillsetdata}{sm}{
	\bool_if:NTF \g__qrbill_to_string_bool {
		\IfBooleanTF {#1} {
			\tl_set:Nx \l_tmpa_tl {#2}
			\exp_args:Nnx \keys_set:nn {qrbill/data} {\tl_to_str:V \l_tmpa_tl}
		}{
			\exp_args:Nnx \keys_set:nn {qrbill/data} {\tl_to_str:n {#2}}
		}
	} {
	\IfBooleanT {#1}
		\exp_args:Nnx
	\keys_set:nn
		{qrbill/data}{#2}
	}
}

\tl_if_empty:NTF \g__qrbill_font_tl {
  \def\qrbillfont{\normalfont}
}{
  \RequirePackage{fontspec}
  \newfontfamily{\qrbillfont}{\g__qrbill_font_tl}
  \RequirePackage{anyfontsize}
}

\dim_new:N \g_qrbill_QRcode_dim
\dim_gset:Nn \g_qrbill_QRcode_dim {46mm}
\bool_if:NT \g__qrbill_luamode_bool {
	\file_if_exist:nTF {qrencode.lua} {
		\lua_load_module:n {qrbill-latexluaqrcode}
	} {
		\msg_new:nnn {qrbill} {luaqrcode-not-found} {
			Could~not~find~the~required~library~for~qrmode=lua.\\
			I~will~switch~to~qrmode=package.
		}
		\msg_warning:nn {qrbill} {luaqrcode-not-found}
		\bool_gset_false:N \g__qrbill_luamode_bool
	}

	% qrcode setup
	\dim_new:N \l__qrbill_QRblocksize_dim
	\cs_set_protected:Npn \qrbill_qrcode_black: {\rule{\l__qrbill_QRblocksize_dim}{\l__qrbill_QRblocksize_dim}}
	\cs_set_protected:Npn \qrbill_qrcode_white: {\rule{\l__qrbill_QRblocksize_dim}{0pt}\rule{0pt}{\l__qrbill_QRblocksize_dim}}
	\cs_new:Nn \qrbill_parse_QRcode:n {
		\lua_now:e {
			num, string = printQRcode("\lua_escape:n {#1}")
		}
		\dim_set:Nn \l__qrbill_QRblocksize_dim {\g_qrbill_QRcode_dim/\lua_now:n {tex.print(num)}}
		\let\qrblack\qrbill_qrcode_black:
		\let\qrwhite\qrbill_qrcode_white:
		\def\qrnewline{\\[\dimexpr-\baselineskip+\l__qrbill_QRblocksize_dim]}
		\noindent\parbox{\g_qrbill_QRcode_dim}{
			\lua_now:n {tex.sprint(string)}
		}
	}
}

\bool_if:NF \g__qrbill_luamode_bool {
  \usepackage{qrcode}
  % modified version of \qr@encode@binary to allow utf8 qrcodes required by swiss qrbill scheme
  % Copyright (C) 2015 by Anders Hendrickson <ahendric@cord.edu>
	\cs_set:Nn \__qrbill_encode_unicode_binary:n {
		% #1 = string of ascii characters, to be converted into bitstream
		%
		% We do this one entirely in hex, rather than binary, because we can.
		\edef\qr@plaintext{#1}%
		%
		%First, the mode indicator.
		\def\qr@codetext{4}% %This means `binary'
		%
		%Next, the character count.
		\xdef\qr@stringlength{\tl_count:o {\qr@plaintext}}%
		%Set \qr@charactercountlengthinhex to \qr@charactercountbits@byte/4%
		\edef\qr@charactercountlengthinhex{\int_eval:n {\qr@charactercountbits@byte / 4}}%
		\qr@decimaltohex[\qr@charactercountlengthinhex]{\qr@charactercount}{\qr@stringlength}%
		\xa\g@addto@macro\xa\qr@codetext\xa{\qr@charactercount}%
		%
		%Now comes the actual data.
		\exp_args:NNx \str_set_convert:Nnnn \l_tmpa_str  { \qr@plaintext }  {iso88591} {utf8}
		\exp_args:NNV \str_set_convert:Nnnn \l_tmpa_str  \l_tmpa_str {} {latin1/hex}
		\str_gput_right:NV \qr@codetext \l_tmpa_str
		\xdef\qr@codetext{\exp_args:No \str_lowercase:n {\qr@codetext}}
		%Now the terminator.
		\g@addto@macro\qr@codetext{0}% %This is '0000' in binary.
		%
		%There is no need to pad bits to make a multiple of 8,
		%because the data length is already 4 + 8 + 8n + 4.
		%
		%Now add padding codewords if needed.
		\setcounter{qr@hexchars}{\tl_count:o {\qr@codetext}}%
		%Set \qr@numpaddingcodewords equal to \qr@totaldatacodewords - qr@hexchars/2.
		\edef\qr@numpaddingcodewords{\int_eval:n {(-\c@qr@hexchars / 2)+\qr@totaldatacodewords}}
		%
		\int_compare:nNnT {\qr@numpaddingcodewords} < {0} {
			\edef\ds{ERROR:~Too~much~data!~Over~by~\qr@numpaddingcodewords~bytes.}
		}
		\int_compare:nNnT {\qr@numpaddingcodewords} > {0} {
			\int_step_inline:nnnn {2} {2} {\qr@numpaddingcodewords} {
			\g@addto@macro{\qr@codetext}{ec11}%
		}
		\int_if_odd:nT {\qr@numpaddingcodewords} {
				\g@addto@macro{\qr@codetext}{ec}%
			}
		}
	}
  \cs_set:Nn \qrbill_parse_QRcode:n {
		\cs_set_eq:NN \qr@encode@binary \__qrbill_encode_unicode_binary:n
		\raisebox{\depth}{\cs_set_eq:NN \qr@encode@binary \__qrbill_encode_unicode_binary:n\qrcode[height= \g_qrbill_QRcode_dim]{#1}}
  }
}

\cs_generate_variant:Nn \qrbill_parse_QRcode:n {V}

\newcommand*{\QRbillAddCustomReplacement}[2]{
	 \prop_gput:Nxx \g__qrbill_replacement_prop  {#1} {#2},
}

\RequirePackage{scrbase}
\RequirePackage{graphicx}
\RequirePackage{numprint}
\npthousandsep{\,}
\npdecimalsign{.}

\dim_new:N \g__qrbill_rule_dim
\dim_gset:Nn \g__qrbill_rule_dim {.5pt}
\dim_const:Nn \c_qrbill_sep_dim {5mm}
\dim_const:Nn \c_qrbill_width_dim {210mm}
\dim_const:Nn \c_qrbill_height_dim {105mm}

\cs_new:Nn \qrbill_title_font: {\fontsize{11bp}{11bp}\selectfont\bfseries}

\cs_new:Nn \qrbill_headingR_font: {\fontsize{6bp}{9bp}\selectfont\bfseries}
\cs_new:Nn \qrbill_valueR_font: {\fontsize{8bp}{9bp}\selectfont}
\cs_new:Nn \qrbill_amountR_font: {\fontsize{8bp}{11bp}\selectfont}
\cs_new:Nn \qrbill_acceptance_font: {\fontsize{6bp}{8bp}\selectfont\bfseries}

\cs_new:Nn \qrbill_headingP_font: {\fontsize{8bp}{11bp}\selectfont\bfseries}
\cs_new:Nn \qrbill_valueP_font: {\fontsize{10bp}{11bp}\selectfont}
\cs_new:Nn \qrbill_amountP_font: {\fontsize{10bp}{13bp}\selectfont}

\cs_new:Nn \qrbill_infoheading_font: {\fontsize{7bp}{8bp}\selectfont\bfseries}
\cs_new:Nn \qrbill_info_font: {\fontsize{7bp}{8bp}\selectfont}

\dim_new:N \g_qrbill_placeholder_rule_dim
\dim_gset:Nn \g_qrbill_placeholder_rule_dim {.75pt}
\dim_new:N \g_qrbill_placeholder_corner_dim
\dim_gset:Nn \g_qrbill_placeholder_corner_dim {3mm}
\cs_new:Nn \__qrbill_placeholder_hmark: {
  \rule{\g_qrbill_placeholder_corner_dim}{\g_qrbill_placeholder_rule_dim}
}
\cs_new:Nn \__qrbill_placeholder_vmark: {
  \rule{\g_qrbill_placeholder_rule_dim}{\g_qrbill_placeholder_corner_dim}
}


\cs_new:Nn \__qrbill_placeholder:nn {
  \vbox_to_ht:nn {#2} {
    \hbox_to_wd:nn {#1} {\__qrbill_placeholder_hmark: \hfill \__qrbill_placeholder_hmark:}
    \nointerlineskip
    \hbox_to_wd:nn {#1} {\__qrbill_placeholder_vmark: \hfill \__qrbill_placeholder_vmark:}
    \vfill
    \hbox_to_wd:nn {#1} {\__qrbill_placeholder_vmark: \hfill \__qrbill_placeholder_vmark:}
    \nointerlineskip
    \hbox_to_wd:nn {#1} {\__qrbill_placeholder_hmark: \hfill \__qrbill_placeholder_hmark:}
  }
}

\cs_new:Nn \qrbill_bill_create: {
  \begingroup
  \qrbill_parse_BillingInfo:
  \qrbillfont
  \setlength{\parindent}{\z@}
  \parbox{\c_qrbill_width_dim }{
    \vbox to \c_qrbill_height_dim {
      \bool_if:NTF \g__qrbill_top_frame_bool
        {
          \bool_if:NTF \g__qrbill_separateinfo_bool
            {\qrbill_print_separate_info:}
            {\rule{\c_qrbill_width_dim}{\g__qrbill_rule_dim}}
        }
        {\rule{\c_zero_dim}{\g__qrbill_rule_dim}}
      \par\nointerlineskip
      \skip_vertical:n {\c_qrbill_sep_dim-\g__qrbill_rule_dim}
      \skip_horizontal:n {\c_qrbill_sep_dim-\g__qrbill_rule_dim}
      \begin{minipage}[c][95mm][t]{52mm}
        \vbox_to_ht:nn {7mm} {\qrbill_title_font:\qrbillreceiptname}
        \par\nointerlineskip
        \vbox_to_ht:nn {56mm}{
          {\qrbill_headingR_font:\qrbillaccountname\par}
          {
            \qrbill_valueR_font:
            \__qrbill_sep_tl:nV {iban} \l_qrbill_data_Account_tl\par
            \qrbill_insert_address:N \g__qrbill_creditorprefix_tl
            \par\vskip\baselineskip
          }
          \tl_if_empty:NF \l_qrbill_data_Reference_tl {
            {\qrbill_headingR_font:\qrbillreferencename\par}
            {
              \qrbill_valueR_font:
              \__qrbill_sep_tl:nV {reference} \l_qrbill_data_Reference_tl
              \par\vskip\baselineskip
            }
          }
          \tl_if_empty:cTF {l_qrbill_data_\g__qrbill_debtorprefix_tl Name_tl}
             {
               {\qrbill_headingR_font:\qrbilldebtoraddrname\par}
               \__qrbill_placeholder:nn {52mm} {20mm}
             }{
               {\qrbill_headingR_font:\qrbilldebtorname\par}
               {
                 \qrbill_valueR_font:
                 \qrbill_insert_address:N \g__qrbill_debtorprefix_tl
                 \par
               }
             }
        }
        \par\nointerlineskip
        \vbox_to_ht:nn {14mm}{
          \qrbill_headingR_font:
          \begin{tabular}[t]{@{}ll@{}}
            \qrbillcurrencyname&\qrbill_headingR_font:\qrbillamountname\\
            \qrbill_amountR_font:\l_qrbill_data_Currency_tl
              &\qrbill_amountR_font:
                \tl_if_empty:NF \l_qrbill_data_Amount_tl
                   {\numprint{\l_qrbill_data_Amount_tl}}
          \end{tabular}
          \tl_if_empty:NTF \l_qrbill_data_Amount_tl {
            \hfill
            \raisebox{\dimexpr-\height+\ht\strutbox}[\z@]{\llap{
                \__qrbill_placeholder:nn {30mm} {10mm}
            }}
          }
          \vfill
        }
        \par\nointerlineskip
        \vbox_to_ht:nn {18mm} {
          \makebox[\linewidth][r]{\qrbill_headingR_font:\qrbillacceptantname}\par
        }
      \end{minipage}%
      \skip_horizontal:n {2\c_qrbill_sep_dim}
      \begin{minipage}[c][95mm][t]{138mm}
        \begin{minipage}[c][85mm][t]{51mm}
          \parbox[t][7mm][t]{\linewidth}{\qrbill_title_font:\qrbillpaymentpartname}
          \par\nointerlineskip
          \skip_vertical:n {\c_qrbill_sep_dim}
          \qrcode_setup_QRcode:
          \leavevmode\qrbill_parse_QRcode:V \l_qrbill_data_str
          \tl_if_empty:NF \g_qrbill_icon_tl {
            \llap{\hbox_to_wd:nn {\g_qrbill_QRcode_dim} {
                \hfill
                \raisebox{\dimexpr-.5\height+.5\g_qrbill_QRcode_dim}[0pt][0pt]{
                  \includegraphics[width=\g_qrbill_iconwidth_dim]{\g_qrbill_icon_tl}
                }
                \hfill
            }}
          }
          \skip_vertical:n {\c_qrbill_sep_dim}
          \vbox_to_ht:nn {22mm}{
            \begin{tabular}[b]{@{}ll@{}}
              \qrbill_headingP_font:\qrbillcurrencyname&\qrbill_headingP_font:
                \qrbillamountname\\
              \qrbill_amountP_font:\tl_use:c {l_qrbill_data_Currency_tl}&
              \tl_if_empty:NF \l_qrbill_data_Amount_tl {
                \qrbill_amountP_font:\numprint{\l_qrbill_data_Amount_tl}
              }
            \end{tabular}
            \tl_if_empty:NTF \l_qrbill_data_Amount_tl {
              \hfill
              \raisebox{\dimexpr-\height+\ht\strutbox}[\z@]{
                \llap{\__qrbill_placeholder:nn {40mm} {15mm}
              }}
            }
          }
        \end{minipage}
        \begin{minipage}[c][85mm][t]{87mm}
          \par\nointerlineskip
          {\qrbill_headingP_font:\qrbillaccountname\par}
          {
            \qrbill_valueP_font:
            \__qrbill_sep_tl:nV {iban} \l_qrbill_data_Account_tl \par
            \qrbill_insert_address:N \g__qrbill_creditorprefix_tl
            \par\vskip\baselineskip
          }
          \tl_if_empty:NF \l_qrbill_data_Reference_tl {
            {\qrbill_headingP_font:\qrbillreferencename\par}
            {\qrbill_valueP_font:
              \__qrbill_sep_tl:nV {reference} \l_qrbill_data_Reference_tl
              \par\vskip\baselineskip}
          }
          \exp_args:Nf \tl_if_empty:nF  {
            \l_qrbill_data_BillingInfo_tl
            \l_qrbill_data_Message_tl
          }{
            {\qrbill_headingP_font:\qrbilladdinfoname\par}
            {
              \qrbill_valueP_font:
              \l_qrbill_data_Message_tl\par
              \tl_replace_all:Nnn \l_qrbill_data_BillingInfo_tl {/} {\discretionary{}{}{}/}
              \l_qrbill_data_BillingInfo_tl
              \par\vskip\baselineskip
            }
          }
          \tl_if_empty:cTF {l_qrbill_data_\g__qrbill_debtorprefix_tl Name_tl} {
            {\qrbill_headingP_font:\qrbilldebtoraddrname\par}
            \__qrbill_placeholder:nn {65mm} {25mm}
          }{
            {\qrbill_headingP_font:\qrbilldebtorname\par}
            {
              \qrbill_valueP_font:
              \qrbill_insert_address:N \g__qrbill_debtorprefix_tl
              \par
            }
          }
        \end{minipage}\par\nointerlineskip
        \begin{minipage}[b][10mm][t]{\linewidth}
          \strut
          \qrbill_insert_AV_parameters:NNn
            \qrbill_infoheading_font:
            \qrbill_info_font:
            {AV1,AV2}
        \end{minipage}
      \end{minipage}
      \par\nointerlineskip\skip_vertical:n  {\c_qrbill_sep_dim}
      \smash{
      \bool_if:NT \g__qrbill_bottom_frame_bool
        {\rlap{\rule{\c_qrbill_width_dim}{\g__qrbill_rule_dim}}}
      \bool_if:NTF \g__qrbill_left_frame_bool
        {\rule{\g__qrbill_rule_dim}{\c_qrbill_height_dim}}
        {\rule{\g__qrbill_rule_dim}{\c_zero_dim}}
      \hspace{\dimexpr62mm-1.5\g__qrbill_rule_dim}
      \bool_if:NTF \g__qrbill_vrule_bool
        {\rule{\g__qrbill_rule_dim}{\c_qrbill_height_dim}}
        {\rule{\g__qrbill_rule_dim}{\c_zero_dim}}
      \hspace{\dimexpr148mm-1.5\g__qrbill_rule_dim}
      \bool_if:NTF \g__qrbill_right_frame_bool
        {\rule{\g__qrbill_rule_dim}{\c_qrbill_height_dim}}
        {\rule{\g__qrbill_rule_dim}{\c_zero_dim}}
      }
    }
  }
  \endgroup
}

\NewDocumentCommand{\QRbill}{so}{
	\begingroup
	\IfNoValueF{#2} {\keys_set:nn {qrbill/data} {#2}}
	\IfBooleanTF {#1}
	{
		\qrcode_setup_QRcode:
		\qrbill_parse_QRcode:V \l_qrbill_data_str
	}{
		\qrbill_bill_create:
	}
	\endgroup
}

\ior_new:N \qrbill_ior
\clist_new:N \l_qrbill_tmpa_clist
\ior_open:Nn \qrbill_ior {qrbill-vocab.csv}

\ior_get:NN \qrbill_ior \l_tmpa_tl
\clist_set:Nx \l_qrbill_tmpa_clist {\l_tmpa_tl}
\int_set:Nn \l_tmpa_int {\clist_count:N \l_qrbill_tmpa_clist}

\ior_str_map_inline:Nn \qrbill_ior {
  \int_step_inline:nnn {2} {\l_tmpa_int } {
    \exp_args:Nnx \use:n {\exp_args:NNx \exp_args:Nnc \defcaptionname
      {\clist_item:Nn \l_qrbill_tmpa_clist {##1}}
      {qrbill\clist_item:nn {#1} {1}name}}
        {\clist_item:nn {#1} {##1}}
  }
}

\ior_close:N \qrbill_ior

\seq_new:N \l_qrbill_tmp_seq

\cs_new:Nn \qrbill_set_address_combined:nn {
	\bool_if:NTF \g__qrbill_to_string_bool {
		\exp_args:NNxx \seq_set_split:Nnn \l_qrbill_tmp_seq
			{\tl_to_str:n {\\}}
			{ \str_range:nnn { #2 } { 2 } { -2 } }
	} {
		\seq_set_split:Nnn \l_qrbill_tmp_seq {\\} {#2}
	}
  \exp_args:Nnx \keys_set:nn {qrbill/data} {
    #1AddressType=K,
    #1Name=\seq_item:Nn \l_qrbill_tmp_seq {1},
    #1Address1=\seq_item:Nn \l_qrbill_tmp_seq {2},
    #1Address2=\seq_item:Nn \l_qrbill_tmp_seq {3},
    #1PostalCode=,
    #1City=,
    #1Country=\seq_item:Nn \l_qrbill_tmp_seq {4},
  }
}

\cs_new:Nn \qrbill_set_address_structured:nn {
	\bool_if:NTF \g__qrbill_to_string_bool {
		\exp_args:NNxx \seq_set_split:Nnn \l_qrbill_tmp_seq
			{\tl_to_str:n {\\}}
			{ \str_range:nnn { #2 } { 2 } { -2 } }
	} {
		\seq_set_split:Nnn \l_qrbill_tmp_seq {\\} {#2}
	}
  \exp_args:Nnx \keys_set:nn {qrbill/data} {
    #1AddressType=S,
    #1Name=\seq_item:Nn \l_qrbill_tmp_seq {1},
    #1Address1=\seq_item:Nn \l_qrbill_tmp_seq {2},
    #1Address2=\seq_item:Nn \l_qrbill_tmp_seq {3},
    #1PostalCode=\seq_item:Nn \l_qrbill_tmp_seq {4},
    #1City=\seq_item:Nn \l_qrbill_tmp_seq {5},
    #1Country=\seq_item:Nn \l_qrbill_tmp_seq {6},
  }
}

\cs_new:Nn \qrbill_insert_address:N {
  \tl_use:c {l_qrbill_data_#1Name_tl}\ifhmode\\\fi
  \str_case_e:nnF {\use:c {l_qrbill_data_#1AddressType_tl}}
      {
        {K}     {
          \tl_use:c {l_qrbill_data_#1Address1_tl}
          \tl_if_empty:cF {l_qrbill_data_#1Address2_tl} {
            \ifhmode\\\fi
            \tl_if_empty:cF {l_qrbill_data_#1Country_tl}
              {\tl_use:c {l_qrbill_data_#1Country_tl}-}
              \tl_use:c {l_qrbill_data_#1Address2_tl}
           }
        }
      }{
        \tl_use:c {l_qrbill_data_#1Address1_tl}~
        \tl_use:c {l_qrbill_data_#1Address2_tl}
        \tl_if_empty:cF {l_qrbill_data_#1City_tl} {
          \ifhmode\\\fi
          \tl_if_empty:cF {l_qrbill_data_#1Country_tl}
            {\tl_use:c {l_qrbill_data_#1Country_tl}-}
          \tl_use:c {l_qrbill_data_#1PostalCode_tl}~
          \tl_use:c {l_qrbill_data_#1City_tl}
        }
      }
}

\cs_new:Nn \__qrbill_sep_tl:nn {
	\int_compare:nTF  {\int_use:c {g__qrbill_#1sep_int} = 0} {
		#2
	}{
		\str_set:Nn \l_tmpa_str {#2}
		\int_compare:nT {\int_use:c  {g__qrbill_#1sep_int} < 0} {
			\tl_reverse:N \l_tmpa_str
		}
		\int_set:Nn \l_tmpb_int {\int_abs:n {\int_use:c {g__qrbill_#1sep_int}}}
		\int_set:Nn \l_tmpa_int {1}
		\tl_clear:N \l_tmpa_tl
		\int_while_do:nNnn {\l_tmpa_int} < {\str_count:N \l_tmpa_str - \l_tmpb_int +1 } {
			\tl_put_right:Nx \l_tmpa_tl {
				\str_range:Nnn \l_tmpa_str {\l_tmpa_int} {\l_tmpa_int + \l_tmpb_int-1}
			}
			\int_add:Nn \l_tmpa_int {\l_tmpb_int}
			\tl_put_right:Nn \l_tmpa_tl {{\tl_use:c {g__qrbill_#1sep_tl}}}
		}
		\tl_put_right:Nx \l_tmpa_tl {
			\str_range:Nnn \l_tmpa_str {\l_tmpa_int} {\str_count:N \l_tmpa_str}
		}
		\int_compare:nT {\int_use:c  {g__qrbill_#1sep_int} < 0} {
			\tl_reverse:N \l_tmpa_tl
		}
		\l_tmpa_tl
	}
}
\cs_generate_variant:Nn \__qrbill_sep_tl:nn {nV}

\newcommand*{\insertdebtor}{\null\qrbill_insert_address:N \g__qrbill_debtorprefix_tl}
\newcommand*{\insertcreditor}{\null\qrbill_insert_address:N \g__qrbill_creditorprefix_tl}
\newcommand*{\insertcurrency}{\l_qrbill_data_Currency_tl}

\keys_define:nn {qrbill/data} {
  creditor .code:n = \qrbill_set_address_combined:nn {\g__qrbill_creditorprefix_tl}{#1},
  creditor* .code:n = \qrbill_set_address_structured:nn {\g__qrbill_creditorprefix_tl} {#1},
  debtor .code:n = \qrbill_set_address_combined:nn {\g__qrbill_debtorprefix_tl}{#1},
  debtor* .code:n = \qrbill_set_address_structured:nn {\g__qrbill_debtorprefix_tl} {#1},
  account .tl_set:N = \l_qrbill_iban_tl,
}

\clist_map_inline:nn {AV1, AV2} {
  \keys_define:nn {qrbill/data} {
    #1 .code:n = {
      \tl_if_empty:nF {##1}{
        \exp_args:Nnx \keys_set:nn {qrbill/data} {
          #1-Parameters={\qrbill_av_prefix:n {#1}##1}
        }
      }
      \tl_set:cn {l_qrbill_#1_tl} {##1}
    },
    #1 .initial:n =,
  }
}

\newcommand*{\SetupQrBill}[1]{
	\bool_if:NTF \g__qrbill_to_string_bool {
		\exp_args:Nnx \keys_set:nn {qrbill/data} {\tl_to_str:n {#1}}
	} {
		\keys_set:nn {qrbill/data} {#1}
	}
}

\str_new:N \l_qrbill_data_str
\cs_new:Nn \qrcode_setup_QRcode: {
  \str_clear:N \l_qrbill_data_str
  \bool_set_false:N \l_tmpa_bool
  \seq_map_inline:Nn \g__qrbill_qrscheme_seq {
    \bool_if:NTF \l_tmpa_bool
         {\str_put_right:Nn\l_qrbill_data_str  {^^J}}
         {\bool_set_true:N \l_tmpa_bool}
         \exp_args:NNv \str_put_right:Nn \l_qrbill_data_str {l_qrbill_data_##1_tl}
  }
  %necessary to preserve spaces!
  \str_replace_all:Nnn \l_qrbill_data_str {~ } {\ }
  \prop_map_inline:Nn \g__qrbill_replacement_prop {
		\str_replace_all:Nnn \l_qrbill_data_str {##1} {##2}
	}
  \tl_set_rescan:Nno \l_qrbill_data_str {\ExplSyntaxOff} {\l_qrbill_data_str}
}

\seq_new:N \g__qrbill_qrscheme_seq
\newcommand*\SetQrScheme[1]{
  \seq_gset_from_clist:Nn \g__qrbill_qrscheme_seq {#1}
  \seq_map_inline:Nn \g__qrbill_qrscheme_seq {
    \keys_define:nn {qrbill/data} {
      ##1 .tl_set:c = l_qrbill_data_##1_tl,
      ##1 .initial:n =,
    }
  }
}



\prop_new:N \g__qrbill_billing_info_prop 
\seq_new:N \g__qrbill_billing_info_seq

\clist_new:N \g__qrbill_billing_info_static_clist
\newcommand*{\SetStaticData}[1]{\clist_gset:Nx \g__qrbill_billing_info_static_clist {\tl_to_str:n {#1}}}

\newcommand*{\SetBillingInfoScheme}[1]{
  \prop_gset_from_keyval:Nn \g__qrbill_billing_info_prop {#1}
  \seq_gclear:N  \g__qrbill_billing_info_seq
  \prop_map_inline:Nn \g__qrbill_billing_info_prop {
    \clist_if_in:NnF \g__qrbill_billing_info_static_clist {##1} {
      \seq_push:Nn \g__qrbill_billing_info_seq {##1}
    }
    \keys_define:nn {qrbill/data} {
      ##2 .tl_set:c = l_qrbill_##2_tl,
      ##2 .initial:n =,
    }
  }
	\seq_if_empty:NF \g__qrbill_billing_info_seq {
		\prop_map_inline:Nn \g__qrbill_billing_info_prop {
			\clist_if_in:NnT \g__qrbill_billing_info_static_clist {##1} {
				\exp_args:Nx \clist_if_in:nnF {\tl_to_str:n {prefix , postfix}} {##1} {
					\seq_push:Nn  \g__qrbill_billing_info_seq {##1}
		    }
			}
		}
	}
  \seq_sort:Nn \g__qrbill_billing_info_seq {
    \int_compare:nNnTF { ##1 } > { ##2 }
        { \sort_return_swapped: }
        { \sort_return_same: }
  }
}

\tl_new:N \l_qrbill_data_BillingInfo_tl

\cs_new:Nn \qrbill_parse_BillingInfo: {
  \bool_if:NT \g__grbill_billinginfo_auto_bool {
    \str_put_right:Nx \l_qrbill_data_BillingInfo_tl {
      \prop_item:Nn \g__qrbill_billing_info_prop  {prefix}
    }
    \seq_map_inline:Nn \g__qrbill_billing_info_seq {
      \prop_get:NnN \g__qrbill_billing_info_prop {##1} \l_tmpa_tl
      \tl_if_empty:cF {l_qrbill_\l_tmpa_tl _tl} {
        \str_put_right:Nx \l_qrbill_data_BillingInfo_tl {
          /##1/\tl_use:c {l_qrbill_\l_tmpa_tl _tl}
        }
      }
    }
  }
}

\cs_set:Nn \qrbill_parse_date:nnn {
	#1-
	\int_compare:nNnT {#2} < {10} {0}#2-
	\int_compare:nNnT {#3} < {10} {0}#3
}

\cs_generate_variant:Nn \qrbill_parse_date:nnn {eee}

\cs_set:Npn \QRbillParseDate #1#2#3 {
	\qrbill_parse_date:eee {#1}{#2}{#3}
}

\cs_new:Nn \qrbill_insert_AV_parameters:NNn {
  \clist_map_inline:nn {#3} {
    \tl_if_empty:cF {l_qrbill_##1_tl}
       {{#1\qrbill_av_prefix:n {##1}}{#2 \tl_use:c {l_qrbill_##1_tl}}}
  }
}

\cs_new:Nn \qrbill_av_prefix:n {Name~#1:~}

\input{\g__qrbill_qrscheme_tl.qrbill-cfg}

%    \end{macrocode}
%    \begin{macrocode}
%</qrbill.sty>
% \section{The file swiss.qrbill-cfg.tex as a custom qrbill scheme}
%<*swiss.qrbill-cfg.tex>
\qrbillsetup{
        creditorprefix =CR-,
        debtorprefix =UD-,
}

\SetQrScheme{
  QRType,
  Version,
  CodingType,
  Account,
  CR-AddressType,
  CR-Name,
  CR-Address1,
  CR-Address2,
  CR-PostalCode,
  CR-City,
  CR-Country,
  UCR-AddressType,
  UCR-Name,
  UCR-Address1,
  UCR-Address2,
  UCR-ZIP,
  UCR-City,
  UCR-Country,
  Amount,
  Currency,
  UD-AddressType,
  UD-Name,
  UD-Address1,
  UD-Address2,
  UD-PostalCode,
  UD-City,
  UD-Country,
  ReferenceType,
  Reference,
  Message,
  Trailer,
  BillingInfo,
  AV1-Parameters,
  AV2-Parameters
}

\SetStaticData{prefix,11,31}

\SetBillingInfoScheme{
  prefix=//S1,
  10=invoicenum,
  11=invoicedate,
  20=customerref,
  30=vat,
  31=vatdate,
  32=vatdetails,
  33=importvat,
  40=conditions
}

\ExplSyntaxOn
\cs_set:Nn \qrbill_parse_date:nnn {
	\str_range:nnn {#1} {3} {4}
	\int_compare:nNnT {#2} < {10} {0}#2
	\int_compare:nNnT {#3} < {10} {0}#3
}
\ExplSyntaxOff

\SetupQrBill{
        QRType=SPC,
        Version=0200,
        CodingType=1,
        Trailer=EPD,
        Currency=CHF,
        ReferenceType=NON,
}

\qrbillsetdata*{
	invoicedate=\QRbillParseDate{\the\year}{\the\month}{\the\day},
	vatdate=\QRbillParseDate{\the\year}{\the\month}{\the\day}
}
%    \end{macrocode}
% \iffalse
%    \begin{macrocode}
%</swiss.qrbill-cfg.tex>
%    \end{macrocode}
% \section{The file epc.qrbill-cfg.tex as a custom qrbill scheme}
% This scheme supports much less variables in contrast to the swiss scheme.
% Therefore the \latexinline{\QRbill} macro has to be used as the starred variant or additional variables have to be provided by the user.
%<*epc.qrbill-cfg.tex>
%    \end{macrocode}
% \fi
%    \begin{macrocode}
\SetQrScheme{
	QRType,
	Version,
	CodingType,
	Trailer,
	BIC,
	Name,
	Account,
	Amount,
	DTA,
	Reference,
	Message,
	Note
}

\SetupQrBill{
	QRType=BCD,
	Version=002,
	CodingType=1,
	Trailer=SCT,
}
%</epc.qrbill-cfg.tex>
%    \end{macrocode}
% \fi
%
% \PrintChanges
% \begin{thebibliography}{99}
% \bibitem{qrbill-spec} Swiss Implementation Guidelines QR-bill: Technical and professional specifications of the payment part with Swiss QR Code and of the receipt. Version 2.2, with effect from 22 February 2021. \url{https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf}. Last checked 2022-08-28
% \bibitem{qrbill-design} Style Guide QR-billStyle Guide QR-bill: The right layout pays off. Layout rules and recommendations for the payment part with Swiss QR Code and for the receipt. \url{https://www.paymentstandards.ch/dam/downloads/style-guide-en.pdf}
% \bibitem{luaqrcode} Luaqrcode – Pure Lua QR Code library.  By Patrick Gundlach (SPEEDATA GMBH) and contributors.
% \url{http://speedata.github.io/luaqrcode/}. Last checked 2022-08-28
% \end{thebibliography}
% \appendix
% \section{Example of standalone qrbill}
% \changes{v1.03}{2021/05/07}{set sep-iban and sep-reference in examples}
% \label{standalone-complete}
% \iffalse
%    \begin{macrocode}
%<*qrbill-standalone-demo.tex>
%    \end{macrocode}
% \fi
%    \begin{macrocode}
% !TeX program=lualatex
\documentclass{standalone}
\usepackage[nswissgerman]{babel}

\RequirePackage{xcolor}
\usepackage[
  icon=swiss-cross,
  separate=false,
  sep-iban=4,
  sep-reference=-5
]{qrbill}

\begin{document}

\QRbill[
  creditor*={foobar LLC\\
    Postfach\\
    404\\
    2342\\
    Zurich\\
    CH},
  Account=CH1280808005649899718,
  vat=123123123,% VAT number with stripped CH and periods
  debtor*={peiTeX\\
    TeXnikerweg\\
    78\\
    23420\\
    Hamburg\\
    DE},
  Amount=1337.42,
  Message=Bestellung vom 27.06.2020,
  invoicenum=100-4242,
% invoicedate=200701,%yymmdd, preset to todays values
  vatdetails=0,% 0% VAT 
% invoicedate=200701,%yymmdd, preset to todays values
  AV1=LX;F00BAR;2342,
]

\end{document}
%    \end{macrocode}
% \iffalse
%    \begin{macrocode}
%</qrbill-standalone-demo.tex>
%<*qrbill-letter-demo.tex>
%    \end{macrocode}
% \fi
% \section{qrbill scrletter example}
%    \begin{macrocode}
% !TeX Program=lualatex
\documentclass[foldmarks=b]{scrletter}
\usepackage[
  frame=top,
  sep-iban=4,
  sep-reference=-5,
]{qrbill}

% Setup layer:
% This requires the scrlayer package which is already loaded by scrletter
\DeclareNewLayer[
	align=bl,
	voffset=\paperheight,
	hoffset=0pt,
	contents={\QRbill},
	width=\paperwidth,
	height=105mm,
	]{qrbill}
	


\begin{document}

\qrbillsetdata{
  creditor*={foobar LLC\\
    Postfach\\
    404\\
    2342\\
    Zurich\\
    CH},
  Account=CH1280808005649899718,
  vat=123123123,% VAT number with stripped CH and periods
  debtor*={peiTeX\\
    TeXnikerweg\\
    78\\
    23420\\
    Hamburg\\
    DE},
  Amount=1337.42,
  Message=Bestellung vom 27.06.2020,
  invoicenum=100-4242,
%  invoicedate=200701,%yymmdd, preset to todays values
  vatdetails=0,% 0% VAT 
%  vatdate=200701,%yymmdd, preset to todays values
  AV1=LX;F00BAR;2342,
}

\setkomavar{fromaddress}{\insertcreditor}
	
\begin{letter}{\insertdebtor}
	
\opening{opening}

Text

\closing{closing}

% Add qbill on last page
% For more details 
\AddLayersToPageStyle{@everystyle@}{qrbill}
	
\end{letter}
\end{document}
%    \end{macrocode}
% 
% \iffalse
%    \begin{macrocode}
%</qrbill-letter-demo.tex>
%    \end{macrocode}
% \fi
%\Finale
\endinput