diff --git a/contrib/report_accounts.sh b/contrib/report_accounts.sh index d5c5189c..7f5226c0 100755 --- a/contrib/report_accounts.sh +++ b/contrib/report_accounts.sh @@ -5,48 +5,43 @@ # (Compatible Debian Squeze) # Public domain -SUBJECT="[Banques] Rapport des comptes" -TMPSTORAGE="/tmp/" +SUBJECT="[Bank] Accounts report" +TMPSTORAGE=`mktemp -d` -rm -f ${TMPSTORAGE}account* +boobank -q -f table list > ${TMPSTORAGE}/account_list -boobank -q -f table list > ${TMPSTORAGE}account_list - -ACCOUNTS=`cat ${TMPSTORAGE}account_list | fgrep '@' | awk '{print $2}'` +ACCOUNTS=`awk '/@/ {print $2}' ${TMPSTORAGE}/account_list` for i in $ACCOUNTS do - boobank -q -f table history "$i" > ${TMPSTORAGE}account_history_${i} - boobank -q -f table coming "$i" > ${TMPSTORAGE}account_coming_${i} + boobank -q -f table history "$i" > ${TMPSTORAGE}/account_history_${i} + boobank -q -f table coming "$i" > ${TMPSTORAGE}/account_coming_${i} done -echo "Ceci est le rapport des comptes bancaires, généré automatiquement." > ${TMPSTORAGE}account_mail -echo >> ${TMPSTORAGE}account_mail -cat ${TMPSTORAGE}account_list >> ${TMPSTORAGE}account_mail -echo >> ${TMPSTORAGE}account_mail +echo "Bank accounts report, generated by boobank\n" > ${TMPSTORAGE}/account_mail +cat ${TMPSTORAGE}/account_list >> ${TMPSTORAGE}/account_mail +echo >> ${TMPSTORAGE}/account_mail for i in $ACCOUNTS do - echo "Dernières opérations sur le compte $i" >> ${TMPSTORAGE}account_mail - echo >> ${TMPSTORAGE}account_mail - cat ${TMPSTORAGE}account_history_${i} >> ${TMPSTORAGE}account_mail - echo >> ${TMPSTORAGE}account_mail - if [ -s ${TMPSTORAGE}account_coming_${i} ] + echo "Last operations for account $i \n" >> ${TMPSTORAGE}/account_mail + cat ${TMPSTORAGE}/account_history_${i} >> ${TMPSTORAGE}/account_mail + echo >> ${TMPSTORAGE}/account_mail + if [ -s ${TMPSTORAGE}/account_coming_${i} ] then - echo "Opérations à venir sur le compte $i" >> ${TMPSTORAGE}account_mail - echo >> ${TMPSTORAGE}account_mail - cat ${TMPSTORAGE}account_coming_${i} >> ${TMPSTORAGE}account_mail + echo "Coming operations for account $i \n" >> ${TMPSTORAGE}/account_mail + cat ${TMPSTORAGE}/account_coming_${i} >> ${TMPSTORAGE}/account_mail + echo >> ${TMPSTORAGE}/account_mail else - echo "Pas d'opération à venir sur le compte $i" >> ${TMPSTORAGE}account_mail + echo "No coming operation for $i \n" >> ${TMPSTORAGE}/account_mail fi - echo >> ${TMPSTORAGE}account_mail done if [ "$1" = "--mail" ] then - cat ${TMPSTORAGE}account_mail | mail -s "$SUBJECT" -a "Content-type: text/plain; charset=UTF-8" "$2" + cat ${TMPSTORAGE}/account_mail | mail -s "$SUBJECT" -a "Content-type: text/plain; charset=UTF-8" "$2" else - cat ${TMPSTORAGE}account_mail + cat ${TMPSTORAGE}/account_mail fi -rm -f ${TMPSTORAGE}account* +rm -rf ${TMPSTORAGE}