Subversion Repositories SmartDukaan

Rev

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

Rev 18847 Rev 18875
Line 6... Line 6...
6
import in.shop2020.logistics.PickUpType;
6
import in.shop2020.logistics.PickUpType;
7
import in.shop2020.logistics.PickupStore;
7
import in.shop2020.logistics.PickupStore;
8
import in.shop2020.logistics.Provider;
8
import in.shop2020.logistics.Provider;
9
import in.shop2020.logistics.ProviderDetails;
9
import in.shop2020.logistics.ProviderDetails;
10
import in.shop2020.model.v1.catalog.CatalogService;
10
import in.shop2020.model.v1.catalog.CatalogService;
-
 
11
import in.shop2020.model.v1.catalog.CatalogServiceException;
11
import in.shop2020.model.v1.catalog.Item;
12
import in.shop2020.model.v1.catalog.Item;
12
import in.shop2020.model.v1.inventory.BillingType;
13
import in.shop2020.model.v1.inventory.BillingType;
13
import in.shop2020.model.v1.inventory.InventoryServiceException;
14
import in.shop2020.model.v1.inventory.InventoryServiceException;
14
import in.shop2020.model.v1.inventory.Warehouse;
15
import in.shop2020.model.v1.inventory.Warehouse;
15
import in.shop2020.model.v1.order.AmazonOrder;
16
import in.shop2020.model.v1.order.AmazonOrder;
Line 69... Line 70...
69
import com.itextpdf.text.Element;
70
import com.itextpdf.text.Element;
70
import com.itextpdf.text.Font;
71
import com.itextpdf.text.Font;
71
import com.itextpdf.text.FontFactory;
72
import com.itextpdf.text.FontFactory;
72
import com.itextpdf.text.FontFactoryImp;
73
import com.itextpdf.text.FontFactoryImp;
73
import com.itextpdf.text.Image;
74
import com.itextpdf.text.Image;
-
 
75
import com.itextpdf.text.PageSize;
74
import com.itextpdf.text.Paragraph;
76
import com.itextpdf.text.Paragraph;
75
import com.itextpdf.text.Phrase;
77
import com.itextpdf.text.Phrase;
76
import com.itextpdf.text.Rectangle;
78
import com.itextpdf.text.Rectangle;
77
import com.itextpdf.text.Font.FontFamily;
79
import com.itextpdf.text.Font.FontFamily;
78
import com.itextpdf.text.pdf.Barcode128;
80
import com.itextpdf.text.pdf.Barcode128;
Line 181... Line 183...
181
	public ByteArrayOutputStream generateInvoice(long orderId, boolean withBill, boolean printAll, long warehouseId) {
183
	public ByteArrayOutputStream generateInvoice(long orderId, boolean withBill, boolean printAll, long warehouseId) {
182
		ByteArrayOutputStream baosPDF = null;
184
		ByteArrayOutputStream baosPDF = null;
183
		in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
185
		in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
184
		in.shop2020.model.v1.inventory.InventoryService.Client iclient = csc.getClient();
186
		in.shop2020.model.v1.inventory.InventoryService.Client iclient = csc.getClient();
185
		in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
187
		in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
186
		in.shop2020.model.v1.user.UserContextService.Client userClient = usc.getClient();
-
 
187
 
188
		
188
		try {
189
		try {
189
			baosPDF = new ByteArrayOutputStream();
190
			baosPDF = new ByteArrayOutputStream();
190
 
191
 
191
			Document document = new Document();
192
			Document document = new Document();
192
			PdfWriter.getInstance(document, baosPDF);
193
			PdfWriter.getInstance(document, baosPDF);
Line 404... Line 405...
404
							logger.info("Final Imeis List:- " + sbImeis);
405
							logger.info("Final Imeis List:- " + sbImeis);
405
	
406
	
406
							orderItemsDetailTable.addCell(new Phrase(imeis, helvetica8));
407
							orderItemsDetailTable.addCell(new Phrase(imeis, helvetica8));
407
						}
408
						}
408
						
409
						
409
						document.add(new DottedLineSeparator());
-
 
410
						document.add(orderItemsDetailTable);
410
						document.add(orderItemsDetailTable);
411
					}
411
					}
