Subversion Repositories SmartDukaan

Rev

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

Rev 24521 Rev 25084
Line 27... Line 27...
27
		// TODO Auto-generated method stub
27
		// TODO Auto-generated method stub
28
	      List<UserWalletHistory> history = (List<UserWalletHistory>) model.get("history");
28
	      List<UserWalletHistory> history = (List<UserWalletHistory>) model.get("history");
29
	      LocalDateTime startDate = (LocalDateTime)model.get("startDate");
29
	      LocalDateTime startDate = (LocalDateTime)model.get("startDate");
30
	      LocalDateTime endDate = (LocalDateTime)model.get("endDate");
30
	      LocalDateTime endDate = (LocalDateTime)model.get("endDate");
31
	      Float opening = (float)model.get("opening");
31
	      Float opening = (float)model.get("opening");
32
	      Float closing = (float)model.get("closing");
32
	      //Float closing = (float)model.get("closing");
33
	      Sheet sheet = workbook.createSheet("Wallet Statement");
33
	      Sheet sheet = workbook.createSheet("Wallet Statement");
34
	      UserWalletHistory uwhOpening = getOpeningEntry(opening, startDate);
34
	      UserWalletHistory uwhOpening = getOpeningEntry(opening, startDate);
35
	      UserWalletHistory closingEntry = getClosingEntry(closing, endDate);
35
	      //UserWalletHistory closingEntry = getClosingEntry(closing, endDate);
36
	      history.add(0, uwhOpening);
36
	      history.add(0, uwhOpening);
37
	      //history.add(closingEntry);
37
	      //history.add(closingEntry);
38
 
38
 
39
	      
39
	      
40
	      sheet.setFitToPage(true);
40
	      sheet.setFitToPage(true);
Line 45... Line 45...
45
	      header.createCell(1).setCellValue("Transact Type");
45
	      header.createCell(1).setCellValue("Transact Type");
46
	      header.createCell(2).setCellValue("Transact Reference");
46
	      header.createCell(2).setCellValue("Transact Reference");
47
	      header.createCell(3).setCellValue("Transact Description");
47
	      header.createCell(3).setCellValue("Transact Description");
48
	      header.createCell(4).setCellValue("Amount Dr");
48
	      header.createCell(4).setCellValue("Amount Dr");
49
	      header.createCell(5).setCellValue("Amount Cr");
49
	      header.createCell(5).setCellValue("Amount Cr");
50
	      header.createCell(6).setCellValue("Balance");
50
	      //header.createCell(6).setCellValue("Balance");
51
	      int calculatedClosing = 0;
51
	      int calculatedClosing = 0;
52
	      for (UserWalletHistory walletEntry : history) {
52
	      for (UserWalletHistory walletEntry : history) {
53
	          Row walletEntryRow = sheet.createRow(rowCount++);
53
	          Row walletEntryRow = sheet.createRow(rowCount++);
54
	          walletEntryRow.createCell(0).setCellValue(walletEntry.getFormattedDate());
54
	          walletEntryRow.createCell(0).setCellValue(walletEntry.getFormattedDate());
55
	          if(walletEntry.getReferenceType()==null) {
55
	          if(walletEntry.getReferenceType()==null) {
Line 67... Line 67...
67
	          } else if (walletEntry.getAmount() > 0) {
67
	          } else if (walletEntry.getAmount() > 0) {
68
	        	  walletEntryRow.createCell(4).setCellValue("");
68
	        	  walletEntryRow.createCell(4).setCellValue("");
69
	        	  walletEntryRow.createCell(5).setCellValue(walletEntry.getAmount());
69
	        	  walletEntryRow.createCell(5).setCellValue(walletEntry.getAmount());
70
	          }
70
	          }
71
	          calculatedClosing = calculatedClosing + walletEntry.getAmount();
71
	          calculatedClosing = calculatedClosing + walletEntry.getAmount();
72
	          walletEntryRow.createCell(6).setCellValue(calculatedClosing);
72
	          //walletEntryRow.createCell(6).setCellValue(calculatedClosing);
73
	      }
73
	      }
74
	      String fileName = "wallet-" + FormattingUtils.formatDate(startDate) + " " + FormattingUtils.formatDate(endDate) + ".xlsx";
74
	      String fileName = "wallet-" + FormattingUtils.formatDate(startDate) + " " + FormattingUtils.formatDate(endDate) + ".xlsx";
75
	      response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
75
	      response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
76
 
76
 
77
	}
77
	}