From e3f50ddb72c25379adb1d080b220184c62c41b94 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Tue, 23 Sep 2025 17:13:13 -0700 Subject: [PATCH] container: hledger-flow: vultr: add credits support - Fixes direction to allow for credits issued by Vultr for N instances - Updates documentation, adds where to put invoices to catch Sales Tax --- .../hledger-flow/accounts/vultr/vultr-shared.bash | 12 +++++++++--- .../hledger-flow/accounts/vultr/vultr-shared.rules | 11 ++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/container/src/hledger-flow/accounts/vultr/vultr-shared.bash b/container/src/hledger-flow/accounts/vultr/vultr-shared.bash index 389bf18..4cde798 100755 --- a/container/src/hledger-flow/accounts/vultr/vultr-shared.bash +++ b/container/src/hledger-flow/accounts/vultr/vultr-shared.bash @@ -53,6 +53,12 @@ function parse() -v global_subaccount="$global_subaccount" \ -v invoice="$_invoice" \ '{ + # WARNING: + # + # Because upstream INVOICE DATE will be at beginning of the month, + # any January invoices *MUST* also go into the previous year December, + # in order to catch Sales Tax issued on the 1st for the previous month. + if ($2 !~ global_year) next @@ -66,14 +72,14 @@ function parse() # Skip $4 printf $5 OFS # quantity + + direction = ($6 ~ /^"-/ ? "IN" : "OUT") + sub(/^"-/, "\"", $6) printf $6 OFS # amount printf invoice OFS # invoice number - # NOTE: Vultr currently only provides expenses w/out sales tax - direction="OUT" printf direction OFS - printf global_subaccount printf "\n" diff --git a/container/src/hledger-flow/accounts/vultr/vultr-shared.rules b/container/src/hledger-flow/accounts/vultr/vultr-shared.rules index 7eafd36..cfff0ef 100644 --- a/container/src/hledger-flow/accounts/vultr/vultr-shared.rules +++ b/container/src/hledger-flow/accounts/vultr/vultr-shared.rules @@ -1,6 +1,6 @@ # docker-finance | modern accounting for the power-user # -# Copyright (C) 2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# Copyright (C) 2024-2025 Aaron Fiore (Founder, Evergreen Crypto LLC) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,11 +20,16 @@ fields date,description,quantity,amount_,invoice,direction,subaccount date-format %Y-%m-%d %H:%M account1 assets:vultr:%subaccount:USD -amount -%amount_ USD +amount %amount_ USD comment invoice:%invoice, quantity:%quantity, direction:%direction -account2 expenses:vultr:%subaccount:USD +if %direction ^IN$ + account2 income:vultr:%subaccount:credits:USD + +if %direction ^OUT$ + amount -%amount_ USD + account2 expenses:vultr:%subaccount:USD if %description ^Sales Tax$ account2 expenses:vultr:%subaccount:sales_tax:USD