blob: 1374f9219d2ff0712fd25971883c6664acadd88b (
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
|
#!/bin/sh
set -ueo pipefail
SOURCE=$1
if [ -z $SOURCE ]; then
echo "Usage: invoice <file>"
exit 2
fi
TARGET=$(dirname $SOURCE)
ACCOUNT=$(basename $SOURCE .yml)
# The reason behind this awk madness is that we want to be able to write
# a date as yyyy-mm-dd in the invoice descriptor, but LaTeX needs the
# date as three elements to fill in a {d}{m}{y} pattern. Thus we replace
# a simple "date" line with three seperate fields that we can then read
# from LaTeX
cat $SOURCE | xargs -d '\n' -L 1 \
| awk -F '-' '{ if(match($0, /date/)) { gsub(/date: /,"", $1); \
print "date_year: " $1 "\n" "date_month: " $2 "\n" "date_day: " $3 } \
else { print $0} }' \
| pandoc - -o $TARGET/$ACCOUNT.pdf --template=$TEMPLATE_FILE --pdf-engine=xelatex
|