Subversion Repositories SmartDukaan

Rev

Rev 4616 | Rev 4734 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4600 varun.gupt 1
package in.shop2020.support.controllers;
2
 
3
import java.io.ByteArrayOutputStream;
4
import java.io.File;
5
import java.io.FileInputStream;
6
import java.io.FileNotFoundException;
7
import java.io.IOException;
8
import java.text.DateFormat;
9
import java.text.ParseException;
10
import java.text.SimpleDateFormat;
4715 varun.gupt 11
import java.util.ArrayList;
4600 varun.gupt 12
import java.util.Date;
13
import java.util.HashMap;
14
import java.util.List;
15
import java.util.Map;
16
 
17
import in.shop2020.model.v1.catalog.InventoryService.Client;
18
import in.shop2020.model.v1.catalog.Vendor;
19
import in.shop2020.model.v1.order.LineItem;
20
import in.shop2020.model.v1.order.Order;
21
import in.shop2020.model.v1.order.PaymentSettlement;
22
import in.shop2020.model.v1.order.Transaction;
23
import in.shop2020.model.v1.order.TransactionServiceException;
24
import in.shop2020.payments.Payment;
25
import in.shop2020.payments.PaymentException;
26
import in.shop2020.payments.PaymentGateway;
27
import in.shop2020.thrift.clients.CatalogClient;
28
import in.shop2020.thrift.clients.PaymentClient;
29
import in.shop2020.thrift.clients.TransactionClient;
30
 
31
import javax.servlet.ServletContext;
32
import javax.servlet.ServletOutputStream;
33
import javax.servlet.http.HttpServletRequest;
34
import javax.servlet.http.HttpServletResponse;
35
import javax.servlet.http.HttpSession;
36
 
37
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
38
import org.apache.poi.ss.usermodel.Cell;
39
import org.apache.poi.ss.usermodel.CellStyle;
40
import org.apache.poi.ss.usermodel.Font;
41
import org.apache.poi.ss.usermodel.Row;
42
import org.apache.poi.ss.usermodel.Sheet;
43
import org.apache.poi.ss.usermodel.Workbook;
44
import org.apache.poi.ss.util.CellRangeAddress;
4601 varun.gupt 45
import org.apache.struts2.convention.annotation.InterceptorRef;
46
import org.apache.struts2.convention.annotation.InterceptorRefs;
47
import org.apache.struts2.convention.annotation.Result;
48
import org.apache.struts2.convention.annotation.Results;
4600 varun.gupt 49
import org.apache.struts2.interceptor.ServletRequestAware;
50
import org.apache.struts2.interceptor.ServletResponseAware;
51
import org.apache.struts2.rest.DefaultHttpHeaders;
52
import org.apache.struts2.rest.HttpHeaders;
53
import org.apache.struts2.util.ServletContextAware;
4715 varun.gupt 54
import org.apache.thrift.TApplicationException;
4600 varun.gupt 55
import org.apache.thrift.TException;
56
import org.apache.thrift.transport.TTransportException;
57
import org.slf4j.Logger;
58
import org.slf4j.LoggerFactory;
59
 
4715 varun.gupt 60
import com.opensymphony.xwork2.ValidationAwareSupport;
61
 
4600 varun.gupt 62
/**
63
 * @author Varun Gupta
64
 * @description: This class handles web requests to generate vendor specific reconciliation reports
65
 *               for given vendor for a given date range
66
 */
67
 
