summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/qrbill/qrbill.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-07-09 03:01:16 +0000
committerNorbert Preining <norbert@preining.info>2022-07-09 03:01:16 +0000
commit7891283a2f2fb8a8a884bb212c36da8082764a9b (patch)
tree98a050dec8439492144177997c6f66e4f9543d62 /macros/latex/contrib/qrbill/qrbill.dtx
parentc600912bde983d6a04c7ce42321d50d4c7c1a50b (diff)
CTAN sync 202207090301
Diffstat (limited to 'macros/latex/contrib/qrbill/qrbill.dtx')
-rw-r--r--macros/latex/contrib/qrbill/qrbill.dtx180
1 files changed, 143 insertions, 37 deletions
diff --git a/macros/latex/contrib/qrbill/qrbill.dtx b/macros/latex/contrib/qrbill/qrbill.dtx
index 21126cf973..e2b228f2ae 100644
--- a/macros/latex/contrib/qrbill/qrbill.dtx
+++ b/macros/latex/contrib/qrbill/qrbill.dtx
@@ -2,7 +2,7 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% Copyright (C) 2020–2021 by Marei Peischl (peiTeX) <marei@peitex.de>
+% 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).
@@ -23,8 +23,8 @@
% This work consists of the files
% qrbill.dtx and qrbill.ins, qrbill-vocab.csv
% and the derived files
-% qrbill.sty, swiss.qrbill-cfg.tex, qrbill-letter-demo.tex,
-% qrbill-standalone-demo.tex .
+% 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
@@ -54,13 +54,13 @@
% \fi
% \iffalse
%<*driver>
-\ProvidesFile{qrbill.dtx}[2021/05/10 v1.03 \ create QR-bills based on the Swiss standard]
+\ProvidesFile{qrbill.dtx}[2022/07/02 v1.04 \ create QR-bills based on the Swiss standard]
\documentclass[english, parskip=half-]{scrartcl}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\fi
-\usepackage{doc}
+\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
@@ -79,10 +79,9 @@
\usepackage{babel}
\usepackage[babel]{csquotes}
-\EnableCrossrefs
\PageIndex
\RecordChanges
-\newmintinline[code]{latex}{}
+\newmintinline{latex}{}
\newcommand*\repl[1]{\meta{#1}}
\newcommand*\opt[1]{\colorbox{black!20}{\meta{#1}}}
@@ -215,7 +214,7 @@
% \end{doccode}
%
% \DescribeMacro{\QRbill}\oarg{Data Setup}
-% The macro \code{\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.
+% 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}).
%
@@ -236,14 +235,14 @@
% \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 \code{font} option on page \pageref{opt:font} for a custom font setup.
+% 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 \code{false} one still can add data to this field using the \code{BillingInformation} key, as Described in section \ref{sec:data-setup}.
+% 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.
@@ -252,7 +251,7 @@
% \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 \code{font=custom}. This will disable all font setup and not prevent the fontspec package from being loaded. You can redefine the macro \code{qrbillfont} to use any font available on your system, for example:
+% 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
@@ -264,7 +263,7 @@
%
% \changes{v1.02}{2020/08/25}{add ibanseparator option}
% \item[ibanseparator (tokenlist) (\textbackslash,)]
-% Set the tokenlist to separate the account numbers. See option \code{sep-iban} for
+% Set the tokenlist to separate the account numbers. See option \latexinline{sep-iban} for
% further information.
%
% \item[icon (swiss-cross/filename) (<empty>)]
@@ -280,13 +279,13 @@
%
% \changes{v1.02}{2020/08/25}{add referenceseparator option}
% \item[referenceseparator (tokenlist) (\textbackslash,)]
-% Set the tokenlist to separate the reference codes. See option \code{sep-reference} for
+% 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 \code{sep-iban=4} and \code{sep-reference=-5} e.\,g.:
+% The most variants of the Swiss QRbill use values of \latexinline{sep-iban=4} and \latexinline{sep-reference=-5} e.\,g.:
%
% \ExplSyntaxOn
% \begingroup
@@ -304,11 +303,26 @@
%
% \section{Data setup}
% \label{sec:data-setup}
-% \DescribeMacro{\qrbillsetdata}
-% The data fields can be filled either using the optional argument of \code{\QRbill} or using the macro \code{\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}.
+% \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{Setup for the preconfigured Swiss QR-bill}
% \subsection{Preconfigured data}
% \changes{v1.03}{2021/05/07}{Update to swiss qrbill standard version 2.2}
@@ -324,18 +338,18 @@
% 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 \code{0210}.
-% With the update to version 2.2 of the standard this was changed to \code{0200}.
+% 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 \code{0200} therefore SIX decided to keep this error and created a workaround with finally documenting this change in version 2.2 of the guildelines.
+% 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 \code{CHF} or \code{EUR}.
+% 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 \code{CR-}) and debtor (Prefix \code{UD-}):
+% 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
@@ -348,7 +362,7 @@
% 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 \code{debtor} or \code{creditor}. Type \enquote{S} can be achieved using the starred variant (\code{debtor*}/\code{creditor*}).
+% 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}
@@ -390,7 +404,7 @@
% /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 \code{AV1}/\code{AV2} are used instead of \code{AV1-Parameters}/\code{AV2-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.
@@ -427,11 +441,40 @@
% \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}{2021/05/10}{1.03}{
+\ProvidesExplPackage{qrbill}{2022/07/02}{1.04}{
Template for QR-bills based on the Swiss Payment Standards
}
\RequirePackage{iftex}
@@ -538,7 +581,12 @@
\ProcessKeysOptions{qrbill}
\newcommand*{\qrbillsetup}[1]{\keys_set:nn {qrbill}{#1}}
-\newcommand*{\qrbillsetdata}[1]{\keys_set:nn {qrbill/data}{#1}}
+\NewDocumentCommand{\qrbillsetdata}{sm}{
+ \IfBooleanT {#1}
+ \exp_args:Nnx
+ \keys_set:nn
+ {qrbill/data}{#2}
+}
\tl_if_empty:NTF \g__qrbill_font_tl {
\def\qrbillfont{\normalfont}
@@ -781,11 +829,17 @@
\endgroup
}
-\newcommand{\QRbill}[1][]{
- \begingroup
- \tl_if_empty:nF {#1} {\keys_set:nn {qrbill/data} {#1}}
- \qrbill_bill_create:
- \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
@@ -987,6 +1041,18 @@
}
}
+\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}
@@ -1003,9 +1069,6 @@
%</qrbill.sty>
% \section{The file swiss.qrbill-cfg.tex as a custom qrbill scheme}
%<*swiss.qrbill-cfg.tex>
-% \end{macrocode}
-% \fi
-% \begin{macrocode}
\qrbillsetup{
creditorprefix =CR-,
debtorprefix =UD-,
@@ -1060,6 +1123,14 @@
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,
@@ -1068,11 +1139,46 @@
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
@@ -1122,9 +1228,9 @@
Amount=1337.42,
Message=Bestellung vom 27.06.2020,
invoicenum=100-4242,
- invoicedate=200701,%yymmdd
+% invoicedate=200701,%yymmdd, preset to todays values
vatdetails=0,% 0% VAT
- vatdate=200701,%yymmdd
+% invoicedate=200701,%yymmdd, preset to todays values
AV1=LX;F00BAR;2342,
]
@@ -1178,9 +1284,9 @@
Amount=1337.42,
Message=Bestellung vom 27.06.2020,
invoicenum=100-4242,
- invoicedate=200701,%yymmdd
+% invoicedate=200701,%yymmdd, preset to todays values
vatdetails=0,% 0% VAT
- vatdate=200701,%yymmdd
+% vatdate=200701,%yymmdd, preset to todays values
AV1=LX;F00BAR;2342,
}