412
					PdfPTable billingAddressTable = getCustomerAddressTable(order, null, true, helvetica8, true, true);
412
					PdfPTable billingAddressTable = getCustomerAddressTable(order, null, true, helvetica8, true, true);
413
					if(billingAddress!=null){
413
					if(billingAddress!=null){
414
						billingAddressTable.setWidthPercentage(90.0f);
414
						billingAddressTable.setWidthPercentage(90.0f);
Line 592... Line 592...
592
							logger.info("Final Imeis List:- " + sbImeis);
592
							logger.info("Final Imeis List:- " + sbImeis);
593
	
593
	
594
							orderItemsDetailTable.addCell(new Phrase(imeis, helvetica8));
594
							orderItemsDetailTable.addCell(new Phrase(imeis, helvetica8));
595
						}
595
						}
596
						
596
						
597
						document.add(new DottedLineSeparator());
-
 
598
						document.add(orderItemsDetailTable);
597
						document.add(orderItemsDetailTable);
599
					}
598
					}
600
					PdfPTable billingAddressTable = getCustomerAddressTable(order, null, true, helvetica8, true, true);
599
					PdfPTable billingAddressTable = getCustomerAddressTable(order, null, true, helvetica8, true, true);
601
					if(billingAddress!=null){
600
					if(billingAddress!=null){
602
						billingAddressTable.setWidthPercentage(90.0f);
601
						billingAddressTable.setWidthPercentage(90.0f);
Line 610... Line 609...
610
					
609
					
611
					document.newPage();
610
					document.newPage();
612
				}
611
				}
613
			}
612
			}
614
			
613
			
-
 
614
			
-
 
615
			if(logisticsTxnIdOrdersMap!=null && logisticsTxnIdOrdersMap.size()>0){
-
 
616
                for(String logisticsTxnId : logisticsTxnIdOrdersMap.keySet()){
-
 
617
                	document.setPageSize(PageSize.A4.rotate());
-
 
618
        	        document.left(100f);
-
 
619
        	        document.top(150f);
-
 
620
					document.newPage(); 
-
 
621
					List<Order> ordersList = logisticsTxnIdOrdersMap.get(logisticsTxnId);
-
 
622
					PdfPTable headerTable = new PdfPTable(1);
-
 
623
	    	        headerTable.addCell(getInvoiceTableHeader(0,ordersList.get(0).getLogisticsTransactionId()));
-
 
624
					PdfPTable packagingTable = getPackagingInfoTable(ordersList);
-
 
625
					document.add(headerTable);
-
 
626
					document.add(packagingTable);
-
 
627
				}
-
 
628
				
-
 
629
			}
-
 
630
			
-
 
631
			
-
 
632
			
615
 
633
 
616
			
634
			
617
			document.close();
635
			document.close();
618
			baosPDF.close();
636
			baosPDF.close();
619
			// Adding facility to store the bill on the local directory. This will happen for only for Mahipalpur warehouse.
637
			// Adding facility to store the bill on the local directory. This will happen for only for Mahipalpur warehouse.
Line 632... Line 650...
632
		} catch (Exception e) {
650
		} catch (Exception e) {
633
			logger.error("Error while generating Invoice: ", e);
651
			logger.error("Error while generating Invoice: ", e);
634
		}
652
		}
635
		return baosPDF;
653
		return baosPDF;
636
	}
654
	}
-
 
655
	
-
 
656
	
-
 