4715 varun.gupt 68
//@InterceptorRefs({
69
//    @InterceptorRef("defaultStack"),
70
//    @InterceptorRef("login")
71
//})
72
//@Results({
73
//    @Result(name="authfail", type="redirectAction", params = {"actionName" , "reports"})
74
//})
75
public class VendorReconciliationController extends ValidationAwareSupport implements ServletRequestAware, ServletResponseAware, ServletContextAware {
4600 varun.gupt 76
 
77
    private static Logger logger = LoggerFactory.getLogger(VendorReconciliationController.class);
78
 
79
	private enum OrderReportColumn {
80
	    ORDER_ID(0),
81
	    ORDER_DATE(1),
82
		BILLING_NUMBER(2),
83
		BILLING_DATE(3),
84
		DELIVERY_DATE(4),
85
		SETTLEMENT_DATE(5),
86
		CURRENT_STATUS(6),
87
		BRAND(7),
88
		MODEL_NAME(8),
89
		MODEL_NUMBER(9),
90
		COLOR(10),
91
		QUANTITY(11),
92
		UNIT_TRANSFER_PRICE(12),
93
		UNIT_SELLING_PRICE(13),
94
		TOTAL_TRANSFER_PRICE(14),
95
		TOTAL_SELLING_PRICE(15),
96
		GATEWAY_TRANSACTION_ID(16),
97
		PAYMENT_TYPE(17),
98
		PAYMENT_ID(18),
99
		COUPON_CODE(19),
100
		SERVICE_TAX(20),
101
		OTHER_CHARGES(21),
4715 varun.gupt 102
		NET_COLLECTION(22),
103
	    REFUND(23),
104
	    FINAL_AMOUNT(24),
105
	    IS_RESHIPED_ORDER(25);
4600 varun.gupt 106
//		COUPON_CATEGORY(19),
107
//		DISCOUNT(20),
108
 
109
		private int value;
110
 
111
		OrderReportColumn(int value) {
112
			this.value = value;
113
		}
114
		public int getValue(){
115
			return this.value;
116
		}
117
	}
118
 
119
	private enum OrderMismatchColumn	{
120
		ORDER_ID(0),
121
		EXPECTED_COLLECTION(1),
122
		ACTUAL_COLLECTION(2);
123
 
124
		private int value;
125
 
126
		OrderMismatchColumn(int value) {
127
			this.value = value;
128
		}
129
		public int getValue(){
130
			return this.value;
131
		}
132
	}
133
 
134
	private HttpServletRequest request;
135
	private HttpServletResponse response;
136
	private ServletContext context;
137
    private HttpSession session;
138
	private List<Vendor> vendors;
139
	private String reportSource;
4715 varun.gupt 140
	private List<Long> orderIdsWithoutSuccess;
4600 varun.gupt 141
 
142
	private File hdfcSettlementReport;
143
 
144
	private File ebsSettlementReport;
145
	private File ebsSettlementSummary;
146
 
147
	private String bluedartSettlementDate;
148
	private File bluedartSettlementReport;
149
 
4715 varun.gupt 150
	private String aramexSettlementDate;
151
	private File aramexSettlementReport;
152
 
4600 varun.gupt 153
	private Map<Long, Map<String, Double>> misMatches = new HashMap<Long, Map<String, Double>>();
154
	private Map<Long, String> ebsSettlementSummaries;
155
 
156
	private final DateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy");
157
 
158
	public VendorReconciliationController()	{
159
		try	{
160
			CatalogClient csc = new CatalogClient();
161
			Client catalogClient = csc.getClient();
162
 
163
			vendors = catalogClient.getAllVendors();
4715 varun.gupt 164
			orderIdsWithoutSuccess = new ArrayList<Long>();
165
 
4600 varun.gupt 166
			TransactionClient tsc = new TransactionClient();
167
			in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
168
 
169
			ebsSettlementSummaries = transactionClient.getEBSSettlementSummaries();
4715 varun.gupt 170
			logger.info("", ebsSettlementSummaries);
4600 varun.gupt 171
 
4715 varun.gupt 172
		} catch (TException e) {
173
			logger.error("TException", e);
174
 
175
		} catch (TransactionServiceException e) {
176
			logger.error("TransactionServiceException", e);
4600 varun.gupt 177
		}
178
	}
179
 
180
	public String index()	{
181
		return "report";
182
	}
183
 
184
	public HttpHeaders create()	{
185
 
186
		String formType = request.getParameter("formtype");
4715 varun.gupt 187
		logger.info("Form Type: " + formType);
4600 varun.gupt 188
 
189
		if (formType.equals("uploadEBSSettlementSummary")) {
190
			uploadEBSSettlementSummary();
191
 
192
		} else if (formType.equals("uploadEBSSettlements")) {
193
			uploadEBSSettlements();
194
 
195
		} else if (formType.equals("uploadHDFCSettlements")) {
196
			uploadHDFCSettlements();
197
 
198
		} else if (formType.equals("uploadBluedartSettlements")) {
199
			uploadBluedartSettlements();
4715 varun.gupt 200
 
201
		} else if (formType.equals("uploadAramexSettlements")) {
202
			uploadAramexSettlements();
4600 varun.gupt 203
		}
4715 varun.gupt 204
	    logger.info("Order Ids where no successful payment was found", orderIdsWithoutSuccess);
205
 
4600 varun.gupt 206
		return new DefaultHttpHeaders("report");
207
	}
208
 
209
	public HttpHeaders generateReconciliationReport()	{
210
		DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
211
 
212
		try	{
213
			//Formatting Form input parameters
214
 
215
		    Date startDate = dateFormat.parse(request.getParameter("start"));
216
			Date endDate = dateFormat.parse(request.getParameter("end"));
217
		    long vendorId = Long.parseLong(request.getParameter("vendor"));
218
 
219
		    logger.info(startDate + " " + endDate + " " + vendorId);
220
 
221
			TransactionClient tsc = new TransactionClient();
222
			in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
223
 
224
			List<Order> orders = transactionClient.getBilledOrdersForVendor(vendorId, startDate.getTime(), endDate.getTime());
225
			logger.info("Order count: " + orders.size());
226
			DateFormat dateFormatForFile = new SimpleDateFormat("dd.MM.yyyy");
227
			String vendorName = getVendorName(vendorId);
4715 varun.gupt 228
 
4600 varun.gupt 229
			response.setContentType("application/vnd.ms-excel");
230
			response.setHeader("Content-disposition", "inline; filename=" + vendorName + "-reconciliation-from-" + dateFormatForFile.format(startDate) + "-" + dateFormatForFile.format(endDate) + ".xls");
231
 
232
			ServletOutputStream sos;
233
			try {
234
				ByteArrayOutputStream baos = getReconciliationReport(orders, startDate, endDate);
235
				sos = response.getOutputStream();
236
				baos.writeTo(sos);
237
				sos.flush();
238
			} catch (IOException e)	{
239
				logger.error("Error while streaming the hotspot reconciliation report", e);
240
			}
241
		} catch (ParseException e)	{
242
			logger.error("Unable to parse the start or end date", e);
243
		} catch (TransactionServiceException e)	{
244
			logger.error("Error while getting order information from the transaction service", e);
245
		} catch (TException e) {
246
            logger.error("Unable to get the orders or the warehouses", e);
247
		} catch (NullPointerException e)   {
248
            logger.error("NullPointerException", e);
249
		} catch (Exception e)   {
250
            logger.error("Unexpected exception", e);
251
        }
252
		return new DefaultHttpHeaders("report");
253
	}
254
 
255
	public void uploadEBSSettlementSummary()	{
256
 
257
		DateFormat settlementDateFormat = new SimpleDateFormat("dd MMM,yyyy hh:mm:ss a");
258
		DateFormat transactionDateFormat = new SimpleDateFormat("yyyy-MM-dd");
259
 
260
		Workbook wb = null;
261
        try {
262
            wb = new HSSFWorkbook(new FileInputStream(ebsSettlementSummary));
263
        } catch (FileNotFoundException e) {
264
            logger.error("Unable to open the Settlement Summary report", e);
265
        } catch (IOException e) {
266
            logger.error("Unable to open the Settlement Summary report", e);
267
        }
268
        Sheet sheet = wb.getSheetAt(0);
269
 
270
        int indexSettlementId = 0;
271
        int indexSettlementDate = 1;
272
        int indexTransactionDateFrom = 2;
273
        int indexTransactionDateTo = 3;
274
        int indexAmount = 4;
275
 
276
        Row firstRow = sheet.getRow(0);
277
        Row secondRow = sheet.getRow(1);
278
        Row thirdRow = sheet.getRow(2);
279
        Row fourthRow = sheet.getRow(3);
280
        Row fifthRow = sheet.getRow(4);
281
 
282
		TransactionClient tsc;
283
 
284
		try {
285
			tsc = new TransactionClient();
286
			in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
287
 
288
			for(Row row: sheet)	{
289
				if(row.equals(firstRow) || row.equals(secondRow) || row.equals(thirdRow) || row.equals(fourthRow) || row.equals(fifthRow))	{
290
					continue;
291
				}
292
				long settlementId = (long) row.getCell(indexSettlementId).getNumericCellValue();
293
				String settlementDateStr = row.getCell(indexSettlementDate).getStringCellValue();
294
				String transactionDateFromStr = row.getCell(indexTransactionDateFrom).getStringCellValue();
295
				String transactionDateToStr = row.getCell(indexTransactionDateTo).getStringCellValue();
296
				Double amount = row.getCell(indexAmount).getNumericCellValue();
297
 
298
				Date settlementDate = settlementDateFormat.parse(settlementDateStr);
299
				Date transactionDateFrom = transactionDateFormat.parse(transactionDateFromStr);
300
				Date transactionDateTo = transactionDateFormat.parse(transactionDateToStr);
301
 
302
				try	{
303
					transactionClient.saveEBSSettlementSummary(settlementId, settlementDate.getTime(), transactionDateFrom.getTime(), transactionDateTo.getTime(), amount);
304
 
305
				} catch (Exception e) {
306
					e.printStackTrace();
307
				}
308
			}
309
        } catch (Exception e) {
310
        	e.printStackTrace();
311
		}
312
	}
313
 
314
	public void uploadHDFCSettlements()	{
315
		logger.info("Uploading HDFC settlements");
316
 
317
		Workbook wb = null;
318
		try {
319
			wb = new HSSFWorkbook(new FileInputStream(this.hdfcSettlementReport));
320
		} catch (FileNotFoundException e) {
321
			logger.error("Unable to open the Settlement report", e);
322
		} catch (IOException e) {
323
			logger.error("Unable to open the Settlement report", e);
324
		}
325
		Sheet sheet = wb.getSheetAt(0);
326
 
327
		Row firstRow = sheet.getRow(0);
328
 
329
		int indexRECFMT = 2;
330
		int indexSettlementDate = 7;
331
		int indexPaymentId = 13;
332
		int indexMSF = 14;
333
		int indexServiceTax = 15;
334
		int indexEduCess = 16;
335
		int indexNetCollection = 17;
336
 
337
		TransactionClient tsc;
338
		String paymentIdStr = "";
339
		long paymentId = 0;
340
 
341
		try {
342
			tsc = new TransactionClient();
343
			in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
344
 
345
			for (Row row: sheet)	{
346
                if(row.equals(firstRow))	continue;
347
 
348
                try	{
349
                    String recfmt = row.getCell(indexRECFMT).getStringCellValue();
350
                    Date settlementDate = row.getCell(indexSettlementDate).getDateCellValue();
351
                	double netCollection = row.getCell(indexNetCollection).getNumericCellValue();
352
                	paymentIdStr = row.getCell(indexPaymentId).getStringCellValue().replace("'", "");
353
                	paymentId = Long.parseLong(paymentIdStr);
354
 
355
                	logger.info("paymentId: " + paymentId + ", recfmt: " + recfmt + ", settlementDate: " + settlementDate + ", netCollection: " + netCollection);
356
 
4715 varun.gupt 357
                    if (recfmt.trim().equalsIgnoreCase("CVD"))	{
358
                    	if (netCollection > 0.0)	netCollection *= -1.0;
359
                    	transactionClient.savePaymentSettlements(settlementDate.getTime(), 1, paymentId, 0.0, 0.0, netCollection);
4600 varun.gupt 360
 
361
                    } else	{
362
                    	double msf = row.getCell(indexMSF).getNumericCellValue();
363
                    	double serviceTax = row.getCell(indexServiceTax).getNumericCellValue();
364
                    	double eduCess = row.getCell(indexEduCess).getNumericCellValue();
365
                    	logger.info("msf: " + msf + ", serviceTax: " + serviceTax + ", eduCess: " + eduCess);
366
 
367
                    	transactionClient.savePaymentSettlements(settlementDate.getTime(), 1, paymentId, serviceTax, (eduCess + msf), netCollection);
368
                 	}
369
                } catch (NumberFormatException e) {
370
        			logger.error("NumberFormatException recieved for payment Id," + paymentIdStr + " "+ e);
371
 
372
        		} catch (TransactionServiceException e) {
373
        			logger.error("TransactionServiceException recieved for payment Id," + Long.toString(paymentId) + " " + e);
374
        		}
375
			}
376
		} catch (TTransportException e) {
377
			logger.error("TTransportException recieved for payment Id," + Long.toString(paymentId) + " " + e);
378
 
379
		} catch (TException e) {
380
			logger.error("TException recieved for payment Id," + Long.toString(paymentId) + " " + e);
381
		}
382
	}
383
 
384
	public void uploadEBSSettlements()	{
385
		Workbook wb = null;
386
        try {
387
            wb = new HSSFWorkbook(new FileInputStream(this.ebsSettlementReport));
388
        } catch (FileNotFoundException e) {
389
            logger.error("Unable to open the Settlement report", e);
390
        } catch (IOException e) {
391
            logger.error("Unable to open the Settlement report", e);
392
        }
393
 
394
        Sheet sheet = wb.getSheetAt(0);
395
 
396
		Row firstRow = sheet.getRow(0);
397
		Row secondRow = sheet.getRow(1);
398
 
399
        int indexPaymentId = 2;
400
        int indexTxnType = 5;
401
        int indexAmount = 6;
402
 
403
        Map<Long, Map<String, Double>> map = new HashMap<Long, Map<String,Double>>();
404
        Map <String, Double> record;
405
 
406
        try	{
407
        	for (Row row: sheet)	{
408
                if(row.equals(firstRow) || row.equals(secondRow))	continue;
409
 
410
                long paymentId = Long.parseLong(row.getCell(indexPaymentId).getStringCellValue());
411
                String transactionType = row.getCell(indexTxnType).getStringCellValue();
412
                double amount = row.getCell(indexAmount).getNumericCellValue();
413
 
414
                if(map.containsKey(paymentId))	{
415
                	map.get(paymentId).put(transactionType, amount);
416
 
417
                } else	{
418
                	record = new HashMap<String, Double>();
419
                	record.put(transactionType, amount);
420
                	map.put(paymentId, record);
421
                }
422
        	}
423
        } catch	(NullPointerException e)	{
424
        	logger.error("" + e);
425
        }
426
 
427
		TransactionClient tsc;
428
 
429
        long settlementId = Long.parseLong(request.getParameter("settlementId"));
430
 
431
        try	{
432
			tsc = new TransactionClient();
433
			in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
434
			long settlementDate = transactionClient.getEBSSettlementDate(settlementId);
435
 
436
        	for (long paymentId: map.keySet())	{
437
            	record = map.get(paymentId);
438
 
439
            	if(record.containsKey("Captured"))	{
440
            		double capturedAmount = record.get("Captured");
441
            		double tdr = record.get("TDR");
442
            		double serviceTax = record.get("ServiceTax");
443
 
444
            		if(tdr < 0)	tdr *= -1;
445
            		if(serviceTax < 0)	serviceTax *= -1;
446
 
447
            		double amount = capturedAmount - tdr - serviceTax;
448
            		transactionClient.savePaymentSettlements(settlementDate, 2, paymentId, serviceTax, tdr, amount);
449
            	} else	{
450
            		double refundedAmount = record.get("Refunded");
451
 
452
            		if (refundedAmount > 0)	refundedAmount *= -1;
453
 
454
            		transactionClient.savePaymentSettlements(settlementDate, 2, paymentId, 0.0, 0.0, refundedAmount);
455
            	}
456
            }
457
        	transactionClient.markEBSSettlementUploaded(settlementId);
458
 
459
        } catch (TTransportException e) {
460
        	logger.error("TTransportException " + e);
461
		} catch (TException e) {
462
        	logger.error("TException " + e);
463
		} catch (TransactionServiceException e) {
464
        	logger.error("TransactionServiceException " + e);
465
		}
466
	}
467
 
468
	public void uploadBluedartSettlements()	{
469
 
470
		Workbook wb = null;
471
        try {
472
            wb = new HSSFWorkbook(new FileInputStream(this.bluedartSettlementReport));
473
        } catch (FileNotFoundException e) {
474
            logger.error("Unable to open the Settlement report", e);
475
        } catch (IOException e) {
476
            logger.error("Unable to open the Settlement report", e);
477
        }
478
 
479
        Sheet sheet = wb.getSheetAt(0);
480
 
481
        Row firstRow = sheet.getRow(0);
482
        logger.info("Cell count:" + firstRow.getPhysicalNumberOfCells());
483
 
484
        int indexAWBno = 4;		//FIXME: add look up string to determine exact cell
485
        int indexAmount = 19;
486
 
487
        TransactionClient tsc;
488
        PaymentClient psc;
489
 
490
        try	{
491
			long settlementDate = DATE_FORMAT.parse(bluedartSettlementDate).getTime();
492
        	tsc = new TransactionClient();
493
        	in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
494
			psc = new PaymentClient();
495
	    	in.shop2020.payments.PaymentService.Client paymentClient = psc.getClient();
496
 
497
        	for (Row row : sheet) {
4715 varun.gupt 498
        		Order order = null;
4600 varun.gupt 499
        		try	{
500
        			if(row.equals(firstRow))	continue;
501
        			long awbNumber = (long) row.getCell(indexAWBno).getNumericCellValue();
4715 varun.gupt 502
 
4600 varun.gupt 503
        			double amount = row.getCell(indexAmount).getNumericCellValue();
4715 varun.gupt 504
        			order = transactionClient.getOrderForAwb(Long.toString(awbNumber));
4600 varun.gupt 505
        			Payment payment = paymentClient.getSuccessfulPaymentForTxnId(order.getTransactionId());
506
        			logger.info("settlementDate: " + settlementDate + ", PaymentId: " + payment.getPaymentId() + ", Amount: " + amount);
507
 
508
        			transactionClient.savePaymentSettlements(settlementDate, 4, payment.getPaymentId(), 0.0, 0, amount);
509
        		} catch (NullPointerException e) {
510
        			logger.error("" + e);
511
 
512
        		} catch (PaymentException e) {
513
        			logger.error("" + e);
514
 
515
				} catch (TransactionServiceException e) {
516
					logger.error("" + e);
4715 varun.gupt 517
 
518
				} catch (TApplicationException e)	{
519
					orderIdsWithoutSuccess.add(order.getId());
520
 
521
					logger.error("Application Exception while getting successfull payment for transaction Id, " + order.getTransactionId(), e);
522
					addActionError("Application Exception while getting payment for transaction Id, " + order.getTransactionId());
4600 varun.gupt 523
				}
524
        	}
525
        } catch (ParseException e) {
526
        	logger.error("Could not parse " + bluedartSettlementDate + " " + e);
527
		} catch (TTransportException e) {
528
			logger.error("" + e);
529
        } catch (TException e) {
530
        	logger.error("" + e);
531
        }
532
	}
533
 
4715 varun.gupt 534
	public void uploadAramexSettlements()	{
535
		logger.info("Uploading Aramex Settlements" + this.aramexSettlementDate);
536
 
537
		if(this.aramexSettlementDate.equals(""))	{
538
			addActionError("Settlement date cannot be left blank");
539
			return;
540
		}
541
 
542
		Workbook wb = null;
543
        try {
544
            wb = new HSSFWorkbook(new FileInputStream(this.aramexSettlementReport));
545
        } catch (FileNotFoundException e) {
546
            logger.error("Unable to open the Settlement report", e);
547
        } catch (IOException e) {
548
            logger.error("Unable to open the Settlement report", e);
549
        } catch (NullPointerException e) {
550
        	addActionError(e.getMessage());
551
        	logger.error("Unable to open the Settlement report", e);
552
        	return;
553
		}
554
 
555
        Sheet sheet = wb.getSheetAt(0);
556
 
557
        int indexOrderId = 0;
558
        int indexAmount = 4;
559
 
560
        Row firstRow = sheet.getRow(0);
561
        logger.info("Cell count:" + firstRow.getPhysicalNumberOfCells());
562
 
563
        TransactionClient tsc;
564
        PaymentClient psc;
565
 
566
        try	{
567
			long settlementDate = DATE_FORMAT.parse(aramexSettlementDate).getTime();
568
 
569
        	tsc = new TransactionClient();
570
        	in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
571
			psc = new PaymentClient();
572
	    	in.shop2020.payments.PaymentService.Client paymentClient = psc.getClient();
573
 
574
	    	for (Row row: sheet)	{
575
	    		if(row.equals(firstRow))	continue;
576
 
577
	    		long orderId = (long) row.getCell(indexOrderId).getNumericCellValue();
578
	    		double amount = row.getCell(indexAmount).getNumericCellValue();
579
	    		Order order = null;
580
 
581
	    		try {
582
					order = transactionClient.getOrder(orderId);
583
					Payment payment = paymentClient.getSuccessfulPaymentForTxnId(order.getTransactionId());
584
					transactionClient.savePaymentSettlements(settlementDate, 4, payment.getPaymentId(), 0.0, 0.0, amount);
585
 
586
				} catch (TransactionServiceException e) {
587
					logger.error("Transaction Service Exception while getting order for id, " + orderId, e);
588
					addActionError("Transaction Service Exception while getting order for id, " + orderId);
589
 
590
				} catch (PaymentException e) {
591
					logger.error("Payment Service Exception while getting successfull payment for transaction Id, " + order.getTransactionId(), e);
592
					addActionError("Payment Service Exception while getting payment for transaction Id, " + order.getTransactionId());
593
 
594
				} catch (TApplicationException e)	{
595
					orderIdsWithoutSuccess.add(orderId);
596
					logger.error("Application Exception while getting successfull payment for transaction Id, " + order.getTransactionId(), e);
597
					addActionError("Application Exception while getting payment for transaction Id, " + order.getTransactionId());
598
				}
599
	    	}
600
        } catch (ParseException e) {
601
        	addActionError("Could not parse " + aramexSettlementDate);
602
        	logger.error("Could not parse " + aramexSettlementDate + " " + e);
603
        	return;
604
        } catch (TTransportException e) {
605
        	logger.error("" + e);
606
        } catch (TException e) {
607
        	logger.error("" + e);
608
        }
609
	}
610
 
4600 varun.gupt 611
	// Prepares the XLS worksheet object and fills in the data with proper formatting
612
	private ByteArrayOutputStream getReconciliationReport(List<Order> orders, Date startDate, Date endDate)	{
613
		ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
614
 
615
	    Workbook wb = new HSSFWorkbook();
616
 
617
	    //Create the style for the title row
618
	    Font font = wb.createFont();
619
	    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
620
	    CellStyle boldStyle = wb.createCellStyle();
621
	    boldStyle.setFont(font);
622
 
623
	    CellStyle rightAlignStyle = wb.createCellStyle();
624
	    rightAlignStyle.setAlignment(CellStyle.ALIGN_RIGHT);
625
 
626
		Sheet orderSheet = wb.createSheet("Orders");
627
		Sheet mismatchSheet = wb.createSheet("Mismatches");
628
 
629
	    populateOrderSheet(orders, startDate, endDate, orderSheet, boldStyle, rightAlignStyle);
630
	    populateMismatchSheet(mismatchSheet);
631
 
632
		// Write the workbook to the output stream
633
		try {
634
			wb.write(baosXLS);
635
			baosXLS.close();
636
		} catch (IOException e) {
637
			logger.error("Unable to write the hotspot reconciliation report to the byte array", e);
638
		}		
639
		return baosXLS;
640
	}
641
 
642
	private void populateMismatchSheet(Sheet sheet)	{
643
	    int serialNo = 0;
644
		Row titleRow = sheet.createRow(serialNo ++);
645
	    Cell titleCell = titleRow.createCell(0);
646
	    titleCell.setCellValue("Order Reconciliation Report (Mis-matches)");
647
 
648
	    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 4));
