feat: Add extra weight, price tracking, print history, usage analytics
Some checks failed
CI / style (push) Has been cancelled
CI / build-client (push) Has been cancelled
CI / build-amd64 (push) Has been cancelled
CI / build-tester (push) Has been cancelled
CI / test (cockroachdb) (push) Has been cancelled
CI / test (mariadb) (push) Has been cancelled
CI / test (postgres) (push) Has been cancelled
CI / test (sqlite) (push) Has been cancelled
CI / build-arm64 (push) Has been cancelled
CI / build-armv7 (push) Has been cancelled
CI / publish-images (push) Has been cancelled
CI / publish-release (push) Has been cancelled
Some checks failed
CI / style (push) Has been cancelled
CI / build-client (push) Has been cancelled
CI / build-amd64 (push) Has been cancelled
CI / build-tester (push) Has been cancelled
CI / test (cockroachdb) (push) Has been cancelled
CI / test (mariadb) (push) Has been cancelled
CI / test (postgres) (push) Has been cancelled
CI / test (sqlite) (push) Has been cancelled
CI / build-arm64 (push) Has been cancelled
CI / build-armv7 (push) Has been cancelled
CI / publish-images (push) Has been cancelled
CI / publish-release (push) Has been cancelled
- Extra Weight Field (#14): Track DryPods, custom holders in spool weight calculations. New extra_weight field on spool with DB migration. - Price/Cost Tracking: Compute remaining_value based on remaining weight and price. Added column to spool list, inventory value on dashboard. - Print History: Show print job history on spool detail page with collapsible table showing filename, filament used, status, dates. - Usage Analytics: New dashboard component with time-series chart showing daily consumption, period selector (7/30/90 days), and material breakdown. New API endpoints for analytics data. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -311,6 +311,12 @@ class Spool(BaseModel):
|
||||
description=("Weight of an empty spool (tare weight)."),
|
||||
examples=[246],
|
||||
)
|
||||
extra_weight: Optional[float] = Field(
|
||||
default=None,
|
||||
ge=0,
|
||||
description=("Extra weight to account for, such as DryPods, custom spool holders, etc."),
|
||||
examples=[50],
|
||||
)
|
||||
used_weight: float = Field(
|
||||
ge=0,
|
||||
description="Consumed weight of filament from the spool in grams.",
|
||||
@@ -325,6 +331,12 @@ class Spool(BaseModel):
|
||||
),
|
||||
examples=[5612.4],
|
||||
)
|
||||
remaining_value: Optional[float] = Field(
|
||||
default=None,
|
||||
ge=0,
|
||||
description="Estimated remaining value of filament on the spool based on remaining weight and price.",
|
||||
examples=[12.50],
|
||||
)
|
||||
used_length: float = Field(
|
||||
ge=0,
|
||||
description="Consumed length of filament from the spool in millimeters.",
|
||||
@@ -389,6 +401,13 @@ class Spool(BaseModel):
|
||||
diameter=filament.diameter,
|
||||
)
|
||||
|
||||
# Calculate remaining value based on remaining weight and price
|
||||
remaining_value: Optional[float] = None
|
||||
price = item.price if item.price is not None else filament.price
|
||||
initial_weight = item.initial_weight if item.initial_weight is not None else filament.weight
|
||||
if remaining_weight is not None and price is not None and initial_weight is not None and initial_weight > 0:
|
||||
remaining_value = round((remaining_weight / initial_weight) * price, 2)
|
||||
|
||||
return Spool(
|
||||
id=item.id,
|
||||
registered=item.registered,
|
||||
@@ -398,10 +417,12 @@ class Spool(BaseModel):
|
||||
price=item.price,
|
||||
initial_weight=item.initial_weight,
|
||||
spool_weight=item.spool_weight,
|
||||
extra_weight=item.extra_weight,
|
||||
used_weight=item.used_weight,
|
||||
used_length=used_length,
|
||||
remaining_weight=remaining_weight,
|
||||
remaining_length=remaining_length,
|
||||
remaining_value=remaining_value,
|
||||
location=item.location,
|
||||
lot_nr=item.lot_nr,
|
||||
comment=item.comment,
|
||||
|
||||
Reference in New Issue
Block a user