| Line 1... |
Line 1... |
| 1 |
package in.shop2020.inventory.service;
|
1 |
package in.shop2020.inventory.service;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.model.v1.catalog.CatalogServiceException;
|
- |
|
| 4 |
import in.shop2020.model.v1.inventory.StateInfo;
|
- |
|
| 5 |
import in.shop2020.model.v1.inventory.VatType;
|
- |
|
| 6 |
import in.shop2020.purchase.PurchaseOrder;
|
- |
|
| 7 |
import in.shop2020.purchase.Supplier;
|
- |
|
| 8 |
import in.shop2020.purchase.TaxType;
|
- |
|
| 9 |
|
- |
|
| 10 |
import java.io.ByteArrayOutputStream;
|
3 |
import java.io.ByteArrayOutputStream;
|
| 11 |
import java.io.File;
|
4 |
import java.io.File;
|
| 12 |
import java.io.FileOutputStream;
|
5 |
import java.io.FileOutputStream;
|
| 13 |
import java.io.IOException;
|
6 |
import java.io.IOException;
|
| 14 |
import java.math.BigDecimal;
|
- |
|
| 15 |
import java.text.DateFormat;
|
7 |
import java.text.DateFormat;
|
| - |
|
8 |
import java.text.ParseException;
|
| - |
|
9 |
import java.text.SimpleDateFormat;
|
| 16 |
import java.util.Calendar;
|
10 |
import java.util.Calendar;
|
| 17 |
import java.util.Date;
|
11 |
import java.util.Date;
|
| 18 |
import java.util.Map;
|
12 |
import java.util.Map;
|
| 19 |
|
13 |
|
| - |
|
14 |
import org.apache.log4j.helpers.DateTimeDateFormat;
|
| 20 |
import org.apache.thrift.TException;
|
15 |
import org.apache.thrift.TException;
|
| 21 |
import org.apache.thrift.transport.TTransportException;
|
- |
|
| 22 |
import org.slf4j.Logger;
|
16 |
import org.slf4j.Logger;
|
| 23 |
import org.slf4j.LoggerFactory;
|
17 |
import org.slf4j.LoggerFactory;
|
| 24 |
|
18 |
|
| 25 |
import com.itextpdf.text.Document;
|
19 |
import com.itextpdf.text.Document;
|
| 26 |
import com.itextpdf.text.Element;
|
20 |
import com.itextpdf.text.Element;
|
| Line 31... |
Line 25... |
| 31 |
import com.itextpdf.text.Phrase;
|
25 |
import com.itextpdf.text.Phrase;
|
| 32 |
import com.itextpdf.text.Rectangle;
|
26 |
import com.itextpdf.text.Rectangle;
|
| 33 |
import com.itextpdf.text.pdf.PdfPCell;
|
27 |
import com.itextpdf.text.pdf.PdfPCell;
|
| 34 |
import com.itextpdf.text.pdf.PdfPTable;
|
28 |
import com.itextpdf.text.pdf.PdfPTable;
|
| 35 |
import com.itextpdf.text.pdf.PdfWriter;
|
29 |
import com.itextpdf.text.pdf.PdfWriter;
|
| - |
|
30 |
|
| - |
|
31 |
import in.shop2020.model.v1.catalog.CatalogServiceException;
|
| - |
|
32 |
import in.shop2020.model.v1.inventory.StateInfo;
|
| - |
|
33 |
import in.shop2020.model.v1.inventory.VatType;
|
| - |
|
34 |
import in.shop2020.purchase.PurchaseOrder;
|
| - |
|
35 |
import in.shop2020.purchase.Supplier;
|
| - |
|
36 |
import in.shop2020.purchase.TaxType;
|
| 36 |
import in.shop2020.thrift.clients.CatalogClient;
|
37 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 37 |
import in.shop2020.thrift.clients.InventoryClient;
|
38 |
import in.shop2020.thrift.clients.InventoryClient;
|
| - |
|
39 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 38 |
|
40 |
|
| 39 |
public class PdfPoSheetGenerator {
|
41 |
public class PdfPoSheetGenerator {
|
| 40 |
|
42 |
|
| 41 |
private static Logger logger = LoggerFactory
|
43 |
private static Logger logger = LoggerFactory
|
| 42 |
.getLogger(PdfPoSheetGenerator.class);
|
44 |
.getLogger(PdfPoSheetGenerator.class);
|
| 43 |
|
45 |
|
| 44 |
// private static final Properties properties = readProperties();
|
46 |
// private static final Properties properties = readProperties();
|
| 45 |
private static final String ourAddressDelhi = "Spice Online Retail Pvt. Ltd.\nC/O,PIBCO LIMITED, Basement,Punjsons\n2,Kalkaji Industrial Area, New Delhi-110019\n";
|
47 |
private static final String ourAddressDelhi = "Spice Online Retail Pvt. Ltd.\nC/O,PIBCO LIMITED, Basement,Punjsons\n2,Kalkaji Industrial Area, New Delhi-110019\n";
|
| - |
|
48 |
private static final String ourNewCompanyAddressDelhi = "New Spice Online Retail Pvt. Ltd.\nC/O,PIBCO LIMITED, Basement,Punjsons\n2,Kalkaji Industrial Area, New Delhi-110019\n";
|
| 46 |
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";
|
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";
|
| 47 |
private static final String ourAddressGoregaon = "Spice Online Retail Pvt. Ltd.\n93/743, Motilal Nagar-1, Goregaon(WEST),\nMotilal Nagar, Mumbai, Maharashtra-400062\n";
|
50 |
private static final String ourAddressGoregaon = "Spice Online Retail Pvt. Ltd.\n93/743, Motilal Nagar-1, Goregaon(WEST),\nMotilal Nagar, Mumbai, Maharashtra-400062\n";
|
| 48 |
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";
|
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";
|
| 49 |
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";
|
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";
|
| 50 |
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";
|
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";
|
| Line 57... |
Line 60... |
| 57 |
private static final String amazonAddressDelhi = "Spice Online Retail Pvt Ltd., \nC/O Amazon Seller Services Pvt. Ltd., \nA43 GF MOHAN COOPERATIVE IND, \nESTATE MAIN MATHURA ROAD, \nBADARPUR SOUTH DELHI, Delhi -110044";
|
60 |
private static final String amazonAddressDelhi = "Spice Online Retail Pvt Ltd., \nC/O Amazon Seller Services Pvt. Ltd., \nA43 GF MOHAN COOPERATIVE IND, \nESTATE MAIN MATHURA ROAD, \nBADARPUR SOUTH DELHI, Delhi -110044";
|
| 58 |
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";
|
61 |
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";
|
| 59 |
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";
|
62 |
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";
|
| 60 |
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";
|
63 |
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";
|
| 61 |
private static final String tinNoDelhi = "07250399732";
|
64 |
private static final String tinNoDelhi = "07250399732";
|
| - |
|
65 |
private static final String newCompanyTinNoDelhi = "07250399733";
|
| 62 |
private static final String tinNoMum = "27450984008";
|
66 |
private static final String tinNoMum = "27450984008";
|
| 63 |
private static final String tinNoBan = "29171183852";
|
67 |
private static final String tinNoBan = "29171183852";
|
| 64 |
private static final String tinNoFkGgn = "06681944625";
|
68 |
private static final String tinNoFkGgn = "06681944625";
|
| 65 |
private static final String tinNoOurGgn = "06681944625";
|
69 |
private static final String tinNoOurGgn = "06681944625";
|
| 66 |
private static final String tinNoOurHyd = "36601220768";
|
70 |
private static final String tinNoOurHyd = "36601220768";
|
| Line 74... |
Line 78... |
| 74 |
FontFactory.HELVETICA_BOLD, 8);
|
78 |
FontFactory.HELVETICA_BOLD, 8);
|
| 75 |
private static final Font helveticaBold12 = FontFactory.getFont(
|
79 |
private static final Font helveticaBold12 = FontFactory.getFont(
|
| 76 |
FontFactory.HELVETICA_BOLD, 12);
|
80 |
FontFactory.HELVETICA_BOLD, 12);
|
| 77 |
|
81 |
|
| 78 |
public static Map<Long, StateInfo> stateIdMap = null;
|
82 |
public static Map<Long, StateInfo> stateIdMap = null;
|
| - |
|
83 |
public static long cutoffTime = 0;
|
| 79 |
|
84 |
|
| 80 |
static{
|
85 |
static{
|
| 81 |
try{
|
86 |
try{
|
| 82 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
87 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
| 83 |
stateIdMap = inventoryClient.getStateMaster();
|
88 |
stateIdMap = inventoryClient.getStateMaster();
|
| - |
|
89 |
String cutOffDate = ConfigClient.getClient().get("warehouse_company_cutoff_date");
|
| - |
|
90 |
DateFormat df = new SimpleDateFormat("yyyy-mm-dd");
|
| - |
|
91 |
cutoffTime = df.parse(cutOffDate).getTime();
|
| 84 |
|
92 |
|
| 85 |
} catch(Exception e){
|
93 |
} catch(Exception e){
|
| 86 |
logger.error("Unable to get State Info Map", e);
|
94 |
logger.error("Could not initialize static block", e);
|
| - |
|
95 |
System.exit(0);
|
| 87 |
}
|
96 |
}
|
| 88 |
}
|
97 |
}
|
| 89 |
|
98 |
|
| 90 |
public static String generatePdfSheet(PurchaseOrder purchaseOrder,
|
99 |
public static String generatePdfSheet(PurchaseOrder purchaseOrder,
|
| 91 |
Supplier supplier) throws IOException {
|
100 |
Supplier supplier) throws IOException {
|
| Line 149... |
Line 158... |
| 149 |
+ DateFormat.getDateInstance(DateFormat.MEDIUM).format(
|
158 |
+ DateFormat.getDateInstance(DateFormat.MEDIUM).format(
|
| 150 |
poExpiryDate))));
|
159 |
poExpiryDate))));
|
| 151 |
poSummaryTable.setSpacingBefore(10.0f);
|
160 |
poSummaryTable.setSpacingBefore(10.0f);
|
| 152 |
|
161 |
|
| 153 |
poTable.addCell(poTitleCell);
|
162 |
poTable.addCell(poTitleCell);
|
| 154 |
poTable.addCell(getAddressCell(purchaseOrder.getWarehouseId(), purchaseOrder.getShippingWarehouseId()));
|
163 |
poTable.addCell(getAddressCell(purchaseOrder.getWarehouseId(), purchaseOrder.getShippingWarehouseId(), purchaseOrder.getCreatedAt()));
|
| 155 |
poTable.addCell(poSummaryTable);
|
164 |
poTable.addCell(poSummaryTable);
|
| 156 |
poTable.addCell(getSalutationTable(supplier));
|
165 |
poTable.addCell(getSalutationTable(supplier));
|
| 157 |
poTable.addCell(getPoDetailsTable(purchaseOrder, supplier));
|
166 |
poTable.addCell(getPoDetailsTable(purchaseOrder, supplier));
|
| 158 |
poTable.addCell(getBillToTable(purchaseOrder.getWarehouseId(), purchaseOrder.getTaxType()));
|
167 |
poTable.addCell(getBillToTable(purchaseOrder.getWarehouseId(), purchaseOrder.getTaxType()));
|
| 159 |
//poTable.addCell(getCFormCell(purchaseOrder.getTaxType()));
|
168 |
//poTable.addCell(getCFormCell(purchaseOrder.getTaxType()));
|
| Line 171... |
Line 180... |
| 171 |
cFormCell.setBorder(Rectangle.NO_BORDER);
|
180 |
cFormCell.setBorder(Rectangle.NO_BORDER);
|
| 172 |
cFormCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
181 |
cFormCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
| 173 |
return cFormCell;
|
182 |
return cFormCell;
|
| 174 |
}
|
183 |
}
|
| 175 |
|
184 |
|
| 176 |
private static PdfPTable getAddressCell(long warehouseId, long shippingWarehouseId) {
|
185 |
private static PdfPTable getAddressCell(long warehouseId, long shippingWarehouseId, long createdAt) {
|
| 177 |
//TODO Write this code in a proper configurable way
|
186 |
//TODO Write this code in a proper configurable way
|
| 178 |
String address = "";
|
187 |
String address = "";
|
| 179 |
String tinNo = "";
|
188 |
String tinNo = "";
|
| 180 |
String shippingAddress = "";
|
189 |
String shippingAddress = "";
|
| 181 |
String shippingTinNo = "";
|
190 |
String shippingTinNo = "";
|
| 182 |
if(warehouseId ==7) {
|
191 |
if(warehouseId ==7) {
|
| - |
|
192 |
if(createdAt < cutoffTime) {
|
| 183 |
address = ourAddressDelhi;
|
193 |
address = ourAddressDelhi;
|
| 184 |
tinNo = tinNoDelhi;
|
194 |
tinNo = tinNoDelhi;
|
| - |
|
195 |
} else {
|
| - |
|
196 |
address = ourNewCompanyAddressDelhi;
|
| - |
|
197 |
tinNo = newCompanyTinNoDelhi;
|
| - |
|
198 |
}
|
| 185 |
} else if(warehouseId == 12) {
|
199 |
} else if(warehouseId == 12) {
|
| 186 |
address = ourAddressGoregaon;
|
200 |
address = ourAddressGoregaon;
|
| 187 |
tinNo = tinNoMum;
|
201 |
tinNo = tinNoMum;
|
| 188 |
} else if(warehouseId == 13) {
|
202 |
} else if(warehouseId == 13) {
|
| 189 |
address = ourAddressBhiwandi;
|
203 |
address = ourAddressBhiwandi;
|