From 6346841e5b81786d6a9df3926302c49ba9632c3f Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 1 Jul 2020 05:57:25 +0200 Subject: [PATCH] create_monthly_cash_flow.sh: warn instead of error if no bank statement found. --- create_monthly_cash_flow.sh | 43 ++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/create_monthly_cash_flow.sh b/create_monthly_cash_flow.sh index 34e3b04..b11a031 100755 --- a/create_monthly_cash_flow.sh +++ b/create_monthly_cash_flow.sh @@ -12,6 +12,7 @@ src_base_dir_cash_flow="${office_dir}/Einnahmen/" bill_receipts="Rechnungen Einnahmen" bill_cost="Rechnungen Ausgaben" +bill_storno="Storno Rechnungen" backup_time="$(date +%Y-%m-%d-%H%M)" @@ -185,6 +186,7 @@ fi src_dir_cash_receipts="${office_dir}/Einnahmen/${year}" +src_dir_cash_storno="${office_dir}/Einnahmen/${year}/Stornorechnungen" src_dir_cash_cost="${office_dir}/Ausgaben/${year}/$month" src_dir_bank_statement="$base_dir_bank_statement/${year}" @@ -192,6 +194,7 @@ base_dir_cash_flow="${office_dir}/Abschluss_${year}" dir_cash_flow="${base_dir_cash_flow}/${year}-${month}" dir_cash_receipts="${dir_cash_flow}/$bill_receipts" dir_cash_cost="${dir_cash_flow}/$bill_cost" +dir_cash_storno="${dir_cash_flow}/$bill_storno" echo @@ -282,6 +285,19 @@ else echo_skipped fi +echononl "Create directory '$(basename "$dir_cash_storno")'.." +if [[ ! -d "$dir_cash_storno" ]]; then + mkdir "$dir_cash_storno" > $logfile 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error $(cat $logfile) + fi +else + echo_skipped +fi + @@ -324,6 +340,30 @@ else echo_skipped fi + +# --- +# - Cash flow storno +# --- + +echo "" +echo "" +echo -e "\033[37m\033[1mCreate cash flow storno (Stornorechnungen)..\033[m" +echo "" + +found_cash_storno=false +while IFS='' read -r -d '' _storno_rg_pdf ; do + found_cash_storno=true + echononl "Kopiere Stornorechnung '$(basename "$_storno_rg_pdf")'.." + cp -a "$_storno_rg_pdf" "$dir_cash_storno" > $logfile 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error $(cat $logfile) + fi +done < <(find "$src_dir_cash_storno" -maxdepth 1 -type f -name "storno-${year}-${month}*.pdf" -print0) + + # --- # - Cash flow receipts # --- @@ -389,6 +429,7 @@ while IFS='' read -r -d '' dir ; do copy_file "$(basename "$dir")" "" done < <(find "$src_dir_cash_cost/" -mindepth 1 -maxdepth 1 -type d -print0) + # --- # - Create zip archive # --- @@ -439,7 +480,7 @@ if ! $found_bank_transaction ; then error "No transaction volumes found." fi if ! $found_bank_statement ; then - error "No bank statement file found." + warn "No bank statement file found." else echo fi