打印收据

打印收据

是否有一个包可以生成包含以下信息的收据。标题包含公司名称、日期、应自动生成的收据编号,以及文字说明 - 已从 xyz 先生处收到 Xx 金额作为 xyz 的付款。

签名

答案1

我使用 datatool 和 tikz 制作了一张样本收据。要打印这样的收据,您可能需要一个数据库来存储客户的数据。我通过创建一个名为的 cvs 文件来制作它database

BillNumber,FirstName,Surname,Address,Date,Amount
11234,Name,Family,"No. 1, First St.", "2014,06,02",1000
21485,Name,Family,"No. 1, First St.", "2014,06,02",1000
35987,Name,Family,"No. 1, First St.", "2014,06,02",1000
45784,Name,Family,"No. 1, First St.", "2014,06,02",1000
56874,Name,Family,"No. 1, First St., City, Country.", "2014,06,02",1000
69851,Name,Family,"No. 1, First St.", "2014,06,02",1000

通过运行下面的代码,您将要求 Latex 读取您在前面输入的收据或账单号码,\def \query { }并且您需要的所有数据都将打印在输出 pdf 文件中。

我也使用 tikz 包创建了一个示例徽标,您可以更改此部分并添加您自己公司的徽标,甚至可以从文件中省略它。

在此处输入图片描述

\documentclass{article}
\usepackage{datatool}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{latexsym}
\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage[a6paper, margin=10mm, landscape]{geometry}

% ------------- | ---------- Please enter the bill number you want to print
\def \query {56874}
% ---------------------------------------------------------------------------------

\begin{document}
\thispagestyle{empty}
\pagecolor{yellow!25}
\begin{tikzpicture}[overlay,remember picture]
\draw [line width=1.0pt,rounded corners=10pt,]
    ($ (current page.north west) + (5mm,-5mm) $)
    rectangle
    ($ (current page.south east) + (-5mm,5mm) $);       
\end{tikzpicture}
\begin{tikzpicture}[overlay,remember picture]
\draw [line width=1.0pt,rounded corners=10pt,]
    ($ (current page.north west) + (15mm,-10mm) $)
    rectangle
    ($ (current page.south east) + (-105mm,65mm) $);
    \node at (-2.11,-1) {Logo};
\end{tikzpicture}
{\centering
{\bf \LARGE Your Store Name}\\[2.5mm]
Address Line Here\\
Phone: 555-555-555555\\
Fax: 123-123-123456\\[15mm]
{\bf \Large Cash Receipt}\hfill$\overline{\text{cashier's signature}}$\\[10mm]
}
\DTLloaddb{database}{database.csv}

\DTLforeach*[\DTLiseq{\billnumber}{\query}]{database}{%
\billnumber=BillNumber,\firstname=FirstName,\surname=Surname,\address=Address,\billdate=Date,\amount=Amount}{%
\noindent {\bf Cash Receipt Number:} \billnumber \hfill {\bf Date:} \billdate \vfill
\noindent Cash Received from\hfill \firstname{ }\surname\hfill of \hfill \$\amount \hfill payed in cash~$\blacksquare$~/~by check~$\square$\vfill
\noindent{\bf Customer's address:} \address\vfill
}

\end{document}

答案2

部分答案,只是为了展示如何增加计数器(公平地说,这个技巧是在 TeX.sxe 的某个地方找到的,但我再也找不到在哪里了……)。

\documentclass{article}
\newcounter{NumberOfRuns}
\makeatletter
\AtEndDocument{%
    \immediate\write\@auxout{%
    \string\setcounter{NumberOfRuns}{\number\value{NumberOfRuns}}}
}%
\AtBeginDocument{%
    \refstepcounter{NumberOfRuns}
}%
\makeatletter

\begin{document}
This document was compiled \theNumberOfRuns~times so far!
\end{document}

这段小代码会将您迄今为止编译的aux次数存储在文件中。您可以编辑或删除它来影响计数器的值。texNumberOfRuns

答案3

我有一个解决方案,您可以根据您的需要进行修改:

\documentclass[
  11pt,
  a4paper,
  english
  ]{scrartcl}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\newwrite\NoFile
\newread\NoFile
\newread\DataFile
\newcounter{NoReceipt}
\openin\NoFile=NoFile.txt%
\read\NoFile to \fileline
\setcounter{NoReceipt}{\fileline}
\closein\NoFile
\stepcounter{NoReceipt}
\immediate\openout\NoFile=NoFile.txt
\immediate\write\NoFile{\theNoReceipt}
\immediate\closeout\NoFile


\begin{document}


Company

\today

Receipt No. \theNoReceipt

\openin\DataFile=DataFile.txt%

Received
\read\DataFile to \fileline
\fileline
from
\read\DataFile to \fileline
\fileline
as payment for
\read\DataFile to \fileline
\fileline

\closein\DataFile

\end{document}

此外,您需要两个文件,NoFile.txtDataFile.txt。NoFile.txt 包含当前号码,因此您最初需要仅向此文件提供内容0,而 DataFile.txt 包含以下格式的信息:

195\$
Mr. X
Drugs

相关内容