649
	    sheet.createRow(serialNo ++);
650
 
651
	    Row headerRow = sheet.createRow(serialNo ++);
652
	    headerRow.createCell(OrderMismatchColumn.ORDER_ID.getValue()).setCellValue("Order Id");
653
	    headerRow.createCell(OrderMismatchColumn.EXPECTED_COLLECTION.getValue()).setCellValue("Expected Collection");
654
	    headerRow.createCell(OrderMismatchColumn.ACTUAL_COLLECTION.getValue()).setCellValue("Actual Collection");
655
 
656
	    for (long orderId: misMatches.keySet())	{
657
	    	Row contentRow = sheet.createRow(serialNo ++);
658
	    	contentRow.createCell(OrderMismatchColumn.ORDER_ID.getValue()).setCellValue(orderId);
659
	    	contentRow.createCell(OrderMismatchColumn.EXPECTED_COLLECTION.getValue()).setCellValue(misMatches.get(orderId).get("expected"));
660
	    	contentRow.createCell(OrderMismatchColumn.ACTUAL_COLLECTION.getValue()).setCellValue(misMatches.get(orderId).get("actual"));
661
	    }
662
	}
663
 
664
	private void populateOrderSheet(List<Order> orders, Date startDate, Date endDate, Sheet sheet, CellStyle style, CellStyle rightAlignStyle) {
665
	    short serialNo = 0;
666
 
667
	    // Create the title row and put all the titles in it. Rows are 0 based.
668
	    Row titleRow = sheet.createRow(serialNo ++);
669
	    Cell titleCell = titleRow.createCell(0);
670
	    titleCell.setCellValue("Order Reconciliation Report (" + DATE_FORMAT.format(startDate) + " - " + DATE_FORMAT.format(endDate) + ")");
671
	    titleCell.setCellStyle(style);
672
 
673
	    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
674
 
675
	    sheet.createRow(serialNo ++);
676
 
677
	    Row headerRow = sheet.createRow(serialNo ++);
678
	    headerRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue("Order Id");
679
	    headerRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue("Order Date");
680
	    headerRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue("Billing Number");
681
	    headerRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue("Billing Date");
682
	    headerRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue("Delivery Date");
683
	    headerRow.createCell(OrderReportColumn.SETTLEMENT_DATE.getValue()).setCellValue("Settlement Date");
684
	    headerRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue("Brand");
685
	    headerRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue("Model Name");
686
	    headerRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue("Model Number");
687
	    headerRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue("Color");
688
	    headerRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue("Quantity");
689
	    headerRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue("Unit Transfer Price");
690
	    headerRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue("Unit Selling Price");
691
	    headerRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue("Total Transfer Price");
692
	    headerRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue("Total Selling Price");
693
	    headerRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue("Current Status");
694
	    headerRow.createCell(OrderReportColumn.GATEWAY_TRANSACTION_ID.getValue()).setCellValue("Gateway Transaction Id");
695
	    headerRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue("Payment Type");
696
	    headerRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue("Payment Id");
697
	    headerRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue("Coupon Code");
698
//	    headerRow.createCell(OrderReportColumn.COUPON_CATEGORY.getValue()).setCellValue("Coupon Category");
699
//	    headerRow.createCell(OrderReportColumn.DISCOUNT.getValue()).setCellValue("Discount");
700
	    headerRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue("Service Tax");
701
	    headerRow.createCell(OrderReportColumn.OTHER_CHARGES.getValue()).setCellValue("Other Charges");
702
	    headerRow.createCell(OrderReportColumn.NET_COLLECTION.getValue()).setCellValue("Net Collection");
4715 varun.gupt 703
	    headerRow.createCell(OrderReportColumn.REFUND.getValue()).setCellValue("Refund");
704
	    headerRow.createCell(OrderReportColumn.FINAL_AMOUNT.getValue()).setCellValue("Final Amount");
705
	    headerRow.createCell(OrderReportColumn.IS_RESHIPED_ORDER.getValue()).setCellValue("Is Reshipped Order");
4600 varun.gupt 706
 
707
	    sheet.createRow(serialNo ++);
708
 
709
		TransactionClient tsc;
710
    	PaymentClient psc;
711
 
712
		try {
713
			tsc = new TransactionClient();
714
			in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
715
 
716
			psc = new PaymentClient();
717
	    	in.shop2020.payments.PaymentService.Client paymentClient = psc.getClient();
718
 
719
	    	List<PaymentGateway> tPaymentGateways = paymentClient.getActivePaymentGateways();
720
	    	Map<Long, String> paymentGateways = new HashMap<Long, String>();
721
 
722
	    	for (PaymentGateway tPaymentGateway: tPaymentGateways)	{
723
	    		paymentGateways.put(tPaymentGateway.getId(), tPaymentGateway.getName());
724
	    	}
725
 
4715 varun.gupt 726
			List<PaymentSettlement> settlements = transactionClient.getSettlementsByDate(startDate.getTime(), endDate.getTime(), true);
727
			logger.info("Refunds: " + settlements.size());
728
			logger.info(settlements.toString());
729
 
730
			Map<Long, PaymentSettlement> refunds = new HashMap<Long, PaymentSettlement>();
731
 
732
			for (PaymentSettlement settlement: settlements)	{
733
				refunds.put(settlement.getPaymentId(), settlement);
734
			}
735
 
736
			List <Long> orderIds = new ArrayList<Long>();
737
 
4600 varun.gupt 738
			for(Order order : orders)	{
4715 varun.gupt 739
				orderIds.add(order.getId());
740
			}
741
 
742
			List<Long> reshippedOrderIds = null;
743
 
744
			reshippedOrderIds = transactionClient.getReshippedOrderIds(orderIds);
745
 
746
			for(Order order : orders)	{
747
			    logger.info("For order: " + order.getId());
4600 varun.gupt 748
 
749
			    LineItem lineItem = order.getLineitems().get(0);
750
			    double transferPrice = lineItem.getTransfer_price();
4715 varun.gupt 751
			    Payment payment = null;
4600 varun.gupt 752
 
4715 varun.gupt 753
			    try	{
754
			    	payment = paymentClient.getSuccessfulPaymentForTxnId(order.getTransactionId());
755
				    logger.info("getSuccessfulPaymentForTxnId: " + payment);
756
 
757
			    } catch (TApplicationException e)	{
758
			    	orderIdsWithoutSuccess.add(order.getId());
759
 
760
					logger.error("Exception while getting successfull payment for transaction Id, " + order.getTransactionId(), e);
761
					addActionError("Exception while getting payment for transaction Id, " + order.getTransactionId());
762
				}
763
 
4600 varun.gupt 764
			    Transaction txn = transactionClient.getTransaction(order.getTransactionId());
4715 varun.gupt 765
			    PaymentSettlement paymentSettlement = null;
766
			    String paymentType = null;
4600 varun.gupt 767
 
4715 varun.gupt 768
			    if(payment != null)	{
769
			    	paymentSettlement = transactionClient.getSettlementForPaymentId(payment.getPaymentId());
770
			    	paymentType = paymentGateways.get(payment.getGatewayId());
771
			    }
772
 
4600 varun.gupt 773
	            double totalSellingPrice = lineItem.getTotal_price();
4715 varun.gupt 774
	            double serviceTax = 0.0;
775
	            double otherCollectionCharges = 0.0;
776
	            double netCollection = 0.0;
4600 varun.gupt 777
 
4715 varun.gupt 778
	            if(paymentSettlement != null)	{
779
		            serviceTax = paymentSettlement.getServiceTax();
780
		            otherCollectionCharges = paymentSettlement.getOtherCharges();
781
		            netCollection = paymentSettlement.getNetCollection();
782
	            }
4600 varun.gupt 783
 
784
	            if (netCollection < 0.0)	{
785
	            	paymentType = paymentType + "-REFUND";
786
	            }
787
	            double expectedCollection = totalSellingPrice - otherCollectionCharges - serviceTax;
788
 
789
	            //FIXME ignore differences of upto 50 paisa
790
	            if (netCollection > 0.0 && expectedCollection != netCollection)	{
791
	            	Map <String, Double> mismatch = new HashMap<String, Double>();
792
	            	mismatch.put("expected", expectedCollection);
793
	            	mismatch.put("actual", netCollection);
794
	            	misMatches.put(order.getId(), mismatch);
795
	            }
796
 
4715 varun.gupt 797
		    	Row contentRow = sheet.createRow(serialNo++);
4600 varun.gupt 798
	            contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
799
	            contentRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getCreated_timestamp())));
