From cb84052d734a4d44ddafd1d53af9c6ec487db4fd Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Wed, 14 Feb 2018 15:18:22 +0000 Subject: [PATCH] =?UTF-8?q?Bug=201803=20-=20Cr=C3=A9er=20un=20outil=20de?= =?UTF-8?q?=20suivi=20des=20achats=20et=20d'inventaire=20IPR-ISCR=20:=20aj?= =?UTF-8?q?out=20de=20la=20prise=20en=20compte=20des=20maintenances?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inventory.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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