| 21686 |
ashik.ali |
1 |
package com.spice.profitmandi.common.util;
|
|
|
2 |
|
| 29930 |
amit.gupta |
3 |
import com.ibm.icu.text.RuleBasedNumberFormat;
|
|
|
4 |
import com.itextpdf.text.*;
|
|
|
5 |
import com.itextpdf.text.Font.FontFamily;
|
|
|
6 |
import com.itextpdf.text.pdf.*;
|
|
|
7 |
import com.spice.profitmandi.common.model.*;
|
|
|
8 |
import org.apache.logging.log4j.LogManager;
|
|
|
9 |
import org.apache.logging.log4j.Logger;
|
|
|
10 |
import org.springframework.util.StringUtils;
|
|
|
11 |
|
| 24506 |
amit.gupta |
12 |
import java.io.ByteArrayInputStream;
|
|
|
13 |
import java.io.ByteArrayOutputStream;
|
|
|
14 |
import java.io.IOException;
|
| 21686 |
ashik.ali |
15 |
import java.io.OutputStream;
|
| 24506 |
amit.gupta |
16 |
import java.net.URL;
|
| 24854 |
amit.gupta |
17 |
import java.util.ArrayList;
|
| 23001 |
amit.gupta |
18 |
import java.util.List;
|
| 21915 |
ashik.ali |
19 |
import java.util.Locale;
|
| 21686 |
ashik.ali |
20 |
|
|
|
21 |
public class PdfUtils {
|
| 23509 |
amit.gupta |
22 |
|
| 32275 |
tejbeer |
23 |
private static final Font FONT_TITLE = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD);
|
|
|
24 |
private static Font FONT_NORMAL = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL);
|
|
|
25 |
private static Font FONT_BOLD = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD);
|
|
|
26 |
// private static Font fontTableHeader = new
|
|
|
27 |
// Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD);
|
|
|
28 |
public static final String INVOICE_TITLE = "TAX INVOICE";
|
|
|
29 |
public static final String DEBIT_NOTE_TITLE = "DEBIT NOTE";
|
|
|
30 |
public static final String SECURITY_DEPOSIT = "SECURITY DEPOSIT RECEIPT";
|
| 23509 |
amit.gupta |
31 |
|
| 32275 |
tejbeer |
32 |
private static float[] igstWidthsWithDiscount = new float[]{.2f, 2.6f, 0.7f, .4f, 0.7f, 0.6f, .7f, .6f, 0.7f};
|
|
|
33 |
private static float[] stateWidthsWithDiscount = new float[]{.2f, 2.1f, 0.7f, .3f, 0.6f, 0.5f, .7f, .6f, .6f, .7f};
|
| 23509 |
amit.gupta |
34 |
|
| 32275 |
tejbeer |
35 |
private static float[] igstWidths = new float[]{.6f, 2.6f, 0.7f, .4f, 0.7f, .7f, .6f, 0.6f, 0.9f};
|
|
|
36 |
private static float[] stateWidths = new float[]{.6f, 2.1f, 0.7f, .3f, 0.6f, .7f, .5f, .6f, .5f, .6f, .8f};
|
| 23533 |
amit.gupta |
37 |
|
| 32275 |
tejbeer |
38 |
private static float[] igstWidthsCrNote = new float[]{2.6f, 0.7f, .4f, 0.7f, .7f, .6f, 0.6f, 0.9f};
|
|
|
39 |
private static float[] stateWidthsCrNote = new float[]{2.1f, 0.7f, .3f, 0.6f, .7f, .5f, .6f, .5f, .6f, .8f};
|
| 23654 |
amit.gupta |
40 |
|
| 32275 |
tejbeer |
41 |
private static final Locale indianLocale = Locale.getDefault();
|
| 23509 |
amit.gupta |
42 |
|
| 32275 |
tejbeer |
43 |
private static final Logger LOGGER = LogManager.getLogger(PdfUtils.class);
|
| 23509 |
amit.gupta |
44 |
|
| 32275 |
tejbeer |
45 |
private static final URL iconUrl = PdfUtils.class.getClassLoader().getResource("sdlogo.png");
|
|
|
46 |
private static Image iconImg = null;
|
| 30400 |
amit.gupta |
47 |
|
| 32275 |
tejbeer |
48 |
static {
|
|
|
49 |
try {
|
|
|
50 |
iconImg = Image.getInstance(iconUrl);
|
|
|
51 |
} catch (Exception e) {
|
|
|
52 |
e.printStackTrace();
|
|
|
53 |
}
|
|
|
54 |
}
|
| 30400 |
amit.gupta |
55 |
|
| 32275 |
tejbeer |
56 |
//Debit Note generation logic has been changed
|
|
|
57 |
//Debit Note considers price drops so amount in debit note is current price of item.
|
|
|
58 |
//From 16Nov 2019 onwards all debit notes will be as per actuall billing value, all pricedrops
|
|
|
59 |
//shall be rolledback or cancelled once the debit note is generated.
|
| 25463 |
amit.gupta |
60 |
|
| 30400 |
amit.gupta |
61 |
|
| 32275 |
tejbeer |
62 |
public static void generateAndWrite(List<InvoicePdfModel> pdfModels, ByteArrayOutputStream outputStream) {
|
|
|
63 |
try {
|
| 32991 |
amit.gupta |
64 |
boolean cancelledPages = false;
|
| 32275 |
tejbeer |
65 |
List<Integer> caneclledPageList = new ArrayList<>();
|
|
|
66 |
Document document = new Document();
|
|
|
67 |
document.setMargins(0, 0, 25, 0);
|
| 33741 |
amit.gupta |
68 |
PdfWriter pdfWriter = PdfWriter.getInstance(document, outputStream);
|
| 32275 |
tejbeer |
69 |
document.open();
|
|
|
70 |
for (InvoicePdfModel pdfModel : pdfModels) {
|
|
|
71 |
CustomCustomer customer = pdfModel.getCustomer();
|
|
|
72 |
CustomRetailer retailer = pdfModel.getRetailer();
|
|
|
73 |
boolean stateGst = false;
|
|
|
74 |
if (customer.getAddress().getState().equals(retailer.getAddress().getState())) {
|
|
|
75 |
stateGst = true;
|
|
|
76 |
}
|
| 33298 |
amit.gupta |
77 |
List<CustomOrderItem> orderItems = pdfModel.getOrderItems();
|
| 32275 |
tejbeer |
78 |
if (pdfModel.isCancelled()) {
|
|
|
79 |
caneclledPageList.add(1);
|
| 32991 |
amit.gupta |
80 |
cancelledPages = true;
|
| 32275 |
tejbeer |
81 |
} else {
|
|
|
82 |
caneclledPageList.add(0);
|
|
|
83 |
}
|
|
|
84 |
document.addTitle(pdfModel.getTitle());
|
|
|
85 |
document.addAuthor(pdfModel.getAuther());
|
| 22889 |
amit.gupta |
86 |
|
| 32275 |
tejbeer |
87 |
Paragraph paragraphTitle = new Paragraph(INVOICE_TITLE, FONT_TITLE);
|
|
|
88 |
paragraphTitle.setAlignment(Element.ALIGN_CENTER);
|
| 21686 |
ashik.ali |
89 |
|
| 32980 |
amit.gupta |
90 |
document.add(paragraphTitle);
|
|
|
91 |
|
|
|
92 |
Rectangle rectangle = document.getPageSize();
|
|
|
93 |
|
|
|
94 |
/*Paragraph paragraphTitle = new Paragraph(INVOICE_TITLE, FONT_TITLE);
|
|
|
95 |
paragraphTitle.setAlignment(Element.ALIGN_CENTER);*/
|
|
|
96 |
/*pdfCell.addElement(paragraphTitle);
|
|
|
97 |
pdfCell.setBorder(Rectangle.NO_BORDER);*/
|
|
|
98 |
if (pdfModel.getIrnModel() != null) {
|
|
|
99 |
addIrnDetails(pdfModel.getIrnModel(), rectangle, document);
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
PdfPTable tableCustomerRetailer = new PdfPTable(2);
|
| 32275 |
tejbeer |
104 |
tableCustomerRetailer.setWidthPercentage(90);
|
|
|
105 |
tableCustomerRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
106 |
PdfPCell columnCustomerInfo = new PdfPCell();
|
|
|
107 |
columnCustomerInfo.addElement(new Paragraph("Customer Details", FONT_BOLD));
|
|
|
108 |
columnCustomerInfo.addElement(new Paragraph(
|
|
|
109 |
StringUtils.capitalize(customer.getAddress().getName() + (customer.getAddress().getLastName() == null ? "" : " " + customer.getAddress().getLastName())), FONT_NORMAL));
|
| 32627 |
ranu |
110 |
if (customer.getAddress() != null) {
|
|
|
111 |
if ((customer.getAddress().getLine1() != null && !customer.getAddress().getLine1().trim().isEmpty()) || (customer.getAddress().getLine2() != null && !customer.getAddress().getLine2().trim().isEmpty())) {
|
|
|
112 |
columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getLine1()) + ", " + StringUtils.capitalize(customer.getAddress().getLine2()), FONT_NORMAL));
|
|
|
113 |
}
|
|
|
114 |
if ((customer.getAddress().getCity() != null && !customer.getAddress().getCity().trim().isEmpty()) || (customer.getAddress().getState() != null && !customer.getAddress().getState().trim().isEmpty())) {
|
|
|
115 |
columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getCity()) + ", " + StringUtils.capitalize(customer.getAddress().getState()) + "(" + pdfModel.getCustomerAddressStateCode() + ")" + "\n" + customer.getAddress().getPinCode(), FONT_NORMAL));
|
|
|
116 |
}
|
|
|
117 |
}
|
|
|
118 |
|
| 32275 |
tejbeer |
119 |
columnCustomerInfo.addElement(new Paragraph("Mobile - " + customer.getAddress().getPhoneNumber(), FONT_NORMAL));
|
|
|
120 |
if (customer.getGstNumber() != null && !customer.getGstNumber().isEmpty()) {
|
|
|
121 |
columnCustomerInfo.addElement(new Paragraph("GST Number - " + customer.getGstNumber(), FONT_NORMAL));
|
|
|
122 |
}
|
|
|
123 |
columnCustomerInfo.setBorder(Rectangle.NO_BORDER);
|
|
|
124 |
PdfPCell columnRetailerInfo = new PdfPCell();
|
|
|
125 |
columnRetailerInfo.addElement(new Paragraph(StringUtils.capitalize(retailer.getAddress().getName()), FONT_BOLD));
|
|
|
126 |
columnRetailerInfo.addElement(new Paragraph(StringUtils.capitalize(retailer.getAddress().getLine1()) + ", " + StringUtils.capitalize(retailer.getAddress().getLine2()) + ", " + StringUtils.capitalize(retailer.getAddress().getCity()) + "-" + retailer.getAddress().getPinCode() + ", " + retailer.getAddress().getState() + "(" + (stateGst ? pdfModel.getCustomerAddressStateCode() : pdfModel.getPartnerAddressStateCode()) + ")", FONT_BOLD));
|
|
|
127 |
columnRetailerInfo.addElement(new Paragraph("Contact No.- " + retailer.getAddress().getPhoneNumber(), FONT_BOLD));
|
|
|
128 |
columnRetailerInfo.addElement(new Paragraph("GST NO. " + retailer.getGstNumber(), FONT_BOLD));
|
|
|
129 |
columnRetailerInfo.setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
130 |
|
| 32275 |
tejbeer |
131 |
PdfPTable tableInvoiceDateRetailer = new PdfPTable(1);
|
|
|
132 |
tableInvoiceDateRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
133 |
|
| 32275 |
tejbeer |
134 |
PdfPTable tableInvoiceDate = new PdfPTable(2);
|
|
|
135 |
tableInvoiceDate.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
136 |
|
| 32275 |
tejbeer |
137 |
PdfPCell invoiceNumberKey = new PdfPCell(new Paragraph("Invoice No:", FONT_NORMAL));
|
|
|
138 |
invoiceNumberKey.setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
139 |
|
| 32275 |
tejbeer |
140 |
PdfPCell invoiceNumberValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceNumber(), FONT_NORMAL));
|
|
|
141 |
invoiceNumberValue.setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
142 |
|
| 32275 |
tejbeer |
143 |
PdfPCell dateKey = new PdfPCell(new Paragraph("Date:", FONT_NORMAL));
|
|
|
144 |
dateKey.setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
145 |
|
| 32275 |
tejbeer |
146 |
PdfPCell dateValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceDate(), FONT_NORMAL));
|
|
|
147 |
dateValue.setBorder(Rectangle.NO_BORDER);
|
|
|
148 |
tableInvoiceDate.addCell(invoiceNumberKey);
|
|
|
149 |
// tableInvoiceDate.addCell(blankCell);
|
|
|
150 |
tableInvoiceDate.addCell(invoiceNumberValue);
|
|
|
151 |
tableInvoiceDate.addCell(dateKey);
|
|
|
152 |
// tableInvoiceDate.addCell(blankCell);
|
|
|
153 |
tableInvoiceDate.addCell(dateValue);
|
|
|
154 |
tableInvoiceDateRetailer.addCell(tableInvoiceDate);
|
|
|
155 |
tableInvoiceDateRetailer.addCell(columnRetailerInfo);
|
| 23509 |
amit.gupta |
156 |
|
| 32275 |
tejbeer |
157 |
tableCustomerRetailer.addCell(columnCustomerInfo);
|
|
|
158 |
tableCustomerRetailer.addCell(tableInvoiceDateRetailer);
|
| 23509 |
amit.gupta |
159 |
|
| 32275 |
tejbeer |
160 |
PdfPTable orders = null;
|
|
|
161 |
if (stateGst) {
|
|
|
162 |
orders = new PdfPTable(stateWidthsWithDiscount.length);
|
|
|
163 |
orders.setWidths(stateWidthsWithDiscount);
|
|
|
164 |
} else {
|
|
|
165 |
orders = new PdfPTable(igstWidthsWithDiscount.length);
|
|
|
166 |
orders.setWidths(igstWidthsWithDiscount);
|
|
|
167 |
}
|
|
|
168 |
orders.setWidthPercentage(90);
|
|
|
169 |
orders.addCell(new Paragraph("Sl", FONT_BOLD));
|
|
|
170 |
orders.addCell(new Paragraph("Description", FONT_BOLD));
|
|
|
171 |
orders.addCell(new Paragraph("HSN", FONT_BOLD));
|
|
|
172 |
orders.addCell(new Paragraph("Qty", FONT_BOLD));
|
|
|
173 |
orders.addCell(new Paragraph("Rate\n(Per pc)", FONT_BOLD));
|
|
|
174 |
orders.addCell(new Paragraph("Discount", FONT_BOLD));
|
|
|
175 |
orders.addCell(new Paragraph("Total\nTaxable", FONT_BOLD));
|
|
|
176 |
if (!stateGst) {
|
|
|
177 |
orders.addCell(new Paragraph("IGST", FONT_BOLD));
|
|
|
178 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1});
|
|
|
179 |
// total 8f
|
|
|
180 |
} else {
|
|
|
181 |
orders.addCell(new Paragraph("CGST", FONT_BOLD));
|
|
|
182 |
orders.addCell(new Paragraph("SGST", FONT_BOLD));
|
|
|
183 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1, 1, 1});
|
|
|
184 |
// total 8f
|
|
|
185 |
}
|
|
|
186 |
orders.addCell(new Paragraph("Total", FONT_BOLD));
|
| 23509 |
amit.gupta |
187 |
|
| 32275 |
tejbeer |
188 |
// orders.addCell(new Paragraph("Item Total (Rs)", FONT_BOLD));
|
| 23509 |
amit.gupta |
189 |
|
| 32275 |
tejbeer |
190 |
orders.setHeaderRows(1);
|
|
|
191 |
// orders.setSkipFirstHeader(true);
|
| 23509 |
amit.gupta |
192 |
|
| 32275 |
tejbeer |
193 |
float igstTotalAmount = 0, cgstTotalAmount = 0, sgstTotalAmount = 0;
|
|
|
194 |
int index = 1;
|
|
|
195 |
for (CustomOrderItem orderItem : orderItems) {
|
|
|
196 |
orders.addCell(new Paragraph(String.valueOf(index++), FONT_NORMAL));
|
|
|
197 |
orders.addCell(new Paragraph(orderItem.getDescription(), FONT_NORMAL));
|
|
|
198 |
orders.addCell(new Paragraph(orderItem.getHsnCode(), FONT_NORMAL));
|
|
|
199 |
orders.addCell(new Paragraph(String.valueOf(orderItem.getQuantity()), FONT_NORMAL));
|
|
|
200 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getRate()), FONT_NORMAL));
|
|
|
201 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getDiscount()), FONT_NORMAL));
|
|
|
202 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getAmount()), FONT_NORMAL));
|
|
|
203 |
if (!stateGst) {
|
|
|
204 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", orderItem.getIgstAmount(), orderItem.getIgstRate()), FONT_NORMAL));
|
|
|
205 |
igstTotalAmount = igstTotalAmount + orderItem.getIgstAmount();
|
|
|
206 |
} else {
|
|
|
207 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", orderItem.getCgstAmount(), orderItem.getCgstRate()), FONT_NORMAL));
|
|
|
208 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", orderItem.getSgstAmount(), orderItem.getSgstRate()), FONT_NORMAL));
|
|
|
209 |
cgstTotalAmount = cgstTotalAmount + orderItem.getCgstAmount();
|
|
|
210 |
sgstTotalAmount = sgstTotalAmount + orderItem.getSgstAmount();
|
|
|
211 |
}
|
|
|
212 |
orders.addCell(new Paragraph(String.format("%.0f", orderItem.getNetAmount()), FONT_NORMAL));
|
|
|
213 |
// orders.addCell(new Paragraph(String.format("%.2f",
|
|
|
214 |
// orderItem.getItemTotal()), FONT_NORMAL));
|
|
|
215 |
}
|
|
|
216 |
if (pdfModel.getInsurancePolicies() != null) {
|
|
|
217 |
for (CustomInsurancePolicy insurancePolicy : pdfModel.getInsurancePolicies()) {
|
|
|
218 |
orders.addCell(new Paragraph(String.valueOf(index++), FONT_NORMAL));
|
|
|
219 |
orders.addCell(new Paragraph(insurancePolicy.getDescription(), FONT_NORMAL));
|
|
|
220 |
orders.addCell(new Paragraph(insurancePolicy.getHsnCode(), FONT_NORMAL));
|
|
|
221 |
orders.addCell(new Paragraph("1", FONT_NORMAL));
|
|
|
222 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
|
|
|
223 |
orders.addCell(new Paragraph("-", FONT_NORMAL));
|
|
|
224 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
|
|
|
225 |
if (!stateGst) {
|
|
|
226 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", insurancePolicy.getIgstAmount(), insurancePolicy.getIgstRate()), FONT_NORMAL));
|
|
|
227 |
igstTotalAmount = igstTotalAmount + insurancePolicy.getIgstAmount();
|
|
|
228 |
} else {
|
|
|
229 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", insurancePolicy.getCgstAmount(), insurancePolicy.getCgstRate()), FONT_NORMAL));
|
|
|
230 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", insurancePolicy.getSgstAmount(), insurancePolicy.getSgstRate()), FONT_NORMAL));
|
|
|
231 |
cgstTotalAmount = cgstTotalAmount + insurancePolicy.getCgstAmount();
|
|
|
232 |
sgstTotalAmount = sgstTotalAmount + insurancePolicy.getSgstAmount();
|
|
|
233 |
}
|
|
|
234 |
orders.addCell(new Paragraph(String.format("%.0f", insurancePolicy.getNetAmount()), FONT_NORMAL));
|
|
|
235 |
}
|
|
|
236 |
}
|
| 32980 |
amit.gupta |
237 |
|
| 32275 |
tejbeer |
238 |
iconImg.setAbsolutePosition(25, rectangle.getHeight() - 100);
|
|
|
239 |
iconImg.scalePercent(30);
|
| 30400 |
amit.gupta |
240 |
|
| 32275 |
tejbeer |
241 |
document.add(iconImg);
|
|
|
242 |
document.add(Chunk.NEWLINE);
|
|
|
243 |
document.add(Chunk.NEWLINE);
|
|
|
244 |
document.add(tableCustomerRetailer);
|
| 23509 |
amit.gupta |
245 |
|
| 32275 |
tejbeer |
246 |
document.add(Chunk.NEWLINE);
|
|
|
247 |
document.add(orders);
|
| 23509 |
amit.gupta |
248 |
|
| 32275 |
tejbeer |
249 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
|
|
250 |
PdfPTable paymentsTable = new PdfPTable(2);
|
|
|
251 |
paymentsTable.setWidthPercentage(95);
|
|
|
252 |
paymentsTable.setWidths(new float[]{8f, 2f});
|
| 23509 |
amit.gupta |
253 |
|
| 32275 |
tejbeer |
254 |
if (stateGst) {
|
|
|
255 |
grandTotalTable.setWidths(new float[]{6.6f, .6f, .8f});
|
|
|
256 |
} else {
|
|
|
257 |
grandTotalTable.setWidths(new float[]{6.5f, .6f, .9f});
|
|
|
258 |
}
|
|
|
259 |
grandTotalTable.setWidthPercentage(90);
|
| 23654 |
amit.gupta |
260 |
|
| 32275 |
tejbeer |
261 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
|
|
262 |
grandTotalParagraph.setIndentationRight(20);
|
|
|
263 |
grandTotalTable.addCell(grandTotalParagraph);
|
|
|
264 |
Paragraph rsParagraph = new Paragraph("Rs.", FONT_BOLD);
|
|
|
265 |
grandTotalTable.addCell(rsParagraph);
|
|
|
266 |
Paragraph amountParagraph = new Paragraph(String.format("%.2f", pdfModel.getTotalAmount()), FONT_BOLD);
|
|
|
267 |
grandTotalTable.addCell(amountParagraph);
|
| 24845 |
amit.gupta |
268 |
|
| 32275 |
tejbeer |
269 |
document.add(grandTotalTable);
|
| 24845 |
amit.gupta |
270 |
|
| 32275 |
tejbeer |
271 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
|
|
272 |
amountInWordsTable.setWidthPercentage(90);
|
|
|
273 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
|
|
274 |
if (!stateGst) {
|
|
|
275 |
amountInWordsTable.setWidths(new float[]{2, 5.1f, 0.9f});
|
|
|
276 |
} else {
|
|
|
277 |
amountInWordsTable.setWidths(new float[]{2, 5.2f, 0.8f});
|
|
|
278 |
}
|
| 23509 |
amit.gupta |
279 |
|
| 32275 |
tejbeer |
280 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
|
|
281 |
amountInWordsTable.addCell(new Paragraph(amountInWords.toString(), FONT_BOLD));
|
|
|
282 |
amountInWordsTable.addCell(new Paragraph("E & O.E", FONT_NORMAL));
|
|
|
283 |
document.add(amountInWordsTable);
|
| 23654 |
amit.gupta |
284 |
|
| 32275 |
tejbeer |
285 |
if (pdfModel.getPaymentOptions() != null) {
|
|
|
286 |
PdfPTable paidAmountTable = new PdfPTable(2);
|
|
|
287 |
paidAmountTable.setWidthPercentage(90);
|
|
|
288 |
if (!stateGst) {
|
|
|
289 |
paidAmountTable.setWidths(new float[]{7.1f, 0.9f});
|
|
|
290 |
} else {
|
|
|
291 |
paidAmountTable.setWidths(new float[]{7.2f, 0.8f});
|
|
|
292 |
}
|
|
|
293 |
float totalPaidValue = 0;
|
|
|
294 |
for (CustomPaymentOption paymentOption : pdfModel.getPaymentOptions()) {
|
| 33795 |
ranu |
295 |
LOGGER.info("paymentOption - {}", paymentOption);
|
|
|
296 |
if (!"CASH DISCOUNT".equals(paymentOption.getPaymentOption())) {
|
|
|
297 |
PdfPCell cell = new PdfPCell(
|
|
|
298 |
new Paragraph(10, "Paid Through " + paymentOption.getPaymentOption(), FONT_BOLD));
|
|
|
299 |
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
300 |
cell.setPadding(5);
|
|
|
301 |
paidAmountTable.addCell(cell);
|
| 23654 |
amit.gupta |
302 |
|
| 33795 |
ranu |
303 |
PdfPCell cell1 = new PdfPCell(new Paragraph(10, FormattingUtils.formatDecimal(paymentOption.getAmount()), FONT_BOLD));
|
|
|
304 |
cell1.setPadding(5);
|
|
|
305 |
paidAmountTable.addCell(cell1);
|
|
|
306 |
totalPaidValue += paymentOption.getAmount();
|
|
|
307 |
}
|
| 23654 |
amit.gupta |
308 |
|
| 33795 |
ranu |
309 |
|
|
|
310 |
|
|
|
311 |
|
| 32275 |
tejbeer |
312 |
}
|
|
|
313 |
PdfPCell totalPaidCell = new PdfPCell(new Paragraph(10, "Total Paid", FONT_BOLD));
|
|
|
314 |
totalPaidCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
315 |
totalPaidCell.setPadding(5);
|
|
|
316 |
paidAmountTable.addCell(totalPaidCell);
|
| 23558 |
amit.gupta |
317 |
|
| 32275 |
tejbeer |
318 |
PdfPCell totalPaidValueCell = new PdfPCell(
|
|
|
319 |
new Paragraph(10, FormattingUtils.formatDecimal(totalPaidValue), FONT_BOLD));
|
|
|
320 |
totalPaidValueCell.setPadding(5);
|
|
|
321 |
paidAmountTable.addCell(totalPaidValueCell);
|
| 23509 |
amit.gupta |
322 |
|
| 32275 |
tejbeer |
323 |
document.add(paidAmountTable);
|
|
|
324 |
}
|
| 32980 |
amit.gupta |
325 |
Paragraph autoGenerateParagraph = new Paragraph("Note - This is computer generated Invoice, no signature is required", FONT_NORMAL);
|
|
|
326 |
autoGenerateParagraph.setAlignment(Element.ALIGN_CENTER);
|
|
|
327 |
document.add(autoGenerateParagraph);
|
| 24845 |
amit.gupta |
328 |
|
| 32275 |
tejbeer |
329 |
if (pdfModel.getTncs() != null) {
|
|
|
330 |
StringBuffer sb = new StringBuffer();
|
|
|
331 |
for (String tnc : pdfModel.getTncs()) {
|
|
|
332 |
sb.append(tnc).append("\n");
|
|
|
333 |
}
|
|
|
334 |
Paragraph warningParagraph = new Paragraph(sb.toString(), FONT_NORMAL);
|
|
|
335 |
warningParagraph.setIndentationLeft(40);
|
|
|
336 |
document.add(Chunk.NEWLINE);
|
|
|
337 |
document.add(warningParagraph);
|
|
|
338 |
}
|
| 24845 |
amit.gupta |
339 |
|
| 32275 |
tejbeer |
340 |
document.newPage();
|
| 33741 |
amit.gupta |
341 |
if(pdfModel.geteWayBillPdfModel()!=null) {
|
|
|
342 |
|
|
|
343 |
EWayBillPDF.generateDocument(document, pdfWriter, pdfModel.geteWayBillPdfModel());
|
|
|
344 |
}
|
| 32275 |
tejbeer |
345 |
}
|
|
|
346 |
document.close(); // no need to close PDFwriter?
|
| 32991 |
amit.gupta |
347 |
if(cancelledPages) {
|
|
|
348 |
stampCancelled(outputStream, caneclledPageList);
|
|
|
349 |
}
|
| 23509 |
amit.gupta |
350 |
|
| 32275 |
tejbeer |
351 |
} catch (DocumentException e) {
|
|
|
352 |
LOGGER.error("Unable to write data to pdf file : ", e);
|
|
|
353 |
} catch (Exception e) {
|
|
|
354 |
// TODO Auto-generated catch block
|
|
|
355 |
e.printStackTrace();
|
|
|
356 |
}
|
| 24506 |
amit.gupta |
357 |
|
| 32275 |
tejbeer |
358 |
}
|
| 23509 |
amit.gupta |
359 |
|
| 32980 |
amit.gupta |
360 |
private static void addIrnDetails(IrnModel irnModel, Rectangle rectangle, Document document) throws IOException, DocumentException {
|
|
|
361 |
PdfPTable taxTable = new PdfPTable(1);
|
|
|
362 |
taxTable.setWidthPercentage(45);
|
|
|
363 |
PdfPCell pdfCell = new PdfPCell();
|
|
|
364 |
pdfCell.setBorder(Rectangle.NO_BORDER);
|
|
|
365 |
Image img = Image.getInstance(irnModel.getQrCode().toURI().toURL());
|
|
|
366 |
img.setAbsolutePosition(450f, rectangle.getHeight() - 140);
|
|
|
367 |
document.add(img);
|
|
|
368 |
Paragraph irnParagraph = new Paragraph("IRN No - " + irnModel.getIrnNumber(), FONT_NORMAL);
|
|
|
369 |
irnParagraph.setAlignment(Element.ALIGN_LEFT);
|
|
|
370 |
pdfCell.addElement(irnParagraph);
|
|
|
371 |
|
|
|
372 |
Paragraph ackParagraph = new Paragraph("Ack No - " + irnModel.getAcknowledgeNumber(), FONT_NORMAL);
|
|
|
373 |
ackParagraph.setAlignment(Element.ALIGN_LEFT);
|
|
|
374 |
pdfCell.addElement(ackParagraph);
|
|
|
375 |
|
|
|
376 |
Paragraph ackDateParagraph = new Paragraph("Ack Date - " + FormattingUtils.format(irnModel.getAcknowledgeDate()), FONT_NORMAL);
|
|
|
377 |
ackDateParagraph.setAlignment(Element.ALIGN_LEFT);
|
|
|
378 |
pdfCell.addElement(ackDateParagraph);
|
|
|
379 |
taxTable.addCell(pdfCell);
|
|
|
380 |
document.add(taxTable);
|
|
|
381 |
}
|
|
|
382 |
|
| 32275 |
tejbeer |
383 |
private static void stampCancelled(ByteArrayOutputStream byteStream, List<Integer> cancelledPage) throws IOException, DocumentException {
|
|
|
384 |
ByteArrayInputStream bais = new ByteArrayInputStream(byteStream.toByteArray());
|
|
|
385 |
PdfReader pdfReader = new PdfReader(bais);
|
|
|
386 |
int n = pdfReader.getNumberOfPages();
|
|
|
387 |
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
388 |
PdfStamper pdfStamper = new PdfStamper(pdfReader, baos);
|
|
|
389 |
pdfStamper.setRotateContents(false);
|
|
|
390 |
// text watermark
|
|
|
391 |
Font f = new Font(FontFamily.HELVETICA, 30);
|
|
|
392 |
Phrase p = new Phrase("My watermark (text)", f);
|
|
|
393 |
URL cancelledImgUrl = PdfUtils.class.getClassLoader().getResource("cancelled.png");
|
|
|
394 |
URL waterMarkImgUrl = PdfUtils.class.getClassLoader().getResource("sd1.jpg");
|
|
|
395 |
Image imgCancelled = Image.getInstance(cancelledImgUrl);
|
|
|
396 |
Image imgWatermark = Image.getInstance(waterMarkImgUrl);
|
|
|
397 |
imgWatermark.scaleAbsolute(imgWatermark.getScaledWidth() * 2.5f, imgWatermark.getScaledHeight() * 2.5f);
|
|
|
398 |
float w = imgCancelled.getScaledWidth() / 2;
|
|
|
399 |
float h = imgCancelled.getScaledHeight() / 2;
|
|
|
400 |
float wWaterMark = imgWatermark.getScaledWidth() / 2;
|
|
|
401 |
float hWatermark = imgWatermark.getScaledHeight() / 2;
|
|
|
402 |
// transparency
|
|
|
403 |
PdfGState gs1 = new PdfGState();
|
| 32980 |
amit.gupta |
404 |
gs1.setFillOpacity(0.4f);
|
| 32275 |
tejbeer |
405 |
PdfGState gs2 = new PdfGState();
|
| 32980 |
amit.gupta |
406 |
gs2.setFillOpacity(0.05f);
|
| 32275 |
tejbeer |
407 |
// properties
|
|
|
408 |
PdfContentByte over;
|
|
|
409 |
Rectangle pagesize;
|
|
|
410 |
float x, y;
|
| 24506 |
amit.gupta |
411 |
|
| 32275 |
tejbeer |
412 |
// loop over every page
|
|
|
413 |
for (int i = 1; i <= n; i++) {
|
|
|
414 |
pagesize = pdfReader.getPageSize(i);
|
|
|
415 |
x = (pagesize.getLeft() + pagesize.getRight()) / 2;
|
|
|
416 |
y = (pagesize.getTop() + pagesize.getBottom()) / 2;
|
|
|
417 |
over = pdfStamper.getOverContent(i);
|
|
|
418 |
over.saveState();
|
|
|
419 |
if (cancelledPage.get(i - 1) == 1) {
|
|
|
420 |
over.setGState(gs1);
|
|
|
421 |
over.addImage(imgCancelled, w, 0, 0, h, x - (w / 2), y - (h / 2));
|
|
|
422 |
over.restoreState();
|
|
|
423 |
} else {
|
|
|
424 |
over.setGState(gs2);
|
|
|
425 |
over.addImage(imgWatermark, wWaterMark, 0, 0, hWatermark, x - (wWaterMark / 2), y - (hWatermark / 2));
|
|
|
426 |
over.restoreState();
|
|
|
427 |
}
|
|
|
428 |
}
|
|
|
429 |
pdfStamper.close();
|
|
|
430 |
pdfReader.close();
|
|
|
431 |
baos.writeTo(byteStream);
|
| 24845 |
amit.gupta |
432 |
|
| 32275 |
tejbeer |
433 |
}
|
| 24506 |
amit.gupta |
434 |
|
| 32275 |
tejbeer |
435 |
public static void generateAndWriteDebitNote(List<DebitNotePdfModel> debitNotePdfModels, OutputStream outputStream) {
|
|
|
436 |
Document document = new Document();
|
|
|
437 |
document.setMargins(0, 0, 25, 0);
|
|
|
438 |
try {
|
|
|
439 |
for (DebitNotePdfModel debitNotePdfModel : debitNotePdfModels) {
|
| 23509 |
amit.gupta |
440 |
|
| 32275 |
tejbeer |
441 |
InvoicePdfModel pdfModel = debitNotePdfModel.getPdfModel();
|
|
|
442 |
CustomCustomer customer = pdfModel.getCustomer();
|
|
|
443 |
CustomRetailer retailer = pdfModel.getRetailer();
|
|
|
444 |
boolean stateGst = false;
|
| 32290 |
tejbeer |
445 |
|
|
|
446 |
LOGGER.info("Customer - {}", customer.getAddress().getState());
|
|
|
447 |
LOGGER.info("retailer - {}", retailer.getAddress().getState());
|
|
|
448 |
|
|
|
449 |
|
| 32292 |
tejbeer |
450 |
if (customer.getAddress().getState().equals(retailer.getAddress().getState())) {
|
|
|
451 |
stateGst = true;
|
|
|
452 |
}
|
| 33298 |
amit.gupta |
453 |
List<CustomOrderItem> orderItems = pdfModel.getOrderItems();
|
| 23509 |
amit.gupta |
454 |
|
| 32275 |
tejbeer |
455 |
PdfWriter.getInstance(document, outputStream);
|
| 23509 |
amit.gupta |
456 |
|
| 32275 |
tejbeer |
457 |
document.open();
|
|
|
458 |
document.addTitle(pdfModel.getTitle());
|
|
|
459 |
document.addAuthor(pdfModel.getAuther());
|
| 23509 |
amit.gupta |
460 |
|
| 32275 |
tejbeer |
461 |
Paragraph paragraphTitle = new Paragraph(pdfModel.getTitle(), FONT_TITLE);
|
|
|
462 |
paragraphTitle.setAlignment(Element.ALIGN_CENTER);
|
| 23509 |
amit.gupta |
463 |
|
| 32275 |
tejbeer |
464 |
PdfPCell blankCell = new PdfPCell();
|
|
|
465 |
blankCell.setBorder(Rectangle.NO_BORDER);
|
|
|
466 |
PdfPTable tableCustomerRetailer = new PdfPTable(3);
|
|
|
467 |
tableCustomerRetailer.setWidthPercentage(95);
|
|
|
468 |
PdfPCell partnerInfo = new PdfPCell();
|
|
|
469 |
partnerInfo.addElement(new Paragraph("From Party:", FONT_BOLD));
|
|
|
470 |
partnerInfo.addElement(
|
|
|
471 |
new Paragraph(StringUtils.capitalize(customer.getAddress().getName()), FONT_NORMAL));
|
|
|
472 |
partnerInfo.addElement(new Paragraph(
|
| 32289 |
tejbeer |
473 |
(customer.getAddress().getLine1() == null ? "" : StringUtils.capitalize(customer.getAddress().getLine1()) + ", ") + (customer.getAddress().getLine2() == null ? "" : StringUtils.capitalize(customer.getAddress().getLine2()) + ", ") + (customer.getAddress().getCity() == null ? "" : StringUtils.capitalize(customer.getAddress().getCity()) + " - ") + (customer.getAddress().getPinCode() == null ? "" : StringUtils.capitalize(customer.getAddress().getPinCode())), FONT_NORMAL));
|
| 23654 |
amit.gupta |
474 |
|
| 32275 |
tejbeer |
475 |
partnerInfo.addElement(new Paragraph(
|
|
|
476 |
StringUtils.capitalize(customer.getAddress().getState()) + "(" + pdfModel.getCustomerAddressStateCode() + ")", FONT_NORMAL));
|
|
|
477 |
partnerInfo.addElement(new Paragraph("Mobile - " + customer.getMobileNumber(), FONT_NORMAL));
|
|
|
478 |
if (customer.getGstNumber() != null && !customer.getGstNumber().isEmpty()) {
|
|
|
479 |
partnerInfo.addElement(new Paragraph("GST No - " + customer.getGstNumber(), FONT_BOLD));
|
|
|
480 |
}
|
| 23533 |
amit.gupta |
481 |
|
| 32275 |
tejbeer |
482 |
PdfPCell sellerParty = new PdfPCell();
|
|
|
483 |
sellerParty.addElement(new Paragraph("To Party:", FONT_BOLD));
|
|
|
484 |
sellerParty.addElement(
|
|
|
485 |
new Paragraph(StringUtils.capitalize(retailer.getAddress().getName()), FONT_NORMAL));
|
| 32289 |
tejbeer |
486 |
sellerParty.addElement(new Paragraph((retailer.getAddress().getLine1() == null ? "" : StringUtils.capitalize(retailer.getAddress().getLine1()) + ", ") + (retailer.getAddress().getLine2() == null ? "" : StringUtils.capitalize(retailer.getAddress().getLine2()) + ", ") + (retailer.getAddress().getCity() == null ? "" : StringUtils.capitalize(retailer.getAddress().getCity()) + "-") + (retailer.getAddress().getPinCode() == null ? "" : StringUtils.capitalize(retailer.getAddress().getPinCode())), FONT_NORMAL));
|
| 32275 |
tejbeer |
487 |
sellerParty.addElement(new Paragraph(
|
|
|
488 |
retailer.getAddress().getState() + "(" + pdfModel.getPartnerAddressStateCode() + ")", FONT_NORMAL));
|
|
|
489 |
sellerParty.addElement(new Paragraph("Mobile - " + retailer.getAddress().getPhoneNumber(), FONT_NORMAL));
|
|
|
490 |
sellerParty.addElement(new Paragraph("GST No - " + retailer.getGstNumber(), FONT_BOLD));
|
| 23509 |
amit.gupta |
491 |
|
| 32275 |
tejbeer |
492 |
PdfPTable tableInvoiceDateRetailer = new PdfPTable(1);
|
|
|
493 |
tableInvoiceDateRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
494 |
|
| 32275 |
tejbeer |
495 |
PdfPTable tableInvoiceDate = new PdfPTable(2);
|
|
|
496 |
tableInvoiceDate.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
497 |
tableInvoiceDate.setWidthPercentage(90);
|
| 23509 |
amit.gupta |
498 |
|
| 32275 |
tejbeer |
499 |
PdfPCell debitNoteDetails = new PdfPCell(new Paragraph("Debit Note Details", FONT_BOLD));
|
|
|
500 |
debitNoteDetails.setColspan(2);
|
|
|
501 |
debitNoteDetails.setBorder(Rectangle.NO_BORDER);
|
| 23654 |
amit.gupta |
502 |
|
| 32275 |
tejbeer |
503 |
PdfPCell debitNoteNumberKey = new PdfPCell(new Paragraph("Debit Note No:", FONT_NORMAL));
|
|
|
504 |
debitNoteNumberKey.setBorder(Rectangle.NO_BORDER);
|
|
|
505 |
PdfPCell debitNoteNumberValue = new PdfPCell(
|
|
|
506 |
new Paragraph(debitNotePdfModel.getDebitNoteNumber(), FONT_NORMAL));
|
|
|
507 |
debitNoteNumberValue.setBorder(Rectangle.NO_BORDER);
|
| 23532 |
amit.gupta |
508 |
|
| 32275 |
tejbeer |
509 |
PdfPCell debitNoteDateKey = new PdfPCell(new Paragraph("Debit Note Dt:", FONT_NORMAL));
|
|
|
510 |
debitNoteDateKey.setBorder(Rectangle.NO_BORDER);
|
| 23533 |
amit.gupta |
511 |
|
| 32275 |
tejbeer |
512 |
PdfPCell debitNoteDateValue = new PdfPCell(
|
|
|
513 |
new Paragraph(debitNotePdfModel.getDebitNoteDate(), FONT_NORMAL));
|
|
|
514 |
debitNoteDateValue.setBorder(Rectangle.NO_BORDER);
|
| 23532 |
amit.gupta |
515 |
|
| 32275 |
tejbeer |
516 |
PdfPCell invoiceNumberKey = new PdfPCell(new Paragraph("Invoice Ref No:", FONT_NORMAL));
|
|
|
517 |
invoiceNumberKey.setBorder(Rectangle.NO_BORDER);
|
|
|
518 |
PdfPCell invoiceNumberValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceNumber(), FONT_NORMAL));
|
|
|
519 |
invoiceNumberValue.setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
520 |
|
| 32275 |
tejbeer |
521 |
PdfPCell dateKey = new PdfPCell(new Paragraph("Invoice Dt:", FONT_NORMAL));
|
|
|
522 |
dateKey.setBorder(Rectangle.NO_BORDER);
|
|
|
523 |
PdfPCell dateValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceDate(), FONT_NORMAL));
|
|
|
524 |
dateValue.setBorder(Rectangle.NO_BORDER);
|
| 23533 |
amit.gupta |
525 |
|
| 32275 |
tejbeer |
526 |
tableInvoiceDate.addCell(debitNoteDetails);
|
|
|
527 |
tableInvoiceDate.addCell(debitNoteNumberKey);
|
|
|
528 |
tableInvoiceDate.addCell(debitNoteNumberValue);
|
|
|
529 |
tableInvoiceDate.addCell(debitNoteDateKey);
|
|
|
530 |
tableInvoiceDate.addCell(debitNoteDateValue);
|
|
|
531 |
tableInvoiceDate.addCell(invoiceNumberKey);
|
|
|
532 |
tableInvoiceDate.addCell(invoiceNumberValue);
|
|
|
533 |
tableInvoiceDate.addCell(dateKey);
|
|
|
534 |
tableInvoiceDate.addCell(dateValue);
|
| 23509 |
amit.gupta |
535 |
|
| 32275 |
tejbeer |
536 |
tableCustomerRetailer.addCell(partnerInfo);
|
|
|
537 |
tableCustomerRetailer.addCell(tableInvoiceDate);
|
|
|
538 |
tableCustomerRetailer.addCell(sellerParty);
|
| 23509 |
amit.gupta |
539 |
|
| 32275 |
tejbeer |
540 |
PdfPTable orders = null;
|
|
|
541 |
if (stateGst) {
|
|
|
542 |
orders = new PdfPTable(stateWidths.length);
|
|
|
543 |
orders.setWidths(stateWidths);
|
|
|
544 |
} else {
|
|
|
545 |
orders = new PdfPTable(igstWidths.length);
|
|
|
546 |
orders.setWidths(igstWidths);
|
|
|
547 |
}
|
|
|
548 |
orders.setWidthPercentage(95);
|
|
|
549 |
orders.addCell(new Paragraph("Order Id", FONT_BOLD));
|
|
|
550 |
orders.addCell(new Paragraph("Description", FONT_BOLD));
|
|
|
551 |
orders.addCell(new Paragraph("HSN", FONT_BOLD));
|
|
|
552 |
orders.addCell(new Paragraph("Qty", FONT_BOLD));
|
|
|
553 |
orders.addCell(new Paragraph("Rate\n(Per pc)", FONT_BOLD));
|
|
|
554 |
orders.addCell(new Paragraph("Total\nTaxable", FONT_BOLD));
|
|
|
555 |
if (!stateGst) {
|
|
|
556 |
orders.addCell(new Paragraph("IGST\n%", FONT_BOLD));
|
|
|
557 |
orders.addCell(new Paragraph("IGST", FONT_BOLD));
|
|
|
558 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1});
|
|
|
559 |
// total 8f
|
|
|
560 |
} else {
|
|
|
561 |
orders.addCell(new Paragraph("CGST %", FONT_BOLD));
|
|
|
562 |
orders.addCell(new Paragraph("CGST", FONT_BOLD));
|
|
|
563 |
orders.addCell(new Paragraph("SGST %", FONT_BOLD));
|
|
|
564 |
orders.addCell(new Paragraph("SGST", FONT_BOLD));
|
|
|
565 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1, 1,
|
|
|
566 |
// 1});
|
|
|
567 |
// total 8f
|
|
|
568 |
}
|
|
|
569 |
orders.addCell(new Paragraph("Total", FONT_BOLD));
|
| 23509 |
amit.gupta |
570 |
|
| 32275 |
tejbeer |
571 |
orders.setHeaderRows(1);
|
| 23509 |
amit.gupta |
572 |
|
| 32275 |
tejbeer |
573 |
float igstTotalAmount = 0, cgstTotalAmount = 0, sgstTotalAmount = 0;
|
|
|
574 |
for (CustomOrderItem orderItem : orderItems) {
|
|
|
575 |
orders.addCell(new Paragraph(String.valueOf(orderItem.getOrderId()), FONT_NORMAL));
|
|
|
576 |
orders.addCell(new Paragraph(orderItem.getDescription(), FONT_NORMAL));
|
|
|
577 |
orders.addCell(new Paragraph(orderItem.getHsnCode(), FONT_NORMAL));
|
|
|
578 |
orders.addCell(new Paragraph(String.valueOf(orderItem.getQuantity()), FONT_NORMAL));
|
|
|
579 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getRate()), FONT_NORMAL));
|
|
|
580 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getAmount()), FONT_NORMAL));
|
|
|
581 |
if (!stateGst) {
|
|
|
582 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstRate()), FONT_NORMAL));
|
|
|
583 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstAmount()), FONT_NORMAL));
|
|
|
584 |
igstTotalAmount = igstTotalAmount + orderItem.getIgstAmount();
|
|
|
585 |
} else {
|
|
|
586 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstRate()), FONT_NORMAL));
|
|
|
587 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstAmount()), FONT_NORMAL));
|
|
|
588 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstRate()), FONT_NORMAL));
|
|
|
589 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstAmount()), FONT_NORMAL));
|
|
|
590 |
cgstTotalAmount = cgstTotalAmount + orderItem.getCgstAmount();
|
|
|
591 |
sgstTotalAmount = sgstTotalAmount + orderItem.getSgstAmount();
|
|
|
592 |
}
|
|
|
593 |
orders.addCell(new Paragraph(String.format("%.0f", orderItem.getNetAmount()), FONT_NORMAL));
|
|
|
594 |
LOGGER.info("IN FOR LOOP");
|
|
|
595 |
}
|
| 23509 |
amit.gupta |
596 |
|
| 32275 |
tejbeer |
597 |
document.add(paragraphTitle);
|
| 23533 |
amit.gupta |
598 |
|
| 32275 |
tejbeer |
599 |
document.add(Chunk.NEWLINE);
|
|
|
600 |
document.add(tableCustomerRetailer);
|
| 23509 |
amit.gupta |
601 |
|
| 32275 |
tejbeer |
602 |
document.add(Chunk.NEWLINE);
|
|
|
603 |
document.add(orders);
|
| 23509 |
amit.gupta |
604 |
|
| 32275 |
tejbeer |
605 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
|
|
606 |
if (stateGst) {
|
|
|
607 |
grandTotalTable.setWidths(new float[]{6.6f, .6f, .8f});
|
|
|
608 |
} else {
|
|
|
609 |
grandTotalTable.setWidths(new float[]{6.5f, .6f, .9f});
|
|
|
610 |
}
|
|
|
611 |
grandTotalTable.setWidthPercentage(95);
|
| 23509 |
amit.gupta |
612 |
|
| 32275 |
tejbeer |
613 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
|
|
614 |
grandTotalParagraph.setIndentationRight(20);
|
|
|
615 |
grandTotalTable.addCell(grandTotalParagraph);
|
|
|
616 |
Paragraph rsParagraph = new Paragraph("Rs.", FONT_BOLD);
|
|
|
617 |
grandTotalTable.addCell(rsParagraph);
|
|
|
618 |
Paragraph amountParagraph = new Paragraph(String.format("%.2f", pdfModel.getTotalAmount()), FONT_BOLD);
|
|
|
619 |
grandTotalTable.addCell(amountParagraph);
|
| 23509 |
amit.gupta |
620 |
|
| 32275 |
tejbeer |
621 |
document.add(grandTotalTable);
|
| 23509 |
amit.gupta |
622 |
|
| 32275 |
tejbeer |
623 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
|
|
624 |
if (!stateGst) {
|
|
|
625 |
amountInWordsTable.setWidths(new float[]{2, 5.1f, 0.9f});
|
|
|
626 |
} else {
|
|
|
627 |
amountInWordsTable.setWidths(new float[]{2, 5.2f, 0.8f});
|
|
|
628 |
}
|
|
|
629 |
amountInWordsTable.setWidthPercentage(95);
|
|
|
630 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
| 23509 |
amit.gupta |
631 |
|
| 32275 |
tejbeer |
632 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
|
|
633 |
amountInWordsTable.addCell(new Paragraph(amountInWords.toString(), FONT_BOLD));
|
|
|
634 |
amountInWordsTable.addCell(new Paragraph("E & O.E", FONT_NORMAL));
|
|
|
635 |
document.add(amountInWordsTable);
|
| 23509 |
amit.gupta |
636 |
|
| 32275 |
tejbeer |
637 |
document.newPage();
|
|
|
638 |
}
|
|
|
639 |
document.close(); // no need to close PDFwriter?
|
| 30539 |
amit.gupta |
640 |
|
| 32275 |
tejbeer |
641 |
} catch (DocumentException e) {
|
|
|
642 |
LOGGER.error("Unable to write data to pdf file : ", e);
|
|
|
643 |
} catch (Exception e) {
|
|
|
644 |
// TODO Auto-generated catch block
|
|
|
645 |
e.printStackTrace();
|
|
|
646 |
}
|
|
|
647 |
}
|
| 23509 |
amit.gupta |
648 |
|
| 32275 |
tejbeer |
649 |
private static String toAmountInWords(float amount) {
|
|
|
650 |
RuleBasedNumberFormat amountInWordsFormat = new RuleBasedNumberFormat(indianLocale, RuleBasedNumberFormat.SPELLOUT);
|
|
|
651 |
StringBuilder amountInWords = new StringBuilder("Rs. ");
|
|
|
652 |
amountInWords.append(StringUtils.capitalize(amountInWordsFormat.format((int) amount)));
|
|
|
653 |
amountInWords.append(" and ");
|
|
|
654 |
amountInWords.append(StringUtils.capitalize(amountInWordsFormat.format((int) (amount * 100) % 100)));
|
|
|
655 |
amountInWords.append(" paise");
|
|
|
656 |
return amountInWords.toString();
|
|
|
657 |
}
|
| 23654 |
amit.gupta |
658 |
|
| 32275 |
tejbeer |
659 |
public static void generateAndWriteCustomerCreditNotes(List<CreditNotePdfModel> creditNotes, OutputStream outputStream) {
|
|
|
660 |
Document document = new Document();
|
|
|
661 |
document.setMargins(0, 0, 25, 0);
|
|
|
662 |
try {
|
|
|
663 |
PdfWriter.getInstance(document, outputStream);
|
| 24506 |
amit.gupta |
664 |
|
| 32275 |
tejbeer |
665 |
document.open();
|
|
|
666 |
document.addTitle(creditNotes.get(0).getPdfModel().getTitle());
|
|
|
667 |
document.addAuthor(creditNotes.get(0).getPdfModel().getAuther());
|
|
|
668 |
for (CreditNotePdfModel creditNotePdfModel : creditNotes) {
|
|
|
669 |
InvoicePdfModel pdfModel = creditNotePdfModel.getPdfModel();
|
|
|
670 |
CustomCustomer customer = pdfModel.getCustomer();
|
|
|
671 |
CustomRetailer retailer = pdfModel.getRetailer();
|
|
|
672 |
boolean stateGst = false;
|
| 32290 |
tejbeer |
673 |
|
| 32275 |
tejbeer |
674 |
if (customer.getAddress().getState().equals(retailer.getAddress().getState())) {
|
|
|
675 |
stateGst = true;
|
|
|
676 |
}
|
| 33298 |
amit.gupta |
677 |
List<CustomOrderItem> orderItems = pdfModel.getOrderItems();
|
| 23654 |
amit.gupta |
678 |
|
| 32275 |
tejbeer |
679 |
Paragraph paragraphTitle = new Paragraph(pdfModel.getTitle(), FONT_TITLE);
|
|
|
680 |
paragraphTitle.setAlignment(Element.ALIGN_CENTER);
|
| 23654 |
amit.gupta |
681 |
|
| 32275 |
tejbeer |
682 |
PdfPCell blankCell = new PdfPCell();
|
|
|
683 |
blankCell.setBorder(Rectangle.NO_BORDER);
|
|
|
684 |
PdfPTable tableCustomerRetailer = new PdfPTable(3);
|
|
|
685 |
tableCustomerRetailer.setWidthPercentage(95);
|
|
|
686 |
PdfPCell partnerInfo = new PdfPCell();
|
|
|
687 |
partnerInfo.addElement(new Paragraph("To Party:", FONT_BOLD));
|
|
|
688 |
partnerInfo.addElement(
|
|
|
689 |
new Paragraph(StringUtils.capitalize(customer.getAddress().getName()), FONT_NORMAL));
|
|
|
690 |
partnerInfo.addElement(new Paragraph(
|
|
|
691 |
StringUtils.capitalize(customer.getAddress().getLine1()) + ", " + (customer.getAddress().getLine2() == null ? "" : StringUtils.capitalize(customer.getAddress().getLine2())) + ", " + customer.getAddress().getCity() + " - " + customer.getAddress().getPinCode(), FONT_NORMAL));
|
| 23654 |
amit.gupta |
692 |
|
| 32275 |
tejbeer |
693 |
partnerInfo.addElement(new Paragraph(
|
|
|
694 |
StringUtils.capitalize(customer.getAddress().getState()) + "(" + pdfModel.getCustomerAddressStateCode() + ")", FONT_NORMAL));
|
|
|
695 |
partnerInfo.addElement(new Paragraph("Mobile - " + customer.getMobileNumber(), FONT_NORMAL));
|
|
|
696 |
if (customer.getGstNumber() != null && !customer.getGstNumber().isEmpty()) {
|
|
|
697 |
partnerInfo.addElement(new Paragraph("GST No - " + customer.getGstNumber(), FONT_BOLD));
|
|
|
698 |
}
|
| 23654 |
amit.gupta |
699 |
|
| 32275 |
tejbeer |
700 |
PdfPCell sellerParty = new PdfPCell();
|
|
|
701 |
sellerParty.addElement(new Paragraph("From Party:", FONT_BOLD));
|
|
|
702 |
sellerParty.addElement(
|
|
|
703 |
new Paragraph(StringUtils.capitalize(retailer.getAddress().getName()), FONT_NORMAL));
|
|
|
704 |
sellerParty.addElement(new Paragraph((retailer.getAddress().getLine1() == null ? "" : StringUtils.capitalize(retailer.getAddress().getLine1()) + ", ") + (retailer.getAddress().getLine2() == null ? "" : StringUtils.capitalize(retailer.getAddress().getLine2()) + ", ") + StringUtils.capitalize(retailer.getAddress().getCity()) + "-" + retailer.getAddress().getPinCode() + ", ", FONT_NORMAL));
|
|
|
705 |
sellerParty.addElement(new Paragraph(
|
|
|
706 |
retailer.getAddress().getState() + "(" + pdfModel.getPartnerAddressStateCode() + ")", FONT_NORMAL));
|
|
|
707 |
sellerParty.addElement(new Paragraph("Mobile - " + retailer.getAddress().getPhoneNumber(), FONT_NORMAL));
|
|
|
708 |
sellerParty.addElement(new Paragraph("GST No - " + retailer.getGstNumber(), FONT_BOLD));
|
| 23654 |
amit.gupta |
709 |
|
| 32275 |
tejbeer |
710 |
PdfPTable tableInvoiceDateRetailer = new PdfPTable(1);
|
|
|
711 |
tableInvoiceDateRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 23654 |
amit.gupta |
712 |
|
| 32275 |
tejbeer |
713 |
PdfPTable tableInvoiceDate = new PdfPTable(2);
|
|
|
714 |
tableInvoiceDate.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
715 |
tableInvoiceDate.setWidthPercentage(90);
|
| 23654 |
amit.gupta |
716 |
|
| 32275 |
tejbeer |
717 |
PdfPCell debitNoteDetails = new PdfPCell(new Paragraph("Credit Note Details", FONT_BOLD));
|
|
|
718 |
debitNoteDetails.setColspan(2);
|
|
|
719 |
debitNoteDetails.setBorder(Rectangle.NO_BORDER);
|
| 23654 |
amit.gupta |
720 |
|
| 32275 |
tejbeer |
721 |
PdfPCell debitNoteNumberKey = new PdfPCell(new Paragraph("Credit Note No:", FONT_NORMAL));
|
|
|
722 |
debitNoteNumberKey.setBorder(Rectangle.NO_BORDER);
|
|
|
723 |
PdfPCell debitNoteNumberValue = new PdfPCell(
|
|
|
724 |
new Paragraph(creditNotePdfModel.getCreditNoteNumber(), FONT_NORMAL));
|
|
|
725 |
debitNoteNumberValue.setBorder(Rectangle.NO_BORDER);
|
| 23654 |
amit.gupta |
726 |
|
| 32275 |
tejbeer |
727 |
PdfPCell debitNoteDateKey = new PdfPCell(new Paragraph("Credit Note Dt:", FONT_NORMAL));
|
|
|
728 |
debitNoteDateKey.setBorder(Rectangle.NO_BORDER);
|
| 23654 |
amit.gupta |
729 |
|
| 32275 |
tejbeer |
730 |
PdfPCell debitNoteDateValue = new PdfPCell(
|
|
|
731 |
new Paragraph(creditNotePdfModel.getCreditNoteDate(), FONT_NORMAL));
|
|
|
732 |
debitNoteDateValue.setBorder(Rectangle.NO_BORDER);
|
|
|
733 |
tableInvoiceDate.addCell(debitNoteDetails);
|
|
|
734 |
tableInvoiceDate.addCell(debitNoteNumberKey);
|
|
|
735 |
tableInvoiceDate.addCell(debitNoteNumberValue);
|
|
|
736 |
tableInvoiceDate.addCell(debitNoteDateKey);
|
|
|
737 |
tableInvoiceDate.addCell(debitNoteDateValue);
|
| 32980 |
amit.gupta |
738 |
if (pdfModel.getInvoiceNumber() != null) {
|
| 32275 |
tejbeer |
739 |
PdfPCell dateKey = new PdfPCell(new Paragraph("Invoice Dt:", FONT_NORMAL));
|
|
|
740 |
dateKey.setBorder(Rectangle.NO_BORDER);
|
|
|
741 |
PdfPCell dateValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceDate(), FONT_NORMAL));
|
|
|
742 |
dateValue.setBorder(Rectangle.NO_BORDER);
|
| 23654 |
amit.gupta |
743 |
|
| 32275 |
tejbeer |
744 |
PdfPCell invoiceNumberKey = new PdfPCell(new Paragraph("Invoice Ref No:", FONT_NORMAL));
|
|
|
745 |
invoiceNumberKey.setBorder(Rectangle.NO_BORDER);
|
|
|
746 |
PdfPCell invoiceNumberValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceNumber(), FONT_NORMAL));
|
|
|
747 |
invoiceNumberValue.setBorder(Rectangle.NO_BORDER);
|
|
|
748 |
tableInvoiceDate.addCell(invoiceNumberKey);
|
|
|
749 |
tableInvoiceDate.addCell(invoiceNumberValue);
|
|
|
750 |
tableInvoiceDate.addCell(dateKey);
|
|
|
751 |
tableInvoiceDate.addCell(dateValue);
|
|
|
752 |
}
|
| 31008 |
amit.gupta |
753 |
|
| 32275 |
tejbeer |
754 |
tableCustomerRetailer.addCell(partnerInfo);
|
|
|
755 |
tableCustomerRetailer.addCell(tableInvoiceDate);
|
|
|
756 |
tableCustomerRetailer.addCell(sellerParty);
|
| 23654 |
amit.gupta |
757 |
|
| 32275 |
tejbeer |
758 |
PdfPTable orders = null;
|
|
|
759 |
if (stateGst) {
|
|
|
760 |
orders = new PdfPTable(stateWidthsCrNote.length);
|
|
|
761 |
orders.setWidths(stateWidthsCrNote);
|
|
|
762 |
} else {
|
|
|
763 |
orders = new PdfPTable(igstWidthsCrNote.length);
|
|
|
764 |
orders.setWidths(igstWidthsCrNote);
|
|
|
765 |
}
|
|
|
766 |
orders.setWidthPercentage(95);
|
|
|
767 |
orders.addCell(new Paragraph("Description", FONT_BOLD));
|
|
|
768 |
orders.addCell(new Paragraph("HSN", FONT_BOLD));
|
|
|
769 |
orders.addCell(new Paragraph("Qty", FONT_BOLD));
|
|
|
770 |
orders.addCell(new Paragraph("Rate\n(Per pc)", FONT_BOLD));
|
|
|
771 |
orders.addCell(new Paragraph("Total\nTaxable", FONT_BOLD));
|
|
|
772 |
if (!stateGst) {
|
|
|
773 |
orders.addCell(new Paragraph("IGST%", FONT_BOLD));
|
|
|
774 |
orders.addCell(new Paragraph("IGST", FONT_BOLD));
|
|
|
775 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1});
|
|
|
776 |
// total 8f
|
|
|
777 |
} else {
|
|
|
778 |
orders.addCell(new Paragraph("CGST %", FONT_BOLD));
|
|
|
779 |
orders.addCell(new Paragraph("CGST", FONT_BOLD));
|
|
|
780 |
orders.addCell(new Paragraph("SGST %", FONT_BOLD));
|
|
|
781 |
orders.addCell(new Paragraph("SGST", FONT_BOLD));
|
|
|
782 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1, 1,
|
|
|
783 |
// 1});
|
|
|
784 |
// total 8f
|
|
|
785 |
}
|
|
|
786 |
orders.addCell(new Paragraph("Total", FONT_BOLD));
|
| 23654 |
amit.gupta |
787 |
|
| 32275 |
tejbeer |
788 |
orders.setHeaderRows(1);
|
| 23654 |
amit.gupta |
789 |
|
| 32275 |
tejbeer |
790 |
float igstTotalAmount = 0, cgstTotalAmount = 0, sgstTotalAmount = 0;
|
|
|
791 |
for (CustomOrderItem orderItem : orderItems) {
|
|
|
792 |
LOGGER.info("Custom Order Item - {}", orderItem);
|
|
|
793 |
orders.addCell(new Paragraph(orderItem.getDescription(), FONT_NORMAL));
|
|
|
794 |
orders.addCell(new Paragraph(orderItem.getHsnCode(), FONT_NORMAL));
|
|
|
795 |
orders.addCell(new Paragraph(String.valueOf(orderItem.getQuantity()), FONT_NORMAL));
|
|
|
796 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getRate()), FONT_NORMAL));
|
|
|
797 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getAmount()), FONT_NORMAL));
|
|
|
798 |
if (!stateGst) {
|
|
|
799 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstRate()), FONT_NORMAL));
|
|
|
800 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstAmount()), FONT_NORMAL));
|
|
|
801 |
igstTotalAmount = igstTotalAmount + orderItem.getIgstAmount();
|
|
|
802 |
} else {
|
|
|
803 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstRate()), FONT_NORMAL));
|
|
|
804 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstAmount()), FONT_NORMAL));
|
|
|
805 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstRate()), FONT_NORMAL));
|
|
|
806 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstAmount()), FONT_NORMAL));
|
|
|
807 |
cgstTotalAmount = cgstTotalAmount + orderItem.getCgstAmount();
|
|
|
808 |
sgstTotalAmount = sgstTotalAmount + orderItem.getSgstAmount();
|
|
|
809 |
}
|
|
|
810 |
orders.addCell(new Paragraph(String.format("%.0f", orderItem.getNetAmount()), FONT_NORMAL));
|
|
|
811 |
LOGGER.info("IN FOR LOOP");
|
|
|
812 |
}
|
| 23654 |
amit.gupta |
813 |
|
| 32275 |
tejbeer |
814 |
document.add(paragraphTitle);
|
| 23654 |
amit.gupta |
815 |
|
| 32275 |
tejbeer |
816 |
document.add(Chunk.NEWLINE);
|
|
|
817 |
document.add(tableCustomerRetailer);
|
| 23654 |
amit.gupta |
818 |
|
| 32275 |
tejbeer |
819 |
document.add(Chunk.NEWLINE);
|
|
|
820 |
document.add(orders);
|
| 23654 |
amit.gupta |
821 |
|
| 32275 |
tejbeer |
822 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
|
|
823 |
if (stateGst) {
|
|
|
824 |
grandTotalTable.setWidths(new float[]{6.6f, .6f, .8f});
|
|
|
825 |
} else {
|
|
|
826 |
grandTotalTable.setWidths(new float[]{6.5f, .6f, .9f});
|
|
|
827 |
}
|
|
|
828 |
grandTotalTable.setWidthPercentage(95);
|
| 23654 |
amit.gupta |
829 |
|
| 32275 |
tejbeer |
830 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
|
|
831 |
grandTotalParagraph.setIndentationRight(20);
|
|
|
832 |
grandTotalTable.addCell(grandTotalParagraph);
|
|
|
833 |
Paragraph rsParagraph = new Paragraph("Rs.", FONT_BOLD);
|
|
|
834 |
grandTotalTable.addCell(rsParagraph);
|
|
|
835 |
Paragraph amountParagraph = new Paragraph(String.format("%.2f", pdfModel.getTotalAmount()), FONT_BOLD);
|
|
|
836 |
grandTotalTable.addCell(amountParagraph);
|
| 23654 |
amit.gupta |
837 |
|
| 32275 |
tejbeer |
838 |
document.add(grandTotalTable);
|
| 23654 |
amit.gupta |
839 |
|
| 32275 |
tejbeer |
840 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
|
|
841 |
if (!stateGst) {
|
|
|
842 |
amountInWordsTable.setWidths(new float[]{2, 5.1f, 0.9f});
|
|
|
843 |
} else {
|
|
|
844 |
amountInWordsTable.setWidths(new float[]{2, 5.2f, 0.8f});
|
|
|
845 |
}
|
|
|
846 |
amountInWordsTable.setWidthPercentage(95);
|
|
|
847 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
| 23654 |
amit.gupta |
848 |
|
| 32275 |
tejbeer |
849 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
|
|
850 |
amountInWordsTable.addCell(new Paragraph(amountInWords.toString(), FONT_BOLD));
|
|
|
851 |
amountInWordsTable.addCell(new Paragraph("E & O.E", FONT_NORMAL));
|
|
|
852 |
document.add(amountInWordsTable);
|
| 23654 |
amit.gupta |
853 |
|
| 32275 |
tejbeer |
854 |
document.newPage();
|
|
|
855 |
}
|
|
|
856 |
document.close(); // no need to close PDFwriter?
|
|
|
857 |
} catch (DocumentException e) {
|
|
|
858 |
LOGGER.error("Unable to write data to pdf file : ", e);
|
|
|
859 |
} catch (Exception e) {
|
|
|
860 |
// TODO Auto-generated catch block
|
|
|
861 |
e.printStackTrace();
|
|
|
862 |
}
|
| 23654 |
amit.gupta |
863 |
|
| 32275 |
tejbeer |
864 |
}
|
| 21686 |
ashik.ali |
865 |
}
|