800
			    contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
801
			    contentRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getBilling_timestamp())));
802
			    contentRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getDelivery_timestamp())));
803
			    contentRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
804
			    contentRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
805
			    contentRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
806
			    contentRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
807
			    contentRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue(lineItem.getQuantity());
808
			    contentRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue(transferPrice);
809
			    contentRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue(lineItem.getUnit_price());
810
			    contentRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue(transferPrice * lineItem.getQuantity());
811
			    contentRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue(totalSellingPrice);
812
			    contentRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue(order.getStatusDescription());
4715 varun.gupt 813
 
814
		    	double refund = 0.0;
815
 
816
			    if (payment != null)	{
817
				    contentRow.createCell(OrderReportColumn.SETTLEMENT_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(paymentSettlement.getSettlementDate())));
818
			    	contentRow.createCell(OrderReportColumn.GATEWAY_TRANSACTION_ID.getValue()).setCellValue(payment.getGatewayTxnId());
819
			    	contentRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue(paymentType);
820
			    	contentRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue(payment.getPaymentId());
821
 
822
			    	if(refunds.containsKey(payment.getPaymentId()))	{
823
			    		refund = refunds.get(payment.getPaymentId()).getNetCollection();
824
			    		refunds.remove(payment.getPaymentId());
825
			    	}
