| 2787 |
chandransh |
1 |
package in.shop2020.hotspot.dashbaord.server;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.config.ConfigException;
|
| 3044 |
chandransh |
4 |
import in.shop2020.logistics.DeliveryType;
|
| 2787 |
chandransh |
5 |
import in.shop2020.logistics.LogisticsServiceException;
|
| 5527 |
anupam.sin |
6 |
import in.shop2020.logistics.PickUpType;
|
| 5556 |
rajveer |
7 |
import in.shop2020.logistics.PickupStore;
|
| 2787 |
chandransh |
8 |
import in.shop2020.logistics.Provider;
|
| 7792 |
anupam.sin |
9 |
import in.shop2020.logistics.ProviderDetails;
|
| 7190 |
amar.kumar |
10 |
import in.shop2020.model.v1.catalog.CatalogService;
|
|
|
11 |
import in.shop2020.model.v1.catalog.Item;
|
| 6746 |
rajveer |
12 |
import in.shop2020.model.v1.inventory.BillingType;
|
| 5948 |
mandeep.dh |
13 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
| 5945 |
mandeep.dh |
14 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 7528 |
rajveer |
15 |
import in.shop2020.model.v1.order.AmazonOrder;
|
| 5527 |
anupam.sin |
16 |
import in.shop2020.model.v1.order.Attribute;
|
| 8182 |
amar.kumar |
17 |
import in.shop2020.model.v1.order.EbayOrder;
|
| 13691 |
manish.sha |
18 |
import in.shop2020.model.v1.order.HsOrder;
|
| 2787 |
chandransh |
19 |
import in.shop2020.model.v1.order.LineItem;
|
|
|
20 |
import in.shop2020.model.v1.order.Order;
|
| 7318 |
rajveer |
21 |
import in.shop2020.model.v1.order.OrderSource;
|
| 4361 |
rajveer |
22 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 5527 |
anupam.sin |
23 |
import in.shop2020.model.v1.order.OrderType;
|
| 10310 |
amar.kumar |
24 |
import in.shop2020.model.v1.order.ProductCondition;
|
| 8488 |
amar.kumar |
25 |
import in.shop2020.model.v1.order.SnapdealOrder;
|
| 8996 |
amar.kumar |
26 |
import in.shop2020.model.v1.order.FlipkartOrder;
|
| 9432 |
amar.kumar |
27 |
import in.shop2020.model.v1.order.TaxType;
|
| 18530 |
manish.sha |
28 |
import in.shop2020.model.v1.user.Address;
|
| 7190 |
amar.kumar |
29 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 3132 |
rajveer |
30 |
import in.shop2020.thrift.clients.LogisticsClient;
|
|
|
31 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 2787 |
chandransh |
32 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 5948 |
mandeep.dh |
33 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 18530 |
manish.sha |
34 |
import in.shop2020.thrift.clients.UserClient;
|
| 2787 |
chandransh |
35 |
|
| 8067 |
manish.sha |
36 |
import java.awt.image.BufferedImage;
|
| 2787 |
chandransh |
37 |
import java.io.ByteArrayOutputStream;
|
|
|
38 |
import java.io.File;
|
|
|
39 |
import java.io.FileOutputStream;
|
|
|
40 |
import java.io.IOException;
|
| 8067 |
manish.sha |
41 |
import java.io.OutputStream;
|
| 2787 |
chandransh |
42 |
import java.text.DateFormat;
|
|
|
43 |
import java.text.DecimalFormat;
|
| 4361 |
rajveer |
44 |
import java.util.ArrayList;
|
| 2787 |
chandransh |
45 |
import java.util.Date;
|
| 13276 |
manish.sha |
46 |
import java.util.HashMap;
|
| 2787 |
chandransh |
47 |
import java.util.List;
|
|
|
48 |
import java.util.Locale;
|
| 13276 |
manish.sha |
49 |
import java.util.Map;
|
| 2787 |
chandransh |
50 |
|
|
|
51 |
import javax.servlet.ServletException;
|
|
|
52 |
import javax.servlet.ServletOutputStream;
|
|
|
53 |
import javax.servlet.http.HttpServlet;
|
|
|
54 |
import javax.servlet.http.HttpServletRequest;
|
|
|
55 |
import javax.servlet.http.HttpServletResponse;
|
|
|
56 |
|
| 7014 |
rajveer |
57 |
import org.apache.commons.lang.StringUtils;
|
| 2787 |
chandransh |
58 |
import org.apache.commons.lang.WordUtils;
|
|
|
59 |
import org.apache.thrift.TException;
|
| 8067 |
manish.sha |
60 |
import org.krysalis.barcode4j.impl.code128.Code128Bean;
|
|
|
61 |
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
|
|
|
62 |
import org.krysalis.barcode4j.tools.UnitConv;
|
| 2787 |
chandransh |
63 |
import org.slf4j.Logger;
|
|
|
64 |
import org.slf4j.LoggerFactory;
|
|
|
65 |
|
|
|
66 |
import com.ibm.icu.text.RuleBasedNumberFormat;
|
|
|
67 |
|
|
|
68 |
import com.itextpdf.text.Document;
|
|
|
69 |
import com.itextpdf.text.Element;
|
|
|
70 |
import com.itextpdf.text.Font;
|
|
|
71 |
import com.itextpdf.text.FontFactory;
|
|
|
72 |
import com.itextpdf.text.FontFactoryImp;
|
|
|
73 |
import com.itextpdf.text.Image;
|
|
|
74 |
import com.itextpdf.text.Paragraph;
|
|
|
75 |
import com.itextpdf.text.Phrase;
|
|
|
76 |
import com.itextpdf.text.Rectangle;
|
|
|
77 |
import com.itextpdf.text.Font.FontFamily;
|
| 8034 |
manish.sha |
78 |
import com.itextpdf.text.pdf.Barcode128;
|
| 2787 |
chandransh |
79 |
import com.itextpdf.text.pdf.BaseFont;
|
| 8037 |
manish.sha |
80 |
import com.itextpdf.text.pdf.PdfContentByte;
|
| 2787 |
chandransh |
81 |
import com.itextpdf.text.pdf.PdfPCell;
|
|
|
82 |
import com.itextpdf.text.pdf.PdfPTable;
|
|
|
83 |
import com.itextpdf.text.pdf.PdfWriter;
|
|
|
84 |
import com.itextpdf.text.pdf.draw.DottedLineSeparator;
|
|
|
85 |
|
|
|
86 |
@SuppressWarnings("serial")
|
|
|
87 |
public class InvoiceServlet extends HttpServlet {
|
| 7014 |
rajveer |
88 |
|
|
|
89 |
private static Logger logger = LoggerFactory.getLogger(InvoiceServlet.class);
|
|
|
90 |
|
|
|
91 |
@Override
|
|
|
92 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
93 |
long orderId = Long.parseLong(request.getParameter("id"));
|
| 13276 |
manish.sha |
94 |
String logisticsTxnId = request.getParameter("logisticsTxnId");
|
| 7014 |
rajveer |
95 |
long warehouseId = Long.parseLong(request.getParameter("warehouse"));
|
|
|
96 |
boolean withBill = false;
|
|
|
97 |
boolean printAll = false;
|
|
|
98 |
try {
|
|
|
99 |
withBill = Boolean.parseBoolean(request.getParameter("withBill"));
|
|
|
100 |
} catch(Exception e){
|
|
|
101 |
logger.warn("Couldn't infer whether bill should be printed. Not printing the bill.", e);
|
|
|
102 |
}
|
|
|
103 |
try {
|
|
|
104 |
printAll = Boolean.parseBoolean(request.getParameter("printAll"));
|
|
|
105 |
} catch(Exception e){
|
|
|
106 |
logger.warn("Couldn't infer whether bill should be printed. Not printing the bill.", e);
|
|
|
107 |
}
|
|
|
108 |
|
| 13276 |
manish.sha |
109 |
if(logisticsTxnId!=null && !logisticsTxnId.isEmpty()){
|
|
|
110 |
logger.info("Printing invoice for master order id: " + logisticsTxnId);
|
|
|
111 |
}else{
|
|
|
112 |
logger.info("Printing invoice for order id: " + orderId);
|
|
|
113 |
}
|
| 8182 |
amar.kumar |
114 |
|
| 8194 |
amar.kumar |
115 |
ByteArrayOutputStream baos = null;
|
| 8182 |
amar.kumar |
116 |
|
|
|
117 |
InvoiceGenerationService invoiceGenerationService = new InvoiceGenerationService();
|
|
|
118 |
baos = invoiceGenerationService.generateInvoice(orderId, withBill, printAll, warehouseId);
|
| 7014 |
rajveer |
119 |
|
|
|
120 |
response.setContentType("application/pdf");
|
| 13276 |
manish.sha |
121 |
if(logisticsTxnId!=null && !logisticsTxnId.isEmpty()){
|
|
|
122 |
response.setHeader("Content-disposition", "inline; filename=invoice-"+logisticsTxnId+".pdf" );
|
|
|
123 |
} else {
|
|
|
124 |
response.setHeader("Content-disposition", "inline; filename=invoice-"+orderId+".pdf" );
|
|
|
125 |
}
|
| 7014 |
rajveer |
126 |
|
|
|
127 |
ServletOutputStream sos;
|
|
|
128 |
try {
|
|
|
129 |
sos = response.getOutputStream();
|
|
|
130 |
baos.writeTo(sos);
|
|
|
131 |
sos.flush();
|
|
|
132 |
} catch (IOException e) {
|
|
|
133 |
logger.error("Encountered error while sending invoice response: ", e);
|
|
|
134 |
}
|
|
|
135 |
}
|
| 2787 |
chandransh |
136 |
}
|
|
|
137 |
|
|
|
138 |
class InvoiceGenerationService {
|
|
|
139 |
|
| 7014 |
rajveer |
140 |
private static Logger logger = LoggerFactory.getLogger(InvoiceGenerationService.class);
|
| 2787 |
chandransh |
141 |
|
| 7014 |
rajveer |
142 |
private TransactionClient tsc = null;
|
|
|
143 |
private InventoryClient csc = null;
|
|
|
144 |
private LogisticsClient lsc = null;
|
| 7190 |
amar.kumar |
145 |
private CatalogClient ctsc = null;
|
| 18530 |
manish.sha |
146 |
private UserClient usc = null;
|
| 2787 |
chandransh |
147 |
|
| 7014 |
rajveer |
148 |
private static Locale indianLocale = new Locale("en", "IN");
|
|
|
149 |
private DecimalFormat amountFormat = new DecimalFormat("#,##0.00");
|
| 2787 |
chandransh |
150 |
|
| 7994 |
manish.sha |
151 |
//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
|
|
152 |
private static final Font helvetica6 = FontFactory.getFont(FontFactory.HELVETICA, 6);
|
| 7995 |
manish.sha |
153 |
//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
| 7014 |
rajveer |
154 |
private static final Font helvetica8 = FontFactory.getFont(FontFactory.HELVETICA, 8);
|
|
|
155 |
private static final Font helvetica10 = FontFactory.getFont(FontFactory.HELVETICA, 10);
|
|
|
156 |
private static final Font helvetica12 = FontFactory.getFont(FontFactory.HELVETICA, 12);
|
|
|
157 |
private static final Font helvetica16 = FontFactory.getFont(FontFactory.HELVETICA, 16);
|
| 8551 |
manish.sha |
158 |
private static final Font helvetica22 = FontFactory.getFont(FontFactory.HELVETICA, 22);
|
| 2787 |
chandransh |
159 |
|
| 7014 |
rajveer |
160 |
private static final Font helveticaBold8 = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 8);
|
|
|
161 |
private static final Font helveticaBold12 = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12);
|
|
|
162 |
|
|
|
163 |
private static final String delhiPincodePrefix = "11";
|
| 9319 |
amar.kumar |
164 |
private static final String[] maharashtraPincodePrefix = {"40", "41", "42", "43", "44"};
|
| 16196 |
manish.sha |
165 |
private static final String[] karnatakaPincodePrefix = {"56", "57", "58", "59"};
|
| 12809 |
manish.sha |
166 |
private static final String[] telanganaPincodes = {"500001","500002","500003","500004","500005","500006","500007","500008","500009","500010","500011","500012","500013","500014","500015","500016","500017","500018","500019","500020","500021","500022","500023","500024","500025","500026","500027","500028","500029","500030","500031","500032","500033","500034","500035","500036","500037","500038","500039","500040","500041","500042","500043","500044","500045","500046","500047","500048","500049","500050","500051","500052","500053","500054","500055","500056","500057","500058","500059","500060","500061","500062","500063","500064","500065","500066","500067","500068","500069","500070","500071","500072","500073","500074","500075","500076","500077","500078","500079","500080","500081","500082","500083","500084","500085","500086","500087","500088","500089","500090","500091","500092","500093","500094","500095","500096","500097","500098","500178","500409","501218","501301","501401","501510","501511","501512","502307","502319","517501","517502","517503","517505","517507","520001","520002","520003","520004","520005","520006","520007","520008","520009","520010","520011","520012","520013","520014","520015","521108","521225","522001","522002","522003","522004","522005","522006","522007","522019","522509","530001","530002","530003","530004","530005","530007","530008","530009","530010","530010","530011","530012","530013","530014","530015","530016","530017","530018","530020","530021","530022","530023","530024","530026","530027","530028","530029","530032","530035","530040","530041","530043","530044","530045","530046","531001","533101","533103","533104","533105"};
|
| 7014 |
rajveer |
167 |
|
|
|
168 |
public InvoiceGenerationService() {
|
|
|
169 |
try {
|
|
|
170 |
tsc = new TransactionClient();
|
|
|
171 |
csc = new InventoryClient();
|
|
|
172 |
lsc = new LogisticsClient();
|
| 7190 |
amar.kumar |
173 |
ctsc = new CatalogClient();
|
| 18530 |
manish.sha |
174 |
usc = new UserClient();
|
| 7014 |
rajveer |
175 |
} catch (Exception e) {
|
|
|
176 |
logger.error("Error while instantiating thrift clients.", e);
|
|
|
177 |
}
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
public ByteArrayOutputStream generateInvoice(long orderId, boolean withBill, boolean printAll, long warehouseId) {
|
|
|
181 |
ByteArrayOutputStream baosPDF = null;
|
|
|
182 |
in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
|
|
|
183 |
in.shop2020.model.v1.inventory.InventoryService.Client iclient = csc.getClient();
|
|
|
184 |
in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
|
| 18530 |
manish.sha |
185 |
in.shop2020.model.v1.user.UserContextService.Client userClient = usc.getClient();
|
| 7014 |
rajveer |
186 |
|
|
|
187 |
try {
|
|
|
188 |
baosPDF = new ByteArrayOutputStream();
|
|
|
189 |
|
|
|
190 |
Document document = new Document();
|
| 8039 |
manish.sha |
191 |
PdfWriter.getInstance(document, baosPDF);
|
| 7014 |
rajveer |
192 |
document.addAuthor("shop2020");
|
|
|
193 |
//document.addTitle("Invoice No: " + order.getInvoice_number());
|
|
|
194 |
document.open();
|
| 13276 |
manish.sha |
195 |
//document.bo
|
| 7014 |
rajveer |
196 |
|
|
|
197 |
List<Order> orders = new ArrayList<Order>();
|
| 13276 |
manish.sha |
198 |
Map<String, List<Order>> logisticsTxnIdOrdersMap = new HashMap<String, List<Order>>();
|
| 7014 |
rajveer |
199 |
if(printAll){
|
|
|
200 |
try {
|
|
|
201 |
List<OrderStatus> statuses = new ArrayList<OrderStatus>();
|
|
|
202 |
statuses.add(OrderStatus.ACCEPTED);
|
| 13276 |
manish.sha |
203 |
if(!tclient.isAlive()){
|
|
|
204 |
tclient = tsc.getClient();
|
|
|
205 |
}
|
| 7014 |
rajveer |
206 |
orders = tclient.getAllOrders(statuses, 0, 0, warehouseId);
|
| 13276 |
manish.sha |
207 |
for(Order o:orders){
|
|
|
208 |
if(o.isSetLogisticsTransactionId()){
|
|
|
209 |
if(logisticsTxnIdOrdersMap.containsKey(o.getLogisticsTransactionId())){
|
|
|
210 |
List<Order> groupOrdersList = logisticsTxnIdOrdersMap.get(o.getLogisticsTransactionId());
|
|
|
211 |
groupOrdersList.add(o);
|
|
|
212 |
logisticsTxnIdOrdersMap.put(o.getLogisticsTransactionId(), groupOrdersList);
|
|
|
213 |
}else {
|
|
|
214 |
List<Order> groupOrdersList = new ArrayList<Order>();
|
|
|
215 |
groupOrdersList.add(o);
|
|
|
216 |
logisticsTxnIdOrdersMap.put(o.getLogisticsTransactionId(), groupOrdersList);
|
|
|
217 |
}
|
|
|
218 |
}
|
|
|
219 |
}
|
| 7014 |
rajveer |
220 |
} catch (Exception e) {
|
|
|
221 |
logger.error("Error while getting order information", e);
|
|
|
222 |
return baosPDF;
|
| 4361 |
rajveer |
223 |
}
|
| 7014 |
rajveer |
224 |
}else{
|
| 13276 |
manish.sha |
225 |
if(!tclient.isAlive()){
|
|
|
226 |
tclient = tsc.getClient();
|
|
|
227 |
}
|
|
|
228 |
orders.add(tclient.getOrder(orderId));
|
|
|
229 |
Order o = orders.get(0);
|
|
|
230 |
if(o.isSetLogisticsTransactionId()){
|
|
|
231 |
List<Order> groupOrdersList = tclient.getGroupOrdersByLogisticsTxnId(o.getLogisticsTransactionId());
|
|
|
232 |
logisticsTxnIdOrdersMap.put(o.getLogisticsTransactionId(), groupOrdersList);
|
|
|
233 |
}
|
| 7014 |
rajveer |
234 |
}
|
|
|
235 |
boolean isFirst = true;
|
| 13276 |
manish.sha |
236 |
if(logisticsTxnIdOrdersMap!=null && logisticsTxnIdOrdersMap.size()>0){
|
|
|
237 |
for(String logisticsTxnId : logisticsTxnIdOrdersMap.keySet()){
|
|
|
238 |
List<Order> ordersList = logisticsTxnIdOrdersMap.get(logisticsTxnId);
|
|
|
239 |
Order singleOrder = ordersList.get(0);
|
|
|
240 |
Warehouse warehouse = null;
|
|
|
241 |
Provider provider = null;
|
|
|
242 |
String destCode = null;
|
|
|
243 |
Warehouse shippingLocation = null;
|
|
|
244 |
int barcodeFontSize = 0;
|
|
|
245 |
String invoiceFormat = null;
|
|
|
246 |
try {
|
|
|
247 |
warehouse = iclient.getWarehouse(singleOrder.getWarehouse_id());
|
|
|
248 |
long providerId = singleOrder.getLogistics_provider_id();
|
|
|
249 |
provider = logisticsClient.getProvider(providerId);
|
|
|
250 |
if(provider.getPickup().equals(PickUpType.SELF) || provider.getPickup().equals(PickUpType.RUNNER))
|
|
|
251 |
destCode = provider.getPickup().toString();
|
|
|
252 |
else
|
|
|
253 |
destCode = logisticsClient.getDestinationCode(providerId, singleOrder.getCustomer_pincode());
|
| 5387 |
rajveer |
254 |
|
| 13276 |
manish.sha |
255 |
barcodeFontSize = Integer.parseInt(ConfigClient.getClient().get(provider.getName().toLowerCase() + "_barcode_fontsize"));
|
|
|
256 |
shippingLocation = CatalogUtils.getWarehouse(warehouse.getShippingWarehouseId());
|
|
|
257 |
invoiceFormat = tclient.getInvoiceFormatLogisticsTxnId(singleOrder.getTransactionId(), Long.parseLong(logisticsTxnId.split("-")[1]));
|
|
|
258 |
} catch (InventoryServiceException ise) {
|
|
|
259 |
logger.error("Error while getting the warehouse information.", ise);
|
|
|
260 |
return baosPDF;
|
|
|
261 |
} catch (LogisticsServiceException lse) {
|
|
|
262 |
logger.error("Error while getting the provider information.", lse);
|
|
|
263 |
return baosPDF;
|
|
|
264 |
} catch (ConfigException ce) {
|
|
|
265 |
logger.error("Error while getting the fontsize for the given provider", ce);
|
|
|
266 |
return baosPDF;
|
|
|
267 |
} catch (TException te) {
|
|
|
268 |
logger.error("Error while getting some essential information from the services", te);
|
|
|
269 |
return baosPDF;
|
|
|
270 |
}
|
|
|
271 |
|
|
|
272 |
if(printAll && warehouse.getBillingType() == BillingType.OURS_EXTERNAL){
|
|
|
273 |
for(Order order : ordersList){
|
|
|
274 |
if(isFirst){
|
|
|
275 |
document.add(getFixedTextTable(16, "Spice Online Retail Pvt Ltd"));
|
|
|
276 |
isFirst = false;
|
|
|
277 |
}
|
|
|
278 |
document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
|
|
|
279 |
continue;
|
|
|
280 |
}
|
|
|
281 |
}
|
|
|
282 |
PdfPTable dispatchAdviceTable = null;
|
|
|
283 |
Order order = ordersList.get(0);
|
|
|
284 |
if(ordersList.size()==1){
|
|
|
285 |
if (new Long(order.getSource()).intValue() == OrderSource.SNAPDEAL.getValue()) {
|
|
|
286 |
dispatchAdviceTable = new PdfPTable(1);
|
|
|
287 |
} else if(new Long(order.getSource()).intValue() == OrderSource.FLIPKART.getValue()) {
|
|
|
288 |
dispatchAdviceTable = new PdfPTable(1);
|
| 13691 |
manish.sha |
289 |
} else if(new Long(order.getSource()).intValue() == OrderSource.HOMESHOP18.getValue()) {
|
|
|
290 |
dispatchAdviceTable = new PdfPTable(1);
|
| 13276 |
manish.sha |
291 |
} else if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7)) {
|
|
|
292 |
if(order.getWarehouse_id() == 7 || order.getWarehouse_id() == 5 || order.getWarehouse_id() == 9) {
|
|
|
293 |
dispatchAdviceTable = new PdfPTable(1);
|
|
|
294 |
} else {
|
|
|
295 |
if (order.getAirwaybill_no()== null || order.getAirwaybill_no().equals("null") || order.getAirwaybill_no().isEmpty()) {
|
|
|
296 |
dispatchAdviceTable = new PdfPTable(1);
|
|
|
297 |
} else {
|
|
|
298 |
EbayInvoiceGenerationService invoiceGenerationService = new EbayInvoiceGenerationService();
|
|
|
299 |
dispatchAdviceTable = invoiceGenerationService.getDispatchAdviceTable(orderId, warehouseId);
|
|
|
300 |
}
|
|
|
301 |
}
|
|
|
302 |
}
|
|
|
303 |
else {
|
|
|
304 |
dispatchAdviceTable = getDispatchAdviceTable(ordersList, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation, invoiceFormat);
|
|
|
305 |
}
|
|
|
306 |
} else {
|
|
|
307 |
dispatchAdviceTable = getDispatchAdviceTable(ordersList, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation, invoiceFormat);
|
|
|
308 |
}
|
|
|
309 |
|
|
|
310 |
dispatchAdviceTable.setSpacingAfter(10.0f);
|
|
|
311 |
dispatchAdviceTable.setWidthPercentage(90.0f);
|
|
|
312 |
document.add(dispatchAdviceTable);
|
|
|
313 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
| 13321 |
manish.sha |
314 |
if(ordersList.size()>3 || (order.getLogistics_provider_id()==7 && order.isLogisticsCod())){
|
| 13320 |
manish.sha |
315 |
document.newPage();
|
|
|
316 |
}
|
| 13276 |
manish.sha |
317 |
}
|
|
|
318 |
|
|
|
319 |
if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7) &&(ordersList.size()==1)) {
|
|
|
320 |
if (order.getAirwaybill_no()== null || order.getAirwaybill_no().equals("null") || order.getAirwaybill_no().isEmpty()
|
|
|
321 |
|| order.getWarehouse_id() == 7 || order.getWarehouse_id() == 5 || order.getWarehouse_id() == 9) {
|
|
|
322 |
if(withBill){
|
|
|
323 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
|
|
324 |
taxTable.setSpacingBefore(5.0f);
|
|
|
325 |
taxTable.setWidthPercentage(90.0f);
|
|
|
326 |
document.add(new DottedLineSeparator());
|
|
|
327 |
document.add(taxTable);
|
|
|
328 |
}else{
|
|
|
329 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
|
|
330 |
extraInfoTable.setSpacingBefore(5.0f);
|
|
|
331 |
extraInfoTable.setWidthPercentage(90.0f);
|
|
|
332 |
document.add(new DottedLineSeparator());
|
|
|
333 |
document.add(extraInfoTable);
|
|
|
334 |
}
|
|
|
335 |
} else {
|
|
|
336 |
document.newPage();
|
|
|
337 |
}
|
|
|
338 |
} else if (new Long(order.getSource()).intValue() == OrderSource.SNAPDEAL.getValue() &&(ordersList.size()==1)) {
|
|
|
339 |
if(withBill){
|
|
|
340 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
|
|
341 |
taxTable.setSpacingBefore(5.0f);
|
|
|
342 |
taxTable.setWidthPercentage(90.0f);
|
|
|
343 |
document.add(new DottedLineSeparator());
|
|
|
344 |
document.add(taxTable);
|
|
|
345 |
}else{
|
|
|
346 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
|
|
347 |
extraInfoTable.setSpacingBefore(5.0f);
|
|
|
348 |
extraInfoTable.setWidthPercentage(90.0f);
|
|
|
349 |
document.add(new DottedLineSeparator());
|
|
|
350 |
document.add(extraInfoTable);
|
|
|
351 |
}
|
|
|
352 |
}
|
|
|
353 |
if(withBill){
|
|
|
354 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
|
|
355 |
taxTable.setSpacingBefore(5.0f);
|
|
|
356 |
taxTable.setWidthPercentage(90.0f);
|
|
|
357 |
document.add(new DottedLineSeparator());
|
|
|
358 |
document.add(taxTable);
|
|
|
359 |
if(order.getSource() == OrderSource.FLIPKART.getValue()) {
|
|
|
360 |
//document.add(new DottedLineSeparator());
|
|
|
361 |
document.add(getFlipkartBarCodes(order));
|
|
|
362 |
}
|
| 2787 |
chandransh |
363 |
|
| 13276 |
manish.sha |
364 |
}else{
|
|
|
365 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
|
|
366 |
extraInfoTable.setSpacingBefore(5.0f);
|
|
|
367 |
extraInfoTable.setWidthPercentage(90.0f);
|
|
|
368 |
document.add(new DottedLineSeparator());
|
|
|
369 |
document.add(extraInfoTable);
|
|
|
370 |
}
|
| 13316 |
manish.sha |
371 |
|
|
|
372 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
|
|
373 |
PdfPTable orderItemsDetailTable = new PdfPTable(1);
|
|
|
374 |
orderItemsDetailTable.setWidthPercentage(90.0f);
|
|
|
375 |
orderItemsDetailTable.setSpacingBefore(5.0f);
|
|
|
376 |
orderItemsDetailTable.addCell(new Phrase("SubOrder Ids :", helveticaBold8));
|
|
|
377 |
StringBuffer sbOrders = new StringBuffer();
|
|
|
378 |
|
| 13318 |
manish.sha |
379 |
for(Order o1 : ordersList){
|
| 13316 |
manish.sha |
380 |
sbOrders.append(o1.getId()+",");
|
|
|
381 |
}
|
|
|
382 |
|
|
|
383 |
|
|
|
384 |
String orderIds = sbOrders.toString();
|
|
|
385 |
orderIds = orderIds.substring(0, orderIds.length()-1);
|
| 13319 |
manish.sha |
386 |
|
| 13316 |
manish.sha |
387 |
StringBuffer sbImeis = new StringBuffer();
|
|
|
388 |
|
| 13317 |
manish.sha |
389 |
for(Order o1 : ordersList){
|
| 13316 |
manish.sha |
390 |
if(o1.getLineitems().get(0).getSerial_number()!=null){
|
|
|
391 |
sbImeis.append(o1.getLineitems().get(0).getSerial_number()+",");
|
|
|
392 |
}
|
|
|
393 |
}
|
|
|
394 |
|
| 13319 |
manish.sha |
395 |
orderItemsDetailTable.addCell(new Phrase(orderIds.toString(), helvetica8));
|
| 13316 |
manish.sha |
396 |
|
| 13319 |
manish.sha |
397 |
if(sbImeis.length()>0){
|
|
|
398 |
orderItemsDetailTable.addCell(new Phrase("IMEI Details :", helveticaBold8));
|
|
|
399 |
logger.info("Imeis List:- " + sbImeis);
|
|
|
400 |
String imeis = sbImeis.toString();
|
| 13490 |
manish.sha |
401 |
if(imeis.endsWith(","))
|
|
|
402 |
imeis = imeis.substring(0, imeis.length()-1);
|
| 13319 |
manish.sha |
403 |
logger.info("Final Imeis List:- " + sbImeis);
|
|
|
404 |
|
|
|
405 |
orderItemsDetailTable.addCell(new Phrase(imeis, helvetica8));
|
|
|
406 |
}
|
|
|
407 |
|
| 13316 |
manish.sha |
408 |
document.add(new DottedLineSeparator());
|
|
|
409 |
document.add(orderItemsDetailTable);
|
|
|
410 |
}
|
|
|
411 |
|
| 13276 |
manish.sha |
412 |
document.newPage();
|
| 7014 |
rajveer |
413 |
}
|
| 13276 |
manish.sha |
414 |
} else {
|
|
|
415 |
for(Order singleOrder : orders){
|
|
|
416 |
List<Order> ordersList = new ArrayList<Order>();
|
|
|
417 |
ordersList.add(singleOrder);
|
|
|
418 |
Warehouse warehouse = null;
|
|
|
419 |
Provider provider = null;
|
|
|
420 |
String destCode = null;
|
|
|
421 |
Warehouse shippingLocation = null;
|
|
|
422 |
int barcodeFontSize = 0;
|
|
|
423 |
String invoiceFormat = "Individual";
|
|
|
424 |
try {
|
|
|
425 |
warehouse = iclient.getWarehouse(singleOrder.getWarehouse_id());
|
|
|
426 |
long providerId = singleOrder.getLogistics_provider_id();
|
|
|
427 |
provider = logisticsClient.getProvider(providerId);
|
|
|
428 |
if(provider.getPickup().equals(PickUpType.SELF) || provider.getPickup().equals(PickUpType.RUNNER))
|
|
|
429 |
destCode = provider.getPickup().toString();
|
|
|
430 |
else
|
|
|
431 |
destCode = logisticsClient.getDestinationCode(providerId, singleOrder.getCustomer_pincode());
|
| 4361 |
rajveer |
432 |
|
| 13276 |
manish.sha |
433 |
barcodeFontSize = Integer.parseInt(ConfigClient.getClient().get(provider.getName().toLowerCase() + "_barcode_fontsize"));
|
|
|
434 |
shippingLocation = CatalogUtils.getWarehouse(warehouse.getShippingWarehouseId());
|
|
|
435 |
} catch (InventoryServiceException ise) {
|
|
|
436 |
logger.error("Error while getting the warehouse information.", ise);
|
|
|
437 |
return baosPDF;
|
|
|
438 |
} catch (LogisticsServiceException lse) {
|
|
|
439 |
logger.error("Error while getting the provider information.", lse);
|
|
|
440 |
return baosPDF;
|
|
|
441 |
} catch (ConfigException ce) {
|
|
|
442 |
logger.error("Error while getting the fontsize for the given provider", ce);
|
|
|
443 |
return baosPDF;
|
|
|
444 |
} catch (TException te) {
|
|
|
445 |
logger.error("Error while getting some essential information from the services", te);
|
|
|
446 |
return baosPDF;
|
| 7014 |
rajveer |
447 |
}
|
| 13276 |
manish.sha |
448 |
|
|
|
449 |
if(printAll && warehouse.getBillingType() == BillingType.OURS_EXTERNAL){
|
|
|
450 |
for(Order order : ordersList){
|
|
|
451 |
if(isFirst){
|
|
|
452 |
document.add(getFixedTextTable(16, "Spice Online Retail Pvt Ltd"));
|
|
|
453 |
isFirst = false;
|
|
|
454 |
}
|
|
|
455 |
document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
|
|
|
456 |
continue;
|
|
|
457 |
}
|
|
|
458 |
}
|
|
|
459 |
PdfPTable dispatchAdviceTable = null;
|
|
|
460 |
Order order = ordersList.get(0);
|
|
|
461 |
if(ordersList.size()==1){
|
|
|
462 |
if (new Long(order.getSource()).intValue() == OrderSource.SNAPDEAL.getValue()) {
|
| 8303 |
amar.kumar |
463 |
dispatchAdviceTable = new PdfPTable(1);
|
| 13276 |
manish.sha |
464 |
} else if(new Long(order.getSource()).intValue() == OrderSource.FLIPKART.getValue()) {
|
|
|
465 |
dispatchAdviceTable = new PdfPTable(1);
|
| 13705 |
manish.sha |
466 |
} else if(new Long(order.getSource()).intValue() == OrderSource.HOMESHOP18.getValue()) {
|
|
|
467 |
dispatchAdviceTable = new PdfPTable(1);
|
| 13276 |
manish.sha |
468 |
} else if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7)) {
|
|
|
469 |
if(order.getWarehouse_id() == 7 || order.getWarehouse_id() == 5 || order.getWarehouse_id() == 9) {
|
|
|
470 |
dispatchAdviceTable = new PdfPTable(1);
|
|
|
471 |
} else {
|
|
|
472 |
if (order.getAirwaybill_no()== null || order.getAirwaybill_no().equals("null") || order.getAirwaybill_no().isEmpty()) {
|
|
|
473 |
dispatchAdviceTable = new PdfPTable(1);
|
|
|
474 |
} else {
|
|
|
475 |
EbayInvoiceGenerationService invoiceGenerationService = new EbayInvoiceGenerationService();
|
|
|
476 |
dispatchAdviceTable = invoiceGenerationService.getDispatchAdviceTable(orderId, warehouseId);
|
|
|
477 |
}
|
|
|
478 |
}
|
|
|
479 |
}
|
|
|
480 |
else {
|
|
|
481 |
dispatchAdviceTable = getDispatchAdviceTable(ordersList, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation, invoiceFormat);
|
|
|
482 |
}
|
|
|
483 |
} else {
|
|
|
484 |
dispatchAdviceTable = getDispatchAdviceTable(ordersList, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation, invoiceFormat);
|
|
|
485 |
}
|
|
|
486 |
|
|
|
487 |
dispatchAdviceTable.setSpacingAfter(10.0f);
|
|
|
488 |
dispatchAdviceTable.setWidthPercentage(90.0f);
|
|
|
489 |
document.add(dispatchAdviceTable);
|
|
|
490 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
| 13320 |
manish.sha |
491 |
if(ordersList.size()>1){
|
|
|
492 |
document.newPage();
|
|
|
493 |
}
|
| 13276 |
manish.sha |
494 |
}
|
|
|
495 |
|
|
|
496 |
if ((new Long(order.getSource()).intValue() == OrderSource.EBAY.getValue()) && (order.getLogistics_provider_id()>7) &&(ordersList.size()==1)) {
|
|
|
497 |
if (order.getAirwaybill_no()== null || order.getAirwaybill_no().equals("null") || order.getAirwaybill_no().isEmpty()
|
|
|
498 |
|| order.getWarehouse_id() == 7 || order.getWarehouse_id() == 5 || order.getWarehouse_id() == 9) {
|
|
|
499 |
if(withBill){
|
|
|
500 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
|
|
501 |
taxTable.setSpacingBefore(5.0f);
|
|
|
502 |
taxTable.setWidthPercentage(90.0f);
|
|
|
503 |
document.add(new DottedLineSeparator());
|
|
|
504 |
document.add(taxTable);
|
|
|
505 |
}else{
|
|
|
506 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
|
|
507 |
extraInfoTable.setSpacingBefore(5.0f);
|
|
|
508 |
extraInfoTable.setWidthPercentage(90.0f);
|
|
|
509 |
document.add(new DottedLineSeparator());
|
|
|
510 |
document.add(extraInfoTable);
|
|
|
511 |
}
|
| 8303 |
amar.kumar |
512 |
} else {
|
| 13276 |
manish.sha |
513 |
document.newPage();
|
| 8303 |
amar.kumar |
514 |
}
|
| 13276 |
manish.sha |
515 |
} else if (new Long(order.getSource()).intValue() == OrderSource.SNAPDEAL.getValue() &&(ordersList.size()==1)) {
|
| 8303 |
amar.kumar |
516 |
if(withBill){
|
| 13276 |
manish.sha |
517 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
| 8303 |
amar.kumar |
518 |
taxTable.setSpacingBefore(5.0f);
|
|
|
519 |
taxTable.setWidthPercentage(90.0f);
|
|
|
520 |
document.add(new DottedLineSeparator());
|
|
|
521 |
document.add(taxTable);
|
|
|
522 |
}else{
|
|
|
523 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
|
|
524 |
extraInfoTable.setSpacingBefore(5.0f);
|
|
|
525 |
extraInfoTable.setWidthPercentage(90.0f);
|
|
|
526 |
document.add(new DottedLineSeparator());
|
|
|
527 |
document.add(extraInfoTable);
|
|
|
528 |
}
|
|
|
529 |
}
|
| 8488 |
amar.kumar |
530 |
if(withBill){
|
| 13276 |
manish.sha |
531 |
PdfPTable taxTable = getTaxCumRetailInvoiceTable(ordersList, provider, shippingLocation.getLocation() + "-" + shippingLocation.getPincode() , shippingLocation.getTinNumber(), invoiceFormat);
|
| 8488 |
amar.kumar |
532 |
taxTable.setSpacingBefore(5.0f);
|
|
|
533 |
taxTable.setWidthPercentage(90.0f);
|
|
|
534 |
document.add(new DottedLineSeparator());
|
|
|
535 |
document.add(taxTable);
|
| 13276 |
manish.sha |
536 |
if(order.getSource() == OrderSource.FLIPKART.getValue()) {
|
|
|
537 |
//document.add(new DottedLineSeparator());
|
|
|
538 |
document.add(getFlipkartBarCodes(order));
|
|
|
539 |
}
|
|
|
540 |
|
| 8488 |
amar.kumar |
541 |
}else{
|
|
|
542 |
PdfPTable extraInfoTable = getExtraInfoTable(order, provider, 16, warehouse.getBillingType());
|
|
|
543 |
extraInfoTable.setSpacingBefore(5.0f);
|
|
|
544 |
extraInfoTable.setWidthPercentage(90.0f);
|
|
|
545 |
document.add(new DottedLineSeparator());
|
|
|
546 |
document.add(extraInfoTable);
|
|
|
547 |
}
|
| 13276 |
manish.sha |
548 |
|
|
|
549 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
|
|
550 |
PdfPTable orderItemsDetailTable = new PdfPTable(1);
|
|
|
551 |
orderItemsDetailTable.setWidthPercentage(90.0f);
|
|
|
552 |
orderItemsDetailTable.setSpacingBefore(5.0f);
|
| 13313 |
manish.sha |
553 |
orderItemsDetailTable.addCell(new Phrase("SubOrder Ids :", helveticaBold8));
|
| 13276 |
manish.sha |
554 |
StringBuffer sbOrders = new StringBuffer();
|
|
|
555 |
|
|
|
556 |
for(Order o1 : orders){
|
|
|
557 |
sbOrders.append(o1.getId()+",");
|
|
|
558 |
}
|
|
|
559 |
|
|
|
560 |
|
|
|
561 |
String orderIds = sbOrders.toString();
|
|
|
562 |
orderIds = orderIds.substring(0, orderIds.length()-1);
|
|
|
563 |
|
|
|
564 |
orderItemsDetailTable.addCell(new Phrase(orderIds.toString(), helvetica8));
|
| 13319 |
manish.sha |
565 |
|
| 13276 |
manish.sha |
566 |
|
|
|
567 |
StringBuffer sbImeis = new StringBuffer();
|
|
|
568 |
|
|
|
569 |
for(Order o1 : orders){
|
|
|
570 |
if(o1.getLineitems().get(0).getSerial_number()!=null){
|
|
|
571 |
sbImeis.append(o1.getLineitems().get(0).getSerial_number()+",");
|
|
|
572 |
}
|
|
|
573 |
}
|
|
|
574 |
|
| 13319 |
manish.sha |
575 |
if(sbImeis.length()>0){
|
|
|
576 |
orderItemsDetailTable.addCell(new Phrase("IMEI Details :", helveticaBold8));
|
|
|
577 |
|
|
|
578 |
logger.info("Imeis List:- " + sbImeis);
|
|
|
579 |
String imeis = sbImeis.toString();
|
|
|
580 |
imeis = imeis.substring(0, imeis.length()-2);
|
|
|
581 |
logger.info("Final Imeis List:- " + sbImeis);
|
|
|
582 |
|
|
|
583 |
orderItemsDetailTable.addCell(new Phrase(imeis, helvetica8));
|
|
|
584 |
}
|
|
|
585 |
|
| 13276 |
manish.sha |
586 |
document.add(new DottedLineSeparator());
|
|
|
587 |
document.add(orderItemsDetailTable);
|
| 9009 |
amar.kumar |
588 |
}
|
| 13276 |
manish.sha |
589 |
document.newPage();
|
| 7014 |
rajveer |
590 |
}
|
|
|
591 |
}
|
| 13276 |
manish.sha |
592 |
|
|
|
593 |
|
|
|
594 |
|
| 7014 |
rajveer |
595 |
document.close();
|
|
|
596 |
baosPDF.close();
|
|
|
597 |
// Adding facility to store the bill on the local directory. This will happen for only for Mahipalpur warehouse.
|
|
|
598 |
if(withBill && !printAll){
|
| 7079 |
rajveer |
599 |
String strOrderId = StringUtils.repeat("0", 10-String.valueOf(orderId).length()) + orderId;
|
| 7014 |
rajveer |
600 |
String dirPath = "/SaholicInvoices" + File.separator + strOrderId.substring(0, 2) + File.separator + strOrderId.substring(2, 4) + File.separator + strOrderId.substring(4, 6);
|
|
|
601 |
String filename = dirPath + File.separator + orderId + ".pdf";
|
|
|
602 |
File dirFile = new File(dirPath);
|
|
|
603 |
if(!dirFile.exists()){
|
|
|
604 |
dirFile.mkdirs();
|
|
|
605 |
}
|
|
|
606 |
File f = new File(filename);
|
|
|
607 |
FileOutputStream fos = new FileOutputStream(f);
|
|
|
608 |
baosPDF.writeTo(fos);
|
|
|
609 |
}
|
|
|
610 |
} catch (Exception e) {
|
|
|
611 |
logger.error("Error while generating Invoice: ", e);
|
|
|
612 |
}
|
|
|
613 |
return baosPDF;
|
|
|
614 |
}
|
| 3065 |
chandransh |
615 |
|
| 13276 |
manish.sha |
616 |
private PdfPTable getDispatchAdviceTable(List<Order> orderList, Warehouse warehouse, Provider provider, float barcodeFontSize, String destCode, boolean withBill, Warehouse shippingLocation, String invoiceFormat){
|
|
|
617 |
Order order = orderList.get(0);
|
| 7014 |
rajveer |
618 |
Font barCodeFont = getBarCodeFont(provider, barcodeFontSize);
|
| 13276 |
manish.sha |
619 |
|
|
|
620 |
double totalAmount = 0.0;
|
|
|
621 |
double totalWeight = 0.0;
|
|
|
622 |
|
|
|
623 |
for (Order o: orderList){
|
| 17470 |
manish.sha |
624 |
totalAmount = totalAmount + o.getTotal_amount() +o.getShippingCost()-o.getGvAmount()-o.getAdvanceAmount();
|
| 13276 |
manish.sha |
625 |
totalWeight = totalWeight + o.getTotal_weight();
|
|
|
626 |
}
|
| 2787 |
chandransh |
627 |
|
| 7014 |
rajveer |
628 |
PdfPTable table = new PdfPTable(1);
|
|
|
629 |
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 8106 |
manish.sha |
630 |
|
|
|
631 |
PdfPTable titleBarTable = new PdfPTable(new float[]{0.4f, 0.4f, 0.2f});
|
| 8107 |
manish.sha |
632 |
titleBarTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 8106 |
manish.sha |
633 |
|
| 8103 |
manish.sha |
634 |
PdfPTable logoTable = new PdfPTable(2);
|
|
|
635 |
addLogoTable(logoTable,order);
|
| 7318 |
rajveer |
636 |
|
| 7014 |
rajveer |
637 |
PdfPCell titleCell = getTitleCell();
|
| 18530 |
manish.sha |
638 |
PdfPTable customerTable = getCustomerAddressTable(order, destCode, false, helvetica12, false, false);
|
| 13276 |
manish.sha |
639 |
PdfPTable providerInfoTable = getProviderTable(order, provider, barCodeFont, totalWeight);
|
| 2787 |
chandransh |
640 |
|
| 7014 |
rajveer |
641 |
PdfPTable dispatchTable = new PdfPTable(new float[]{0.5f, 0.1f, 0.4f});
|
|
|
642 |
dispatchTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
643 |
dispatchTable.addCell(customerTable);
|
|
|
644 |
dispatchTable.addCell(new Phrase(" "));
|
|
|
645 |
dispatchTable.addCell(providerInfoTable);
|
| 2787 |
chandransh |
646 |
|
| 13276 |
manish.sha |
647 |
PdfPTable invoiceTable = getTopInvoiceTable(orderList, shippingLocation.getTinNumber(), invoiceFormat);
|
| 8110 |
manish.sha |
648 |
PdfPTable addressTable = new PdfPTable(1);
|
|
|
649 |
addressTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
650 |
addressTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
651 |
|
| 7014 |
rajveer |
652 |
PdfPCell addressCell = getAddressCell(shippingLocation.getLocation() +
|
| 17203 |
manish.sha |
653 |
" - " + shippingLocation.getPincode() + "\nContact No.- +91-9811247808" + "\n\n");
|
| 2787 |
chandransh |
654 |
|
| 7014 |
rajveer |
655 |
PdfPTable chargesTable = new PdfPTable(1);
|
|
|
656 |
chargesTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
657 |
chargesTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
658 |
if(order.isLogisticsCod()){
|
| 13276 |
manish.sha |
659 |
chargesTable.addCell(new Phrase("AMOUNT TO BE COLLECTED : Rs " + (totalAmount), helveticaBold12));
|
| 7014 |
rajveer |
660 |
chargesTable.addCell(new Phrase("RTO ADDRESS:DEL/HPW/111116"));
|
| 7994 |
manish.sha |
661 |
//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
|
|
662 |
if(order.getLogistics_provider_id()==7L){
|
|
|
663 |
in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
|
|
|
664 |
String fedexCodReturnBarcode = "";
|
| 8080 |
manish.sha |
665 |
String fedexCodReturnTrackingId = "";
|
| 7994 |
manish.sha |
666 |
try {
|
|
|
667 |
fedexCodReturnBarcode = tclient.getOrderAttributeValue(order.getId(), "FedEx_COD_Return_BarCode");
|
| 8080 |
manish.sha |
668 |
fedexCodReturnTrackingId = tclient.getOrderAttributeValue(order.getId(), "FedEx_COD_Return_Tracking_No");
|
| 7994 |
manish.sha |
669 |
} catch (TException e1) {
|
|
|
670 |
logger.error("Error while getting the provider information.", e1);
|
|
|
671 |
}
|
| 8080 |
manish.sha |
672 |
PdfPCell formIdCell= new PdfPCell(new Paragraph("COD Return "+fedexCodReturnTrackingId+" Form id-0325", helvetica6));
|
| 8104 |
manish.sha |
673 |
formIdCell.setPaddingTop(2.0f);
|
| 7994 |
manish.sha |
674 |
formIdCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
675 |
formIdCell.setBorder(Rectangle.NO_BORDER);
|
|
|
676 |
chargesTable.addCell(new Phrase("PRIORITY OVERNIGHT ", helvetica8));
|
|
|
677 |
chargesTable.addCell(formIdCell);
|
| 8035 |
manish.sha |
678 |
|
| 8067 |
manish.sha |
679 |
generateBarcode(fedexCodReturnBarcode, "fedex_codr_"+order.getId());
|
| 8037 |
manish.sha |
680 |
|
| 8067 |
manish.sha |
681 |
Image barcodeImage=null;
|
|
|
682 |
try {
|
|
|
683 |
barcodeImage = Image.getInstance("/tmp/"+"fedex_codr_"+order.getId()+".png");
|
|
|
684 |
} catch (Exception e) {
|
|
|
685 |
logger.error("Exception during getting Barcode Image for Fedex : ", e);
|
|
|
686 |
}
|
|
|
687 |
|
| 8173 |
manish.sha |
688 |
PdfPTable codReturnTable = new PdfPTable(new float[]{0.6f,0.4f});
|
|
|
689 |
codReturnTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
690 |
codReturnTable.addCell(barcodeImage);
|
|
|
691 |
codReturnTable.addCell(new Phrase(" "));
|
|
|
692 |
chargesTable.addCell(codReturnTable);
|
|
|
693 |
|
| 7994 |
manish.sha |
694 |
}
|
|
|
695 |
//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
| 7014 |
rajveer |
696 |
} else {
|
|
|
697 |
chargesTable.addCell(new Phrase("Do not pay any extra charges to the Courier."));
|
|
|
698 |
}
|
| 8080 |
manish.sha |
699 |
|
|
|
700 |
if(order.getLogistics_provider_id()==7L){
|
|
|
701 |
chargesTable.addCell(new Phrase("Term and Condition:- Subject to the Conditions of Carriage which " +
|
|
|
702 |
"limits the liability of FedEx for loss, delay or damage to the consignment." +
|
|
|
703 |
" Visit http://www.fedex.com/in/domestic/services/terms to view the conitions of Carriage" ,
|
| 8082 |
manish.sha |
704 |
new Font(FontFamily.TIMES_ROMAN, 8f)));
|
| 8080 |
manish.sha |
705 |
}
|
| 10310 |
amar.kumar |
706 |
|
| 8110 |
manish.sha |
707 |
addressTable.addCell(new Phrase("If undelivered, return to:", helvetica10));
|
|
|
708 |
addressTable.addCell(addressCell);
|
|
|
709 |
|
| 7014 |
rajveer |
710 |
PdfPTable addressAndNoteTable = new PdfPTable(new float[]{0.3f, 0.7f});
|
|
|
711 |
addressAndNoteTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 8110 |
manish.sha |
712 |
addressAndNoteTable.addCell(addressTable);
|
| 7014 |
rajveer |
713 |
addressAndNoteTable.addCell(chargesTable);
|
| 2787 |
chandransh |
714 |
|
| 8106 |
manish.sha |
715 |
titleBarTable.addCell(logoTable);
|
|
|
716 |
titleBarTable.addCell(titleCell);
|
|
|
717 |
titleBarTable.addCell(" ");
|
|
|
718 |
|
|
|
719 |
table.addCell(titleBarTable);
|
| 7014 |
rajveer |
720 |
table.addCell(dispatchTable);
|
|
|
721 |
table.addCell(invoiceTable);
|
|
|
722 |
table.addCell(addressAndNoteTable);
|
|
|
723 |
return table;
|
|
|
724 |
}
|
| 2787 |
chandransh |
725 |
|
| 8103 |
manish.sha |
726 |
private void addLogoTable(PdfPTable logoTable,Order order) {
|
| 7318 |
rajveer |
727 |
logoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
728 |
logoTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
729 |
logoTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_BOTTOM);
|
| 8096 |
manish.sha |
730 |
|
| 7318 |
rajveer |
731 |
PdfPCell logoCell;
|
|
|
732 |
String logoPath;
|
| 8102 |
manish.sha |
733 |
|
| 7556 |
rajveer |
734 |
if(order.getSource() == OrderSource.STORE.getValue()){
|
|
|
735 |
logoCell = new PdfPCell(new Phrase(""));
|
|
|
736 |
|
|
|
737 |
}else{
|
| 8102 |
manish.sha |
738 |
logoPath = InvoiceGenerationService.class.getResource("/logo.jpg").getPath();
|
| 8094 |
manish.sha |
739 |
|
| 7318 |
rajveer |
740 |
try {
|
|
|
741 |
logoCell = new PdfPCell(Image.getInstance(logoPath), false);
|
|
|
742 |
} catch (Exception e) {
|
|
|
743 |
//Too Many exceptions to catch here: BadElementException, MalformedURLException and IOException
|
|
|
744 |
logger.warn("Couldn't load the Saholic logo: ", e);
|
|
|
745 |
logoCell = new PdfPCell(new Phrase("Saholic Logo"));
|
|
|
746 |
}
|
|
|
747 |
|
|
|
748 |
}
|
| 8090 |
manish.sha |
749 |
logoCell.setBorder(Rectangle.NO_BORDER);
|
|
|
750 |
logoCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
| 8102 |
manish.sha |
751 |
logoTable.addCell(logoCell);
|
|
|
752 |
logoTable.addCell(" ");
|
| 8103 |
manish.sha |
753 |
|
| 7318 |
rajveer |
754 |
}
|
|
|
755 |
|
| 7014 |
rajveer |
756 |
private Font getBarCodeFont(Provider provider, float barcodeFontSize) {
|
|
|
757 |
String fontPath = InvoiceGenerationService.class.getResource("/" + provider.getName().toLowerCase() + "/barcode.TTF").getPath();
|
|
|
758 |
FontFactoryImp ttfFontFactory = new FontFactoryImp();
|
|
|
759 |
ttfFontFactory.register(fontPath, "barcode");
|
|
|
760 |
Font barCodeFont = ttfFontFactory.getFont("barcode", BaseFont.CP1252, true, barcodeFontSize);
|
|
|
761 |
return barCodeFont;
|
|
|
762 |
}
|
| 2787 |
chandransh |
763 |
|
| 7014 |
rajveer |
764 |
private PdfPCell getTitleCell() {
|
|
|
765 |
PdfPCell titleCell = new PdfPCell(new Phrase("Dispatch Advice", helveticaBold12));
|
|
|
766 |
titleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
767 |
titleCell.setBorder(Rectangle.NO_BORDER);
|
|
|
768 |
return titleCell;
|
|
|
769 |
}
|
| 2787 |
chandransh |
770 |
|
| 13276 |
manish.sha |
771 |
private PdfPTable getProviderTable(Order order, Provider provider, Font barCodeFont, double totalWeight) {
|
| 7014 |
rajveer |
772 |
PdfPTable providerInfoTable = new PdfPTable(1);
|
|
|
773 |
providerInfoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 7318 |
rajveer |
774 |
if(order.isLogisticsCod()){
|
| 8551 |
manish.sha |
775 |
PdfPCell deliveryTypeCell = new PdfPCell(new Phrase("COD ", helvetica22));
|
| 7318 |
rajveer |
776 |
deliveryTypeCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
777 |
deliveryTypeCell.setBorder(Rectangle.NO_BORDER);
|
|
|
778 |
providerInfoTable.addCell(deliveryTypeCell);
|
|
|
779 |
}
|
|
|
780 |
|
| 8035 |
manish.sha |
781 |
|
| 7014 |
rajveer |
782 |
PdfPCell providerNameCell = new PdfPCell(new Phrase(provider.getName(), helveticaBold12));
|
|
|
783 |
providerNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
784 |
providerNameCell.setBorder(Rectangle.NO_BORDER);
|
| 7994 |
manish.sha |
785 |
PdfPCell formIdCell= null;
|
|
|
786 |
if(order.getLogistics_provider_id()==7L){
|
|
|
787 |
if(order.isCod()){
|
| 8034 |
manish.sha |
788 |
formIdCell = new PdfPCell(new Paragraph(order.getAirwaybill_no()+" Form id-0305", helvetica6));
|
| 7994 |
manish.sha |
789 |
}
|
|
|
790 |
else{
|
| 8034 |
manish.sha |
791 |
formIdCell = new PdfPCell(new Paragraph(order.getAirwaybill_no()+" Form id-0467", helvetica6));
|
| 7994 |
manish.sha |
792 |
}
|
| 8551 |
manish.sha |
793 |
formIdCell.setPaddingTop(1.0f);
|
| 8015 |
rajveer |
794 |
formIdCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
795 |
formIdCell.setBorder(Rectangle.NO_BORDER);
|
| 7994 |
manish.sha |
796 |
}
|
| 8015 |
rajveer |
797 |
|
| 7994 |
manish.sha |
798 |
|
|
|
799 |
PdfPCell awbNumberCell= null;
|
| 8034 |
manish.sha |
800 |
String fedexPackageBarcode = "";
|
| 7994 |
manish.sha |
801 |
if(order.getLogistics_provider_id()!=7L){
|
|
|
802 |
awbNumberCell = new PdfPCell(new Paragraph("*" + order.getAirwaybill_no() + "*", barCodeFont));
|
| 8017 |
manish.sha |
803 |
awbNumberCell.setPaddingTop(20.0f);
|
| 7994 |
manish.sha |
804 |
}
|
|
|
805 |
else{
|
| 8013 |
rajveer |
806 |
in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
|
|
|
807 |
try {
|
|
|
808 |
fedexPackageBarcode = tclient.getOrderAttributeValue(order.getId(), "FedEx_Package_BarCode");
|
|
|
809 |
} catch (TException e1) {
|
|
|
810 |
logger.error("Error while getting the provider information.", e1);
|
|
|
811 |
}
|
| 8174 |
manish.sha |
812 |
awbNumberCell = new PdfPCell(new Paragraph(" ", helvetica6));
|
|
|
813 |
}
|
|
|
814 |
awbNumberCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
815 |
awbNumberCell.setBorder(Rectangle.NO_BORDER);
|
|
|
816 |
|
|
|
817 |
providerInfoTable.addCell(providerNameCell);
|
|
|
818 |
if(formIdCell != null){
|
|
|
819 |
providerInfoTable.addCell(formIdCell);
|
|
|
820 |
}
|
|
|
821 |
//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
|
|
822 |
if(order.getLogistics_provider_id()==7L){
|
| 8169 |
manish.sha |
823 |
generateBarcode(fedexPackageBarcode, "fedex_"+order.getId());
|
|
|
824 |
|
|
|
825 |
Image barcodeImage=null;
|
|
|
826 |
try {
|
|
|
827 |
barcodeImage = Image.getInstance("/tmp/"+"fedex_"+order.getId()+".png");
|
|
|
828 |
} catch (Exception e) {
|
|
|
829 |
logger.error("Exception during getting Barcode Image for Fedex : ", e);
|
|
|
830 |
}
|
| 8174 |
manish.sha |
831 |
providerInfoTable.addCell(barcodeImage);
|
| 7994 |
manish.sha |
832 |
}
|
| 8174 |
manish.sha |
833 |
providerInfoTable.addCell(awbNumberCell);
|
| 7014 |
rajveer |
834 |
|
| 7792 |
anupam.sin |
835 |
Warehouse warehouse = null;
|
|
|
836 |
try{
|
|
|
837 |
InventoryClient isc = new InventoryClient();
|
| 7804 |
amar.kumar |
838 |
warehouse = isc.getClient().getWarehouse(order.getWarehouse_id());
|
| 7803 |
amar.kumar |
839 |
} catch(Exception e) {
|
| 7792 |
anupam.sin |
840 |
logger.error("Unable to get warehouse for id : " + order.getWarehouse_id(), e);
|
| 7805 |
amar.kumar |
841 |
//TODO throw e;
|
| 7792 |
anupam.sin |
842 |
}
|
|
|
843 |
DeliveryType dt = DeliveryType.PREPAID;
|
|
|
844 |
if (order.isLogisticsCod()) {
|
|
|
845 |
dt = DeliveryType.COD;
|
|
|
846 |
}
|
| 7994 |
manish.sha |
847 |
//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
|
|
848 |
if(order.getLogistics_provider_id()!=7L){
|
|
|
849 |
for (ProviderDetails detail : provider.getDetails()) {
|
|
|
850 |
if(in.shop2020.model.v1.inventory.WarehouseLocation.findByValue((int) detail.getLogisticLocation()) == warehouse.getLogisticsLocation() && detail.getDeliveryType() == dt) {
|
|
|
851 |
providerInfoTable.addCell(new Phrase("Account No : " + detail.getAccountNo(), helvetica8));
|
|
|
852 |
}
|
|
|
853 |
}
|
| 7792 |
anupam.sin |
854 |
}
|
| 7994 |
manish.sha |
855 |
else{
|
|
|
856 |
providerInfoTable.addCell(new Phrase("STANDARD OVERNIGHT ", helvetica8));
|
|
|
857 |
}
|
|
|
858 |
//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
| 7014 |
rajveer |
859 |
Date awbDate;
|
|
|
860 |
if(order.getBilling_timestamp() == 0){
|
|
|
861 |
awbDate = new Date();
|
|
|
862 |
}else{
|
|
|
863 |
awbDate = new Date(order.getBilling_timestamp());
|
|
|
864 |
}
|
| 8106 |
manish.sha |
865 |
if(order.getLogistics_provider_id()!=7L){
|
|
|
866 |
providerInfoTable.addCell(new Phrase("AWB Date : " + DateFormat.getDateInstance(DateFormat.MEDIUM).format(awbDate), helvetica8));
|
|
|
867 |
}
|
| 13322 |
manish.sha |
868 |
providerInfoTable.addCell(new Phrase("Weight : " + totalWeight + " Kg", helvetica8));
|
| 8182 |
amar.kumar |
869 |
if(order.getSource() == OrderSource.EBAY.getValue()){
|
|
|
870 |
EbayOrder ebayOrder = null;
|
|
|
871 |
try {
|
|
|
872 |
ebayOrder = tsc.getClient().getEbayOrderByOrderId(order.getId());
|
|
|
873 |
} catch (TException e) {
|
|
|
874 |
logger.error("Error while getting ebay order", e);
|
|
|
875 |
}
|
|
|
876 |
providerInfoTable.addCell(new Phrase("PaisaPayId : " + ebayOrder.getPaisaPayId(), helvetica8));
|
|
|
877 |
providerInfoTable.addCell(new Phrase("Sales Rec Number: " + ebayOrder.getSalesRecordNumber(), helvetica8));
|
|
|
878 |
}
|
| 7994 |
manish.sha |
879 |
//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
|
|
880 |
if(order.getLogistics_provider_id()==7L){
|
|
|
881 |
providerInfoTable.addCell(new Phrase("Bill T/C Sender "+ "Bill D/T Sender", helvetica8));
|
|
|
882 |
}
|
|
|
883 |
//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
| 7014 |
rajveer |
884 |
return providerInfoTable;
|
|
|
885 |
}
|
|
|
886 |
|
| 13276 |
manish.sha |
887 |
private PdfPTable getTopInvoiceTable(List<Order> orderList, String tinNo, String invoiceFormat){
|
| 7014 |
rajveer |
888 |
PdfPTable invoiceTable = new PdfPTable(new float[]{0.2f, 0.2f, 0.3f, 0.1f, 0.1f, 0.1f});
|
|
|
889 |
invoiceTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
890 |
|
| 13276 |
manish.sha |
891 |
invoiceTable.addCell(getInvoiceTableHeader(6,orderList.get(0).getLogisticsTransactionId()));
|
|
|
892 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
|
|
893 |
invoiceTable.addCell(new Phrase("Sr No", helvetica8));
|
|
|
894 |
}else{
|
|
|
895 |
invoiceTable.addCell(new Phrase("Order No", helvetica8));
|
|
|
896 |
}
|
| 7014 |
rajveer |
897 |
invoiceTable.addCell(new Phrase("Paymode", helvetica8));
|
|
|
898 |
invoiceTable.addCell(new Phrase("Product Name", helvetica8));
|
|
|
899 |
invoiceTable.addCell(new Phrase("Quantity", helvetica8));
|
|
|
900 |
invoiceTable.addCell(new Phrase("Rate", helvetica8));
|
|
|
901 |
invoiceTable.addCell(new Phrase("Amount", helvetica8));
|
| 13276 |
manish.sha |
902 |
double totalAmount = 0.0;
|
| 17470 |
manish.sha |
903 |
double totalShippingCost = 0.0;
|
| 13276 |
manish.sha |
904 |
double insuranceAmount = 0.0;
|
|
|
905 |
double advanceAmount = 0.0;
|
|
|
906 |
|
|
|
907 |
|
|
|
908 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
|
|
909 |
Map<Long, String> itemNamesMap= new HashMap<Long, String>();
|
|
|
910 |
Map<Long, Double> itemQuantityMap = new HashMap<Long, Double>();
|
|
|
911 |
Map<Long, Double> itemRateMap = new HashMap<Long, Double>();
|
|
|
912 |
Map<Long, Double> itemTotalAmtMap = new HashMap<Long, Double>();
|
|
|
913 |
String paymentMode = "";
|
|
|
914 |
for(Order order : orderList){
|
|
|
915 |
LineItem lineitem = order.getLineitems().get(0);
|
| 13496 |
manish.sha |
916 |
totalAmount = totalAmount + order.getTotal_amount()-order.getAdvanceAmount();
|
| 17470 |
manish.sha |
917 |
totalShippingCost = totalShippingCost + order.getShippingCost();
|
| 13276 |
manish.sha |
918 |
if(order.getInsurer() > 0) {
|
|
|
919 |
insuranceAmount =insuranceAmount + order.getInsuranceAmount();
|
|
|
920 |
}
|
|
|
921 |
if(order.getSource() == OrderSource.STORE.getValue()) {
|
|
|
922 |
advanceAmount = advanceAmount + order.getAdvanceAmount();
|
|
|
923 |
}
|
|
|
924 |
if(!itemNamesMap.containsKey(lineitem.getItem_id())){
|
|
|
925 |
itemNamesMap.put(lineitem.getItem_id(), getItemDisplayName(lineitem, false));
|
|
|
926 |
}
|
|
|
927 |
if(!itemRateMap.containsKey(lineitem.getItem_id())){
|
|
|
928 |
itemRateMap.put(lineitem.getItem_id(), lineitem.getUnit_price());
|
|
|
929 |
}
|
|
|
930 |
if(itemQuantityMap.containsKey(lineitem.getItem_id())){
|
|
|
931 |
double currentQuantity = itemQuantityMap.get(lineitem.getItem_id()) +lineitem.getQuantity();
|
|
|
932 |
itemQuantityMap.put(lineitem.getItem_id(), currentQuantity);
|
|
|
933 |
}else{
|
|
|
934 |
itemQuantityMap.put(lineitem.getItem_id(), lineitem.getQuantity());
|
|
|
935 |
}
|
|
|
936 |
|
|
|
937 |
if(itemTotalAmtMap.containsKey(lineitem.getItem_id())){
|
| 13492 |
manish.sha |
938 |
double totalItemAmount = itemTotalAmtMap.get(lineitem.getItem_id()) + (order.getTotal_amount()-order.getAdvanceAmount()-order.getInsuranceAmount());
|
| 13276 |
manish.sha |
939 |
itemTotalAmtMap.put(lineitem.getItem_id(), totalItemAmount);
|
|
|
940 |
}else{
|
| 13492 |
manish.sha |
941 |
itemTotalAmtMap.put(lineitem.getItem_id(), (order.getTotal_amount()-order.getAdvanceAmount()-order.getInsuranceAmount()));
|
| 13276 |
manish.sha |
942 |
}
|
|
|
943 |
if(paymentMode==null || paymentMode.isEmpty()){
|
|
|
944 |
if(order.getPickupStoreId() > 0 && order.isCod() == true)
|
|
|
945 |
paymentMode = "In-Store";
|
|
|
946 |
else if (order.isCod())
|
|
|
947 |
paymentMode = "COD";
|
|
|
948 |
else
|
|
|
949 |
paymentMode = "Prepaid";
|
|
|
950 |
}
|
|
|
951 |
}
|
|
|
952 |
|
|
|
953 |
int serialNo = 0;
|
|
|
954 |
for(Long itemId : itemNamesMap.keySet()){
|
|
|
955 |
serialNo ++;
|
|
|
956 |
invoiceTable.addCell(new Phrase(serialNo+ "", helvetica8));
|
|
|
957 |
invoiceTable.addCell(new Phrase(paymentMode, helvetica8));
|
|
|
958 |
invoiceTable.addCell(new Phrase(itemNamesMap.get(itemId), helvetica8));
|
|
|
959 |
invoiceTable.addCell(new Phrase(itemQuantityMap.get(itemId)+"", helvetica8));
|
|
|
960 |
invoiceTable.addCell(new Phrase(itemRateMap.get(itemId)+"", helvetica8));
|
|
|
961 |
invoiceTable.addCell(new Phrase(itemTotalAmtMap.get(itemId)+"", helvetica8));
|
|
|
962 |
}
|
|
|
963 |
|
|
|
964 |
if(insuranceAmount>0){
|
|
|
965 |
invoiceTable.addCell(getInsuranceCell(4));
|
|
|
966 |
invoiceTable.addCell(getPriceCell(insuranceAmount));
|
|
|
967 |
invoiceTable.addCell(getPriceCell(insuranceAmount));
|
|
|
968 |
}
|
|
|
969 |
if(advanceAmount>0){
|
|
|
970 |
invoiceTable.addCell(getAdvanceAmountCell(4));
|
|
|
971 |
invoiceTable.addCell(getPriceCell(advanceAmount));
|
|
|
972 |
invoiceTable.addCell(getPriceCell(advanceAmount));
|
|
|
973 |
}
|
|
|
974 |
}else{
|
|
|
975 |
for(Order order : orderList){
|
|
|
976 |
populateTopInvoiceTable(order, invoiceTable);
|
|
|
977 |
if(order.getInsurer() > 0) {
|
|
|
978 |
invoiceTable.addCell(getInsuranceCell(4));
|
|
|
979 |
invoiceTable.addCell(getPriceCell(order.getInsuranceAmount()));
|
|
|
980 |
invoiceTable.addCell(getPriceCell(order.getInsuranceAmount()));
|
|
|
981 |
}
|
| 7014 |
rajveer |
982 |
|
| 13276 |
manish.sha |
983 |
if(order.getSource() == OrderSource.STORE.getValue()) {
|
|
|
984 |
invoiceTable.addCell(getAdvanceAmountCell(4));
|
|
|
985 |
invoiceTable.addCell(getPriceCell(order.getAdvanceAmount()));
|
|
|
986 |
invoiceTable.addCell(getPriceCell(order.getAdvanceAmount()));
|
|
|
987 |
}
|
| 13494 |
manish.sha |
988 |
totalAmount = totalAmount + order.getTotal_amount()-order.getAdvanceAmount();
|
| 17470 |
manish.sha |
989 |
totalShippingCost = totalShippingCost + order.getShippingCost();
|
| 13276 |
manish.sha |
990 |
}
|
| 7014 |
rajveer |
991 |
}
|
| 17470 |
manish.sha |
992 |
if(totalShippingCost>0){
|
|
|
993 |
invoiceTable.addCell(getShippingCostCell(4));
|
| 17501 |
manish.sha |
994 |
invoiceTable.addCell(getRupeesCell(false));
|
|
|
995 |
invoiceTable.addCell(getPriceCell(totalShippingCost));
|
| 17470 |
manish.sha |
996 |
}
|
| 7014 |
rajveer |
997 |
invoiceTable.addCell(getTotalCell(4));
|
| 17501 |
manish.sha |
998 |
invoiceTable.addCell(getRupeesCell(true));
|
| 17470 |
manish.sha |
999 |
invoiceTable.addCell(getTotalAmountCell(totalAmount+totalShippingCost));
|
| 13276 |
manish.sha |
1000 |
|
| 7014 |
rajveer |
1001 |
|
|
|
1002 |
PdfPCell tinCell = new PdfPCell(new Phrase("TIN NO. " + tinNo, helvetica8));
|
|
|
1003 |
tinCell.setColspan(6);
|
|
|
1004 |
tinCell.setPadding(2);
|
|
|
1005 |
invoiceTable.addCell(tinCell);
|
|
|
1006 |
|
|
|
1007 |
return invoiceTable;
|
|
|
1008 |
}
|
|
|
1009 |
|
|
|
1010 |
private void populateTopInvoiceTable(Order order, PdfPTable invoiceTable) {
|
|
|
1011 |
List<LineItem> lineitems = order.getLineitems();
|
|
|
1012 |
for (LineItem lineitem : lineitems) {
|
|
|
1013 |
invoiceTable.addCell(new Phrase(order.getId() + "", helvetica8));
|
|
|
1014 |
if(order.getPickupStoreId() > 0 && order.isCod() == true)
|
|
|
1015 |
invoiceTable.addCell(new Phrase("In-Store", helvetica8));
|
|
|
1016 |
else if (order.isCod())
|
|
|
1017 |
invoiceTable.addCell(new Phrase("COD", helvetica8));
|
|
|
1018 |
else
|
|
|
1019 |
invoiceTable.addCell(new Phrase("Prepaid", helvetica8));
|
| 7318 |
rajveer |
1020 |
|
| 7190 |
amar.kumar |
1021 |
invoiceTable.addCell(getProductNameCell(lineitem, false, order.getFreebieItemId()));
|
| 2787 |
chandransh |
1022 |
|
| 7014 |
rajveer |
1023 |
invoiceTable.addCell(new Phrase(lineitem.getQuantity() + "", helvetica8));
|
| 2787 |
chandransh |
1024 |
|
| 7014 |
rajveer |
1025 |
invoiceTable.addCell(getPriceCell(lineitem.getUnit_price()-order.getGvAmount()));
|
|
|
1026 |
|
|
|
1027 |
invoiceTable.addCell(getPriceCell(lineitem.getTotal_price()-order.getGvAmount()));
|
|
|
1028 |
}
|
|
|
1029 |
}
|
|
|
1030 |
|
|
|
1031 |
private PdfPCell getAddressCell(String address) {
|
|
|
1032 |
Paragraph addressParagraph = new Paragraph(address, new Font(FontFamily.TIMES_ROMAN, 8f));
|
|
|
1033 |
PdfPCell addressCell = new PdfPCell();
|
|
|
1034 |
addressCell.addElement(addressParagraph);
|
|
|
1035 |
addressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
1036 |
addressCell.setBorder(Rectangle.NO_BORDER);
|
|
|
1037 |
return addressCell;
|
|
|
1038 |
}
|
|
|
1039 |
|
| 13276 |
manish.sha |
1040 |
private PdfPTable getTaxCumRetailInvoiceTable(List<Order> orderList, Provider provider, String ourAddress, String tinNo, String invoiceFormat){
|
|
|
1041 |
Order order = orderList.get(0);
|
| 7014 |
rajveer |
1042 |
PdfPTable taxTable = new PdfPTable(1);
|
|
|
1043 |
Phrase phrase = null;
|
|
|
1044 |
taxTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
1045 |
taxTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 8104 |
manish.sha |
1046 |
|
| 8110 |
manish.sha |
1047 |
PdfPTable logoTitleAndOurAddressTable = new PdfPTable(new float[]{0.4f, 0.3f, 0.3f});
|
| 8107 |
manish.sha |
1048 |
logoTitleAndOurAddressTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 8112 |
manish.sha |
1049 |
logoTitleAndOurAddressTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
|
| 8107 |
manish.sha |
1050 |
|
| 8110 |
manish.sha |
1051 |
|
| 8103 |
manish.sha |
1052 |
PdfPTable logoTable = new PdfPTable(2);
|
|
|
1053 |
addLogoTable(logoTable,order);
|
| 7318 |
rajveer |
1054 |
|
| 7014 |
rajveer |
1055 |
if (order.getOrderType().equals(OrderType.B2B)) {
|
|
|
1056 |
phrase = new Phrase("TAX INVOICE", helveticaBold12);
|
|
|
1057 |
} else {
|
|
|
1058 |
phrase = new Phrase("RETAIL INVOICE", helveticaBold12);
|
|
|
1059 |
}
|
|
|
1060 |
PdfPCell retailInvoiceTitleCell = new PdfPCell(phrase);
|
|
|
1061 |
retailInvoiceTitleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
1062 |
retailInvoiceTitleCell.setBorder(Rectangle.NO_BORDER);
|
|
|
1063 |
|
| 17203 |
manish.sha |
1064 |
Paragraph sorlAddress = new Paragraph(ourAddress + "\n Contact No.- +91-9811247808" + "\nTIN NO. " + tinNo, new Font(FontFamily.TIMES_ROMAN, 8f, Element.ALIGN_CENTER));
|
| 7014 |
rajveer |
1065 |
PdfPCell sorlAddressCell = new PdfPCell(sorlAddress);
|
|
|
1066 |
sorlAddressCell.addElement(sorlAddress);
|
| 8110 |
manish.sha |
1067 |
sorlAddressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
| 7014 |
rajveer |
1068 |
|
| 18530 |
manish.sha |
1069 |
PdfPTable customerAddress = getCustomerAddressTable(order, null, true, helvetica8, true, true);
|
| 7014 |
rajveer |
1070 |
PdfPTable orderDetails = getOrderDetails(order, provider);
|
|
|
1071 |
|
|
|
1072 |
PdfPTable addrAndOrderDetailsTable = new PdfPTable(new float[]{0.5f, 0.1f, 0.4f});
|
|
|
1073 |
addrAndOrderDetailsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
1074 |
addrAndOrderDetailsTable.addCell(customerAddress);
|
|
|
1075 |
addrAndOrderDetailsTable.addCell(new Phrase(" "));
|
|
|
1076 |
addrAndOrderDetailsTable.addCell(orderDetails);
|
|
|
1077 |
|
| 9319 |
amar.kumar |
1078 |
boolean isVAT = isVatApplicable(order);
|
| 13276 |
manish.sha |
1079 |
PdfPTable invoiceTable = getBottomInvoiceTable(orderList, isVAT, invoiceFormat);
|
| 7014 |
rajveer |
1080 |
|
| 10607 |
manish.sha |
1081 |
PdfPTable regAddAndDisCellTable = new PdfPTable(2);
|
|
|
1082 |
|
| 7014 |
rajveer |
1083 |
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));
|
|
|
1084 |
disclaimerCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
1085 |
disclaimerCell.setBorder(Rectangle.NO_BORDER);
|
| 7318 |
rajveer |
1086 |
|
| 17203 |
manish.sha |
1087 |
PdfPCell regAddressCell = new PdfPCell(new Phrase(" SPICE ONLINE RETAIL PRIVATE LIMITED\n Regd. Add. 60-D, STREET NO. C-5, SAINIK FARMS,NEW DELHI-110062\n CIN: U74140DL2008PTC183856 Tel. No. +91-9811247808 E-mail. help@saholic.com Website. www.saholic.com", helvetica6));
|
| 10607 |
manish.sha |
1088 |
regAddressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
1089 |
regAddressCell.setBorder(Rectangle.NO_BORDER);
|
|
|
1090 |
/*SPICE ONLINE RETAIL PRIVATE LIMITED
|
|
|
1091 |
Regd. Add. 60-D, STREET NO. C-5, SAINIK FARMS,NEW DELHI-110062
|
|
|
1092 |
CIN: U74140DL2008PTC183856
|
|
|
1093 |
Tel. No. 0120-2479977
|
|
|
1094 |
E-mail. help@saholic.com
|
|
|
1095 |
Website. www.saholic.com*/
|
| 9014 |
amar.kumar |
1096 |
PdfPCell powerTextCell = new PdfPCell(new Phrase("Powered By Flipkart", helvetica8));
|
|
|
1097 |
powerTextCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
1098 |
powerTextCell.setBorder(Rectangle.NO_BORDER);
|
|
|
1099 |
powerTextCell.setPaddingBottom(30.0f);
|
| 8104 |
manish.sha |
1100 |
|
|
|
1101 |
logoTitleAndOurAddressTable.addCell(logoTable);
|
| 8110 |
manish.sha |
1102 |
logoTitleAndOurAddressTable.addCell(retailInvoiceTitleCell);
|
|
|
1103 |
logoTitleAndOurAddressTable.addCell(sorlAddress);
|
| 8104 |
manish.sha |
1104 |
|
| 10607 |
manish.sha |
1105 |
regAddAndDisCellTable.addCell(disclaimerCell);
|
|
|
1106 |
regAddAndDisCellTable.addCell(regAddressCell);
|
|
|
1107 |
|
| 8104 |
manish.sha |
1108 |
taxTable.addCell(logoTitleAndOurAddressTable);
|
| 7014 |
rajveer |
1109 |
taxTable.addCell(addrAndOrderDetailsTable);
|
|
|
1110 |
taxTable.addCell(invoiceTable);
|
| 10608 |
manish.sha |
1111 |
taxTable.addCell(regAddAndDisCellTable);
|
| 9014 |
amar.kumar |
1112 |
if(order.getSource() == OrderSource.FLIPKART.getValue()) {
|
|
|
1113 |
taxTable.addCell(powerTextCell);
|
|
|
1114 |
|
|
|
1115 |
}
|
| 10320 |
amar.kumar |
1116 |
if(order.getProductCondition().equals(ProductCondition.BAD)){
|
| 10328 |
amar.kumar |
1117 |
PdfPCell badSaleDisclaimerCell = new PdfPCell(new Phrase(" Item(s) above are sold on as is where is basis. They " +
|
| 10320 |
amar.kumar |
1118 |
"may be in dead/defective/damaged/refurbished/incomplete/open condition. These " +
|
|
|
1119 |
"are not returnable, exchangeable or refundable under any circumstances. No " +
|
|
|
1120 |
"warranty is assured on these items." ,
|
| 10329 |
amar.kumar |
1121 |
new Font(FontFamily.TIMES_ROMAN, 8f)));
|
| 10328 |
amar.kumar |
1122 |
badSaleDisclaimerCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
1123 |
badSaleDisclaimerCell.setBorder(Rectangle.NO_BORDER);
|
|
|
1124 |
taxTable.addCell(badSaleDisclaimerCell);
|
| 10320 |
amar.kumar |
1125 |
}
|
| 7014 |
rajveer |
1126 |
return taxTable;
|
|
|
1127 |
}
|
| 9009 |
amar.kumar |
1128 |
|
| 9319 |
amar.kumar |
1129 |
private boolean isVatApplicable(Order order) {
|
|
|
1130 |
if(order.getWarehouse_id() == 7) {
|
|
|
1131 |
if(order.getCustomer_pincode().startsWith(delhiPincodePrefix)) {
|
|
|
1132 |
return true;
|
|
|
1133 |
} else {
|
|
|
1134 |
return false;
|
|
|
1135 |
}
|
| 12809 |
manish.sha |
1136 |
} else if(order.getWarehouse_id() == 3298){
|
|
|
1137 |
for(int i=0; i< telanganaPincodes.length; i++) {
|
|
|
1138 |
if(order.getCustomer_pincode().trim().equalsIgnoreCase(telanganaPincodes[i])) {
|
|
|
1139 |
return true;
|
|
|
1140 |
}
|
|
|
1141 |
}
|
|
|
1142 |
return false;
|
| 16196 |
manish.sha |
1143 |
} else if(order.getWarehouse_id() == 1765 || order.getWarehouse_id() == 1768){
|
|
|
1144 |
for(int i=0; i< karnatakaPincodePrefix.length; i++) {
|
|
|
1145 |
if(order.getCustomer_pincode().startsWith(karnatakaPincodePrefix[i])) {
|
|
|
1146 |
return true;
|
|
|
1147 |
}
|
|
|
1148 |
}
|
|
|
1149 |
return false;
|
| 12809 |
manish.sha |
1150 |
}
|
|
|
1151 |
else {
|
| 9319 |
amar.kumar |
1152 |
for(int i=0; i< maharashtraPincodePrefix.length; i++) {
|
|
|
1153 |
if(order.getCustomer_pincode().startsWith(maharashtraPincodePrefix[i])) {
|
|
|
1154 |
return true;
|
|
|
1155 |
}
|
|
|
1156 |
}
|
|
|
1157 |
return false;
|
|
|
1158 |
}
|
|
|
1159 |
}
|
|
|
1160 |
|
| 9037 |
amar.kumar |
1161 |
private PdfPTable getFlipkartBarCodes(Order order) {
|
|
|
1162 |
PdfPTable flipkartTable = new PdfPTable(3);
|
|
|
1163 |
|
|
|
1164 |
PdfPCell spacerCell = new PdfPCell();
|
| 9040 |
amar.kumar |
1165 |
spacerCell.setBorder(Rectangle.NO_BORDER);
|
| 9037 |
amar.kumar |
1166 |
spacerCell.setColspan(3);
|
| 9099 |
amar.kumar |
1167 |
spacerCell.setPaddingTop(330.0f);
|
| 9037 |
amar.kumar |
1168 |
|
|
|
1169 |
String flipkartCodeFontPath = InvoiceGenerationService.class.getResource("/saholic-wn.TTF").getPath();
|
|
|
1170 |
FontFactoryImp ttfFontFactory = new FontFactoryImp();
|
|
|
1171 |
ttfFontFactory.register(flipkartCodeFontPath, "barcode");
|
|
|
1172 |
Font flipkartBarCodeFont = ttfFontFactory.getFont("barcode", BaseFont.CP1252, true, 20);
|
|
|
1173 |
|
| 9040 |
amar.kumar |
1174 |
String serialNumber = "0000000000";
|
| 9511 |
manish.sha |
1175 |
if(order.getLineitems().get(0).getSerial_number()!=null && !order.getLineitems().get(0).getSerial_number().isEmpty()) {
|
| 9040 |
amar.kumar |
1176 |
serialNumber = order.getLineitems().get(0).getSerial_number();
|
| 9511 |
manish.sha |
1177 |
} else if(order.getLineitems().get(0).getItem_number()!=null && !order.getLineitems().get(0).getItem_number().isEmpty()) {
|
| 9040 |
amar.kumar |
1178 |
serialNumber = order.getLineitems().get(0).getItem_number();
|
|
|
1179 |
}
|
|
|
1180 |
|
|
|
1181 |
PdfPCell serialNumberBarCodeCell = new PdfPCell(new Paragraph("*" + serialNumber + "*", flipkartBarCodeFont));
|
| 9037 |
amar.kumar |
1182 |
serialNumberBarCodeCell.setBorder(Rectangle.TOP);
|
| 9044 |
amar.kumar |
1183 |
serialNumberBarCodeCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 9037 |
amar.kumar |
1184 |
serialNumberBarCodeCell.setPaddingTop(11.0f);
|
|
|
1185 |
|
|
|
1186 |
|
|
|
1187 |
PdfPCell invoiceNumberBarCodeCell = new PdfPCell(new Paragraph("*" + order.getInvoice_number() + "*", flipkartBarCodeFont));
|
|
|
1188 |
invoiceNumberBarCodeCell.setBorder(Rectangle.TOP);
|
| 9044 |
amar.kumar |
1189 |
invoiceNumberBarCodeCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 9037 |
amar.kumar |
1190 |
invoiceNumberBarCodeCell.setPaddingTop(11.0f);
|
|
|
1191 |
|
|
|
1192 |
double rate = order.getLineitems().get(0).getVatRate();
|
|
|
1193 |
double salesTax = (rate * order.getTotal_amount())/(100 + rate);
|
| 9040 |
amar.kumar |
1194 |
PdfPCell vatAmtBarCodeCell = new PdfPCell(new Paragraph("*" + amountFormat.format(salesTax) + "*", flipkartBarCodeFont));
|
| 9037 |
amar.kumar |
1195 |
vatAmtBarCodeCell.setBorder(Rectangle.TOP);
|
| 9044 |
amar.kumar |
1196 |
vatAmtBarCodeCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 9037 |
amar.kumar |
1197 |
vatAmtBarCodeCell.setPaddingTop(11.0f);
|
|
|
1198 |
|
|
|
1199 |
flipkartTable.addCell(spacerCell);
|
|
|
1200 |
flipkartTable.addCell(serialNumberBarCodeCell);
|
|
|
1201 |
flipkartTable.addCell(invoiceNumberBarCodeCell);
|
|
|
1202 |
flipkartTable.addCell(vatAmtBarCodeCell);
|
|
|
1203 |
|
|
|
1204 |
return flipkartTable;
|
|
|
1205 |
|
| 9009 |
amar.kumar |
1206 |
}
|
|
|
1207 |
|
| 18530 |
manish.sha |
1208 |
private PdfPTable getCustomerAddressTable(Order order, String destCode, boolean showPaymentMode, Font font, boolean forInvoce, boolean billingAdd){
|
| 7014 |
rajveer |
1209 |
PdfPTable customerTable = new PdfPTable(1);
|
|
|
1210 |
customerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
1211 |
if(forInvoce || order.getPickupStoreId() == 0){
|
| 18530 |
manish.sha |
1212 |
in.shop2020.model.v1.user.UserContextService.Client userClient = usc.getClient();
|
|
|
1213 |
try {
|
|
|
1214 |
if(billingAdd && userClient.isPrivateDealUser(order.getCustomer_id())){
|
|
|
1215 |
Address billingAddress = userClient.getBillingAddressForUser(order.getCustomer_id());
|
|
|
1216 |
customerTable.addCell(new Phrase(billingAddress.getName(), font));
|
|
|
1217 |
customerTable.addCell(new Phrase(billingAddress.getLine1(), font));
|
|
|
1218 |
customerTable.addCell(new Phrase(billingAddress.getLine2(), font));
|
|
|
1219 |
customerTable.addCell(new Phrase(billingAddress.getCity() + "," + billingAddress.getState(), font));
|
|
|
1220 |
customerTable.addCell(new Phrase(billingAddress.getPin(), font));
|
|
|
1221 |
customerTable.addCell(new Phrase("Phone : " + (billingAddress.getPhone()== null ? "" : billingAddress.getPhone()), font));
|
|
|
1222 |
}else{
|
|
|
1223 |
customerTable.addCell(new Phrase(order.getCustomer_name(), font));
|
|
|
1224 |
if(order.getSource() == OrderSource.HOMESHOP18.getValue()){
|
|
|
1225 |
HsOrder hsOrder = null;
|
|
|
1226 |
try {
|
|
|
1227 |
hsOrder = tsc.getClient().getHomeShopOrder(order.getId(), null, null).get(0);
|
|
|
1228 |
}catch (TException e) {
|
|
|
1229 |
logger.error("Error while getting homeshop18 order", e);
|
|
|
1230 |
}
|
|
|
1231 |
String hsShippingName = hsOrder.getShippingName();
|
|
|
1232 |
if(hsShippingName!=null && !hsShippingName.isEmpty()){
|
|
|
1233 |
customerTable.addCell(new Phrase("Shipped To: "+hsShippingName, font));
|
|
|
1234 |
}
|
|
|
1235 |
}
|
|
|
1236 |
customerTable.addCell(new Phrase(order.getCustomer_address1(), font));
|
|
|
1237 |
customerTable.addCell(new Phrase(order.getCustomer_address2(), font));
|
|
|
1238 |
customerTable.addCell(new Phrase(order.getCustomer_city() + "," + order.getCustomer_state(), font));
|
|
|
1239 |
//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
|
|
1240 |
if(order.getLogistics_provider_id()!=7L){
|
|
|
1241 |
if(destCode != null)
|
|
|
1242 |
customerTable.addCell(new Phrase(order.getCustomer_pincode() + " - " + destCode, helvetica16));
|
|
|
1243 |
else
|
|
|
1244 |
customerTable.addCell(new Phrase(order.getCustomer_pincode(), font));
|
|
|
1245 |
}
|
|
|
1246 |
else{
|
|
|
1247 |
in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
|
|
|
1248 |
String fedexLocationcode = "";
|
|
|
1249 |
try {
|
|
|
1250 |
fedexLocationcode = tclient.getOrderAttributeValue(order.getId(), "FedEx_Location_Code");
|
|
|
1251 |
} catch (TException e1) {
|
|
|
1252 |
logger.error("Error while getting the provider information.", e1);
|
|
|
1253 |
}
|
|
|
1254 |
customerTable.addCell(new Phrase(order.getCustomer_pincode() + " - " + fedexLocationcode, helvetica16));
|
|
|
1255 |
}
|
|
|
1256 |
//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
|
|
|
1257 |
if(order.getCustomer_mobilenumber()!=null && !order.getCustomer_mobilenumber().isEmpty()) {
|
|
|
1258 |
customerTable.addCell(new Phrase("Phone : " + (order.getCustomer_mobilenumber()== null ? "" : order.getCustomer_mobilenumber()), font));
|
|
|
1259 |
}
|
| 13734 |
manish.sha |
1260 |
}
|
| 18530 |
manish.sha |
1261 |
} catch (TException e2) {
|
|
|
1262 |
e2.printStackTrace();
|
| 13734 |
manish.sha |
1263 |
}
|
| 18530 |
manish.sha |
1264 |
|
| 7014 |
rajveer |
1265 |
}else{
|
|
|
1266 |
try {
|
| 5556 |
rajveer |
1267 |
in.shop2020.logistics.LogisticsService.Client lclient = (new LogisticsClient()).getClient();
|
| 7014 |
rajveer |
1268 |
PickupStore store = lclient.getPickupStore(order.getPickupStoreId());
|
|
|
1269 |
customerTable.addCell(new Phrase(order.getCustomer_name() + " \nc/o " + store.getName(), font));
|
|
|
1270 |
customerTable.addCell(new Phrase(store.getLine1(), font));
|
|
|
1271 |
customerTable.addCell(new Phrase(store.getLine2(), font));
|
|
|
1272 |
customerTable.addCell(new Phrase(store.getCity() + "," + store.getState(), font));
|
|
|
1273 |
if(destCode != null)
|
|
|
1274 |
customerTable.addCell(new Phrase(store.getPin() + " - " + destCode, helvetica16));
|
|
|
1275 |
else
|
|
|
1276 |
customerTable.addCell(new Phrase(store.getPin(), font));
|
|
|
1277 |
customerTable.addCell(new Phrase("Phone :" + store.getPhone(), font));
|
| 5556 |
rajveer |
1278 |
} catch (TException e) {
|
|
|
1279 |
// TODO Auto-generated catch block
|
|
|
1280 |
e.printStackTrace();
|
|
|
1281 |
}
|
| 5527 |
anupam.sin |
1282 |
|
| 7014 |
rajveer |
1283 |
}
|
|
|
1284 |
|
|
|
1285 |
if(order.getOrderType().equals(OrderType.B2B)) {
|
|
|
1286 |
String tin = null;
|
|
|
1287 |
in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
|
|
|
1288 |
List<Attribute> attributes;
|
|
|
1289 |
try {
|
|
|
1290 |
attributes = tclient.getAllAttributesForOrderId(order.getId());
|
|
|
1291 |
|
|
|
1292 |
for(Attribute attribute : attributes) {
|
|
|
1293 |
if(attribute.getName().equals("tinNumber")) {
|
|
|
1294 |
tin = attribute.getValue();
|
|
|
1295 |
}
|
|
|
1296 |
}
|
|
|
1297 |
if (tin != null) {
|
|
|
1298 |
customerTable.addCell(new Phrase("TIN :" + tin, font));
|
|
|
1299 |
}
|
|
|
1300 |
|
|
|
1301 |
} catch (Exception e) {
|
|
|
1302 |
logger.error("Error while getting order attributes", e);
|
|
|
1303 |
}
|
|
|
1304 |
}
|
|
|
1305 |
/*
|
| 2787 |
chandransh |
1306 |
if(showPaymentMode){
|
|
|
1307 |
customerTable.addCell(new Phrase(" ", font));
|
|
|
1308 |
customerTable.addCell(new Phrase("Payment Mode: Prepaid", font));
|
| 5856 |
anupam.sin |
1309 |
}*/
|
| 7014 |
rajveer |
1310 |
return customerTable;
|
|
|
1311 |
}
|
| 2787 |
chandransh |
1312 |
|
| 7014 |
rajveer |
1313 |
private PdfPTable getOrderDetails(Order order, Provider provider){
|
|
|
1314 |
PdfPTable orderTable = new PdfPTable(new float[]{0.4f, 0.6f});
|
|
|
1315 |
orderTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 2787 |
chandransh |
1316 |
|
| 7014 |
rajveer |
1317 |
orderTable.addCell(new Phrase("Invoice No:", helvetica8));
|
|
|
1318 |
orderTable.addCell(new Phrase(order.getInvoice_number(), helvetica8));
|
| 2787 |
chandransh |
1319 |
|
| 7014 |
rajveer |
1320 |
orderTable.addCell(new Phrase("Date:", helvetica8));
|
|
|
1321 |
orderTable.addCell(new Phrase(DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(order.getBilling_timestamp())), helvetica8));
|
| 2787 |
chandransh |
1322 |
|
| 13691 |
manish.sha |
1323 |
String hsCourierName = "";
|
| 12590 |
amit.gupta |
1324 |
if(order.getSource() == OrderSource.AMAZON.getValue() || order.getSource() == OrderSource.JUNGLEE.getValue()){
|
| 7528 |
rajveer |
1325 |
AmazonOrder aorder = null;
|
|
|
1326 |
try {
|
|
|
1327 |
aorder = tsc.getClient().getAmazonOrder(order.getId());
|
|
|
1328 |
} catch (TException e) {
|
|
|
1329 |
logger.error("Error while getting amazon order", e);
|
|
|
1330 |
}
|
| 12590 |
amit.gupta |
1331 |
if(order.getSource() == OrderSource.JUNGLEE.getValue()){
|
|
|
1332 |
orderTable.addCell(new Phrase("Junglee Order ID:", helvetica8));
|
|
|
1333 |
}else {
|
|
|
1334 |
orderTable.addCell(new Phrase("Amazon Order ID:", helvetica8));
|
|
|
1335 |
}
|
| 7528 |
rajveer |
1336 |
orderTable.addCell(new Phrase(aorder.getAmazonOrderCode(), helvetica8));
|
| 13691 |
manish.sha |
1337 |
} else if(order.getSource() == OrderSource.HOMESHOP18.getValue()){
|
|
|
1338 |
HsOrder hsOrder = null;
|
|
|
1339 |
try {
|
| 13706 |
manish.sha |
1340 |
hsOrder = tsc.getClient().getHomeShopOrder(order.getId(), null, null).get(0);
|
| 13691 |
manish.sha |
1341 |
}catch (TException e) {
|
|
|
1342 |
logger.error("Error while getting homeshop18 order", e);
|
|
|
1343 |
}
|
|
|
1344 |
hsCourierName = hsOrder.getCourierName();
|
|
|
1345 |
orderTable.addCell(new Phrase("HomeShop18 Order No:", helvetica8));
|
|
|
1346 |
orderTable.addCell(new Phrase(hsOrder.getHsOrderNo(), helvetica8));
|
|
|
1347 |
orderTable.addCell(new Phrase("HomeShop18 Sub Order No:", helvetica8));
|
|
|
1348 |
orderTable.addCell(new Phrase(hsOrder.getHsSubOrderNo(), helvetica8));
|
|
|
1349 |
|
| 8182 |
amar.kumar |
1350 |
} else if(order.getSource() == OrderSource.EBAY.getValue()){
|
|
|
1351 |
EbayOrder ebayOrder = null;
|
|
|
1352 |
try {
|
|
|
1353 |
ebayOrder = tsc.getClient().getEbayOrderByOrderId(order.getId());
|
|
|
1354 |
} catch (TException e) {
|
|
|
1355 |
logger.error("Error while getting ebay order", e);
|
|
|
1356 |
}
|
|
|
1357 |
orderTable.addCell(new Phrase("PaisaPayId:", helvetica8));
|
|
|
1358 |
orderTable.addCell(new Phrase(ebayOrder.getPaisaPayId(), helvetica8));
|
|
|
1359 |
orderTable.addCell(new Phrase("Sales Rec Number:", helvetica8));
|
|
|
1360 |
orderTable.addCell(new Phrase(new Long(ebayOrder.getSalesRecordNumber()).toString(), helvetica8));
|
| 8488 |
amar.kumar |
1361 |
} else if(order.getSource() == OrderSource.SNAPDEAL.getValue()){
|
|
|
1362 |
SnapdealOrder snapdealOrder = null;
|
|
|
1363 |
try {
|
| 11424 |
kshitij.so |
1364 |
snapdealOrder = tsc.getClient().getSnapdealOrder(order.getId(), null, null).get(0);
|
| 8488 |
amar.kumar |
1365 |
} catch (TException e) {
|
|
|
1366 |
logger.error("Error while getting snapdeal order", e);
|
|
|
1367 |
}
|
|
|
1368 |
orderTable.addCell(new Phrase("Snapdeal OrderId:", helvetica8));
|
|
|
1369 |
orderTable.addCell(new Phrase(new Long(snapdealOrder.getSubOrderId()).toString(), helvetica8));
|
| 8828 |
amar.kumar |
1370 |
|
|
|
1371 |
String refernceCodeFontPath = InvoiceGenerationService.class.getResource("/saholic-wn.TTF").getPath();
|
|
|
1372 |
FontFactoryImp ttfFontFactory = new FontFactoryImp();
|
|
|
1373 |
ttfFontFactory.register(refernceCodeFontPath, "barcode");
|
| 8876 |
amar.kumar |
1374 |
Font referenceCodeBarCodeFont = ttfFontFactory.getFont("barcode", BaseFont.CP1252, true, 20);
|
| 8828 |
amar.kumar |
1375 |
|
| 8874 |
amar.kumar |
1376 |
PdfPCell snapdealReferenceBarCodeCell = new PdfPCell(new Paragraph("*" + snapdealOrder.getReferenceCode() + "*", referenceCodeBarCodeFont));
|
| 8828 |
amar.kumar |
1377 |
snapdealReferenceBarCodeCell.setBorder(Rectangle.NO_BORDER);
|
| 8876 |
amar.kumar |
1378 |
snapdealReferenceBarCodeCell.setPaddingTop(9.0f);
|
|
|
1379 |
snapdealReferenceBarCodeCell.setColspan(2);
|
| 9042 |
amar.kumar |
1380 |
snapdealReferenceBarCodeCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 8876 |
amar.kumar |
1381 |
//orderTable.addCell(new Phrase("Snapdeal ReferenceCode:", helvetica8));
|
| 8828 |
amar.kumar |
1382 |
orderTable.addCell(snapdealReferenceBarCodeCell);
|
|
|
1383 |
//orderTable.addCell(new Phrase(snapdealOrder.getReferenceCode(), helvetica8));
|
| 7528 |
rajveer |
1384 |
}
|
| 8989 |
vikram.rag |
1385 |
else if(order.getSource() == OrderSource.FLIPKART.getValue()){
|
|
|
1386 |
FlipkartOrder flipkartOrder = null;
|
|
|
1387 |
try {
|
|
|
1388 |
flipkartOrder = tsc.getClient().getFlipkartOrder(order.getId());
|
|
|
1389 |
} catch (TException e) {
|
| 8996 |
amar.kumar |
1390 |
logger.error("Error while getting flipkart order", e);
|
| 8989 |
vikram.rag |
1391 |
}
|
|
|
1392 |
orderTable.addCell(new Phrase("Flipkart OrderId:", helvetica8));
|
|
|
1393 |
orderTable.addCell(new Phrase(flipkartOrder.getFlipkartOrderId(), helvetica8));
|
| 9037 |
amar.kumar |
1394 |
|
|
|
1395 |
//orderTable.addCell(new Phrase("Flipkart OrderItemId:", helvetica8));
|
|
|
1396 |
String flipkartBarCodeFontPath = InvoiceGenerationService.class.getResource("/saholic-wn.TTF").getPath();
|
|
|
1397 |
FontFactoryImp ttfFontFactory = new FontFactoryImp();
|
|
|
1398 |
ttfFontFactory.register(flipkartBarCodeFontPath, "barcode");
|
| 9043 |
amar.kumar |
1399 |
Font flipkartBarCodeFont = ttfFontFactory.getFont("barcode", BaseFont.CP1252, true, 18);
|
| 9037 |
amar.kumar |
1400 |
|
| 9043 |
amar.kumar |
1401 |
orderTable.addCell(new Phrase("Flipkart OrderItemId:", helvetica8));
|
| 9037 |
amar.kumar |
1402 |
PdfPCell flipkartOrderItemIdBarCodeCell = new PdfPCell(new Paragraph("*" + new Long(flipkartOrder.getFlipkartSubOrderId()).toString() + "*", flipkartBarCodeFont));
|
|
|
1403 |
flipkartOrderItemIdBarCodeCell.setBorder(Rectangle.NO_BORDER);
|
|
|
1404 |
flipkartOrderItemIdBarCodeCell.setPaddingTop(9.0f);
|
| 9043 |
amar.kumar |
1405 |
//flipkartOrderItemIdBarCodeCell.setColspan(2);
|
|
|
1406 |
//flipkartOrderItemIdBarCodeCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 9037 |
amar.kumar |
1407 |
orderTable.addCell(flipkartOrderItemIdBarCodeCell);
|
|
|
1408 |
//orderTable.addCell(new Phrase("Flipkart OrderItemId:", helvetica8));
|
|
|
1409 |
//orderTable.addCell(new Phrase(new Long(flipkartOrder.getFlipkartSubOrderId()).toString(), helvetica8));
|
| 8989 |
vikram.rag |
1410 |
}
|
|
|
1411 |
|
|
|
1412 |
|
| 7014 |
rajveer |
1413 |
orderTable.addCell(new Phrase("Order Date:", helvetica8));
|
|
|
1414 |
orderTable.addCell(new Phrase(DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(order.getCreated_timestamp())), helvetica8));
|
| 13276 |
manish.sha |
1415 |
|
|
|
1416 |
if(OrderType.B2B==order.getOrderType()){
|
|
|
1417 |
try {
|
|
|
1418 |
String poRefVal = tsc.getClient().getOrderAttributeValue(order.getId(), "poRefNumber");
|
|
|
1419 |
if(poRefVal!=null && poRefVal.length()>0){
|
|
|
1420 |
orderTable.addCell(new Phrase("PO Ref:", helvetica8));
|
|
|
1421 |
orderTable.addCell(new Phrase(poRefVal, helvetica8));
|
|
|
1422 |
}
|
|
|
1423 |
|
|
|
1424 |
} catch (TException e) {
|
|
|
1425 |
logger.error("Error while getting amazon order", e);
|
|
|
1426 |
}
|
|
|
1427 |
}
|
| 2787 |
chandransh |
1428 |
|
| 7014 |
rajveer |
1429 |
orderTable.addCell(new Phrase("Courier:", helvetica8));
|
| 13691 |
manish.sha |
1430 |
if(order.getSource() == OrderSource.HOMESHOP18.getValue()){
|
|
|
1431 |
orderTable.addCell(new Phrase(hsCourierName, helvetica8));
|
|
|
1432 |
} else{
|
|
|
1433 |
orderTable.addCell(new Phrase(provider.getName(), helvetica8));
|
|
|
1434 |
}
|
| 2787 |
chandransh |
1435 |
|
| 9038 |
amar.kumar |
1436 |
if(order.getAirwaybill_no()!=null && !order.getAirwaybill_no().isEmpty()) {
|
|
|
1437 |
orderTable.addCell(new Phrase("AWB No:", helvetica8));
|
|
|
1438 |
orderTable.addCell(new Phrase(order.getAirwaybill_no(), helvetica8));
|
|
|
1439 |
}
|
| 2787 |
chandransh |
1440 |
|
| 7014 |
rajveer |
1441 |
orderTable.addCell(new Phrase("AWB Date:", helvetica8));
|
|
|
1442 |
orderTable.addCell(new Phrase(DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(order.getBilling_timestamp())), helvetica8));
|
| 2787 |
chandransh |
1443 |
|
| 7014 |
rajveer |
1444 |
return orderTable;
|
|
|
1445 |
}
|
| 2787 |
chandransh |
1446 |
|
| 13276 |
manish.sha |
1447 |
private PdfPTable getBottomInvoiceTable(List<Order> orderList,boolean isVAT, String invoiceFormat){
|
|
|
1448 |
PdfPTable invoiceTable = new PdfPTable(new float[]{0.1f, 0.3f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f});
|
| 7014 |
rajveer |
1449 |
invoiceTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 2787 |
chandransh |
1450 |
|
| 13284 |
manish.sha |
1451 |
invoiceTable.addCell(getInvoiceTableHeader(8,orderList.get(0).getLogisticsTransactionId()));
|
| 4262 |
rajveer |
1452 |
|
| 13276 |
manish.sha |
1453 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
|
|
1454 |
invoiceTable.addCell(new Phrase("Sr No", helveticaBold8));
|
|
|
1455 |
}else{
|
|
|
1456 |
invoiceTable.addCell(new Phrase("Order No", helveticaBold8));
|
|
|
1457 |
}
|
| 7014 |
rajveer |
1458 |
invoiceTable.addCell(new Phrase("Description", helveticaBold8));
|
|
|
1459 |
invoiceTable.addCell(new Phrase("Quantity", helveticaBold8));
|
|
|
1460 |
invoiceTable.addCell(new Phrase("Rate (Rs)", helveticaBold8));
|
|
|
1461 |
invoiceTable.addCell(new Phrase("Amount (Rs)", helveticaBold8));
|
| 13276 |
manish.sha |
1462 |
invoiceTable.addCell(new Phrase("Tax Rate%", helveticaBold8));
|
|
|
1463 |
invoiceTable.addCell(new Phrase("Tax (Rs)", helveticaBold8));
|
|
|
1464 |
invoiceTable.addCell(new Phrase("Item Total (Rs)", helveticaBold8));;
|
|
|
1465 |
double totalAmount = 0.0;
|
|
|
1466 |
double insuranceAmount = 0.0;
|
| 17470 |
manish.sha |
1467 |
double totalShippingCost = 0.0;
|
| 13276 |
manish.sha |
1468 |
int i=1;
|
|
|
1469 |
if("Bulk".equalsIgnoreCase(invoiceFormat)){
|
|
|
1470 |
Map<Long, String> itemNamesMap= new HashMap<Long, String>();
|
|
|
1471 |
Map<Long, Double> itemQuantityMap = new HashMap<Long, Double>();
|
|
|
1472 |
Map<Long, Double> itemRateMap = new HashMap<Long, Double>();
|
|
|
1473 |
Map<Long, Double> itemTotalAmtMap = new HashMap<Long, Double>();
|
|
|
1474 |
Map<Long, Double> itemTaxPercentageMap = new HashMap<Long, Double>();
|
|
|
1475 |
Map<Long, Double> itemTaxValueMap = new HashMap<Long, Double>();
|
|
|
1476 |
|
|
|
1477 |
for(Order order : orderList){
|
|
|
1478 |
LineItem lineitem = order.getLineitems().get(0);
|
|
|
1479 |
|
|
|
1480 |
double orderAmount = order.getTotal_amount();
|
|
|
1481 |
double rate = lineitem.getVatRate();
|
|
|
1482 |
double salesTax = (rate * (orderAmount - order.getInsuranceAmount()))/(100 + rate);
|
|
|
1483 |
totalAmount = totalAmount + orderAmount;
|
| 17470 |
manish.sha |
1484 |
totalShippingCost = totalShippingCost + order.getShippingCost();
|
| 13276 |
manish.sha |
1485 |
double itemPrice = lineitem.getUnit_price();
|
|
|
1486 |
double showPrice = (100 * itemPrice)/(100 + rate);
|
|
|
1487 |
double totalPrice = lineitem.getTotal_price();
|
|
|
1488 |
double showTotalPrice = (100 * totalPrice)/(100 + rate);
|
|
|
1489 |
|
|
|
1490 |
if(order.getInsurer() > 0) {
|
|
|
1491 |
insuranceAmount =insuranceAmount + order.getInsuranceAmount();
|
|
|
1492 |
}
|
|
|
1493 |
|
|
|
1494 |
if(!itemNamesMap.containsKey(lineitem.getItem_id())){
|
|
|
1495 |
itemNamesMap.put(lineitem.getItem_id(), getItemDisplayName(lineitem, false));
|
|
|
1496 |
}
|
|
|
1497 |
if(itemQuantityMap.containsKey(lineitem.getItem_id())){
|
|
|
1498 |
double quantity = itemQuantityMap.get(lineitem.getItem_id()) + lineitem.getQuantity();
|
|
|
1499 |
itemQuantityMap.put(lineitem.getItem_id(), quantity);
|
|
|
1500 |
} else {
|
|
|
1501 |
itemQuantityMap.put(lineitem.getItem_id(),lineitem.getQuantity());
|
|
|
1502 |
}
|
|
|
1503 |
if(!itemRateMap.containsKey(lineitem.getItem_id())){
|
|
|
1504 |
itemRateMap.put(lineitem.getItem_id(), showPrice);
|
|
|
1505 |
}
|
|
|
1506 |
if(!itemTaxPercentageMap.containsKey(lineitem.getItem_id())){
|
|
|
1507 |
itemTaxPercentageMap.put(lineitem.getItem_id(), rate);
|
|
|
1508 |
}
|
|
|
1509 |
if(itemTaxValueMap.containsKey(lineitem.getItem_id())){
|
|
|
1510 |
double taxValue = itemTaxValueMap.get(lineitem.getItem_id()) + salesTax;
|
|
|
1511 |
itemTaxValueMap.put(lineitem.getItem_id(), taxValue);
|
|
|
1512 |
}else{
|
|
|
1513 |
itemTaxValueMap.put(lineitem.getItem_id(), salesTax);
|
|
|
1514 |
}
|
|
|
1515 |
if(itemTotalAmtMap.containsKey(lineitem.getItem_id())){
|
|
|
1516 |
double totalItemAmount = itemTotalAmtMap.get(lineitem.getItem_id()) + showTotalPrice;
|
|
|
1517 |
itemTotalAmtMap.put(lineitem.getItem_id(), totalItemAmount);
|
|
|
1518 |
}else{
|
|
|
1519 |
itemTotalAmtMap.put(lineitem.getItem_id(), showTotalPrice);
|
|
|
1520 |
}
|
|
|
1521 |
}
|
|
|
1522 |
|
|
|
1523 |
for(Long itemId : itemNamesMap.keySet()){
|
|
|
1524 |
invoiceTable.addCell(new Phrase(i+"", helveticaBold8));
|
|
|
1525 |
invoiceTable.addCell(new Phrase(itemNamesMap.get(itemId),helvetica8));
|
|
|
1526 |
invoiceTable.addCell(new Phrase(itemQuantityMap.get(itemId)+"",helvetica8));
|
| 13285 |
manish.sha |
1527 |
invoiceTable.addCell(getPriceCell(itemRateMap.get(itemId)));
|
|
|
1528 |
invoiceTable.addCell(getPriceCell(itemTotalAmtMap.get(itemId)));
|
|
|
1529 |
invoiceTable.addCell(new Phrase(itemTaxPercentageMap.get(itemId)+"%",helvetica8));
|
|
|
1530 |
invoiceTable.addCell(getPriceCell(itemTaxValueMap.get(itemId)));
|
|
|
1531 |
invoiceTable.addCell(getPriceCell(itemTotalAmtMap.get(itemId)+itemTaxValueMap.get(itemId)));
|
| 13313 |
manish.sha |
1532 |
i++;
|
| 13276 |
manish.sha |
1533 |
}
|
|
|
1534 |
}
|
|
|
1535 |
else{
|
| 9432 |
amar.kumar |
1536 |
|
| 13276 |
manish.sha |
1537 |
for(Order order :orderList){
|
|
|
1538 |
LineItem lineItem = order.getLineitems().get(0);
|
|
|
1539 |
double orderAmount = order.getTotal_amount();
|
|
|
1540 |
double rate = lineItem.getVatRate();
|
|
|
1541 |
double salesTax = (rate * (orderAmount - order.getInsuranceAmount()))/(100 + rate);
|
|
|
1542 |
|
|
|
1543 |
invoiceTable.addCell(new Phrase(order.getId()+"", helveticaBold8));
|
|
|
1544 |
invoiceTable.addCell(getProductNameCell(lineItem, true, order.getFreebieItemId()));
|
|
|
1545 |
invoiceTable.addCell(new Phrase("" + lineItem.getQuantity(), helvetica8));
|
|
|
1546 |
|
|
|
1547 |
|
|
|
1548 |
//populateBottomInvoiceTable(order, invoiceTable, rate);
|
|
|
1549 |
|
|
|
1550 |
double itemPrice = lineItem.getUnit_price();
|
|
|
1551 |
double showPrice = (100 * itemPrice)/(100 + rate);
|
|
|
1552 |
invoiceTable.addCell(getPriceCell(showPrice));
|
|
|
1553 |
|
|
|
1554 |
double totalPrice = lineItem.getTotal_price();
|
|
|
1555 |
showPrice = (100 * totalPrice)/(100 + rate);
|
|
|
1556 |
invoiceTable.addCell(getPriceCell(showPrice));
|
|
|
1557 |
|
|
|
1558 |
PdfPCell salesTaxCell = getPriceCell(salesTax);
|
|
|
1559 |
|
|
|
1560 |
|
|
|
1561 |
invoiceTable.addCell(new Phrase(rate + "%", helvetica8));
|
|
|
1562 |
invoiceTable.addCell(salesTaxCell);
|
|
|
1563 |
invoiceTable.addCell(getTotalAmountCell(orderAmount));
|
|
|
1564 |
|
|
|
1565 |
if(order.getInsurer() > 0) {
|
|
|
1566 |
insuranceAmount =insuranceAmount + order.getInsuranceAmount();
|
|
|
1567 |
}
|
|
|
1568 |
totalAmount = totalAmount+ orderAmount;
|
| 17470 |
manish.sha |
1569 |
totalShippingCost = totalShippingCost + order.getShippingCost();
|
| 13276 |
manish.sha |
1570 |
i++;
|
|
|
1571 |
}
|
| 9432 |
amar.kumar |
1572 |
}
|
| 7014 |
rajveer |
1573 |
|
| 13276 |
manish.sha |
1574 |
if(insuranceAmount>0){
|
|
|
1575 |
invoiceTable.addCell(getInsuranceCell(7));
|
|
|
1576 |
invoiceTable.addCell(getPriceCell(insuranceAmount));
|
| 7014 |
rajveer |
1577 |
}
|
| 17470 |
manish.sha |
1578 |
if(totalShippingCost>0){
|
| 17501 |
manish.sha |
1579 |
invoiceTable.addCell(getShippingCostCell(6));
|
|
|
1580 |
invoiceTable.addCell(getRupeesCell(false));
|
|
|
1581 |
invoiceTable.addCell(getPriceCell(totalShippingCost));
|
| 17470 |
manish.sha |
1582 |
}
|
| 13276 |
manish.sha |
1583 |
invoiceTable.addCell(getTotalCell(6));
|
| 17501 |
manish.sha |
1584 |
invoiceTable.addCell(getRupeesCell(true));
|
| 17470 |
manish.sha |
1585 |
invoiceTable.addCell(getTotalAmountCell(totalAmount+totalShippingCost));
|
| 7014 |
rajveer |
1586 |
|
| 13276 |
manish.sha |
1587 |
invoiceTable.addCell(new Phrase("Amount in Words:", helveticaBold8));
|
| 17470 |
manish.sha |
1588 |
invoiceTable.addCell(getAmountInWordsCell(totalAmount+totalShippingCost));
|
| 7014 |
rajveer |
1589 |
|
| 13276 |
manish.sha |
1590 |
invoiceTable.addCell(getEOECell(8));
|
| 7014 |
rajveer |
1591 |
|
|
|
1592 |
return invoiceTable;
|
|
|
1593 |
}
|
|
|
1594 |
|
| 13276 |
manish.sha |
1595 |
private PdfPCell getInvoiceTableHeader(int colspan, String masterOrderId) {
|
|
|
1596 |
PdfPTable invoiceHeaderTable = new PdfPTable(2);
|
|
|
1597 |
PdfPCell masterOrderIdCell = new PdfPCell(new Phrase("Master Order Id- "+masterOrderId, helvetica10));
|
| 13320 |
manish.sha |
1598 |
if(masterOrderId!=null && !masterOrderId.isEmpty()){
|
|
|
1599 |
masterOrderIdCell.setBorder(Rectangle.NO_BORDER);
|
|
|
1600 |
masterOrderIdCell.setPaddingTop(1);
|
|
|
1601 |
}
|
| 13281 |
manish.sha |
1602 |
PdfPCell invoiceTableHeader = new PdfPCell(new Phrase("Order Details:", helveticaBold12));
|
| 7014 |
rajveer |
1603 |
invoiceTableHeader.setBorder(Rectangle.NO_BORDER);
|
| 8551 |
manish.sha |
1604 |
invoiceTableHeader.setPaddingTop(1);
|
| 13276 |
manish.sha |
1605 |
invoiceHeaderTable.addCell(invoiceTableHeader);
|
| 13320 |
manish.sha |
1606 |
if(masterOrderId!=null && !masterOrderId.isEmpty()){
|
|
|
1607 |
invoiceHeaderTable.addCell(masterOrderIdCell);
|
|
|
1608 |
}else{
|
|
|
1609 |
masterOrderIdCell = new PdfPCell(new Phrase(" ", helvetica10));
|
|
|
1610 |
invoiceHeaderTable.addCell(masterOrderIdCell);
|
|
|
1611 |
}
|
| 13283 |
manish.sha |
1612 |
PdfPCell headerCell = new PdfPCell(invoiceHeaderTable);
|
|
|
1613 |
headerCell.setColspan(colspan);
|
|
|
1614 |
return headerCell;
|
| 7014 |
rajveer |
1615 |
}
|
|
|
1616 |
|
| 13276 |
manish.sha |
1617 |
/*private void populateBottomInvoiceTable(List<Order> orderList, PdfPTable invoiceTable) {
|
| 7014 |
rajveer |
1618 |
for (LineItem lineitem : order.getLineitems()) {
|
|
|
1619 |
invoiceTable.addCell(new Phrase("" + order.getId() , helvetica8));
|
|
|
1620 |
|
| 7190 |
amar.kumar |
1621 |
invoiceTable.addCell(getProductNameCell(lineitem, true, order.getFreebieItemId()));
|
| 7014 |
rajveer |
1622 |
|
|
|
1623 |
invoiceTable.addCell(new Phrase("" + lineitem.getQuantity(), helvetica8));
|
|
|
1624 |
|
|
|
1625 |
double itemPrice = lineitem.getUnit_price();
|
|
|
1626 |
double showPrice = (100 * itemPrice)/(100 + rate);
|
|
|
1627 |
invoiceTable.addCell(getPriceCell(showPrice)); //Unit Price Cell
|
|
|
1628 |
|
|
|
1629 |
double totalPrice = lineitem.getTotal_price();
|
|
|
1630 |
showPrice = (100 * totalPrice)/(100 + rate);
|
|
|
1631 |
invoiceTable.addCell(getPriceCell(showPrice)); //Total Price Cell
|
|
|
1632 |
}
|
| 13276 |
manish.sha |
1633 |
}*/
|
| 7014 |
rajveer |
1634 |
|
| 7190 |
amar.kumar |
1635 |
private PdfPCell getProductNameCell(LineItem lineitem, boolean appendIMEI, Long freebieItemId) {
|
| 7014 |
rajveer |
1636 |
String itemName = getItemDisplayName(lineitem, appendIMEI);
|
| 7190 |
amar.kumar |
1637 |
if(freebieItemId!=null && freebieItemId!=0){
|
|
|
1638 |
try {
|
|
|
1639 |
CatalogService.Client catalogClient = ctsc.getClient();
|
|
|
1640 |
Item item = catalogClient.getItem(freebieItemId);
|
|
|
1641 |
itemName = itemName + "\n(Free Item: " + item.getBrand() + " " + item.getModelName() + " " + item.getModelNumber() + ")";
|
|
|
1642 |
} catch(Exception tex) {
|
|
|
1643 |
logger.error("Not able to get Freebie Item Details for ItemId:" + freebieItemId, tex);
|
|
|
1644 |
}
|
|
|
1645 |
}
|
| 7014 |
rajveer |
1646 |
PdfPCell productNameCell = new PdfPCell(new Phrase(itemName, helvetica8));
|
|
|
1647 |
productNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
1648 |
return productNameCell;
|
|
|
1649 |
}
|
|
|
1650 |
|
|
|
1651 |
private PdfPCell getPriceCell(double price) {
|
|
|
1652 |
PdfPCell totalPriceCell = new PdfPCell(new Phrase(amountFormat.format(price), helvetica8));
|
|
|
1653 |
totalPriceCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
1654 |
return totalPriceCell;
|
|
|
1655 |
}
|
|
|
1656 |
|
|
|
1657 |
private PdfPCell getVATLabelCell(boolean isVAT) {
|
|
|
1658 |
PdfPCell vatCell = null;
|
|
|
1659 |
if(isVAT){
|
|
|
1660 |
vatCell = new PdfPCell(new Phrase("VAT", helveticaBold8));
|
|
|
1661 |
} else {
|
|
|
1662 |
vatCell = new PdfPCell(new Phrase("CST", helveticaBold8));
|
|
|
1663 |
}
|
|
|
1664 |
vatCell.setColspan(3);
|
|
|
1665 |
vatCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
1666 |
return vatCell;
|
|
|
1667 |
}
|
|
|
1668 |
|
| 9432 |
amar.kumar |
1669 |
private PdfPCell getCFORMLabelCell() {
|
|
|
1670 |
PdfPCell cFormCell = null;
|
|
|
1671 |
cFormCell = new PdfPCell(new Phrase("CST Against CForm", helveticaBold8));
|
|
|
1672 |
cFormCell.setColspan(3);
|
|
|
1673 |
cFormCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
1674 |
return cFormCell;
|
|
|
1675 |
}
|
|
|
1676 |
|
| 7318 |
rajveer |
1677 |
private PdfPCell getAdvanceAmountCell(int colspan) {
|
|
|
1678 |
PdfPCell insuranceCell = null;
|
|
|
1679 |
insuranceCell = new PdfPCell(new Phrase("Advance Amount Received", helvetica8));
|
|
|
1680 |
insuranceCell.setColspan(colspan);
|
|
|
1681 |
insuranceCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
1682 |
return insuranceCell;
|
|
|
1683 |
}
|
|
|
1684 |
|
| 7014 |
rajveer |
1685 |
private PdfPCell getInsuranceCell(int colspan) {
|
|
|
1686 |
PdfPCell insuranceCell = null;
|
| 13276 |
manish.sha |
1687 |
insuranceCell = new PdfPCell(new Phrase("1 Year WorldWide Theft Insurance. T&C Apply", helvetica8));
|
| 7014 |
rajveer |
1688 |
insuranceCell.setColspan(colspan);
|
|
|
1689 |
insuranceCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
1690 |
return insuranceCell;
|
|
|
1691 |
}
|
|
|
1692 |
|
|
|
1693 |
private PdfPCell getEmptyCell(int colspan) {
|
|
|
1694 |
PdfPCell emptyCell = new PdfPCell(new Phrase(" ", helvetica8));
|
|
|
1695 |
emptyCell.setColspan(colspan);
|
|
|
1696 |
return emptyCell;
|
|
|
1697 |
}
|
| 17470 |
manish.sha |
1698 |
|
|
|
1699 |
private PdfPCell getShippingCostCell(int colspan) {
|
|
|
1700 |
PdfPCell shippingCostCell = new PdfPCell(new Phrase("Shipping Charges", helvetica8));
|
|
|
1701 |
shippingCostCell.setColspan(colspan);
|
| 17501 |
manish.sha |
1702 |
shippingCostCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
| 17470 |
manish.sha |
1703 |
return shippingCostCell;
|
|
|
1704 |
}
|
|
|
1705 |
|
|
|
1706 |
private PdfPCell getCodChargesCell(int colspan) {
|
|
|
1707 |
PdfPCell codChargesCell = new PdfPCell(new Phrase("COD Charges", helvetica8));
|
|
|
1708 |
codChargesCell.setColspan(colspan);
|
|
|
1709 |
return codChargesCell;
|
|
|
1710 |
}
|
| 7014 |
rajveer |
1711 |
|
|
|
1712 |
private PdfPCell getTotalCell(int colspan) {
|
| 13276 |
manish.sha |
1713 |
PdfPCell totalCell = new PdfPCell(new Phrase("Grand Total", helveticaBold8));
|
| 7014 |
rajveer |
1714 |
totalCell.setColspan(colspan);
|
|
|
1715 |
totalCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
1716 |
return totalCell;
|
|
|
1717 |
}
|
|
|
1718 |
|
| 17501 |
manish.sha |
1719 |
private PdfPCell getRupeesCell(boolean useBold) {
|
|
|
1720 |
PdfPCell rupeesCell;
|
|
|
1721 |
if(useBold)
|
|
|
1722 |
rupeesCell= new PdfPCell(new Phrase("Rs.", helveticaBold8));
|
|
|
1723 |
else
|
|
|
1724 |
rupeesCell= new PdfPCell(new Phrase("Rs.", helvetica8));
|
| 7014 |
rajveer |
1725 |
rupeesCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
1726 |
return rupeesCell;
|
|
|
1727 |
}
|
|
|
1728 |
|
|
|
1729 |
private PdfPCell getTotalAmountCell(double orderAmount) {
|
|
|
1730 |
PdfPCell totalAmountCell = new PdfPCell(new Phrase(amountFormat.format(orderAmount), helveticaBold8));
|
|
|
1731 |
totalAmountCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
1732 |
return totalAmountCell;
|
|
|
1733 |
}
|
|
|
1734 |
|
|
|
1735 |
/**
|
|
|
1736 |
* This method uses ICU4J libraries to convert the given amount into words
|
|
|
1737 |
* of Indian locale.
|
|
|
1738 |
*
|
|
|
1739 |
* @param orderAmount
|
|
|
1740 |
* The amount to convert.
|
|
|
1741 |
* @return the string representation of the given amount.
|
|
|
1742 |
*/
|
|
|
1743 |
private PdfPCell getAmountInWordsCell(double orderAmount) {
|
|
|
1744 |
RuleBasedNumberFormat amountInWordsFormat = new RuleBasedNumberFormat(indianLocale, RuleBasedNumberFormat.SPELLOUT);
|
|
|
1745 |
StringBuilder amountInWords = new StringBuilder("Rs. ");
|
|
|
1746 |
amountInWords.append(WordUtils.capitalize(amountInWordsFormat.format((int)orderAmount)));
|
|
|
1747 |
amountInWords.append(" and ");
|
|
|
1748 |
amountInWords.append(WordUtils.capitalize(amountInWordsFormat.format((int)(orderAmount*100)%100)));
|
|
|
1749 |
amountInWords.append(" paise");
|
|
|
1750 |
|
|
|
1751 |
PdfPCell amountInWordsCell= new PdfPCell(new Phrase(amountInWords.toString(), helveticaBold8));
|
|
|
1752 |
amountInWordsCell.setColspan(4);
|
|
|
1753 |
return amountInWordsCell;
|
|
|
1754 |
}
|
|
|
1755 |
|
|
|
1756 |
/**
|
|
|
1757 |
* Returns the item name to be displayed in the invoice table.
|
|
|
1758 |
*
|
|
|
1759 |
* @param lineitem
|
|
|
1760 |
* The line item whose name has to be displayed
|
|
|
1761 |
* @param appendIMEI
|
|
|
1762 |
* Whether to attach the IMEI No. to the item name
|
|
|
1763 |
* @return The name to be displayed for the given line item.
|
|
|
1764 |
*/
|
|
|
1765 |
private String getItemDisplayName(LineItem lineitem, boolean appendIMEI){
|
|
|
1766 |
StringBuffer itemName = new StringBuffer();
|
|
|
1767 |
if(lineitem.getBrand()!= null)
|
|
|
1768 |
itemName.append(lineitem.getBrand() + " ");
|
|
|
1769 |
if(lineitem.getModel_name() != null)
|
|
|
1770 |
itemName.append(lineitem.getModel_name() + " ");
|
|
|
1771 |
if(lineitem.getModel_number() != null )
|
|
|
1772 |
itemName.append(lineitem.getModel_number() + " ");
|
|
|
1773 |
if(lineitem.getColor() != null && !lineitem.getColor().trim().equals("NA"))
|
|
|
1774 |
itemName.append("("+lineitem.getColor()+")");
|
| 13320 |
manish.sha |
1775 |
if(appendIMEI && lineitem.isSetSerial_number() && !lineitem.getSerial_number().isEmpty()){
|
| 7014 |
rajveer |
1776 |
itemName.append("\nIMEI No. " + lineitem.getSerial_number());
|
|
|
1777 |
}
|
|
|
1778 |
|
|
|
1779 |
return itemName.toString();
|
|
|
1780 |
}
|
|
|
1781 |
|
|
|
1782 |
/**
|
|
|
1783 |
*
|
|
|
1784 |
* @param colspan
|
|
|
1785 |
* @return a PdfPCell containing the E&OE text and spanning the given
|
|
|
1786 |
* no. of columns
|
|
|
1787 |
*/
|
|
|
1788 |
private PdfPCell getEOECell(int colspan) {
|
|
|
1789 |
PdfPCell eoeCell = new PdfPCell(new Phrase("E & O.E", helvetica8));
|
|
|
1790 |
eoeCell.setColspan(colspan);
|
|
|
1791 |
eoeCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
1792 |
return eoeCell;
|
|
|
1793 |
}
|
|
|
1794 |
|
|
|
1795 |
private PdfPTable getExtraInfoTable(Order order, Provider provider, float barcodeFontSize, BillingType billingType){
|
|
|
1796 |
PdfPTable extraInfoTable = new PdfPTable(1);
|
|
|
1797 |
extraInfoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
1798 |
extraInfoTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
1799 |
|
|
|
1800 |
String fontPath = InvoiceGenerationService.class.getResource("/saholic-wn.TTF").getPath();
|
|
|
1801 |
FontFactoryImp ttfFontFactory = new FontFactoryImp();
|
|
|
1802 |
ttfFontFactory.register(fontPath, "barcode");
|
|
|
1803 |
Font barCodeFont = ttfFontFactory.getFont("barcode", BaseFont.CP1252, true, barcodeFontSize);
|
|
|
1804 |
|
|
|
1805 |
PdfPCell extraInfoCell;
|
|
|
1806 |
if(billingType == BillingType.EXTERNAL){
|
|
|
1807 |
extraInfoCell = new PdfPCell(new Paragraph( "*" + order.getId() + "* *" + order.getCustomer_name() + "* *" + order.getTotal_amount() + "*", barCodeFont));
|
|
|
1808 |
}else{
|
|
|
1809 |
extraInfoCell = new PdfPCell(new Paragraph( "*" + order.getId() + "* *" + order.getLineitems().get(0).getTransfer_price() + "*", barCodeFont));
|
|
|
1810 |
}
|
|
|
1811 |
|
|
|
1812 |
extraInfoCell.setPaddingTop(20.0f);
|
|
|
1813 |
extraInfoCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
1814 |
extraInfoCell.setBorder(Rectangle.NO_BORDER);
|
|
|
1815 |
|
|
|
1816 |
extraInfoTable.addCell(extraInfoCell);
|
|
|
1817 |
|
|
|
1818 |
|
|
|
1819 |
return extraInfoTable;
|
|
|
1820 |
}
|
|
|
1821 |
|
|
|
1822 |
private PdfPTable getFixedTextTable(float barcodeFontSize, String printText){
|
|
|
1823 |
PdfPTable extraInfoTable = new PdfPTable(1);
|
|
|
1824 |
extraInfoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
1825 |
extraInfoTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
1826 |
|
|
|
1827 |
String fontPath = InvoiceGenerationService.class.getResource("/saholic-wn.TTF").getPath();
|
|
|
1828 |
FontFactoryImp ttfFontFactory = new FontFactoryImp();
|
|
|
1829 |
ttfFontFactory.register(fontPath, "barcode");
|
|
|
1830 |
Font barCodeFont = ttfFontFactory.getFont("barcode", BaseFont.CP1252, true, barcodeFontSize);
|
|
|
1831 |
|
|
|
1832 |
PdfPCell extraInfoCell = new PdfPCell(new Paragraph( "*" + printText + "*", barCodeFont));
|
|
|
1833 |
|
|
|
1834 |
extraInfoCell.setPaddingTop(20.0f);
|
|
|
1835 |
extraInfoCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
1836 |
extraInfoCell.setBorder(Rectangle.NO_BORDER);
|
|
|
1837 |
|
|
|
1838 |
extraInfoTable.addCell(extraInfoCell);
|
|
|
1839 |
|
|
|
1840 |
return extraInfoTable;
|
|
|
1841 |
}
|
| 8067 |
manish.sha |
1842 |
|
|
|
1843 |
private void generateBarcode(String barcodeString, String fileName){
|
|
|
1844 |
Code128Bean bean = new Code128Bean();
|
| 7014 |
rajveer |
1845 |
|
| 8067 |
manish.sha |
1846 |
final int dpi = 60;
|
|
|
1847 |
|
|
|
1848 |
//Configure the barcode generator
|
|
|
1849 |
bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); //makes the narrow bar
|
|
|
1850 |
//width exactly one pixel
|
|
|
1851 |
bean.setFontSize(bean.getFontSize()+1.0f);
|
|
|
1852 |
bean.doQuietZone(false);
|
|
|
1853 |
|
|
|
1854 |
try {
|
|
|
1855 |
File outputFile = new File("/tmp/"+fileName+".png");
|
|
|
1856 |
OutputStream out = new FileOutputStream(outputFile);
|
|
|
1857 |
|
|
|
1858 |
//Set up the canvas provider for monochrome PNG output
|
|
|
1859 |
BitmapCanvasProvider canvas = new BitmapCanvasProvider(
|
|
|
1860 |
out, "image/x-png", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);
|
|
|
1861 |
|
|
|
1862 |
//Generate the barcode
|
|
|
1863 |
bean.generateBarcode(canvas, barcodeString);
|
|
|
1864 |
|
|
|
1865 |
//Signal end of generation
|
|
|
1866 |
canvas.finish();
|
|
|
1867 |
out.close();
|
|
|
1868 |
|
|
|
1869 |
}
|
|
|
1870 |
catch(Exception e){
|
|
|
1871 |
logger.error("Exception during generating Barcode : ", e);
|
|
|
1872 |
}
|
|
|
1873 |
}
|
|
|
1874 |
|
| 7014 |
rajveer |
1875 |
public static void main(String[] args) throws IOException {
|
|
|
1876 |
InvoiceGenerationService invoiceGenerationService = new InvoiceGenerationService();
|
| 7318 |
rajveer |
1877 |
long orderId = 356324;
|
|
|
1878 |
ByteArrayOutputStream baos = invoiceGenerationService.generateInvoice(orderId, true, false, 1);
|
| 7014 |
rajveer |
1879 |
String userHome = System.getProperty("user.home");
|
|
|
1880 |
File f = new File(userHome + "/invoice-" + orderId + ".pdf");
|
|
|
1881 |
FileOutputStream fos = new FileOutputStream(f);
|
|
|
1882 |
baos.writeTo(fos);
|
|
|
1883 |
System.out.println("Invoice generated.");
|
|
|
1884 |
}
|
| 2787 |
chandransh |
1885 |
}
|