commit a9ad50225115de3bf97e56775eb958e0f77ebb06 parent a1420ec26f017805ccaa1222038dc94f94428060 Author: Tomas Nemec <owl@gtms.dev> Date: Tue, 21 Nov 2023 07:31:31 +0100 fix: wrong comparing of numbers Diffstat:
M | fin-check-invoices | | | 27 | +++++++++++++++------------ |
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/fin-check-invoices b/fin-check-invoices @@ -34,21 +34,24 @@ comm -12 \ for vs in ${(f)found}; do # Fio Data - fio_data=$(jq ".[] | select(.vs == \"$vs\")" $fi) - fio_money=$(jq ".money | tonumber" <<< $fio_data) - fio_date=$(jq ".date" -r <<< $fio_data | cut -d+ -f1) - fio_from=$(jq "if .beneficiary_name == \"\" then .beneficiary_comment else .beneficiary_name end" -r <<< $fio_data) - fio_currency=$(jq ".currency" -r <<< $fio_data) + local fio_data=$(jq ".[] | select(.vs == \"$vs\")" $fi) + local -F fio_money=$(jq ".money | tonumber" <<< $fio_data) + local fio_date=$(jq ".date" -r <<< $fio_data | cut -d+ -f1) + local fio_from=$(jq "if .beneficiary_name == \"\" then .beneficiary_comment else .beneficiary_name end" -r <<< $fio_data) + local fio_currency=$(jq ".currency" -r <<< $fio_data) # Fakturoid Data - fak_data=$(jq ".[] | select(.variable_symbol == \"$vs\")" $fa) - fak_money=$(jq ".subtotal | tonumber" <<< $fak_data) - fak_id=$(jq ".id" <<< $fak_data) - fak_currency=$(jq ".currency" -r <<< $fak_data) + local fak_data=$(jq ".[] | select(.variable_symbol == \"$vs\")" $fa) + local -F fak_money=$(jq ".subtotal | tonumber" <<< $fak_data) + local fak_id=$(jq ".id" <<< $fak_data) + local fak_currency=$(jq ".currency" -r <<< $fak_data) print "Invoice $vs has been paid.\n" + + # TODO: check currency + # Money check [fak.total == fio.money] - mcheck="OK" - if [[ $fio_money != $fak_money ]]; then + local mcheck="OK" + if [[ $fio_money -ne $fak_money ]]; then mcheck="Failed: $(( $fio_money - $fak_money ))" print "Money check failed: FIO:$fio_money != FAK:$fak_money\n" >&2 fi @@ -60,7 +63,7 @@ for vs in ${(f)found}; do --paid-amount="$fio_money" # Generate rss page - from="" + local from="" if [[ -n "$fio_from" ]]; then from="[$fio_from]" fi