Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 37 additions and 1 deletion.
  1. +1 −1 README.md
  2. +36 −0 scripts/mail-total-qif-sum.sh
View
2 README.md
@@ -19,7 +19,7 @@ When quitting, TurboOlaf prints a string representation of the final invoice to
TurboOlaf uses a simple JSON configuration file format. Actually, all invoices that TurboOlaf generates are clones of the original `invoice_prototype.olaf` file. This means that old invoices are always readable and editable, regardless of the current set of products configured in `invoice_prototype.olaf`.
-Internally, TurboOlaf uses a dependencies to subdivide products into smaller "building blocks". Consider for example a crate of beer. This product can be subdivided into the actual liquid that is sold and the plastic crate with 24 glass bottles. This full crate can be divided into 24 single glass bottles and the plastic crate. The advantage of subdividing these products is that a meta-product for returning deposits can easily be created by creating a "Crate of Beer Deposit" product that costs nothing but dependes on "-1 times" the plastic crate with 24 glass bottles.
+Internally, TurboOlaf uses a dependency model to subdivide products into smaller "building blocks". Consider for example a crate of beer. This product can be subdivided into the actual liquid that is sold and the plastic crate with 24 glass bottles. This full crate can be divided into 24 single glass bottles and the plastic crate. The advantage of subdividing these products is that a meta-product for returning deposits can easily be created by creating a "Crate of Beer Deposit" product that costs nothing but dependes on "-1 times" the plastic crate with 24 glass bottles.
A product has the following attributes:
View
36 scripts/mail-total-qif-sum.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+# mail the total amount of all QIF files in the qif/ directory
+# to the given email address
+
+# add a greeting
+email_string="Hello Sir,\n\n"
+
+# list all the individual prices of the evening
+for qif in `find qif/*.qif`
+do
+ email_string="$email_string$qif: $(grep "^T" $qif)\n"
+done
+
+email_string="$email_string\n"
+
+# construct a sum of all the invoices
+calculation="0"
+for i in `grep -h "^T" qif/*.qif`
+do
+ calculation="$calculation + $(echo $i | cut -c 2- -)"
+done
+
+# calculate the sum
+sum=`echo $calculation | bc`
+# append the sum to the email
+email_string=$email_string"Total amount: "$sum
+
+email_string=$email_string"\n\nCheers!\nTurboOlaf\n"
+
+# seek confirmation to send the email
+echo -e $email_string
+echo "Send this message to $1 now?"
+read
+
+echo -e $email_string | mail -s "TurboOlaf sales report generated $(date +"%A, %d.%m.%Y")" $1

No commit comments for this range

Something went wrong with that request. Please try again.