Exemplo n.º 1
0
	def add_data_in_CSV(self, qty_diff, rate_diff):
		"""Add diffs column in attached file"""
		
		# add header
		out = "'Item Code', 'Warehouse', 'Qty', 'Valuation Rate', 'Qty Diff', 'Val Rate Diff'"
		
		# add data
		for d in self.data:
			s = [cstr(i) for i in d] + [cstr(qty_diff), cstr(rate_diff)]
			out += "\n" + ','.join(s)
		
		# write to file
		fname = self.doc.file_list.split(',')
		from webnotes.utils import file_manager
		file_manager.write_file(fname[1], out.encode('utf-8'))
Exemplo n.º 2
0
	def add_data_in_CSV(self,data):
		filename = self.doc.file_list.split(',')
		head = []
		for h in ['Item Code','Warehouse','Qty','Actual','Difference','MAR']:
			head.append(self.getCSVelement(h))
		dset = (','.join(head) + "\n")
		for d in data:
			l = [d[self.label['item_code']],d[self.label['warehouse']],d[self.label['qty']],d[self.label['actual_qty']],flt(d[self.label['qty']])-flt(d[self.label['actual_qty']]),d[self.label['mar']]]
			s =[]
			for i in l:
				s.append(self.getCSVelement(i))
			dset +=(','.join(s)+"\n")
		
		from webnotes.utils import file_manager
		file_manager.write_file(filename[1], dset)