| Line 1... |
Line 1... |
| 1 |
package in.shop2020.support.services;
|
1 |
package in.shop2020.support.services;
|
| 2 |
|
2 |
|
| - |
|
3 |
import in.shop2020.purchase.PurchaseOrder;
|
| - |
|
4 |
import in.shop2020.purchase.Supplier;
|
| - |
|
5 |
|
| 3 |
import java.io.ByteArrayOutputStream;
|
6 |
import java.io.ByteArrayOutputStream;
|
| 4 |
import java.io.File;
|
7 |
import java.io.File;
|
| 5 |
import java.io.FileOutputStream;
|
8 |
import java.io.FileOutputStream;
|
| 6 |
import java.io.IOException;
|
9 |
import java.io.IOException;
|
| 7 |
import java.text.DateFormat;
|
10 |
import java.text.DateFormat;
|
| 8 |
import java.util.Date;
|
11 |
import java.util.Date;
|
| 9 |
import java.util.Enumeration;
|
- |
|
| 10 |
import java.util.Properties;
|
- |
|
| 11 |
import java.util.ResourceBundle;
|
- |
|
| 12 |
|
12 |
|
| 13 |
import org.slf4j.Logger;
|
13 |
import org.slf4j.Logger;
|
| 14 |
import org.slf4j.LoggerFactory;
|
14 |
import org.slf4j.LoggerFactory;
|
| 15 |
|
15 |
|
| 16 |
import com.itextpdf.text.Document;
|
16 |
import com.itextpdf.text.Document;
|
| 17 |
import com.itextpdf.text.Element;
|
17 |
import com.itextpdf.text.Element;
|
| 18 |
import com.itextpdf.text.Font;
|
18 |
import com.itextpdf.text.Font;
|
| - |
|
19 |
import com.itextpdf.text.Font.FontFamily;
|
| 19 |
import com.itextpdf.text.FontFactory;
|
20 |
import com.itextpdf.text.FontFactory;
|
| 20 |
import com.itextpdf.text.Paragraph;
|
21 |
import com.itextpdf.text.Paragraph;
|
| 21 |
import com.itextpdf.text.Phrase;
|
22 |
import com.itextpdf.text.Phrase;
|
| 22 |
import com.itextpdf.text.Rectangle;
|
23 |
import com.itextpdf.text.Rectangle;
|
| 23 |
import com.itextpdf.text.Font.FontFamily;
|
- |
|
| 24 |
import com.itextpdf.text.pdf.PdfPCell;
|
24 |
import com.itextpdf.text.pdf.PdfPCell;
|
| 25 |
import com.itextpdf.text.pdf.PdfPTable;
|
25 |
import com.itextpdf.text.pdf.PdfPTable;
|
| 26 |
import com.itextpdf.text.pdf.PdfWriter;
|
26 |
import com.itextpdf.text.pdf.PdfWriter;
|
| 27 |
|
27 |
|
| 28 |
import in.shop2020.thrift.clients.WarehouseClient;
|
- |
|
| 29 |
import in.shop2020.warehouse.LineItem;
|
- |
|
| 30 |
import in.shop2020.warehouse.PurchaseOrder;
|
- |
|
| 31 |
import in.shop2020.warehouse.Supplier;
|
- |
|
| 32 |
import in.shop2020.warehouse.WarehouseService.Client;
|
- |
|
| 33 |
|
- |
|
| 34 |
public class PdfPoSheetGenerator {
|
28 |
public class PdfPoSheetGenerator {
|
| 35 |
|
29 |
|
| 36 |
private static Logger logger = LoggerFactory.getLogger(PdfPoSheetGenerator.class);
|
30 |
private static Logger logger = LoggerFactory.getLogger(PdfPoSheetGenerator.class);
|
| 37 |
|
31 |
|
| 38 |
//private static final Properties properties = readProperties();
|
32 |
//private static final Properties properties = readProperties();
|
| Line 128... |
Line 122... |
| 128 |
detailsTable.addCell(new Phrase("Rate (Rs)", helveticaBold8));
|
122 |
detailsTable.addCell(new Phrase("Rate (Rs)", helveticaBold8));
|
| 129 |
detailsTable.addCell(new Phrase("Amount (Rs)", helveticaBold8));
|
123 |
detailsTable.addCell(new Phrase("Amount (Rs)", helveticaBold8));
|
| 130 |
|
124 |
|
| 131 |
int slNo = 0;
|
125 |
int slNo = 0;
|
| 132 |
double total = 0;
|
126 |
double total = 0;
|
| 133 |
for(LineItem lineitem : purchaseOrder.getLineitems()){
|
127 |
for(in.shop2020.purchase.LineItem lineitem : purchaseOrder.getLineitems()){
|
| 134 |
slNo++;
|
128 |
slNo++;
|
| 135 |
detailsTable.addCell(new Phrase(slNo + "", helvetica8));
|
129 |
detailsTable.addCell(new Phrase(slNo + "", helvetica8));
|
| 136 |
detailsTable.addCell(getProductNameCell(lineitem));
|
130 |
detailsTable.addCell(getProductNameCell(lineitem));
|
| 137 |
detailsTable.addCell(new Phrase(lineitem.getQuantity() + "", helvetica8));
|
131 |
detailsTable.addCell(new Phrase(lineitem.getQuantity() + "", helvetica8));
|
| 138 |
detailsTable.addCell(new Phrase(lineitem.getUnitPrice() + "", helvetica8));
|
132 |
detailsTable.addCell(new Phrase(lineitem.getUnitPrice() + "", helvetica8));
|
| Line 159... |
Line 153... |
| 159 |
billToTable.addCell(new Phrase("Prices inclusive of all taxes", helvetica8));
|
153 |
billToTable.addCell(new Phrase("Prices inclusive of all taxes", helvetica8));
|
| 160 |
|
154 |
|
| 161 |
return billToTable;
|
155 |
return billToTable;
|
| 162 |
}
|
156 |
}
|
| 163 |
|
157 |
|
| 164 |
private static PdfPCell getProductNameCell(LineItem lineitem) {
|
158 |
private static PdfPCell getProductNameCell(in.shop2020.purchase.LineItem lineitem) {
|
| 165 |
String itemName = getItemDisplayName(lineitem);
|
159 |
String itemName = getItemDisplayName(lineitem);
|
| 166 |
PdfPCell productNameCell = new PdfPCell(new Phrase(itemName, helvetica8));
|
160 |
PdfPCell productNameCell = new PdfPCell(new Phrase(itemName, helvetica8));
|
| 167 |
productNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
161 |
productNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
| 168 |
return productNameCell;
|
162 |
return productNameCell;
|
| 169 |
}
|
163 |
}
|
| 170 |
|
164 |
|
| 171 |
private static String getItemDisplayName(LineItem lineitem){
|
165 |
private static String getItemDisplayName(in.shop2020.purchase.LineItem lineitem){
|
| 172 |
StringBuffer itemName = new StringBuffer();
|
166 |
StringBuffer itemName = new StringBuffer();
|
| 173 |
if(lineitem.getBrand()!= null)
|
167 |
if(lineitem.getBrand()!= null)
|
| 174 |
itemName.append(lineitem.getBrand() + " ");
|
168 |
itemName.append(lineitem.getBrand() + " ");
|
| 175 |
if(lineitem.getModelName() != null)
|
169 |
if(lineitem.getModelName() != null)
|
| 176 |
itemName.append(lineitem.getModelName() + " ");
|
170 |
itemName.append(lineitem.getModelName() + " ");
|