Added pricing field for single spool
This commit is contained in:
@@ -133,6 +133,11 @@ class Spool(BaseModel):
|
||||
first_used: Optional[datetime] = Field(description="First logged occurence of spool usage. UTC Timezone.")
|
||||
last_used: Optional[datetime] = Field(description="Last logged occurence of spool usage. UTC Timezone.")
|
||||
filament: Filament = Field(description="The filament type of this spool.")
|
||||
price: Optional[float] = Field(
|
||||
ge=0,
|
||||
description="The price of this spool in the system configured currency.",
|
||||
example=20.0,
|
||||
)
|
||||
remaining_weight: Optional[float] = Field(
|
||||
default=None,
|
||||
ge=0,
|
||||
|
||||
@@ -34,6 +34,11 @@ class SpoolParameters(BaseModel):
|
||||
first_used: Optional[datetime] = Field(description="First logged occurence of spool usage.")
|
||||
last_used: Optional[datetime] = Field(description="Last logged occurence of spool usage.")
|
||||
filament_id: int = Field(description="The ID of the filament type of this spool.")
|
||||
price: Optional[float] = Field(
|
||||
ge=0,
|
||||
description="The price of this filament in the system configured currency.",
|
||||
example=20.0,
|
||||
)
|
||||
remaining_weight: Optional[float] = Field(
|
||||
ge=0,
|
||||
description=(
|
||||
@@ -336,6 +341,7 @@ async def create( # noqa: ANN201
|
||||
db_item = await spool.create(
|
||||
db=db,
|
||||
filament_id=body.filament_id,
|
||||
price=body.price,
|
||||
remaining_weight=body.remaining_weight,
|
||||
used_weight=body.used_weight,
|
||||
first_used=body.first_used,
|
||||
|
||||
@@ -50,6 +50,7 @@ class Spool(Base):
|
||||
registered: Mapped[datetime] = mapped_column()
|
||||
first_used: Mapped[Optional[datetime]] = mapped_column()
|
||||
last_used: Mapped[Optional[datetime]] = mapped_column()
|
||||
price: Mapped[Optional[float]] = mapped_column()
|
||||
filament_id: Mapped[int] = mapped_column(ForeignKey("filament.id"))
|
||||
filament: Mapped["Filament"] = relationship(back_populates="spools")
|
||||
used_weight: Mapped[float] = mapped_column()
|
||||
|
||||
@@ -38,6 +38,7 @@ async def create(
|
||||
used_weight: Optional[float] = None,
|
||||
first_used: Optional[datetime] = None,
|
||||
last_used: Optional[datetime] = None,
|
||||
price: Optional[float] = None,
|
||||
location: Optional[str] = None,
|
||||
lot_nr: Optional[str] = None,
|
||||
comment: Optional[str] = None,
|
||||
|
||||
Reference in New Issue
Block a user