diff --git a/container/src/hledger-flow/accounts/vultr/template/vultr-shared.bash b/container/src/hledger-flow/accounts/vultr/template/vultr-shared.bash new file mode 100755 index 0000000..4f34bfa --- /dev/null +++ b/container/src/hledger-flow/accounts/vultr/template/vultr-shared.bash @@ -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 . + +[ -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 diff --git a/container/src/hledger-flow/accounts/vultr/template/vultr-shared.rules b/container/src/hledger-flow/accounts/vultr/template/vultr-shared.rules new file mode 100644 index 0000000..7380334 --- /dev/null +++ b/container/src/hledger-flow/accounts/vultr/template/vultr-shared.rules @@ -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 . + +include ../../../../../src/accounts/vultr/vultr-shared.rules + +# vim: sw=2 sts=2 si ai et diff --git a/container/src/hledger-flow/accounts/vultr/template/vultr/credits/1-in/mockup/2022/invoice_12345678.csv b/container/src/hledger-flow/accounts/vultr/template/vultr/credits/1-in/mockup/2022/invoice_12345678.csv new file mode 100644 index 0000000..b1dfcd8 --- /dev/null +++ b/container/src/hledger-flow/accounts/vultr/template/vultr/credits/1-in/mockup/2022/invoice_12345678.csv @@ -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" diff --git a/container/src/hledger-flow/accounts/vultr/template/vultr/credits/1-in/mockup/2023/invoice_12345678.csv b/container/src/hledger-flow/accounts/vultr/template/vultr/credits/1-in/mockup/2023/invoice_12345678.csv new file mode 100644 index 0000000..b1dfcd8 --- /dev/null +++ b/container/src/hledger-flow/accounts/vultr/template/vultr/credits/1-in/mockup/2023/invoice_12345678.csv @@ -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" diff --git a/container/src/hledger-flow/accounts/vultr/template/vultr/credits/1-in/mockup/2024/invoice_12345678.csv b/container/src/hledger-flow/accounts/vultr/template/vultr/credits/1-in/mockup/2024/invoice_12345678.csv new file mode 100644 index 0000000..b1dfcd8 --- /dev/null +++ b/container/src/hledger-flow/accounts/vultr/template/vultr/credits/1-in/mockup/2024/invoice_12345678.csv @@ -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" diff --git a/container/src/hledger-flow/accounts/vultr/template/vultr/credits/preprocess b/container/src/hledger-flow/accounts/vultr/template/vultr/credits/preprocess new file mode 120000 index 0000000..891c52a --- /dev/null +++ b/container/src/hledger-flow/accounts/vultr/template/vultr/credits/preprocess @@ -0,0 +1 @@ +../../vultr-shared.bash \ No newline at end of file diff --git a/container/src/hledger-flow/accounts/vultr/template/vultr/credits/vultr-credits.rules b/container/src/hledger-flow/accounts/vultr/template/vultr/credits/vultr-credits.rules new file mode 100644 index 0000000..3a54a09 --- /dev/null +++ b/container/src/hledger-flow/accounts/vultr/template/vultr/credits/vultr-credits.rules @@ -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 . + +include ../../vultr-shared.rules + +# vim: sw=2 sts=2 si ai et diff --git a/container/src/hledger-flow/accounts/vultr/vultr-shared.bash b/container/src/hledger-flow/accounts/vultr/vultr-shared.bash new file mode 100755 index 0000000..8d08d23 --- /dev/null +++ b/container/src/hledger-flow/accounts/vultr/vultr-shared.bash @@ -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 . + +# +# "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 diff --git a/container/src/hledger-flow/accounts/vultr/vultr-shared.rules b/container/src/hledger-flow/accounts/vultr/vultr-shared.rules new file mode 100644 index 0000000..4c827d3 --- /dev/null +++ b/container/src/hledger-flow/accounts/vultr/vultr-shared.rules @@ -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 . + +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