make the program installable
This commit is contained in:
23
gen.sh
23
gen.sh
@@ -1,16 +1,14 @@
|
||||
#!/bin/bash
|
||||
# What you charge an hour
|
||||
export RATE=50
|
||||
export COMPANY_NAME="Cookies Unlimited, LLC"
|
||||
export ADDR_LN_1="123 Sesasme St"
|
||||
export ADDR_LN_2="Dumpster 1"
|
||||
export ADDR_LN_3="12345, Nicevile, FL"
|
||||
export PHONE="(123) 456-7890"
|
||||
export EMAIL="cookie@exapmle.com"
|
||||
DATA_HOME="$XDG_DATA_HOME/bill-generator"
|
||||
source "$XDG_CONFIG_HOME/bill-generator/ident"
|
||||
# Need to be set to the installed location
|
||||
TEMPLATE_1COL="$DATA_HOME/1col.template.mm"
|
||||
TEMPLATE_2COL="$DATA_HOME/2col.template.mm"
|
||||
INV_FILE="$DATA_HOME/last_invoice_number"
|
||||
|
||||
print_help() {
|
||||
echo "$0 -1 <hrs.csv> <Paying Company Name> [output file]"
|
||||
echo "$0 -2 <hrs.csv> <items.csv> <Paying Company Name> [output file]"
|
||||
echo "$(basename $0) -1 <hrs.csv> <Paying Company Name> [output file]"
|
||||
echo "$(basename $0) -2 <hrs.csv> <items.csv> <Paying Company Name> [output file]"
|
||||
echo ""
|
||||
echo "CSV files should be <name>,<value>."
|
||||
echo "CSV files should have no empty line at the end."
|
||||
@@ -19,7 +17,6 @@ print_help() {
|
||||
}
|
||||
get_invoice_num() {
|
||||
# Increment a global invoice number
|
||||
INV_FILE="last_invoice_number"
|
||||
INV_NUM=0
|
||||
if [[ -f $INV_FILE ]]; then
|
||||
INV_NUM=$(expr $(cat $INV_FILE) + 1)
|
||||
@@ -58,7 +55,7 @@ if [[ $1 = "-1" ]]; then
|
||||
OUTPUT=$4
|
||||
fi
|
||||
export COMPANY=$3
|
||||
envsubst < 1col.template.mm | groff -t -mm -T pdf > $OUTPUT
|
||||
envsubst < $TEMPLATE_1COL | groff -t -mm -T pdf > $OUTPUT
|
||||
elif [[ $1 = "-2" ]]; then
|
||||
if [[ ! -z $5 ]]; then
|
||||
OUTPUT=$5
|
||||
@@ -70,7 +67,7 @@ elif [[ $1 = "-2" ]]; then
|
||||
export ITEM_BODY=$(cat $CONSUME_TMP | head -n -1)
|
||||
export TOTAL=$(A=$HRS_COST B=$ITEM_TOTAL awk 'BEGIN{ print ENVIRON["A"] + ENVIRON["B"] }')
|
||||
export COMPANY=$4
|
||||
envsubst < 2col.template.mm | groff -t -mm -T pdf > $OUTPUT
|
||||
envsubst < $TEMPLATE_2COL | groff -t -mm -T pdf > $OUTPUT
|
||||
else
|
||||
echo First arg should be either -1 or -2
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user