예제 #1
0
파일: event.py 프로젝트: spr3nk3ls/koert
	def from_array(cls, ar, number, boozedir):
		if len(ar)==0 or len(ar[0])==0 or ar[0][0].lower()!="bar":
			raise MildErr("Missing 'bar' title")
		if len(ar)==1 or len(ar[1])<6:
			raise MildErr("Incomplete/missing header")
		# header:
		#   pricelist; date ; counter ; shift# ; 
		#        startbal ; endbal [; mutation ]
		#
		# Here: mutation the amount transferred to the
		# cash register during the shift.  For istance,
		# an "afroming" during a shift would lower this number.
		header = ar[1]
		pricelist_str = header[0]
		pricelist = boozedir.pricelistdir[pricelist_str]
		date = parse_moment(header[1])
		counter = header[2]
		shift = Shift.from_str(header[3])
		startbal = parse_decimal(header[4])
		endbal = parse_decimal(header[5])
		mutation = parse_decimal(header[6]) if len(header)>6 \
				else Decimal(0)
		# below, to translate "product@pricelist" to a commodity
		commodity_view = boozedir.commoditydir.get_view(pricelist)
		sell_count = Count.from_array(ar[2:], commodity_view, 
				parse_amount)
		event = boozedir.eventdir[date]
		return cls(event=event, counter=counter, shift=shift,
				startbal=startbal, endbal=endbal,
				sell_count=sell_count, number=number,
				pricelist=pricelist,
				mutation=mutation)
예제 #2
0
	def from_array(cls, ar, name, boozedir):
		if len(ar)==0 or len(ar[0])==0 or \
				ar[0][0].lower()!="prijslijst":
			raise MildErr("Missing 'prijslijst' title")
		prices = Count.from_array(ar[1:], boozedir.productdir,
				parse_amount)
		return cls(name=name,prices=prices)
예제 #3
0
파일: event.py 프로젝트: spr3nk3ls/koert
	def _load_btc_from_array(cls, ar, boozedir):
		if len(ar)==0:
			raise MildErr("beertankcount.csv has no header")
		if len(ar[0])==0 or ar[0][0].lower()!="tap":
			raise MildErr("beertankcount.csv has faulty header: "
					"%s" % ar[0])
		count = Count.from_array(ar[1:], boozedir.eventdir,
				parse_amount)
		for event in count.countlets.iterkeys():
			event.register_btc(count[event])
		return count
예제 #4
0
파일: event.py 프로젝트: spr3nk3ls/koert
	def from_array(cls, ar, code, boozedir):
		if len(ar)==0 or len(ar[0])==0:
			raise MildErr("no title")
		if ar[0][0].lower()!="voorraadtelling":
			raise MildErr("title is not 'voorraadtelling'")
		if len(ar)==1 or len(ar[1])==0:
			raise MildErr("header is too small")
		header = ar[1]
		date = parse_moment(header[0])
		event = boozedir.eventdir[date]
		count = Count.from_array(ar[2:], boozedir.productdir, 
				parse_amount)
		return cls(code, event, count)
예제 #5
0
파일: event.py 프로젝트: spr3nk3ls/koert
	def from_array(cls, ar, code, boozedir, board):
		if len(ar)==0 or len(ar[0])==0:
			raise MildErr("no title")
		if ar[0][0].lower()!="levering":
			raise MildErr("title is not 'levering'")
		if len(ar)==1 or len(ar[1])<2:
			raise MildErr("header is too small")
		header = ar[1]
		try:
			pricelist = boozedir.pricelistdir[header[0]]
		except ObjDirErr:
			raise MildErr("could not find pricelist")
		date = parse_moment(header[1])
		event = boozedir.eventdir[date]
		description = header[2].lower() if len(header)>=3 \
				else None
		view = boozedir.commoditydir.get_view(pricelist)
		count = Count.from_array(ar[2:], view, parse_amount)
		return cls(code, event, description, count, board)