Subversion Repositories SmartDukaan

Rev

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

Rev 24511 Rev 24523
Line 36... Line 36...
36
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
36
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
37
import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;
37
import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;
38
import com.spice.profitmandi.dao.repository.catalog.UnsettledPaymentsRepository;
38
import com.spice.profitmandi.dao.repository.catalog.UnsettledPaymentsRepository;
39
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
39
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
40
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
40
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
-
 
41
import com.spice.profitmandi.service.authentication.RoleManager;
41
import com.spice.profitmandi.service.user.RetailerService;
42
import com.spice.profitmandi.service.user.RetailerService;
42
import com.spice.profitmandi.service.wallet.WalletService;
43
import com.spice.profitmandi.service.wallet.WalletService;
43
import com.spice.profitmandi.web.model.LoginDetails;
44
import com.spice.profitmandi.web.model.LoginDetails;
44
import com.spice.profitmandi.web.util.CookiesProcessor;
45
import com.spice.profitmandi.web.util.CookiesProcessor;
45
import com.spice.profitmandi.web.util.MVCResponseSender;
46
import com.spice.profitmandi.web.util.MVCResponseSender;
Line 71... Line 72...
71
	@Autowired
72
	@Autowired
72
	private UnsettledPaymentsRepository unsettledPaymentsRepository;
73
	private UnsettledPaymentsRepository unsettledPaymentsRepository;
73
 
74
 
74
	@Autowired
75
	@Autowired
75
	private RetailerService retailerService;
76
	private RetailerService retailerService;
-
 
77
	
-
 
78
	@Autowired
-
 
79
	private RoleManager roleManager;
76
 
80
 
77
	@Autowired
81
	@Autowired
78
	AddWalletRequestRepository addWalletRequestRepository;
82
	AddWalletRequestRepository addWalletRequestRepository;
79
	private static final Logger LOGGER = LogManager.getLogger(WalletController.class);
83
	private static final Logger LOGGER = LogManager.getLogger(WalletController.class);
80
 
84
 
Line 84... Line 88...
84
			@RequestParam(name = ProfitMandiConstants.END_TIME, required = false) String endTimeString,
88
			@RequestParam(name = ProfitMandiConstants.END_TIME, required = false) String endTimeString,
85
			@RequestParam(name = "offset", defaultValue = "0") int offset,
89
			@RequestParam(name = "offset", defaultValue = "0") int offset,
86
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
90
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
87
			throws ProfitMandiBusinessException {
91
			throws ProfitMandiBusinessException {
88
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
92
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
89
 
-
 
-
 
93
		boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
90
		UserWallet userWallet = null;
94
		UserWallet userWallet = null;
91
		try {
95
		try {
92
			userWallet = userWalletRepository.selectByRetailerId(fofoDetails.getFofoId());
96
			userWallet = userWalletRepository.selectByRetailerId(fofoDetails.getFofoId());
93
		} catch (ProfitMandiBusinessException profitMandiBusinessException) {
97
		} catch (ProfitMandiBusinessException profitMandiBusinessException) {
94
			LOGGER.error("UserWallet not found : ", profitMandiBusinessException);
98
			LOGGER.error("UserWallet not found : ", profitMandiBusinessException);
Line 114... Line 118...
114
		}
118
		}
115
		model.addAttribute("userWallet", userWallet);
119
		model.addAttribute("userWallet", userWallet);
116
		model.addAttribute("walletHistories", userWalletHistories);
120
		model.addAttribute("walletHistories", userWalletHistories);
117
		model.addAttribute("start", offset + 1);
121
		model.addAttribute("start", offset + 1);
118
		model.addAttribute("size", countItems);
122
		model.addAttribute("size", countItems);
-
 
123
		model.addAttribute("isAdmin", isAdmin);
119
		model.addAttribute(ProfitMandiConstants.START_TIME, startTimeString);
124
		model.addAttribute(ProfitMandiConstants.START_TIME, startTimeString);
120
		model.addAttribute(ProfitMandiConstants.END_TIME, endTimeString);
125
		model.addAttribute(ProfitMandiConstants.END_TIME, endTimeString);
121
		if (userWalletHistories.size() < limit) {
126
		if (userWalletHistories.size() < limit) {
122
			model.addAttribute("end", offset + userWalletHistories.size());
127
			model.addAttribute("end", offset + userWalletHistories.size());
123
		} else {
128
		} else {
Line 491... Line 496...
491
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
496
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
492
		return "response";
497
		return "response";
493
	}
498
	}
494
 
499
 
495
	@RequestMapping(value = "/wallet/statement", method = RequestMethod.GET)
500
	@RequestMapping(value = "/wallet/statement", method = RequestMethod.GET)
496
	public String removeUnsettledPaymentsEntries(HttpServletRequest request, @RequestParam LocalDateTime startDate,
501
	public String getWalletStatement(HttpServletRequest request, @RequestParam LocalDateTime startDate,
497
			@RequestParam LocalDateTime endDate, Model model) throws Exception {
502
			@RequestParam LocalDateTime endDate, Model model, @RequestParam(defaultValue="0") int fofoId) throws Exception {
-
 
503
		boolean isAdmin = roleManager.isAdmin(cookiesProcessor.getCookiesObject(request).getRoleIds());
-
 
504
		if(fofoId > 0) {
-
 
505
			if(!isAdmin) {
-
 
506
				throw new ProfitMandiBusinessException("Unauthorised access", "PartnerId", "Permission Denied");
-
 
507
			}
-
 
508
		} else {
498
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
509
			fofoId = cookiesProcessor.getCookiesObject(request).getFofoId();
-
 
510
		}
499
		float openingBalance = walletService.getOpeningTill(fofoDetails.getFofoId(), startDate);
511
		float openingBalance = walletService.getOpeningTill(fofoId, startDate);
500
		float closingBalance = walletService.getOpeningTill(fofoDetails.getFofoId(), endDate);
512
		float closingBalance = walletService.getOpeningTill(fofoId, endDate);
501
		List<UserWalletHistory> uwhList = walletService.getPaginatedUserWalletHistoryByRetailerId(
513
		List<UserWalletHistory> uwhList = walletService.getPaginatedUserWalletHistoryByRetailerId(
502
				fofoDetails.getFofoId(), startDate, endDate, 0, 0);
514
				fofoId, startDate, endDate, 0, 0);
503
		Collections.reverse(uwhList);
515
		Collections.reverse(uwhList);
504
		/*HttpHeaders headers = new HttpHeaders();
516
		/*HttpHeaders headers = new HttpHeaders();
505
		InputStreamResource is = new InputStreamResource();
517
		InputStreamResource is = new InputStreamResource();
506
		headers.set("Content-Type", "application/vnd.ms-excel");
518
		headers.set("Content-Type", "application/vnd.ms-excel");
507
		headers.set("Content-disposition", "inline; filename=report-" + fileName + ".csv");
519
		headers.set("Content-disposition", "inline; filename=report-" + fileName + ".csv");