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