| 4687 |
mandeep.dh |
1 |
package in.shop2020.inventory.service;
|
|
|
2 |
|
| 14072 |
manish.sha |
3 |
import in.shop2020.inventory.controllers.PurchaseOrderController;
|
|
|
4 |
import in.shop2020.model.v1.catalog.CatalogServiceException;
|
|
|
5 |
import in.shop2020.model.v1.inventory.StateInfo;
|
|
|
6 |
import in.shop2020.model.v1.inventory.VatType;
|
|
|
7 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 4687 |
mandeep.dh |
8 |
import in.shop2020.purchase.PurchaseOrder;
|
|
|
9 |
import in.shop2020.purchase.Supplier;
|
| 9416 |
amar.kumar |
10 |
import in.shop2020.purchase.TaxType;
|
| 4687 |
mandeep.dh |
11 |
|
|
|
12 |
import java.io.ByteArrayOutputStream;
|
|
|
13 |
import java.io.File;
|
|
|
14 |
import java.io.FileOutputStream;
|
|
|
15 |
import java.io.IOException;
|
| 12863 |
manish.sha |
16 |
import java.math.BigDecimal;
|
| 4687 |
mandeep.dh |
17 |
import java.text.DateFormat;
|
|
|
18 |
import java.util.Date;
|
| 14072 |
manish.sha |
19 |
import java.util.Map;
|
| 4687 |
mandeep.dh |
20 |
|
| 14072 |
manish.sha |
21 |
import org.apache.thrift.TException;
|
|
|
22 |
import org.apache.thrift.transport.TTransportException;
|
| 4687 |
mandeep.dh |
23 |
import org.slf4j.Logger;
|
|
|
24 |
import org.slf4j.LoggerFactory;
|
|
|
25 |
|
|
|
26 |
import com.itextpdf.text.Document;
|
|
|
27 |
import com.itextpdf.text.Element;
|
|
|
28 |
import com.itextpdf.text.Font;
|
|
|
29 |
import com.itextpdf.text.Font.FontFamily;
|
|
|
30 |
import com.itextpdf.text.FontFactory;
|
|
|
31 |
import com.itextpdf.text.Paragraph;
|
|
|
32 |
import com.itextpdf.text.Phrase;
|
|
|
33 |
import com.itextpdf.text.Rectangle;
|
|
|
34 |
import com.itextpdf.text.pdf.PdfPCell;
|
|
|
35 |
import com.itextpdf.text.pdf.PdfPTable;
|
|
|
36 |
import com.itextpdf.text.pdf.PdfWriter;
|
| 14072 |
manish.sha |
37 |
import in.shop2020.purchase.PurchaseService.Client;
|
|
|
38 |
import in.shop2020.thrift.clients.CatalogClient;
|
|
|
39 |
import in.shop2020.thrift.clients.InventoryClient;
|
|
|
40 |
import in.shop2020.thrift.clients.PurchaseClient;
|
| 4687 |
mandeep.dh |
41 |
|
|
|
42 |
public class PdfPoSheetGenerator {
|
|
|
43 |
|
|
|
44 |
private static Logger logger = LoggerFactory
|
|
|
45 |
.getLogger(PdfPoSheetGenerator.class);
|
|
|
46 |
|
|
|
47 |
// private static final Properties properties = readProperties();
|
| 7410 |
amar.kumar |
48 |
private static final String ourAddressDelhi = "Spice Online Retail Pvt. Ltd.\nC/O,PIBCO LIMITED, Basement,Punjsons\n2,Kalkaji Industrial Area, New Delhi-110019\n";
|
| 7676 |
amar.kumar |
49 |
private static final String ourAddressBhiwandi = "Spice Online Retail Pvt. Ltd.\nC/O. FedEx Express Transportation and Supply Chain Services (India) Private Limited.\nC/O NDR WAREHOUSING, SURVEY NO.95, MUMBAI - NASIK HIGHWAY, WADAPE VILLAGE\nBHIWANDI (NR. SAI DHABA), Thane,Maharashtra -421302\n";
|
| 7410 |
amar.kumar |
50 |
private static final String ourAddressGoregaon = "Spice Online Retail Pvt. Ltd.\n93/743, Motilal Nagar-1, Goregaon(WEST),\nMotilal Nagar, Mumbai, Maharashtra-400062\n";
|
| 10877 |
manish.sha |
51 |
private static final String ourAddressBangalore = "Spice Online Retail Pvt. Ltd.\n C/O.Drive India Enterprise Solutions Limited)\n Survey No. 86, Korulur Village, Kasab Hobli\n Hoskote Taluka\n Bangalore – 560067, Karnataka\n";
|
|
|
52 |
private static final String ourAddressBangaloreSR = "Spice Online Retail Pvt. Ltd.\n Shop No. 320, Municipal 59th Cross,\n Next to Rammandir Ground,\n 3rd Block, Rajaji Nagar,\nBangalore - 560010, Karnataka\n";
|
| 12769 |
manish.sha |
53 |
private static final String ourAddressGurgaon = "Spice Online Retail Private Limited,\n SHOP NO. 10 & 11,\n OLD DELHI ROAD,OPP SECTOR-14, GURGAON-122001 Haryana\n";
|
|
|
54 |
private static final String ourAddressHyderabad = "Spice Online Retail Pvt. Ltd, Drive India Enterprise Solutions Limited, 16,17&18, Gundllapochampalli, Kompalli, Medchal Mandal, Secandrabad-500014, Dist- Hyderabad";
|
| 13051 |
manish.sha |
55 |
private static final String ourAddressGurgaonS = "Spice Online Retail Pvt Ltd. \nC/O.Drive India Enterprise Solutions Ltd, \nKhasra No.2771,Main Sheetla Mata Mandir Road \nOpposite Sec-5,Petrol Pump(Bharat Petroliam) \nNear Anmol Vatika, Gurgaon- 122001";
|
| 10877 |
manish.sha |
56 |
|
| 9925 |
amar.kumar |
57 |
private static final String amazonAddress = "Spice Online Retail Pvt. Ltd. C/O Amazon Seller Services Pvt. Ltd.,\nBuilding H Prathmesh Complex, Saravali Village,\nOpp Hotel Vatika Kalyan, Bhivandi Junction,\nBhiwandi, Maharashtra\n";
|
| 10877 |
manish.sha |
58 |
private static final String amazonAddreseBangalore = "Spice Online Retail Pvt. Ltd.\n C/O Amazon Seller Services Pvt. Ltd.\n 38 & 39, Soukya Road,\n kacherakanahalli,\n Hoskote Taluka,\n Bangalore -560067, Karnataka\n";
|
| 12752 |
manish.sha |
59 |
private static final String amazonAddressMewat = "Spice Online Retail Pvt. Ltd.\n C/O AMAZON Seller Services Pvt. Limited,\n Gokaldas Warehousing Corporation, Unit No 1,\n Village Taoru, Tehsil Taoru, Distt Mewat - 122105";
|
| 12543 |
manish.sha |
60 |
private static final String flipkartAddressGgn = "Spice Online Retail Pvt. Ltd.\n C/O. Flipkart Internet Pvt. Ltd, \n KILLA NO.219/15-16 25/1 220/11 12/1 12/2 13/1/113/1/2 20 21/1 21/2/1 22/1 23/1/1,\n Bohra Kalan, PATAUDI, GURGAON - 122001, Haryana\n";
|
| 13354 |
manish.sha |
61 |
private static final String flipkartAddressDelhi = "Spice Online Retail Pvt. Ltd.\n C/O Flipkart Internet Pvt. Ltd.\n Khasra No. 435,Road No.# 04 ,Lal Dora Extension,\nMahipalpur, New Delhi- 110037\n";
|
| 13938 |
manish.sha |
62 |
private static final String snapdealAddressDelhi = "Spice Online Retail Pvt. Ltd, \nC/O. Gati Kintetsu Express Pvt Ltd.,\nPlot In Khasra No. 15/17,24, G/F, \nVillage- Samalkha, New Delhi - 110037";
|
| 7410 |
amar.kumar |
63 |
private static final String tinNoDelhi = "07250399732";
|
|
|
64 |
private static final String tinNoMum = "27450984008";
|
| 10877 |
manish.sha |
65 |
private static final String tinNoBan = "29171183852";
|
| 12543 |
manish.sha |
66 |
private static final String tinNoFkGgn = "06681944625";
|
|
|
67 |
private static final String tinNoOurGgn = "06681944625";
|
| 12769 |
manish.sha |
68 |
private static final String tinNoOurHyd = "36601220768";
|
| 13354 |
manish.sha |
69 |
private static final String tinNoFkDelhi = "07720408834";
|
| 12543 |
manish.sha |
70 |
|
| 4687 |
mandeep.dh |
71 |
|
|
|
72 |
private static final Font helvetica8 = FontFactory.getFont(
|
|
|
73 |
FontFactory.HELVETICA, 8);
|
|
|
74 |
|
|
|
75 |
private static final Font helveticaBold8 = FontFactory.getFont(
|
|
|
76 |
FontFactory.HELVETICA_BOLD, 8);
|
|
|
77 |
private static final Font helveticaBold12 = FontFactory.getFont(
|
|
|
78 |
FontFactory.HELVETICA_BOLD, 12);
|
| 14072 |
manish.sha |
79 |
|
|
|
80 |
public static Map<Long, StateInfo> stateIdMap = null;
|
| 4687 |
mandeep.dh |
81 |
|
| 14072 |
manish.sha |
82 |
static{
|
|
|
83 |
try{
|
|
|
84 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
85 |
stateIdMap = inventoryClient.getStateMaster();
|
|
|
86 |
|
|
|
87 |
} catch(Exception e){
|
|
|
88 |
logger.error("Unable to get State Info Map", e);
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
|
| 4687 |
mandeep.dh |
92 |
public static String generatePdfSheet(PurchaseOrder purchaseOrder,
|
|
|
93 |
Supplier supplier) throws IOException {
|
|
|
94 |
ByteArrayOutputStream baosPDF = null;
|
|
|
95 |
try {
|
| 14072 |
manish.sha |
96 |
baosPDF = new ByteArrayOutputStream();
|
| 4687 |
mandeep.dh |
97 |
|
|
|
98 |
Document document = new Document();
|
|
|
99 |
PdfWriter.getInstance(document, baosPDF);
|
|
|
100 |
document.addAuthor("shop2020");
|
|
|
101 |
document.addTitle("Purchase Order No: "
|
|
|
102 |
+ purchaseOrder.getPoNumber());
|
|
|
103 |
document.open();
|
|
|
104 |
|
|
|
105 |
PdfPTable poTable = getPoTable(purchaseOrder, supplier);
|
|
|
106 |
poTable.setSpacingAfter(10.0f);
|
|
|
107 |
poTable.setWidthPercentage(90.0f);
|
|
|
108 |
|
|
|
109 |
document.add(poTable);
|
|
|
110 |
document.close();
|
|
|
111 |
baosPDF.close();
|
|
|
112 |
} catch (Exception e) {
|
|
|
113 |
logger.error("Error while generating Invoice: ", e);
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
String tmpDir = System.getProperty("java.io.tmpdir");
|
|
|
117 |
String filename = tmpDir + "/po-" + purchaseOrder.getId() + ".pdf";
|
|
|
118 |
File f = new File(filename);
|
|
|
119 |
FileOutputStream fos = new FileOutputStream(f);
|
|
|
120 |
baosPDF.writeTo(fos);
|
|
|
121 |
return filename;
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
private static PdfPTable getPoTable(PurchaseOrder purchaseOrder,
|
|
|
125 |
Supplier supplier) throws Exception {
|
|
|
126 |
PdfPTable poTable = new PdfPTable(1);
|
|
|
127 |
poTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
128 |
poTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
129 |
|
|
|
130 |
PdfPCell poTitleCell = new PdfPCell(new Phrase("Purchase Order",
|
|
|
131 |
helveticaBold12));
|
|
|
132 |
poTitleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
133 |
poTitleCell.setBorder(Rectangle.NO_BORDER);
|
|
|
134 |
|
|
|
135 |
Date poDate = new Date(purchaseOrder.getCreatedAt());
|
|
|
136 |
PdfPTable poSummaryTable = new PdfPTable(new float[] { 0.5f, 0.5f });
|
|
|
137 |
poSummaryTable.addCell(new PdfPCell(new Phrase("PO No: "
|
|
|
138 |
+ purchaseOrder.getPoNumber())));
|
| 9416 |
amar.kumar |
139 |
poSummaryTable.addCell(new PdfPCell(new Phrase("Date: "
|
|
|
140 |
+ DateFormat.getDateInstance(DateFormat.MEDIUM).format(
|
|
|
141 |
poDate))));
|
| 4687 |
mandeep.dh |
142 |
poSummaryTable.setSpacingBefore(10.0f);
|
|
|
143 |
|
|
|
144 |
poTable.addCell(poTitleCell);
|
| 9925 |
amar.kumar |
145 |
poTable.addCell(getAddressCell(purchaseOrder.getWarehouseId(), purchaseOrder.getShippingWarehouseId()));
|
| 4687 |
mandeep.dh |
146 |
poTable.addCell(poSummaryTable);
|
|
|
147 |
poTable.addCell(getSalutationTable(supplier));
|
| 14072 |
manish.sha |
148 |
poTable.addCell(getPoDetailsTable(purchaseOrder, supplier));
|
| 9591 |
amar.kumar |
149 |
poTable.addCell(getBillToTable(purchaseOrder.getWarehouseId(), purchaseOrder.getTaxType()));
|
|
|
150 |
//poTable.addCell(getCFormCell(purchaseOrder.getTaxType()));
|
| 4687 |
mandeep.dh |
151 |
|
|
|
152 |
return poTable;
|
|
|
153 |
}
|
|
|
154 |
|
| 9416 |
amar.kumar |
155 |
private static PdfPCell getCFormCell(TaxType taxType) {
|
|
|
156 |
PdfPCell cFormCell = null;
|
|
|
157 |
if(taxType == TaxType.CFORM) {
|
| 9586 |
amar.kumar |
158 |
cFormCell = new PdfPCell(new Paragraph("*To be billed on CST Against C-Form ", new Font(FontFamily.TIMES_ROMAN, 8f)));
|
| 9416 |
amar.kumar |
159 |
} else {
|
|
|
160 |
cFormCell = new PdfPCell();
|
|
|
161 |
}
|
|
|
162 |
cFormCell.setBorder(Rectangle.NO_BORDER);
|
|
|
163 |
cFormCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
164 |
return cFormCell;
|
|
|
165 |
}
|
|
|
166 |
|
| 9925 |
amar.kumar |
167 |
private static PdfPTable getAddressCell(long warehouseId, long shippingWarehouseId) {
|
| 7410 |
amar.kumar |
168 |
//TODO Write this code in a proper configurable way
|
|
|
169 |
String address = "";
|
|
|
170 |
String tinNo = "";
|
| 9925 |
amar.kumar |
171 |
String shippingAddress = "";
|
|
|
172 |
String shippingTinNo = "";
|
| 7410 |
amar.kumar |
173 |
if(warehouseId ==7) {
|
|
|
174 |
address = ourAddressDelhi;
|
|
|
175 |
tinNo = tinNoDelhi;
|
|
|
176 |
} else if(warehouseId == 12) {
|
|
|
177 |
address = ourAddressGoregaon;
|
|
|
178 |
tinNo = tinNoMum;
|
|
|
179 |
} else if(warehouseId == 13) {
|
|
|
180 |
address = ourAddressBhiwandi;
|
|
|
181 |
tinNo = tinNoMum;
|
| 7466 |
amar.kumar |
182 |
} else if(warehouseId ==16) {
|
| 7464 |
amar.kumar |
183 |
address = amazonAddress;
|
|
|
184 |
tinNo = tinNoMum;
|
| 10877 |
manish.sha |
185 |
} else if(warehouseId ==1765){
|
|
|
186 |
address = ourAddressBangalore;
|
|
|
187 |
tinNo = tinNoBan;
|
|
|
188 |
} else if(warehouseId ==1768){
|
|
|
189 |
address = ourAddressBangaloreSR;
|
|
|
190 |
tinNo = tinNoBan;
|
|
|
191 |
} else if(warehouseId ==1771){
|
|
|
192 |
address = amazonAddreseBangalore;
|
|
|
193 |
tinNo = tinNoBan;
|
| 12543 |
manish.sha |
194 |
} else if(warehouseId == 2854){
|
|
|
195 |
address = flipkartAddressGgn;
|
|
|
196 |
tinNo = tinNoFkGgn;
|
|
|
197 |
} else if(warehouseId == 2857){
|
|
|
198 |
address = ourAddressGurgaon;
|
|
|
199 |
tinNo = tinNoOurGgn;
|
| 12769 |
manish.sha |
200 |
} else if(warehouseId == 3295){
|
|
|
201 |
address = amazonAddressMewat;
|
|
|
202 |
tinNo = tinNoOurGgn;
|
| 13354 |
manish.sha |
203 |
} else if(warehouseId == 3298){
|
| 12769 |
manish.sha |
204 |
address = ourAddressHyderabad;
|
|
|
205 |
tinNo = tinNoOurHyd;
|
| 13051 |
manish.sha |
206 |
} else if(warehouseId == 3931){
|
|
|
207 |
address = ourAddressGurgaonS;
|
|
|
208 |
tinNo = tinNoOurGgn;
|
| 13354 |
manish.sha |
209 |
} else if(warehouseId == 4699){
|
|
|
210 |
address = flipkartAddressDelhi;
|
|
|
211 |
tinNo = tinNoFkDelhi;
|
| 13938 |
manish.sha |
212 |
} else if(warehouseId == 5314){
|
|
|
213 |
address = snapdealAddressDelhi;
|
|
|
214 |
tinNo = tinNoFkDelhi;
|
| 12769 |
manish.sha |
215 |
}
|
| 9925 |
amar.kumar |
216 |
PdfPTable billToShipToTable = new PdfPTable(2);
|
| 7410 |
amar.kumar |
217 |
Paragraph addressParagraph = new Paragraph(address + "\nTIN NO. "
|
| 4687 |
mandeep.dh |
218 |
+ tinNo, new Font(FontFamily.TIMES_ROMAN, 8f));
|
|
|
219 |
PdfPCell addressCell = new PdfPCell();
|
| 9925 |
amar.kumar |
220 |
if(warehouseId != shippingWarehouseId) {
|
|
|
221 |
addressParagraph = new Paragraph("Bill To :\n" + address + "\n\nTIN NO. "
|
|
|
222 |
+ tinNo, new Font(FontFamily.TIMES_ROMAN, 8f));
|
|
|
223 |
}
|
| 4687 |
mandeep.dh |
224 |
addressCell.addElement(addressParagraph);
|
| 9925 |
amar.kumar |
225 |
//addressCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
| 4687 |
mandeep.dh |
226 |
addressCell.setBorder(Rectangle.NO_BORDER);
|
| 9925 |
amar.kumar |
227 |
|
|
|
228 |
if(warehouseId != shippingWarehouseId) {
|
|
|
229 |
if(shippingWarehouseId ==7) {
|
|
|
230 |
shippingAddress = ourAddressDelhi;
|
|
|
231 |
shippingTinNo = tinNoDelhi;
|
|
|
232 |
} else if(shippingWarehouseId == 12) {
|
|
|
233 |
shippingAddress = ourAddressGoregaon;
|
|
|
234 |
shippingTinNo = tinNoMum;
|
|
|
235 |
} else if(shippingWarehouseId == 13) {
|
|
|
236 |
shippingAddress = ourAddressBhiwandi;
|
|
|
237 |
shippingTinNo = tinNoMum;
|
|
|
238 |
} else if(shippingWarehouseId ==16) {
|
|
|
239 |
shippingAddress = amazonAddress;
|
|
|
240 |
shippingTinNo = tinNoMum;
|
| 10877 |
manish.sha |
241 |
} else if(shippingWarehouseId ==1765){
|
|
|
242 |
shippingAddress = ourAddressBangalore;
|
|
|
243 |
shippingTinNo = tinNoBan;
|
|
|
244 |
} else if(shippingWarehouseId ==1768){
|
|
|
245 |
shippingAddress = ourAddressBangaloreSR;
|
|
|
246 |
shippingTinNo = tinNoBan;
|
|
|
247 |
} else if(shippingWarehouseId ==1771){
|
|
|
248 |
shippingAddress = amazonAddreseBangalore;
|
|
|
249 |
shippingTinNo = tinNoBan;
|
| 12543 |
manish.sha |
250 |
} else if(shippingWarehouseId == 2854){
|
|
|
251 |
shippingAddress = flipkartAddressGgn;
|
|
|
252 |
shippingTinNo = tinNoFkGgn;
|
|
|
253 |
} else if(shippingWarehouseId == 2857){
|
|
|
254 |
shippingAddress = ourAddressGurgaon;
|
|
|
255 |
shippingTinNo = tinNoOurGgn;
|
| 12729 |
manish.sha |
256 |
} else if(shippingWarehouseId == 3295){
|
|
|
257 |
shippingAddress = amazonAddressMewat;
|
|
|
258 |
shippingTinNo = tinNoOurGgn;
|
| 12769 |
manish.sha |
259 |
} else if(shippingWarehouseId == 3298){
|
|
|
260 |
shippingAddress = ourAddressHyderabad;
|
|
|
261 |
shippingTinNo = tinNoOurHyd;
|
| 13051 |
manish.sha |
262 |
} else if(shippingWarehouseId == 3931){
|
|
|
263 |
shippingAddress = ourAddressGurgaonS;
|
|
|
264 |
shippingTinNo = tinNoOurGgn;
|
| 13354 |
manish.sha |
265 |
} else if(shippingWarehouseId == 4699){
|
|
|
266 |
shippingAddress = flipkartAddressDelhi;
|
|
|
267 |
shippingTinNo = tinNoFkDelhi;
|
| 13938 |
manish.sha |
268 |
} else if(shippingWarehouseId == 5314){
|
|
|
269 |
shippingAddress = snapdealAddressDelhi;
|
|
|
270 |
shippingTinNo = tinNoFkDelhi;
|
| 9925 |
amar.kumar |
271 |
}
|
|
|
272 |
|
|
|
273 |
PdfPCell billToShipToCell = new PdfPCell();
|
|
|
274 |
billToShipToCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
275 |
billToShipToCell.setBorder(Rectangle.NO_BORDER);
|
|
|
276 |
|
|
|
277 |
PdfPCell shippingAddressCell = new PdfPCell();
|
|
|
278 |
shippingAddressCell.addElement(new Paragraph("Ship To :\n" +shippingAddress + "\nTIN NO. "
|
|
|
279 |
+ shippingTinNo, new Font(FontFamily.TIMES_ROMAN, 8f)));
|
|
|
280 |
shippingAddressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
281 |
shippingAddressCell.setBorder(Rectangle.LEFT);
|
|
|
282 |
billToShipToTable.addCell(addressCell);
|
|
|
283 |
billToShipToTable.addCell(shippingAddressCell);
|
|
|
284 |
billToShipToCell.addElement(billToShipToTable);
|
|
|
285 |
return billToShipToTable;
|
|
|
286 |
|
|
|
287 |
}
|
|
|
288 |
billToShipToTable.addCell(addressCell);
|
|
|
289 |
PdfPCell placeHolderCell = new PdfPCell();
|
|
|
290 |
placeHolderCell.setBorder(Rectangle.NO_BORDER);
|
|
|
291 |
billToShipToTable.addCell(placeHolderCell);
|
|
|
292 |
return billToShipToTable;
|
| 4687 |
mandeep.dh |
293 |
}
|
|
|
294 |
|
|
|
295 |
private static PdfPTable getSalutationTable(Supplier supplier)
|
|
|
296 |
throws Exception {
|
|
|
297 |
PdfPTable salutationTable = new PdfPTable(1);
|
|
|
298 |
salutationTable.getDefaultCell().setHorizontalAlignment(
|
|
|
299 |
Element.ALIGN_LEFT);
|
|
|
300 |
salutationTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
301 |
salutationTable.addCell(new Phrase("To", helvetica8));
|
| 8712 |
amar.kumar |
302 |
if(supplier.getName().equals("Smobility Ltd.")) {
|
|
|
303 |
salutationTable.addCell(new Phrase("Spice Retail Ltd.", helvetica8));
|
| 8713 |
amar.kumar |
304 |
} else if(supplier.getName().equals("Smobility Ltd. - Mumbai")) {
|
|
|
305 |
salutationTable.addCell(new Phrase("Spice Retail Ltd. Mumbai", helvetica8));
|
| 8712 |
amar.kumar |
306 |
} else {
|
|
|
307 |
salutationTable.addCell(new Phrase(supplier
|
|
|
308 |
.getName(), helvetica8));
|
|
|
309 |
}
|
|
|
310 |
|
| 4687 |
mandeep.dh |
311 |
salutationTable.addCell(new Paragraph(supplier
|
|
|
312 |
.getCommunicationAddress(), helvetica8));
|
|
|
313 |
salutationTable.addCell(new Phrase("Dear Sir/Madam", helveticaBold8));
|
|
|
314 |
salutationTable
|
|
|
315 |
.addCell(new Phrase(
|
|
|
316 |
"Please supply the following stocks as per the details given below:",
|
|
|
317 |
helvetica8));
|
|
|
318 |
salutationTable.addCell(new Phrase(" "));
|
|
|
319 |
return salutationTable;
|
|
|
320 |
}
|
|
|
321 |
|
| 14072 |
manish.sha |
322 |
private static PdfPTable getPoDetailsTable(PurchaseOrder purchaseOrder,Supplier supplier) throws CatalogServiceException, TException {
|
|
|
323 |
PdfPTable detailsTable = new PdfPTable(new float[] { 0.1f, 0.3f, 0.1f,
|
|
|
324 |
0.1f, 0.1f, 0.1f, 0.15f, 0.15f });
|
| 4687 |
mandeep.dh |
325 |
detailsTable.addCell(new Phrase("Sl. No.", helveticaBold8));
|
|
|
326 |
detailsTable.addCell(new Phrase("Description", helveticaBold8));
|
|
|
327 |
detailsTable.addCell(new Phrase("Quantity", helveticaBold8));
|
| 9591 |
amar.kumar |
328 |
detailsTable.addCell(new Phrase("Mrp", helveticaBold8));
|
| 14072 |
manish.sha |
329 |
if(purchaseOrder.getTaxType()==TaxType.CFORM){
|
|
|
330 |
detailsTable.addCell(new Phrase("CST Amount",helveticaBold8));
|
|
|
331 |
} else {
|
|
|
332 |
detailsTable.addCell(new Phrase("VAT Amount",helveticaBold8));
|
|
|
333 |
}
|
|
|
334 |
detailsTable.addCell(new Phrase("Rate Excl. (Rs)", helveticaBold8));
|
|
|
335 |
detailsTable.addCell(new Phrase("Rate Incl. (Rs)", helveticaBold8));
|
| 4687 |
mandeep.dh |
336 |
detailsTable.addCell(new Phrase("Amount (Rs)", helveticaBold8));
|
|
|
337 |
|
|
|
338 |
int slNo = 0;
|
|
|
339 |
double total = 0;
|
| 14072 |
manish.sha |
340 |
double vatFactor = 0;
|
|
|
341 |
double totalUnits = 0;
|
|
|
342 |
boolean isMRPVat = false;
|
|
|
343 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = new CatalogClient().getClient();
|
|
|
344 |
if(stateIdMap.get(supplier.getStateId()).getVatType().equals(VatType.MRP)) {
|
|
|
345 |
isMRPVat = true;
|
|
|
346 |
}
|
| 4687 |
mandeep.dh |
347 |
for (in.shop2020.purchase.LineItem lineitem : purchaseOrder
|
|
|
348 |
.getLineitems()) {
|
|
|
349 |
slNo++;
|
|
|
350 |
detailsTable.addCell(new Phrase(slNo + "", helvetica8));
|
|
|
351 |
detailsTable.addCell(getProductNameCell(lineitem));
|
|
|
352 |
detailsTable.addCell(new Phrase(lineitem.getQuantity() + "",
|
|
|
353 |
helvetica8));
|
| 9591 |
amar.kumar |
354 |
detailsTable.addCell(new Phrase(lineitem.getMrp() + "",
|
|
|
355 |
helvetica8));
|
| 14072 |
manish.sha |
356 |
if(purchaseOrder.getTaxType()==TaxType.CFORM){
|
|
|
357 |
vatFactor = 2.0;
|
|
|
358 |
} else {
|
|
|
359 |
if(isMRPVat){
|
|
|
360 |
vatFactor = catalogClient.getVatPercentageForItem(lineitem.getItemId(), supplier.getStateId(), lineitem.getMrp());
|
|
|
361 |
}else{
|
|
|
362 |
vatFactor = catalogClient.getVatPercentageForItem(lineitem.getItemId(), supplier.getStateId(), lineitem.getUnitPrice());
|
|
|
363 |
}
|
|
|
364 |
}
|
|
|
365 |
double taxAmount = (lineitem.getUnitPrice() * vatFactor)/100;
|
|
|
366 |
detailsTable.addCell(new Phrase(taxAmount + "",
|
|
|
367 |
helvetica8));
|
|
|
368 |
detailsTable.addCell(new Phrase((lineitem.getUnitPrice()-taxAmount) + "",
|
|
|
369 |
helvetica8));
|
| 4687 |
mandeep.dh |
370 |
detailsTable.addCell(new Phrase(lineitem.getUnitPrice() + "",
|
|
|
371 |
helvetica8));
|
|
|
372 |
double lineTotal = lineitem.getQuantity() * lineitem.getUnitPrice();
|
| 14072 |
manish.sha |
373 |
totalUnits += lineitem.getQuantity();
|
| 4687 |
mandeep.dh |
374 |
total += lineTotal;
|
|
|
375 |
detailsTable.addCell(new Phrase("" + lineTotal, helvetica8));
|
|
|
376 |
}
|
| 14072 |
manish.sha |
377 |
detailsTable.addCell(getTotalCell(2));
|
|
|
378 |
detailsTable.addCell(new Phrase(BigDecimal.valueOf(totalUnits).toPlainString(), helvetica8));
|
|
|
379 |
detailsTable.addCell(getTotalAmountCell(5,total));
|
| 4687 |
mandeep.dh |
380 |
return detailsTable;
|
|
|
381 |
}
|
|
|
382 |
|
| 9591 |
amar.kumar |
383 |
private static PdfPTable getBillToTable(long warehouseId, TaxType taxType) {
|
| 7410 |
amar.kumar |
384 |
//TODO Write this code in a proper configurable way
|
|
|
385 |
String address = "";
|
|
|
386 |
String tinNo = "";
|
|
|
387 |
String contactPerson = "";
|
|
|
388 |
if(warehouseId ==7) {
|
|
|
389 |
address = ourAddressDelhi;
|
|
|
390 |
tinNo = tinNoDelhi;
|
| 12729 |
manish.sha |
391 |
contactPerson = "Mr. Shiv Kumar, Contact No. +91 9953858076";
|
| 7410 |
amar.kumar |
392 |
} else if(warehouseId == 12) {
|
|
|
393 |
address = ourAddressGoregaon;
|
|
|
394 |
tinNo = tinNoMum;
|
| 7421 |
amar.kumar |
395 |
contactPerson = "Mr. Avinash Sambhaji Lavange, Contact No. +91 9004049589";
|
| 7410 |
amar.kumar |
396 |
} else if(warehouseId == 13) {
|
|
|
397 |
address = ourAddressBhiwandi;
|
|
|
398 |
tinNo = tinNoMum;
|
| 12729 |
manish.sha |
399 |
contactPerson = "Mr. Vishal Tayade, Contact No. +91 9819231651";
|
| 7466 |
amar.kumar |
400 |
} else if(warehouseId ==16) {
|
|
|
401 |
address = amazonAddress;
|
|
|
402 |
tinNo = tinNoMum;
|
|
|
403 |
contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
|
| 13354 |
manish.sha |
404 |
} else if(warehouseId ==1765) {
|
| 10877 |
manish.sha |
405 |
address = ourAddressBangalore;
|
|
|
406 |
tinNo = tinNoBan;
|
| 12729 |
manish.sha |
407 |
contactPerson = "Mr. Ravi Kumar, Contact No. +91 9686392567";
|
| 10877 |
manish.sha |
408 |
}
|
|
|
409 |
else if(warehouseId ==1768) {
|
|
|
410 |
address = ourAddressBangaloreSR;
|
|
|
411 |
tinNo = tinNoBan;
|
| 12729 |
manish.sha |
412 |
contactPerson = "Mr. Ravi Kumar, Contact No. +91 9686392567";
|
| 10877 |
manish.sha |
413 |
}
|
|
|
414 |
else if(warehouseId ==1771) {
|
|
|
415 |
address = amazonAddreseBangalore;
|
|
|
416 |
tinNo = tinNoBan;
|
| 12729 |
manish.sha |
417 |
contactPerson = "Mr. Ravi Kumar, Contact No. +91 9686392567";
|
| 10877 |
manish.sha |
418 |
}
|
| 12543 |
manish.sha |
419 |
else if(warehouseId ==2854) {
|
|
|
420 |
address = flipkartAddressGgn;
|
|
|
421 |
tinNo = tinNoFkGgn;
|
|
|
422 |
contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
|
|
|
423 |
}
|
|
|
424 |
else if(warehouseId ==2857) {
|
|
|
425 |
address = ourAddressGurgaon;
|
|
|
426 |
tinNo = tinNoOurGgn;
|
|
|
427 |
contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
|
| 12729 |
manish.sha |
428 |
}
|
|
|
429 |
else if(warehouseId == 3295) {
|
|
|
430 |
address = amazonAddressMewat;
|
|
|
431 |
tinNo = tinNoOurGgn;
|
|
|
432 |
contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
|
| 12543 |
manish.sha |
433 |
}
|
| 12769 |
manish.sha |
434 |
else if(warehouseId == 3298) {
|
|
|
435 |
address = ourAddressHyderabad;
|
|
|
436 |
tinNo = tinNoOurHyd;
|
|
|
437 |
contactPerson = "Mr. Achyuta Ramaiah A, Contact No. +91 9246581582";
|
|
|
438 |
}
|
| 13051 |
manish.sha |
439 |
else if(warehouseId == 3931) {
|
|
|
440 |
address = ourAddressGurgaonS;
|
|
|
441 |
tinNo = tinNoOurGgn;
|
|
|
442 |
contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
|
|
|
443 |
}
|
| 13354 |
manish.sha |
444 |
else if(warehouseId == 4699) {
|
|
|
445 |
address = flipkartAddressDelhi;
|
|
|
446 |
tinNo = tinNoFkDelhi;
|
|
|
447 |
contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
|
|
|
448 |
}
|
| 13938 |
manish.sha |
449 |
else if(warehouseId == 5314){
|
|
|
450 |
address = snapdealAddressDelhi;
|
|
|
451 |
tinNo = tinNoFkDelhi;
|
|
|
452 |
contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
|
|
|
453 |
}
|
| 7410 |
amar.kumar |
454 |
|
| 4687 |
mandeep.dh |
455 |
PdfPTable billToTable = new PdfPTable(new float[] { 0.2f, 0.8f });
|
|
|
456 |
billToTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
457 |
|
| 9925 |
amar.kumar |
458 |
billToTable.addCell(new Phrase("Bill To :", helvetica8));
|
| 7410 |
amar.kumar |
459 |
billToTable.addCell(new PdfPCell(new Paragraph(address
|
| 4687 |
mandeep.dh |
460 |
+ "\nTIN NO. " + tinNo, helvetica8)));
|
|
|
461 |
|
|
|
462 |
billToTable.addCell(new Phrase("Contact Person:", helvetica8));
|
| 7410 |
amar.kumar |
463 |
billToTable.addCell(new Phrase(contactPerson, helvetica8));
|
| 4687 |
mandeep.dh |
464 |
|
|
|
465 |
billToTable.addCell(new Phrase("Taxes:", helvetica8));
|
| 9591 |
amar.kumar |
466 |
if(taxType == TaxType.CFORM) {
|
|
|
467 |
billToTable.addCell(new Phrase("Prices inclusive of all taxes (To be billed on CST Against C-Form)",
|
|
|
468 |
helvetica8));
|
|
|
469 |
} else {
|
|
|
470 |
billToTable.addCell(new Phrase("Prices inclusive of all taxes",
|
|
|
471 |
helvetica8));
|
|
|
472 |
}
|
| 4687 |
mandeep.dh |
473 |
|
|
|
474 |
return billToTable;
|
|
|
475 |
}
|
|
|
476 |
|
|
|
477 |
private static PdfPCell getProductNameCell(
|
|
|
478 |
in.shop2020.purchase.LineItem lineitem) {
|
|
|
479 |
String itemName = getItemDisplayName(lineitem);
|
|
|
480 |
PdfPCell productNameCell = new PdfPCell(
|
|
|
481 |
new Phrase(itemName, helvetica8));
|
|
|
482 |
productNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
483 |
return productNameCell;
|
|
|
484 |
}
|
|
|
485 |
|
|
|
486 |
private static String getItemDisplayName(
|
|
|
487 |
in.shop2020.purchase.LineItem lineitem) {
|
|
|
488 |
StringBuffer itemName = new StringBuffer();
|
|
|
489 |
if (lineitem.getBrand() != null)
|
|
|
490 |
itemName.append(lineitem.getBrand() + " ");
|
|
|
491 |
if (lineitem.getModelName() != null)
|
|
|
492 |
itemName.append(lineitem.getModelName() + " ");
|
|
|
493 |
if (lineitem.getModelNumber() != null)
|
|
|
494 |
itemName.append(lineitem.getModelNumber() + " ");
|
|
|
495 |
if (lineitem.getColor() != null
|
|
|
496 |
&& !lineitem.getColor().trim().equals("NA"))
|
|
|
497 |
itemName.append("(" + lineitem.getColor() + ")");
|
|
|
498 |
|
|
|
499 |
return itemName.toString();
|
|
|
500 |
}
|
|
|
501 |
|
|
|
502 |
private static PdfPCell getTotalCell(int colspan) {
|
|
|
503 |
PdfPCell totalCell = new PdfPCell(new Phrase("Total", helveticaBold8));
|
|
|
504 |
totalCell.setColspan(colspan);
|
|
|
505 |
totalCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
506 |
return totalCell;
|
|
|
507 |
}
|
| 14072 |
manish.sha |
508 |
|
|
|
509 |
private static PdfPCell getTotalAmountCell(int colspan, double totalAmount){
|
|
|
510 |
PdfPCell totalCell = new PdfPCell(new Phrase(BigDecimal.valueOf(totalAmount).toPlainString(), helvetica8));
|
|
|
511 |
totalCell.setColspan(colspan);
|
| 14073 |
manish.sha |
512 |
totalCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
| 14072 |
manish.sha |
513 |
return totalCell;
|
|
|
514 |
}
|
| 4687 |
mandeep.dh |
515 |
|
|
|
516 |
}
|