Subversion Repositories SmartDukaan

Rev

Rev 36831 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36831 Rev 36904
Line 471... Line 471...
471
    @RequestMapping(value = "/addAmountToWallet", method = RequestMethod.PUT)
471
    @RequestMapping(value = "/addAmountToWallet", method = RequestMethod.PUT)
472
    public String addAmountToWallet(HttpServletRequest request, @RequestParam(name = "id", defaultValue = "0") int id, @RequestParam(name = "walletRequestid", defaultValue = "0") int walletRequestid, Model model) throws Exception {
472
    public String addAmountToWallet(HttpServletRequest request, @RequestParam(name = "id", defaultValue = "0") int id, @RequestParam(name = "walletRequestid", defaultValue = "0") int walletRequestid, Model model) throws Exception {
473
 
473
 
474
        AddWalletRequest addWalletRequest = addWalletRequestRepository.selectById(walletRequestid);
474
        AddWalletRequest addWalletRequest = addWalletRequestRepository.selectById(walletRequestid);
475
        List<AddWalletRequest> requests = addWalletRequestRepository.selectAllByTransactionReference(addWalletRequest.getTransaction_reference());
475
        List<AddWalletRequest> requests = addWalletRequestRepository.selectAllByTransactionReference(addWalletRequest.getTransaction_reference());
-
 
476
        // Scope the duplicate-reference check to the SAME retailer. Reference numbers
-
 
477
        // (e.g. cheque numbers like "000310") are not globally unique and collide across
-
 
478
        // partners; without this filter a legitimate payment is wrongly blocked as
-
 
479
        // "Entry already Approved Please reject" because a different store used the same ref.
476
        if (requests.stream().filter(x -> x.getId() != addWalletRequest.getId()).filter(x -> x.getStatus().equals(approved)).count() != 1) {
480
        if (requests.stream().filter(x -> x.getId() != addWalletRequest.getId()).filter(x -> x.getRetailerId() == addWalletRequest.getRetailerId()).filter(x -> x.getStatus().equals(approved)).count() != 1) {
477
            HdfcPayment hdfcPayment = hdfcPaymentRepository.selectByUtrNo(addWalletRequest.getTransaction_reference());
481
            HdfcPayment hdfcPayment = hdfcPaymentRepository.selectByUtrNo(addWalletRequest.getTransaction_reference());
478
            if (hdfcPayment != null) {
482
            if (hdfcPayment != null) {
479
                String rejectReason = "Payment for UTR Already added via Auto Update";
483
                String rejectReason = "Payment for UTR Already added via Auto Update";
480
                throw new ProfitMandiBusinessException(rejectReason, rejectReason, rejectReason);
484
                throw new ProfitMandiBusinessException(rejectReason, rejectReason, rejectReason);
481
            }
485
            }