| Line 38... |
Line 38... |
| 38 |
import java.io.OutputStream;
|
38 |
import java.io.OutputStream;
|
| 39 |
import java.text.DateFormat;
|
39 |
import java.text.DateFormat;
|
| 40 |
import java.text.DecimalFormat;
|
40 |
import java.text.DecimalFormat;
|
| 41 |
import java.util.ArrayList;
|
41 |
import java.util.ArrayList;
|
| 42 |
import java.util.Date;
|
42 |
import java.util.Date;
|
| - |
|
43 |
import java.util.HashMap;
|
| 43 |
import java.util.List;
|
44 |
import java.util.List;
|
| 44 |
import java.util.Locale;
|
45 |
import java.util.Locale;
|
| - |
|
46 |
import java.util.Map;
|
| 45 |
|
47 |
|
| 46 |
import javax.servlet.ServletException;
|
48 |
import javax.servlet.ServletException;
|
| 47 |
import javax.servlet.ServletOutputStream;
|
49 |
import javax.servlet.ServletOutputStream;
|
| 48 |
import javax.servlet.http.HttpServlet;
|
50 |
import javax.servlet.http.HttpServlet;
|
| 49 |
import javax.servlet.http.HttpServletRequest;
|
51 |
import javax.servlet.http.HttpServletRequest;
|
| Line 84... |
Line 86... |
| 84 |
private static Logger logger = LoggerFactory.getLogger(InvoiceServlet.class);
|
86 |
private static Logger logger = LoggerFactory.getLogger(InvoiceServlet.class);
|
| 85 |
|
87 |
|
| 86 |
@Override
|
88 |
@Override
|
| 87 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
89 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
| 88 |
long orderId = Long.parseLong(request.getParameter("id"));
|
90 |
long orderId = Long.parseLong(request.getParameter("id"));
|
| - |
|
91 |
String logisticsTxnId = request.getParameter("logisticsTxnId");
|
| 89 |
long warehouseId = Long.parseLong(request.getParameter("warehouse"));
|
92 |
long warehouseId = Long.parseLong(request.getParameter("warehouse"));
|
| 90 |
boolean withBill = false;
|
93 |
boolean withBill = false;
|
| 91 |
boolean printAll = false;
|
94 |
boolean printAll = false;
|
| 92 |
try {
|
95 |
try {
|
| 93 |
withBill = Boolean.parseBoolean(request.getParameter("withBill"));
|
96 |
withBill = Boolean.parseBoolean(request.getParameter("withBill"));
|
| Line 98... |
Line 101... |
| 98 |
printAll = Boolean.parseBoolean(request.getParameter("printAll"));
|
101 |
printAll = Boolean.parseBoolean(request.getParameter("printAll"));
|
| 99 |
} catch(Exception e){
|
102 |
} catch(Exception e){
|
| 100 |
logger.warn("Couldn't infer whether bill should be printed. Not printing the bill.", e);
|
103 |
logger.warn("Couldn't infer whether bill should be printed. Not printing the bill.", e);
|
| 101 |
}
|
104 |
}
|
| 102 |
|
105 |
|
| - |
|
106 |
if(logisticsTxnId!=null && !logisticsTxnId.isEmpty()){
|
| - |
|
107 |
logger.info("Printing invoice for master order id: " + logisticsTxnId);
|
| - |
|
108 |
}else{
|
| 103 |
logger.info("Printing invoice for order id: " + orderId);
|
109 |
logger.info("Printing invoice for order id: " + orderId);
|
| - |
|
110 |
}
|
| 104 |
|
111 |
|
| 105 |
ByteArrayOutputStream baos = null;
|
112 |
ByteArrayOutputStream baos = null;
|
| 106 |
|
113 |
|
| 107 |
InvoiceGenerationService invoiceGenerationService = new InvoiceGenerationService();
|
114 |
InvoiceGenerationService invoiceGenerationService = new InvoiceGenerationService();
|
| 108 |
baos = invoiceGenerationService.generateInvoice(orderId, withBill, printAll, warehouseId);
|
115 |
baos = invoiceGenerationService.generateInvoice(orderId, withBill, printAll, warehouseId);
|
| 109 |
|
116 |
|
| 110 |
response.setContentType("application/pdf");
|
117 |
response.setContentType("application/pdf");
|
| - |
|
118 |
if(logisticsTxnId!=null && !logisticsTxnId.isEmpty()){
|
| - |
|
119 |
response.setHeader("Content-disposition", "inline; filename=invoice-"+logisticsTxnId+".pdf" );
|
| - |
|
120 |
} else {
|
| 111 |
response.setHeader("Content-disposition", "inline; filename=invoice-"+orderId+".pdf" );
|
121 |
response.setHeader("Content-disposition", "inline; filename=invoice-"+orderId+".pdf" );
|
| - |
|
122 |
}
|
| 112 |
|
123 |
|
| 113 |
ServletOutputStream sos;
|
124 |
ServletOutputStream sos;
|
| 114 |
try {
|
125 |
try {
|
| 115 |
sos = response.getOutputStream();
|
126 |
sos = response.getOutputStream();
|
| 116 |
baos.writeTo(sos);
|
127 |
baos.writeTo(sos);
|
| Line 173... |
Line 184... |
| 173 |
Document document = new Document();
|
184 |
Document document = new Document();
|
| 174 |
PdfWriter.getInstance(document, baosPDF);
|
185 |
PdfWriter.getInstance(document, baosPDF);
|
| 175 |
document.addAuthor("shop2020");
|
186 |
document.addAuthor("shop2020");
|
| 176 |
//document.addTitle("Invoice No: " + order.getInvoice_number());
|
187 |
//document.addTitle("Invoice No: " + order.getInvoice_number());
|
| 177 |
document.open();
|
188 |
document.open();
|
| - |
|
189 |
//document.bo
|
| 178 |
|
190 |
|
| 179 |
List<Order> orders = new ArrayList<Order>();
|
191 |
List<Order> orders = new ArrayList<Order>();
|
| - |
|
192 |
Map<String, List<Order>> logisticsTxnIdOrdersMap = new HashMap<String, List<Order>>();
|
| 180 |
if(printAll){
|
193 |
if(printAll){
|
| 181 |
try {
|
194 |
try {
|
| 182 |
List<OrderStatus> statuses = new ArrayList<OrderStatus>();
|
195 |
List<OrderStatus> statuses = new ArrayList<OrderStatus>();
|
| 183 |
statuses.add(OrderStatus.ACCEPTED);
|
196 |
statuses.add(OrderStatus.ACCEPTED);
|
| - |
|
197 |
if(!tclient.isAlive()){
|
| - |
|
198 |
tclient = tsc.getClient();
|
| - |
|
199 |
}
|
| 184 |
orders = tclient.getAllOrders(statuses, 0, 0, warehouseId);
|
200 |
orders = tclient.getAllOrders(statuses, 0, 0, warehouseId);
|
| - |
|
201 |
for(Order o:orders){
|
| - |
|
202 |
if(o.isSetLogisticsTransactionId()){
|
| - |
|
203 |
if(logisticsTxnIdOrdersMap.containsKey(o.getLogisticsTransactionId())){
|
| - |
|
204 |
List<Order> groupOrdersList = logisticsTxnIdOrdersMap.get(o.getLogisticsTransactionId());
|
| - |
|
205 |
groupOrdersList.add(o);
|
| - |
|
206 |
logisticsTxnIdOrdersMap.put(o.getLogisticsTransactionId(), groupOrdersList);
|
| - |
|
207 |
}else {
|
| - |
|
208 |
List<Order> groupOrdersList = new ArrayList<Order>();
|
| - |
|
209 |
groupOrdersList.add(o);
|
| - |
|
210 |
logisticsTxnIdOrdersMap.put(o.getLogisticsTransactionId(), groupOrdersList);
|
| - |
|
211 |
}
|
| - |
|
212 |
}
|
| - |
|
213 |
}
|
| 185 |
} catch (Exception e) {
|
214 |
} catch (Exception e) {
|
| 186 |
logger.error("Error while getting order information", e);
|
215 |
logger.error("Error while getting order information", e);
|
| 187 |
return baosPDF;
|
216 |
return baosPDF;
|
| 188 |
}
|
217 |
}
|
| 189 |
}else{
|
218 |
}else{
|
| - |
|
219 |
if(!tclient.isAlive()){
|
| - |
|
220 |
tclient = tsc.getClient();
|
| - |
|
221 |
}
|
| 190 |
orders.add(tclient.getOrder(orderId));
|
222 |
orders.add(tclient.getOrder(orderId));
|
| - |
|
223 |
Order o = orders.get(0);
|
| - |
|
224 |
if(o.isSetLogisticsTransactionId()){
|
| - |
|
225 |
List<Order> groupOrdersList = tclient.getGroupOrdersByLogisticsTxnId(o.getLogisticsTransactionId());
|
| - |
|
226 |
logisticsTxnIdOrdersMap.put(o.getLogisticsTransactionId(), groupOrdersList);
|
| - |
|
227 |
}
|
| 191 |
}
|
228 |
}
|
| 192 |
boolean isFirst = true;
|
229 |
boolean isFirst = true;
|
| 193 |
|
- |
|
| - |
|
230 |
if(logisticsTxnIdOrdersMap!=null && logisticsTxnIdOrdersMap.size()>0){
|
| - |
|
231 |
for(String logisticsTxnId : logisticsTxnIdOrdersMap.keySet()){
|
| - |
|
232 |
List<Order> ordersList = logisticsTxnIdOrdersMap.get(logisticsTxnId);
|
| 194 |
for(Order order: orders){
|
233 |
Order singleOrder = ordersList.get(0);
|
| 195 |
Warehouse warehouse = null;
|
234 |
Warehouse warehouse = null;
|
| 196 |
Provider provider = null;
|
235 |
Provider provider = null;
|
| 197 |
String destCode = null;
|
236 |
String destCode = null;
|
| 198 |
Warehouse shippingLocation = null;
|
237 |
Warehouse shippingLocation = null;
|
| 199 |
int barcodeFontSize = 0;
|
238 |
int barcodeFontSize = 0;
|
| - |
|
239 |
String invoiceFormat = null;
|
| 200 |
try {
|
240 |
try {
|
| 201 |
warehouse = iclient.getWarehouse(order.getWarehouse_id());
|
241 |
warehouse = iclient.getWarehouse(singleOrder.getWarehouse_id());
|
| 202 |
long providerId = order.getLogistics_provider_id();
|
242 |
long providerId = singleOrder.getLogistics_provider_id();
|
| 203 |
provider = logisticsClient.getProvider(providerId);
|
243 |
provider = logisticsClient.getProvider(providerId);
|
| 204 |
if(provider.getPickup().equals(PickUpType.SELF) || provider.getPickup().equals(PickUpType.RUNNER))
|
244 |
if(provider.getPickup().equals(PickUpType.SELF) || provider.getPickup().equals(PickUpType.RUNNER))
|
| 205 |
destCode = provider.getPickup().toString();
|
245 |
destCode = provider.getPickup().toString();
|
| 206 |
else
|
246 |
else
|
| 207 |
destCode = logisticsClient.getDestinationCode(providerId, order.getCustomer_pincode());
|
247 |
destCode = logisticsClient.getDestinationCode(providerId, singleOrder.getCustomer_pincode());
|
| 208 |
|
248 |
|
| 209 |
barcodeFontSize = Integer.parseInt(ConfigClient.getClient().get(provider.getName().toLowerCase() + "_barcode_fontsize"));
|
249 |
barcodeFontSize = Integer.parseInt(ConfigClient.getClient().get(provider.getName().toLowerCase() + "_barcode_fontsize"));
|
| 210 |
shippingLocation = CatalogUtils.getWarehouse(warehouse.getShippingWarehouseId());
|
250 |
shippingLocation = CatalogUtils.getWarehouse(warehouse.getShippingWarehouseId());
|
| - |
|
251 |
invoiceFormat = tclient.getInvoiceFormatLogisticsTxnId(singleOrder.getTransactionId(), Long.parseLong(logisticsTxnId.split("-")[1]));
|
| 211 |
} catch (InventoryServiceException ise) {
|
252 |
} catch (InventoryServiceException ise) {
|
| 212 |
logger.error("Error while getting the warehouse information.", ise);
|
253 |
logger.error("Error while getting the warehouse information.", ise);
|
| 213 |
return baosPDF;
|
254 |
return baosPDF;
|
| 214 |
} catch (LogisticsServiceException lse) {
|
255 |
} catch (LogisticsServiceException lse) {
|
| 215 |
logger.error("Error while getting the provider information.", lse);
|
256 |
logger.error("Error while getting the provider information.", lse);
|
| 216 |
return baosPDF;
|
257 |
return baosPDF;
|
| 217 |
} catch (ConfigException ce) {
|
258 |
} catch (ConfigException ce) {
|
| 218 |
logger.error("Error while getting the fontsize for the given provider", ce);
|
259 |
logger.error("Error while getting the fontsize for the given provider", ce);
|
| 219 |
return baosPDF;
|
260 |
return baosPDF;
|
| 220 |
} catch (TException te) {
|
261 |
} catch (TException te) {
|
| 221 |
logger.error("Error while getting some essential information from the services", te);
|
262 |
logger.error("Error while getting some essential information from the services", te);
|
| 222 |
return baosPDF;
|
263 |
return baosPDF;
|
| 223 |
}
|
- |
|
| 224 |
|
- |
|
| 225 |
if(printAll && warehouse.getBillingType() == BillingType.OURS_EXTERNAL){
|
- |
|
| 226 |
if(isFirst){
|
- |
|
| 227 |
document.add(getFixedTextTable(16, "Spice Online Retail Pvt Ltd"));
|
- |
|
| 228 |
isFirst = false;
|
- |
|
| 229 |
}
|
264 |
}
|
| - |
|
265 |
|
| - |
|
266 |
if(printAll && warehouse.getBillingType() == BillingType.OURS_EXTERNAL){
|
| - |
|
267 |
for(Order order : ordersList){
|
| - |
|
268 |
if(isFirst){
|
| - |
|
269 |
document.add(getFixedTextTable(16, "Spice Online Retail Pvt Ltd"));
|
| - |
|
270 |
isFirst = false;
|
| - |
|
271 |
}
|
| 230 |
document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
|
272 |
document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
|
| 231 |
continue;
|
273 |
continue;
|
| 232 |
}
|
274 |
}
|
| 233 |
|
275 |
}
|
| 234 |
PdfPTable dispatchAdviceTable = null;
|
276 |
PdfPTable dispatchAdviceTable = null;
|
| 235 |
|
- |
|
| 236 |
if (new Long(order.getSource()).intValue() == OrderSource.SNAPDEAL.getValue()) {
|
277 |
Order order = ordersList.get(0);
|
| 237 |
dispatchAdviceTable = new PdfPTable(1);
|
278 |
if(ordersList.size()==1){
|
| 238 |
} else if(new Long(order.getSource()).intValue() == OrderSource.FLIPKART.getValue()) {
|
279 |
if (new Long(order.getSource()).intValue() == OrderSource.SNAPDEAL.getValue()) {
|
| 239 |
dispatchAdviceTable = new PdfPTable(1);
|
- |
|
| 240 |
} else if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7)) {
|
- |
|
| 241 |
if(order.getWarehouse_id() == 7 || order.getWarehouse_id() == 5 || order.getWarehouse_id() == 9) {
|
- |
|
| 242 |
dispatchAdviceTable = new PdfPTable(1);
|
- |
|
| 243 |
} else {
|
- |
|
| 244 |
if (order.getAirwaybill_no()== null || order.getAirwaybill_no().equals("null") || order.getAirwaybill_no().isEmpty()) {
|
- |
|
| 245 |
dispatchAdviceTable = new PdfPTable(1);
|
280 |
dispatchAdviceTable = new PdfPTable(1);
|
| - |
|
281 |
} else if(new Long(order.getSource()).intValue() == OrderSource.FLIPKART.getValue()) {
|
| - |
|
282 |
dispatchAdviceTable = new PdfPTable(1);
|
| - |
|
283 |
} else if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7)) {
|
| - |
|
284 |
if(order.getWarehouse_id() == 7 || order.getWarehouse_id() == 5 || order.getWarehouse_id() == 9) {
|
| - |
|
285 |
dispatchAdviceTable = new PdfPTable(1);
|
| 246 |
} else {
|
286 |
} else {
|
| - |
|
287 |
if (order.getAirwaybill_no()== null || order.getAirwaybill_no().equals("null") || order.getAirwaybill_no().isEmpty()) {
|
| - |
|
288 |
dispatchAdviceTable = new PdfPTable(1);
|
| - |
|
289 |
} else {
|
| 247 |
EbayInvoiceGenerationService invoiceGenerationService = new EbayInvoiceGenerationService();
|
290 |
EbayInvoiceGenerationService invoiceGenerationService = new EbayInvoiceGenerationService();
|
| 248 |
dispatchAdviceTable = invoiceGenerationService.getDispatchAdviceTable(orderId, warehouseId);
|
291 |
dispatchAdviceTable = invoiceGenerationService.getDispatchAdviceTable(orderId, warehouseId);
|
| - |
|
292 |
}
|
| - |
|
293 |
}
|
| 249 |
}
|
294 |
}
|
| - |
|
295 |
else {
|
| - |
|
296 |
dispatchAdviceTable = getDispatchAdviceTable(ordersList, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation, invoiceFormat);
|
| - |
|
297 |
}
|
| - |
|
298 |
} else {
|
| - |
|
299 |
dispatchAdviceTable = getDispatchAdviceTable(ordersList, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation, invoiceFormat);
|
| 250 |
}
|
300 |
}
|
| 251 |
} else {
|
- |
|
| 252 |
dispatchAdviceTable = getDispatchAdviceTable(order, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation);
|
- |
|
| 253 |
}
|
301 |
|
| 254 |
dispatchAdviceTable.setSpacingAfter(10.0f);
|
302 |
dispatchAdviceTable.setSpacingAfter(10.0f);
|
| 255 |
dispatchAdviceTable.setWidthPercentage(90.0f);
|
303 |
dispatchAdviceTable.setWidthPercentage(90.0f);
|
| 256 |
document.add(dispatchAdviceTable);
|
304 |
document.add(dispatchAdviceTable);
|
| - |
|
305 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
| 257 |
//TODO fix this logic
|
306 |
document.newPage();
|
| - |
|
307 |
}
|
| - |
|
308 |
|
| 258 |
if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7)) {
|
309 |
if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7) &&(ordersList.size()==1)) {
|
| 259 |
if (order.getAirwaybill_no()== null || order.getAirwaybill_no().equals("null") || order.getAirwaybill_no().isEmpty()
|
310 |
if (order.getAirwaybill_no()== null || order.getAirwaybill_no().equals("null") || order.getAirwaybill_no().isEmpty()
|
| 260 |
|| order.getWarehouse_id() == 7 || order.getWarehouse_id() == 5 || order.getWarehouse_id() == 9) {
|
311 |
|| order.getWarehouse_id() == 7 || order.getWarehouse_id() == 5 || order.getWarehouse_id() == 9) {
|
| - |
|
312 |
if(withBill){
|
| - |
|
313 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
| - |
|
314 |
taxTable.setSpacingBefore(5.0f);
|
| - |
|
315 |
taxTable.setWidthPercentage(90.0f);
|
| - |
|
316 |
document.add(new DottedLineSeparator());
|
| - |
|
317 |
document.add(taxTable);
|
| - |
|
318 |
}else{
|
| - |
|
319 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
| - |
|
320 |
extraInfoTable.setSpacingBefore(5.0f);
|
| - |
|
321 |
extraInfoTable.setWidthPercentage(90.0f);
|
| - |
|
322 |
document.add(new DottedLineSeparator());
|
| - |
|
323 |
document.add(extraInfoTable);
|
| - |
|
324 |
}
|
| - |
|
325 |
} else {
|
| - |
|
326 |
document.newPage();
|
| - |
|
327 |
}
|
| - |
|
328 |
} else if (new Long(order.getSource()).intValue() == OrderSource.SNAPDEAL.getValue() &&(ordersList.size()==1)) {
|
| 261 |
if(withBill){
|
329 |
if(withBill){
|
| 262 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(order, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber());
|
330 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
| 263 |
taxTable.setSpacingBefore(5.0f);
|
331 |
taxTable.setSpacingBefore(5.0f);
|
| 264 |
taxTable.setWidthPercentage(90.0f);
|
332 |
taxTable.setWidthPercentage(90.0f);
|
| 265 |
document.add(new DottedLineSeparator());
|
333 |
document.add(new DottedLineSeparator());
|
| 266 |
document.add(taxTable);
|
334 |
document.add(taxTable);
|
| 267 |
}else{
|
335 |
}else{
|
| Line 269... |
Line 337... |
| 269 |
extraInfoTable.setSpacingBefore(5.0f);
|
337 |
extraInfoTable.setSpacingBefore(5.0f);
|
| 270 |
extraInfoTable.setWidthPercentage(90.0f);
|
338 |
extraInfoTable.setWidthPercentage(90.0f);
|
| 271 |
document.add(new DottedLineSeparator());
|
339 |
document.add(new DottedLineSeparator());
|
| 272 |
document.add(extraInfoTable);
|
340 |
document.add(extraInfoTable);
|
| 273 |
}
|
341 |
}
|
| 274 |
} else {
|
- |
|
| 275 |
document.newPage();
|
- |
|
| 276 |
}
|
342 |
}
|
| 277 |
} else if (new Long(order.getSource()).intValue() == OrderSource.SNAPDEAL.getValue()) {
|
- |
|
| 278 |
if(withBill){
|
343 |
if(withBill){
|
| 279 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(order, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber());
|
344 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
| 280 |
taxTable.setSpacingBefore(5.0f);
|
345 |
taxTable.setSpacingBefore(5.0f);
|
| 281 |
taxTable.setWidthPercentage(90.0f);
|
346 |
taxTable.setWidthPercentage(90.0f);
|
| 282 |
document.add(new DottedLineSeparator());
|
347 |
document.add(new DottedLineSeparator());
|
| 283 |
document.add(taxTable);
|
348 |
document.add(taxTable);
|
| - |
|
349 |
if(order.getSource() == OrderSource.FLIPKART.getValue()) {
|
| - |
|
350 |
//document.add(new DottedLineSeparator());
|
| - |
|
351 |
document.add(getFlipkartBarCodes(order));
|
| - |
|
352 |
}
|
| - |
|
353 |
|
| 284 |
}else{
|
354 |
}else{
|
| 285 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
355 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
| 286 |
extraInfoTable.setSpacingBefore(5.0f);
|
356 |
extraInfoTable.setSpacingBefore(5.0f);
|
| 287 |
extraInfoTable.setWidthPercentage(90.0f);
|
357 |
extraInfoTable.setWidthPercentage(90.0f);
|
| 288 |
document.add(new DottedLineSeparator());
|
358 |
document.add(new DottedLineSeparator());
|
| 289 |
document.add(extraInfoTable);
|
359 |
document.add(extraInfoTable);
|
| 290 |
}
|
360 |
}
|
| - |
|
361 |
document.newPage();
|
| 291 |
}
|
362 |
}
|
| - |
|
363 |
} else {
|
| - |
|
364 |
for(Order singleOrder : orders){
|
| - |
|
365 |
List<Order> ordersList = new ArrayList<Order>();
|
| - |
|
366 |
ordersList.add(singleOrder);
|
| - |
|
367 |
Warehouse warehouse = null;
|
| - |
|
368 |
Provider provider = null;
|
| - |
|
369 |
String destCode = null;
|
| - |
|
370 |
Warehouse shippingLocation = null;
|
| - |
|
371 |
int barcodeFontSize = 0;
|
| - |
|
372 |
String invoiceFormat = "Individual";
|
| - |
|
373 |
try {
|
| - |
|
374 |
warehouse = iclient.getWarehouse(singleOrder.getWarehouse_id());
|
| - |
|
375 |
long providerId = singleOrder.getLogistics_provider_id();
|
| - |
|
376 |
provider = logisticsClient.getProvider(providerId);
|
| - |
|
377 |
if(provider.getPickup().equals(PickUpType.SELF) || provider.getPickup().equals(PickUpType.RUNNER))
|
| - |
|
378 |
destCode = provider.getPickup().toString();
|
| - |
|
379 |
else
|
| - |
|
380 |
destCode = logisticsClient.getDestinationCode(providerId, singleOrder.getCustomer_pincode());
|
| - |
|
381 |
|
| - |
|
382 |
barcodeFontSize = Integer.parseInt(ConfigClient.getClient().get(provider.getName().toLowerCase() + "_barcode_fontsize"));
|
| - |
|
383 |
shippingLocation = CatalogUtils.getWarehouse(warehouse.getShippingWarehouseId());
|
| - |
|
384 |
} catch (InventoryServiceException ise) {
|
| - |
|
385 |
logger.error("Error while getting the warehouse information.", ise);
|
| - |
|
386 |
return baosPDF;
|
| - |
|
387 |
} catch (LogisticsServiceException lse) {
|
| - |
|
388 |
logger.error("Error while getting the provider information.", lse);
|
| - |
|
389 |
return baosPDF;
|
| - |
|
390 |
} catch (ConfigException ce) {
|
| - |
|
391 |
logger.error("Error while getting the fontsize for the given provider", ce);
|
| - |
|
392 |
return baosPDF;
|
| - |
|
393 |
} catch (TException te) {
|
| - |
|
394 |
logger.error("Error while getting some essential information from the services", te);
|
| - |
|
395 |
return baosPDF;
|
| - |
|
396 |
}
|
| - |
|
397 |
|
| - |
|
398 |
if(printAll && warehouse.getBillingType() == BillingType.OURS_EXTERNAL){
|
| - |
|
399 |
for(Order order : ordersList){
|
| - |
|
400 |
if(isFirst){
|
| - |
|
401 |
document.add(getFixedTextTable(16, "Spice Online Retail Pvt Ltd"));
|
| - |
|
402 |
isFirst = false;
|
| - |
|
403 |
}
|
| - |
|
404 |
document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
|
| - |
|
405 |
continue;
|
| - |
|
406 |
}
|
| - |
|
407 |
}
|
| - |
|
408 |
PdfPTable dispatchAdviceTable = null;
|
| - |
|
409 |
Order order = ordersList.get(0);
|
| - |
|
410 |
if(ordersList.size()==1){
|
| - |
|
411 |
if (new Long(order.getSource()).intValue() == OrderSource.SNAPDEAL.getValue()) {
|
| - |
|
412 |
dispatchAdviceTable = new PdfPTable(1);
|
| - |
|
413 |
} else if(new Long(order.getSource()).intValue() == OrderSource.FLIPKART.getValue()) {
|
| - |
|
414 |
dispatchAdviceTable = new PdfPTable(1);
|
| - |
|
415 |
} else if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7)) {
|
| - |
|
416 |
if(order.getWarehouse_id() == 7 || order.getWarehouse_id() == 5 || order.getWarehouse_id() == 9) {
|
| - |
|
417 |
dispatchAdviceTable = new PdfPTable(1);
|
| - |
|
418 |
} else {
|
| - |
|
419 |
if (order.getAirwaybill_no()== null || order.getAirwaybill_no().equals("null") || order.getAirwaybill_no().isEmpty()) {
|
| - |
|
420 |
dispatchAdviceTable = new PdfPTable(1);
|
| - |
|
421 |
} else {
|
| - |
|
422 |
EbayInvoiceGenerationService invoiceGenerationService = new EbayInvoiceGenerationService();
|
| - |
|
423 |
dispatchAdviceTable = invoiceGenerationService.getDispatchAdviceTable(orderId, warehouseId);
|
| - |
|
424 |
}
|
| - |
|
425 |
}
|
| - |
|
426 |
}
|
| - |
|
427 |
else {
|
| - |
|
428 |
dispatchAdviceTable = getDispatchAdviceTable(ordersList, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation, invoiceFormat);
|
| - |
|
429 |
}
|
| - |
|
430 |
} else {
|
| - |
|
431 |
dispatchAdviceTable = getDispatchAdviceTable(ordersList, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation, invoiceFormat);
|
| - |
|
432 |
}
|
| - |
|
433 |
|
| - |
|
434 |
dispatchAdviceTable.setSpacingAfter(10.0f);
|
| - |
|
435 |
dispatchAdviceTable.setWidthPercentage(90.0f);
|
| - |
|
436 |
document.add(dispatchAdviceTable);
|
| - |
|
437 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
| - |
|
438 |
document.newPage();
|
| - |
|
439 |
}
|
| - |
|
440 |
|
| - |
|
441 |
if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7) &&(ordersList.size()==1)) {
|
| - |
|
442 |
if (order.getAirwaybill_no()== null || order.getAirwaybill_no().equals("null") || order.getAirwaybill_no().isEmpty()
|
| - |
|
443 |
|| order.getWarehouse_id() == 7 || order.getWarehouse_id() == 5 || order.getWarehouse_id() == 9) {
|
| - |
|
444 |
if(withBill){
|
| - |
|
445 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
| - |
|
446 |
taxTable.setSpacingBefore(5.0f);
|
| - |
|
447 |
taxTable.setWidthPercentage(90.0f);
|
| - |
|
448 |
document.add(new DottedLineSeparator());
|
| - |
|
449 |
document.add(taxTable);
|
| - |
|
450 |
}else{
|
| - |
|
451 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
| - |
|
452 |
extraInfoTable.setSpacingBefore(5.0f);
|
| - |
|
453 |
extraInfoTable.setWidthPercentage(90.0f);
|
| - |
|
454 |
document.add(new DottedLineSeparator());
|
| - |
|
455 |
document.add(extraInfoTable);
|
| - |
|
456 |
}
|
| - |
|
457 |
} else {
|
| - |
|
458 |
document.newPage();
|
| - |
|
459 |
}
|
| - |
|
460 |
} else if (new Long(order.getSource()).intValue() == OrderSource.SNAPDEAL.getValue() &&(ordersList.size()==1)) {
|
| - |
|
461 |
if(withBill){
|
| - |
|
462 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
| - |
|
463 |
taxTable.setSpacingBefore(5.0f);
|
| - |
|
464 |
taxTable.setWidthPercentage(90.0f);
|
| - |
|
465 |
document.add(new DottedLineSeparator());
|
| - |
|
466 |
document.add(taxTable);
|
| - |
|
467 |
}else{
|
| - |
|
468 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
| - |
|
469 |
extraInfoTable.setSpacingBefore(5.0f);
|
| - |
|
470 |
extraInfoTable.setWidthPercentage(90.0f);
|
| - |
|
471 |
document.add(new DottedLineSeparator());
|
| - |
|
472 |
document.add(extraInfoTable);
|
| - |
|
473 |
}
|
| - |
|
474 |
}
|
| 292 |
if(withBill){
|
475 |
if(withBill){
|
| 293 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(order, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber());
|
476 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
| 294 |
taxTable.setSpacingBefore(5.0f);
|
477 |
taxTable.setSpacingBefore(5.0f);
|
| 295 |
taxTable.setWidthPercentage(90.0f);
|
478 |
taxTable.setWidthPercentage(90.0f);
|
| 296 |
document.add(new DottedLineSeparator());
|
479 |
document.add(new DottedLineSeparator());
|
| 297 |
document.add(taxTable);
|
480 |
document.add(taxTable);
|
| 298 |
if(order.getSource() == OrderSource.FLIPKART.getValue()) {
|
481 |
if(order.getSource() == OrderSource.FLIPKART.getValue()) {
|
| 299 |
//document.add(new DottedLineSeparator());
|
482 |
//document.add(new DottedLineSeparator());
|
| 300 |
document.add(getFlipkartBarCodes(order));
|
483 |
document.add(getFlipkartBarCodes(order));
|
| - |
|
484 |
}
|
| - |
|
485 |
|
| - |
|
486 |
}else{
|
| - |
|
487 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
| - |
|
488 |
extraInfoTable.setSpacingBefore(5.0f);
|
| - |
|
489 |
extraInfoTable.setWidthPercentage(90.0f);
|
| - |
|
490 |
document.add(new DottedLineSeparator());
|
| - |
|
491 |
document.add(extraInfoTable);
|
| 301 |
}
|
492 |
}
|
| - |
|
493 |
|
| - |
|
494 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
| - |
|
495 |
PdfPTable orderItemsDetailTable = new PdfPTable(1);
|
| - |
|
496 |
orderItemsDetailTable.setWidthPercentage(90.0f);
|
| - |
|
497 |
orderItemsDetailTable.setSpacingBefore(5.0f);
|
| - |
|
498 |
orderItemsDetailTable.addCell(new Phrase("Order Reference Ids :", helveticaBold8));
|
| - |
|
499 |
StringBuffer sbOrders = new StringBuffer();
|
| 302 |
|
500 |
|
| - |
|
501 |
for(Order o1 : orders){
|
| - |
|
502 |
sbOrders.append(o1.getId()+",");
|
| 303 |
}else{
|
503 |
}
|
| - |
|
504 |
|
| - |
|
505 |
|
| - |
|
506 |
String orderIds = sbOrders.toString();
|
| - |
|
507 |
orderIds = orderIds.substring(0, orderIds.length()-1);
|
| - |
|
508 |
|
| 304 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
509 |
orderItemsDetailTable.addCell(new Phrase(orderIds.toString(), helvetica8));
|
| - |
|
510 |
orderItemsDetailTable.addCell(new Phrase("IMEI Details :", helveticaBold8));
|
| - |
|
511 |
|
| 305 |
extraInfoTable.setSpacingBefore(5.0f);
|
512 |
StringBuffer sbImeis = new StringBuffer();
|
| - |
|
513 |
|
| - |
|
514 |
for(Order o1 : orders){
|
| - |
|
515 |
if(o1.getLineitems().get(0).getSerial_number()!=null){
|
| - |
|
516 |
sbImeis.append(o1.getLineitems().get(0).getSerial_number()+",");
|
| - |
|
517 |
}
|
| - |
|
518 |
}
|
| - |
|
519 |
|
| 306 |
extraInfoTable.setWidthPercentage(90.0f);
|
520 |
String imeis = sbImeis.toString();
|
| - |
|
521 |
imeis = imeis.substring(0, imeis.length()-1);
|
| - |
|
522 |
|
| - |
|
523 |
orderItemsDetailTable.addCell(new Phrase(imeis, helvetica8));
|
| - |
|
524 |
|
| 307 |
document.add(new DottedLineSeparator());
|
525 |
document.add(new DottedLineSeparator());
|
| 308 |
document.add(extraInfoTable);
|
526 |
document.add(orderItemsDetailTable);
|
| - |
|
527 |
}
|
| - |
|
528 |
document.newPage();
|
| 309 |
}
|
529 |
}
|
| 310 |
document.newPage();
|
- |
|
| 311 |
}
|
530 |
}
|
| - |
|
531 |
|
| - |
|
532 |
|
| - |
|
533 |
|
| 312 |
document.close();
|
534 |
document.close();
|
| 313 |
baosPDF.close();
|
535 |
baosPDF.close();
|
| 314 |
// Adding facility to store the bill on the local directory. This will happen for only for Mahipalpur warehouse.
|
536 |
// Adding facility to store the bill on the local directory. This will happen for only for Mahipalpur warehouse.
|
| 315 |
if(withBill && !printAll){
|
537 |
if(withBill && !printAll){
|
| 316 |
String strOrderId = StringUtils.repeat("0", 10-String.valueOf(orderId).length()) + orderId;
|
538 |
String strOrderId = StringUtils.repeat("0", 10-String.valueOf(orderId).length()) + orderId;
|
| Line 328... |
Line 550... |
| 328 |
logger.error("Error while generating Invoice: ", e);
|
550 |
logger.error("Error while generating Invoice: ", e);
|
| 329 |
}
|
551 |
}
|
| 330 |
return baosPDF;
|
552 |
return baosPDF;
|
| 331 |
}
|
553 |
}
|
| 332 |
|
554 |
|
| 333 |
private PdfPTable getDispatchAdviceTable(Order order, Warehouse warehouse, Provider provider, float barcodeFontSize, String destCode, boolean withBill, Warehouse shippingLocation){
|
555 |
private PdfPTable getDispatchAdviceTable(List<Order> orderList, Warehouse warehouse, Provider provider, float barcodeFontSize, String destCode, boolean withBill, Warehouse shippingLocation, String invoiceFormat){
|
| - |
|
556 |
Order order = orderList.get(0);
|
| 334 |
Font barCodeFont = getBarCodeFont(provider, barcodeFontSize);
|
557 |
Font barCodeFont = getBarCodeFont(provider, barcodeFontSize);
|
| - |
|
558 |
|
| - |
|
559 |
double totalAmount = 0.0;
|
| - |
|
560 |
double totalWeight = 0.0;
|
| - |
|
561 |
|
| - |
|
562 |
for (Order o: orderList){
|
| - |
|
563 |
totalAmount = totalAmount + order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount();
|
| - |
|
564 |
totalWeight = totalWeight + o.getTotal_weight();
|
| - |
|
565 |
}
|
| 335 |
|
566 |
|
| 336 |
PdfPTable table = new PdfPTable(1);
|
567 |
PdfPTable table = new PdfPTable(1);
|
| 337 |
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
568 |
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 338 |
|
569 |
|
| 339 |
PdfPTable titleBarTable = new PdfPTable(new float[]{0.4f, 0.4f, 0.2f});
|
570 |
PdfPTable titleBarTable = new PdfPTable(new float[]{0.4f, 0.4f, 0.2f});
|
| Line 342... |
Line 573... |
| 342 |
PdfPTable logoTable = new PdfPTable(2);
|
573 |
PdfPTable logoTable = new PdfPTable(2);
|
| 343 |
addLogoTable(logoTable,order);
|
574 |
addLogoTable(logoTable,order);
|
| 344 |
|
575 |
|
| 345 |
PdfPCell titleCell = getTitleCell();
|
576 |
PdfPCell titleCell = getTitleCell();
|
| 346 |
PdfPTable customerTable = getCustomerAddressTable(order, destCode, false, helvetica12, false);
|
577 |
PdfPTable customerTable = getCustomerAddressTable(order, destCode, false, helvetica12, false);
|
| 347 |
PdfPTable providerInfoTable = getProviderTable(order, provider, barCodeFont);
|
578 |
PdfPTable providerInfoTable = getProviderTable(order, provider, barCodeFont, totalWeight);
|
| 348 |
|
579 |
|
| 349 |
PdfPTable dispatchTable = new PdfPTable(new float[]{0.5f, 0.1f, 0.4f});
|
580 |
PdfPTable dispatchTable = new PdfPTable(new float[]{0.5f, 0.1f, 0.4f});
|
| 350 |
dispatchTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
581 |
dispatchTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 351 |
dispatchTable.addCell(customerTable);
|
582 |
dispatchTable.addCell(customerTable);
|
| 352 |
dispatchTable.addCell(new Phrase(" "));
|
583 |
dispatchTable.addCell(new Phrase(" "));
|
| 353 |
dispatchTable.addCell(providerInfoTable);
|
584 |
dispatchTable.addCell(providerInfoTable);
|
| 354 |
|
585 |
|
| 355 |
PdfPTable invoiceTable = getTopInvoiceTable(order, shippingLocation.getTinNumber());
|
586 |
PdfPTable invoiceTable = getTopInvoiceTable(orderList, shippingLocation.getTinNumber(), invoiceFormat);
|
| 356 |
PdfPTable addressTable = new PdfPTable(1);
|
587 |
PdfPTable addressTable = new PdfPTable(1);
|
| 357 |
addressTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
588 |
addressTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 358 |
addressTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
|
589 |
addressTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
|
| 359 |
|
590 |
|
| 360 |
PdfPCell addressCell = getAddressCell(shippingLocation.getLocation() +
|
591 |
PdfPCell addressCell = getAddressCell(shippingLocation.getLocation() +
|
| Line 362... |
Line 593... |
| 362 |
|
593 |
|
| 363 |
PdfPTable chargesTable = new PdfPTable(1);
|
594 |
PdfPTable chargesTable = new PdfPTable(1);
|
| 364 |
chargesTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
595 |
chargesTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 365 |
chargesTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
596 |
chargesTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 366 |
if(order.isLogisticsCod()){
|
597 |
if(order.isLogisticsCod()){
|
| 367 |
chargesTable.addCell(new Phrase("AMOUNT TO BE COLLECTED : Rs " + (order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount()), helveticaBold12));
|
598 |
chargesTable.addCell(new Phrase("AMOUNT TO BE COLLECTED : Rs " + (totalAmount), helveticaBold12));
|
| 368 |
chargesTable.addCell(new Phrase("RTO ADDRESS:DEL/HPW/111116"));
|
599 |
chargesTable.addCell(new Phrase("RTO ADDRESS:DEL/HPW/111116"));
|
| 369 |
//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
600 |
//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
| 370 |
if(order.getLogistics_provider_id()==7L){
|
601 |
if(order.getLogistics_provider_id()==7L){
|
| 371 |
in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
|
602 |
in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
|
| 372 |
String fedexCodReturnBarcode = "";
|
603 |
String fedexCodReturnBarcode = "";
|
| Line 474... |
Line 705... |
| 474 |
titleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
705 |
titleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 475 |
titleCell.setBorder(Rectangle.NO_BORDER);
|
706 |
titleCell.setBorder(Rectangle.NO_BORDER);
|
| 476 |
return titleCell;
|
707 |
return titleCell;
|
| 477 |
}
|
708 |
}
|
| 478 |
|
709 |
|
| 479 |
private PdfPTable getProviderTable(Order order, Provider provider, Font barCodeFont) {
|
710 |
private PdfPTable getProviderTable(Order order, Provider provider, Font barCodeFont, double totalWeight) {
|
| 480 |
PdfPTable providerInfoTable = new PdfPTable(1);
|
711 |
PdfPTable providerInfoTable = new PdfPTable(1);
|
| 481 |
providerInfoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
712 |
providerInfoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 482 |
if(order.isLogisticsCod()){
|
713 |
if(order.isLogisticsCod()){
|
| 483 |
PdfPCell deliveryTypeCell = new PdfPCell(new Phrase("COD ", helvetica22));
|
714 |
PdfPCell deliveryTypeCell = new PdfPCell(new Phrase("COD ", helvetica22));
|
| 484 |
deliveryTypeCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
715 |
deliveryTypeCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
| Line 590... |
Line 821... |
| 590 |
}
|
821 |
}
|
| 591 |
//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
822 |
//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
| 592 |
return providerInfoTable;
|
823 |
return providerInfoTable;
|
| 593 |
}
|
824 |
}
|
| 594 |
|
825 |
|
| 595 |
private PdfPTable getTopInvoiceTable(Order order, String tinNo){
|
826 |
private PdfPTable getTopInvoiceTable(List<Order> orderList, String tinNo, String invoiceFormat){
|
| 596 |
PdfPTable invoiceTable = new PdfPTable(new float[]{0.2f, 0.2f, 0.3f, 0.1f, 0.1f, 0.1f});
|
827 |
PdfPTable invoiceTable = new PdfPTable(new float[]{0.2f, 0.2f, 0.3f, 0.1f, 0.1f, 0.1f});
|
| 597 |
invoiceTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
828 |
invoiceTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 598 |
|
829 |
|
| - |
|
830 |
invoiceTable.addCell(getInvoiceTableHeader(6,orderList.get(0).getLogisticsTransactionId()));
|
| - |
|
831 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
| 599 |
invoiceTable.addCell(getInvoiceTableHeader(6));
|
832 |
invoiceTable.addCell(new Phrase("Sr No", helvetica8));
|
| 600 |
|
833 |
}else{
|
| 601 |
invoiceTable.addCell(new Phrase("Order No", helvetica8));
|
834 |
invoiceTable.addCell(new Phrase("Order No", helvetica8));
|
| - |
|
835 |
}
|
| 602 |
invoiceTable.addCell(new Phrase("Paymode", helvetica8));
|
836 |
invoiceTable.addCell(new Phrase("Paymode", helvetica8));
|
| 603 |
invoiceTable.addCell(new Phrase("Product Name", helvetica8));
|
837 |
invoiceTable.addCell(new Phrase("Product Name", helvetica8));
|
| 604 |
invoiceTable.addCell(new Phrase("Quantity", helvetica8));
|
838 |
invoiceTable.addCell(new Phrase("Quantity", helvetica8));
|
| 605 |
invoiceTable.addCell(new Phrase("Rate", helvetica8));
|
839 |
invoiceTable.addCell(new Phrase("Rate", helvetica8));
|
| 606 |
invoiceTable.addCell(new Phrase("Amount", helvetica8));
|
840 |
invoiceTable.addCell(new Phrase("Amount", helvetica8));
|
| - |
|
841 |
double totalAmount = 0.0;
|
| - |
|
842 |
double insuranceAmount = 0.0;
|
| 607 |
populateTopInvoiceTable(order, invoiceTable);
|
843 |
double advanceAmount = 0.0;
|
| 608 |
|
844 |
|
| 609 |
|
845 |
|
| - |
|
846 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
| - |
|
847 |
Map<Long, String> itemNamesMap= new HashMap<Long, String>();
|
| - |
|
848 |
Map<Long, Double> itemQuantityMap = new HashMap<Long, Double>();
|
| - |
|
849 |
Map<Long, Double> itemRateMap = new HashMap<Long, Double>();
|
| - |
|
850 |
Map<Long, Double> itemTotalAmtMap = new HashMap<Long, Double>();
|
| - |
|
851 |
String paymentMode = "";
|
| - |
|
852 |
for(Order order : orderList){
|
| - |
|
853 |
LineItem lineitem = order.getLineitems().get(0);
|
| - |
|
854 |
totalAmount = totalAmount + order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount();
|
| 610 |
if(order.getInsurer() > 0) {
|
855 |
if(order.getInsurer() > 0) {
|
| - |
|
856 |
insuranceAmount =insuranceAmount + order.getInsuranceAmount();
|
| - |
|
857 |
}
|
| - |
|
858 |
if(order.getSource() == OrderSource.STORE.getValue()) {
|
| - |
|
859 |
advanceAmount = advanceAmount + order.getAdvanceAmount();
|
| - |
|
860 |
}
|
| - |
|
861 |
if(!itemNamesMap.containsKey(lineitem.getItem_id())){
|
| - |
|
862 |
itemNamesMap.put(lineitem.getItem_id(), getItemDisplayName(lineitem, false));
|
| - |
|
863 |
}
|
| - |
|
864 |
if(!itemRateMap.containsKey(lineitem.getItem_id())){
|
| - |
|
865 |
itemRateMap.put(lineitem.getItem_id(), lineitem.getUnit_price());
|
| - |
|
866 |
}
|
| - |
|
867 |
if(itemQuantityMap.containsKey(lineitem.getItem_id())){
|
| - |
|
868 |
double currentQuantity = itemQuantityMap.get(lineitem.getItem_id()) +lineitem.getQuantity();
|
| - |
|
869 |
itemQuantityMap.put(lineitem.getItem_id(), currentQuantity);
|
| - |
|
870 |
}else{
|
| - |
|
871 |
itemQuantityMap.put(lineitem.getItem_id(), lineitem.getQuantity());
|
| - |
|
872 |
}
|
| - |
|
873 |
|
| - |
|
874 |
if(itemTotalAmtMap.containsKey(lineitem.getItem_id())){
|
| - |
|
875 |
double totalItemAmount = itemTotalAmtMap.get(lineitem.getItem_id()) + (order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount());
|
| - |
|
876 |
itemTotalAmtMap.put(lineitem.getItem_id(), totalItemAmount);
|
| - |
|
877 |
}else{
|
| - |
|
878 |
itemTotalAmtMap.put(lineitem.getItem_id(), (order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount()));
|
| - |
|
879 |
}
|
| - |
|
880 |
if(paymentMode==null || paymentMode.isEmpty()){
|
| - |
|
881 |
if(order.getPickupStoreId() > 0 && order.isCod() == true)
|
| - |
|
882 |
paymentMode = "In-Store";
|
| - |
|
883 |
else if (order.isCod())
|
| - |
|
884 |
paymentMode = "COD";
|
| - |
|
885 |
else
|
| - |
|
886 |
paymentMode = "Prepaid";
|
| - |
|
887 |
}
|
| - |
|
888 |
}
|
| - |
|
889 |
|
| - |
|
890 |
int serialNo = 0;
|
| - |
|
891 |
for(Long itemId : itemNamesMap.keySet()){
|
| - |
|
892 |
serialNo ++;
|
| - |
|
893 |
invoiceTable.addCell(new Phrase(serialNo+ "", helvetica8));
|
| - |
|
894 |
invoiceTable.addCell(new Phrase(paymentMode, helvetica8));
|
| - |
|
895 |
invoiceTable.addCell(new Phrase(itemNamesMap.get(itemId), helvetica8));
|
| - |
|
896 |
invoiceTable.addCell(new Phrase(itemQuantityMap.get(itemId)+"", helvetica8));
|
| - |
|
897 |
invoiceTable.addCell(new Phrase(itemRateMap.get(itemId)+"", helvetica8));
|
| - |
|
898 |
invoiceTable.addCell(new Phrase(itemTotalAmtMap.get(itemId)+"", helvetica8));
|
| - |
|
899 |
}
|
| - |
|
900 |
|
| - |
|
901 |
if(insuranceAmount>0){
|
| 611 |
invoiceTable.addCell(getInsuranceCell(4));
|
902 |
invoiceTable.addCell(getInsuranceCell(4));
|
| - |
|
903 |
invoiceTable.addCell(getPriceCell(insuranceAmount));
|
| - |
|
904 |
invoiceTable.addCell(getPriceCell(insuranceAmount));
|
| - |
|
905 |
}
|
| - |
|
906 |
if(advanceAmount>0){
|
| - |
|
907 |
invoiceTable.addCell(getAdvanceAmountCell(4));
|
| - |
|
908 |
invoiceTable.addCell(getPriceCell(advanceAmount));
|
| - |
|
909 |
invoiceTable.addCell(getPriceCell(advanceAmount));
|
| - |
|
910 |
}
|
| - |
|
911 |
}else{
|
| - |
|
912 |
for(Order order : orderList){
|
| - |
|
913 |
populateTopInvoiceTable(order, invoiceTable);
|
| - |
|
914 |
if(order.getInsurer() > 0) {
|
| - |
|
915 |
invoiceTable.addCell(getInsuranceCell(4));
|
| 612 |
invoiceTable.addCell(getPriceCell(order.getInsuranceAmount()));
|
916 |
invoiceTable.addCell(getPriceCell(order.getInsuranceAmount()));
|
| 613 |
invoiceTable.addCell(getPriceCell(order.getInsuranceAmount()));
|
917 |
invoiceTable.addCell(getPriceCell(order.getInsuranceAmount()));
|
| 614 |
}
|
918 |
}
|
| 615 |
|
919 |
|
| 616 |
if(order.getSource() == OrderSource.STORE.getValue()) {
|
920 |
if(order.getSource() == OrderSource.STORE.getValue()) {
|
| 617 |
invoiceTable.addCell(getAdvanceAmountCell(4));
|
921 |
invoiceTable.addCell(getAdvanceAmountCell(4));
|
| 618 |
invoiceTable.addCell(getPriceCell(order.getAdvanceAmount()));
|
922 |
invoiceTable.addCell(getPriceCell(order.getAdvanceAmount()));
|
| 619 |
invoiceTable.addCell(getPriceCell(order.getAdvanceAmount()));
|
923 |
invoiceTable.addCell(getPriceCell(order.getAdvanceAmount()));
|
| - |
|
924 |
}
|
| - |
|
925 |
totalAmount = totalAmount + order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount();
|
| - |
|
926 |
}
|
| 620 |
}
|
927 |
}
|
| 621 |
|
928 |
|
| 622 |
invoiceTable.addCell(getTotalCell(4));
|
929 |
invoiceTable.addCell(getTotalCell(4));
|
| 623 |
invoiceTable.addCell(getRupeesCell());
|
930 |
invoiceTable.addCell(getRupeesCell());
|
| 624 |
invoiceTable.addCell(getTotalAmountCell(order.getTotal_amount()-order.getGvAmount()-order.getAdvanceAmount()));
|
931 |
invoiceTable.addCell(getTotalAmountCell(totalAmount));
|
| - |
|
932 |
|
| 625 |
|
933 |
|
| 626 |
PdfPCell tinCell = new PdfPCell(new Phrase("TIN NO. " + tinNo, helvetica8));
|
934 |
PdfPCell tinCell = new PdfPCell(new Phrase("TIN NO. " + tinNo, helvetica8));
|
| 627 |
tinCell.setColspan(6);
|
935 |
tinCell.setColspan(6);
|
| 628 |
tinCell.setPadding(2);
|
936 |
tinCell.setPadding(2);
|
| 629 |
invoiceTable.addCell(tinCell);
|
937 |
invoiceTable.addCell(tinCell);
|
| Line 659... |
Line 967... |
| 659 |
addressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
967 |
addressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
| 660 |
addressCell.setBorder(Rectangle.NO_BORDER);
|
968 |
addressCell.setBorder(Rectangle.NO_BORDER);
|
| 661 |
return addressCell;
|
969 |
return addressCell;
|
| 662 |
}
|
970 |
}
|
| 663 |
|
971 |
|
| 664 |
private PdfPTable getTaxCumRetailInvoiceTable(Order order, Provider provider, String ourAddress, String tinNo){
|
972 |
private PdfPTable getTaxCumRetailInvoiceTable(List<Order> orderList, Provider provider, String ourAddress, String tinNo, String invoiceFormat){
|
| - |
|
973 |
Order order = orderList.get(0);
|
| 665 |
PdfPTable taxTable = new PdfPTable(1);
|
974 |
PdfPTable taxTable = new PdfPTable(1);
|
| 666 |
Phrase phrase = null;
|
975 |
Phrase phrase = null;
|
| 667 |
taxTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
976 |
taxTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 668 |
taxTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
977 |
taxTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 669 |
|
978 |
|
| Line 697... |
Line 1006... |
| 697 |
addrAndOrderDetailsTable.addCell(customerAddress);
|
1006 |
addrAndOrderDetailsTable.addCell(customerAddress);
|
| 698 |
addrAndOrderDetailsTable.addCell(new Phrase(" "));
|
1007 |
addrAndOrderDetailsTable.addCell(new Phrase(" "));
|
| 699 |
addrAndOrderDetailsTable.addCell(orderDetails);
|
1008 |
addrAndOrderDetailsTable.addCell(orderDetails);
|
| 700 |
|
1009 |
|
| 701 |
boolean isVAT = isVatApplicable(order);
|
1010 |
boolean isVAT = isVatApplicable(order);
|
| 702 |
PdfPTable invoiceTable = getBottomInvoiceTable(order, isVAT);
|
1011 |
PdfPTable invoiceTable = getBottomInvoiceTable(orderList, isVAT, invoiceFormat);
|
| 703 |
|
1012 |
|
| 704 |
PdfPTable regAddAndDisCellTable = new PdfPTable(2);
|
1013 |
PdfPTable regAddAndDisCellTable = new PdfPTable(2);
|
| 705 |
|
1014 |
|
| 706 |
PdfPCell disclaimerCell = new PdfPCell(new Phrase("Goods once sold will not be taken back.\nAll disputes subject to Delhi Jurisdiction.\nThis is a Computer generated Invoice.", helvetica8));
|
1015 |
PdfPCell disclaimerCell = new PdfPCell(new Phrase("Goods once sold will not be taken back.\nAll disputes subject to Delhi Jurisdiction.\nThis is a Computer generated Invoice.", helvetica8));
|
| 707 |
disclaimerCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
1016 |
disclaimerCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
| Line 906... |
Line 1215... |
| 906 |
orderTable.addCell(new Phrase(order.getInvoice_number(), helvetica8));
|
1215 |
orderTable.addCell(new Phrase(order.getInvoice_number(), helvetica8));
|
| 907 |
|
1216 |
|
| 908 |
orderTable.addCell(new Phrase("Date:", helvetica8));
|
1217 |
orderTable.addCell(new Phrase("Date:", helvetica8));
|
| 909 |
orderTable.addCell(new Phrase(DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(order.getBilling_timestamp())), helvetica8));
|
1218 |
orderTable.addCell(new Phrase(DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(order.getBilling_timestamp())), helvetica8));
|
| 910 |
|
1219 |
|
| 911 |
orderTable.addCell(new Phrase("Order ID:", helvetica8));
|
- |
|
| 912 |
orderTable.addCell(new Phrase("" + order.getId(), helvetica8));
|
- |
|
| 913 |
|
- |
|
| 914 |
if(order.getSource() == OrderSource.AMAZON.getValue() || order.getSource() == OrderSource.JUNGLEE.getValue()){
|
1220 |
if(order.getSource() == OrderSource.AMAZON.getValue() || order.getSource() == OrderSource.JUNGLEE.getValue()){
|
| 915 |
AmazonOrder aorder = null;
|
1221 |
AmazonOrder aorder = null;
|
| 916 |
try {
|
1222 |
try {
|
| 917 |
aorder = tsc.getClient().getAmazonOrder(order.getId());
|
1223 |
aorder = tsc.getClient().getAmazonOrder(order.getId());
|
| 918 |
} catch (TException e) {
|
1224 |
} catch (TException e) {
|
| Line 987... |
Line 1293... |
| 987 |
}
|
1293 |
}
|
| 988 |
|
1294 |
|
| 989 |
|
1295 |
|
| 990 |
orderTable.addCell(new Phrase("Order Date:", helvetica8));
|
1296 |
orderTable.addCell(new Phrase("Order Date:", helvetica8));
|
| 991 |
orderTable.addCell(new Phrase(DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(order.getCreated_timestamp())), helvetica8));
|
1297 |
orderTable.addCell(new Phrase(DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(order.getCreated_timestamp())), helvetica8));
|
| - |
|
1298 |
|
| - |
|
1299 |
if(OrderType.B2B==order.getOrderType()){
|
| - |
|
1300 |
try {
|
| - |
|
1301 |
String poRefVal = tsc.getClient().getOrderAttributeValue(order.getId(), "poRefNumber");
|
| - |
|
1302 |
if(poRefVal!=null && poRefVal.length()>0){
|
| - |
|
1303 |
orderTable.addCell(new Phrase("PO Ref:", helvetica8));
|
| - |
|
1304 |
orderTable.addCell(new Phrase(poRefVal, helvetica8));
|
| - |
|
1305 |
}
|
| - |
|
1306 |
|
| - |
|
1307 |
} catch (TException e) {
|
| - |
|
1308 |
logger.error("Error while getting amazon order", e);
|
| - |
|
1309 |
}
|
| - |
|
1310 |
}
|
| 992 |
|
1311 |
|
| 993 |
orderTable.addCell(new Phrase("Courier:", helvetica8));
|
1312 |
orderTable.addCell(new Phrase("Courier:", helvetica8));
|
| 994 |
orderTable.addCell(new Phrase(provider.getName(), helvetica8));
|
1313 |
orderTable.addCell(new Phrase(provider.getName(), helvetica8));
|
| 995 |
|
1314 |
|
| 996 |
if(order.getAirwaybill_no()!=null && !order.getAirwaybill_no().isEmpty()) {
|
1315 |
if(order.getAirwaybill_no()!=null && !order.getAirwaybill_no().isEmpty()) {
|
| Line 1002... |
Line 1321... |
| 1002 |
orderTable.addCell(new Phrase(DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(order.getBilling_timestamp())), helvetica8));
|
1321 |
orderTable.addCell(new Phrase(DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(order.getBilling_timestamp())), helvetica8));
|
| 1003 |
|
1322 |
|
| 1004 |
return orderTable;
|
1323 |
return orderTable;
|
| 1005 |
}
|
1324 |
}
|
| 1006 |
|
1325 |
|
| 1007 |
private PdfPTable getBottomInvoiceTable(Order order, boolean isVAT){
|
1326 |
private PdfPTable getBottomInvoiceTable(List<Order> orderList,boolean isVAT, String invoiceFormat){
|
| 1008 |
PdfPTable invoiceTable = new PdfPTable(new float[]{0.2f, 0.5f, 0.1f, 0.1f, 0.1f});
|
1327 |
PdfPTable invoiceTable = new PdfPTable(new float[]{0.1f, 0.3f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f});
|
| 1009 |
invoiceTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
1328 |
invoiceTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 1010 |
|
1329 |
|
| 1011 |
invoiceTable.addCell(getInvoiceTableHeader(5));
|
1330 |
invoiceTable.addCell(getInvoiceTableHeader(5,orderList.get(0).getLogisticsTransactionId()));
|
| 1012 |
|
1331 |
|
| - |
|
1332 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
| 1013 |
invoiceTable.addCell(new Phrase("Sl. No.", helveticaBold8));
|
1333 |
invoiceTable.addCell(new Phrase("Sr No", helveticaBold8));
|
| - |
|
1334 |
}else{
|
| - |
|
1335 |
invoiceTable.addCell(new Phrase("Order No", helveticaBold8));
|
| - |
|
1336 |
}
|
| 1014 |
invoiceTable.addCell(new Phrase("Description", helveticaBold8));
|
1337 |
invoiceTable.addCell(new Phrase("Description", helveticaBold8));
|
| 1015 |
invoiceTable.addCell(new Phrase("Quantity", helveticaBold8));
|
1338 |
invoiceTable.addCell(new Phrase("Quantity", helveticaBold8));
|
| 1016 |
invoiceTable.addCell(new Phrase("Rate (Rs)", helveticaBold8));
|
1339 |
invoiceTable.addCell(new Phrase("Rate (Rs)", helveticaBold8));
|
| 1017 |
invoiceTable.addCell(new Phrase("Amount (Rs)", helveticaBold8));
|
1340 |
invoiceTable.addCell(new Phrase("Amount (Rs)", helveticaBold8));
|
| - |
|
1341 |
invoiceTable.addCell(new Phrase("Tax Rate%", helveticaBold8));
|
| - |
|
1342 |
invoiceTable.addCell(new Phrase("Tax (Rs)", helveticaBold8));
|
| - |
|
1343 |
invoiceTable.addCell(new Phrase("Item Total (Rs)", helveticaBold8));;
|
| - |
|
1344 |
double totalAmount = 0.0;
|
| - |
|
1345 |
double insuranceAmount = 0.0;
|
| - |
|
1346 |
int i=1;
|
| - |
|
1347 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
| - |
|
1348 |
Map<Long, String> itemNamesMap= new HashMap<Long, String>();
|
| - |
|
1349 |
Map<Long, Double> itemQuantityMap = new HashMap<Long, Double>();
|
| - |
|
1350 |
Map<Long, Double> itemRateMap = new HashMap<Long, Double>();
|
| - |
|
1351 |
Map<Long, Double> itemTotalAmtMap = new HashMap<Long, Double>();
|
| - |
|
1352 |
Map<Long, Double> itemTaxPercentageMap = new HashMap<Long, Double>();
|
| - |
|
1353 |
Map<Long, Double> itemTaxValueMap = new HashMap<Long, Double>();
|
| - |
|
1354 |
|
| - |
|
1355 |
for(Order order : orderList){
|
| 1018 |
LineItem lineItem = order.getLineitems().get(0);
|
1356 |
LineItem lineitem = order.getLineitems().get(0);
|
| - |
|
1357 |
|
| 1019 |
double orderAmount = order.getTotal_amount();
|
1358 |
double orderAmount = order.getTotal_amount();
|
| 1020 |
double rate = lineItem.getVatRate();
|
1359 |
double rate = lineitem.getVatRate();
|
| 1021 |
double salesTax = (rate * (orderAmount - order.getInsuranceAmount()))/(100 + rate);
|
1360 |
double salesTax = (rate * (orderAmount - order.getInsuranceAmount()))/(100 + rate);
|
| - |
|
1361 |
totalAmount = totalAmount + orderAmount;
|
| - |
|
1362 |
double itemPrice = lineitem.getUnit_price();
|
| - |
|
1363 |
double showPrice = (100 * itemPrice)/(100 + rate);
|
| - |
|
1364 |
double totalPrice = lineitem.getTotal_price();
|
| - |
|
1365 |
double showTotalPrice = (100 * totalPrice)/(100 + rate);
|
| - |
|
1366 |
|
| - |
|
1367 |
if(order.getInsurer() > 0) {
|
| - |
|
1368 |
insuranceAmount =insuranceAmount + order.getInsuranceAmount();
|
| - |
|
1369 |
}
|
| 1022 |
|
1370 |
|
| - |
|
1371 |
if(!itemNamesMap.containsKey(lineitem.getItem_id())){
|
| - |
|
1372 |
itemNamesMap.put(lineitem.getItem_id(), getItemDisplayName(lineitem, false));
|
| - |
|
1373 |
}
|
| - |
|
1374 |
if(itemQuantityMap.containsKey(lineitem.getItem_id())){
|
| - |
|
1375 |
double quantity = itemQuantityMap.get(lineitem.getItem_id()) + lineitem.getQuantity();
|
| - |
|
1376 |
itemQuantityMap.put(lineitem.getItem_id(), quantity);
|
| - |
|
1377 |
} else {
|
| - |
|
1378 |
itemQuantityMap.put(lineitem.getItem_id(),lineitem.getQuantity());
|
| - |
|
1379 |
}
|
| - |
|
1380 |
if(!itemRateMap.containsKey(lineitem.getItem_id())){
|
| - |
|
1381 |
itemRateMap.put(lineitem.getItem_id(), showPrice);
|
| - |
|
1382 |
}
|
| - |
|
1383 |
if(!itemTaxPercentageMap.containsKey(lineitem.getItem_id())){
|
| 1023 |
populateBottomInvoiceTable(order, invoiceTable, rate);
|
1384 |
itemTaxPercentageMap.put(lineitem.getItem_id(), rate);
|
| - |
|
1385 |
}
|
| - |
|
1386 |
if(itemTaxValueMap.containsKey(lineitem.getItem_id())){
|
| - |
|
1387 |
double taxValue = itemTaxValueMap.get(lineitem.getItem_id()) + salesTax;
|
| - |
|
1388 |
itemTaxValueMap.put(lineitem.getItem_id(), taxValue);
|
| - |
|
1389 |
}else{
|
| - |
|
1390 |
itemTaxValueMap.put(lineitem.getItem_id(), salesTax);
|
| - |
|
1391 |
}
|
| - |
|
1392 |
if(itemTotalAmtMap.containsKey(lineitem.getItem_id())){
|
| - |
|
1393 |
double totalItemAmount = itemTotalAmtMap.get(lineitem.getItem_id()) + showTotalPrice;
|
| - |
|
1394 |
itemTotalAmtMap.put(lineitem.getItem_id(), totalItemAmount);
|
| - |
|
1395 |
}else{
|
| - |
|
1396 |
itemTotalAmtMap.put(lineitem.getItem_id(), showTotalPrice);
|
| - |
|
1397 |
}
|
| - |
|
1398 |
}
|
| 1024 |
|
1399 |
|
| - |
|
1400 |
for(Long itemId : itemNamesMap.keySet()){
|
| 1025 |
PdfPCell salesTaxCell = getPriceCell(salesTax);
|
1401 |
invoiceTable.addCell(new Phrase(i+"", helveticaBold8));
|
| - |
|
1402 |
invoiceTable.addCell(new Phrase(itemNamesMap.get(itemId),helvetica8));
|
| - |
|
1403 |
invoiceTable.addCell(new Phrase(itemQuantityMap.get(itemId)+"",helvetica8));
|
| - |
|
1404 |
invoiceTable.addCell(new Phrase(itemRateMap.get(itemId)+"",helvetica8));
|
| - |
|
1405 |
invoiceTable.addCell(new Phrase(itemTotalAmtMap.get(itemId)+"",helvetica8));
|
| - |
|
1406 |
invoiceTable.addCell(new Phrase(itemTaxPercentageMap.get(itemId)+"",helvetica8));
|
| - |
|
1407 |
invoiceTable.addCell(new Phrase(itemTaxValueMap.get(itemId)+"",helvetica8));
|
| - |
|
1408 |
invoiceTable.addCell(new Phrase((itemTotalAmtMap.get(itemId)+itemTaxValueMap.get(itemId))+"",helvetica8));
|
| - |
|
1409 |
}
|
| - |
|
1410 |
}
|
| - |
|
1411 |
else{
|
| 1026 |
|
1412 |
|
| - |
|
1413 |
for(Order order :orderList){
|
| - |
|
1414 |
LineItem lineItem = order.getLineitems().get(0);
|
| - |
|
1415 |
double orderAmount = order.getTotal_amount();
|
| 1027 |
if(order.getTaxType().equals(TaxType.CFORM)) {
|
1416 |
double rate = lineItem.getVatRate();
|
| - |
|
1417 |
double salesTax = (rate * (orderAmount - order.getInsuranceAmount()))/(100 + rate);
|
| - |
|
1418 |
|
| - |
|
1419 |
invoiceTable.addCell(new Phrase(order.getId()+"", helveticaBold8));
|
| - |
|
1420 |
invoiceTable.addCell(getProductNameCell(lineItem, true, order.getFreebieItemId()));
|
| - |
|
1421 |
invoiceTable.addCell(new Phrase("" + lineItem.getQuantity(), helvetica8));
|
| - |
|
1422 |
|
| - |
|
1423 |
|
| - |
|
1424 |
//populateBottomInvoiceTable(order, invoiceTable, rate);
|
| - |
|
1425 |
|
| - |
|
1426 |
double itemPrice = lineItem.getUnit_price();
|
| - |
|
1427 |
double showPrice = (100 * itemPrice)/(100 + rate);
|
| 1028 |
invoiceTable.addCell(getCFORMLabelCell());
|
1428 |
invoiceTable.addCell(getPriceCell(showPrice));
|
| 1029 |
} else {
|
1429 |
|
| - |
|
1430 |
double totalPrice = lineItem.getTotal_price();
|
| - |
|
1431 |
showPrice = (100 * totalPrice)/(100 + rate);
|
| 1030 |
invoiceTable.addCell(getVATLabelCell(isVAT));
|
1432 |
invoiceTable.addCell(getPriceCell(showPrice));
|
| - |
|
1433 |
|
| - |
|
1434 |
PdfPCell salesTaxCell = getPriceCell(salesTax);
|
| - |
|
1435 |
|
| - |
|
1436 |
|
| - |
|
1437 |
invoiceTable.addCell(new Phrase(rate + "%", helvetica8));
|
| - |
|
1438 |
invoiceTable.addCell(salesTaxCell);
|
| - |
|
1439 |
invoiceTable.addCell(getTotalAmountCell(orderAmount));
|
| - |
|
1440 |
|
| - |
|
1441 |
if(order.getInsurer() > 0) {
|
| - |
|
1442 |
insuranceAmount =insuranceAmount + order.getInsuranceAmount();
|
| - |
|
1443 |
}
|
| - |
|
1444 |
totalAmount = totalAmount+ orderAmount;
|
| - |
|
1445 |
i++;
|
| - |
|
1446 |
}
|
| 1031 |
}
|
1447 |
}
|
| 1032 |
invoiceTable.addCell(new Phrase(rate + "%", helvetica8));
|
- |
|
| 1033 |
invoiceTable.addCell(salesTaxCell);
|
- |
|
| 1034 |
|
1448 |
|
| 1035 |
if(order.getInsurer() > 0) {
|
1449 |
if(insuranceAmount>0){
|
| 1036 |
invoiceTable.addCell(getInsuranceCell(3));
|
1450 |
invoiceTable.addCell(getInsuranceCell(7));
|
| 1037 |
invoiceTable.addCell(getPriceCell(order.getInsuranceAmount()));
|
- |
|
| 1038 |
invoiceTable.addCell(getPriceCell(order.getInsuranceAmount()));
|
1451 |
invoiceTable.addCell(getPriceCell(insuranceAmount));
|
| 1039 |
}
|
1452 |
}
|
| 1040 |
|
1453 |
|
| 1041 |
invoiceTable.addCell(getEmptyCell(5));
|
- |
|
| 1042 |
|
- |
|
| 1043 |
invoiceTable.addCell(getTotalCell(3));
|
1454 |
invoiceTable.addCell(getTotalCell(6));
|
| 1044 |
invoiceTable.addCell(getRupeesCell());
|
1455 |
invoiceTable.addCell(getRupeesCell());
|
| 1045 |
invoiceTable.addCell(getTotalAmountCell(orderAmount));
|
1456 |
invoiceTable.addCell(getTotalAmountCell(totalAmount));
|
| 1046 |
|
1457 |
|
| 1047 |
invoiceTable.addCell(new Phrase("Amount in Words:", helvetica8));
|
1458 |
invoiceTable.addCell(new Phrase("Amount in Words:", helveticaBold8));
|
| 1048 |
invoiceTable.addCell(getAmountInWordsCell(orderAmount));
|
1459 |
invoiceTable.addCell(getAmountInWordsCell(totalAmount));
|
| 1049 |
|
1460 |
|
| 1050 |
invoiceTable.addCell(getEOECell(5));
|
1461 |
invoiceTable.addCell(getEOECell(8));
|
| 1051 |
|
1462 |
|
| 1052 |
return invoiceTable;
|
1463 |
return invoiceTable;
|
| 1053 |
}
|
1464 |
}
|
| 1054 |
|
1465 |
|
| 1055 |
private PdfPCell getInvoiceTableHeader(int colspan) {
|
1466 |
private PdfPCell getInvoiceTableHeader(int colspan, String masterOrderId) {
|
| - |
|
1467 |
PdfPTable invoiceHeaderTable = new PdfPTable(2);
|
| - |
|
1468 |
PdfPCell masterOrderIdCell = new PdfPCell(new Phrase("Master Order Id- "+masterOrderId, helvetica10));
|
| - |
|
1469 |
masterOrderIdCell.setBorder(Rectangle.NO_BORDER);
|
| - |
|
1470 |
masterOrderIdCell.setColspan(colspan);
|
| - |
|
1471 |
masterOrderIdCell.setPaddingTop(1);
|
| 1056 |
PdfPCell invoiceTableHeader = new PdfPCell(new Phrase("Order Details:", helveticaBold12));
|
1472 |
PdfPCell invoiceTableHeader = new PdfPCell(new Phrase("Order Details: Master Order Id- "+masterOrderId, helveticaBold12));
|
| 1057 |
invoiceTableHeader.setBorder(Rectangle.NO_BORDER);
|
1473 |
invoiceTableHeader.setBorder(Rectangle.NO_BORDER);
|
| 1058 |
invoiceTableHeader.setColspan(colspan);
|
1474 |
invoiceTableHeader.setColspan(colspan);
|
| 1059 |
invoiceTableHeader.setPaddingTop(1);
|
1475 |
invoiceTableHeader.setPaddingTop(1);
|
| - |
|
1476 |
invoiceHeaderTable.addCell(invoiceTableHeader);
|
| - |
|
1477 |
invoiceHeaderTable.addCell(masterOrderIdCell);
|
| - |
|
1478 |
|
| 1060 |
return invoiceTableHeader;
|
1479 |
return new PdfPCell(invoiceHeaderTable);
|
| 1061 |
}
|
1480 |
}
|
| 1062 |
|
1481 |
|
| 1063 |
private void populateBottomInvoiceTable(Order order, PdfPTable invoiceTable, double rate) {
|
1482 |
/*private void populateBottomInvoiceTable(List<Order> orderList, PdfPTable invoiceTable) {
|
| 1064 |
for (LineItem lineitem : order.getLineitems()) {
|
1483 |
for (LineItem lineitem : order.getLineitems()) {
|
| 1065 |
invoiceTable.addCell(new Phrase("" + order.getId() , helvetica8));
|
1484 |
invoiceTable.addCell(new Phrase("" + order.getId() , helvetica8));
|
| 1066 |
|
1485 |
|
| 1067 |
invoiceTable.addCell(getProductNameCell(lineitem, true, order.getFreebieItemId()));
|
1486 |
invoiceTable.addCell(getProductNameCell(lineitem, true, order.getFreebieItemId()));
|
| 1068 |
|
1487 |
|
| Line 1074... |
Line 1493... |
| 1074 |
|
1493 |
|
| 1075 |
double totalPrice = lineitem.getTotal_price();
|
1494 |
double totalPrice = lineitem.getTotal_price();
|
| 1076 |
showPrice = (100 * totalPrice)/(100 + rate);
|
1495 |
showPrice = (100 * totalPrice)/(100 + rate);
|
| 1077 |
invoiceTable.addCell(getPriceCell(showPrice)); //Total Price Cell
|
1496 |
invoiceTable.addCell(getPriceCell(showPrice)); //Total Price Cell
|
| 1078 |
}
|
1497 |
}
|
| 1079 |
}
|
1498 |
}*/
|
| 1080 |
|
1499 |
|
| 1081 |
private PdfPCell getProductNameCell(LineItem lineitem, boolean appendIMEI, Long freebieItemId) {
|
1500 |
private PdfPCell getProductNameCell(LineItem lineitem, boolean appendIMEI, Long freebieItemId) {
|
| 1082 |
String itemName = getItemDisplayName(lineitem, appendIMEI);
|
1501 |
String itemName = getItemDisplayName(lineitem, appendIMEI);
|
| 1083 |
if(freebieItemId!=null && freebieItemId!=0){
|
1502 |
if(freebieItemId!=null && freebieItemId!=0){
|
| 1084 |
try {
|
1503 |
try {
|
| Line 1128... |
Line 1547... |
| 1128 |
return insuranceCell;
|
1547 |
return insuranceCell;
|
| 1129 |
}
|
1548 |
}
|
| 1130 |
|
1549 |
|
| 1131 |
private PdfPCell getInsuranceCell(int colspan) {
|
1550 |
private PdfPCell getInsuranceCell(int colspan) {
|
| 1132 |
PdfPCell insuranceCell = null;
|
1551 |
PdfPCell insuranceCell = null;
|
| 1133 |
insuranceCell = new PdfPCell(new Phrase("1 Year WorldWide Theft Insurance", helvetica8));
|
1552 |
insuranceCell = new PdfPCell(new Phrase("1 Year WorldWide Theft Insurance. T&C Apply", helvetica8));
|
| 1134 |
insuranceCell.setColspan(colspan);
|
1553 |
insuranceCell.setColspan(colspan);
|
| 1135 |
insuranceCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
1554 |
insuranceCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
| 1136 |
return insuranceCell;
|
1555 |
return insuranceCell;
|
| 1137 |
}
|
1556 |
}
|
| 1138 |
|
1557 |
|
| Line 1141... |
Line 1560... |
| 1141 |
emptyCell.setColspan(colspan);
|
1560 |
emptyCell.setColspan(colspan);
|
| 1142 |
return emptyCell;
|
1561 |
return emptyCell;
|
| 1143 |
}
|
1562 |
}
|
| 1144 |
|
1563 |
|
| 1145 |
private PdfPCell getTotalCell(int colspan) {
|
1564 |
private PdfPCell getTotalCell(int colspan) {
|
| 1146 |
PdfPCell totalCell = new PdfPCell(new Phrase("Total", helveticaBold8));
|
1565 |
PdfPCell totalCell = new PdfPCell(new Phrase("Grand Total", helveticaBold8));
|
| 1147 |
totalCell.setColspan(colspan);
|
1566 |
totalCell.setColspan(colspan);
|
| 1148 |
totalCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
1567 |
totalCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
| 1149 |
return totalCell;
|
1568 |
return totalCell;
|
| 1150 |
}
|
1569 |
}
|
| 1151 |
|
1570 |
|