def testNumItemsAvailable(): dbConnect = DbConnect(BarcodeDAO.getDbDir()) connector = dbConnect.getConnection() service = AndroidService() print(service.numItemsAvailable(1)) print("===================================================") print("Testing numItemsAvailable-------------------complete\n\n\n")
def testGetFirstPageInfo(): dbConnect = DbConnect(BarcodeDAO.getDbDir()) connector = dbConnect.getConnection() service = AndroidService() print(sys._getframe().f_code.co_name + ": ") print( service.getFirstPageInfo() ) print("===================================================") print("Testing getFirstPageInfo-------------------complete\n\n\n")
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)