costs

Tool to help you see the impact of recurring costs
Log | Files | Refs | README

commit 36b193e0ad761334dd934a957014084b1ae5e096
parent 293d8b3006b06c89d3590a5b2d61b9288469d5f9
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Sun,  6 Aug 2023 07:44:40 -0700

Allow steps with time period

By appending /number to a time period, you end up multiplying that
period by the number. For example month/3 is three months.

Diffstat:
Mcosts.awk | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/costs.awk b/costs.awk @@ -40,9 +40,16 @@ BEGIN { } /^[^# ]/ && ! /^$/ { - if (! $period in t) - die($period " not a valid period"); - daily = $amount / t[$period]; + m = 1 + n = split($period, ts, "/") + if (n > 2 || !(ts[1] in t) || (n > 2 && ts[2] == 0)) + die($period ": Invalid period") + + if (n > 1) + m = ts[2] + x = t[ts[1]] * m + + daily = $amount / x if (maketotal) total += daily * t[output]; else