826
			    	contentRow.createCell(OrderReportColumn.REFUND.getValue()).setCellValue(refund);
827
			    }
4600 varun.gupt 828
			    contentRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue(txn.getCoupon_code());
829
			    contentRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue(serviceTax);
830
			    contentRow.createCell(OrderReportColumn.OTHER_CHARGES.getValue()).setCellValue(otherCollectionCharges);
831
			    contentRow.createCell(OrderReportColumn.NET_COLLECTION.getValue()).setCellValue(netCollection);
4715 varun.gupt 832
			    contentRow.createCell(OrderReportColumn.FINAL_AMOUNT.getValue()).setCellValue(netCollection - refund);
833
 
834
			    boolean isReshippedOrder = reshippedOrderIds.contains(order.getId());
835
			    contentRow.createCell(OrderReportColumn.IS_RESHIPED_ORDER.getValue()).setCellValue(isReshippedOrder ? 1 : 0);
4600 varun.gupt 836
		    }
4715 varun.gupt 837
		    logger.info("Order Ids where no successful payment was found: " + orderIdsWithoutSuccess.size());
838
		    logger.info(orderIdsWithoutSuccess.toString());
839
		    logger.info("Pending Refunds: " + refunds);
840
		    logger.info("Reshipped Order Ids" + reshippedOrderIds);
