! budget 1 20230813 20230902
18.0
A console script written in the Python programming language that helps you to calculate the total budget for a given period between two dates.
The console script and its documentation were created with nbdev.
(Note: The application has not been released to PyPI yet. Use pip install -e .
at the root folder of the local cloned repository.)
The simplest usage example:
This means that if the daily budget is 1 dollar, and if we are budgeting for only six days in each week (i.e. only from Monday to Saturday), the total budget for the period from 13 August 2023 to 2 September 2023 would come to 18 dollars.
We can change the budgeting to be for all seven days of each week by specifying the --days_in_week
option with a value of 7:
In this case, the total budget for the period becomes 21 dollars.
The default value of the days_in_week
argument is 6.
We can also specify the daily weights to apply. For example:
Here, the specified --weights
means that we want to apply a multiplier of 1 on every Monday, Wednesday, Thursday, Friday, and Saturday; a multiplier of 2 on every Tuesday; and, a multiplier of 0 on every Sunday. The total budget would be 21 dollars.
Note: When the --weights
option is used, it will supersede the --days_in_week
option. Also, the --weights
option must be a string representation of a list with exactly seven elements, and where each of them has to be either an integer, or a real number.
Finally, we can also specify a different daily budget to use for each day of the week with the --amounts
option:
Note: When the --amounts
option is used, it will supersede the budget
amount (the ‘1’ in the above example) that we have specified. The --amounts
option must be a string representation of a list with exactly seven elements, and where each of them has to be either an integer, or a real number.
If you need help on the usage, you can type the following command (excluding the exclamation mark) in your terminal:
usage: budget [-h] [--days_in_week DAYS_IN_WEEK] [--weights WEIGHTS]
[--amounts AMOUNTS]
budget start_date end_date
Return the total budget for the calculation period from the start date to the
end date (inclusive).
positional arguments:
budget The budget amount per day
start_date The start date of the calculation period; it is
expected to be in the ISO 8601 format
end_date The end date of the calculation period; it is
expected to be in the ISO 8601 format
options:
-h, --help show this help message and exit
--days_in_week DAYS_IN_WEEK The number of consecutive days in a week
(starting from Monday) to include in the budget
(default: 6)
--weights WEIGHTS The weight to apply for each day of a week, and
specified as '[x0, .. , xn]', where x0..xn are
numbers; this will override --days_in_week
--amounts AMOUNTS The budget amount for each day of a week, and
specified as '[x0, .. , xn]', where x0..xn are
numbers; the budget amount per day that was
specified will be ignored