forked from EvergreenCrypto/docker-finance
container: hledger-flow: add Vultr support
This addition is treading a fine line between finance and other
accounting, as Vultr cloud service is related to DevOps and is also not
a financial entity. However, financial information is provided; so this
addition is useful.
With this commit, a precedent is set for other cloud services to be
added to the repository (services that provide CSV financial accounting
data) and I believe that they could (should) be added as needed.
NOTE: there are several upstream CSV issues:
- Only expenses are given
* Transfers must be added manually (manual import or custom rules)
- Sales tax is not included
* Sales tax expenses must be added manually
This commit is contained in:
23
container/src/hledger-flow/accounts/vultr/template/vultr-shared.bash
Executable file
23
container/src/hledger-flow/accounts/vultr/template/vultr-shared.bash
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2024 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
[ -z "$DOCKER_FINANCE_CONTAINER_REPO" ] && exit 1
|
||||
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/hledger-flow/accounts/vultr/vultr-shared.bash"
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
@@ -0,0 +1,20 @@
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2024 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
include ../../../../../src/accounts/vultr/vultr-shared.rules
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
@@ -0,0 +1,2 @@
|
||||
"2024-01-01 01:01","2024-02-01 01:01","123.123.123.123 (4096 MB) [abc123.domain]","0.00","456","12.34"
|
||||
"2024-01-01 01:01","2024-02-01 01:01","Backup Service for 123.123.123.123","0.00","123","1.23"
|
||||
|
@@ -0,0 +1,2 @@
|
||||
"2024-01-01 01:01","2024-02-01 01:01","123.123.123.123 (4096 MB) [abc123.domain]","0.00","456","12.34"
|
||||
"2024-01-01 01:01","2024-02-01 01:01","Backup Service for 123.123.123.123","0.00","123","1.23"
|
||||
|
@@ -0,0 +1,2 @@
|
||||
"2024-01-01 01:01","2024-02-01 01:01","123.123.123.123 (4096 MB) [abc123.domain]","0.00","456","12.34"
|
||||
"2024-01-01 01:01","2024-02-01 01:01","Backup Service for 123.123.123.123","0.00","123","1.23"
|
||||
|
@@ -0,0 +1 @@
|
||||
../../vultr-shared.bash
|
||||
@@ -0,0 +1,20 @@
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2024 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
include ../../vultr-shared.rules
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
88
container/src/hledger-flow/accounts/vultr/vultr-shared.bash
Executable file
88
container/src/hledger-flow/accounts/vultr/vultr-shared.bash
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2024 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#
|
||||
# "Libraries"
|
||||
#
|
||||
|
||||
[ -z "$DOCKER_FINANCE_CONTAINER_REPO" ] && exit 1
|
||||
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/hledger-flow/lib/lib_preprocess.bash" "$1" "$2"
|
||||
|
||||
#
|
||||
# Implementation
|
||||
#
|
||||
|
||||
function parse()
|
||||
{
|
||||
[ -z "$global_year" ] && exit 1
|
||||
[ -z "$global_subaccount" ] && exit 1
|
||||
|
||||
[ -z "$global_in_path" ] && exit 1
|
||||
[ -z "$global_out_path" ] && exit 1
|
||||
|
||||
#
|
||||
# NOTE:
|
||||
#
|
||||
# - Upstream does not provide CSV header
|
||||
#
|
||||
# - Invoice number is provided as filename
|
||||
# * invoice_12345678.csv
|
||||
#
|
||||
|
||||
[ -z "$global_in_filename" ] && exit 1
|
||||
local -r _invoice="${global_in_filename:8:8}"
|
||||
|
||||
gawk \
|
||||
-v global_year="$global_year" \
|
||||
-v global_subaccount="$global_subaccount" \
|
||||
-v invoice="$_invoice" \
|
||||
'{
|
||||
if ($2 !~ global_year)
|
||||
next
|
||||
|
||||
# Skip $1 # start date
|
||||
|
||||
printf $2 OFS # end date (date)
|
||||
printf $3 OFS # description
|
||||
|
||||
# Skip $4
|
||||
|
||||
printf $5 OFS # quantity
|
||||
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"
|
||||
}' FS=, OFS=, "$global_in_path" >"$global_out_path"
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
parse
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
30
container/src/hledger-flow/accounts/vultr/vultr-shared.rules
Normal file
30
container/src/hledger-flow/accounts/vultr/vultr-shared.rules
Normal file
@@ -0,0 +1,30 @@
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2024 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
fields date,description,quantity,amount_,invoice,direction,subaccount
|
||||
|
||||
date-format %Y-%m-%d %H:%M
|
||||
|
||||
account1 assets:vultr:%subaccount:USD
|
||||
amount -%amount_ USD
|
||||
|
||||
comment invoice:%invoice, quantity:%quantity, direction:%direction
|
||||
|
||||
# NOTE: Vultr currently only provides expenses w/out sales tax
|
||||
account2 expenses:vultr:%subaccount:USD
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
Reference in New Issue
Block a user