Subversion Repositories SmartDukaan

Rev

Rev 4598 | Rev 4674 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4598 Rev 4657
Line 157... Line 157...
157
            Map<Date, Long> registerCountMap = new HashMap<Date, Long>();
157
            Map<Date, Long> registerCountMap = new HashMap<Date, Long>();
158
            Map<Date, Double> saleQuantityMap = new HashMap<Date, Double>();
158
            Map<Date, Double> saleQuantityMap = new HashMap<Date, Double>();
159
            Map<Date, Double> saleAmountMap = new HashMap<Date, Double>();
159
            Map<Date, Double> saleAmountMap = new HashMap<Date, Double>();
160
            
160
            
161
            Map<Date, Map<String, Double>> productQuantityMap = new HashMap<Date, Map<String, Double>>();
161
            Map<Date, Map<String, Double>> productQuantityMap = new HashMap<Date, Map<String, Double>>();
162
            Map<Date, Map<Long, String>> dateTxnProductMap = new HashMap<Date, Map<Long, String>>();
162
            Map<Date, Map<Long, ArrayList<String>>> dateTxnProductMap = new HashMap<Date, Map<Long, ArrayList<String>>>();
163
            Map<Date, Map<String, Double>> productAmountMap = new HashMap<Date, Map<String,Double>>();
163
            Map<Date, Map<String, Double>> productAmountMap = new HashMap<Date, Map<String,Double>>();
164
            
164
            
165
            for (Affiliate aff : affiliates) {
165
            for (Affiliate aff : affiliates) {
166
                Set<Long> Payments = new HashSet<Long>(); // To deal with multiple refreshes on pay-success page.
166
                Set<Long> Payments = new HashSet<Long>(); // To deal with multiple refreshes on pay-success page.
167
                for (TrackLog tracklog : userClient.getTrackLogsByAffiliate(aff.getId(), startDate.getTime(), endDate.getTime())) {
167
                for (TrackLog tracklog : userClient.getTrackLogsByAffiliate(aff.getId(), startDate.getTime(), endDate.getTime())) {
Line 228... Line 228...
228
                                        pQuantityMap.put(productName, item.getQuantity());
228
                                        pQuantityMap.put(productName, item.getQuantity());
229
                                        productQuantityMap.put(date, pQuantityMap);
229
                                        productQuantityMap.put(date, pQuantityMap);
230
                                    }
230
                                    }
231
                                    
231
                                    
232
                                    if (dateTxnProductMap.containsKey(date)) {
232
                                    if (dateTxnProductMap.containsKey(date)) {
233
                                        Map<Long, String> txnProductMap = dateTxnProductMap.get(date);
233
                                        Map<Long, ArrayList<String>> txnProductMap = dateTxnProductMap.get(date);
-
 
234
                                        if (txnProductMap.containsKey(order.getTransactionId())) {
-
 
235
                                            ArrayList<String> productList = txnProductMap.get(order.getTransactionId());
-
 
236
                                            productList.add(productName); 
-
 
237
                                        } else {
-
 
238
                                            ArrayList<String> productList = new ArrayList<String>();
-
 
239
                                            productList.add(productName);
234
                                        txnProductMap.put(order.getTransactionId(), productName);
240
                                            txnProductMap.put(order.getTransactionId(), productList);
-
 
241
                                        }
235
                                    }
242
                                    }
236
                                    else {
243
                                    else {
237
                                        Map<Long, String> txnProductMap = new HashMap<Long, String>();
244
                                        Map<Long, ArrayList<String>> txnProductMap = new HashMap<Long, ArrayList<String>>();
-
 
245
                                        ArrayList<String> productList = new ArrayList<String>();
-
 
246
                                        productList.add(productName);
238
                                        txnProductMap.put(order.getTransactionId(), productName);
247
                                        txnProductMap.put(order.getTransactionId(), productList);
239
                                        dateTxnProductMap.put(date, txnProductMap);
248
                                        dateTxnProductMap.put(date, txnProductMap);
240
                                    }
249
                                    }
241
                                    
250
                                    
242
                                    if (productAmountMap.containsKey(date)) {
251
                                    if (productAmountMap.containsKey(date)) {
243
                                        Map<String, Double> pAmountMap = productAmountMap.get(date);
252
                                        Map<String, Double> pAmountMap = productAmountMap.get(date);
Line 302... Line 311...
302
	        SortedSet<Date> dates,
311
	        SortedSet<Date> dates,
303
            Map<Date, Long> registerCountMap,
312
            Map<Date, Long> registerCountMap,
304
            Map<Date, Double> saleQuantityMap,
313
            Map<Date, Double> saleQuantityMap,
305
            Map<Date, Double> saleAmountMap,
314
            Map<Date, Double> saleAmountMap,
306
            Map<Date, Map<String, Double>> productQuantityMap,
315
            Map<Date, Map<String, Double>> productQuantityMap,
307
            Map<Date, Map<Long, String>> dateTxnProductMap,
316
            Map<Date, Map<Long, ArrayList<String>>> dateTxnProductMap,
308
            Map<Date, Map<String, Double>> productAmountMap)
317
            Map<Date, Map<String, Double>> productAmountMap)
309
	{
318
	{
310
	    ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
319
	    ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
311
 
320
 
312
		Workbook wb = new HSSFWorkbook();
321
		Workbook wb = new HSSFWorkbook();
Line 332... Line 341...
332
		}		
341
		}		
333
		return baosXLS;
342
		return baosXLS;
334
	}
343
	}
