Subversion Repositories SmartDukaan

Rev

Rev 8174 | Rev 8194 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8174 Rev 8182
Line 12... Line 12...
12
import in.shop2020.model.v1.inventory.BillingType;
12
import in.shop2020.model.v1.inventory.BillingType;
13
import in.shop2020.model.v1.inventory.InventoryServiceException;
13
import in.shop2020.model.v1.inventory.InventoryServiceException;
14
import in.shop2020.model.v1.inventory.Warehouse;
14
import in.shop2020.model.v1.inventory.Warehouse;
15
import in.shop2020.model.v1.order.AmazonOrder;
15
import in.shop2020.model.v1.order.AmazonOrder;
16
import in.shop2020.model.v1.order.Attribute;
16
import in.shop2020.model.v1.order.Attribute;
-
 
17
import in.shop2020.model.v1.order.EbayOrder;
17
import in.shop2020.model.v1.order.LineItem;
18
import in.shop2020.model.v1.order.LineItem;
18
import in.shop2020.model.v1.order.Order;
19
import in.shop2020.model.v1.order.Order;
19
import in.shop2020.model.v1.order.OrderSource;
20
import in.shop2020.model.v1.order.OrderSource;
20
import in.shop2020.model.v1.order.OrderStatus;
21
import in.shop2020.model.v1.order.OrderStatus;
21
import in.shop2020.model.v1.order.OrderType;
22
import in.shop2020.model.v1.order.OrderType;
Line 94... Line 95...
94
		} catch(Exception e){
95
		} catch(Exception e){
95
			logger.warn("Couldn't infer whether bill should be printed. Not printing the bill.", e);
96
			logger.warn("Couldn't infer whether bill should be printed. Not printing the bill.", e);
96
		}
97
		}
97
 
98
 
98
		logger.info("Printing invoice for order id: " + orderId);
99
		logger.info("Printing invoice for order id: " + orderId);
-
 
100
		
-
 
101
		//ByteArrayOutputStream baos = null;
99
 
102
	
100
		InvoiceGenerationService invoiceGenerationService = new InvoiceGenerationService();
103
		InvoiceGenerationService invoiceGenerationService = new InvoiceGenerationService();
101
		ByteArrayOutputStream baos = invoiceGenerationService.generateInvoice(orderId, withBill, printAll, warehouseId);
104
		baos = invoiceGenerationService.generateInvoice(orderId, withBill, printAll, warehouseId);
-
 
105
 
102
		response.setContentType("application/pdf");
106
		response.setContentType("application/pdf");
103
		response.setHeader("Content-disposition", "inline; filename=invoice-"+orderId+".pdf" );
107
		response.setHeader("Content-disposition", "inline; filename=invoice-"+orderId+".pdf" );
104
 
108
 
105
		ServletOutputStream sos;
109
		ServletOutputStream sos;
106
		try {
110
		try {
Line 218... Line 222...
218
						isFirst = false;
222
						isFirst = false;
219
					}
223
					}
220
					document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
224
					document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
221
					continue;
225
					continue;
222
				}
226
				}
-
 
227
				
-
 
228
				PdfPTable dispatchAdviceTable = null;
-
 
229
				//TODO fix this logic
-
 
230
				if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7)) {
-
 
231
					EbayInvoiceGenerationService invoiceGenerationService = new EbayInvoiceGenerationService();
-
 
232
					dispatchAdviceTable = invoiceGenerationService.getDispatchAdviceTable(orderId, warehouseId);
-
 
233
				} else {
223
 
234
				
224
				PdfPTable dispatchAdviceTable = getDispatchAdviceTable(order, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation);
235
					dispatchAdviceTable = getDispatchAdviceTable(order, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation);
-
 
236
				}
225
				dispatchAdviceTable.setSpacingAfter(10.0f);
237
				dispatchAdviceTable.setSpacingAfter(10.0f);
226
				dispatchAdviceTable.setWidthPercentage(90.0f);
238
				dispatchAdviceTable.setWidthPercentage(90.0f);
227
 
239
 
228
				document.add(dispatchAdviceTable);
240
				document.add(dispatchAdviceTable);
-
 
241
				//TODO fix this logic
-
 
242
				if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7)) {
-
 
243
					document.newPage();
-
 
244
				}
