Subversion Repositories SmartDukaan

Rev

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

Rev 7527 Rev 7611
Line 76... Line 76...
76
    private Long orderId;
76
    private Long orderId;
77
 
77
 
78
    private Long refundAmount;
78
    private Long refundAmount;
79
    
79
    
80
    private boolean showReprintColumn = false;
80
    private boolean showReprintColumn = false;
-
 
81
 
-
 
82
    private int reportType;
81
    
83
    
82
    public ReportController(){
84
    public ReportController(){
83
        super();
85
        super();
84
        try {
86
        try {
85
            tsc = new TransactionClient();
87
            tsc = new TransactionClient();
Line 215... Line 217...
215
            contentRow.createCell(6).setCellValue(collection.getCard());
217
            contentRow.createCell(6).setCellValue(collection.getCard());
216
        }
218
        }
217
        try {
219
        try {
218
            wb.write(baosXLS);
220
            wb.write(baosXLS);
219
        } catch (IOException e) {
221
        } catch (IOException e) {
220
            // TODO Auto-generated catch block
222
           log.error("Could not write to XLS file", e);
221
            e.printStackTrace();
-
 
222
        }
223
        }
223
        return baosXLS;
224
        return baosXLS;
224
    }
225
    }
225
 
226
 
226
    
227
    
Line 247... Line 248...
247
                endDate = dateFormatter.format(sDate);
248
                endDate = dateFormatter.format(sDate);
248
            }
249
            }
249
        }
250
        }
250
            
251
            
251
        List<OrderStatus> statuses = new ArrayList<OrderStatus>();
252
        List<OrderStatus> statuses = new ArrayList<OrderStatus>();
-
 
253
        if(reportType == 1) {
252
        statuses.add(OrderStatus.DELIVERY_SUCCESS);
254
            statuses.add(OrderStatus.DELIVERY_SUCCESS);
-
 
255
        }
253
        orders = tClient.getOrdersForStore(0, Long.parseLong((String) request.getSession().getAttribute("STORE_ID")), sDate, eDate, statuses);
256
        orders = tClient.getOrdersForStore(0, Long.parseLong((String) request.getSession().getAttribute("STORE_ID")), sDate, eDate, statuses);
254
 
257
 
255
        ByteArrayOutputStream baos = generateReport(orders);
258
        ByteArrayOutputStream baos = generateReport(orders);
256
        
259
        
257
        response.setContentType("application/vnd.ms-excel");
260
        response.setContentType("application/vnd.ms-excel");
Line 303... Line 306...
303
            contentRow.createCell(5).setCellValue(order.getAdvanceAmount());
306
            contentRow.createCell(5).setCellValue(order.getAdvanceAmount());
304
        }
307
        }
305
        try {
308
        try {
306
            wb.write(baosXLS);
309
            wb.write(baosXLS);
307
        } catch (IOException e) {
310
        } catch (IOException e) {
308
            // TODO Auto-generated catch block
-
 
309
            e.printStackTrace();
311
            e.printStackTrace();
310
        }
312
        }
311
        return baosXLS;
313
        return baosXLS;
312
    }
314
    }
313
    
315
    
Line 318... Line 320...
318
                log.error("rechargeId is 0");
320
                log.error("rechargeId is 0");
319
                return "index";
321
                return "index";
320
            }
322
            }
321
            TransactionClient transactionServiceClient = new TransactionClient();
323
            TransactionClient transactionServiceClient = new TransactionClient();
322
            TransactionService.Client orderClient = transactionServiceClient.getClient();
324
            TransactionService.Client orderClient = transactionServiceClient.getClient();
323
            //TODO : dynamically get StoreId
-
 
324
            buffer = orderClient.getStoreOrderAdvanceInvoice(number, Long.parseLong((String) request.getSession().getAttribute("STORE_ID")));
325
            buffer = orderClient.getStoreOrderAdvanceInvoice(number, Long.parseLong((String) request.getSession().getAttribute("STORE_ID")));
325
            if(!buffer.hasArray()) {
326
            if(!buffer.hasArray()) {
326
                log.error("The invoice was not found for orderId : " + number);
327
                log.error("The invoice was not found for orderId : " + number);
327
            }
328
            }