657
	private PdfPTable getPackagingInfoTable(List<Order> orderList) throws CatalogServiceException, TException{
-
 
658
		PdfPTable packagingTable = new PdfPTable(new float[]{0.05f, 0.1f, 0.1f, 0.2f, 0.3f, 0.05f, 0.05f, 0.05f, 0.05f});
-
 
659
		packagingTable.addCell(new Phrase("Item Id", helveticaBold8));
-
 
660
		packagingTable.addCell(new Phrase("BIN Id", helveticaBold8));
-
 
661
		packagingTable.addCell(new Phrase("Sub Order Id", helveticaBold8));
-
 
662
		packagingTable.addCell(new Phrase("Item Description", helveticaBold8));
-
 
663
		packagingTable.addCell(new Phrase("Serial Numbers", helveticaBold8));
-
 
664
		packagingTable.addCell(new Phrase("Pack Size", helveticaBold8));
-
 
665
		packagingTable.addCell(new Phrase("Quantity", helveticaBold8));
-
 
666
		packagingTable.addCell(new Phrase("Total Pieces", helveticaBold8));
-
 
667
		packagingTable.addCell(new Phrase("Unit Price", helveticaBold8));
-
 
668
		
-
 
669
		Map<Long, Item> itemMap = new HashMap<Long, Item>();
-
 
670
		
-
 
671
		CatalogService.Client catalogClient = ctsc.getClient();
-
 
672
		for(Order order:orderList){
-
 
673
			if(!itemMap.containsKey(order.getLineitems().get(0).getItem_id())){
-
 
674
				itemMap.put(order.getLineitems().get(0).getItem_id(), catalogClient.getItem(order.getLineitems().get(0).getItem_id()));
-
 
675
			}
-
 
676
		}
-
 
677
		
-
 
678
		for(Order order:orderList){
-
 
679
			packagingTable.addCell(new Phrase(order.getLineitems().get(0).getItem_id()+"", helvetica8));
-
 
680
			packagingTable.addCell(new Phrase("", helveticaBold8));
-
 
681
			packagingTable.addCell(new Phrase(order.getId()+"", helvetica8));
-
 
682
			packagingTable.addCell(new Phrase(getItemDisplayName(order.getLineitems().get(0), false), helvetica8));
-
 
683
			if(order.getLineitems().get(0).isSetSerial_number()){
-
 
684
				packagingTable.addCell(new Phrase(order.getLineitems().get(0).getSerial_number(), helvetica8));
-
 
685
			}else{
-
 
686
				packagingTable.addCell(new Phrase("", helvetica8));
-
 
687
			}
-
 
688
			packagingTable.addCell(new Phrase(itemMap.get(order.getLineitems().get(0).getItem_id()).getPackQuantity()+"", helvetica8));
-
 
689
			packagingTable.addCell(new Phrase(order.getLineitems().get(0).getQuantity()+"", helvetica8));
-
 
690
			packagingTable.addCell(new Phrase((order.getLineitems().get(0).getQuantity()*itemMap.get(order.getLineitems().get(0).getItem_id()).getPackQuantity())+"", helvetica8));
-
 
691
			packagingTable.addCell(new Phrase(order.getLineitems().get(0).getUnit_price()+"", helvetica8));
-
 
692
		}
-
 
693
		return packagingTable;
-
 
694
	}
637
 
695
 
638
	private PdfPTable getDispatchAdviceTable(List<Order> orderList, Warehouse warehouse, Provider provider, float barcodeFontSize, String destCode, boolean withBill, Warehouse shippingLocation, String invoiceFormat){
696
	private PdfPTable getDispatchAdviceTable(List<Order> orderList, Warehouse warehouse, Provider provider, float barcodeFontSize, String destCode, boolean withBill, Warehouse shippingLocation, String invoiceFormat){
639
		Order order = orderList.get(0);
697
		Order order = orderList.get(0);
640
		Font barCodeFont = getBarCodeFont(provider, barcodeFontSize);
698
		Font barCodeFont = getBarCodeFont(provider, barcodeFontSize);
641
		
699