##// END OF EJS Templates
reporte de fungibles bugs
fquino -
r277:278
parent child
Show More
@@ -304,7 +304,7
304 304 output = transaction_output_total['sum']
305 305 count = count + transaction_output_total['count']
306 306 total_qty_transactions = input - output
307 total_count_transactions = len(inventory_transactions.all())
307 total_count_transactions = inventory_transactions.all().count()#len(inventory_transactions.all())
308 308 if self.is_unit():
309 309 total_qty_transactions = int(total_qty_transactions)
310 310 inventory_obj = {'inventory': inventory, 'inventory_transactions': total_count_transactions, 'inventory_total': total_qty_transactions}
@@ -315,6 +315,32
315 315 return (stock)
316 316 else:
317 317 return (stock['total_qty'])
318
319
320 @property
321 def stock(self):
322 """
323 Devuelve solo el stock del fungible
324 """
325 transactions = self.transactions.all()
326 stock = {'total_qty': 0}
327 input = Decimal(0.0)
328 output = Decimal(0.0)
329
330 transaction_input_total = transactions.filter(direction='IN', state='COMPLETED').aggregate(sum=Sum('quantity'), count=Count('id'))
331 transaction_output_total = transactions.filter(direction='OUT', state='COMPLETED').aggregate(sum=Sum('quantity'), count=Count('id'))
332 if 'sum' in transaction_input_total and transaction_input_total['sum'] is not None:
333 input = transaction_input_total['sum']
334 if 'sum' in transaction_output_total and transaction_output_total['sum'] is not None:
335 output = transaction_output_total['sum']
336 total_qty_transactions = input - output
337
338 if self.is_unit():
339 total_qty_transactions = int(total_qty_transactions)
340
341 stock['total_qty'] = stock['total_qty'] + total_qty_transactions
342 return (stock['total_qty'])
343
318 344
319 345 def get_price(self, detail=False, get_string=True):
320 346 from movements.models import PurchaseOrderItem, PurchaseOrderFungibleItem
@@ -1468,17 +1468,14
1468 1468 # Generate a sequence of rows. The range is based on the maximum number of
1469 1469 # rows that can be handled by a single sheet in most spreadsheet
1470 1470 # applications.
1471 allfungibles = FungibleItem.objects.all()
1471 allfungibles = FungibleItem.objects.all().select_related('unit', 'area')
1472 1472 #rows = (["Row {}".format(idx), str(idx)] for idx in allfungibles)
1473 rows = ([str(f.id), f.name.encode('utf-8'), f.unit.name.encode('utf-8'), f.area.name.encode('utf-8'), f.get_locations().encode('utf-8'), f.get_stock(), f.notes.encode('utf-8')] for f in allfungibles)
1474 #rows = ([format(f.id), f.name.encode('utf-8'), f.unit.name.encode('utf-8'), f.area.name.encode('utf-8'), f.get_locations().encode('utf-8'), f.get_stock(),f.notes.encode('utf-8')] for f in allfungibles)
1475 1473 #rows = ([])
1476 #print dir(rows)
1477 #[('ID','Name','C','D','E','F','G')]
1478 #rows.insert(0, ['ID','Name'])
1474 rows = ([str(f.id), f.name.encode('utf-8'), f.unit.name.encode('utf-8'), f.area.name.encode('utf-8'), f.get_locations().encode('utf-8'), str(f.stock), f.notes.encode('utf-8')] for f in allfungibles)
1475 #rows = ([f['id'], f['name'].encode('utf-8'), f['unit__name'], f['area__name'].encode('utf-8'), f['stock'], f['notes'].encode('utf-8')] for f in allfungibles)
1479 1476 pseudo_buffer = Echo()
1480 1477 writer = csv.writer(pseudo_buffer)
1481 1478 response = StreamingHttpResponse((writer.writerow(row) for row in rows),
1482 1479 content_type="text/csv")
1483 response['Content-Disposition'] = 'attachment; filename="estedocumento.csv"'
1480 response['Content-Disposition'] = 'attachment; filename="FungiblesReport.csv"'
1484 1481 return response No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now