Exemplo n.º 1
0
    def decrease_stock(self, pet_type, amount):
        """Decrease the current stock levels for a given pet type."""
        if pet_type not in self._inventory:
            raise errors.InventoryError("Pet not in inventory system")
        if amount > self._inventory[pet_type].count:
            raise errors.InventoryError("Insufficient stock")

        self._inventory[pet_type].count -= amount
        self._inventory[pet_type].stock_sold += amount
Exemplo n.º 2
0
    def increase_stock(self, pet_type, amount):
        """Increase the current stock count for a given pet type."""
        if pet_type not in self._inventory:
            raise errors.InventoryError("Pet not in inventory system")

        self._inventory[pet_type].count += amount
        self._inventory[pet_type].stock_received += amount
        if self._inventory[pet_type].on_order < amount:
            self._inventory[pet_type].on_order = 0
        else:
            self._inventory[pet_type].on_order -= amount
Exemplo n.º 3
0
    def write_off_stock(self, pet_type, amount):
        """Decreases the current stock levels for a given pet type to
        account for losses.
        """
        if pet_type not in self._inventory:
            raise errors.InventoryError("Pet not in inventory system")

        # Cannot loss more than the amount actually in stock
        if amount > self._inventory[pet_type].count:
            self._inventory[pet_type].stock_lost +=\
                    self._inventory[pet_type].count
            self._inventory[pet_type].count = 0
        else:
            self._inventory[pet_type].count -= amount
            self._inventory[pet_type].stock_lost += amount
Exemplo n.º 4
0
    def order_stock(self, pet_type, amount):
        if pet_type not in self._inventory:
            raise errors.InventoryError("Pet not in inventory system")

        self._inventory[pet_type].on_order = amount
Exemplo n.º 5
0
    def add_new_pet_type(self, pet):
        """Add a new specific pet type to inventory (i.e. goldfish)."""
        if pet.name in self._inventory:
            raise errors.InventoryError("Pet type already in inventory")

        self._inventory[pet.name] = pet