841
 
842
	    	sheet.createRow(serialNo++);
843
 
844
		    // Refunds belonging to orders billed before the start date of supplied billing date range
845
		    for (long paymentId: refunds.keySet())	{
846
		    	Payment payment = paymentClient.getPayment(paymentId);
847
		    	Transaction txn = transactionClient.getTransaction(payment.getMerchantTxnId());
848
		    	PaymentSettlement paymentSettlement = refunds.get(paymentId);
849
 
850
		    	for (Order order: txn.getOrders())	{
851
			    	Row contentRow = sheet.createRow(serialNo++);
852
 
853
			    	LineItem lineItem = order.getLineitems().get(0);
854
				    double transferPrice = lineItem.getTransfer_price();
855
		            double totalSellingPrice = lineItem.getTotal_price();
856
		            String paymentType = paymentGateways.get(payment.getGatewayId()) + "-REFUND";
857
 
858
			    	contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
859
		            contentRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getCreated_timestamp())));
860
				    contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
861
				    contentRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getBilling_timestamp())));
862
				    contentRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getDelivery_timestamp())));
863
				    contentRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
864
				    contentRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
865
				    contentRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
866
				    contentRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
867
				    contentRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue(lineItem.getQuantity());
868
				    contentRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue(transferPrice);
