Subversion Repositories SmartDukaan

Rev

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

Rev 34492 Rev 34501
Line 164... Line 164...
164
 
164
 
165
                }
165
                }
166
                totalPayableAmount += cartItem.getSellingPrice() * cartItem.getQuantity();
166
                totalPayableAmount += cartItem.getSellingPrice() * cartItem.getQuantity();
167
                cartItems.add(cartItem);
167
                cartItems.add(cartItem);
168
            }
168
            }
-
 
169
            Bid bid = null;
-
 
170
            if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
169
            Bid bid = bidRepository.selectById(fofoBulkOrderModels.get(0).getRowIndex());
171
                bid = bidRepository.selectById(fofoBulkOrderModels.get(0).getRowIndex());
-
 
172
            }
170
            LOGGER.info("totalAmount of item " + totalPayableAmount);
173
            LOGGER.info("totalAmount of item " + totalPayableAmount);
171
            double walletAmount = walletService.getWalletAmount(fofoId);
174
            double walletAmount = walletService.getWalletAmount(fofoId);
172
 
175
 
173
            BigDecimal creditAvailability = sdCreditService.getAvailableAmount(fofoId);
176
            BigDecimal creditAvailability = sdCreditService.getAvailableAmount(fofoId);
174
 
177
 
Line 197... Line 200...
197
                if (creditAmountRequired > ProfitMandiConstants.MAX_NEGATIVE_WALLET_VALUE) {
200
                if (creditAmountRequired > ProfitMandiConstants.MAX_NEGATIVE_WALLET_VALUE) {
198
                    Loan loan = sdCreditService.createLoan(userCart.getUserId(), creditAmountRequired, 365, "Credit limit assigned via SD Credit");
201
                    Loan loan = sdCreditService.createLoan(userCart.getUserId(), creditAmountRequired, 365, "Credit limit assigned via SD Credit");
199
                    loanId = loan.getId();
202
                    loanId = loan.getId();
200
                }
203
                }
201
            } catch (Exception exception){
204
            } catch (Exception exception){
-
 
205
                if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
202
                bidService.sendMailToRBM(netAmountInHand, totalPayableAmount, fofoId);
206
                    bidService.sendMailToRBM(netAmountInHand, totalPayableAmount, fofoId);
203
                bid.setStatus(ProfitMandiConstants.BID_ENUM.PROCESSING);
207
                    bid.setStatus(ProfitMandiConstants.BID_ENUM.PROCESSING);
-
 
208
                }
204
                throw new ProfitMandiBusinessException("Skipping order unable to create load for id - ", fofoId, " ,Sending mail to RBM");
209
                throw new ProfitMandiBusinessException("Skipping order unable to create load for id - ", fofoId, " ,Sending mail to RBM");
205
            }
210
            }
206
 
211
 
207
            int transactionId = transactionService.createTransactionInternally(userCart, totalPayableAmount, 0);
212
            int transactionId = transactionService.createTransactionInternally(userCart, totalPayableAmount, 0);
208
            //Set here created by
213
            //Set here created by
209
            Transaction transaction = transactionRepository.selectById(transactionId);
214
            Transaction transaction = transactionRepository.selectById(transactionId);
210
            transaction.setCreatedBy(creatorId);
215
            transaction.setCreatedBy(creatorId);
211
            LOGGER.info("transaction  created by {}", transaction.getCreatedBy());
216
            LOGGER.info("transaction  created by {}", transaction.getCreatedBy());
212
            commonPaymentService.payThroughWallet(transactionId);
217
            commonPaymentService.payThroughWallet(transactionId);
-
 
218
            if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
213
            bid.setStatus(ProfitMandiConstants.BID_ENUM.CLOSED);
219
                bid.setStatus(ProfitMandiConstants.BID_ENUM.CLOSED);
-
 
220
            }
214
            if (approvalRequired) {
221
            if (approvalRequired) {
215
                this.createApproval(transactionId);
222
                this.createApproval(transactionId);
216
            } else {
223
            } else {
217
                transactionService.processTransaction(transactionId,loanId);
224
                transactionService.processTransaction(transactionId,loanId);
218
            }
225
            }