| Line 1... |
Line 1... |
| 1 |
package in.shop2020.support.controllers;
|
1 |
package in.shop2020.support.controllers;
|
| 2 |
|
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;
|
- |
|
| 11 |
import java.util.ArrayList;
|
- |
|
| 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.logistics.LogisticsServiceException;
|
3 |
import in.shop2020.logistics.LogisticsServiceException;
|
| 18 |
import in.shop2020.logistics.Provider;
|
4 |
import in.shop2020.logistics.Provider;
|
| 19 |
import in.shop2020.model.v1.catalog.InventoryService.Client;
|
5 |
import in.shop2020.model.v1.catalog.InventoryService.Client;
|
| 20 |
import in.shop2020.model.v1.catalog.Vendor;
|
6 |
import in.shop2020.model.v1.catalog.Vendor;
|
| 21 |
import in.shop2020.model.v1.order.LineItem;
|
7 |
import in.shop2020.model.v1.order.LineItem;
|
| 22 |
import in.shop2020.model.v1.order.Order;
|
8 |
import in.shop2020.model.v1.order.Order;
|
| 23 |
import in.shop2020.model.v1.order.OrderStatus;
|
9 |
import in.shop2020.model.v1.order.OrderStatus;
|
| - |
|
10 |
import in.shop2020.model.v1.order.OrderStatusGroups;
|
| 24 |
import in.shop2020.model.v1.order.PaymentSettlement;
|
11 |
import in.shop2020.model.v1.order.PaymentSettlement;
|
| 25 |
import in.shop2020.model.v1.order.Transaction;
|
12 |
import in.shop2020.model.v1.order.Transaction;
|
| 26 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
13 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 27 |
import in.shop2020.payments.Payment;
|
14 |
import in.shop2020.payments.Payment;
|
| 28 |
import in.shop2020.payments.PaymentException;
|
15 |
import in.shop2020.payments.PaymentException;
|
| Line 30... |
Line 17... |
| 30 |
import in.shop2020.thrift.clients.CatalogClient;
|
17 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 31 |
import in.shop2020.thrift.clients.LogisticsClient;
|
18 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 32 |
import in.shop2020.thrift.clients.PaymentClient;
|
19 |
import in.shop2020.thrift.clients.PaymentClient;
|
| 33 |
import in.shop2020.thrift.clients.TransactionClient;
|
20 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 34 |
|
21 |
|
| - |
|
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 |
|
| 35 |
import javax.servlet.ServletContext;
|
36 |
import javax.servlet.ServletContext;
|
| 36 |
import javax.servlet.ServletOutputStream;
|
37 |
import javax.servlet.ServletOutputStream;
|
| 37 |
import javax.servlet.http.HttpServletRequest;
|
38 |
import javax.servlet.http.HttpServletRequest;
|
| 38 |
import javax.servlet.http.HttpServletResponse;
|
39 |
import javax.servlet.http.HttpServletResponse;
|
| 39 |
import javax.servlet.http.HttpSession;
|
40 |
import javax.servlet.http.HttpSession;
|
| Line 44... |
Line 45... |
| 44 |
import org.apache.poi.ss.usermodel.Font;
|
45 |
import org.apache.poi.ss.usermodel.Font;
|
| 45 |
import org.apache.poi.ss.usermodel.Row;
|
46 |
import org.apache.poi.ss.usermodel.Row;
|
| 46 |
import org.apache.poi.ss.usermodel.Sheet;
|
47 |
import org.apache.poi.ss.usermodel.Sheet;
|
| 47 |
import org.apache.poi.ss.usermodel.Workbook;
|
48 |
import org.apache.poi.ss.usermodel.Workbook;
|
| 48 |
import org.apache.poi.ss.util.CellRangeAddress;
|
49 |
import org.apache.poi.ss.util.CellRangeAddress;
|
| 49 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
- |
|
| 50 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
- |
|
| 51 |
import org.apache.struts2.convention.annotation.Result;
|
50 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| 52 |
import org.apache.struts2.convention.annotation.Results;
|
- |
|
| 53 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
51 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
| 54 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
52 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
| 55 |
import org.apache.struts2.rest.DefaultHttpHeaders;
|
53 |
import org.apache.struts2.rest.DefaultHttpHeaders;
|
| 56 |
import org.apache.struts2.rest.HttpHeaders;
|
54 |
import org.apache.struts2.rest.HttpHeaders;
|
| 57 |
import org.apache.struts2.util.ServletContextAware;
|
55 |
import org.apache.struts2.util.ServletContextAware;
|
| Line 96... |
Line 94... |
| 96 |
QUANTITY(11),
|
94 |
QUANTITY(11),
|
| 97 |
UNIT_TRANSFER_PRICE(12),
|
95 |
UNIT_TRANSFER_PRICE(12),
|
| 98 |
UNIT_SELLING_PRICE(13),
|
96 |
UNIT_SELLING_PRICE(13),
|
| 99 |
TOTAL_TRANSFER_PRICE(14),
|
97 |
TOTAL_TRANSFER_PRICE(14),
|
| 100 |
TOTAL_SELLING_PRICE(15),
|
98 |
TOTAL_SELLING_PRICE(15),
|
| 101 |
GATEWAY_TRANSACTION_ID(16),
|
- |
|
| 102 |
PAYMENT_TYPE(17),
|
99 |
PAYMENT_TYPE(16),
|
| 103 |
PAYMENT_ID(18),
|
100 |
PAYMENT_ID(17),
|
| 104 |
COUPON_CODE(19),
|
101 |
COUPON_CODE(18),
|
| 105 |
SERVICE_TAX(20),
|
102 |
SERVICE_TAX(19),
|
| 106 |
OTHER_CHARGES(21),
|
103 |
OTHER_CHARGES(20),
|
| 107 |
NET_COLLECTION(22),
|
104 |
NET_COLLECTION(21),
|
| 108 |
REFUND(23),
|
105 |
REFUND(22),
|
| 109 |
FINAL_AMOUNT(24),
|
106 |
FINAL_AMOUNT(23),
|
| 110 |
IS_RESHIPED_ORDER(25);
|
107 |
IS_RESHIPED_ORDER(24);
|
| 111 |
// COUPON_CATEGORY(19),
|
108 |
// COUPON_CATEGORY(19),
|
| 112 |
// DISCOUNT(20),
|
109 |
// DISCOUNT(20),
|
| 113 |
|
110 |
|
| 114 |
private int value;
|
111 |
private int value;
|
| 115 |
|
112 |
|
| Line 139... |
Line 136... |
| 139 |
private HttpServletRequest request;
|
136 |
private HttpServletRequest request;
|
| 140 |
private HttpServletResponse response;
|
137 |
private HttpServletResponse response;
|
| 141 |
private ServletContext context;
|
138 |
private ServletContext context;
|
| 142 |
private HttpSession session;
|
139 |
private HttpSession session;
|
| 143 |
private List<Vendor> vendors;
|
140 |
private List<Vendor> vendors;
|
| - |
|
141 |
private Map<Long, String> codProviders = new HashMap<Long, String>();
|
| - |
|
142 |
private Map<Long, String> paymentGateways = new HashMap<Long, String>();
|
| - |
|
143 |
|
| 144 |
private String reportSource;
|
144 |
private String reportSource;
|
| 145 |
private List<Long> orderIdsWithoutSuccess;
|
145 |
private List<Long> orderIdsWithoutSuccess;
|
| 146 |
|
146 |
|
| 147 |
private File hdfcSettlementReport;
|
147 |
private File hdfcSettlementReport;
|
| 148 |
|
148 |
|
| Line 156... |
Line 156... |
| 156 |
private File aramexSettlementReport;
|
156 |
private File aramexSettlementReport;
|
| 157 |
|
157 |
|
| 158 |
private Map<Long, Map<String, Double>> misMatches = new HashMap<Long, Map<String, Double>>();
|
158 |
private Map<Long, Map<String, Double>> misMatches = new HashMap<Long, Map<String, Double>>();
|
| 159 |
private Map<Long, String> ebsSettlementSummaries;
|
159 |
private Map<Long, String> ebsSettlementSummaries;
|
| 160 |
|
160 |
|
| 161 |
private List<OrderStatus> refundOrderStatuses = new ArrayList<OrderStatus>();
|
161 |
private List<OrderStatus> refundOrderStatuses;
|
| 162 |
|
162 |
|
| 163 |
private List<Order> refundedOrdersBilledinDateRange = new ArrayList<Order>();
|
163 |
private List<Order> refundedOrdersBilledinDateRange = new ArrayList<Order>();
|
| 164 |
private List<Order> reshippedOrders = new ArrayList<Order>();
|
164 |
private List<Order> reshippedOrders = new ArrayList<Order>();
|
| 165 |
|
165 |
|
| - |
|
166 |
private Map<Long, PaymentSettlement> paymentSettlementsMap;
|
| - |
|
167 |
|
| 166 |
private final DateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy");
|
168 |
private final DateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy");
|
| 167 |
|
169 |
|
| - |
|
170 |
private int rowCount = 0;
|
| - |
|
171 |
|
| 168 |
public VendorReconciliationController() {
|
172 |
public VendorReconciliationController() {
|
| 169 |
try {
|
173 |
try {
|
| 170 |
CatalogClient csc = new CatalogClient();
|
174 |
CatalogClient csc = new CatalogClient();
|
| 171 |
Client catalogClient = csc.getClient();
|
175 |
Client catalogClient = csc.getClient();
|
| - |
|
176 |
OrderStatusGroups orderStatusGroups = new OrderStatusGroups();
|
| - |
|
177 |
refundOrderStatuses = orderStatusGroups.getRefundedOrders();
|
| 172 |
|
178 |
|
| 173 |
vendors = catalogClient.getAllVendors();
|
179 |
vendors = catalogClient.getAllVendors();
|
| 174 |
orderIdsWithoutSuccess = new ArrayList<Long>();
|
180 |
orderIdsWithoutSuccess = new ArrayList<Long>();
|
| 175 |
|
181 |
|
| 176 |
TransactionClient tsc = new TransactionClient();
|
182 |
TransactionClient tsc = new TransactionClient();
|
| Line 216... |
Line 222... |
| 216 |
return new DefaultHttpHeaders("report");
|
222 |
return new DefaultHttpHeaders("report");
|
| 217 |
}
|
223 |
}
|
| 218 |
|
224 |
|
| 219 |
public HttpHeaders generateReconciliationReport() {
|
225 |
public HttpHeaders generateReconciliationReport() {
|
| 220 |
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
226 |
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
| 221 |
|
- |
|
| 222 |
refundOrderStatuses.add(OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST);
|
- |
|
| 223 |
refundOrderStatuses.add(OrderStatus.RTO_REFUNDED);
|
- |
|
| 224 |
refundOrderStatuses.add(OrderStatus.DOA_VALID_REFUNDED);
|
- |
|
| 225 |
refundOrderStatuses.add(OrderStatus.DOA_INVALID_REFUNDED);
|
- |
|
| 226 |
refundOrderStatuses.add(OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
- |
|
| 227 |
refundOrderStatuses.add(OrderStatus.DOA_REFUNDED_RCVD_DAMAGED);
|
- |
|
| 228 |
refundOrderStatuses.add(OrderStatus.DOA_REFUNDED_LOST_IN_TRANSIT);
|
- |
|
| 229 |
refundOrderStatuses.add(OrderStatus.RTO_DAMAGED_REFUNDED);
|
- |
|
| 230 |
refundOrderStatuses.add(OrderStatus.RTO_LOST_IN_TRANSIT_REFUNDED);
|
- |
|
| 231 |
refundOrderStatuses.add(OrderStatus.RET_PRODUCT_USABLE_REFUNDED);
|
- |
|
| 232 |
refundOrderStatuses.add(OrderStatus.RET_PRODUCT_UNUSABLE_REFUNDED);
|
- |
|
| 233 |
refundOrderStatuses.add(OrderStatus.RET_REFUNDED_LOST_IN_TRANSIT);
|
- |
|
| 234 |
refundOrderStatuses.add(OrderStatus.RET_REFUNDED_RCVD_DAMAGED);
|
- |
|
| 235 |
refundOrderStatuses.add(OrderStatus.LOST_IN_TRANSIT_REFUNDED);
|
- |
|
| 236 |
|
227 |
|
| 237 |
try {
|
228 |
try {
|
| 238 |
//Formatting Form input parameters
|
229 |
//Formatting Form input parameters
|
| 239 |
|
230 |
|
| 240 |
Date startDate = dateFormat.parse(request.getParameter("start"));
|
231 |
// Date startDate = dateFormat.parse(request.getParameter("start"));
|
| 241 |
Date endDate = dateFormat.parse(request.getParameter("end"));
|
232 |
// Date endDate = dateFormat.parse(request.getParameter("end"));
|
| 242 |
long vendorId = Long.parseLong(request.getParameter("vendor"));
|
233 |
long vendorId = Long.parseLong(request.getParameter("vendor"));
|
| 243 |
|
234 |
|
| 244 |
logger.info(startDate + " " + endDate + " " + vendorId);
|
235 |
logger.info("Vendor ID: " + vendorId);
|
| 245 |
|
236 |
|
| 246 |
String vendorName = getVendorName(vendorId);
|
237 |
String vendorName = getVendorName(vendorId);
|
| 247 |
DateFormat dateFormatForFile = new SimpleDateFormat("dd.MM.yyyy");
|
238 |
DateFormat dateFormatForFile = new SimpleDateFormat("dd.MM.yyyy");
|
| 248 |
|
239 |
|
| 249 |
response.setContentType("application/vnd.ms-excel");
|
240 |
response.setContentType("application/vnd.ms-excel");
|
| 250 |
response.setHeader("Content-disposition", "inline; filename=" + vendorName + "-reconciliation-from-" + dateFormatForFile.format(startDate) + "-" + dateFormatForFile.format(endDate) + ".xls");
|
241 |
response.setHeader("Content-disposition", "inline; filename=" + vendorName + "-reconciliation.xls");
|
| 251 |
|
242 |
|
| 252 |
ServletOutputStream sos;
|
243 |
ServletOutputStream sos;
|
| 253 |
try {
|
244 |
try {
|
| 254 |
ByteArrayOutputStream baos = getReconciliationReport(vendorId, startDate, endDate);
|
245 |
ByteArrayOutputStream baos = getReconciliationReport(vendorId);
|
| 255 |
sos = response.getOutputStream();
|
246 |
sos = response.getOutputStream();
|
| 256 |
baos.writeTo(sos);
|
247 |
baos.writeTo(sos);
|
| 257 |
sos.flush();
|
248 |
sos.flush();
|
| 258 |
} catch (IOException e) {
|
249 |
} catch (IOException e) {
|
| 259 |
logger.error("Error while streaming the hotspot reconciliation report", e);
|
250 |
logger.error("Error while streaming the hotspot reconciliation report", e);
|
| 260 |
}
|
251 |
}
|
| 261 |
} catch (ParseException e) {
|
- |
|
| 262 |
logger.error("Unable to parse the start or end date", e);
|
- |
|
| 263 |
} catch (NullPointerException e) {
|
252 |
} catch (NullPointerException e) {
|
| 264 |
logger.error("NullPointerException", e);
|
253 |
logger.error("NullPointerException", e);
|
| 265 |
}
|
254 |
}
|
| 266 |
return new DefaultHttpHeaders("report");
|
255 |
return new DefaultHttpHeaders("report");
|
| 267 |
}
|
256 |
}
|
| Line 290... |
Line 279... |
| 290 |
Row firstRow = sheet.getRow(0);
|
279 |
Row firstRow = sheet.getRow(0);
|
| 291 |
Row secondRow = sheet.getRow(1);
|
280 |
Row secondRow = sheet.getRow(1);
|
| 292 |
Row thirdRow = sheet.getRow(2);
|
281 |
Row thirdRow = sheet.getRow(2);
|
| 293 |
Row fourthRow = sheet.getRow(3);
|
282 |
Row fourthRow = sheet.getRow(3);
|
| 294 |
Row fifthRow = sheet.getRow(4);
|
283 |
Row fifthRow = sheet.getRow(4);
|
| 295 |
|
284 |
|
| 296 |
TransactionClient tsc;
|
285 |
TransactionClient tsc;
|
| 297 |
|
286 |
|
| 298 |
try {
|
287 |
try {
|
| 299 |
tsc = new TransactionClient();
|
288 |
tsc = new TransactionClient();
|
| 300 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
289 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
| Line 355... |
Line 344... |
| 355 |
int indexNetCollection = 17;
|
344 |
int indexNetCollection = 17;
|
| 356 |
|
345 |
|
| 357 |
TransactionClient tsc;
|
346 |
TransactionClient tsc;
|
| 358 |
String paymentIdStr = "";
|
347 |
String paymentIdStr = "";
|
| 359 |
long paymentId = 0;
|
348 |
long paymentId = 0;
|
| 360 |
|
349 |
|
| 361 |
int countSuccessfulInserts = 0;
|
350 |
int countSuccessfulInserts = 0;
|
| 362 |
int countRefunds = 0;
|
351 |
int countRefunds = 0;
|
| 363 |
|
352 |
|
| 364 |
try {
|
353 |
try {
|
| 365 |
tsc = new TransactionClient();
|
354 |
tsc = new TransactionClient();
|
| 366 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
355 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
| 367 |
|
356 |
|
| 368 |
for (Row row: sheet) {
|
357 |
for (Row row: sheet) {
|
| 369 |
if(row.equals(firstRow)) continue;
|
358 |
if(row.equals(firstRow)) continue;
|
| 370 |
|
359 |
|
| - |
|
360 |
if(row.getCell(0).getStringCellValue().equals("Total")) break;
|
| - |
|
361 |
|
| 371 |
try {
|
362 |
try {
|
| 372 |
String recfmt = row.getCell(indexRECFMT).getStringCellValue();
|
363 |
String recfmt = row.getCell(indexRECFMT).getStringCellValue();
|
| 373 |
Date settlementDate = row.getCell(indexSettlementDate).getDateCellValue();
|
364 |
Date settlementDate = row.getCell(indexSettlementDate).getDateCellValue();
|
| 374 |
double netCollection = row.getCell(indexNetCollection).getNumericCellValue();
|
365 |
double netCollection = row.getCell(indexNetCollection).getNumericCellValue();
|
| 375 |
paymentIdStr = row.getCell(indexPaymentId).getStringCellValue().replace("'", "");
|
366 |
paymentIdStr = row.getCell(indexPaymentId).getStringCellValue().replace("'", "").trim();
|
| 376 |
paymentId = Long.parseLong(paymentIdStr);
|
367 |
paymentId = Long.parseLong(paymentIdStr);
|
| 377 |
|
368 |
|
| 378 |
logger.info("paymentId: " + paymentId + ", recfmt: " + recfmt + ", settlementDate: " + settlementDate + ", netCollection: " + netCollection);
|
369 |
logger.info("paymentId: " + paymentId + ", recfmt: " + recfmt + ", settlementDate: " + settlementDate + ", netCollection: " + netCollection);
|
| 379 |
|
370 |
|
| 380 |
if (recfmt.trim().equalsIgnoreCase("CVD")) {
|
371 |
if (recfmt.trim().equalsIgnoreCase("CVD")) {
|
| 381 |
if (netCollection > 0.0) netCollection *= -1.0;
|
372 |
if (netCollection > 0.0) netCollection *= -1.0;
|
| 382 |
transactionClient.savePaymentSettlements(settlementDate.getTime(), 1, paymentId, 0.0, 0.0, netCollection);
|
373 |
transactionClient.savePaymentSettlements(settlementDate.getTime(), 1, paymentId, 0.0, 0.0, netCollection);
|
| 383 |
countRefunds += 1;
|
374 |
countRefunds += 1;
|
| 384 |
|
375 |
|
| 385 |
} else {
|
376 |
} else {
|
| 386 |
double msf = row.getCell(indexMSF).getNumericCellValue();
|
377 |
double msf = row.getCell(indexMSF).getNumericCellValue();
|
| 387 |
double serviceTax = row.getCell(indexServiceTax).getNumericCellValue();
|
378 |
double serviceTax = row.getCell(indexServiceTax).getNumericCellValue();
|
| 388 |
double eduCess = row.getCell(indexEduCess).getNumericCellValue();
|
379 |
double eduCess = row.getCell(indexEduCess).getNumericCellValue();
|
| 389 |
logger.info("msf: " + msf + ", serviceTax: " + serviceTax + ", eduCess: " + eduCess);
|
380 |
logger.info("msf: " + msf + ", serviceTax: " + serviceTax + ", eduCess: " + eduCess);
|
| Line 547... |
Line 538... |
| 547 |
Sheet sheet = wb.getSheetAt(0);
|
538 |
Sheet sheet = wb.getSheetAt(0);
|
| 548 |
|
539 |
|
| 549 |
Row firstRow = sheet.getRow(0);
|
540 |
Row firstRow = sheet.getRow(0);
|
| 550 |
logger.info("Cell count:" + firstRow.getPhysicalNumberOfCells());
|
541 |
logger.info("Cell count:" + firstRow.getPhysicalNumberOfCells());
|
| 551 |
|
542 |
|
| 552 |
int indexOrderId = 0;
|
543 |
int indexOrderId = 16;
|
| 553 |
int indexAmount = 1;
|
544 |
int indexAmount = 17;
|
| 554 |
|
545 |
|
| 555 |
TransactionClient tsc;
|
546 |
TransactionClient tsc;
|
| 556 |
int countSuccessfulSaves = 0;
|
547 |
int countSuccessfulSaves = 0;
|
| 557 |
|
548 |
|
| 558 |
try {
|
549 |
try {
|
| Line 562... |
Line 553... |
| 562 |
|
553 |
|
| 563 |
for (Row row : sheet) {
|
554 |
for (Row row : sheet) {
|
| 564 |
long orderId = 0;
|
555 |
long orderId = 0;
|
| 565 |
try {
|
556 |
try {
|
| 566 |
if(row.equals(firstRow)) continue;
|
557 |
if(row.equals(firstRow)) continue;
|
| 567 |
orderId = (long) row.getCell(indexOrderId).getNumericCellValue();
|
558 |
orderId = Long.parseLong(row.getCell(indexOrderId).getStringCellValue());
|
| 568 |
|
559 |
|
| 569 |
double amount = row.getCell(indexAmount).getNumericCellValue();
|
560 |
double amount = row.getCell(indexAmount).getNumericCellValue();
|
| - |
|
561 |
logger.info("Bluedart SettlementDate: " + settlementDate + ", OrderId: " + orderId + ", Amount: " + amount);
|
| 570 |
transactionClient.savePaymentSettlements(settlementDate, 4, orderId, 0.0, 0.0, amount);
|
562 |
transactionClient.savePaymentSettlements(settlementDate, 4, orderId, 0.0, 0.0, amount);
|
| 571 |
logger.info("SettlementDate: " + settlementDate + ", OrderId: " + orderId + ", Amount: " + amount);
|
- |
|
| 572 |
countSuccessfulSaves += 1;
|
563 |
countSuccessfulSaves += 1;
|
| 573 |
|
564 |
|
| 574 |
} catch (NullPointerException e) {
|
565 |
} catch (NullPointerException e) {
|
| 575 |
logger.error("For OrderId: " + orderId + " " + e);
|
566 |
logger.error("For OrderId: " + orderId + " " + e);
|
| 576 |
|
567 |
|
| Line 601... |
Line 592... |
| 601 |
return;
|
592 |
return;
|
| 602 |
}
|
593 |
}
|
| 603 |
|
594 |
|
| 604 |
Workbook wb = null;
|
595 |
Workbook wb = null;
|
| 605 |
try {
|
596 |
try {
|
| 606 |
wb = new HSSFWorkbook(new FileInputStream(this.aramexSettlementReport));
|
597 |
wb = new XSSFWorkbook(new FileInputStream(this.aramexSettlementReport));
|
| 607 |
} catch (FileNotFoundException e) {
|
598 |
} catch (FileNotFoundException e) {
|
| 608 |
addActionError(e.getMessage());
|
599 |
addActionError(e.getMessage());
|
| 609 |
logger.error("Unable to open the Settlement report", e);
|
600 |
logger.error("Unable to open the Settlement report", e);
|
| 610 |
} catch (IOException e) {
|
601 |
} catch (IOException e) {
|
| 611 |
addActionError(e.getMessage());
|
602 |
addActionError(e.getMessage());
|
| Line 616... |
Line 607... |
| 616 |
return;
|
607 |
return;
|
| 617 |
}
|
608 |
}
|
| 618 |
|
609 |
|
| 619 |
Sheet sheet = wb.getSheetAt(0);
|
610 |
Sheet sheet = wb.getSheetAt(0);
|
| 620 |
|
611 |
|
| 621 |
int indexOrderId = 0;
|
612 |
int indexOrderId = 7;
|
| 622 |
int indexAmount = 1;
|
613 |
int indexAmount = 1;
|
| 623 |
|
614 |
|
| 624 |
Row firstRow = sheet.getRow(0);
|
615 |
Row firstRow = sheet.getRow(0);
|
| 625 |
logger.info("Cell count:" + firstRow.getPhysicalNumberOfCells());
|
616 |
logger.info("Cell count:" + firstRow.getPhysicalNumberOfCells());
|
| 626 |
|
617 |
|
| Line 633... |
Line 624... |
| 633 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
624 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
| 634 |
|
625 |
|
| 635 |
for (Row row: sheet) {
|
626 |
for (Row row: sheet) {
|
| 636 |
if(row.equals(firstRow)) continue;
|
627 |
if(row.equals(firstRow)) continue;
|
| 637 |
|
628 |
|
| 638 |
long orderId = (long) row.getCell(indexOrderId).getNumericCellValue();
|
629 |
if(row.getCell(indexOrderId).getStringCellValue().equals("")) break;
|
| 639 |
double amount = row.getCell(indexAmount).getNumericCellValue();
|
- |
|
| 640 |
|
630 |
|
| - |
|
631 |
long orderId = Long.parseLong(row.getCell(indexOrderId).getStringCellValue());
|
| - |
|
632 |
double amount = row.getCell(indexAmount).getNumericCellValue();
|
| - |
|
633 |
logger.info("Aramex Settlement, Order Id: " + orderId + " Amount: " + amount);
|
| 641 |
try {
|
634 |
try {
|
| 642 |
transactionClient.savePaymentSettlements(settlementDate, 4, orderId, 0.0, 0.0, amount);
|
635 |
transactionClient.savePaymentSettlements(settlementDate, 4, orderId, 0.0, 0.0, amount);
|
| 643 |
countSuccessfulSaves += 1;
|
636 |
countSuccessfulSaves += 1;
|
| 644 |
|
637 |
|
| 645 |
} catch (TransactionServiceException e) {
|
638 |
} catch (TransactionServiceException e) {
|
| Line 661... |
Line 654... |
| 661 |
}
|
654 |
}
|
| 662 |
addActionMessage("Successfully added Aramex settlement details for " + countSuccessfulSaves + " orders");
|
655 |
addActionMessage("Successfully added Aramex settlement details for " + countSuccessfulSaves + " orders");
|
| 663 |
}
|
656 |
}
|
| 664 |
|
657 |
|
| 665 |
// Prepares the XLS worksheet object and fills in the data with proper formatting
|
658 |
// Prepares the XLS worksheet object and fills in the data with proper formatting
|
| 666 |
private ByteArrayOutputStream getReconciliationReport(long vendorId, Date startDate, Date endDate) {
|
659 |
private ByteArrayOutputStream getReconciliationReport(long vendorId) {
|
| 667 |
|
660 |
|
| 668 |
List<Order> billedOrders = null;
|
661 |
List<PaymentSettlement> paymentSettlements = new ArrayList<PaymentSettlement>();
|
| 669 |
List<Order> settledOrders = null;
|
662 |
List<PaymentSettlement> refundPaymentSettlements = new ArrayList<PaymentSettlement>();
|
| 670 |
|
663 |
|
| 671 |
try {
|
664 |
try {
|
| 672 |
TransactionClient tsc = new TransactionClient();
|
665 |
TransactionClient tsc = new TransactionClient();
|
| 673 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
666 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
| 674 |
|
- |
|
| 675 |
PaymentClient psc = new PaymentClient();
|
- |
|
| 676 |
in.shop2020.payments.PaymentService.Client paymentClient = psc.getClient();
|
- |
|
| 677 |
|
- |
|
| 678 |
billedOrders = transactionClient.getBilledOrdersForVendor(vendorId, startDate.getTime(), endDate.getTime());
|
- |
|
| 679 |
logger.info("Billed Orders count: " + billedOrders.size());
|
- |
|
| 680 |
|
667 |
|
| 681 |
List<PaymentSettlement> paymentSettlements = transactionClient.getSettlementsByDate(startDate.getTime(), endDate.getTime(), false);
|
668 |
paymentSettlements = transactionClient.getSettlementsByDate(0, (new Date()).getTime(), false);
|
| 682 |
logger.info("Settlement Count: " + paymentSettlements.size());
|
669 |
logger.info("Settlement Count: " + paymentSettlements.size());
|
| 683 |
|
670 |
|
| - |
|
671 |
refundPaymentSettlements = transactionClient.getSettlementsByDate(0, (new Date()).getTime(), true);
|
| 684 |
settledOrders = new ArrayList<Order>();
|
672 |
logger.info("Refund Settlement Count: " + refundPaymentSettlements.size());
|
| 685 |
|
673 |
|
| 686 |
for (PaymentSettlement paymentSettlement: paymentSettlements) {
|
- |
|
| 687 |
Payment payment = paymentClient.getPayment(paymentSettlement.getReferenceId());
|
- |
|
| 688 |
Transaction txn = transactionClient.getTransaction(payment.getMerchantTxnId());
|
- |
|
| 689 |
settledOrders.addAll(txn.getOrders());
|
- |
|
| 690 |
}
|
- |
|
| 691 |
logger.info("Settled Orders count: " + settledOrders.size());
|
- |
|
| 692 |
|
- |
|
| 693 |
} catch (TransactionServiceException e) {
|
674 |
} catch (TransactionServiceException e) {
|
| 694 |
String errMsg = "Transaction Service Exception occured";
|
675 |
String errMsg = "Transaction Service Exception occured";
|
| 695 |
logger.error(errMsg, e);
|
676 |
logger.error(errMsg, e);
|
| 696 |
addActionError(errMsg);
|
677 |
addActionError(errMsg);
|
| 697 |
} catch (TTransportException e) {
|
678 |
} catch (TTransportException e) {
|
| Line 701... |
Line 682... |
| 701 |
} catch (TException e) {
|
682 |
} catch (TException e) {
|
| 702 |
// TODO Auto-generated
|
683 |
// TODO Auto-generated
|
| 703 |
String errMsg = "Transaction Service Exception occured";
|
684 |
String errMsg = "Transaction Service Exception occured";
|
| 704 |
logger.error(errMsg, e);
|
685 |
logger.error(errMsg, e);
|
| 705 |
addActionError(errMsg);
|
686 |
addActionError(errMsg);
|
| 706 |
|
- |
|
| 707 |
} catch (PaymentException e) {
|
- |
|
| 708 |
String errMsg = "Transaction Service Exception occured";
|
- |
|
| 709 |
logger.error(errMsg, e);
|
- |
|
| 710 |
addActionError(errMsg);
|
- |
|
| 711 |
}
|
- |
|
| 712 |
|
- |
|
| 713 |
List<Order> settledOrdersForVendor = new ArrayList<Order>();
|
- |
|
| 714 |
|
- |
|
| 715 |
for (Order order: settledOrders) {
|
- |
|
| 716 |
if(order.getVendorId() == vendorId) {
|
- |
|
| 717 |
settledOrdersForVendor.add(order);
|
- |
|
| 718 |
}
|
- |
|
| 719 |
}
|
687 |
}
|
| 720 |
logger.info("Settled Order count for Vendor: " + settledOrdersForVendor.size());
|
- |
|
| 721 |
|
688 |
|
| 722 |
ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
|
689 |
ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
|
| 723 |
|
690 |
|
| 724 |
Workbook wb = new HSSFWorkbook();
|
691 |
Workbook wb = new HSSFWorkbook();
|
| 725 |
|
692 |
|
| Line 734... |
Line 701... |
| 734 |
|
701 |
|
| 735 |
Sheet orderSheet = wb.createSheet("Orders");
|
702 |
Sheet orderSheet = wb.createSheet("Orders");
|
| 736 |
Sheet reshippedOrderSheet = wb.createSheet("Reshipped");
|
703 |
Sheet reshippedOrderSheet = wb.createSheet("Reshipped");
|
| 737 |
Sheet mismatchSheet = wb.createSheet("Mismatches");
|
704 |
Sheet mismatchSheet = wb.createSheet("Mismatches");
|
| 738 |
|
705 |
|
| 739 |
populateOrderSheet(settledOrdersForVendor, startDate, endDate, orderSheet, boldStyle, rightAlignStyle);
|
706 |
populateOrderSheet(paymentSettlements, refundPaymentSettlements, vendorId, orderSheet, boldStyle, rightAlignStyle);
|
| 740 |
populateReshippedOrderSheet(reshippedOrders, reshippedOrderSheet);
|
707 |
// populateReshippedOrderSheet(reshippedOrders, reshippedOrderSheet);
|
| 741 |
populateMismatchSheet(mismatchSheet);
|
708 |
// populateMismatchSheet(mismatchSheet);
|
| 742 |
|
709 |
|
| 743 |
// Write the workbook to the output stream
|
710 |
// Write the workbook to the output stream
|
| 744 |
try {
|
711 |
try {
|
| 745 |
wb.write(baosXLS);
|
712 |
wb.write(baosXLS);
|
| 746 |
baosXLS.close();
|
713 |
baosXLS.close();
|
| Line 799... |
Line 766... |
| 799 |
headerRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue("Unit Transfer Price");
|
766 |
headerRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue("Unit Transfer Price");
|
| 800 |
headerRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue("Unit Selling Price");
|
767 |
headerRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue("Unit Selling Price");
|
| 801 |
headerRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue("Total Transfer Price");
|
768 |
headerRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue("Total Transfer Price");
|
| 802 |
headerRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue("Total Selling Price");
|
769 |
headerRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue("Total Selling Price");
|
| 803 |
headerRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue("Current Status");
|
770 |
headerRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue("Current Status");
|
| 804 |
headerRow.createCell(OrderReportColumn.GATEWAY_TRANSACTION_ID.getValue()).setCellValue("Gateway Transaction Id");
|
- |
|
| 805 |
headerRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue("Payment Type");
|
771 |
headerRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue("Payment Type");
|
| 806 |
headerRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue("Payment Status");
|
772 |
headerRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue("Payment Status");
|
| 807 |
headerRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue("Payment Id");
|
773 |
headerRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue("Payment Id");
|
| 808 |
headerRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue("Coupon Code");
|
774 |
headerRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue("Coupon Code");
|
| 809 |
// headerRow.createCell(OrderReportColumn.COUPON_CATEGORY.getValue()).setCellValue("Coupon Category");
|
775 |
// headerRow.createCell(OrderReportColumn.COUPON_CATEGORY.getValue()).setCellValue("Coupon Category");
|
| Line 914... |
Line 880... |
| 914 |
contentRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue(paymentType);
|
880 |
contentRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue(paymentType);
|
| 915 |
}
|
881 |
}
|
| 916 |
|
882 |
|
| 917 |
if (payment != null) {
|
883 |
if (payment != null) {
|
| 918 |
contentRow.createCell(OrderReportColumn.SETTLEMENT_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(paymentSettlement.getSettlementDate())));
|
884 |
contentRow.createCell(OrderReportColumn.SETTLEMENT_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(paymentSettlement.getSettlementDate())));
|
| 919 |
contentRow.createCell(OrderReportColumn.GATEWAY_TRANSACTION_ID.getValue()).setCellValue(payment.getGatewayTxnId());
|
- |
|
| 920 |
contentRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue(payment.getStatus().name());
|
885 |
contentRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue(payment.getStatus().name());
|
| 921 |
contentRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue(payment.getPaymentId());
|
886 |
contentRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue(payment.getPaymentId());
|
| 922 |
}
|
887 |
}
|
| 923 |
contentRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue(txn.getCoupon_code());
|
888 |
contentRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue(txn.getCoupon_code());
|
| 924 |
contentRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue(serviceTax);
|
889 |
contentRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue(serviceTax);
|
| Line 943... |
Line 908... |
| 943 |
addActionError("Error loading list of COD providers");
|
908 |
addActionError("Error loading list of COD providers");
|
| 944 |
logger.error("Logistics Service Exception " + e);
|
909 |
logger.error("Logistics Service Exception " + e);
|
| 945 |
}
|
910 |
}
|
| 946 |
}
|
911 |
}
|
| 947 |
|
912 |
|
| 948 |
private void populateOrderSheet(List<Order> orders, Date startDate, Date endDate, Sheet sheet, CellStyle style, CellStyle rightAlignStyle) {
|
913 |
private void populateOrderSheet(List<PaymentSettlement> paymentSettlements, List<PaymentSettlement> refundSettlements, long vendorId, Sheet sheet, CellStyle style, CellStyle rightAlignStyle) {
|
| 949 |
short serialNo = 0;
|
- |
|
| 950 |
|
914 |
|
| 951 |
// Create the title row and put all the titles in it. Rows are 0 based.
|
915 |
// Create the title row and put all the titles in it. Rows are 0 based
|
| 952 |
Row titleRow = sheet.createRow(serialNo ++);
|
916 |
Row titleRow = sheet.createRow(rowCount ++);
|
| 953 |
Cell titleCell = titleRow.createCell(0);
|
917 |
Cell titleCell = titleRow.createCell(0);
|
| 954 |
titleCell.setCellValue("Order Reconciliation Report (" + DATE_FORMAT.format(startDate) + " - " + DATE_FORMAT.format(endDate) + ")");
|
918 |
titleCell.setCellValue("Order Reconciliation Report");
|
| 955 |
titleCell.setCellStyle(style);
|
919 |
titleCell.setCellStyle(style);
|
| 956 |
|
920 |
|
| 957 |
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
|
921 |
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 4));
|
| 958 |
|
922 |
|
| 959 |
sheet.createRow(serialNo ++);
|
923 |
sheet.createRow(rowCount ++);
|
| 960 |
|
924 |
|
| 961 |
Row headerRow = sheet.createRow(serialNo ++);
|
925 |
Row headerRow = sheet.createRow(rowCount ++);
|
| 962 |
headerRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue("Order Id");
|
926 |
headerRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue("Order Id");
|
| 963 |
headerRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue("Order Date");
|
927 |
headerRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue("Order Date");
|
| 964 |
headerRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue("Billing Number");
|
928 |
headerRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue("Billing Number");
|
| 965 |
headerRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue("Billing Date");
|
929 |
headerRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue("Billing Date");
|
| 966 |
headerRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue("Delivery Date");
|
930 |
headerRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue("Delivery Date");
|
| Line 973... |
Line 937... |
| 973 |
headerRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue("Unit Transfer Price");
|
937 |
headerRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue("Unit Transfer Price");
|
| 974 |
headerRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue("Unit Selling Price");
|
938 |
headerRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue("Unit Selling Price");
|
| 975 |
headerRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue("Total Transfer Price");
|
939 |
headerRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue("Total Transfer Price");
|
| 976 |
headerRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue("Total Selling Price");
|
940 |
headerRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue("Total Selling Price");
|
| 977 |
headerRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue("Current Status");
|
941 |
headerRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue("Current Status");
|
| 978 |
headerRow.createCell(OrderReportColumn.GATEWAY_TRANSACTION_ID.getValue()).setCellValue("Gateway Transaction Id");
|
- |
|
| 979 |
headerRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue("Payment Type");
|
942 |
headerRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue("Payment Type");
|
| 980 |
headerRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue("Payment Status");
|
943 |
headerRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue("Payment Status");
|
| 981 |
headerRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue("Payment Id");
|
944 |
headerRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue("Payment Id");
|
| 982 |
headerRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue("Coupon Code");
|
945 |
headerRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue("Coupon Code");
|
| 983 |
// headerRow.createCell(OrderReportColumn.COUPON_CATEGORY.getValue()).setCellValue("Coupon Category");
|
- |
|
| 984 |
// headerRow.createCell(OrderReportColumn.DISCOUNT.getValue()).setCellValue("Discount");
|
- |
|
| 985 |
headerRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue("Service Tax");
|
946 |
headerRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue("Service Tax");
|
| 986 |
headerRow.createCell(OrderReportColumn.OTHER_CHARGES.getValue()).setCellValue("Other Charges");
|
947 |
headerRow.createCell(OrderReportColumn.OTHER_CHARGES.getValue()).setCellValue("Other Charges");
|
| 987 |
headerRow.createCell(OrderReportColumn.NET_COLLECTION.getValue()).setCellValue("Net Collection");
|
948 |
headerRow.createCell(OrderReportColumn.NET_COLLECTION.getValue()).setCellValue("Net Collection");
|
| 988 |
headerRow.createCell(OrderReportColumn.REFUND.getValue()).setCellValue("Refund");
|
- |
|
| 989 |
headerRow.createCell(OrderReportColumn.FINAL_AMOUNT.getValue()).setCellValue("Final Amount");
|
- |
|
| 990 |
|
949 |
|
| 991 |
sheet.createRow(serialNo ++);
|
950 |
sheet.createRow(rowCount ++);
|
| 992 |
|
951 |
|
| 993 |
TransactionClient tsc;
|
952 |
TransactionClient tsc;
|
| 994 |
PaymentClient psc;
|
953 |
PaymentClient psc;
|
| 995 |
LogisticsClient lsc;
|
954 |
LogisticsClient lsc;
|
| 996 |
|
955 |
|
| 997 |
try {
|
956 |
try {
|
| 998 |
tsc = new TransactionClient();
|
957 |
tsc = new TransactionClient();
|
| 999 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
958 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
| 1000 |
|
959 |
|
| 1001 |
psc = new PaymentClient();
|
- |
|
| 1002 |
in.shop2020.payments.PaymentService.Client paymentClient = psc.getClient();
|
- |
|
| 1003 |
|
- |
|
| 1004 |
lsc = new LogisticsClient();
|
960 |
lsc = new LogisticsClient();
|
| 1005 |
in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
|
961 |
in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
|
| 1006 |
|
962 |
|
| 1007 |
Map<Long, String> codProviders = new HashMap<Long, String>();
|
963 |
psc = new PaymentClient();
|
| 1008 |
|
- |
|
| 1009 |
for (Provider provider: logisticsClient.getAllProviders()) {
|
- |
|
| 1010 |
codProviders.put(provider.getId(), provider.getName());
|
964 |
in.shop2020.payments.PaymentService.Client paymentClient = psc.getClient();
|
| 1011 |
}
|
- |
|
| 1012 |
|
965 |
|
| 1013 |
List<PaymentGateway> tPaymentGateways = paymentClient.getActivePaymentGateways();
|
966 |
List<PaymentGateway> tPaymentGateways = paymentClient.getActivePaymentGateways();
|
| 1014 |
Map<Long, String> paymentGateways = new HashMap<Long, String>();
|
- |
|
| 1015 |
|
967 |
|
| 1016 |
for (PaymentGateway tPaymentGateway: tPaymentGateways) {
|
968 |
for (PaymentGateway tPaymentGateway: tPaymentGateways) {
|
| 1017 |
paymentGateways.put(tPaymentGateway.getId(), tPaymentGateway.getName());
|
969 |
paymentGateways.put(tPaymentGateway.getId(), tPaymentGateway.getName());
|
| 1018 |
}
|
970 |
}
|
| 1019 |
|
971 |
|
| - |
|
972 |
for (Provider provider: logisticsClient.getAllProviders()) {
|
| 1020 |
List <Long> orderIds = new ArrayList<Long>();
|
973 |
codProviders.put(provider.getId(), provider.getName());
|
| - |
|
974 |
}
|
| - |
|
975 |
|
| 1021 |
Map<Long, List<Order>> orderMap = new HashMap<Long, List<Order>>();
|
976 |
for (PaymentSettlement paymentSettlement: paymentSettlements) {
|
| 1022 |
|
977 |
|
| 1023 |
int countMultipleOrderTxns = 0;
|
- |
|
| 1024 |
|
978 |
try {
|
| 1025 |
for(Order order : orders) {
|
979 |
if(paymentSettlement.getPaymentGatewayId() == 4) { // If COD
|
| 1026 |
if(order.getBilling_timestamp() == 0) {
|
980 |
Order order = transactionClient.getOrder(paymentSettlement.getReferenceId());
|
| 1027 |
continue;
|
981 |
Transaction txn = transactionClient.getTransaction(order.getTransactionId());
|
| 1028 |
}
|
- |
|
| 1029 |
orderIds.add(order.getId());
|
982 |
Payment payment = paymentClient.getPaymentForTxnId(txn.getId()).get(0);
|
| 1030 |
|
983 |
|
| 1031 |
if (orderMap.containsKey(order.getTransactionId())) {
|
984 |
if (order.getVendorId() == vendorId) {
|
| 1032 |
orderMap.get(order.getTransactionId()).add(order);
|
985 |
Row contentRow = sheet.createRow(rowCount ++);
|
| 1033 |
countMultipleOrderTxns += 1;
|
986 |
outputCODRow(contentRow, paymentSettlement, order, txn, payment);
|
| - |
|
987 |
}
|
| 1034 |
|
988 |
|
| 1035 |
} else {
|
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) {
|
| 1036 |
List<Order> o = new ArrayList<Order>();
|
996 |
logger.error("TransactionServiceException " + e);
|
| 1037 |
o.add(order);
|
997 |
} catch (TException e) {
|
| - |
|
998 |
logger.error("TException " + e);
|
| - |
|
999 |
} catch (PaymentException e) {
|
| 1038 |
orderMap.put(order.getTransactionId(), o);
|
1000 |
logger.error("PaymentException " + e);
|
| 1039 |
}
|
1001 |
}
|
| 1040 |
}
|
1002 |
}
|
| 1041 |
|
1003 |
|
| 1042 |
// Getting list of order ids belonging to reshipped orders
|
1004 |
rowCount ++;
|
| 1043 |
List<Long> reshippedOrderIds = transactionClient.getReshippedOrderIds(orderIds);
|
- |
|
| 1044 |
|
1005 |
|
| 1045 |
for(long txnId: orderMap.keySet()) {
|
1006 |
for (PaymentSettlement paymentSettlement: refundSettlements) {
|
| 1046 |
List<Order> orderList = orderMap.get(txnId);
|
- |
|
| 1047 |
|
1007 |
try {
|
| 1048 |
for (Order order: orderList) {
|
1008 |
Payment payment = paymentClient.getPayment(paymentSettlement.getReferenceId());
|
| 1049 |
logger.info("For order: " + order.getId());
|
1009 |
Transaction txn = transactionClient.getTransaction(payment.getMerchantTxnId());
|
| 1050 |
|
1010 |
|
| 1051 |
// Orders where payment was captured but never billed
|
1011 |
outputRefundRows(sheet, vendorId, paymentSettlement, txn, payment);
|
| 1052 |
if(order.getBilling_timestamp() == 0) {
|
1012 |
} catch (TransactionServiceException e) {
|
| 1053 |
continue;
|
- |
|
| 1054 |
}
|
- |
|
| 1055 |
|
- |
|
| 1056 |
if (reshippedOrderIds.contains(order.getId())) {
|
- |
|
| 1057 |
reshippedOrders.add(order);
|
- |
|
| 1058 |
continue;
|
- |
|
| 1059 |
}
|
- |
|
| 1060 |
|
- |
|
| 1061 |
LineItem lineItem = order.getLineitems().get(0);
|
1013 |
logger.error("TransactionServiceException " + e);
|
| 1062 |
double transferPrice = lineItem.getTransfer_price();
|
- |
|
| 1063 |
Payment payment = null;
|
- |
|
| 1064 |
|
- |
|
| 1065 |
try {
|
- |
|
| 1066 |
if(order.isCod()) {
|
- |
|
| 1067 |
payment = paymentClient.getPaymentForTxnId(order.getTransactionId()).get(0);
|
- |
|
| 1068 |
} else {
|
- |
|
| 1069 |
payment = paymentClient.getSuccessfulPaymentForTxnId(order.getTransactionId());
|
- |
|
| 1070 |
}
|
- |
|
| 1071 |
logger.info("getSuccessfulPaymentForTxnId, " + order.getTransactionId() + ": " + payment);
|
- |
|
| 1072 |
|
- |
|
| 1073 |
} catch (TApplicationException e) {
|
1014 |
} catch (TException e) {
|
| 1074 |
orderIdsWithoutSuccess.add(order.getId());
|
- |
|
| 1075 |
String errMsg = "Exception while getting successfull payment for transaction Id, " + order.getTransactionId();
|
- |
|
| 1076 |
logger.error(errMsg, e);
|
1015 |
logger.error("TException " + e);
|
| 1077 |
addActionError(errMsg);
|
- |
|
| 1078 |
}
|
- |
|
| 1079 |
|
- |
|
| 1080 |
Transaction txn = transactionClient.getTransaction(order.getTransactionId());
|
- |
|
| 1081 |
PaymentSettlement paymentSettlement = null;
|
- |
|
| 1082 |
String paymentType = null;
|
- |
|
| 1083 |
|
- |
|
| 1084 |
if(payment != null) {
|
1016 |
} catch (PaymentException e) {
|
| 1085 |
paymentSettlement = transactionClient.getSettlementForPaymentId(payment.getPaymentId());
|
- |
|
| 1086 |
paymentType = paymentGateways.get(payment.getGatewayId());
|
- |
|
| 1087 |
}
|
- |
|
| 1088 |
|
- |
|
| 1089 |
double totalSellingPrice = lineItem.getTotal_price();
|
- |
|
| 1090 |
double serviceTax = 0.0;
|
- |
|
| 1091 |
double otherCollectionCharges = 0.0;
|
- |
|
| 1092 |
double netCollection = 0.0;
|
1017 |
logger.error("PaymentException " + e);
|
| 1093 |
|
- |
|
| 1094 |
if(paymentSettlement != null) {
|
- |
|
| 1095 |
serviceTax = paymentSettlement.getServiceTax();
|
- |
|
| 1096 |
otherCollectionCharges = paymentSettlement.getOtherCharges();
|
- |
|
| 1097 |
netCollection = paymentSettlement.getNetCollection();
|
- |
|
| 1098 |
}
|
- |
|
| 1099 |
|
- |
|
| 1100 |
if (netCollection < 0.0) {
|
- |
|
| 1101 |
paymentType = paymentType + "-REFUND";
|
- |
|
| 1102 |
}
|
- |
|
| 1103 |
double expectedCollection = totalSellingPrice - otherCollectionCharges - serviceTax;
|
- |
|
| 1104 |
|
- |
|
| 1105 |
//FIXME ignore differences of upto 50 paisa
|
- |
|
| 1106 |
if (netCollection > 0.0 && expectedCollection != netCollection) {
|
- |
|
| 1107 |
Map <String, Double> mismatch = new HashMap<String, Double>();
|
- |
|
| 1108 |
mismatch.put("expected", expectedCollection);
|
- |
|
| 1109 |
mismatch.put("actual", netCollection);
|
- |
|
| 1110 |
misMatches.put(order.getId(), mismatch);
|
- |
|
| 1111 |
}
|
- |
|
| 1112 |
|
- |
|
| 1113 |
Row contentRow = sheet.createRow(serialNo++);
|
- |
|
| 1114 |
contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
- |
|
| 1115 |
contentRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getCreated_timestamp())));
|
- |
|
| 1116 |
contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
|
- |
|
| 1117 |
contentRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getBilling_timestamp())));
|
- |
|
| 1118 |
contentRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getDelivery_timestamp())));
|
- |
|
| 1119 |
contentRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
|
- |
|
| 1120 |
contentRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
|
- |
|
| 1121 |
contentRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
|
- |
|
| 1122 |
contentRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
|
- |
|
| 1123 |
contentRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue(lineItem.getQuantity());
|
- |
|
| 1124 |
contentRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue(transferPrice);
|
- |
|
| 1125 |
contentRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue(lineItem.getUnit_price());
|
- |
|
| 1126 |
contentRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue(transferPrice * lineItem.getQuantity());
|
- |
|
| 1127 |
contentRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue(totalSellingPrice);
|
- |
|
| 1128 |
contentRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue(order.getStatusDescription());
|
- |
|
| 1129 |
|
- |
|
| 1130 |
double refund = 0.0;
|
- |
|
| 1131 |
|
- |
|
| 1132 |
if(order.isCod()) {
|
- |
|
| 1133 |
contentRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue("COD - " + codProviders.get(order.getLogistics_provider_id()));
|
- |
|
| 1134 |
} else {
|
- |
|
| 1135 |
contentRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue(paymentType);
|
- |
|
| 1136 |
}
|
- |
|
| 1137 |
|
- |
|
| 1138 |
if (payment != null) {
|
- |
|
| 1139 |
contentRow.createCell(OrderReportColumn.SETTLEMENT_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(paymentSettlement.getSettlementDate())));
|
- |
|
| 1140 |
contentRow.createCell(OrderReportColumn.GATEWAY_TRANSACTION_ID.getValue()).setCellValue(payment.getGatewayTxnId());
|
- |
|
| 1141 |
contentRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue(payment.getStatus().name());
|
- |
|
| 1142 |
contentRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue(payment.getPaymentId());
|
- |
|
| 1143 |
}
|
- |
|
| 1144 |
contentRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue(txn.getCoupon_code());
|
- |
|
| 1145 |
contentRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue(serviceTax);
|
- |
|
| 1146 |
contentRow.createCell(OrderReportColumn.OTHER_CHARGES.getValue()).setCellValue(otherCollectionCharges);
|
- |
|
| 1147 |
contentRow.createCell(OrderReportColumn.NET_COLLECTION.getValue()).setCellValue(netCollection);
|
- |
|
| 1148 |
contentRow.createCell(OrderReportColumn.FINAL_AMOUNT.getValue()).setCellValue(netCollection - refund);
|
- |
|
| 1149 |
}
|
1018 |
}
|
| - |
|
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);
|
| - |
|
1040 |
|
| - |
|
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 |
}
|
| 1150 |
}
|
1068 |
}
|
| 1151 |
|
1069 |
}
|
| 1152 |
logger.info("Reshipped Orders ", reshippedOrders);
|
- |
|
| 1153 |
|
1070 |
}
|
| - |
|
1071 |
//9810579334
|
| 1154 |
logger.info("Order Ids where no successful payment was found: " + orderIdsWithoutSuccess.size());
|
1072 |
private void outputPrepaidTransactionRows(Sheet sheet, long vendorId, PaymentSettlement paymentSettlement, Transaction txn, Payment payment) {
|
| 1155 |
logger.info(orderIdsWithoutSuccess.toString());
|
- |
|
| 1156 |
logger.info("Reshipped Order Ids: " + reshippedOrderIds);
|
1073 |
logger.info("Printing orders for pmt Id, " + payment.getPaymentId());
|
| 1157 |
logger.info("countMultipleOrderTxns: " + countMultipleOrderTxns);
|
- |
|
| 1158 |
|
1074 |
|
| 1159 |
sheet.createRow(serialNo++);
|
1075 |
boolean isFirstOrderForTransaction = true;
|
| 1160 |
|
1076 |
|
| 1161 |
List<PaymentSettlement> refundSettlements = transactionClient.getSettlementsByDate(startDate.getTime(), endDate.getTime(), true);
|
1077 |
for (Order order: txn.getOrders()) {
|
| 1162 |
logger.info("Refunds: " + refundSettlements.size());
|
1078 |
if(order.getVendorId() == vendorId) {
|
| 1163 |
logger.info(refundSettlements.toString());
|
1079 |
Row contentRow = sheet.createRow(rowCount ++);
|
| 1164 |
|
- |
|
| 1165 |
Map<Long, PaymentSettlement> refunds = new HashMap<Long, PaymentSettlement>();
|
1080 |
LineItem lineItem = order.getLineitems().get(0);
|
| 1166 |
|
1081 |
|
| 1167 |
for (PaymentSettlement settlement: refundSettlements) {
|
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())));
|
| 1168 |
refunds.put(settlement.getReferenceId(), settlement);
|
1084 |
contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
|
| 1169 |
}
|
- |
|
| 1170 |
|
- |
|
| - |
|
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())));
|
| 1171 |
// Refunds belonging to orders billed before the start date of supplied billing date range
|
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()));
|
| 1172 |
for (long paymentId: refunds.keySet()) {
|
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())));
|
| 1173 |
Payment payment = paymentClient.getPayment(paymentId);
|
1099 |
contentRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue(txn.getCoupon_code());
|
| 1174 |
Transaction txn = transactionClient.getTransaction(payment.getMerchantTxnId());
|
1100 |
contentRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue(payment.getStatus().name());
|
| 1175 |
PaymentSettlement paymentSettlement = refunds.get(paymentId);
|
1101 |
contentRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue(payment.getPaymentId());
|
| 1176 |
|
1102 |
|
| 1177 |
for (Order order: txn.getOrders()) {
|
1103 |
if(isFirstOrderForTransaction) {
|
| 1178 |
if(!refundOrderStatuses.contains(order.getStatus())) continue;
|
- |
|
| 1179 |
|
- |
|
| 1180 |
Row contentRow = sheet.createRow(serialNo++);
|
- |
|
| 1181 |
|
- |
|
| 1182 |
LineItem lineItem = order.getLineitems().get(0);
|
- |
|
| 1183 |
double transferPrice = lineItem.getTransfer_price();
|
- |
|
| 1184 |
double totalSellingPrice = lineItem.getTotal_price();
|
- |
|
| 1185 |
String paymentType = paymentGateways.get(payment.getGatewayId()) + "-REFUND";
|
- |
|
| 1186 |
|
- |
|
| 1187 |
contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
- |
|
| 1188 |
contentRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getCreated_timestamp())));
|
- |
|
| 1189 |
contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
|
- |
|
| 1190 |
contentRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getBilling_timestamp())));
|
- |
|
| 1191 |
contentRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getDelivery_timestamp())));
|
- |
|
| 1192 |
contentRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
|
- |
|
| 1193 |
contentRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
|
- |
|
| 1194 |
contentRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
|
- |
|
| 1195 |
contentRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
|
- |
|
| 1196 |
contentRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue(lineItem.getQuantity());
|
- |
|
| 1197 |
contentRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue(transferPrice);
|
- |
|
| 1198 |
contentRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue(lineItem.getUnit_price());
|
- |
|
| 1199 |
contentRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue(transferPrice * lineItem.getQuantity());
|
- |
|
| 1200 |
contentRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue(totalSellingPrice);
|
- |
|
| 1201 |
contentRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue(order.getStatusDescription());
|
- |
|
| 1202 |
|
- |
|
| 1203 |
contentRow.createCell(OrderReportColumn.SETTLEMENT_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(paymentSettlement.getSettlementDate())));
|
- |
|
| 1204 |
contentRow.createCell(OrderReportColumn.GATEWAY_TRANSACTION_ID.getValue()).setCellValue(payment.getGatewayTxnId());
|
- |
|
| 1205 |
contentRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue(paymentType);
|
- |
|
| 1206 |
contentRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue(payment.getPaymentId());
|
1104 |
contentRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue(paymentSettlement.getServiceTax());
|
| 1207 |
|
- |
|
| 1208 |
contentRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue(txn.getCoupon_code());
|
1105 |
contentRow.createCell(OrderReportColumn.OTHER_CHARGES.getValue()).setCellValue(paymentSettlement.getOtherCharges());
|
| 1209 |
contentRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue(0.0);
|
- |
|
| 1210 |
contentRow.createCell(OrderReportColumn.OTHER_CHARGES.getValue()).setCellValue(0.0);
|
- |
|
| 1211 |
contentRow.createCell(OrderReportColumn.NET_COLLECTION.getValue()).setCellValue(paymentSettlement.getNetCollection());
|
1106 |
contentRow.createCell(OrderReportColumn.NET_COLLECTION.getValue()).setCellValue(paymentSettlement.getNetCollection());
|
| - |
|
1107 |
isFirstOrderForTransaction = false;
|
| 1212 |
}
|
1108 |
}
|
| 1213 |
}
|
1109 |
}
|
| 1214 |
|
- |
|
| 1215 |
} catch (TTransportException e) {
|
- |
|
| 1216 |
logger.error("TTransportException " + e);
|
- |
|
| 1217 |
} catch (PaymentException e) {
|
- |
|
| 1218 |
logger.error("PaymentException " + e);
|
- |
|
| 1219 |
} catch (TException e) {
|
- |
|
| 1220 |
logger.error("TException " + e);
|
- |
|
| 1221 |
} catch (TransactionServiceException e) {
|
- |
|
| 1222 |
logger.error("Transaction Service Exception " + e);
|
- |
|
| 1223 |
} catch (LogisticsServiceException e) {
|
- |
|
| 1224 |
addActionError("Error loading list of COD providers");
|
- |
|
| 1225 |
logger.error("Logistics Service Exception " + e);
|
- |
|
| 1226 |
}
|
1110 |
}
|
| 1227 |
}
|
1111 |
}
|
| 1228 |
|
1112 |
|
| - |
|
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 |
|
| 1229 |
public List<Vendor> getAllVendors() {
|
1142 |
public List<Vendor> getAllVendors() {
|
| 1230 |
return this.vendors;
|
1143 |
return this.vendors;
|
| 1231 |
}
|
1144 |
}
|
| 1232 |
|
1145 |
|
| 1233 |
private String getValueForEmptyString(String s){
|
1146 |
private String getValueForEmptyString(String s){
|