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