#!/bin/sh

# Anfang Variablen. Das sollte angepasst werden:

ST_NUMMER="012 345 67890"

FA_ADR_1="Goldstadt"
FA_ADR_2="Speicherstrasse 34"
FA_ADR_3="12345 Goldstadt"

UNT_ADR_1="Duck Import-Export GmbH"
UNT_ADR_2="Malvenweg 23"
UNT_ADR_3="12345 Goldstadt"
UNT_ADR_4="Tel. 01234-56789"

MONAT=2

# Umsatz in vollen Euro
UMSATZ_16="10.000"       
# Umsatzsteuer
USTEUER_16="1.600,00"
# Vorsteuer
VSTEUER_16="283,73"

# Ende Variablen

# Beginn eklige Berechnung, die in einem Shellskript nichts
# zu suchen hat... 

UMSATZ_16=`printf %10s $UMSATZ_16`
USTEUER_16=`printf %10s $USTEUER_16`
VSTEUER_16=`printf %10s $VSTEUER_16`
UST16CENT=`echo $USTEUER_16|tr -d " .,"`
VST16CENT=`echo $VSTEUER_16|tr -d " .,"`
VERBLEIB=`expr $UST16CENT - $VST16CENT`
VERBLEIB_EURO=`expr $VERBLEIB / 100`
VERBLEIB_EURO=`expr $VERBLEIB / 100`
VERBLEIB_CENT=`expr $VERBLEIB - \( $VERBLEIB_EURO \* 100 \)`
VERBLEIB=`printf %7d,%02d $VERBLEIB_EURO $VERBLEIB_CENT`

if [ $MONAT -lt 7 ]
then
    MX=1550
    MY=`expr $MONAT - 1` 
else
    MX=1885
    MY=`expr $MONAT - 7`
fi

MY=`expr 650 + $MY \* 80`

DRAW="text 400,280 '$ST_NUMMER'
      text 280,580 '$FA_ADR_1'
      text 280,660 '$FA_ADR_2'
      text 280,800 '$FA_ADR_3'
      text 280,1050 '$UNT_ADR_1'
      text 280,1110 '$UNT_ADR_2'
      text 280,1170 '$UNT_ADR_3'
      text 280,1230 '$UNT_ADR_4'
      text $MX,$MY 'X'
      text 1480,2160 '$UMSATZ_16'
      text 2120,2160 '$USTEUER_16'
      text 2120,3300 '$USTEUER_16'
     "
     
echo convert ust1.png -font courier.ttf -pointsize 50 -draw "$DRAW" ust1out.ps
convert ust1.png -font courier.ttf -pointsize 50 -draw "$DRAW" ust1out.ps

DRAW="text 500,135 '$ST_NUMMER'
      text 2050,210 '$USTEUER_16'
      text 2050,820 '$USTEUER_16'
      text 2050,950 '$VSTEUER_16'
      text 2050,1495 '$VERBLEIB'
      text 2050,1720 '$VERBLEIB'
      text 2050,1875 '$VERBLEIB'
     "

echo convert ust2.png -font courier.ttf -pointsize 50 -draw "$DRAW" ust2out.ps
convert ust2.png -font courier.ttf -pointsize 50 -draw "$DRAW" ust2out.ps
