1

Is there a package to generate a receipt which has following information. Header with a company name , date , receipt number which should be automatically generated and text saying - Received Xx amount from Mr xyz as a payment for xyz.

Signature

9
  • 4
    In case there isn't, if you provided more info about how you want to input that information, yes, it would be possible to write it. By the way, “receipt number which should be automatically generated” how can you know on a compilation which number to start? You must provide the starting point.
    – Manuel
    Oct 20, 2014 at 19:53
  • May be using data tool
    – Vaibhav
    Oct 21, 2014 at 1:39
  • 3
    As it stands I don't think this question is going to get answered. It's not clear which parts are an issue, and with no example code we've no real idea what you have already done.
    – Joseph Wright
    Oct 28, 2014 at 11:42
  • 1
    lualatex may be useful here, since it can open databases etc. But, indeed, you should speficy your needs more precisely in order to get a useful answer.
    – nplatis
    Oct 28, 2014 at 14:10
  • 1

3 Answers 3

8
+50

I made a sample receipt using datatool and tikz. For printing such receipt, you may need a database in which you store the data of your customers. I made it by creating a cvs file named 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

By running the code bellow, you will ask the latex to read the receipt or bill number you enter in front of the \def \query { } and all the data you need will be printed in the output pdf file.

I used the tikz package to create a sample logo too, you may change this part and add your own company's logo or even omit it from the file.

enter image description here

\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}
3
  • This is off-topic : why % ------------- | ---------- ? What is the purpose of this | ?
    – Clément
    Nov 3, 2014 at 15:53
  • 2
    @Clément its just a marker to point to the invoice number which needs to be changed, directly below on the next line. Personally, I don't see why you would want to do receipts with latex when there are about a million accounting packages built for this purpose (amongst other things)... Nov 3, 2014 at 19:28
  • @Clément I think nicholas's comment perfectly answers your question.
    – enthu
    Nov 3, 2014 at 20:02
2

A partial answer, just to show how you can increment a counter (to be fair, this trick was found somewhere here, on TeX.sxe, but I can't find where anymore…).

\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}

This small code will store in the aux file the number of times your tex was compiled so far. You can edit it or remove it to affect the value of your NumberOfRuns counter.

1

I have a solution, which you can modify for your needs:

\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}

Furthermore, you need two files, NoFile.txt and DataFile.txt. NoFile.txt contains the current number, so you need to provide this file initially with just the content 0 and DataFile.txt contains the information in this format:

195\$
Mr. X
Drugs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .