diff --git a/src/sup/cli.py b/src/sup/cli.py index 743d67c..20903b7 100644 --- a/src/sup/cli.py +++ b/src/sup/cli.py @@ -93,7 +93,7 @@ def status(): config = load_config() num_days_of_inventory_needed = config["FILL_EVERY_X_DAYS"] - next_fill_date = config["LAST_FILL_DATE"] + dt.timedelta( + next_fill_date = dt.datetime.strptime(config["LAST_FILL_DATE"], "%Y-%m-%d").date() + dt.timedelta( num_days_of_inventory_needed ) inventory = load_inventory() @@ -120,7 +120,6 @@ def status(): continue qty_of_inventory = get_qty_inventory(sup_inst, inv, next_fill_date) - print(sup_inst.name, int(qty_of_inventory / inv["numUnitsInServing"])) net_need = int(qty_needed - qty_of_inventory) if net_need > 0: @@ -146,9 +145,7 @@ def fill(): validate_matches() config = load_config() today = dt.date.today() - config["LAST_FILL_DATE"] = today.strftime("%Y-%m-%d") - # TODO: make sure this toml library doesn't add quotes to this entry, it - # makes it so when reading it doesn't get parsed to a date + config["LAST_FILL_DATE"] = today.strftime('%Y-%m-%d') fill_every_x_days = config["FILL_EVERY_X_DAYS"] save_config(config) print( diff --git a/src/sup/main.py b/src/sup/main.py index 8a66ae3..fb20c9d 100644 --- a/src/sup/main.py +++ b/src/sup/main.py @@ -4,11 +4,11 @@ TODO: special case: K Complex has K1, MK-4 and MK-7 in it """ -from dataclasses import dataclass import json import pathlib as pl import tomllib -import typing as t + +from sup.models import Supp ORDERED_SUPPS_FP = pl.Path("inventory.json") @@ -42,25 +42,3 @@ def load_inventory(): for s in load_ordered_supps() if s["name"] not in CONFIG["discontinued"] } - - -@dataclass -class Supp: - name: str - morning: int | float = 0 - lunch: int | float = 0 - dinner: int | float = 0 - bedtime: int | float = 0 - days_per_week: int = 7 - units: t.Literal["caps", "mg", "g", "ml", "mcg", "iu"] = "mg" - winter_only: bool = False - - def __mul__(self, other: int) -> float: - return self.quantity_per_day * other - - @property - def quantity_per_day(self) -> float: - return ( - sum([self.morning, self.lunch, self.dinner, self.bedtime]) - * self.days_per_week / 7 - ) diff --git a/src/sup/models.py b/src/sup/models.py new file mode 100644 index 0000000..527910e --- /dev/null +++ b/src/sup/models.py @@ -0,0 +1,24 @@ +from dataclasses import dataclass +import typing as t + + +@dataclass +class Supp: + name: str + morning: int | float = 0 + lunch: int | float = 0 + dinner: int | float = 0 + bedtime: int | float = 0 + days_per_week: int = 7 + units: t.Literal["caps", "mg", "g", "ml", "mcg", "iu"] = "mg" + winter_only: bool = False + + def __mul__(self, other: int) -> float: + return self.quantity_per_day * other + + @property + def quantity_per_day(self) -> float: + return ( + sum([self.morning, self.lunch, self.dinner, self.bedtime]) + * self.days_per_week / 7 + ) diff --git a/supps.toml b/supps.toml index b639912..7cd5c42 100644 --- a/supps.toml +++ b/supps.toml @@ -1,7 +1,6 @@ -discontinued = ['NAD+ Cell Regenerator', 'Fisetin with Novusetin', 'Fisetin Novusetin', 'Collagen'] +discontinued = [ "NAD+ Cell Regenerator", "Fisetin with Novusetin", "Fisetin Novusetin", "Collagen",] FILL_EVERY_X_DAYS = 30 -LAST_FILL_DATE = 2024-01-16 - +LAST_FILL_DATE = "2024-01-16" [[supps]] name = "ashwagandha" bedtime = 600 @@ -117,11 +116,11 @@ morning = 10 [[supps]] name = "k1" morning = 1500 -units="mcg" +units = "mcg" [[supps]] name = "k2-mk7" -morning = 300 # it's actually 600 but I get half of it from the d-3 + mk7 drops + the Super K +morning = 300 units = "mcg" [[supps]] @@ -215,4 +214,4 @@ B-50 = "b complex" "Super K" = "k1" "Ultimate Omega, Lemon" = "epa/dha" "Ultimate Omega" = "epa/dha" -"Lithium" = "lithium orotate" +Lithium = "lithium orotate"