create_monthly_cash_flow.sh: warn instead of error if no bank statement found.

This commit is contained in:
Christoph 2020-07-01 05:57:25 +02:00
parent 83c39e7886
commit 6346841e5b

View File

@ -12,6 +12,7 @@ src_base_dir_cash_flow="${office_dir}/Einnahmen/"
bill_receipts="Rechnungen Einnahmen" bill_receipts="Rechnungen Einnahmen"
bill_cost="Rechnungen Ausgaben" bill_cost="Rechnungen Ausgaben"
bill_storno="Storno Rechnungen"
backup_time="$(date +%Y-%m-%d-%H%M)" backup_time="$(date +%Y-%m-%d-%H%M)"
@ -185,6 +186,7 @@ fi
src_dir_cash_receipts="${office_dir}/Einnahmen/${year}" 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_cash_cost="${office_dir}/Ausgaben/${year}/$month"
src_dir_bank_statement="$base_dir_bank_statement/${year}" 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_flow="${base_dir_cash_flow}/${year}-${month}"
dir_cash_receipts="${dir_cash_flow}/$bill_receipts" dir_cash_receipts="${dir_cash_flow}/$bill_receipts"
dir_cash_cost="${dir_cash_flow}/$bill_cost" dir_cash_cost="${dir_cash_flow}/$bill_cost"
dir_cash_storno="${dir_cash_flow}/$bill_storno"
echo echo
@ -282,6 +285,19 @@ else
echo_skipped echo_skipped
fi 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 echo_skipped
fi 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 # - Cash flow receipts
# --- # ---
@ -389,6 +429,7 @@ while IFS='' read -r -d '' dir ; do
copy_file "$(basename "$dir")" "" copy_file "$(basename "$dir")" ""
done < <(find "$src_dir_cash_cost/" -mindepth 1 -maxdepth 1 -type d -print0) done < <(find "$src_dir_cash_cost/" -mindepth 1 -maxdepth 1 -type d -print0)
# --- # ---
# - Create zip archive # - Create zip archive
# --- # ---
@ -439,7 +480,7 @@ if ! $found_bank_transaction ; then
error "No transaction volumes found." error "No transaction volumes found."
fi fi
if ! $found_bank_statement ; then if ! $found_bank_statement ; then
error "No bank statement file found." warn "No bank statement file found."
else else
echo echo
fi fi