From de18bd01aa0b0c43c8cc848e9116fc7393f84118 Mon Sep 17 00:00:00 2001 From: Paul Cochrane Date: Sat, 12 Sep 2015 20:55:53 +0200 Subject: Handle dollar, euro and pound currencies ... by adding a "currency" option to the documentclass, which can (currently) take either "dollar" (the default), "euro" or "pound" as a value and then use the relevant currency symbol within the invoice text. --- dapper-invoice.cls | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/dapper-invoice.cls b/dapper-invoice.cls index 0f5e915..45015c2 100644 --- a/dapper-invoice.cls +++ b/dapper-invoice.cls @@ -4,6 +4,25 @@ \NeedsTeXFormat{LaTeX2e} \LoadClass[11pt]{article} +% For page number calculations +\RequirePackage{ifthen} + +% To handle key=value options in class definition +\RequirePackage{kvoptions} +\SetupKeyvalOptions{% + prefix=dapper@ +} +% Default currency option is "dollar" +\DeclareStringOption[dollar]{currency}[dollar] +\ProcessKeyvalOptions* + +\RequirePackage{eurosym} + +\ifthenelse{\equal{\dapper@currency}{dollar}}{\newcommand{\currencysym}{\$}}{} +\ifthenelse{\equal{\dapper@currency}{euro}}{\newcommand{\currencysym}{\euro}}{} +\ifthenelse{\equal{\dapper@currency}{pound}}{\newcommand{\currencysym}{\textsterling}}{} + +% Set the standard geometry \RequirePackage[hmargin=.75in,vmargin=1in]{geometry} % For links and metadata @@ -15,9 +34,6 @@ % For "At*" hooks \RequirePackage{etoolbox} -% For page number calculations -\RequirePackage{ifthen} - % For adjusting footer \RequirePackage{fancyhdr} @@ -206,8 +222,8 @@ \end{minipage} & {\itemizationRowStyle \@formatHoursLeft{#2}} & {\itemizationRowStyle \@formatHoursRight{#2}} & - {\itemizationRowStyle \$#3} & - {\itemizationRowStyle \$\calcamount{#2}{#3}} + {\itemizationRowStyle \currencysym#3} & + {\itemizationRowStyle \currencysym\calcamount{#2}{#3}} \\ \noalign{\medskip} } @@ -220,8 +236,8 @@ \end{minipage} & {\itemizationRowStyle \@formatHoursLeft{#2}} & {\itemizationRowStyle \@formatHoursRight{#2}} & - {\itemizationRowStyle \$#3} & - {\itemizationRowStyle \$\calcamount{#2}{#3}} + {\itemizationRowStyle \currencysym#3} & + {\itemizationRowStyle \currencysym\calcamount{#2}{#3}} \\ \noalign{\medskip} } -- cgit v1.2.3 From 69c6c35694a40ad1f30595c01747180a9a65b8f2 Mon Sep 17 00:00:00 2001 From: Paul Cochrane Date: Sat, 12 Sep 2015 20:57:41 +0200 Subject: Use the \currencysym variable to control the currency symbol Also add commented-out example versions of the documentclass options which then control the currency symbol. --- example.tex | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/example.tex b/example.tex index 682f303..f38fc3c 100644 --- a/example.tex +++ b/example.tex @@ -1,4 +1,7 @@ \documentclass[letterpaper]{dapper-invoice} +%\documentclass[letterpaper,currency=dollar]{dapper-invoice} +%\documentclass[letterpaper,currency=euro]{dapper-invoice} +%\documentclass[letterpaper,currency=pound]{dapper-invoice} \def\invoiceNo{101} \def\balance{137.50} @@ -27,7 +30,7 @@ \infoSub{\faMobilePhone}{\small\slshape +1~(555)~555-5555} \noalign{\addvspace{8ex}} \infoBox{}{ - {\large\raisebox{.55\height}\$\huge\formatdollars{\balance} \arrowbase} \\ + {\large\raisebox{.55\height}\currencysym\huge\formatdollars{\balance} \arrowbase} \\ {\small\color{subduedColor} due \duedate{\duein}} } \end{infoSection} @@ -60,10 +63,10 @@ \beginsummary - \summaryline{Total}{\$\formatdollars{\InvoiceTotal}} + \summaryline{Total}{\currencysym\formatdollars{\InvoiceTotal}} - \summaryline{Paid}{\$\formatdollars{50}} - \summaryline{Balance Due}{\$\formatdollars{\balance}} % not really any math support (yet) + \summaryline{Paid}{\currencysym\formatdollars{50}} + \summaryline{Balance Due}{\currencysym\formatdollars{\balance}} % not really any math support (yet) \end{hoursItemizationWithProject} -- cgit v1.2.3