Beispiel #1
0
	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 "[email protected]" 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)
Beispiel #2
0
	def __getitem__(self, date):
		if isinstance(date,str):
			date = parse_moment(date)
		if not isinstance(date,Moment):
			raise ValueError("date not a Moment or str"
					" %s" %	repr(date))
		if date not in self.events:
			self.events[date] = Event(date)
		return self.events[date]
Beispiel #3
0
	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)
Beispiel #4
0
	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)