示例#1
0
	def depositInventory(self, barcode, x_index, y_index, x_encoder, y_encoder):
		
		dbConnect = DbConnect(InventoryDAO.getDbDir())
		connector = dbConnect.getConnection()


		barcodeDAO = BarcodeDAO(connector)
		barcodeId = barcodeDAO.getPriKeys("Barcode", barcode)[0]


		inventoryDAO = InventoryDAO(connector)
		entry = (barcodeId, x_index, y_index, x_encoder, y_encoder, 0)
		inventoryDAO.createAnEntry(entry)
示例#2
0
	def __numItemsAvailable(self, connector, barcode):

		barcodeDAO = BarcodeDAO(connector)
		barcodeColHeader = "Barcode"
		barcodePriKey = barcodeDAO.getPriKeys(barcodeColHeader, barcode)[0]

		inventoryDAO = InventoryDAO(connector)
		numItems = 0

		barcodesInInventory = inventoryDAO.getPriKeys("BarcodeDetailsFk", barcodePriKey)

		for barcodeInInventory in barcodesInInventory:
			if inventoryDAO.selectAColumn("CheckoutFlag", barcodeInInventory) == 0:
				numItems += 1

		return numItems
示例#3
0
	def reserveInventoryIfAvailable(self, customerId, barcode, quantity):

		dbConnect = DbConnect(BarcodeDAO.getDbDir())
		connector = dbConnect.getConnection()

		# the customer should order the exact amount. For example if there exists 1 item in the
		# back room and the customer ordered 2 items, then the whole transaction is rejected.
		# if returning false, the available quantity
		numAvailableItem = self.__numItemsAvailable(connector, barcode)
		if numAvailableItem < quantity:
			return (False, numAvailableItem)


		barcodeDAO = BarcodeDAO(connector)
		barcodePriKey = barcodeDAO.getPriKeys("Barcode", barcode)[0]


		inventoryDAO = InventoryDAO(connector)
		inventoryEntries = inventoryDAO.selectEntries("BarcodeDetailsFk", barcodePriKey)


		virtualCartDAO = VirtualCartDAO(connector)
		newVirtualCartRowId = virtualCartDAO.createAnEntry( (customerId, barcodePriKey, quantity, 0) )


		reservedInventoryLoc = list()

		reserveCount = 0
		for inventoryEntry in inventoryEntries:

			if reserveCount == quantity:
				break

			if inventoryEntry[6] != 0:
				continue

			inventoryDAO.update(inventoryEntry[0], "CheckoutFlag", 1)

			# [inventoryDetailsId, barcodeDetailsFk, X_index, Y_index, X_encoder, Y_encoder, checkoutFlag]
			entry = inventoryDAO.selectAnEntry(inventoryEntry[0])

			reservedInventoryLoc.append(entry[0:1]+entry[2:6]) # omit barcodeDetailsFk and checkoutFlag
			reserveCount += 1

		return (True, reservedInventoryLoc, newVirtualCartRowId)