def populateBarcodeDetails():

	print(sys._getframe().f_code.co_name + ": ")

	dao = BarcodeDAO(gc_connector)

	entries = [
				(1, 1, 11, 44.5, 10, "M"),
				(2, 2, 11, 44.5, 10, "M"),
				(3, 3, 12, 46, 11, "M"),
				(4, 4, 11, 44.5, 10, "M"),
				(5, 5, 8, 41, 7.5, "M"),
				(6, 6, 9, 43, 8.5, "M"),
				(7, 7, 12, 46, 11, "M"),
				(8, 8, 11, 44.5, 10, "M"),
				(9, 9, 8.5, 41.5, 8, "M"),
				(10, 10, 9, 43, 8.5, "M"),
				(11, 11, 8, 41, 7.5, "M"),
				(12, 12, 12, 46, 11, "M")
			  ]

	for entry in entries:
		dao.createAnEntry(entry)

	print(dao.selectAllEntries())

	print("===================================================")
	print("Testing populateBarcodeDetails-------------------complete\n\n\n")
def populateBarcodeDetails():

	print(sys._getframe().f_code.co_name + ": ")

	dao = BarcodeDAO(gc_connector)

	footwearSelectionDetailsFk = 1
	US_size = 1
	EUR_size = 2
	UK_size = 3
	gender = ("M", "F")

	for i in range(1, 5+1):
		entry = (i,
				 footwearSelectionDetailsFk,
				 US_size,
				 EUR_size,
				 UK_size,
				 gender[i%2])
		dao.createAnEntry(entry)

		footwearSelectionDetailsFk += 1
		US_size += 3
		EUR_size += 3
		UK_size += 3

	print(dao.selectAllEntries())

	print("===================================================")
	print("Testing populateBarcodeDetails-------------------complete\n\n\n")
示例#3
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)
示例#4
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
def testNumItemsAvailable():
	dbConnect = DbConnect(BarcodeDAO.getDbDir())
	connector = dbConnect.getConnection()

	service = AndroidService()
	print(service.numItemsAvailable(1))
	print("===================================================")
	print("Testing numItemsAvailable-------------------complete\n\n\n")
示例#6
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)
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")
示例#8
0
	def getSecondPageInfo(self, selection):

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

		footwearSelectionDAO = FootwearSelectionDAO(connector)
		footwearSelectionPriKeys = footwearSelectionDAO.getPriKeys("Selection", selection)

		retVal = list()

		barcodeDAO = BarcodeDAO(connector)
		for footwearSelectionPriKey in footwearSelectionPriKeys:
			entries = barcodeDAO.selectEntries("FootwearSelectionDetailsFk", footwearSelectionPriKey)

			barcodePriKey = entries[0]

			inventoryDAO = InventoryDAO(connector)
			inventories = inventoryDAO.getPriKeys("BarcodeDetailsFk", barcodePriKey)

			for entry in entries:
				retVal.append((entry[1], entry[3], entry[4], entry[5], entry[6], len(inventories) ) )

		return retVal