869
				    contentRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue(lineItem.getUnit_price());
870
				    contentRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue(transferPrice * lineItem.getQuantity());
871
				    contentRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue(totalSellingPrice);
872
				    contentRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue(order.getStatusDescription());
873
 
874
				    contentRow.createCell(OrderReportColumn.SETTLEMENT_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(paymentSettlement.getSettlementDate())));
875
			    	contentRow.createCell(OrderReportColumn.GATEWAY_TRANSACTION_ID.getValue()).setCellValue(payment.getGatewayTxnId());
876
			    	contentRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue(paymentType);
877
			    	contentRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue(payment.getPaymentId());
878
			    	contentRow.createCell(OrderReportColumn.REFUND.getValue()).setCellValue(paymentSettlement.getNetCollection());
879
 
880
				    contentRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue(txn.getCoupon_code());
881
				    contentRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue(0.0);
882
				    contentRow.createCell(OrderReportColumn.OTHER_CHARGES.getValue()).setCellValue(0.0);
883
				    contentRow.createCell(OrderReportColumn.NET_COLLECTION.getValue()).setCellValue(paymentSettlement.getNetCollection());
884
		    	}
885
		    }
886
 
4600 varun.gupt 887
		} catch (TTransportException e) {
4715 varun.gupt 888
			logger.error("TTransportException " + e);
4600 varun.gupt 889
		} catch (PaymentException e) {
4715 varun.gupt 890
			logger.error("PaymentException " + e);
4600 varun.gupt 891
		} catch (TException e) {
4715 varun.gupt 892
			logger.error("TException " + e);
4600 varun.gupt 893
		} catch (TransactionServiceException e) {
4715 varun.gupt 894
			logger.error("TransactionServiceException " + e);
4600 varun.gupt 895
		}
