Changed initial_weight to be net weight, not gross weight

This commit is contained in:
Matt Gerega
2024-04-10 11:00:46 -04:00
parent dad446621f
commit c6f9abeced
14 changed files with 159 additions and 203 deletions

View File

@@ -190,10 +190,10 @@ class Spool(BaseModel):
initial_weight: Optional[float] = Field(
default=None,
ge=0,
description=("Initial weight of the filament and spool (gross weight)"),
description=("The initial weight, in grams, of the filament on the spool (net weight)."),
example=1246,
)
empty_weight: Optional[float] = Field(
spool_weight: Optional[float] = Field(
default=None,
ge=0,
description=("Weight of an empty spool (tare weight)."),
@@ -242,9 +242,7 @@ class Spool(BaseModel):
remaining_length: Optional[float] = None
if item.initial_weight is not None:
filament_spool_weight = item.filament.spool_weight if item.filament.spool_weight is not None else 0
spool_weight = item.empty_weight if item.empty_weight is not None else filament_spool_weight
remaining_weight = max(item.initial_weight - spool_weight - item.used_weight, 0)
remaining_weight = max(item.initial_weight - item.used_weight, 0)
remaining_length = length_from_weight(
weight=remaining_weight,
density=filament.density,
@@ -272,7 +270,7 @@ class Spool(BaseModel):
filament=filament,
price=item.price,
initial_weight=item.initial_weight,
empty_weight=item.empty_weight,
spool_weight=item.spool_weight,
used_weight=item.used_weight,
used_length=used_length,
remaining_weight=remaining_weight,