| Line 4... |
Line 4... |
| 4 |
import in.shop2020.logistics.DeliveryType;
|
4 |
import in.shop2020.logistics.DeliveryType;
|
| 5 |
import in.shop2020.logistics.LogisticsServiceException;
|
5 |
import in.shop2020.logistics.LogisticsServiceException;
|
| 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.model.v1.catalog.CatalogService;
|
| - |
|
10 |
import in.shop2020.model.v1.catalog.Item;
|
| 9 |
import in.shop2020.model.v1.inventory.BillingType;
|
11 |
import in.shop2020.model.v1.inventory.BillingType;
|
| 10 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
12 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
| 11 |
import in.shop2020.model.v1.inventory.Warehouse;
|
13 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 12 |
import in.shop2020.model.v1.order.Attribute;
|
14 |
import in.shop2020.model.v1.order.Attribute;
|
| 13 |
import in.shop2020.model.v1.order.LineItem;
|
15 |
import in.shop2020.model.v1.order.LineItem;
|
| 14 |
import in.shop2020.model.v1.order.Order;
|
16 |
import in.shop2020.model.v1.order.Order;
|
| 15 |
import in.shop2020.model.v1.order.OrderStatus;
|
17 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 16 |
import in.shop2020.model.v1.order.OrderType;
|
18 |
import in.shop2020.model.v1.order.OrderType;
|
| - |
|
19 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 17 |
import in.shop2020.thrift.clients.LogisticsClient;
|
20 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 18 |
import in.shop2020.thrift.clients.TransactionClient;
|
21 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 19 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
22 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 20 |
import in.shop2020.thrift.clients.InventoryClient;
|
23 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 21 |
|
24 |
|
| Line 110... |
Line 113... |
| 110 |
private static Logger logger = LoggerFactory.getLogger(InvoiceGenerationService.class);
|
113 |
private static Logger logger = LoggerFactory.getLogger(InvoiceGenerationService.class);
|
| 111 |
|
114 |
|
| 112 |
private TransactionClient tsc = null;
|
115 |
private TransactionClient tsc = null;
|
| 113 |
private InventoryClient csc = null;
|
116 |
private InventoryClient csc = null;
|
| 114 |
private LogisticsClient lsc = null;
|
117 |
private LogisticsClient lsc = null;
|
| - |
|
118 |
private CatalogClient ctsc = null;
|
| 115 |
|
119 |
|
| 116 |
private static Locale indianLocale = new Locale("en", "IN");
|
120 |
private static Locale indianLocale = new Locale("en", "IN");
|
| 117 |
private DecimalFormat amountFormat = new DecimalFormat("#,##0.00");
|
121 |
private DecimalFormat amountFormat = new DecimalFormat("#,##0.00");
|
| 118 |
|
122 |
|
| 119 |
private static final Font helvetica8 = FontFactory.getFont(FontFactory.HELVETICA, 8);
|
123 |
private static final Font helvetica8 = FontFactory.getFont(FontFactory.HELVETICA, 8);
|
| Line 147... |
Line 151... |
| 147 |
public InvoiceGenerationService() {
|
151 |
public InvoiceGenerationService() {
|
| 148 |
try {
|
152 |
try {
|
| 149 |
tsc = new TransactionClient();
|
153 |
tsc = new TransactionClient();
|
| 150 |
csc = new InventoryClient();
|
154 |
csc = new InventoryClient();
|
| 151 |
lsc = new LogisticsClient();
|
155 |
lsc = new LogisticsClient();
|
| - |
|
156 |
ctsc = new CatalogClient();
|
| 152 |
} catch (Exception e) {
|
157 |
} catch (Exception e) {
|
| 153 |
logger.error("Error while instantiating thrift clients.", e);
|
158 |
logger.error("Error while instantiating thrift clients.", e);
|
| 154 |
}
|
159 |
}
|
| 155 |
}
|
160 |
}
|
| 156 |
|
161 |
|
| Line 423... |
Line 428... |
| 423 |
if(order.isLogisticsCod())
|
428 |
if(order.isLogisticsCod())
|
| 424 |
invoiceTable.addCell(new Phrase("COD", helvetica8));
|
429 |
invoiceTable.addCell(new Phrase("COD", helvetica8));
|
| 425 |
else
|
430 |
else
|
| 426 |
invoiceTable.addCell(new Phrase("Prepaid", helvetica8));
|
431 |
invoiceTable.addCell(new Phrase("Prepaid", helvetica8));
|
| 427 |
*/
|
432 |
*/
|
| 428 |
invoiceTable.addCell(getProductNameCell(lineitem, false));
|
433 |
invoiceTable.addCell(getProductNameCell(lineitem, false, order.getFreebieItemId()));
|
| 429 |
|
434 |
|
| 430 |
invoiceTable.addCell(new Phrase(lineitem.getQuantity() + "", helvetica8));
|
435 |
invoiceTable.addCell(new Phrase(lineitem.getQuantity() + "", helvetica8));
|
| 431 |
|
436 |
|
| 432 |
invoiceTable.addCell(getPriceCell(lineitem.getUnit_price()-order.getGvAmount()));
|
437 |
invoiceTable.addCell(getPriceCell(lineitem.getUnit_price()-order.getGvAmount()));
|
| 433 |
|
438 |
|
| Line 635... |
Line 640... |
| 635 |
|
640 |
|
| 636 |
private void populateBottomInvoiceTable(Order order, PdfPTable invoiceTable, double rate) {
|
641 |
private void populateBottomInvoiceTable(Order order, PdfPTable invoiceTable, double rate) {
|
| 637 |
for (LineItem lineitem : order.getLineitems()) {
|
642 |
for (LineItem lineitem : order.getLineitems()) {
|
| 638 |
invoiceTable.addCell(new Phrase("" + order.getId() , helvetica8));
|
643 |
invoiceTable.addCell(new Phrase("" + order.getId() , helvetica8));
|
| 639 |
|
644 |
|
| 640 |
invoiceTable.addCell(getProductNameCell(lineitem, true));
|
645 |
invoiceTable.addCell(getProductNameCell(lineitem, true, order.getFreebieItemId()));
|
| 641 |
|
646 |
|
| 642 |
invoiceTable.addCell(new Phrase("" + lineitem.getQuantity(), helvetica8));
|
647 |
invoiceTable.addCell(new Phrase("" + lineitem.getQuantity(), helvetica8));
|
| 643 |
|
648 |
|
| 644 |
double itemPrice = lineitem.getUnit_price();
|
649 |
double itemPrice = lineitem.getUnit_price();
|
| 645 |
double showPrice = (100 * itemPrice)/(100 + rate);
|
650 |
double showPrice = (100 * itemPrice)/(100 + rate);
|
| Line 649... |
Line 654... |
| 649 |
showPrice = (100 * totalPrice)/(100 + rate);
|
654 |
showPrice = (100 * totalPrice)/(100 + rate);
|
| 650 |
invoiceTable.addCell(getPriceCell(showPrice)); //Total Price Cell
|
655 |
invoiceTable.addCell(getPriceCell(showPrice)); //Total Price Cell
|
| 651 |
}
|
656 |
}
|
| 652 |
}
|
657 |
}
|
| 653 |
|
658 |
|
| 654 |
private PdfPCell getProductNameCell(LineItem lineitem, boolean appendIMEI) {
|
659 |
private PdfPCell getProductNameCell(LineItem lineitem, boolean appendIMEI, Long freebieItemId) {
|
| 655 |
String itemName = getItemDisplayName(lineitem, appendIMEI);
|
660 |
String itemName = getItemDisplayName(lineitem, appendIMEI);
|
| - |
|
661 |
if(freebieItemId!=null && freebieItemId!=0){
|
| - |
|
662 |
try {
|
| - |
|
663 |
CatalogService.Client catalogClient = ctsc.getClient();
|
| - |
|
664 |
Item item = catalogClient.getItem(freebieItemId);
|
| - |
|
665 |
itemName = itemName + "\n(Free Item: " + item.getBrand() + " " + item.getModelName() + " " + item.getModelNumber() + ")";
|
| - |
|
666 |
} catch(Exception tex) {
|
| - |
|
667 |
logger.error("Not able to get Freebie Item Details for ItemId:" + freebieItemId, tex);
|
| - |
|
668 |
}
|
| - |
|
669 |
}
|
| 656 |
PdfPCell productNameCell = new PdfPCell(new Phrase(itemName, helvetica8));
|
670 |
PdfPCell productNameCell = new PdfPCell(new Phrase(itemName, helvetica8));
|
| 657 |
productNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
671 |
productNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
| 658 |
return productNameCell;
|
672 |
return productNameCell;
|
| 659 |
}
|
673 |
}
|
| 660 |
|
674 |
|