896
	}
897
 
898
	public List<Vendor> getAllVendors()	{
899
		return this.vendors;
900
	}
901
 
902
	private String getValueForEmptyString(String s){
903
		if(s==null || s.equals(""))
904
			return "-";
905
		else
906
			return s; 
907
	}
908
 
909
	private String getVendorName(long vendorId)	{
910
		for (Vendor vendor: vendors)	{
911
			if (vendor.getId() == vendorId)	return vendor.getName();
912
		}
913
		return null;
914
	}
915
 
916
	public String getReportSource()	{
917
		return reportSource;
918
	}
919
 
920
	public void setReportSource(String reportSource)	{
921
		this.reportSource = reportSource;
922
	}
923
 
924
    public File getHdfcSettlementReport() {
925
        return hdfcSettlementReport;
926
    }
927
 
928
    public void setHdfcSettlementReport(File hdfcSettlementReport) {
929
        this.hdfcSettlementReport = hdfcSettlementReport;
930
    }
931
 
932
    public File getEbsSettlementSummary()	{
933
    	return ebsSettlementSummary;
934
    }
935
 
936
    public void setEbsSettlementSummary(File ebsSettlementSummary)	{
937
    	this.ebsSettlementSummary = ebsSettlementSummary;
938
    }
939
 
940
    public File getEbsSettlementReport()	{
941
    	return ebsSettlementReport;
942
    }
943
 
944
    public void setEbsSettlementReport(File ebsSettlementReport)	{
945
    	this.ebsSettlementReport = ebsSettlementReport;
946
    }
947
 
948
    public String getBluedartSettlementDate()	{
949
    	return bluedartSettlementDate;
950
    }
951
 
952
    public void setBluedartSettlementDate(String bluedartSettlementDate)	{
953
    	this.bluedartSettlementDate = bluedartSettlementDate;
954
    }
955
 
956
    public File getBluedartSettlementReport()	{
957
    	return bluedartSettlementReport;
958
    }
959
 
960
    public void setBluedartSettlementReport(File bluedartSettlementReport)	{
961
    	this.bluedartSettlementReport = bluedartSettlementReport;
962
    }
963
 
4715 varun.gupt 964
    public String getAramexSettlementDate()	{
965
    	return this.aramexSettlementDate;
966
    }
967
 
968
    public void setAramexSettlementDate(String aramexSettlementDate)	{
969
    	this.aramexSettlementDate = aramexSettlementDate;
970
    }
971
 
972
    public void setAramexSettlementReport(File aramexSettlementReport) {
973
		this.aramexSettlementReport = aramexSettlementReport;
974
	}
975
 
976
	public File getAramexSettlementReport() {
977
		return aramexSettlementReport;
978
	}
979
 
4600 varun.gupt 980
	@Override
4715 varun.gupt 981
     public void setServletContext(ServletContext context) {
4600 varun.gupt 982
        this.context = context;
983
    }
984
 
985
    public String getServletContextPath() {
986
        return context.getContextPath();
987
    }
988
 
989
	@Override
990
	public void setServletResponse(HttpServletResponse response) {
991
		this.response = response;
992
	}
993
 
994
	@Override
995
	public void setServletRequest(HttpServletRequest request) {
996
		this.request = request;
997
		this.session = request.getSession();
998
	}
999
 
1000
	public Map<Long, String> getEBSSettlementSummaries()	{
1001
		return ebsSettlementSummaries;
1002
	}
1003
}