Bug 1803 - Créer un outil de suivi des achats et d'inventaire IPR-ISCR : ajout de la prise en compte des maintenances

This commit is contained in:
Guillaume Raffy 2018-02-14 15:18:22 +00:00
parent 8e32bd1bc8
commit cb84052d73
1 changed files with 9 additions and 2 deletions

View File

@ -117,7 +117,7 @@ class Inventory( object ):
container_id = rows[0][0] container_id = rows[0][0]
return container_id 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.) :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 :return float: the price of the item exluding taxes
@ -127,12 +127,19 @@ class Inventory( object ):
item_price = 0.0 item_price = 0.0
else: else:
item_price = float(item_price) 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: if include_contents:
# add the price of included parts # add the price of included parts
rows = self._sql_reader.query("SELECT part_id FROM container WHERE container_id='%s'" % item_id) rows = self._sql_reader.query("SELECT part_id FROM container WHERE container_id='%s'" % item_id)
for row in rows: for row in rows:
part_id = row[0] 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)) #print(u'price of %s : %.2f € HT' % (item_id, item_price))
return item_price return item_price