328
        } catch (Exception e) {
329
        } catch (Exception e) {
Line 392... Line 393...
392
    public String cancelRequest() {
393
    public String cancelRequest() {
393
        try{
394
        try{
394
        TransactionClient tcl = new TransactionClient();
395
        TransactionClient tcl = new TransactionClient();
395
        long storeId =  Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
396
        long storeId =  Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
396
        StoreOrderDetail sod = tcl.getClient().getStoreOrderDetail(orderId, storeId);
397
        StoreOrderDetail sod = tcl.getClient().getStoreOrderDetail(orderId, storeId);
-
 
398
        if(sod.getCardAmount() > 0 && "debit".equals(sod.getCardType())) {
-
 
399
            logger.error("Error : Cancellation cannot be requested for order with Debit Card Transaction : " + orderId.toString());
-
 
400
            setSearchError("Amount was paid by Debit card. Please call customer care to get this order cancelled.");
-
 
401
            number = orderId;
-
 
402
            return search();
-
 
403
        }
397
        tcl.getClient().saveRefundAmountsForStoreOrder(orderId, storeId, sod.getCashAmount(), sod.getCardAmount());
404
        tcl.getClient().saveRefundAmountsForStoreOrder(orderId, storeId, sod.getCashAmount(), sod.getCardAmount());
398
        tcl.getClient().markOrderCancellationRequestReceived(orderId);
405
        tcl.getClient().markOrderCancellationRequestReceived(orderId);
399
        tcl.getClient().markOrderCancellationRequestConfirmed(orderId);
406
        tcl.getClient().markOrderCancellationRequestConfirmed(orderId);
400
        tcl.getClient().refundOrder(orderId, "Store", "User requested for cancellation");
407
        tcl.getClient().refundOrder(orderId, "Store", "User requested for cancellation");
401
        } catch (Exception e) {
408
        } catch (Exception e) {
Line 422... Line 429...
422
        }
429
        }
423
        number = orderId;
430
        number = orderId;
424
        return search();
431
        return search();
425
    }
432
    }
426
    
433
    
427
    public String refundOrder() {
434
//    public String refundOrder() {
428
        number = orderId;
435
//        number = orderId;
429
        try{
436
//        try{
430
            TransactionClient tcl = new TransactionClient();
437
//            TransactionClient tcl = new TransactionClient();
431
            Order order = tcl.getClient().getOrder(number);
438
//            Order order = tcl.getClient().getOrder(number);
432
            if(order.getTotal_amount() < refundAmount) {
439
//            if(order.getTotal_amount() < refundAmount) {
433
                setSearchError("You cannot refund more than Rs. " + refundAmount.toString());
440
//                setSearchError("You cannot refund more than Rs. " + refundAmount.toString());
434
                return search();
441
//                return search();
435
            }
442
//            }
436
            tcl.getClient().refundOrder(orderId, "ANU", "Cancelled");
443
//            tcl.getClient().refundOrder(orderId, "ANU", "Cancelled");
437
            setSearchError("SUCCESSFUL. Please refund Rs. " + refundAmount.toString() + " to the customer.");
444
//            setSearchError("SUCCESSFUL. Please refund Rs. " + refundAmount.toString() + " to the customer.");
438
        } catch (Exception e) {
445
//        } catch (Exception e) {
439
            logger.error("Could not mark order as return requested for id : " + orderId.toString(), e);
446
//            logger.error("Could not mark order as return requested for id : " + orderId.toString(), e);
440
            setSearchError("Could not refund. Try again or call customer care.");
447
//            setSearchError("Could not refund. Try again or call customer care.");
441
        }
448
//        }
442
        return search();
449
//        return search();
443
    }
450
//    }
444
 
451
 
445
    public List<Order> getOrders(){
452
    public List<Order> getOrders(){
446
        return orders;
453
        return orders;
447
    }
454
    }
448
    
455
    
Line 599... Line 606...
599
                && cal.get(Calendar.YEAR) == calOrderDate.get(Calendar.YEAR)) {
606
                && cal.get(Calendar.YEAR) == calOrderDate.get(Calendar.YEAR)) {
600
            return true;
607
            return true;
601
        }
608
        }
602
        return false;
609
        return false;
603
    }
610
    }
-
 
611
    
-
 
612
    public boolean debitCardNotUsed(long orderId) {
-
 
613
        try {
-
 
614
            TransactionClient tcl = new TransactionClient();
-
 
615
            StoreOrderDetail sod = tcl.getClient().getStoreOrderDetail(orderId, Long.parseLong((String) request.getSession().getAttribute("STORE_ID")));
-
 
616
            if("debit".equals(sod.getCardType())) {
-
 
617
                return false;
-
 
618
            }
-
 
619
            else {
-
 
620
                return true;
-
 
621
            }
-
 
622
        } catch(Exception e) {
-
 
623
            //We cannot be sure so not taking any risks.
-
 
624
            log.error("Unable to get storeOrderDetail for order Id : " + orderId, e);
-
 
625
            return false;
-
 
626
        }
-
 
627
        
-
 
628
    }
-
 
629
 
-
 
630
 
-
 
631
    public int getReportType() {
-
 
632
        return reportType;
-
 
633
    }
-
 
634
 
-
 
635
 
-
 
636
    public void setReportType(int reportType) {
-
 
637
        this.reportType = reportType;
-
 
638
    }
604
 
639
 
605
}
640
}
606
641