Subversion Repositories SmartDukaan

Rev

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

Rev 3501 Rev 4141
Line 74... Line 74...
74
            logger.error("Error establishing connection to one of txn, payment or user service", e);
74
            logger.error("Error establishing connection to one of txn, payment or user service", e);
75
        }
75
        }
76
    }
76
    }
77
 
77
 
78
    /**
78
    /**
79
     * This method is used in PaymentDetailsController.
-
 
80
     * If any pending or failed payment exists between given date range, it returns ByteArrayOutputStream,
79
     * If any pending or failed payment exists between given date range, it returns ByteArrayOutputStream,
81
     * otherwise it returns null.
80
     * otherwise it returns null.
82
     * @param startDate
81
     * @param startDate
83
     * @param endDate
82
     * @param endDate
84
     * @param status 0 --> user input: Successful  1: Failed & pending
83
     * @param status 0 --> user input: Successful  1: Failed & pending
85
     * @return
84
     * @return
86
     */
85
     */
87
    public ByteArrayOutputStream generatePaymentDetailsReport(Date startDate, Date endDate, int status) {
86
    public ByteArrayOutputStream generatePaymentDetailsReport(Date startDate, Date endDate, int status) {
88
 
-
 
89
        // Retrieving all the payments between start and end dates with status
87
        // Retrieving all the payments between start and end dates with status
90
        // as FAILED or INIT and for gateway Id = 1 (HDFC)
88
        // as FAILED or INIT and for gateway Id = 1 (HDFC)
91
        List<Payment> payments = null;
89
        List<Payment> payments = null;
92
        List<Payment> authorizedPayments = null;
90
        List<Payment> authorizedPayments = null;
93
        List<Payment> pendingPayments = null;
91
        List<Payment> pendingPayments = null;
Line 117... Line 115...
117
        if (payments == null || payments.isEmpty()) {
115
        if (payments == null || payments.isEmpty()) {
118
            return null;
116
            return null;
119
        }
117
        }
120
 
118
 
121
        // Preparing XLS file for output
119
        // Preparing XLS file for output
122
        return getSpreadSheetData(payments);
120
        return getSpreadSheetData(payments, false);
-
 
121
    }
123
 
122
 
-
 
123
	/**
-
 
124
	 * Generates the payment reconciliation report for the payments captured
-
 
125
	 * between the given dates.
-
 
126
	 * 
-
 
127
	 * @param startDate
-
 
128
	 * @param endDate
-
 
129
	 * @return
-
 
130
	 */
-
 
131
    public ByteArrayOutputStream generatePaymentReconciliationReport(Date startDate, Date endDate) {
-
 
132
		// Retrieving all the payments between start and end dates with status
-
 
133
		// as CAPTURED
-
 
134
        List<Payment> payments = null;
-
 
135
        try {
-
 
136
            payments = pClient.getPaymentsByCapturedDate(startDate.getTime(), endDate.getTime(), 0);
-
 
137
        } catch (PaymentException e) {
-
 
138
            logger.error("Error in payment service while getting payments", e);
-
 
139
        } catch (TException e) {
-
 
140
            logger.error("Error getting info from payment service", e);
-
 
141
        }
-
 
142
        if (payments == null || payments.isEmpty())
-
 
143
            return null;
-
 
144
 
-
 
145
        // Preparing XLS file for output
-
 
146
        return getSpreadSheetData(payments, true);
124
    }
147
    }
125
 
148
 
-
 
149
    
126
    // Prepares the XLS worksheet object and fills in the data with proper
150
    // Prepares the XLS worksheet object and fills in the data with proper
127
    // formatting
151
    // formatting
128
    private ByteArrayOutputStream getSpreadSheetData(List<Payment> payments) {
152
    private ByteArrayOutputStream getSpreadSheetData(List<Payment> payments, boolean useCaptureTimeAsTxnTime) {
129
        ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
153
        ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
130
 
154
 
131
        Workbook wb = new HSSFWorkbook();
155
        Workbook wb = new HSSFWorkbook();
132
 
156
 
133
        Font font = wb.createFont();
157
        Font font = wb.createFont();
Line 242... Line 266...
242
                    newRowHeight = Math.max(newRowHeight, (desc.length() / statusDescWidth + 1) * rowHeight);
266
                    newRowHeight = Math.max(newRowHeight, (desc.length() / statusDescWidth + 1) * rowHeight);
243
                }
267
                }
244
                
268
                
245
                contentRow.createCell(TXN_STATUS).setCellValue(payment.getGatewayTxnStatus());
269
                contentRow.createCell(TXN_STATUS).setCellValue(payment.getGatewayTxnStatus());
246
                contentRow.createCell(REF_CODE).setCellValue(payment.getReferenceCode());
270
                contentRow.createCell(REF_CODE).setCellValue(payment.getReferenceCode());
-
 
271
                
-
 
272
                if(useCaptureTimeAsTxnTime)
-
 
273
                	calendar.setTimeInMillis(payment.getSuccessTimestamp());
-
 
274
                else
247
                calendar.setTimeInMillis(payment.getInitTimestamp());
275
                	calendar.setTimeInMillis(payment.getInitTimestamp());
248
                contentRow.createCell(TXN_TIME).setCellValue(formatter.format(calendar.getTime()));
276
                contentRow.createCell(TXN_TIME).setCellValue(formatter.format(calendar.getTime()));
249
 
277
 
250
                txnId = payment.getMerchantTxnId();
278
                txnId = payment.getMerchantTxnId();
251
                orders = tClient.getOrdersForTransaction(txnId, payment.getUserId());
279
                orders = tClient.getOrdersForTransaction(txnId, payment.getUserId());
252
                List<LineItem> lineItems;
280
                List<LineItem> lineItems;