335
	
344
	
336
    private void createSaleDetailSheet(String mAffName, SortedSet<Date> dates,
345
    private void createSaleDetailSheet(String mAffName, SortedSet<Date> dates,
337
            Map<Date, Map<Long, String>> dateTxnProductMap,
346
            Map<Date, Map<Long, ArrayList<String>>> dateTxnProductMap,
338
            Map<Date, Map<String, Double>> productQuantityMap,
347
            Map<Date, Map<String, Double>> productQuantityMap,
339
            Map<Date, Map<String, Double>> productAmountMap, Workbook wb,
348
            Map<Date, Map<String, Double>> productAmountMap, Workbook wb,
340
            CellStyle style, CellStyle dateCellStyle) {
349
            CellStyle style, CellStyle dateCellStyle) {
341
        // Product Sales SHEET
350
        // Product Sales SHEET
342
        Sheet affSheet = wb.createSheet("Product Sales Report");
351
        Sheet affSheet = wb.createSheet("Product Sales Report");
Line 379... Line 388...
379
        for(Date date : dates) {
388
        for(Date date : dates) {
380
            if (!dateTxnProductMap.containsKey(date)) {
389
            if (!dateTxnProductMap.containsKey(date)) {
381
                continue;
390
                continue;
382
            }
391
            }
383
            //HashSet<String> tmpProductSet = new HashSet<String>();
392
            //HashSet<String> tmpProductSet = new HashSet<String>();
384
            String prodName = null;
393
            ArrayList<String> prodList = new ArrayList<String>();
385
            Row commContentRow = null;
394
            Row commContentRow = null;
386
            for (Entry<Long, String> txnEntry : dateTxnProductMap.get(date).entrySet()) {
395
            for (Entry<Long, ArrayList<String>> txnEntry : dateTxnProductMap.get(date).entrySet()) {
387
                affSerialNo++;
396
                affSerialNo++;
388
                prodName = txnEntry.getValue();
397
                prodList = txnEntry.getValue();
389
                Long txn = txnEntry.getKey();
398
                Long txn = txnEntry.getKey();
-
 
399
                for (String prodName : prodList) {
390
                commContentRow = affSheet.createRow(affSerialNo);
400
                    commContentRow = affSheet.createRow(affSerialNo);
391
                commContentRow.createCell(0).setCellValue(date);
401
                    commContentRow.createCell(0).setCellValue(date);
392
                commContentRow.getCell(0).setCellStyle(dateCellStyle);
402
                    commContentRow.getCell(0).setCellStyle(dateCellStyle);
393
                commContentRow.createCell(1).setCellValue(prodName);
403
                    commContentRow.createCell(1).setCellValue(prodName);
394
                commContentRow.createCell(2).setCellValue(txn);
404
                    commContentRow.createCell(2).setCellValue(txn);
395
                Double amount = productAmountMap.get(date).get(prodName);
405
                    Double amount = productAmountMap.get(date).get(prodName);
396
                amount = amount/(productQuantityMap.get(date).get(prodName));
406
                    amount = amount/(productQuantityMap.get(date).get(prodName));
397
                totalAmount += amount;
407
                    totalAmount += amount;
398
                commContentRow.createCell(3).setCellValue(amount);
408
                    commContentRow.createCell(3).setCellValue(amount);
399
                totalQuantity++;
409
                    totalQuantity++;
-
 
410
                }
400
            }
411
            }
401
        }
412
        }
402
        affSerialNo+=2;
413
        affSerialNo+=2;
403
        Row commContentRow = affSheet.createRow(affSerialNo);
414
        Row commContentRow = affSheet.createRow(affSerialNo);
404
        commContentRow.createCell(0).setCellValue("Total");
415
        commContentRow.createCell(0).setCellValue("Total");