| 4600 |
varun.gupt |
1 |
package in.shop2020.support.controllers;
|
|
|
2 |
|
| 4734 |
varun.gupt |
3 |
import in.shop2020.logistics.Provider;
|
| 5945 |
mandeep.dh |
4 |
import in.shop2020.model.v1.inventory.Vendor;
|
| 6387 |
amar.kumar |
5 |
import in.shop2020.model.v1.inventory.InventoryService.Client;
|
| 4600 |
varun.gupt |
6 |
import in.shop2020.model.v1.order.LineItem;
|
|
|
7 |
import in.shop2020.model.v1.order.Order;
|
| 4734 |
varun.gupt |
8 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 5020 |
varun.gupt |
9 |
import in.shop2020.model.v1.order.OrderStatusGroups;
|
| 4600 |
varun.gupt |
10 |
import in.shop2020.model.v1.order.PaymentSettlement;
|
| 5386 |
phani.kuma |
11 |
import in.shop2020.model.v1.order.ReturnOrder;
|
| 4600 |
varun.gupt |
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.PaymentGateway;
|
| 5945 |
mandeep.dh |
16 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 4734 |
varun.gupt |
17 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 4600 |
varun.gupt |
18 |
import in.shop2020.thrift.clients.PaymentClient;
|
|
|
19 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
20 |
|
| 5020 |
varun.gupt |
21 |
import java.io.ByteArrayOutputStream;
|
|
|
22 |
import java.io.File;
|
|
|
23 |
import java.io.FileInputStream;
|
|
|
24 |
import java.io.FileNotFoundException;
|
|
|
25 |
import java.io.IOException;
|
|
|
26 |
import java.text.DateFormat;
|
|
|
27 |
import java.text.ParseException;
|
|
|
28 |
import java.text.SimpleDateFormat;
|
|
|
29 |
import java.util.ArrayList;
|
|
|
30 |
import java.util.Date;
|
|
|
31 |
import java.util.HashMap;
|
| 5386 |
phani.kuma |
32 |
import java.util.HashSet;
|
| 6387 |
amar.kumar |
33 |
import java.util.Hashtable;
|
| 5020 |
varun.gupt |
34 |
import java.util.List;
|
|
|
35 |
import java.util.Map;
|
| 5386 |
phani.kuma |
36 |
import java.util.Set;
|
|
|
37 |
import java.util.Map.Entry;
|
| 5020 |
varun.gupt |
38 |
|
| 4600 |
varun.gupt |
39 |
import javax.servlet.ServletContext;
|
|
|
40 |
import javax.servlet.ServletOutputStream;
|
|
|
41 |
import javax.servlet.http.HttpServletRequest;
|
|
|
42 |
import javax.servlet.http.HttpServletResponse;
|
| 5189 |
varun.gupt |
43 |
import org.apache.commons.io.IOUtils;
|
| 4600 |
varun.gupt |
44 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
45 |
import org.apache.poi.ss.usermodel.Row;
|
|
|
46 |
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
47 |
import org.apache.poi.ss.usermodel.Workbook;
|
| 5020 |
varun.gupt |
48 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| 4600 |
varun.gupt |
49 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
|
|
50 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
|
|
51 |
import org.apache.struts2.rest.DefaultHttpHeaders;
|
|
|
52 |
import org.apache.struts2.rest.HttpHeaders;
|
|
|
53 |
import org.apache.struts2.util.ServletContextAware;
|
|
|
54 |
import org.apache.thrift.transport.TTransportException;
|
|
|
55 |
import org.slf4j.Logger;
|
|
|
56 |
import org.slf4j.LoggerFactory;
|
|
|
57 |
|
| 4715 |
varun.gupt |
58 |
import com.opensymphony.xwork2.ValidationAwareSupport;
|
|
|
59 |
|
| 4600 |
varun.gupt |
60 |
/**
|
|
|
61 |
* @author Varun Gupta
|
|
|
62 |
* @description: This class handles web requests to generate vendor specific reconciliation reports
|
|
|
63 |
* for given vendor for a given date range
|
|
|
64 |
*/
|
| 5386 |
phani.kuma |
65 |
|
| 4715 |
varun.gupt |
66 |
public class VendorReconciliationController extends ValidationAwareSupport implements ServletRequestAware, ServletResponseAware, ServletContextAware {
|
| 4600 |
varun.gupt |
67 |
|
| 5386 |
phani.kuma |
68 |
private static final long serialVersionUID = 1L;
|
|
|
69 |
private static Logger logger = LoggerFactory.getLogger(VendorReconciliationController.class);
|
| 4600 |
varun.gupt |
70 |
|
|
|
71 |
private enum OrderReportColumn {
|
|
|
72 |
ORDER_ID(0),
|
| 5386 |
phani.kuma |
73 |
ORIGINAL_ORDER_ID(1),
|
|
|
74 |
VENDOR_ID(2),
|
| 6387 |
amar.kumar |
75 |
VENDOR_NAME(3),
|
|
|
76 |
ORDER_DATE(4),
|
|
|
77 |
BILLING_NUMBER(5),
|
|
|
78 |
BILLING_DATE(6),
|
|
|
79 |
DELIVERY_DATE(7),
|
|
|
80 |
BRAND(8),
|
|
|
81 |
MODEL_NAME(9),
|
|
|
82 |
MODEL_NUMBER(10),
|
|
|
83 |
COLOR(11),
|
|
|
84 |
QUANTITY(12),
|
|
|
85 |
UNIT_TRANSFER_PRICE(13),
|
|
|
86 |
UNIT_SELLING_PRICE(14),
|
|
|
87 |
TOTAL_TRANSFER_PRICE(15),
|
|
|
88 |
TOTAL_SELLING_PRICE(16),
|
|
|
89 |
CURRENT_STATUS(17),
|
|
|
90 |
VENDOR_PAID(18),
|
|
|
91 |
PAYMENT_STATUS(19),
|
|
|
92 |
PAYMENT_TYPE(20),
|
|
|
93 |
PAYMENT_ID(21),
|
|
|
94 |
COUPON_CODE(22),
|
|
|
95 |
SETTLEMENT_DATE(23),
|
|
|
96 |
SERVICE_TAX(24),
|
|
|
97 |
OTHER_CHARGES(25),
|
|
|
98 |
NET_COLLECTION(26),
|
|
|
99 |
USER_PAYABLE_AMOUNT(27);
|
| 4600 |
varun.gupt |
100 |
|
|
|
101 |
private int value;
|
|
|
102 |
|
|
|
103 |
OrderReportColumn(int value) {
|
|
|
104 |
this.value = value;
|
|
|
105 |
}
|
|
|
106 |
public int getValue(){
|
|
|
107 |
return this.value;
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
private HttpServletRequest request;
|
|
|
112 |
private HttpServletResponse response;
|
|
|
113 |
private ServletContext context;
|
|
|
114 |
private List<Vendor> vendors;
|
| 5020 |
varun.gupt |
115 |
private Map<Long, String> codProviders = new HashMap<Long, String>();
|
|
|
116 |
private Map<Long, String> paymentGateways = new HashMap<Long, String>();
|
|
|
117 |
|
| 5386 |
phani.kuma |
118 |
private File orderIdsToBeMarked;
|
| 4600 |
varun.gupt |
119 |
private File hdfcSettlementReport;
|
|
|
120 |
|
|
|
121 |
private File ebsSettlementReport;
|
|
|
122 |
private File ebsSettlementSummary;
|
|
|
123 |
|
|
|
124 |
private String bluedartSettlementDate;
|
|
|
125 |
private File bluedartSettlementReport;
|
|
|
126 |
|
| 4715 |
varun.gupt |
127 |
private String aramexSettlementDate;
|
|
|
128 |
private File aramexSettlementReport;
|
|
|
129 |
|
| 5481 |
phani.kuma |
130 |
private String delhiverySettlementDate;
|
|
|
131 |
private File delhiverySettlementReport;
|
|
|
132 |
|
| 4600 |
varun.gupt |
133 |
private Map<Long, String> ebsSettlementSummaries;
|
|
|
134 |
|
| 5020 |
varun.gupt |
135 |
private List<OrderStatus> refundOrderStatuses;
|
| 5189 |
varun.gupt |
136 |
|
| 5386 |
phani.kuma |
137 |
private List<Order> reshippedNonPayableOrders = new ArrayList<Order>();
|
|
|
138 |
private List<Order> returnedOrders = new ArrayList<Order>();
|
| 5189 |
varun.gupt |
139 |
private List<Order> unsettledOrders = new ArrayList<Order>();
|
| 5386 |
phani.kuma |
140 |
private List<Order> userPaymentNotRequiredOrders = new ArrayList<Order>();
|
|
|
141 |
private Map<Order, PaymentSettlement> paymentSettledOrdersMap = new HashMap<Order, PaymentSettlement>();
|
|
|
142 |
private List<Order> ordersWithErrors = new ArrayList<Order>();
|
| 6387 |
amar.kumar |
143 |
private Map<Long, String> vendorIdNameMap;
|
| 4745 |
varun.gupt |
144 |
|
| 4600 |
varun.gupt |
145 |
private final DateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy");
|
|
|
146 |
|
|
|
147 |
public String index() {
|
| 5098 |
varun.gupt |
148 |
initiatializeDashboard();
|
| 4600 |
varun.gupt |
149 |
return "report";
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
public HttpHeaders create() {
|
|
|
153 |
|
|
|
154 |
String formType = request.getParameter("formtype");
|
| 4715 |
varun.gupt |
155 |
logger.info("Form Type: " + formType);
|
| 4600 |
varun.gupt |
156 |
|
|
|
157 |
if (formType.equals("uploadEBSSettlementSummary")) {
|
|
|
158 |
uploadEBSSettlementSummary();
|
|
|
159 |
|
|
|
160 |
} else if (formType.equals("uploadEBSSettlements")) {
|
|
|
161 |
uploadEBSSettlements();
|
|
|
162 |
|
|
|
163 |
} else if (formType.equals("uploadHDFCSettlements")) {
|
|
|
164 |
uploadHDFCSettlements();
|
|
|
165 |
|
|
|
166 |
} else if (formType.equals("uploadBluedartSettlements")) {
|
|
|
167 |
uploadBluedartSettlements();
|
| 4715 |
varun.gupt |
168 |
|
|
|
169 |
} else if (formType.equals("uploadAramexSettlements")) {
|
|
|
170 |
uploadAramexSettlements();
|
| 5098 |
varun.gupt |
171 |
|
|
|
172 |
} else if (formType.equals("markOrdersAsPaid")) {
|
| 5189 |
varun.gupt |
173 |
uploadOrderIdsToBeMarkedPaid();
|
| 5386 |
phani.kuma |
174 |
|
|
|
175 |
} else if (formType.equals("markOrdersAsReturned")) {
|
|
|
176 |
uploadOrderIdsToBeMarkedReturned();
|
|
|
177 |
|
| 5481 |
phani.kuma |
178 |
} else if (formType.equals("uploadDelhiverySettlements")) {
|
|
|
179 |
uploadDelhiverySettlements();
|
|
|
180 |
|
|
|
181 |
}
|
| 5386 |
phani.kuma |
182 |
|
| 5098 |
varun.gupt |
183 |
initiatializeDashboard();
|
| 4600 |
varun.gupt |
184 |
return new DefaultHttpHeaders("report");
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
public HttpHeaders generateReconciliationReport() {
|
| 5189 |
varun.gupt |
188 |
initiatializeDashboard();
|
| 5386 |
phani.kuma |
189 |
|
|
|
190 |
try {
|
|
|
191 |
LogisticsClient lsc = new LogisticsClient();
|
|
|
192 |
in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
|
|
|
193 |
|
|
|
194 |
PaymentClient psc = new PaymentClient();
|
|
|
195 |
in.shop2020.payments.PaymentService.Client paymentClient = psc.getClient();
|
|
|
196 |
|
|
|
197 |
List<PaymentGateway> tPaymentGateways = paymentClient.getActivePaymentGateways();
|
|
|
198 |
|
|
|
199 |
for (PaymentGateway tPaymentGateway: tPaymentGateways) {
|
|
|
200 |
paymentGateways.put(tPaymentGateway.getId(), tPaymentGateway.getName());
|
|
|
201 |
}
|
|
|
202 |
|
|
|
203 |
for (Provider provider: logisticsClient.getAllProviders()) {
|
|
|
204 |
codProviders.put(provider.getId(), provider.getName());
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
try {
|
| 5481 |
phani.kuma |
208 |
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
|
|
209 |
String formType = request.getParameter("formtype");
|
|
|
210 |
long fromTime = 0;
|
|
|
211 |
long toTime = 0;
|
|
|
212 |
boolean notall = true;
|
|
|
213 |
|
|
|
214 |
if (formType.equals("downloadbydate")) {
|
|
|
215 |
if(! request.getParameter("start").isEmpty() && ! request.getParameter("end").isEmpty()) {
|
|
|
216 |
Date startDate = dateFormat.parse(request.getParameter("start"));
|
|
|
217 |
fromTime = startDate.getTime();
|
|
|
218 |
|
|
|
219 |
Date endDate = dateFormat.parse(request.getParameter("end"));
|
|
|
220 |
toTime = endDate.getTime();
|
|
|
221 |
}
|
|
|
222 |
else {
|
|
|
223 |
String errMsg = "No Date Range given";
|
|
|
224 |
logger.error(errMsg);
|
|
|
225 |
addActionError(errMsg);
|
|
|
226 |
return new DefaultHttpHeaders("report");
|
|
|
227 |
}
|
|
|
228 |
notall = false;
|
|
|
229 |
|
|
|
230 |
}
|
|
|
231 |
|
| 5386 |
phani.kuma |
232 |
long vendorId = Long.parseLong(request.getParameter("vendor"));
|
|
|
233 |
String vendorName = "";
|
|
|
234 |
logger.info("Vendor ID: " + vendorId);
|
|
|
235 |
|
|
|
236 |
if(vendorId == -1) {
|
|
|
237 |
vendorName = "ALL-Vendors";
|
|
|
238 |
}
|
|
|
239 |
else {
|
|
|
240 |
vendorName = getVendorName(vendorId);
|
|
|
241 |
if(vendorName != null) {
|
|
|
242 |
vendorName = vendorName.replaceAll("\\s", "-");
|
|
|
243 |
}
|
|
|
244 |
}
|
|
|
245 |
|
|
|
246 |
response.setContentType("application/vnd.ms-excel");
|
|
|
247 |
response.setHeader("Content-disposition", "inline; filename=" + vendorName + "-reconciliation.xls");
|
|
|
248 |
|
|
|
249 |
ServletOutputStream sos;
|
|
|
250 |
try {
|
| 5481 |
phani.kuma |
251 |
ByteArrayOutputStream baos = getReconciliationReport(vendorId, fromTime, toTime, notall);
|
| 5386 |
phani.kuma |
252 |
sos = response.getOutputStream();
|
|
|
253 |
baos.writeTo(sos);
|
|
|
254 |
sos.flush();
|
|
|
255 |
} catch (IOException e) {
|
|
|
256 |
String errMsg = "Error while streaming the reconciliation report";
|
|
|
257 |
logger.error(errMsg, e);
|
|
|
258 |
addActionError(errMsg);
|
|
|
259 |
}
|
|
|
260 |
} catch (NullPointerException e) {
|
|
|
261 |
String errMsg = "NullPointerException";
|
|
|
262 |
logger.error(errMsg, e);
|
|
|
263 |
addActionError(errMsg);
|
| 5481 |
phani.kuma |
264 |
} catch (ParseException e) {
|
|
|
265 |
String errMsg = "Could not parse the Dates";
|
|
|
266 |
logger.error(errMsg, e);
|
|
|
267 |
addActionError(errMsg);
|
|
|
268 |
}
|
| 4600 |
varun.gupt |
269 |
|
| 5386 |
phani.kuma |
270 |
} catch (Exception e) {
|
|
|
271 |
String errMsg = "Exception Occured in generateReconciliationReport";
|
|
|
272 |
logger.error(errMsg, e);
|
|
|
273 |
addActionError(errMsg);
|
| 4745 |
varun.gupt |
274 |
}
|
| 5386 |
phani.kuma |
275 |
|
| 4600 |
varun.gupt |
276 |
return new DefaultHttpHeaders("report");
|
|
|
277 |
}
|
|
|
278 |
|
|
|
279 |
public void uploadEBSSettlementSummary() {
|
|
|
280 |
|
|
|
281 |
DateFormat settlementDateFormat = new SimpleDateFormat("dd MMM,yyyy hh:mm:ss a");
|
|
|
282 |
DateFormat transactionDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
283 |
|
|
|
284 |
Workbook wb = null;
|
|
|
285 |
try {
|
|
|
286 |
wb = new HSSFWorkbook(new FileInputStream(ebsSettlementSummary));
|
|
|
287 |
} catch (FileNotFoundException e) {
|
| 5386 |
phani.kuma |
288 |
String errMsg = "Unable to open the EBS Settlement Summary report";
|
|
|
289 |
logger.error(errMsg, e);
|
|
|
290 |
addActionError(errMsg);
|
|
|
291 |
return;
|
| 4600 |
varun.gupt |
292 |
} catch (IOException e) {
|
| 5386 |
phani.kuma |
293 |
String errMsg = "Unable to open the EBS Settlement Summary report";
|
|
|
294 |
logger.error(errMsg, e);
|
|
|
295 |
addActionError(errMsg);
|
|
|
296 |
return;
|
| 4600 |
varun.gupt |
297 |
}
|
|
|
298 |
Sheet sheet = wb.getSheetAt(0);
|
|
|
299 |
|
|
|
300 |
int indexSettlementId = 0;
|
|
|
301 |
int indexSettlementDate = 1;
|
|
|
302 |
int indexTransactionDateFrom = 2;
|
|
|
303 |
int indexTransactionDateTo = 3;
|
|
|
304 |
int indexAmount = 4;
|
|
|
305 |
|
|
|
306 |
TransactionClient tsc;
|
| 5481 |
phani.kuma |
307 |
int countSuccessfulSaves = 0;
|
| 5386 |
phani.kuma |
308 |
long settlementId = 0;
|
| 4600 |
varun.gupt |
309 |
|
|
|
310 |
try {
|
|
|
311 |
tsc = new TransactionClient();
|
|
|
312 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
|
|
313 |
|
|
|
314 |
for(Row row: sheet) {
|
| 5481 |
phani.kuma |
315 |
if(row.getRowNum() < 5) {
|
|
|
316 |
continue;
|
|
|
317 |
}
|
| 4600 |
varun.gupt |
318 |
|
|
|
319 |
try {
|
| 5481 |
phani.kuma |
320 |
settlementId = (long) row.getCell(indexSettlementId).getNumericCellValue();
|
|
|
321 |
String settlementDateStr = row.getCell(indexSettlementDate).getStringCellValue();
|
|
|
322 |
String transactionDateFromStr = row.getCell(indexTransactionDateFrom).getStringCellValue();
|
|
|
323 |
String transactionDateToStr = row.getCell(indexTransactionDateTo).getStringCellValue();
|
|
|
324 |
Double amount = row.getCell(indexAmount).getNumericCellValue();
|
|
|
325 |
|
|
|
326 |
Date settlementDate = settlementDateFormat.parse(settlementDateStr);
|
|
|
327 |
Date transactionDateFrom = transactionDateFormat.parse(transactionDateFromStr);
|
|
|
328 |
Date transactionDateTo = transactionDateFormat.parse(transactionDateToStr);
|
|
|
329 |
|
| 4600 |
varun.gupt |
330 |
transactionClient.saveEBSSettlementSummary(settlementId, settlementDate.getTime(), transactionDateFrom.getTime(), transactionDateTo.getTime(), amount);
|
| 5481 |
phani.kuma |
331 |
countSuccessfulSaves += 1;
|
| 4600 |
varun.gupt |
332 |
|
| 5386 |
phani.kuma |
333 |
} catch (TransactionServiceException e) {
|
|
|
334 |
String errMsg = "TransactionServiceException recieved for settlement Id, " + Long.toString(settlementId);
|
|
|
335 |
logger.error(errMsg, e);
|
|
|
336 |
addActionError(errMsg);
|
| 5481 |
phani.kuma |
337 |
} catch (Exception e) {
|
|
|
338 |
String errMsg = "Exception recieved for settlement Id, " + Long.toString(settlementId);
|
|
|
339 |
logger.error(errMsg, e);
|
|
|
340 |
addActionError(errMsg);
|
| 5386 |
phani.kuma |
341 |
}
|
| 4600 |
varun.gupt |
342 |
}
|
|
|
343 |
} catch (Exception e) {
|
| 5481 |
phani.kuma |
344 |
String errMsg = "Exception recieved for settlement Id," + Long.toString(settlementId);
|
| 5386 |
phani.kuma |
345 |
logger.error(errMsg, e);
|
|
|
346 |
addActionError(errMsg);
|
| 4600 |
varun.gupt |
347 |
}
|
| 5481 |
phani.kuma |
348 |
addActionMessage("Successfully added " + countSuccessfulSaves + " EBS Settlements");
|
| 4600 |
varun.gupt |
349 |
}
|
|
|
350 |
|
|
|
351 |
public void uploadHDFCSettlements() {
|
|
|
352 |
logger.info("Uploading HDFC settlements");
|
|
|
353 |
|
|
|
354 |
Workbook wb = null;
|
|
|
355 |
try {
|
|
|
356 |
wb = new HSSFWorkbook(new FileInputStream(this.hdfcSettlementReport));
|
|
|
357 |
} catch (FileNotFoundException e) {
|
| 4734 |
varun.gupt |
358 |
String errMsg = "Unable to open the HDFC Payout report";
|
|
|
359 |
logger.error(errMsg, e);
|
|
|
360 |
addActionError(errMsg);
|
|
|
361 |
return;
|
| 4600 |
varun.gupt |
362 |
} catch (IOException e) {
|
| 4734 |
varun.gupt |
363 |
String errMsg = "Unable to open the HDFC Payout report";
|
|
|
364 |
logger.error(errMsg, e);
|
|
|
365 |
addActionError(errMsg);
|
|
|
366 |
return;
|
| 4600 |
varun.gupt |
367 |
}
|
|
|
368 |
Sheet sheet = wb.getSheetAt(0);
|
|
|
369 |
|
|
|
370 |
int indexRECFMT = 2;
|
|
|
371 |
int indexSettlementDate = 7;
|
|
|
372 |
int indexPaymentId = 13;
|
|
|
373 |
int indexMSF = 14;
|
|
|
374 |
int indexServiceTax = 15;
|
|
|
375 |
int indexEduCess = 16;
|
|
|
376 |
int indexNetCollection = 17;
|
|
|
377 |
|
|
|
378 |
TransactionClient tsc;
|
|
|
379 |
String paymentIdStr = "";
|
|
|
380 |
long paymentId = 0;
|
| 5020 |
varun.gupt |
381 |
|
| 4734 |
varun.gupt |
382 |
int countSuccessfulInserts = 0;
|
|
|
383 |
int countRefunds = 0;
|
| 4600 |
varun.gupt |
384 |
|
|
|
385 |
try {
|
|
|
386 |
tsc = new TransactionClient();
|
|
|
387 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
|
|
388 |
|
|
|
389 |
for (Row row: sheet) {
|
| 5481 |
phani.kuma |
390 |
if(row.getRowNum() < 1) {
|
|
|
391 |
continue;
|
|
|
392 |
}
|
| 4600 |
varun.gupt |
393 |
|
|
|
394 |
try {
|
| 5481 |
phani.kuma |
395 |
|
|
|
396 |
if(row.getCell(0).getStringCellValue().equals("Total")) {
|
|
|
397 |
break;
|
|
|
398 |
}
|
|
|
399 |
|
| 4600 |
varun.gupt |
400 |
String recfmt = row.getCell(indexRECFMT).getStringCellValue();
|
|
|
401 |
Date settlementDate = row.getCell(indexSettlementDate).getDateCellValue();
|
|
|
402 |
double netCollection = row.getCell(indexNetCollection).getNumericCellValue();
|
| 5020 |
varun.gupt |
403 |
paymentIdStr = row.getCell(indexPaymentId).getStringCellValue().replace("'", "").trim();
|
| 4600 |
varun.gupt |
404 |
paymentId = Long.parseLong(paymentIdStr);
|
|
|
405 |
|
|
|
406 |
logger.info("paymentId: " + paymentId + ", recfmt: " + recfmt + ", settlementDate: " + settlementDate + ", netCollection: " + netCollection);
|
|
|
407 |
|
| 4715 |
varun.gupt |
408 |
if (recfmt.trim().equalsIgnoreCase("CVD")) {
|
|
|
409 |
if (netCollection > 0.0) netCollection *= -1.0;
|
|
|
410 |
transactionClient.savePaymentSettlements(settlementDate.getTime(), 1, paymentId, 0.0, 0.0, netCollection);
|
| 4734 |
varun.gupt |
411 |
countRefunds += 1;
|
| 5020 |
varun.gupt |
412 |
|
| 4600 |
varun.gupt |
413 |
} else {
|
|
|
414 |
double msf = row.getCell(indexMSF).getNumericCellValue();
|
|
|
415 |
double serviceTax = row.getCell(indexServiceTax).getNumericCellValue();
|
|
|
416 |
double eduCess = row.getCell(indexEduCess).getNumericCellValue();
|
|
|
417 |
logger.info("msf: " + msf + ", serviceTax: " + serviceTax + ", eduCess: " + eduCess);
|
|
|
418 |
|
|
|
419 |
transactionClient.savePaymentSettlements(settlementDate.getTime(), 1, paymentId, serviceTax, (eduCess + msf), netCollection);
|
| 4734 |
varun.gupt |
420 |
countSuccessfulInserts += 1;
|
| 4600 |
varun.gupt |
421 |
}
|
|
|
422 |
} catch (NumberFormatException e) {
|
| 4734 |
varun.gupt |
423 |
String errMsg = "NumberFormatException recieved for payment Id, " + paymentIdStr;
|
| 5386 |
phani.kuma |
424 |
logger.error(errMsg, e);
|
| 4734 |
varun.gupt |
425 |
addActionError(errMsg);
|
| 4600 |
varun.gupt |
426 |
|
|
|
427 |
} catch (TransactionServiceException e) {
|
| 5386 |
phani.kuma |
428 |
String errMsg = "TransactionServiceException recieved for payment Id, " + Long.toString(paymentId);
|
|
|
429 |
logger.error(errMsg, e);
|
| 4734 |
varun.gupt |
430 |
addActionError(errMsg);
|
| 5481 |
phani.kuma |
431 |
} catch (Exception e) {
|
|
|
432 |
String errMsg = "Exception recieved for payment Id," + Long.toString(paymentId);
|
|
|
433 |
logger.error(errMsg, e);
|
|
|
434 |
addActionError(errMsg);
|
| 4600 |
varun.gupt |
435 |
}
|
|
|
436 |
}
|
| 5386 |
phani.kuma |
437 |
} catch (Exception e) {
|
|
|
438 |
String errMsg = "Exception recieved for payment Id," + Long.toString(paymentId);
|
|
|
439 |
logger.error(errMsg, e);
|
|
|
440 |
addActionError(errMsg);
|
|
|
441 |
}
|
| 4600 |
varun.gupt |
442 |
|
| 4734 |
varun.gupt |
443 |
addActionMessage("Added settlements for " + countSuccessfulInserts + " payments");
|
|
|
444 |
addActionMessage("Added settlements for " + countRefunds + " refund payments");
|
| 4600 |
varun.gupt |
445 |
}
|
|
|
446 |
|
|
|
447 |
public void uploadEBSSettlements() {
|
|
|
448 |
Workbook wb = null;
|
|
|
449 |
try {
|
|
|
450 |
wb = new HSSFWorkbook(new FileInputStream(this.ebsSettlementReport));
|
|
|
451 |
} catch (FileNotFoundException e) {
|
| 5386 |
phani.kuma |
452 |
String errMsg = "Unable to open the EBS Settlement detail report";
|
|
|
453 |
logger.error(errMsg, e);
|
|
|
454 |
addActionError(errMsg);
|
|
|
455 |
return;
|
| 4600 |
varun.gupt |
456 |
} catch (IOException e) {
|
| 5386 |
phani.kuma |
457 |
String errMsg = "Unable to open the EBS Settlement detail report";
|
|
|
458 |
logger.error(errMsg, e);
|
|
|
459 |
addActionError(errMsg);
|
|
|
460 |
return;
|
| 4600 |
varun.gupt |
461 |
}
|
|
|
462 |
|
|
|
463 |
Sheet sheet = wb.getSheetAt(0);
|
|
|
464 |
|
|
|
465 |
Row firstRow = sheet.getRow(0);
|
|
|
466 |
Row secondRow = sheet.getRow(1);
|
|
|
467 |
|
|
|
468 |
int indexPaymentId = 2;
|
|
|
469 |
int indexTxnType = 5;
|
|
|
470 |
int indexAmount = 6;
|
|
|
471 |
|
|
|
472 |
Map<Long, Map<String, Double>> map = new HashMap<Long, Map<String,Double>>();
|
|
|
473 |
Map <String, Double> record;
|
| 4734 |
varun.gupt |
474 |
int countPaymentIds = 0;
|
| 4600 |
varun.gupt |
475 |
|
|
|
476 |
try {
|
|
|
477 |
for (Row row: sheet) {
|
|
|
478 |
if(row.equals(firstRow) || row.equals(secondRow)) continue;
|
|
|
479 |
|
|
|
480 |
long paymentId = Long.parseLong(row.getCell(indexPaymentId).getStringCellValue());
|
|
|
481 |
String transactionType = row.getCell(indexTxnType).getStringCellValue();
|
|
|
482 |
double amount = row.getCell(indexAmount).getNumericCellValue();
|
|
|
483 |
|
|
|
484 |
if(map.containsKey(paymentId)) {
|
|
|
485 |
map.get(paymentId).put(transactionType, amount);
|
|
|
486 |
|
|
|
487 |
} else {
|
|
|
488 |
record = new HashMap<String, Double>();
|
|
|
489 |
record.put(transactionType, amount);
|
|
|
490 |
map.put(paymentId, record);
|
| 4734 |
varun.gupt |
491 |
countPaymentIds += 1;
|
| 4600 |
varun.gupt |
492 |
}
|
|
|
493 |
}
|
|
|
494 |
} catch (NullPointerException e) {
|
|
|
495 |
logger.error("" + e);
|
|
|
496 |
}
|
| 4734 |
varun.gupt |
497 |
addActionMessage("Total Payment Ids added: " + countPaymentIds);
|
| 4600 |
varun.gupt |
498 |
|
|
|
499 |
TransactionClient tsc;
|
|
|
500 |
long settlementId = Long.parseLong(request.getParameter("settlementId"));
|
|
|
501 |
|
| 4734 |
varun.gupt |
502 |
int countPaymentsRecieved = 0;
|
|
|
503 |
int countPaymentsRefunded = 0;
|
|
|
504 |
|
| 4600 |
varun.gupt |
505 |
try {
|
|
|
506 |
tsc = new TransactionClient();
|
|
|
507 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
| 4734 |
varun.gupt |
508 |
long settlementDate;
|
| 4600 |
varun.gupt |
509 |
|
| 4734 |
varun.gupt |
510 |
try {
|
|
|
511 |
settlementDate = transactionClient.getEBSSettlementDate(settlementId);
|
|
|
512 |
} catch (TransactionServiceException e) {
|
|
|
513 |
String errMsg = "Could not retrieve EBS Settlement date for settlementId, " + settlementId;
|
| 5386 |
phani.kuma |
514 |
logger.error(errMsg, e);
|
| 4734 |
varun.gupt |
515 |
addActionError(errMsg);
|
|
|
516 |
return;
|
|
|
517 |
}
|
|
|
518 |
|
| 4600 |
varun.gupt |
519 |
for (long paymentId: map.keySet()) {
|
|
|
520 |
record = map.get(paymentId);
|
|
|
521 |
|
|
|
522 |
if(record.containsKey("Captured")) {
|
|
|
523 |
double capturedAmount = record.get("Captured");
|
|
|
524 |
double tdr = record.get("TDR");
|
|
|
525 |
double serviceTax = record.get("ServiceTax");
|
|
|
526 |
|
|
|
527 |
if(tdr < 0) tdr *= -1;
|
|
|
528 |
if(serviceTax < 0) serviceTax *= -1;
|
|
|
529 |
|
|
|
530 |
double amount = capturedAmount - tdr - serviceTax;
|
| 4734 |
varun.gupt |
531 |
|
|
|
532 |
try {
|
|
|
533 |
transactionClient.savePaymentSettlements(settlementDate, 2, paymentId, serviceTax, tdr, amount);
|
|
|
534 |
} catch (TransactionServiceException e) {
|
|
|
535 |
String errMsg = "Could not save settlement for paymentId, " + paymentId;
|
|
|
536 |
logger.error(errMsg + e);
|
|
|
537 |
addActionError(errMsg);
|
|
|
538 |
}
|
|
|
539 |
countPaymentsRecieved += 1;
|
|
|
540 |
}
|
|
|
541 |
|
|
|
542 |
if(record.containsKey("Refunded")) {
|
| 4600 |
varun.gupt |
543 |
double refundedAmount = record.get("Refunded");
|
|
|
544 |
|
|
|
545 |
if (refundedAmount > 0) refundedAmount *= -1;
|
|
|
546 |
|
| 4734 |
varun.gupt |
547 |
try {
|
|
|
548 |
transactionClient.savePaymentSettlements(settlementDate, 2, paymentId, 0.0, 0.0, refundedAmount);
|
|
|
549 |
} catch (TransactionServiceException e) {
|
|
|
550 |
String errMsg = "Could not save refund settlement for paymentId, " + paymentId;
|
| 5386 |
phani.kuma |
551 |
logger.error(errMsg, e);
|
| 4734 |
varun.gupt |
552 |
addActionError(errMsg);
|
|
|
553 |
}
|
|
|
554 |
countPaymentsRefunded += 1;
|
| 4600 |
varun.gupt |
555 |
}
|
|
|
556 |
}
|
| 4734 |
varun.gupt |
557 |
addActionMessage("Total count of payments recieved: " + countPaymentsRecieved);
|
|
|
558 |
addActionMessage("Total count of payments refunded: " + countPaymentsRefunded);
|
| 4600 |
varun.gupt |
559 |
|
| 4734 |
varun.gupt |
560 |
try {
|
|
|
561 |
transactionClient.markEBSSettlementUploaded(settlementId);
|
|
|
562 |
} catch (TransactionServiceException e) {
|
|
|
563 |
String errMsg = "Could not mark settlement for details Uploaded. Settlement ID: " + settlementId;
|
| 5386 |
phani.kuma |
564 |
logger.error(errMsg, e);
|
| 4734 |
varun.gupt |
565 |
addActionError(errMsg);
|
|
|
566 |
}
|
| 5386 |
phani.kuma |
567 |
} catch (Exception e) {
|
|
|
568 |
String errMsg = e.getMessage();
|
|
|
569 |
logger.error(errMsg, e);
|
|
|
570 |
addActionError(errMsg);
|
| 4600 |
varun.gupt |
571 |
}
|
|
|
572 |
}
|
|
|
573 |
|
|
|
574 |
public void uploadBluedartSettlements() {
|
|
|
575 |
|
|
|
576 |
Workbook wb = null;
|
|
|
577 |
try {
|
|
|
578 |
wb = new HSSFWorkbook(new FileInputStream(this.bluedartSettlementReport));
|
|
|
579 |
} catch (FileNotFoundException e) {
|
| 5386 |
phani.kuma |
580 |
String errMsg = "Unable to open the Bluedart Settlement report";
|
|
|
581 |
logger.error(errMsg, e);
|
|
|
582 |
addActionError(errMsg);
|
|
|
583 |
return;
|
| 4600 |
varun.gupt |
584 |
} catch (IOException e) {
|
| 5386 |
phani.kuma |
585 |
String errMsg = "Unable to open the Bluedart Settlement report";
|
|
|
586 |
logger.error(errMsg, e);
|
|
|
587 |
addActionError(errMsg);
|
|
|
588 |
return;
|
| 4600 |
varun.gupt |
589 |
}
|
|
|
590 |
|
|
|
591 |
Sheet sheet = wb.getSheetAt(0);
|
|
|
592 |
|
| 5098 |
varun.gupt |
593 |
int indexOrderId = 15;
|
|
|
594 |
int indexAmount = 14;
|
| 4600 |
varun.gupt |
595 |
|
|
|
596 |
TransactionClient tsc;
|
| 4734 |
varun.gupt |
597 |
int countSuccessfulSaves = 0;
|
| 4600 |
varun.gupt |
598 |
|
|
|
599 |
try {
|
|
|
600 |
long settlementDate = DATE_FORMAT.parse(bluedartSettlementDate).getTime();
|
|
|
601 |
tsc = new TransactionClient();
|
|
|
602 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
|
|
603 |
|
| 5386 |
phani.kuma |
604 |
long orderId = 0;
|
|
|
605 |
|
| 4600 |
varun.gupt |
606 |
for (Row row : sheet) {
|
| 5098 |
varun.gupt |
607 |
String orderIdString = "";
|
| 5481 |
phani.kuma |
608 |
|
|
|
609 |
if(row.getRowNum() < 1) {
|
|
|
610 |
continue;
|
|
|
611 |
}
|
|
|
612 |
|
| 4600 |
varun.gupt |
613 |
try {
|
| 5098 |
varun.gupt |
614 |
orderIdString = row.getCell(indexOrderId).getStringCellValue();
|
|
|
615 |
orderId = Long.parseLong(orderIdString);
|
| 4715 |
varun.gupt |
616 |
|
| 4600 |
varun.gupt |
617 |
double amount = row.getCell(indexAmount).getNumericCellValue();
|
| 5020 |
varun.gupt |
618 |
logger.info("Bluedart SettlementDate: " + settlementDate + ", OrderId: " + orderId + ", Amount: " + amount);
|
| 4905 |
varun.gupt |
619 |
transactionClient.savePaymentSettlements(settlementDate, 4, orderId, 0.0, 0.0, amount);
|
| 4875 |
varun.gupt |
620 |
countSuccessfulSaves += 1;
|
| 4600 |
varun.gupt |
621 |
|
| 5098 |
varun.gupt |
622 |
} catch (IllegalStateException e) {
|
| 5386 |
phani.kuma |
623 |
String errMsg = "IllegalStateException Near OrderId: " + orderId;
|
|
|
624 |
logger.error(errMsg, e);
|
|
|
625 |
addActionError(errMsg);
|
| 5098 |
varun.gupt |
626 |
|
| 5386 |
phani.kuma |
627 |
} catch(NumberFormatException e) {
|
|
|
628 |
String errMsg = "NumberFormatException for Extracted String: " + orderIdString;
|
|
|
629 |
logger.error(errMsg, e);
|
|
|
630 |
addActionError(errMsg);
|
| 5098 |
varun.gupt |
631 |
|
| 4600 |
varun.gupt |
632 |
} catch (NullPointerException e) {
|
| 5386 |
phani.kuma |
633 |
String errMsg = "NullPointerException For OrderId: " + orderId;
|
|
|
634 |
logger.error(errMsg, e);
|
|
|
635 |
addActionError(errMsg);
|
| 4600 |
varun.gupt |
636 |
|
| 4875 |
varun.gupt |
637 |
} catch (TransactionServiceException e) {
|
| 5386 |
phani.kuma |
638 |
String errMsg = "TransactionServiceException For OrderId: " + orderId;
|
|
|
639 |
logger.error(errMsg, e);
|
|
|
640 |
addActionError(errMsg);
|
| 5481 |
phani.kuma |
641 |
} catch (Exception e) {
|
|
|
642 |
String errMsg = "Exception recieved for OrderId:" + orderId;
|
|
|
643 |
logger.error(errMsg, e);
|
|
|
644 |
addActionError(errMsg);
|
|
|
645 |
}
|
| 4600 |
varun.gupt |
646 |
}
|
|
|
647 |
} catch (ParseException e) {
|
| 5386 |
phani.kuma |
648 |
String errMsg = "Could not parse " + bluedartSettlementDate;
|
|
|
649 |
logger.error(errMsg, e);
|
|
|
650 |
addActionError(errMsg);
|
|
|
651 |
} catch (Exception e) {
|
|
|
652 |
String errMsg = e.getMessage();
|
|
|
653 |
logger.error(errMsg, e);
|
|
|
654 |
addActionError(errMsg);
|
| 4600 |
varun.gupt |
655 |
}
|
| 4734 |
varun.gupt |
656 |
addActionMessage("Successfully added Bluedart settlement details for " + countSuccessfulSaves + " orders");
|
| 4600 |
varun.gupt |
657 |
}
|
|
|
658 |
|
| 5386 |
phani.kuma |
659 |
public void uploadAramexSettlements() {
|
| 4715 |
varun.gupt |
660 |
logger.info("Uploading Aramex Settlements" + this.aramexSettlementDate);
|
|
|
661 |
|
| 5386 |
phani.kuma |
662 |
if(this.aramexSettlementDate.equals("")) {
|
| 4715 |
varun.gupt |
663 |
addActionError("Settlement date cannot be left blank");
|
|
|
664 |
return;
|
|
|
665 |
}
|
|
|
666 |
|
|
|
667 |
Workbook wb = null;
|
|
|
668 |
try {
|
| 5020 |
varun.gupt |
669 |
wb = new XSSFWorkbook(new FileInputStream(this.aramexSettlementReport));
|
| 4715 |
varun.gupt |
670 |
} catch (FileNotFoundException e) {
|
| 5386 |
phani.kuma |
671 |
String errMsg = "Unable to open the Aramex Settlement report";
|
|
|
672 |
logger.error(errMsg, e);
|
|
|
673 |
addActionError(errMsg);
|
|
|
674 |
return;
|
| 4715 |
varun.gupt |
675 |
} catch (IOException e) {
|
| 5386 |
phani.kuma |
676 |
String errMsg = "Unable to open the Aramex Settlement report";
|
|
|
677 |
logger.error(errMsg, e);
|
|
|
678 |
addActionError(errMsg);
|
|
|
679 |
return;
|
|
|
680 |
}
|
| 4715 |
varun.gupt |
681 |
|
|
|
682 |
Sheet sheet = wb.getSheetAt(0);
|
|
|
683 |
|
| 5343 |
phani.kuma |
684 |
int indexAWB = 0;
|
| 4734 |
varun.gupt |
685 |
int indexAmount = 1;
|
| 5343 |
phani.kuma |
686 |
int indexComment = 2;
|
| 4715 |
varun.gupt |
687 |
|
|
|
688 |
TransactionClient tsc;
|
| 4734 |
varun.gupt |
689 |
int countSuccessfulSaves = 0;
|
| 4715 |
varun.gupt |
690 |
try {
|
|
|
691 |
long settlementDate = DATE_FORMAT.parse(aramexSettlementDate).getTime();
|
|
|
692 |
|
|
|
693 |
tsc = new TransactionClient();
|
|
|
694 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
|
|
695 |
|
|
|
696 |
for (Row row: sheet) {
|
| 5481 |
phani.kuma |
697 |
if(row.getRowNum() < 1) {
|
| 5343 |
phani.kuma |
698 |
continue;
|
|
|
699 |
}
|
| 4715 |
varun.gupt |
700 |
|
| 5441 |
phani.kuma |
701 |
if(row.getCell(indexAWB) == null) {
|
|
|
702 |
continue;
|
|
|
703 |
}
|
|
|
704 |
|
| 5343 |
phani.kuma |
705 |
long awb = -1;
|
|
|
706 |
|
| 5481 |
phani.kuma |
707 |
try {
|
|
|
708 |
if(row.getCell(indexAWB).getCellType() == 0) {
|
|
|
709 |
awb = (long) row.getCell(indexAWB).getNumericCellValue();
|
|
|
710 |
}
|
|
|
711 |
else if(row.getCell(indexAWB).getCellType() == 1) {
|
|
|
712 |
awb = Long.parseLong(row.getCell(indexAWB).getStringCellValue());
|
|
|
713 |
}
|
|
|
714 |
|
|
|
715 |
if(awb == -1) {
|
|
|
716 |
continue;
|
|
|
717 |
}
|
|
|
718 |
else if(row.getCell(indexComment).getStringCellValue().equals("LOST SHIPMENT")) {
|
|
|
719 |
logger.info("LOST SHIPMENT");
|
|
|
720 |
continue;
|
|
|
721 |
}
|
|
|
722 |
|
|
|
723 |
long orderId = transactionClient.getOrderForAwb(Long.toString(awb)).getId();
|
|
|
724 |
double amount = row.getCell(indexAmount).getNumericCellValue();
|
|
|
725 |
logger.info("Aramex Settlement, Order Id: " + orderId + " Amount: " + amount);
|
|
|
726 |
|
|
|
727 |
transactionClient.savePaymentSettlements(settlementDate, 4, orderId, 0.0, 0.0, amount);
|
|
|
728 |
countSuccessfulSaves += 1;
|
|
|
729 |
|
|
|
730 |
} catch (TransactionServiceException e) {
|
|
|
731 |
logger.error("Transaction Service Exception while getting order for AWB, " + awb, e);
|
|
|
732 |
addActionError("Transaction Service Exception while getting order for AWB, " + awb);
|
|
|
733 |
} catch (Exception e) {
|
|
|
734 |
String errMsg = "Exception recieved for AWB," + awb;
|
|
|
735 |
logger.error(errMsg, e);
|
|
|
736 |
addActionError(errMsg);
|
| 5108 |
varun.gupt |
737 |
}
|
| 5481 |
phani.kuma |
738 |
}
|
|
|
739 |
} catch (ParseException e) {
|
|
|
740 |
String errMsg = "Could not parse " + aramexSettlementDate;
|
|
|
741 |
logger.error(errMsg, e);
|
|
|
742 |
addActionError(errMsg);
|
|
|
743 |
} catch (Exception e) {
|
|
|
744 |
String errMsg = e.getMessage();
|
|
|
745 |
logger.error(errMsg, e);
|
|
|
746 |
addActionError(errMsg);
|
|
|
747 |
}
|
|
|
748 |
addActionMessage("Successfully added Aramex settlement details for " + countSuccessfulSaves + " orders");
|
|
|
749 |
}
|
|
|
750 |
|
|
|
751 |
public void uploadDelhiverySettlements() {
|
|
|
752 |
logger.info("Uploading Delhivery Settlements" + this.delhiverySettlementDate);
|
|
|
753 |
|
|
|
754 |
if(this.delhiverySettlementDate.equals("")) {
|
|
|
755 |
addActionError("Settlement date cannot be left blank");
|
|
|
756 |
return;
|
|
|
757 |
}
|
|
|
758 |
|
|
|
759 |
Workbook wb = null;
|
|
|
760 |
try {
|
|
|
761 |
wb = new XSSFWorkbook(new FileInputStream(this.delhiverySettlementReport));
|
|
|
762 |
} catch (FileNotFoundException e) {
|
|
|
763 |
String errMsg = "Unable to open the Delhivery Settlement report";
|
|
|
764 |
logger.error(errMsg, e);
|
|
|
765 |
addActionError(errMsg);
|
|
|
766 |
return;
|
|
|
767 |
} catch (IOException e) {
|
|
|
768 |
String errMsg = "Unable to open the Delhivery Settlement report";
|
|
|
769 |
logger.error(errMsg, e);
|
|
|
770 |
addActionError(errMsg);
|
|
|
771 |
return;
|
|
|
772 |
}
|
|
|
773 |
|
|
|
774 |
Sheet sheet = wb.getSheetAt(0);
|
|
|
775 |
|
|
|
776 |
int indexAWB = 1;
|
|
|
777 |
int indexAmount = 13;
|
|
|
778 |
|
|
|
779 |
TransactionClient tsc;
|
|
|
780 |
int countSuccessfulSaves = 0;
|
|
|
781 |
try {
|
|
|
782 |
long settlementDate = DATE_FORMAT.parse(delhiverySettlementDate).getTime();
|
|
|
783 |
|
|
|
784 |
tsc = new TransactionClient();
|
|
|
785 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
|
|
786 |
|
|
|
787 |
for (Row row: sheet) {
|
|
|
788 |
if(row.getRowNum() < 9) {
|
| 5343 |
phani.kuma |
789 |
continue;
|
|
|
790 |
}
|
| 5481 |
phani.kuma |
791 |
|
|
|
792 |
if(row.getCell(indexAWB) == null) {
|
|
|
793 |
continue;
|
|
|
794 |
}
|
|
|
795 |
|
|
|
796 |
long awb = -1;
|
| 5343 |
phani.kuma |
797 |
|
| 5481 |
phani.kuma |
798 |
try {
|
|
|
799 |
if(row.getCell(indexAWB).getCellType() == 0) {
|
|
|
800 |
awb = (long) row.getCell(indexAWB).getNumericCellValue();
|
|
|
801 |
}
|
|
|
802 |
else if(row.getCell(indexAWB).getCellType() == 1) {
|
|
|
803 |
awb = Long.parseLong(row.getCell(indexAWB).getStringCellValue());
|
|
|
804 |
}
|
|
|
805 |
|
|
|
806 |
if(awb == -1) {
|
|
|
807 |
continue;
|
|
|
808 |
}
|
|
|
809 |
|
| 5108 |
varun.gupt |
810 |
long orderId = transactionClient.getOrderForAwb(Long.toString(awb)).getId();
|
|
|
811 |
double amount = row.getCell(indexAmount).getNumericCellValue();
|
| 5481 |
phani.kuma |
812 |
logger.info("Delhivery Settlement, Order Id: " + orderId + " Amount: " + amount);
|
| 5108 |
varun.gupt |
813 |
|
| 4907 |
varun.gupt |
814 |
transactionClient.savePaymentSettlements(settlementDate, 4, orderId, 0.0, 0.0, amount);
|
| 4734 |
varun.gupt |
815 |
countSuccessfulSaves += 1;
|
| 4715 |
varun.gupt |
816 |
|
|
|
817 |
} catch (TransactionServiceException e) {
|
| 5108 |
varun.gupt |
818 |
logger.error("Transaction Service Exception while getting order for AWB, " + awb, e);
|
|
|
819 |
addActionError("Transaction Service Exception while getting order for AWB, " + awb);
|
| 5481 |
phani.kuma |
820 |
} catch (Exception e) {
|
|
|
821 |
String errMsg = "Exception recieved for AWB," + awb;
|
|
|
822 |
logger.error(errMsg, e);
|
|
|
823 |
addActionError(errMsg);
|
| 4715 |
varun.gupt |
824 |
}
|
|
|
825 |
}
|
|
|
826 |
} catch (ParseException e) {
|
| 5481 |
phani.kuma |
827 |
String errMsg = "Could not parse " + delhiverySettlementDate;
|
| 5386 |
phani.kuma |
828 |
logger.error(errMsg, e);
|
|
|
829 |
addActionError(errMsg);
|
|
|
830 |
} catch (Exception e) {
|
|
|
831 |
String errMsg = e.getMessage();
|
|
|
832 |
logger.error(errMsg, e);
|
|
|
833 |
addActionError(errMsg);
|
| 4715 |
varun.gupt |
834 |
}
|
| 5481 |
phani.kuma |
835 |
addActionMessage("Successfully added Delhivery settlement details for " + countSuccessfulSaves + " orders");
|
| 4715 |
varun.gupt |
836 |
}
|
|
|
837 |
|
| 5098 |
varun.gupt |
838 |
public void uploadOrderIdsToBeMarkedPaid() {
|
|
|
839 |
logger.info("Uploading Order Ids to be marked as paid");
|
| 5189 |
varun.gupt |
840 |
List<Long> orderIds = new ArrayList<Long>();
|
|
|
841 |
|
|
|
842 |
try {
|
| 5386 |
phani.kuma |
843 |
FileInputStream uploadedFile = new FileInputStream(this.orderIdsToBeMarked);
|
| 5189 |
varun.gupt |
844 |
String uploadedContent = IOUtils.toString(uploadedFile);
|
|
|
845 |
|
|
|
846 |
for(String s: uploadedContent.trim().split("\n")) {
|
|
|
847 |
|
| 5386 |
phani.kuma |
848 |
if(! s.trim().isEmpty()) {
|
|
|
849 |
orderIds.add(Long.parseLong(s));
|
|
|
850 |
}
|
| 5189 |
varun.gupt |
851 |
}
|
|
|
852 |
} catch (FileNotFoundException e) {
|
| 5386 |
phani.kuma |
853 |
String errMsg = "Unable to open the sheet containing orders for which vendor is paid";
|
|
|
854 |
logger.error(errMsg, e);
|
|
|
855 |
addActionError(errMsg);
|
|
|
856 |
return;
|
| 5189 |
varun.gupt |
857 |
} catch (IOException e) {
|
| 5386 |
phani.kuma |
858 |
String errMsg = "IOException occured while reading the file containing orders for which vendor is paid";
|
|
|
859 |
logger.error(errMsg, e);
|
|
|
860 |
addActionError(errMsg);
|
|
|
861 |
return;
|
| 5098 |
varun.gupt |
862 |
}
|
| 5189 |
varun.gupt |
863 |
|
| 5098 |
varun.gupt |
864 |
TransactionClient tsc;
|
|
|
865 |
int countSuccessfulSaves = 0;
|
|
|
866 |
|
| 5189 |
varun.gupt |
867 |
try {
|
|
|
868 |
tsc = new TransactionClient();
|
|
|
869 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
|
|
870 |
|
|
|
871 |
for (long orderId: orderIds) {
|
|
|
872 |
|
| 5198 |
varun.gupt |
873 |
logger.info("Marking as paid, Order Id: " + orderId);
|
| 5189 |
varun.gupt |
874 |
try {
|
| 5386 |
phani.kuma |
875 |
transactionClient.updateOrderOnlyAsPaidToVendor(orderId);
|
| 5189 |
varun.gupt |
876 |
countSuccessfulSaves += 1;
|
|
|
877 |
|
|
|
878 |
} catch (TransactionServiceException e) {
|
|
|
879 |
logger.error("Transaction Service Exception while getting order for id, " + orderId, e);
|
|
|
880 |
addActionError("Transaction Service Exception while getting order for id, " + orderId);
|
|
|
881 |
}
|
|
|
882 |
}
|
| 5386 |
phani.kuma |
883 |
} catch (Exception e) {
|
|
|
884 |
String errMsg = e.getMessage();
|
|
|
885 |
logger.error(errMsg, e);
|
|
|
886 |
addActionError(errMsg);
|
|
|
887 |
}
|
| 5098 |
varun.gupt |
888 |
addActionMessage("Successfully marked " + countSuccessfulSaves + " orders as paid to vendor");
|
|
|
889 |
}
|
|
|
890 |
|
| 5386 |
phani.kuma |
891 |
public void uploadOrderIdsToBeMarkedReturned() {
|
|
|
892 |
logger.info("Uploading Order Ids to be marked as Returned");
|
|
|
893 |
List<Long> orderIds = new ArrayList<Long>();
|
| 4875 |
varun.gupt |
894 |
|
| 5386 |
phani.kuma |
895 |
try {
|
|
|
896 |
FileInputStream uploadedFile = new FileInputStream(this.orderIdsToBeMarked);
|
|
|
897 |
String uploadedContent = IOUtils.toString(uploadedFile);
|
|
|
898 |
|
|
|
899 |
for(String s: uploadedContent.trim().split("\n")) {
|
|
|
900 |
|
|
|
901 |
if(! s.trim().isEmpty()) {
|
|
|
902 |
orderIds.add(Long.parseLong(s));
|
|
|
903 |
}
|
|
|
904 |
}
|
|
|
905 |
} catch (FileNotFoundException e) {
|
|
|
906 |
String errMsg = "Unable to open the sheet containing returned orders to be marked";
|
|
|
907 |
logger.error(errMsg, e);
|
|
|
908 |
addActionError(errMsg);
|
|
|
909 |
return;
|
|
|
910 |
} catch (IOException e) {
|
|
|
911 |
String errMsg = "IOException occured while reading the file containing returned orders to be marked";
|
|
|
912 |
logger.error(errMsg, e);
|
|
|
913 |
addActionError(errMsg);
|
|
|
914 |
return;
|
|
|
915 |
}
|
|
|
916 |
|
|
|
917 |
TransactionClient tsc;
|
|
|
918 |
int countSuccessfulSaves = 0;
|
|
|
919 |
|
|
|
920 |
try {
|
|
|
921 |
tsc = new TransactionClient();
|
|
|
922 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
|
|
923 |
|
|
|
924 |
for (long orderId: orderIds) {
|
|
|
925 |
|
|
|
926 |
logger.info("Marking as Returned, Order Id: " + orderId);
|
|
|
927 |
try {
|
|
|
928 |
transactionClient.processReturn(orderId);
|
|
|
929 |
countSuccessfulSaves += 1;
|
|
|
930 |
|
|
|
931 |
} catch (TransactionServiceException e) {
|
|
|
932 |
String errMsg = "Transaction Service Exception while getting order for id, " + orderId;
|
|
|
933 |
logger.error(errMsg, e);
|
|
|
934 |
addActionError(errMsg);
|
|
|
935 |
}
|
|
|
936 |
}
|
|
|
937 |
} catch (Exception e) {
|
|
|
938 |
String errMsg = e.getMessage();
|
|
|
939 |
logger.error(errMsg, e);
|
|
|
940 |
addActionError(errMsg);
|
|
|
941 |
}
|
|
|
942 |
addActionMessage("Successfully marked " + countSuccessfulSaves + " orders as returned to vendor");
|
|
|
943 |
}
|
|
|
944 |
|
| 5481 |
phani.kuma |
945 |
private ByteArrayOutputStream getReconciliationReport(long vendorId, long fromTime, long toTime, boolean notall) {
|
| 5386 |
phani.kuma |
946 |
ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
|
|
|
947 |
|
|
|
948 |
try {
|
| 5481 |
phani.kuma |
949 |
|
| 6387 |
amar.kumar |
950 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
951 |
Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
952 |
List<Vendor> vendors = inventoryClient.getAllVendors();
|
|
|
953 |
vendorIdNameMap = new Hashtable<Long, String>();
|
|
|
954 |
for(Vendor vendor : vendors){
|
|
|
955 |
vendorIdNameMap.put(vendor.getId(), vendor.getName());
|
|
|
956 |
}
|
|
|
957 |
|
| 4745 |
varun.gupt |
958 |
TransactionClient tsc = new TransactionClient();
|
|
|
959 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
| 5386 |
phani.kuma |
960 |
|
| 5481 |
phani.kuma |
961 |
List<Order> unpaidOrders = transactionClient.getBilledOrders(vendorId, notall, fromTime, toTime);
|
| 5189 |
varun.gupt |
962 |
logger.info("Unpaid Order count: " + unpaidOrders.size());
|
| 4905 |
varun.gupt |
963 |
|
| 5386 |
phani.kuma |
964 |
List<ReturnOrder> returns = new ArrayList<ReturnOrder>();
|
| 4745 |
varun.gupt |
965 |
|
| 5386 |
phani.kuma |
966 |
try {
|
| 5481 |
phani.kuma |
967 |
returns = transactionClient.getAllReturnOrders(notall, fromTime, toTime);
|
| 5386 |
phani.kuma |
968 |
} catch (TTransportException e) {
|
|
|
969 |
tsc = new TransactionClient();
|
|
|
970 |
transactionClient = tsc.getClient();
|
| 5481 |
phani.kuma |
971 |
returns = transactionClient.getAllReturnOrders(notall, fromTime, toTime);
|
| 5386 |
phani.kuma |
972 |
}
|
|
|
973 |
|
|
|
974 |
Map<Long, ReturnOrder> mapReturnOrderIds = new HashMap<Long, ReturnOrder>();
|
|
|
975 |
|
|
|
976 |
for (ReturnOrder returnOrder: returns)
|
|
|
977 |
{
|
|
|
978 |
mapReturnOrderIds.put(returnOrder.getOrderId(), returnOrder);
|
|
|
979 |
}
|
|
|
980 |
|
|
|
981 |
List<Long> ReturnOrderIds = new ArrayList<Long>(mapReturnOrderIds.keySet());
|
|
|
982 |
|
|
|
983 |
List<Order> listofreturnedOrders = new ArrayList<Order>();
|
|
|
984 |
|
|
|
985 |
try {
|
|
|
986 |
listofreturnedOrders = transactionClient.getOrderListForVendor(ReturnOrderIds, vendorId);
|
|
|
987 |
} catch (TTransportException e) {
|
|
|
988 |
tsc = new TransactionClient();
|
|
|
989 |
transactionClient = tsc.getClient();
|
|
|
990 |
listofreturnedOrders = transactionClient.getOrderListForVendor(ReturnOrderIds, vendorId);
|
|
|
991 |
}
|
|
|
992 |
|
|
|
993 |
for (Order order: listofreturnedOrders)
|
|
|
994 |
{
|
|
|
995 |
order.setDelivery_timestamp(mapReturnOrderIds.get(order.getId()).getCreatedAt());
|
| 5481 |
phani.kuma |
996 |
order.setVendorPaid(mapReturnOrderIds.get(order.getId()).isProcessedStatus());
|
| 5386 |
phani.kuma |
997 |
returnedOrders.add(order);
|
|
|
998 |
}
|
|
|
999 |
|
|
|
1000 |
Set<Long> OriginalOrderIds = new HashSet<Long>();
|
|
|
1001 |
Map<Long, Order> mapUnpaidOrders = new HashMap<Long, Order>();
|
|
|
1002 |
|
|
|
1003 |
for (Order order: unpaidOrders)
|
|
|
1004 |
{
|
|
|
1005 |
if(order.getOriginalOrderId() == 0) {
|
|
|
1006 |
OriginalOrderIds.add(order.getId());
|
|
|
1007 |
}
|
|
|
1008 |
else {
|
|
|
1009 |
OriginalOrderIds.add(order.getOriginalOrderId());
|
|
|
1010 |
}
|
|
|
1011 |
mapUnpaidOrders.put(order.getId(), order);
|
|
|
1012 |
}
|
|
|
1013 |
|
|
|
1014 |
List<Order> reshippedPayableOrders = new ArrayList<Order>();
|
|
|
1015 |
List<Order> originalPayableOrders_user = new ArrayList<Order>();
|
|
|
1016 |
List<Order> originalPayableOrders_nouser = new ArrayList<Order>();
|
|
|
1017 |
|
|
|
1018 |
Order originalOrder = null;
|
|
|
1019 |
boolean originalOrderUnpaid = false;
|
|
|
1020 |
Order tempOrder = null;
|
|
|
1021 |
boolean tempOrderUnpaid = false;
|
|
|
1022 |
long nextOrderId = 0;
|
|
|
1023 |
String previous_invoice_number = "";
|
|
|
1024 |
|
|
|
1025 |
for (long originalOrderId: OriginalOrderIds)
|
|
|
1026 |
{
|
|
|
1027 |
originalOrder = null;
|
|
|
1028 |
originalOrderUnpaid = false;
|
|
|
1029 |
tempOrder = null;
|
|
|
1030 |
tempOrderUnpaid = false;
|
|
|
1031 |
nextOrderId = originalOrderId;
|
|
|
1032 |
previous_invoice_number = "";
|
| 5189 |
varun.gupt |
1033 |
|
| 5386 |
phani.kuma |
1034 |
while (true)
|
|
|
1035 |
{
|
|
|
1036 |
if(mapUnpaidOrders.containsKey(nextOrderId)) {
|
|
|
1037 |
tempOrder = mapUnpaidOrders.get(nextOrderId);
|
|
|
1038 |
tempOrderUnpaid = true;
|
|
|
1039 |
}
|
|
|
1040 |
else {
|
|
|
1041 |
try {
|
|
|
1042 |
tempOrder = transactionClient.getOrder(nextOrderId);
|
|
|
1043 |
} catch (TTransportException e) {
|
|
|
1044 |
tsc = new TransactionClient();
|
|
|
1045 |
transactionClient = tsc.getClient();
|
|
|
1046 |
tempOrder = transactionClient.getOrder(nextOrderId);
|
|
|
1047 |
}
|
|
|
1048 |
tempOrderUnpaid = false;
|
|
|
1049 |
}
|
| 5189 |
varun.gupt |
1050 |
|
| 5386 |
phani.kuma |
1051 |
if(tempOrderUnpaid && nextOrderId != originalOrderId) {
|
|
|
1052 |
if(previous_invoice_number.equals(tempOrder.getInvoice_number())) {
|
|
|
1053 |
reshippedNonPayableOrders.add(tempOrder);
|
|
|
1054 |
}
|
|
|
1055 |
else {
|
|
|
1056 |
reshippedPayableOrders.add(tempOrder);
|
|
|
1057 |
}
|
|
|
1058 |
}
|
| 5189 |
varun.gupt |
1059 |
|
| 5386 |
phani.kuma |
1060 |
if(tempOrderUnpaid && nextOrderId == originalOrderId) {
|
|
|
1061 |
originalOrder = tempOrder;
|
|
|
1062 |
originalOrderUnpaid = true;
|
|
|
1063 |
}
|
| 5189 |
varun.gupt |
1064 |
|
| 5386 |
phani.kuma |
1065 |
nextOrderId = tempOrder.getNew_order_id();
|
|
|
1066 |
previous_invoice_number = tempOrder.getInvoice_number();
|
|
|
1067 |
if(nextOrderId == 0) {
|
|
|
1068 |
if(originalOrderUnpaid) {
|
|
|
1069 |
if(refundOrderStatuses.contains(tempOrder.getStatus())) {
|
|
|
1070 |
originalPayableOrders_nouser.add(originalOrder);
|
|
|
1071 |
}
|
|
|
1072 |
else {
|
|
|
1073 |
originalPayableOrders_user.add(originalOrder);
|
|
|
1074 |
}
|
|
|
1075 |
}
|
|
|
1076 |
break;
|
|
|
1077 |
}
|
| 5189 |
varun.gupt |
1078 |
}
|
|
|
1079 |
}
|
|
|
1080 |
|
| 5386 |
phani.kuma |
1081 |
PaymentClient psc = new PaymentClient();
|
|
|
1082 |
in.shop2020.payments.PaymentService.Client paymentClient = psc.getClient();
|
|
|
1083 |
|
|
|
1084 |
PaymentSettlement pmtSettlement = null;
|
|
|
1085 |
Payment payment = null;
|
|
|
1086 |
|
|
|
1087 |
for (Order UserpayRequiredOrder: originalPayableOrders_user)
|
|
|
1088 |
{
|
| 5189 |
varun.gupt |
1089 |
try {
|
| 5386 |
phani.kuma |
1090 |
pmtSettlement = null;
|
| 5189 |
varun.gupt |
1091 |
|
| 5386 |
phani.kuma |
1092 |
if(UserpayRequiredOrder.isCod()) {
|
|
|
1093 |
try {
|
|
|
1094 |
pmtSettlement = transactionClient.getSettlementForCod(UserpayRequiredOrder.getId(), false);
|
|
|
1095 |
} catch (TTransportException e) {
|
|
|
1096 |
tsc = new TransactionClient();
|
|
|
1097 |
transactionClient = tsc.getClient();
|
|
|
1098 |
pmtSettlement = transactionClient.getSettlementForCod(UserpayRequiredOrder.getId(), false);
|
|
|
1099 |
}
|
| 5189 |
varun.gupt |
1100 |
|
| 5386 |
phani.kuma |
1101 |
if(pmtSettlement.getReferenceId() > 0) {
|
|
|
1102 |
paymentSettledOrdersMap.put(UserpayRequiredOrder, pmtSettlement);
|
| 5189 |
varun.gupt |
1103 |
}
|
| 5386 |
phani.kuma |
1104 |
else {
|
|
|
1105 |
unsettledOrders.add(UserpayRequiredOrder);
|
|
|
1106 |
}
|
|
|
1107 |
}
|
|
|
1108 |
else {
|
|
|
1109 |
payment = null;
|
| 5189 |
varun.gupt |
1110 |
|
| 5386 |
phani.kuma |
1111 |
try {
|
|
|
1112 |
payment = paymentClient.getSuccessfulPaymentForTxnId(UserpayRequiredOrder.getTransactionId());
|
|
|
1113 |
} catch (TTransportException e) {
|
|
|
1114 |
psc = new PaymentClient();
|
|
|
1115 |
paymentClient = psc.getClient();
|
|
|
1116 |
payment = paymentClient.getSuccessfulPaymentForTxnId(UserpayRequiredOrder.getTransactionId());
|
| 5189 |
varun.gupt |
1117 |
}
|
|
|
1118 |
|
| 5386 |
phani.kuma |
1119 |
try {
|
|
|
1120 |
pmtSettlement = transactionClient.getSettlementForPrepaid(payment.getPaymentId(), false);
|
|
|
1121 |
} catch (TTransportException e) {
|
|
|
1122 |
tsc = new TransactionClient();
|
|
|
1123 |
transactionClient = tsc.getClient();
|
|
|
1124 |
pmtSettlement = transactionClient.getSettlementForPrepaid(payment.getPaymentId(), false);
|
| 5189 |
varun.gupt |
1125 |
}
|
|
|
1126 |
|
| 5386 |
phani.kuma |
1127 |
if(pmtSettlement.getReferenceId() > 0) {
|
|
|
1128 |
paymentSettledOrdersMap.put(UserpayRequiredOrder, pmtSettlement);
|
| 5189 |
varun.gupt |
1129 |
}
|
| 5386 |
phani.kuma |
1130 |
else {
|
|
|
1131 |
unsettledOrders.add(UserpayRequiredOrder);
|
|
|
1132 |
}
|
| 5189 |
varun.gupt |
1133 |
}
|
| 5386 |
phani.kuma |
1134 |
} catch (Exception e) {
|
|
|
1135 |
ordersWithErrors.add(UserpayRequiredOrder);
|
|
|
1136 |
String errMsg = "error occured in getReconciliationReport during " + UserpayRequiredOrder.getId();
|
|
|
1137 |
logger.error(errMsg, e);
|
|
|
1138 |
addActionError(errMsg);
|
| 5189 |
varun.gupt |
1139 |
}
|
|
|
1140 |
}
|
|
|
1141 |
|
| 5386 |
phani.kuma |
1142 |
userPaymentNotRequiredOrders.addAll(originalPayableOrders_nouser);
|
|
|
1143 |
logger.info("No User Payment Required Original Orders Count: " + originalPayableOrders_nouser.size());
|
|
|
1144 |
userPaymentNotRequiredOrders.addAll(reshippedPayableOrders);
|
|
|
1145 |
logger.info("Reshipped Payable Orders Count: " + reshippedPayableOrders.size());
|
|
|
1146 |
logger.info("Payment Settlement Count: " + paymentSettledOrdersMap.keySet().size());
|
|
|
1147 |
logger.info("Unsettled Orders Count: " + unsettledOrders.size());
|
|
|
1148 |
logger.info("User Payment Not Required Orders Count: " + userPaymentNotRequiredOrders.size());
|
|
|
1149 |
logger.info("Reshipped Orders Count: " + reshippedNonPayableOrders.size());
|
|
|
1150 |
logger.info("Returned Orders Count: " + returnedOrders.size());
|
|
|
1151 |
|
|
|
1152 |
Workbook wb = new HSSFWorkbook();
|
|
|
1153 |
|
|
|
1154 |
Sheet totalPayableOrderSheet = wb.createSheet("Total Payable Orders");
|
|
|
1155 |
Sheet settledOrderSheet = wb.createSheet("Settled Payable Orders");
|
|
|
1156 |
Sheet unsettledOrderSheet = wb.createSheet("Unsettled Payable Orders");
|
|
|
1157 |
Sheet returnedOrderSheet = wb.createSheet("Receivable Orders");
|
|
|
1158 |
Sheet reshippedOrderSheet = wb.createSheet("Reshipped Non Payable Orders");
|
|
|
1159 |
Sheet errorOrderSheet = wb.createSheet("Orders With Errors");
|
|
|
1160 |
|
|
|
1161 |
populateSettledOrderSheet(totalPayableOrderSheet, true);
|
|
|
1162 |
populateSettledOrderSheet(settledOrderSheet, false);
|
|
|
1163 |
populateUnsettledOrderSheet(unsettledOrderSheet);
|
|
|
1164 |
populateReturnedOrderSheet(returnedOrderSheet);
|
|
|
1165 |
populateReshippedOrderSheet(reshippedOrderSheet);
|
|
|
1166 |
populateErrorOrderSheet(errorOrderSheet);
|
|
|
1167 |
|
|
|
1168 |
wb.write(baosXLS);
|
|
|
1169 |
baosXLS.close();
|
|
|
1170 |
|
|
|
1171 |
} catch (Exception e) {
|
|
|
1172 |
String errMsg = e.getMessage();
|
| 4745 |
varun.gupt |
1173 |
logger.error(errMsg, e);
|
|
|
1174 |
addActionError(errMsg);
|
|
|
1175 |
}
|
|
|
1176 |
|
| 4600 |
varun.gupt |
1177 |
return baosXLS;
|
|
|
1178 |
}
|
|
|
1179 |
|
| 5386 |
phani.kuma |
1180 |
private void populateErrorOrderSheet(Sheet sheet) {
|
|
|
1181 |
int rowCount = 0;
|
|
|
1182 |
|
|
|
1183 |
Row headerRow = sheet.createRow(rowCount ++);
|
|
|
1184 |
headerRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue("Order Id");
|
|
|
1185 |
headerRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue("Original Order Id");
|
|
|
1186 |
headerRow.createCell(OrderReportColumn.VENDOR_ID.getValue()).setCellValue("Vendor Id");
|
| 6387 |
amar.kumar |
1187 |
headerRow.createCell(OrderReportColumn.VENDOR_NAME.getValue()).setCellValue("Vendor Name");
|
| 5386 |
phani.kuma |
1188 |
headerRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue("Order Date");
|
|
|
1189 |
headerRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue("Billing Number");
|
|
|
1190 |
headerRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue("Billing Date");
|
|
|
1191 |
headerRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue("Returned Date");
|
|
|
1192 |
headerRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue("Brand");
|
|
|
1193 |
headerRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue("Model Name");
|
|
|
1194 |
headerRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue("Model Number");
|
|
|
1195 |
headerRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue("Color");
|
|
|
1196 |
headerRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue("Quantity");
|
|
|
1197 |
headerRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue("Unit Transfer Price");
|
|
|
1198 |
headerRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue("Unit Selling Price");
|
|
|
1199 |
headerRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue("Total Transfer Price");
|
|
|
1200 |
headerRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue("Total Selling Price");
|
|
|
1201 |
headerRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue("Current Status");
|
| 5481 |
phani.kuma |
1202 |
headerRow.createCell(OrderReportColumn.VENDOR_PAID.getValue()).setCellValue("Vendor Paid");
|
| 4600 |
varun.gupt |
1203 |
|
| 5386 |
phani.kuma |
1204 |
try {
|
|
|
1205 |
|
|
|
1206 |
Row contentRow = null;
|
|
|
1207 |
LineItem lineItem = null;
|
|
|
1208 |
|
|
|
1209 |
for (Order order: ordersWithErrors)
|
|
|
1210 |
{
|
|
|
1211 |
contentRow = sheet.createRow(rowCount ++);
|
|
|
1212 |
lineItem = order.getLineitems().get(0);
|
|
|
1213 |
|
|
|
1214 |
contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
|
|
1215 |
if(order.getOriginalOrderId() == 0) {
|
|
|
1216 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getId());
|
|
|
1217 |
}
|
|
|
1218 |
else {
|
|
|
1219 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getOriginalOrderId());
|
|
|
1220 |
}
|
|
|
1221 |
contentRow.createCell(OrderReportColumn.VENDOR_ID.getValue()).setCellValue(order.getVendorId());
|
| 6387 |
amar.kumar |
1222 |
contentRow.createCell(OrderReportColumn.VENDOR_NAME.getValue()).setCellValue(vendorIdNameMap.get(order.getVendorId()));
|
| 5386 |
phani.kuma |
1223 |
contentRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getCreated_timestamp())));
|
|
|
1224 |
contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
|
|
|
1225 |
contentRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getBilling_timestamp())));
|
|
|
1226 |
contentRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getDelivery_timestamp())));
|
|
|
1227 |
contentRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
|
|
|
1228 |
contentRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
|
|
|
1229 |
contentRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
|
|
|
1230 |
contentRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
|
|
|
1231 |
contentRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue(lineItem.getQuantity());
|
|
|
1232 |
contentRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price());
|
|
|
1233 |
contentRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue(lineItem.getUnit_price());
|
|
|
1234 |
contentRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price() * lineItem.getQuantity());
|
|
|
1235 |
contentRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue(lineItem.getTotal_price());
|
|
|
1236 |
contentRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue(order.getStatus().name());
|
| 5481 |
phani.kuma |
1237 |
contentRow.createCell(OrderReportColumn.VENDOR_PAID.getValue()).setCellValue(order.isVendorPaid());
|
| 5386 |
phani.kuma |
1238 |
}
|
|
|
1239 |
} catch (Exception e) {
|
|
|
1240 |
String errMsg = e.getMessage();
|
|
|
1241 |
logger.error(errMsg, e);
|
|
|
1242 |
addActionError(errMsg);
|
|
|
1243 |
}
|
| 4600 |
varun.gupt |
1244 |
}
|
|
|
1245 |
|
| 5386 |
phani.kuma |
1246 |
private void populateReturnedOrderSheet(Sheet sheet) {
|
|
|
1247 |
int rowCount = 0;
|
|
|
1248 |
|
|
|
1249 |
Row headerRow = sheet.createRow(rowCount ++);
|
| 4875 |
varun.gupt |
1250 |
headerRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue("Order Id");
|
| 5386 |
phani.kuma |
1251 |
headerRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue("Original Order Id");
|
|
|
1252 |
headerRow.createCell(OrderReportColumn.VENDOR_ID.getValue()).setCellValue("Vendor Id");
|
| 6387 |
amar.kumar |
1253 |
headerRow.createCell(OrderReportColumn.VENDOR_NAME.getValue()).setCellValue("Vendor Name");
|
| 4875 |
varun.gupt |
1254 |
headerRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue("Order Date");
|
|
|
1255 |
headerRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue("Billing Number");
|
|
|
1256 |
headerRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue("Billing Date");
|
| 5386 |
phani.kuma |
1257 |
headerRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue("Returned Date");
|
| 4875 |
varun.gupt |
1258 |
headerRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue("Brand");
|
|
|
1259 |
headerRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue("Model Name");
|
|
|
1260 |
headerRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue("Model Number");
|
|
|
1261 |
headerRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue("Color");
|
|
|
1262 |
headerRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue("Quantity");
|
|
|
1263 |
headerRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue("Unit Transfer Price");
|
|
|
1264 |
headerRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue("Unit Selling Price");
|
|
|
1265 |
headerRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue("Total Transfer Price");
|
|
|
1266 |
headerRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue("Total Selling Price");
|
|
|
1267 |
headerRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue("Current Status");
|
| 5481 |
phani.kuma |
1268 |
headerRow.createCell(OrderReportColumn.VENDOR_PAID.getValue()).setCellValue("Processed");
|
| 4875 |
varun.gupt |
1269 |
|
| 5386 |
phani.kuma |
1270 |
try {
|
|
|
1271 |
|
|
|
1272 |
Row contentRow = null;
|
|
|
1273 |
LineItem lineItem = null;
|
|
|
1274 |
|
|
|
1275 |
for (Order order: returnedOrders)
|
|
|
1276 |
{
|
|
|
1277 |
contentRow = sheet.createRow(rowCount ++);
|
|
|
1278 |
lineItem = order.getLineitems().get(0);
|
|
|
1279 |
|
|
|
1280 |
contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
|
|
1281 |
if(order.getOriginalOrderId() == 0) {
|
|
|
1282 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getId());
|
| 4875 |
varun.gupt |
1283 |
}
|
| 5386 |
phani.kuma |
1284 |
else {
|
|
|
1285 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getOriginalOrderId());
|
|
|
1286 |
}
|
|
|
1287 |
contentRow.createCell(OrderReportColumn.VENDOR_ID.getValue()).setCellValue(order.getVendorId());
|
| 6387 |
amar.kumar |
1288 |
contentRow.createCell(OrderReportColumn.VENDOR_NAME.getValue()).setCellValue(vendorIdNameMap.get(order.getVendorId()));
|
| 5386 |
phani.kuma |
1289 |
contentRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getCreated_timestamp())));
|
| 4875 |
varun.gupt |
1290 |
contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
|
|
|
1291 |
contentRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getBilling_timestamp())));
|
|
|
1292 |
contentRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getDelivery_timestamp())));
|
|
|
1293 |
contentRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
|
|
|
1294 |
contentRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
|
|
|
1295 |
contentRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
|
|
|
1296 |
contentRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
|
|
|
1297 |
contentRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue(lineItem.getQuantity());
|
| 5386 |
phani.kuma |
1298 |
contentRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price());
|
| 4875 |
varun.gupt |
1299 |
contentRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue(lineItem.getUnit_price());
|
| 5386 |
phani.kuma |
1300 |
contentRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price() * lineItem.getQuantity());
|
|
|
1301 |
contentRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue(lineItem.getTotal_price());
|
|
|
1302 |
contentRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue(order.getStatus().name());
|
| 5481 |
phani.kuma |
1303 |
contentRow.createCell(OrderReportColumn.VENDOR_PAID.getValue()).setCellValue(order.isVendorPaid());
|
| 5386 |
phani.kuma |
1304 |
}
|
|
|
1305 |
} catch (Exception e) {
|
|
|
1306 |
String errMsg = e.getMessage();
|
|
|
1307 |
logger.error(errMsg, e);
|
|
|
1308 |
addActionError(errMsg);
|
| 4875 |
varun.gupt |
1309 |
}
|
|
|
1310 |
}
|
|
|
1311 |
|
| 5386 |
phani.kuma |
1312 |
private void populateReshippedOrderSheet(Sheet sheet) {
|
|
|
1313 |
int rowCount = 0;
|
| 5020 |
varun.gupt |
1314 |
|
| 5189 |
varun.gupt |
1315 |
Row headerRow = sheet.createRow(rowCount ++);
|
|
|
1316 |
headerRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue("Order Id");
|
| 5386 |
phani.kuma |
1317 |
headerRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue("Original Order Id");
|
|
|
1318 |
headerRow.createCell(OrderReportColumn.VENDOR_ID.getValue()).setCellValue("Vendor Id");
|
| 6387 |
amar.kumar |
1319 |
headerRow.createCell(OrderReportColumn.VENDOR_NAME.getValue()).setCellValue("Vendor Name");
|
| 5189 |
varun.gupt |
1320 |
headerRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue("Order Date");
|
|
|
1321 |
headerRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue("Billing Number");
|
|
|
1322 |
headerRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue("Billing Date");
|
|
|
1323 |
headerRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue("Delivery Date");
|
|
|
1324 |
headerRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue("Brand");
|
|
|
1325 |
headerRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue("Model Name");
|
|
|
1326 |
headerRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue("Model Number");
|
|
|
1327 |
headerRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue("Color");
|
|
|
1328 |
headerRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue("Quantity");
|
|
|
1329 |
headerRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue("Unit Transfer Price");
|
|
|
1330 |
headerRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue("Unit Selling Price");
|
|
|
1331 |
headerRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue("Total Transfer Price");
|
|
|
1332 |
headerRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue("Total Selling Price");
|
|
|
1333 |
headerRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue("Current Status");
|
| 5481 |
phani.kuma |
1334 |
headerRow.createCell(OrderReportColumn.VENDOR_PAID.getValue()).setCellValue("Vendor Paid");
|
| 5189 |
varun.gupt |
1335 |
|
|
|
1336 |
try {
|
| 5386 |
phani.kuma |
1337 |
|
|
|
1338 |
Row contentRow = null;
|
|
|
1339 |
LineItem lineItem = null;
|
|
|
1340 |
|
|
|
1341 |
for (Order order: reshippedNonPayableOrders)
|
|
|
1342 |
{
|
|
|
1343 |
contentRow = sheet.createRow(rowCount ++);
|
|
|
1344 |
lineItem = order.getLineitems().get(0);
|
| 5189 |
varun.gupt |
1345 |
|
| 5386 |
phani.kuma |
1346 |
contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
|
|
1347 |
if(order.getOriginalOrderId() == 0) {
|
|
|
1348 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getId());
|
| 5189 |
varun.gupt |
1349 |
}
|
| 5386 |
phani.kuma |
1350 |
else {
|
|
|
1351 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getOriginalOrderId());
|
|
|
1352 |
}
|
|
|
1353 |
contentRow.createCell(OrderReportColumn.VENDOR_ID.getValue()).setCellValue(order.getVendorId());
|
| 6387 |
amar.kumar |
1354 |
contentRow.createCell(OrderReportColumn.VENDOR_NAME.getValue()).setCellValue(vendorIdNameMap.get(order.getVendorId()));
|
| 5189 |
varun.gupt |
1355 |
contentRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getCreated_timestamp())));
|
|
|
1356 |
contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
|
|
|
1357 |
contentRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getBilling_timestamp())));
|
| 5386 |
phani.kuma |
1358 |
if(order.getDelivery_timestamp() != 0) {
|
|
|
1359 |
contentRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getDelivery_timestamp())));
|
|
|
1360 |
}
|
| 5189 |
varun.gupt |
1361 |
contentRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
|
|
|
1362 |
contentRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
|
|
|
1363 |
contentRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
|
|
|
1364 |
contentRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
|
|
|
1365 |
contentRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue(lineItem.getQuantity());
|
|
|
1366 |
contentRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price());
|
|
|
1367 |
contentRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue(lineItem.getUnit_price());
|
|
|
1368 |
contentRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price() * lineItem.getQuantity());
|
|
|
1369 |
contentRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue(lineItem.getTotal_price());
|
|
|
1370 |
contentRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue(order.getStatusDescription());
|
| 5481 |
phani.kuma |
1371 |
contentRow.createCell(OrderReportColumn.VENDOR_PAID.getValue()).setCellValue(order.isVendorPaid());
|
| 5189 |
varun.gupt |
1372 |
}
|
|
|
1373 |
} catch (Exception e) {
|
| 5386 |
phani.kuma |
1374 |
String errMsg = e.getMessage();
|
|
|
1375 |
logger.error(errMsg, e);
|
|
|
1376 |
addActionError(errMsg);
|
| 5189 |
varun.gupt |
1377 |
}
|
|
|
1378 |
}
|
|
|
1379 |
|
| 5386 |
phani.kuma |
1380 |
private void populateUnsettledOrderSheet(Sheet sheet) {
|
|
|
1381 |
int rowCount = 0;
|
| 5189 |
varun.gupt |
1382 |
|
| 5020 |
varun.gupt |
1383 |
Row headerRow = sheet.createRow(rowCount ++);
|
| 4600 |
varun.gupt |
1384 |
headerRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue("Order Id");
|
| 5386 |
phani.kuma |
1385 |
headerRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue("Original Order Id");
|
|
|
1386 |
headerRow.createCell(OrderReportColumn.VENDOR_ID.getValue()).setCellValue("Vendor Id");
|
| 6387 |
amar.kumar |
1387 |
headerRow.createCell(OrderReportColumn.VENDOR_NAME.getValue()).setCellValue("Vendor Name");
|
| 4600 |
varun.gupt |
1388 |
headerRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue("Order Date");
|
|
|
1389 |
headerRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue("Billing Number");
|
|
|
1390 |
headerRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue("Billing Date");
|
|
|
1391 |
headerRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue("Delivery Date");
|
|
|
1392 |
headerRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue("Brand");
|
|
|
1393 |
headerRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue("Model Name");
|
|
|
1394 |
headerRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue("Model Number");
|
|
|
1395 |
headerRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue("Color");
|
|
|
1396 |
headerRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue("Quantity");
|
|
|
1397 |
headerRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue("Unit Transfer Price");
|
|
|
1398 |
headerRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue("Unit Selling Price");
|
|
|
1399 |
headerRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue("Total Transfer Price");
|
|
|
1400 |
headerRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue("Total Selling Price");
|
|
|
1401 |
headerRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue("Current Status");
|
| 5481 |
phani.kuma |
1402 |
headerRow.createCell(OrderReportColumn.VENDOR_PAID.getValue()).setCellValue("Vendor Paid");
|
| 4600 |
varun.gupt |
1403 |
headerRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue("Payment Type");
|
| 4745 |
varun.gupt |
1404 |
headerRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue("Payment Status");
|
| 4600 |
varun.gupt |
1405 |
headerRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue("Payment Id");
|
|
|
1406 |
headerRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue("Coupon Code");
|
|
|
1407 |
|
| 5386 |
phani.kuma |
1408 |
outputPaymentUnsettledOrdersRows(sheet, rowCount);
|
|
|
1409 |
}
|
|
|
1410 |
|
|
|
1411 |
private int outputPaymentUnsettledOrdersRows(Sheet sheet, int rowCount) {
|
|
|
1412 |
|
|
|
1413 |
try {
|
|
|
1414 |
PaymentClient psc = new PaymentClient();
|
|
|
1415 |
in.shop2020.payments.PaymentService.Client paymentClient = psc.getClient();
|
|
|
1416 |
|
|
|
1417 |
TransactionClient tsc = new TransactionClient();
|
| 4600 |
varun.gupt |
1418 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
| 5189 |
varun.gupt |
1419 |
|
| 5386 |
phani.kuma |
1420 |
Row contentRow = null;
|
|
|
1421 |
LineItem lineItem = null;
|
|
|
1422 |
Payment pmt = null;
|
|
|
1423 |
Transaction txn = null;
|
|
|
1424 |
|
|
|
1425 |
for (Order order: unsettledOrders)
|
|
|
1426 |
{
|
|
|
1427 |
contentRow = sheet.createRow(rowCount ++);
|
|
|
1428 |
lineItem = order.getLineitems().get(0);
|
|
|
1429 |
pmt = null;
|
|
|
1430 |
txn = null;
|
|
|
1431 |
|
|
|
1432 |
try {
|
|
|
1433 |
if(order.isCod()) {
|
|
|
1434 |
try {
|
|
|
1435 |
pmt = paymentClient.getPaymentForTxnId(order.getTransactionId()).get(0);
|
|
|
1436 |
} catch (TTransportException e) {
|
|
|
1437 |
psc = new PaymentClient();
|
|
|
1438 |
paymentClient = psc.getClient();
|
|
|
1439 |
pmt = paymentClient.getPaymentForTxnId(order.getTransactionId()).get(0);
|
|
|
1440 |
}
|
|
|
1441 |
|
|
|
1442 |
try {
|
|
|
1443 |
txn = transactionClient.getTransaction(order.getTransactionId());
|
|
|
1444 |
} catch (TTransportException e) {
|
|
|
1445 |
tsc = new TransactionClient();
|
|
|
1446 |
transactionClient = tsc.getClient();
|
|
|
1447 |
txn = transactionClient.getTransaction(order.getTransactionId());
|
|
|
1448 |
}
|
|
|
1449 |
}
|
|
|
1450 |
else {
|
|
|
1451 |
try {
|
|
|
1452 |
pmt = paymentClient.getSuccessfulPaymentForTxnId(order.getTransactionId());
|
|
|
1453 |
} catch (TTransportException e) {
|
|
|
1454 |
psc = new PaymentClient();
|
|
|
1455 |
paymentClient = psc.getClient();
|
|
|
1456 |
pmt = paymentClient.getSuccessfulPaymentForTxnId(order.getTransactionId());
|
|
|
1457 |
}
|
|
|
1458 |
|
|
|
1459 |
try {
|
|
|
1460 |
txn = transactionClient.getTransaction(pmt.getMerchantTxnId());
|
|
|
1461 |
} catch (TTransportException e) {
|
|
|
1462 |
tsc = new TransactionClient();
|
|
|
1463 |
transactionClient = tsc.getClient();
|
|
|
1464 |
txn = transactionClient.getTransaction(pmt.getMerchantTxnId());
|
|
|
1465 |
}
|
|
|
1466 |
}
|
|
|
1467 |
|
|
|
1468 |
contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
|
|
1469 |
if(order.getOriginalOrderId() == 0) {
|
|
|
1470 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getId());
|
|
|
1471 |
}
|
|
|
1472 |
else {
|
|
|
1473 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getOriginalOrderId());
|
|
|
1474 |
}
|
|
|
1475 |
contentRow.createCell(OrderReportColumn.VENDOR_ID.getValue()).setCellValue(order.getVendorId());
|
| 6387 |
amar.kumar |
1476 |
contentRow.createCell(OrderReportColumn.VENDOR_NAME.getValue()).setCellValue(vendorIdNameMap.get(order.getVendorId()));
|
| 5386 |
phani.kuma |
1477 |
contentRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getCreated_timestamp())));
|
|
|
1478 |
contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
|
|
|
1479 |
contentRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getBilling_timestamp())));
|
|
|
1480 |
if(order.getDelivery_timestamp() != 0) {
|
|
|
1481 |
contentRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getDelivery_timestamp())));
|
|
|
1482 |
}
|
|
|
1483 |
contentRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
|
|
|
1484 |
contentRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
|
|
|
1485 |
contentRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
|
|
|
1486 |
contentRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
|
|
|
1487 |
contentRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue(lineItem.getQuantity());
|
|
|
1488 |
contentRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price());
|
|
|
1489 |
contentRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue(lineItem.getUnit_price());
|
|
|
1490 |
contentRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price() * lineItem.getQuantity());
|
|
|
1491 |
contentRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue(lineItem.getTotal_price());
|
|
|
1492 |
contentRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue(order.getStatus().name());
|
| 5481 |
phani.kuma |
1493 |
contentRow.createCell(OrderReportColumn.VENDOR_PAID.getValue()).setCellValue(order.isVendorPaid());
|
| 5386 |
phani.kuma |
1494 |
|
|
|
1495 |
if(pmt.getGatewayId() == 4) {
|
|
|
1496 |
contentRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue("COD-" + codProviders.get(order.getLogistics_provider_id()));
|
|
|
1497 |
}
|
|
|
1498 |
else {
|
|
|
1499 |
contentRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue(paymentGateways.get(pmt.getGatewayId()));
|
|
|
1500 |
}
|
|
|
1501 |
contentRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue(pmt.getStatus().name());
|
|
|
1502 |
contentRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue(pmt.getPaymentId());
|
|
|
1503 |
contentRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue(txn.getCoupon_code());
|
|
|
1504 |
|
|
|
1505 |
} catch (Exception e) {
|
|
|
1506 |
contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
|
|
1507 |
String errMsg = "error occured in outputPaymentUnsettledOrdersRows during " + order.getId();
|
|
|
1508 |
logger.error(errMsg, e);
|
|
|
1509 |
addActionError(errMsg);
|
| 5020 |
varun.gupt |
1510 |
}
|
| 4600 |
varun.gupt |
1511 |
}
|
| 5386 |
phani.kuma |
1512 |
} catch (Exception e) {
|
|
|
1513 |
String errMsg = e.getMessage();
|
|
|
1514 |
logger.error(errMsg, e);
|
|
|
1515 |
addActionError(errMsg);
|
| 5020 |
varun.gupt |
1516 |
}
|
| 5386 |
phani.kuma |
1517 |
|
|
|
1518 |
return rowCount;
|
| 5020 |
varun.gupt |
1519 |
}
|
|
|
1520 |
|
| 5386 |
phani.kuma |
1521 |
private void populateSettledOrderSheet(Sheet sheet, boolean total) {
|
|
|
1522 |
int rowCount = 0;
|
| 5020 |
varun.gupt |
1523 |
|
| 5386 |
phani.kuma |
1524 |
Row headerRow = sheet.createRow(rowCount ++);
|
|
|
1525 |
headerRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue("Order Id");
|
|
|
1526 |
headerRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue("Original Order Id");
|
|
|
1527 |
headerRow.createCell(OrderReportColumn.VENDOR_ID.getValue()).setCellValue("Vendor Id");
|
| 6387 |
amar.kumar |
1528 |
headerRow.createCell(OrderReportColumn.VENDOR_NAME.getValue()).setCellValue("Vendor Name");
|
| 5386 |
phani.kuma |
1529 |
headerRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue("Order Date");
|
|
|
1530 |
headerRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue("Billing Number");
|
|
|
1531 |
headerRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue("Billing Date");
|
|
|
1532 |
headerRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue("Delivery Date");
|
|
|
1533 |
headerRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue("Brand");
|
|
|
1534 |
headerRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue("Model Name");
|
|
|
1535 |
headerRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue("Model Number");
|
|
|
1536 |
headerRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue("Color");
|
|
|
1537 |
headerRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue("Quantity");
|
|
|
1538 |
headerRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue("Unit Transfer Price");
|
|
|
1539 |
headerRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue("Unit Selling Price");
|
|
|
1540 |
headerRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue("Total Transfer Price");
|
|
|
1541 |
headerRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue("Total Selling Price");
|
|
|
1542 |
headerRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue("Current Status");
|
| 5481 |
phani.kuma |
1543 |
headerRow.createCell(OrderReportColumn.VENDOR_PAID.getValue()).setCellValue("Vendor Paid");
|
| 5386 |
phani.kuma |
1544 |
headerRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue("Payment Type");
|
|
|
1545 |
headerRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue("Payment Status");
|
|
|
1546 |
headerRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue("Payment Reference");
|
|
|
1547 |
headerRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue("Coupon Code");
|
|
|
1548 |
headerRow.createCell(OrderReportColumn.SETTLEMENT_DATE.getValue()).setCellValue("Settlement Date");
|
|
|
1549 |
headerRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue("Service Tax");
|
|
|
1550 |
headerRow.createCell(OrderReportColumn.OTHER_CHARGES.getValue()).setCellValue("Other Charges");
|
|
|
1551 |
headerRow.createCell(OrderReportColumn.NET_COLLECTION.getValue()).setCellValue("Net Collection");
|
|
|
1552 |
headerRow.createCell(OrderReportColumn.USER_PAYABLE_AMOUNT.getValue()).setCellValue("User Payable Amount");
|
|
|
1553 |
|
|
|
1554 |
rowCount = outputPaymentSettledOrdersRows(sheet, rowCount);
|
|
|
1555 |
rowCount = outputPaymentNotRequiredOrdersRows(sheet, rowCount);
|
|
|
1556 |
|
|
|
1557 |
if(total) {
|
|
|
1558 |
rowCount = outputPaymentUnsettledOrdersRows(sheet, rowCount);
|
|
|
1559 |
}
|
|
|
1560 |
}
|
|
|
1561 |
|
|
|
1562 |
private int outputPaymentSettledOrdersRows(Sheet sheet, int rowCount) {
|
| 5020 |
varun.gupt |
1563 |
|
| 5386 |
phani.kuma |
1564 |
try {
|
|
|
1565 |
PaymentClient psc = new PaymentClient();
|
|
|
1566 |
in.shop2020.payments.PaymentService.Client paymentClient = psc.getClient();
|
|
|
1567 |
|
|
|
1568 |
TransactionClient tsc = new TransactionClient();
|
|
|
1569 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
|
|
1570 |
|
|
|
1571 |
Row contentRow = null;
|
|
|
1572 |
Order order = null;
|
|
|
1573 |
PaymentSettlement paymentSettlement = null;
|
|
|
1574 |
Payment pmt = null;
|
|
|
1575 |
Transaction txn = null;
|
|
|
1576 |
LineItem lineItem = null;
|
|
|
1577 |
|
|
|
1578 |
for (Entry<Order, PaymentSettlement> entry : paymentSettledOrdersMap.entrySet())
|
|
|
1579 |
{
|
|
|
1580 |
contentRow = sheet.createRow(rowCount ++);
|
|
|
1581 |
order = entry.getKey();
|
|
|
1582 |
paymentSettlement = entry.getValue();
|
|
|
1583 |
pmt = null;
|
|
|
1584 |
txn = null;
|
| 5020 |
varun.gupt |
1585 |
|
| 5386 |
phani.kuma |
1586 |
try {
|
|
|
1587 |
if(order.isCod()) {
|
|
|
1588 |
try {
|
|
|
1589 |
pmt = paymentClient.getPaymentForTxnId(order.getTransactionId()).get(0);
|
|
|
1590 |
} catch (TTransportException e) {
|
|
|
1591 |
psc = new PaymentClient();
|
|
|
1592 |
paymentClient = psc.getClient();
|
|
|
1593 |
pmt = paymentClient.getPaymentForTxnId(order.getTransactionId()).get(0);
|
|
|
1594 |
}
|
|
|
1595 |
|
|
|
1596 |
try {
|
|
|
1597 |
txn = transactionClient.getTransaction(order.getTransactionId());
|
|
|
1598 |
} catch (TTransportException e) {
|
|
|
1599 |
tsc = new TransactionClient();
|
|
|
1600 |
transactionClient = tsc.getClient();
|
|
|
1601 |
txn = transactionClient.getTransaction(order.getTransactionId());
|
|
|
1602 |
}
|
|
|
1603 |
}
|
|
|
1604 |
else {
|
|
|
1605 |
try {
|
|
|
1606 |
pmt = paymentClient.getSuccessfulPaymentForTxnId(order.getTransactionId());
|
|
|
1607 |
} catch (TTransportException e) {
|
|
|
1608 |
psc = new PaymentClient();
|
|
|
1609 |
paymentClient = psc.getClient();
|
|
|
1610 |
pmt = paymentClient.getSuccessfulPaymentForTxnId(order.getTransactionId());
|
|
|
1611 |
}
|
|
|
1612 |
|
|
|
1613 |
try {
|
|
|
1614 |
txn = transactionClient.getTransaction(pmt.getMerchantTxnId());
|
|
|
1615 |
} catch (TTransportException e) {
|
|
|
1616 |
tsc = new TransactionClient();
|
|
|
1617 |
transactionClient = tsc.getClient();
|
|
|
1618 |
txn = transactionClient.getTransaction(pmt.getMerchantTxnId());
|
|
|
1619 |
}
|
|
|
1620 |
}
|
|
|
1621 |
lineItem = order.getLineitems().get(0);
|
|
|
1622 |
|
|
|
1623 |
contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
|
|
1624 |
if(order.getOriginalOrderId() == 0) {
|
|
|
1625 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getId());
|
|
|
1626 |
}
|
|
|
1627 |
else {
|
|
|
1628 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getOriginalOrderId());
|
|
|
1629 |
}
|
|
|
1630 |
contentRow.createCell(OrderReportColumn.VENDOR_ID.getValue()).setCellValue(order.getVendorId());
|
| 6387 |
amar.kumar |
1631 |
contentRow.createCell(OrderReportColumn.VENDOR_NAME.getValue()).setCellValue(vendorIdNameMap.get(order.getVendorId()));
|
| 5386 |
phani.kuma |
1632 |
contentRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getCreated_timestamp())));
|
|
|
1633 |
contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
|
|
|
1634 |
contentRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getBilling_timestamp())));
|
|
|
1635 |
if(order.getDelivery_timestamp() != 0) {
|
|
|
1636 |
contentRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getDelivery_timestamp())));
|
|
|
1637 |
}
|
|
|
1638 |
contentRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
|
|
|
1639 |
contentRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
|
|
|
1640 |
contentRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
|
|
|
1641 |
contentRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
|
|
|
1642 |
contentRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue(lineItem.getQuantity());
|
|
|
1643 |
contentRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price());
|
|
|
1644 |
contentRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue(lineItem.getUnit_price());
|
|
|
1645 |
contentRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price() * lineItem.getQuantity());
|
|
|
1646 |
contentRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue(lineItem.getTotal_price());
|
|
|
1647 |
contentRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue(order.getStatus().name());
|
| 5481 |
phani.kuma |
1648 |
contentRow.createCell(OrderReportColumn.VENDOR_PAID.getValue()).setCellValue(order.isVendorPaid());
|
| 5386 |
phani.kuma |
1649 |
|
|
|
1650 |
if(pmt.getGatewayId() == 4) {
|
|
|
1651 |
contentRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue("COD-" + codProviders.get(order.getLogistics_provider_id()));
|
|
|
1652 |
contentRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue(paymentSettlement.getServiceTax());
|
|
|
1653 |
contentRow.createCell(OrderReportColumn.OTHER_CHARGES.getValue()).setCellValue(paymentSettlement.getOtherCharges());
|
|
|
1654 |
contentRow.createCell(OrderReportColumn.NET_COLLECTION.getValue()).setCellValue(paymentSettlement.getNetCollection());
|
|
|
1655 |
contentRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue(paymentSettlement.getReferenceId());
|
|
|
1656 |
}
|
|
|
1657 |
else {
|
|
|
1658 |
contentRow.createCell(OrderReportColumn.PAYMENT_TYPE.getValue()).setCellValue(paymentGateways.get(pmt.getGatewayId()));
|
|
|
1659 |
contentRow.createCell(OrderReportColumn.SERVICE_TAX.getValue()).setCellValue((paymentSettlement.getServiceTax() * order.getTotal_amount()) / pmt.getAmount());
|
|
|
1660 |
contentRow.createCell(OrderReportColumn.OTHER_CHARGES.getValue()).setCellValue((paymentSettlement.getOtherCharges() * order.getTotal_amount()) / pmt.getAmount());
|
|
|
1661 |
contentRow.createCell(OrderReportColumn.NET_COLLECTION.getValue()).setCellValue((paymentSettlement.getNetCollection() * order.getTotal_amount()) / pmt.getAmount());
|
|
|
1662 |
contentRow.createCell(OrderReportColumn.PAYMENT_ID.getValue()).setCellValue(pmt.getPaymentId());
|
|
|
1663 |
}
|
|
|
1664 |
contentRow.createCell(OrderReportColumn.PAYMENT_STATUS.getValue()).setCellValue(pmt.getStatus().name());
|
|
|
1665 |
contentRow.createCell(OrderReportColumn.SETTLEMENT_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(paymentSettlement.getSettlementDate())));
|
|
|
1666 |
contentRow.createCell(OrderReportColumn.USER_PAYABLE_AMOUNT.getValue()).setCellValue(order.getTotal_amount());
|
|
|
1667 |
contentRow.createCell(OrderReportColumn.COUPON_CODE.getValue()).setCellValue(txn.getCoupon_code());
|
|
|
1668 |
|
|
|
1669 |
} catch (Exception e) {
|
|
|
1670 |
contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
|
|
1671 |
String errMsg = "error occured in outputPaymentSettledOrdersRows during " + order.getId();
|
|
|
1672 |
logger.error(errMsg, e);
|
|
|
1673 |
addActionError(errMsg);
|
|
|
1674 |
}
|
| 4715 |
varun.gupt |
1675 |
}
|
| 5386 |
phani.kuma |
1676 |
} catch (Exception e) {
|
|
|
1677 |
String errMsg = e.getMessage();
|
|
|
1678 |
logger.error(errMsg, e);
|
|
|
1679 |
addActionError(errMsg);
|
| 5020 |
varun.gupt |
1680 |
}
|
| 5386 |
phani.kuma |
1681 |
|
|
|
1682 |
return rowCount;
|
| 5020 |
varun.gupt |
1683 |
}
|
| 5098 |
varun.gupt |
1684 |
|
| 5386 |
phani.kuma |
1685 |
private int outputPaymentNotRequiredOrdersRows(Sheet sheet, int rowCount) {
|
| 5020 |
varun.gupt |
1686 |
|
| 5386 |
phani.kuma |
1687 |
try {
|
|
|
1688 |
|
|
|
1689 |
Row contentRow = null;
|
|
|
1690 |
LineItem lineItem = null;
|
|
|
1691 |
|
|
|
1692 |
for (Order order: userPaymentNotRequiredOrders)
|
|
|
1693 |
{
|
|
|
1694 |
contentRow = sheet.createRow(rowCount ++);
|
|
|
1695 |
lineItem = order.getLineitems().get(0);
|
| 5189 |
varun.gupt |
1696 |
|
| 5386 |
phani.kuma |
1697 |
contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
|
|
1698 |
if(order.getOriginalOrderId() == 0) {
|
|
|
1699 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getId());
|
| 5189 |
varun.gupt |
1700 |
}
|
| 5386 |
phani.kuma |
1701 |
else {
|
|
|
1702 |
contentRow.createCell(OrderReportColumn.ORIGINAL_ORDER_ID.getValue()).setCellValue(order.getOriginalOrderId());
|
|
|
1703 |
}
|
|
|
1704 |
contentRow.createCell(OrderReportColumn.VENDOR_ID.getValue()).setCellValue(order.getVendorId());
|
| 6387 |
amar.kumar |
1705 |
contentRow.createCell(OrderReportColumn.VENDOR_NAME.getValue()).setCellValue(vendorIdNameMap.get(order.getVendorId()));
|
| 5020 |
varun.gupt |
1706 |
contentRow.createCell(OrderReportColumn.ORDER_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getCreated_timestamp())));
|
|
|
1707 |
contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
|
|
|
1708 |
contentRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getBilling_timestamp())));
|
| 5386 |
phani.kuma |
1709 |
if(order.getDelivery_timestamp() != 0) {
|
|
|
1710 |
contentRow.createCell(OrderReportColumn.DELIVERY_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getDelivery_timestamp())));
|
|
|
1711 |
}
|
| 5020 |
varun.gupt |
1712 |
contentRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
|
|
|
1713 |
contentRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
|
|
|
1714 |
contentRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
|
|
|
1715 |
contentRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
|
|
|
1716 |
contentRow.createCell(OrderReportColumn.QUANTITY.getValue()).setCellValue(lineItem.getQuantity());
|
|
|
1717 |
contentRow.createCell(OrderReportColumn.UNIT_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price());
|
|
|
1718 |
contentRow.createCell(OrderReportColumn.UNIT_SELLING_PRICE.getValue()).setCellValue(lineItem.getUnit_price());
|
|
|
1719 |
contentRow.createCell(OrderReportColumn.TOTAL_TRANSFER_PRICE.getValue()).setCellValue(lineItem.getTransfer_price() * lineItem.getQuantity());
|
|
|
1720 |
contentRow.createCell(OrderReportColumn.TOTAL_SELLING_PRICE.getValue()).setCellValue(lineItem.getTotal_price());
|
| 5386 |
phani.kuma |
1721 |
contentRow.createCell(OrderReportColumn.CURRENT_STATUS.getValue()).setCellValue(order.getStatus().name());
|
| 5481 |
phani.kuma |
1722 |
contentRow.createCell(OrderReportColumn.VENDOR_PAID.getValue()).setCellValue(order.isVendorPaid());
|
| 5386 |
phani.kuma |
1723 |
contentRow.createCell(OrderReportColumn.USER_PAYABLE_AMOUNT.getValue()).setCellValue(0);
|
| 5020 |
varun.gupt |
1724 |
}
|
| 5386 |
phani.kuma |
1725 |
} catch (Exception e) {
|
|
|
1726 |
String errMsg = e.getMessage();
|
|
|
1727 |
logger.error(errMsg, e);
|
|
|
1728 |
addActionError(errMsg);
|
| 4600 |
varun.gupt |
1729 |
}
|
| 5020 |
varun.gupt |
1730 |
|
| 5386 |
phani.kuma |
1731 |
return rowCount;
|
| 5020 |
varun.gupt |
1732 |
}
|
|
|
1733 |
|
| 5098 |
varun.gupt |
1734 |
private void initiatializeDashboard() {
|
|
|
1735 |
try {
|
|
|
1736 |
OrderStatusGroups orderStatusGroups = new OrderStatusGroups();
|
|
|
1737 |
refundOrderStatuses = orderStatusGroups.getRefundedOrders();
|
|
|
1738 |
|
| 5945 |
mandeep.dh |
1739 |
InventoryClient csc = new InventoryClient();
|
|
|
1740 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = csc.getClient();
|
|
|
1741 |
vendors = inventoryClient.getAllVendors();
|
| 5098 |
varun.gupt |
1742 |
|
|
|
1743 |
TransactionClient tsc = new TransactionClient();
|
|
|
1744 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = tsc.getClient();
|
|
|
1745 |
ebsSettlementSummaries = transactionClient.getEBSSettlementSummaries();
|
|
|
1746 |
|
| 5386 |
phani.kuma |
1747 |
} catch (Exception e) {
|
|
|
1748 |
String errMsg = e.getMessage();
|
|
|
1749 |
logger.error(errMsg, e);
|
|
|
1750 |
addActionError(errMsg);
|
| 5098 |
varun.gupt |
1751 |
}
|
|
|
1752 |
}
|
|
|
1753 |
|
| 4600 |
varun.gupt |
1754 |
public List<Vendor> getAllVendors() {
|
|
|
1755 |
return this.vendors;
|
|
|
1756 |
}
|
|
|
1757 |
|
|
|
1758 |
private String getValueForEmptyString(String s){
|
|
|
1759 |
if(s==null || s.equals(""))
|
|
|
1760 |
return "-";
|
|
|
1761 |
else
|
|
|
1762 |
return s;
|
|
|
1763 |
}
|
|
|
1764 |
|
|
|
1765 |
private String getVendorName(long vendorId) {
|
|
|
1766 |
for (Vendor vendor: vendors) {
|
|
|
1767 |
if (vendor.getId() == vendorId) return vendor.getName();
|
|
|
1768 |
}
|
|
|
1769 |
return null;
|
|
|
1770 |
}
|
|
|
1771 |
|
| 5386 |
phani.kuma |
1772 |
public File getHdfcSettlementReport() {
|
| 4600 |
varun.gupt |
1773 |
return hdfcSettlementReport;
|
|
|
1774 |
}
|
|
|
1775 |
|
|
|
1776 |
public void setHdfcSettlementReport(File hdfcSettlementReport) {
|
|
|
1777 |
this.hdfcSettlementReport = hdfcSettlementReport;
|
|
|
1778 |
}
|
|
|
1779 |
|
|
|
1780 |
public File getEbsSettlementSummary() {
|
|
|
1781 |
return ebsSettlementSummary;
|
|
|
1782 |
}
|
|
|
1783 |
|
|
|
1784 |
public void setEbsSettlementSummary(File ebsSettlementSummary) {
|
|
|
1785 |
this.ebsSettlementSummary = ebsSettlementSummary;
|
|
|
1786 |
}
|
|
|
1787 |
|
|
|
1788 |
public File getEbsSettlementReport() {
|
|
|
1789 |
return ebsSettlementReport;
|
|
|
1790 |
}
|
|
|
1791 |
|
|
|
1792 |
public void setEbsSettlementReport(File ebsSettlementReport) {
|
|
|
1793 |
this.ebsSettlementReport = ebsSettlementReport;
|
|
|
1794 |
}
|
|
|
1795 |
|
|
|
1796 |
public String getBluedartSettlementDate() {
|
|
|
1797 |
return bluedartSettlementDate;
|
|
|
1798 |
}
|
|
|
1799 |
|
|
|
1800 |
public void setBluedartSettlementDate(String bluedartSettlementDate) {
|
|
|
1801 |
this.bluedartSettlementDate = bluedartSettlementDate;
|
|
|
1802 |
}
|
|
|
1803 |
|
|
|
1804 |
public File getBluedartSettlementReport() {
|
|
|
1805 |
return bluedartSettlementReport;
|
|
|
1806 |
}
|
|
|
1807 |
|
|
|
1808 |
public void setBluedartSettlementReport(File bluedartSettlementReport) {
|
|
|
1809 |
this.bluedartSettlementReport = bluedartSettlementReport;
|
|
|
1810 |
}
|
|
|
1811 |
|
| 4715 |
varun.gupt |
1812 |
public String getAramexSettlementDate() {
|
|
|
1813 |
return this.aramexSettlementDate;
|
|
|
1814 |
}
|
|
|
1815 |
|
|
|
1816 |
public void setAramexSettlementDate(String aramexSettlementDate) {
|
|
|
1817 |
this.aramexSettlementDate = aramexSettlementDate;
|
|
|
1818 |
}
|
|
|
1819 |
|
|
|
1820 |
public void setAramexSettlementReport(File aramexSettlementReport) {
|
|
|
1821 |
this.aramexSettlementReport = aramexSettlementReport;
|
|
|
1822 |
}
|
|
|
1823 |
|
|
|
1824 |
public File getAramexSettlementReport() {
|
|
|
1825 |
return aramexSettlementReport;
|
|
|
1826 |
}
|
|
|
1827 |
|
| 5481 |
phani.kuma |
1828 |
public String getDelhiverySettlementDate() {
|
|
|
1829 |
return this.delhiverySettlementDate;
|
|
|
1830 |
}
|
|
|
1831 |
|
|
|
1832 |
public void setDelhiverySettlementDate(String delhiverySettlementDate) {
|
|
|
1833 |
this.delhiverySettlementDate = delhiverySettlementDate;
|
|
|
1834 |
}
|
|
|
1835 |
|
|
|
1836 |
public void setDelhiverySettlementReport(File delhiverySettlementReport) {
|
|
|
1837 |
this.delhiverySettlementReport = delhiverySettlementReport;
|
|
|
1838 |
}
|
|
|
1839 |
|
|
|
1840 |
public File getDelhiverySettlementReport() {
|
|
|
1841 |
return delhiverySettlementReport;
|
|
|
1842 |
}
|
|
|
1843 |
|
| 4600 |
varun.gupt |
1844 |
@Override
|
| 5386 |
phani.kuma |
1845 |
public void setServletContext(ServletContext context) {
|
| 4600 |
varun.gupt |
1846 |
this.context = context;
|
|
|
1847 |
}
|
|
|
1848 |
|
|
|
1849 |
public String getServletContextPath() {
|
|
|
1850 |
return context.getContextPath();
|
|
|
1851 |
}
|
|
|
1852 |
|
|
|
1853 |
@Override
|
|
|
1854 |
public void setServletResponse(HttpServletResponse response) {
|
|
|
1855 |
this.response = response;
|
|
|
1856 |
}
|
|
|
1857 |
|
|
|
1858 |
@Override
|
|
|
1859 |
public void setServletRequest(HttpServletRequest request) {
|
|
|
1860 |
this.request = request;
|
|
|
1861 |
}
|
|
|
1862 |
|
| 5386 |
phani.kuma |
1863 |
public Map<Long, String> getEBSSettlementSummaries() {
|
| 4600 |
varun.gupt |
1864 |
return ebsSettlementSummaries;
|
|
|
1865 |
}
|
| 5386 |
phani.kuma |
1866 |
|
|
|
1867 |
public void setOrderIdsToBeMarked(File orderIdsToBeMarked) {
|
|
|
1868 |
this.orderIdsToBeMarked = orderIdsToBeMarked;
|
| 5098 |
varun.gupt |
1869 |
}
|
|
|
1870 |
|
| 5386 |
phani.kuma |
1871 |
public File getOrderIdsToBeMarked() {
|
|
|
1872 |
return orderIdsToBeMarked;
|
| 5098 |
varun.gupt |
1873 |
}
|
| 4600 |
varun.gupt |
1874 |
}
|