| Line 53... |
Line 53... |
| 53 |
* This method is used in PaymentDetailsController.
|
53 |
* This method is used in PaymentDetailsController.
|
| 54 |
* If any pending or failed payment exists between given date range, it returns ByteArrayOutputStream,
|
54 |
* If any pending or failed payment exists between given date range, it returns ByteArrayOutputStream,
|
| 55 |
* otherwise it returns null.
|
55 |
* otherwise it returns null.
|
| 56 |
* @param startDate
|
56 |
* @param startDate
|
| 57 |
* @param endDate
|
57 |
* @param endDate
|
| - |
|
58 |
* @param status 0 --> user input: Successful 1: Failed & pending
|
| 58 |
* @return
|
59 |
* @return
|
| 59 |
*/
|
60 |
*/
|
| 60 |
public ByteArrayOutputStream generatePaymentDetailsReport(Date startDate, Date endDate) {
|
61 |
public ByteArrayOutputStream generatePaymentDetailsReport(Date startDate, Date endDate, int status) {
|
| 61 |
|
62 |
|
| 62 |
// Retrieving all the payments between start and end dates with status
|
63 |
// Retrieving all the payments between start and end dates with status
|
| 63 |
// as FAILED or INIT and for gateway Id = 1 (HDFC)
|
64 |
// as FAILED or INIT and for gateway Id = 1 (HDFC)
|
| 64 |
List<Payment> payments = null;
|
65 |
List<Payment> payments = null;
|
| 65 |
List<Payment> pendingPayments = null;
|
66 |
List<Payment> pendingPayments = null;
|
| 66 |
try {
|
67 |
try {
|
| - |
|
68 |
if(status == 0) {
|
| - |
|
69 |
payments = pClient.getPayments(startDate.getTime(), endDate.getTime(), PaymentStatus.SUCCESS, 1);
|
| - |
|
70 |
} else {
|
| 67 |
payments = pClient.getPayments(startDate.getTime(), endDate.getTime(), PaymentStatus.FAILED, 1);
|
71 |
payments = pClient.getPayments(startDate.getTime(), endDate.getTime(), PaymentStatus.FAILED, 1);
|
| 68 |
pendingPayments = pClient.getPayments(startDate.getTime(), endDate.getTime(), PaymentStatus.INIT, 1);
|
72 |
pendingPayments = pClient.getPayments(startDate.getTime(), endDate.getTime(), PaymentStatus.INIT, 1);
|
| - |
|
73 |
if (payments != null && pendingPayments != null) {
|
| - |
|
74 |
payments.addAll(pendingPayments);
|
| - |
|
75 |
} else if (pendingPayments != null){
|
| - |
|
76 |
payments = pendingPayments;
|
| - |
|
77 |
}
|
| - |
|
78 |
}
|
| 69 |
} catch (PaymentException e) {
|
79 |
} catch (PaymentException e) {
|
| 70 |
e.printStackTrace();
|
80 |
e.printStackTrace();
|
| 71 |
} catch (TException e) {
|
81 |
} catch (TException e) {
|
| 72 |
e.printStackTrace();
|
82 |
e.printStackTrace();
|
| 73 |
}
|
83 |
}
|
| 74 |
if (payments != null && pendingPayments != null) {
|
- |
|
| 75 |
payments.addAll(pendingPayments);
|
- |
|
| 76 |
} else if (pendingPayments != null){
|
- |
|
| 77 |
payments = pendingPayments;
|
- |
|
| 78 |
}
|
- |
|
| 79 |
|
- |
|
| 80 |
if (payments == null || payments.isEmpty()) {
|
84 |
if (payments == null || payments.isEmpty()) {
|
| 81 |
return null;
|
85 |
return null;
|
| 82 |
}
|
86 |
}
|
| 83 |
|
87 |
|
| 84 |
// Preparing XLS file for output
|
88 |
// Preparing XLS file for output
|
| Line 256... |
Line 260... |
| 256 |
}
|
260 |
}
|
| 257 |
PaymentDetailsGenerator pdg = new PaymentDetailsGenerator();
|
261 |
PaymentDetailsGenerator pdg = new PaymentDetailsGenerator();
|
| 258 |
try {
|
262 |
try {
|
| 259 |
String userHome = System.getProperty("user.home");
|
263 |
String userHome = System.getProperty("user.home");
|
| 260 |
FileOutputStream f = new FileOutputStream(userHome + "/payment-details-report.xls");
|
264 |
FileOutputStream f = new FileOutputStream(userHome + "/payment-details-report.xls");
|
| 261 |
ByteArrayOutputStream baosXLS = pdg.generatePaymentDetailsReport(startDate, endDate);
|
265 |
ByteArrayOutputStream baosXLS = pdg.generatePaymentDetailsReport(startDate, endDate, 1);
|
| 262 |
baosXLS.writeTo(f);
|
266 |
baosXLS.writeTo(f);
|
| 263 |
f.close();
|
267 |
f.close();
|
| 264 |
} catch (FileNotFoundException e) {
|
268 |
} catch (FileNotFoundException e) {
|
| 265 |
e.printStackTrace();
|
269 |
e.printStackTrace();
|
| 266 |
} catch (IOException e) {
|
270 |
} catch (IOException e) {
|