diff --git a/inventory.py b/inventory.py index 7810e73..b143862 100644 --- a/inventory.py +++ b/inventory.py @@ -117,7 +117,7 @@ class Inventory( object ): container_id = rows[0][0] return container_id - def get_item_price(self, item_id, include_contents=False): + def get_item_price(self, item_id, include_contents=False, include_maintenance=False): """ :param str item_id: the identifier of an inventory item (a machine (eg simpa-switch002), a group of machines (ceph), etc.) :return float: the price of the item exluding taxes @@ -127,12 +127,19 @@ class Inventory( object ): item_price = 0.0 else: item_price = float(item_price) + if include_maintenance: + # INSERT INTO `maintenance` (`maintenance_id`, `machine_id`, `price_ex_vat`, `command_id`, `comment`) VALUES + rows = self._sql_reader.query("SELECT price_ex_vat FROM maintenance WHERE machine_id='%s'" % item_id) + for row in rows: + maintenance_price_ex_vat = float(row[0]) + item_price += maintenance_price_ex_vat + if include_contents: # add the price of included parts rows = self._sql_reader.query("SELECT part_id FROM container WHERE container_id='%s'" % item_id) for row in rows: part_id = row[0] - item_price += self.get_item_price(part_id, include_contents) + item_price += self.get_item_price(part_id, include_contents, include_maintenance) #print(u'price of %s : %.2f € HT' % (item_id, item_price)) return item_price