Skip to content

Commit

Permalink
add SalePrice to the part class (#220)
Browse files Browse the repository at this point in the history
* add SalePrice

* add getSalePrice to part class

* change blank lines
  • Loading branch information
ljelschen committed Apr 30, 2024
1 parent 4c720b3 commit cdbdd51
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions inventree/part.py
Expand Up @@ -137,6 +137,12 @@ def setInternalPrice(self, quantity: int, price: float):
"""

return InternalPrice.setInternalPrice(self._api, self.pk, quantity, price)

def getSalePrice(self):
"""
Get sales prices for this part
"""
return SalePrice.list(self._api, part=self.pk)[0].price

def getRequirements(self):
"""
Expand Down Expand Up @@ -215,6 +221,28 @@ def setInternalPrice(cls, api, part, quantity: int, price: float):
return api.post(cls.URL, data)


class SalePrice(inventree.base.InventreeObject):
""" Class representing the SalePrice model """

URL = 'part/sale-price'

@classmethod
def setSalePrice(cls, api, part, quantity: int, price: float, price_currency: str):
"""
Set the sale price for this part
"""

data = {
'part': part,
'quantity': quantity,
'price': price,
'price_currency': price_currency,
}

# Send the data to the server
return api.post(cls.URL, data)


class PartRelated(inventree.base.InventreeObject):
""" Class representing a relationship between parts"""

Expand Down

0 comments on commit cdbdd51

Please sign in to comment.