229
				if(withBill){
245
				if(withBill){
230
					PdfPTable taxTable = getTaxCumRetailInvoiceTable(order, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber());
246
					PdfPTable taxTable = getTaxCumRetailInvoiceTable(order, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber());
231
					taxTable.setSpacingBefore(5.0f);
247
					taxTable.setSpacingBefore(5.0f);
232
					taxTable.setWidthPercentage(90.0f);
248
					taxTable.setWidthPercentage(90.0f);
233
					document.add(new DottedLineSeparator());
249
					document.add(new DottedLineSeparator());
Line 504... Line 520...
504
		}
520
		}
505
		if(order.getLogistics_provider_id()!=7L){
521
		if(order.getLogistics_provider_id()!=7L){
506
			providerInfoTable.addCell(new Phrase("AWB Date   : " + DateFormat.getDateInstance(DateFormat.MEDIUM).format(awbDate), helvetica8));
522
			providerInfoTable.addCell(new Phrase("AWB Date   : " + DateFormat.getDateInstance(DateFormat.MEDIUM).format(awbDate), helvetica8));
507
		}
523
		}
508
		providerInfoTable.addCell(new Phrase("Weight         : " + order.getTotal_weight() + " Kg", helvetica8));
524
		providerInfoTable.addCell(new Phrase("Weight         : " + order.getTotal_weight() + " Kg", helvetica8));
-
 
525
		if(order.getSource() == OrderSource.EBAY.getValue()){
-
 
526
			EbayOrder ebayOrder = null;
-
 
527
			try {
-
 
528
				ebayOrder = tsc.getClient().getEbayOrderByOrderId(order.getId());
-
 
529
			} catch (TException e) {
-
 
530
				logger.error("Error while getting ebay order", e);
-
 
531
			}
-
 
532
			providerInfoTable.addCell(new Phrase("PaisaPayId            : " + ebayOrder.getPaisaPayId(), helvetica8));
-
 
533
			providerInfoTable.addCell(new Phrase("Sales Rec Number: " + ebayOrder.getSalesRecordNumber(), helvetica8));
-
 
534
		}
509
		//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
535
		//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
510
		if(order.getLogistics_provider_id()==7L){
536
		if(order.getLogistics_provider_id()==7L){
511
			providerInfoTable.addCell(new Phrase("Bill T/C Sender      "+ "Bill D/T Sender", helvetica8));
537
			providerInfoTable.addCell(new Phrase("Bill T/C Sender      "+ "Bill D/T Sender", helvetica8));
512
		}
538
		}
513
		//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
539
		//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
Line 735... Line 761...
735
			} catch (TException e) {
761
			} catch (TException e) {
736
				logger.error("Error while getting amazon order", e);
762
				logger.error("Error while getting amazon order", e);
737
			}
763
			}
738
			orderTable.addCell(new Phrase("Amazon Order ID:", helvetica8));
764
			orderTable.addCell(new Phrase("Amazon Order ID:", helvetica8));
739
			orderTable.addCell(new Phrase(aorder.getAmazonOrderCode(), helvetica8));
765
			orderTable.addCell(new Phrase(aorder.getAmazonOrderCode(), helvetica8));
-
 
766
		} else if(order.getSource() == OrderSource.EBAY.getValue()){
-
 
767
			EbayOrder ebayOrder = null;
-
 
768
			try {
-
 
769
				ebayOrder = tsc.getClient().getEbayOrderByOrderId(order.getId());
-
 
770
			} catch (TException e) {
-
 
771
				logger.error("Error while getting ebay order", e);
-
 
772
			}
-
 
773
			orderTable.addCell(new Phrase("PaisaPayId:", helvetica8));
-
 
774
			orderTable.addCell(new Phrase(ebayOrder.getPaisaPayId(), helvetica8));
-
 
775
			orderTable.addCell(new Phrase("Sales Rec Number:", helvetica8));
-
 
776
			orderTable.addCell(new Phrase(new Long(ebayOrder.getSalesRecordNumber()).toString(), helvetica8));
740
		}
777
		}
741
 
778
 
742
		orderTable.addCell(new Phrase("Order Date:", helvetica8));
779
		orderTable.addCell(new Phrase("Order Date:", helvetica8));
743
		orderTable.addCell(new Phrase(DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(order.getCreated_timestamp())), helvetica8));
780
		orderTable.addCell(new Phrase(DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(order.getCreated_timestamp())), helvetica8));
744
 
781