| Line 28... |
Line 28... |
| 28 |
// Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD);
|
28 |
// Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD);
|
| 29 |
public static final String INVOICE_TITLE = "TAX INVOICE";
|
29 |
public static final String INVOICE_TITLE = "TAX INVOICE";
|
| 30 |
public static final String DEBIT_NOTE_TITLE = "DEBIT NOTE";
|
30 |
public static final String DEBIT_NOTE_TITLE = "DEBIT NOTE";
|
| 31 |
public static final String SECURITY_DEPOSIT = "SECURITY DEPOSIT RECEIPT";
|
31 |
public static final String SECURITY_DEPOSIT = "SECURITY DEPOSIT RECEIPT";
|
| 32 |
|
32 |
|
| 33 |
private static float[] igstWidthsWithDiscount = new float[] { .2f, 2.6f, 0.7f, .4f, 0.7f, 0.6f, .7f, .6f,
|
33 |
private static float[] igstWidthsWithDiscount = new float[]{.2f, 2.6f, 0.7f, .4f, 0.7f, 0.6f, .7f, .6f,
|
| 34 |
0.7f };
|
34 |
0.7f};
|
| 35 |
private static float[] stateWidthsWithDiscount = new float[] { .2f, 2.1f, 0.7f, .3f, 0.6f, 0.5f, .7f, .6f,
|
35 |
private static float[] stateWidthsWithDiscount = new float[]{.2f, 2.1f, 0.7f, .3f, 0.6f, 0.5f, .7f, .6f,
|
| 36 |
.6f, .7f };
|
36 |
.6f, .7f};
|
| 37 |
|
37 |
|
| 38 |
private static float[] igstWidths = new float[] { .6f, 2.6f, 0.7f, .4f, 0.7f, .7f, .6f, 0.6f, 0.9f };
|
38 |
private static float[] igstWidths = new float[]{.6f, 2.6f, 0.7f, .4f, 0.7f, .7f, .6f, 0.6f, 0.9f};
|
| 39 |
private static float[] stateWidths = new float[] { .6f, 2.1f, 0.7f, .3f, 0.6f, .7f, .5f, .6f, .5f, .6f, .8f };
|
39 |
private static float[] stateWidths = new float[]{.6f, 2.1f, 0.7f, .3f, 0.6f, .7f, .5f, .6f, .5f, .6f, .8f};
|
| 40 |
|
40 |
|
| 41 |
private static float[] igstWidthsCrNote = new float[] { 2.6f, 0.7f, .4f, 0.7f, .7f, .6f, 0.6f, 0.9f };
|
41 |
private static float[] igstWidthsCrNote = new float[]{2.6f, 0.7f, .4f, 0.7f, .7f, .6f, 0.6f, 0.9f};
|
| 42 |
private static float[] stateWidthsCrNote = new float[] { 2.1f, 0.7f, .3f, 0.6f, .7f, .5f, .6f, .5f, .6f, .8f };
|
42 |
private static float[] stateWidthsCrNote = new float[]{2.1f, 0.7f, .3f, 0.6f, .7f, .5f, .6f, .5f, .6f, .8f};
|
| 43 |
|
43 |
|
| 44 |
private static final Locale indianLocale = Locale.getDefault();
|
44 |
private static final Locale indianLocale = Locale.getDefault();
|
| 45 |
|
45 |
|
| 46 |
private static final Logger LOGGER = LogManager.getLogger(PdfUtils.class);
|
46 |
private static final Logger LOGGER = LogManager.getLogger(PdfUtils.class);
|
| 47 |
|
47 |
|
| 48 |
private static final URL iconUrl = PdfUtils.class.getClassLoader().getResource("sdlogo.png");
|
48 |
private static final URL iconUrl = PdfUtils.class.getClassLoader().getResource("sdlogo.png");
|
| 49 |
private static Image iconImg = null;
|
49 |
private static Image iconImg = null;
|
| - |
|
50 |
|
| 50 |
static {
|
51 |
static {
|
| 51 |
try {
|
52 |
try {
|
| 52 |
iconImg = Image.getInstance(iconUrl);
|
53 |
iconImg = Image.getInstance(iconUrl);
|
| 53 |
} catch (Exception e) {
|
54 |
} catch (Exception e) {
|
| 54 |
e.printStackTrace();
|
55 |
e.printStackTrace();
|
| 55 |
}
|
56 |
}
|
| 56 |
}
|
57 |
}
|
| 57 |
|
58 |
|
| 58 |
//Debit Note generation logic has been changed
|
59 |
//Debit Note generation logic has been changed
|
| 59 |
//Debit Note considers price drops so amount in debit note is current price of item.
|
60 |
//Debit Note considers price drops so amount in debit note is current price of item.
|
| 60 |
//From 16Nov 2019 onwards all debit notes will be as per actuall billing value, all pricedrops
|
61 |
//From 16Nov 2019 onwards all debit notes will be as per actuall billing value, all pricedrops
|
| 61 |
//shall be rolledback or cancelled once the debit note is generated.
|
62 |
//shall be rolledback or cancelled once the debit note is generated.
|
| 62 |
|
63 |
|
| 63 |
|
64 |
|
| 64 |
public static void generateAndWrite(List<InvoicePdfModel> pdfModels, ByteArrayOutputStream outputStream) {
|
65 |
public static void generateAndWrite(List<InvoicePdfModel> pdfModels, ByteArrayOutputStream outputStream) {
|
| 65 |
try {
|
66 |
try {
|
| 66 |
List<Integer> caneclledPageList = new ArrayList<>();
|
67 |
List<Integer> caneclledPageList = new ArrayList<>();
|
| 67 |
Document document = new Document();
|
68 |
Document document = new Document();
|
| Line 93... |
Line 94... |
| 93 |
tableCustomerRetailer.setWidthPercentage(90);
|
94 |
tableCustomerRetailer.setWidthPercentage(90);
|
| 94 |
tableCustomerRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
95 |
tableCustomerRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 95 |
PdfPCell columnCustomerInfo = new PdfPCell();
|
96 |
PdfPCell columnCustomerInfo = new PdfPCell();
|
| 96 |
columnCustomerInfo.addElement(new Paragraph("Customer Details", FONT_BOLD));
|
97 |
columnCustomerInfo.addElement(new Paragraph("Customer Details", FONT_BOLD));
|
| 97 |
columnCustomerInfo.addElement(new Paragraph(
|
98 |
columnCustomerInfo.addElement(new Paragraph(
|
| 98 |
StringUtils.capitalize(customer.getAddress().getName() +
|
99 |
StringUtils.capitalize(customer.getAddress().getName() +
|
| 99 |
(customer.getAddress().getLastName()==null?"" : " " + customer.getAddress().getLastName())),
|
100 |
(customer.getAddress().getLastName() == null ? "" : " " + customer.getAddress().getLastName())),
|
| 100 |
FONT_NORMAL));
|
101 |
FONT_NORMAL));
|
| 101 |
columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getLine1())
|
102 |
columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getLine1())
|
| 102 |
+ ", " + StringUtils.capitalize(customer.getAddress().getLine2()), FONT_NORMAL));
|
103 |
+ ", " + StringUtils.capitalize(customer.getAddress().getLine2()), FONT_NORMAL));
|
| 103 |
columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getCity())
|
104 |
columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getCity())
|
| 104 |
+ ", " + StringUtils.capitalize(customer.getAddress().getState()) + "("
|
105 |
+ ", " + StringUtils.capitalize(customer.getAddress().getState()) + "("
|
| Line 208... |
Line 209... |
| 208 |
}
|
209 |
}
|
| 209 |
orders.addCell(new Paragraph(String.format("%.0f", orderItem.getNetAmount()), FONT_NORMAL));
|
210 |
orders.addCell(new Paragraph(String.format("%.0f", orderItem.getNetAmount()), FONT_NORMAL));
|
| 210 |
// orders.addCell(new Paragraph(String.format("%.2f",
|
211 |
// orders.addCell(new Paragraph(String.format("%.2f",
|
| 211 |
// orderItem.getItemTotal()), FONT_NORMAL));
|
212 |
// orderItem.getItemTotal()), FONT_NORMAL));
|
| 212 |
}
|
213 |
}
|
| 213 |
|
- |
|
| - |
|
214 |
if (pdfModel.getInsurancePolicies() != null) {
|
| 214 |
for (CustomInsurancePolicy insurancePolicy : pdfModel.getInsurancePolicies()) {
|
215 |
for (CustomInsurancePolicy insurancePolicy : pdfModel.getInsurancePolicies()) {
|
| 215 |
orders.addCell(new Paragraph(String.valueOf(index++), FONT_NORMAL));
|
216 |
orders.addCell(new Paragraph(String.valueOf(index++), FONT_NORMAL));
|
| 216 |
orders.addCell(new Paragraph(insurancePolicy.getDescription(), FONT_NORMAL));
|
217 |
orders.addCell(new Paragraph(insurancePolicy.getDescription(), FONT_NORMAL));
|
| 217 |
orders.addCell(new Paragraph(insurancePolicy.getHsnCode(), FONT_NORMAL));
|
218 |
orders.addCell(new Paragraph(insurancePolicy.getHsnCode(), FONT_NORMAL));
|
| 218 |
orders.addCell(new Paragraph("1", FONT_NORMAL));
|
219 |
orders.addCell(new Paragraph("1", FONT_NORMAL));
|
| 219 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
|
220 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
|
| 220 |
orders.addCell(new Paragraph("-", FONT_NORMAL));
|
221 |
orders.addCell(new Paragraph("-", FONT_NORMAL));
|
| 221 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
|
222 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
|
| 222 |
if (!stateGst) {
|
223 |
if (!stateGst) {
|
| 223 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", insurancePolicy.getIgstAmount(), insurancePolicy.getIgstRate()), FONT_NORMAL));
|
224 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", insurancePolicy.getIgstAmount(), insurancePolicy.getIgstRate()), FONT_NORMAL));
|
| 224 |
igstTotalAmount = igstTotalAmount + insurancePolicy.getIgstAmount();
|
225 |
igstTotalAmount = igstTotalAmount + insurancePolicy.getIgstAmount();
|
| 225 |
} else {
|
226 |
} else {
|
| 226 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", insurancePolicy.getCgstAmount(), insurancePolicy.getCgstRate()), FONT_NORMAL));
|
227 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", insurancePolicy.getCgstAmount(), insurancePolicy.getCgstRate()), FONT_NORMAL));
|
| 227 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", insurancePolicy.getSgstAmount(), insurancePolicy.getSgstRate()), FONT_NORMAL));
|
228 |
orders.addCell(new Paragraph(String.format("%.2f%n(@%.0f%%)", insurancePolicy.getSgstAmount(), insurancePolicy.getSgstRate()), FONT_NORMAL));
|
| 228 |
cgstTotalAmount = cgstTotalAmount + insurancePolicy.getCgstAmount();
|
229 |
cgstTotalAmount = cgstTotalAmount + insurancePolicy.getCgstAmount();
|
| 229 |
sgstTotalAmount = sgstTotalAmount + insurancePolicy.getSgstAmount();
|
230 |
sgstTotalAmount = sgstTotalAmount + insurancePolicy.getSgstAmount();
|
| - |
|
231 |
}
|
| - |
|
232 |
orders.addCell(new Paragraph(String.format("%.0f", insurancePolicy.getNetAmount()), FONT_NORMAL));
|
| 230 |
}
|
233 |
}
|
| 231 |
orders.addCell(new Paragraph(String.format("%.0f", insurancePolicy.getNetAmount()), FONT_NORMAL));
|
- |
|
| 232 |
}
|
234 |
}
|
| 233 |
Rectangle rectangle = document.getPageSize();
|
235 |
Rectangle rectangle = document.getPageSize();
|
| 234 |
iconImg.setAbsolutePosition(25, rectangle.getHeight() - 100);
|
236 |
iconImg.setAbsolutePosition(25, rectangle.getHeight() - 100);
|
| 235 |
iconImg.scalePercent(30);
|
237 |
iconImg.scalePercent(30);
|
| - |
|
238 |
|
| - |
|
239 |
if (pdfModel.getQrCode() != null) {
|
| - |
|
240 |
Image img = Image.getInstance(pdfModel.getQrCode().toURI().toURL());
|
| - |
|
241 |
img.setAbsolutePosition(450f, rectangle.getHeight() - 140);
|
| - |
|
242 |
document.add(img);
|
| - |
|
243 |
}
|
| 236 |
document.add(iconImg);
|
244 |
document.add(iconImg);
|
| 237 |
document.add(paragraphTitle);
|
245 |
document.add(paragraphTitle);
|
| 238 |
document.add(Chunk.NEWLINE);
|
246 |
document.add(Chunk.NEWLINE);
|
| 239 |
document.add(Chunk.NEWLINE);
|
247 |
document.add(Chunk.NEWLINE);
|
| 240 |
document.add(tableCustomerRetailer);
|
248 |
document.add(tableCustomerRetailer);
|
| Line 243... |
Line 251... |
| 243 |
document.add(orders);
|
251 |
document.add(orders);
|
| 244 |
|
252 |
|
| 245 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
253 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
| 246 |
PdfPTable paymentsTable = new PdfPTable(2);
|
254 |
PdfPTable paymentsTable = new PdfPTable(2);
|
| 247 |
paymentsTable.setWidthPercentage(95);
|
255 |
paymentsTable.setWidthPercentage(95);
|
| 248 |
paymentsTable.setWidths(new float[] { 8f, 2f });
|
256 |
paymentsTable.setWidths(new float[]{8f, 2f});
|
| 249 |
|
257 |
|
| 250 |
if (stateGst) {
|
258 |
if (stateGst) {
|
| 251 |
grandTotalTable.setWidths(new float[] { 6.6f, .6f, .8f });
|
259 |
grandTotalTable.setWidths(new float[]{6.6f, .6f, .8f});
|
| 252 |
} else {
|
260 |
} else {
|
| 253 |
grandTotalTable.setWidths(new float[] { 6.5f, .6f, .9f });
|
261 |
grandTotalTable.setWidths(new float[]{6.5f, .6f, .9f});
|
| 254 |
}
|
262 |
}
|
| 255 |
grandTotalTable.setWidthPercentage(90);
|
263 |
grandTotalTable.setWidthPercentage(90);
|
| 256 |
|
264 |
|
| 257 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
265 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
| 258 |
grandTotalParagraph.setIndentationRight(20);
|
266 |
grandTotalParagraph.setIndentationRight(20);
|
| Line 266... |
Line 274... |
| 266 |
|
274 |
|
| 267 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
275 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
| 268 |
amountInWordsTable.setWidthPercentage(90);
|
276 |
amountInWordsTable.setWidthPercentage(90);
|
| 269 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
277 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
| 270 |
if (!stateGst) {
|
278 |
if (!stateGst) {
|
| 271 |
amountInWordsTable.setWidths(new float[] { 2, 5.1f, 0.9f });
|
279 |
amountInWordsTable.setWidths(new float[]{2, 5.1f, 0.9f});
|
| 272 |
} else {
|
280 |
} else {
|
| 273 |
amountInWordsTable.setWidths(new float[] { 2, 5.2f, 0.8f });
|
281 |
amountInWordsTable.setWidths(new float[]{2, 5.2f, 0.8f});
|
| 274 |
}
|
282 |
}
|
| 275 |
|
283 |
|
| 276 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
284 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
| 277 |
amountInWordsTable.addCell(new Paragraph(amountInWords.toString(), FONT_BOLD));
|
285 |
amountInWordsTable.addCell(new Paragraph(amountInWords.toString(), FONT_BOLD));
|
| 278 |
amountInWordsTable.addCell(new Paragraph("E & O.E", FONT_NORMAL));
|
286 |
amountInWordsTable.addCell(new Paragraph("E & O.E", FONT_NORMAL));
|
| Line 280... |
Line 288... |
| 280 |
|
288 |
|
| 281 |
if (pdfModel.getPaymentOptions() != null) {
|
289 |
if (pdfModel.getPaymentOptions() != null) {
|
| 282 |
PdfPTable paidAmountTable = new PdfPTable(2);
|
290 |
PdfPTable paidAmountTable = new PdfPTable(2);
|
| 283 |
paidAmountTable.setWidthPercentage(90);
|
291 |
paidAmountTable.setWidthPercentage(90);
|
| 284 |
if (!stateGst) {
|
292 |
if (!stateGst) {
|
| 285 |
paidAmountTable.setWidths(new float[] { 7.1f, 0.9f });
|
293 |
paidAmountTable.setWidths(new float[]{7.1f, 0.9f});
|
| 286 |
} else {
|
294 |
} else {
|
| 287 |
paidAmountTable.setWidths(new float[] { 7.2f, 0.8f });
|
295 |
paidAmountTable.setWidths(new float[]{7.2f, 0.8f});
|
| 288 |
}
|
296 |
}
|
| 289 |
float totalPaidValue = 0;
|
297 |
float totalPaidValue = 0;
|
| 290 |
for (CustomPaymentOption paymentOption : pdfModel.getPaymentOptions()) {
|
298 |
for (CustomPaymentOption paymentOption : pdfModel.getPaymentOptions()) {
|
| 291 |
PdfPCell cell = new PdfPCell(
|
299 |
PdfPCell cell = new PdfPCell(
|
| 292 |
new Paragraph(10, "Paid Through " + paymentOption.getPaymentOption(), FONT_BOLD));
|
300 |
new Paragraph(10, "Paid Through " + paymentOption.getPaymentOption(), FONT_BOLD));
|
| Line 312... |
Line 320... |
| 312 |
paidAmountTable.addCell(totalPaidValueCell);
|
320 |
paidAmountTable.addCell(totalPaidValueCell);
|
| 313 |
|
321 |
|
| 314 |
document.add(paidAmountTable);
|
322 |
document.add(paidAmountTable);
|
| 315 |
}
|
323 |
}
|
| 316 |
|
324 |
|
| - |
|
325 |
if (pdfModel.getTncs() != null) {
|
| 317 |
StringBuffer sb = new StringBuffer();
|
326 |
StringBuffer sb = new StringBuffer();
|
| 318 |
List<String> tncs = pdfModel.getTncs();
|
327 |
for (String tnc : pdfModel.getTncs()) {
|
| 319 |
for (String tnc : tncs) {
|
328 |
sb.append(tnc).append("\n");
|
| - |
|
329 |
}
|
| - |
|
330 |
Paragraph warningParagraph = new Paragraph(sb.toString(), FONT_NORMAL);
|
| - |
|
331 |
warningParagraph.setIndentationLeft(40);
|
| - |
|
332 |
document.add(Chunk.NEWLINE);
|
| 320 |
sb.append(tnc).append("\n");
|
333 |
document.add(warningParagraph);
|
| 321 |
}
|
334 |
}
|
| 322 |
|
335 |
|
| 323 |
Paragraph warningParagraph = new Paragraph(sb.toString(), FONT_NORMAL);
|
- |
|
| 324 |
warningParagraph.setIndentationLeft(40);
|
- |
|
| 325 |
document.add(Chunk.NEWLINE);
|
- |
|
| 326 |
document.add(warningParagraph);
|
- |
|
| 327 |
document.newPage();
|
336 |
document.newPage();
|
| 328 |
}
|
337 |
}
|
| 329 |
document.close(); // no need to close PDFwriter?
|
338 |
document.close(); // no need to close PDFwriter?
|
| 330 |
stampCancelled(outputStream, caneclledPageList);
|
339 |
stampCancelled(outputStream, caneclledPageList);
|
| 331 |
|
340 |
|
| Line 390... |
Line 399... |
| 390 |
baos.writeTo(byteStream);
|
399 |
baos.writeTo(byteStream);
|
| 391 |
|
400 |
|
| 392 |
}
|
401 |
}
|
| 393 |
|
402 |
|
| 394 |
public static void generateAndWriteDebitNote(List<DebitNotePdfModel> debitNotePdfModels,
|
403 |
public static void generateAndWriteDebitNote(List<DebitNotePdfModel> debitNotePdfModels,
|
| 395 |
OutputStream outputStream) {
|
404 |
OutputStream outputStream) {
|
| 396 |
Document document = new Document();
|
405 |
Document document = new Document();
|
| 397 |
document.setMargins(0, 0, 25, 0);
|
406 |
document.setMargins(0, 0, 25, 0);
|
| 398 |
try {
|
407 |
try {
|
| 399 |
for (DebitNotePdfModel debitNotePdfModel : debitNotePdfModels) {
|
408 |
for (DebitNotePdfModel debitNotePdfModel : debitNotePdfModels) {
|
| 400 |
|
409 |
|
| Line 431... |
Line 440... |
| 431 |
partnerInfo.addElement(
|
440 |
partnerInfo.addElement(
|
| 432 |
new Paragraph(StringUtils.capitalize(customer.getAddress().getName()), FONT_NORMAL));
|
441 |
new Paragraph(StringUtils.capitalize(customer.getAddress().getName()), FONT_NORMAL));
|
| 433 |
partnerInfo.addElement(new Paragraph(
|
442 |
partnerInfo.addElement(new Paragraph(
|
| 434 |
StringUtils.capitalize(customer.getAddress().getLine1()) + ", "
|
443 |
StringUtils.capitalize(customer.getAddress().getLine1()) + ", "
|
| 435 |
+ (customer.getAddress().getLine2() == null ? ""
|
444 |
+ (customer.getAddress().getLine2() == null ? ""
|
| 436 |
: StringUtils.capitalize(customer.getAddress().getLine2()))
|
445 |
: StringUtils.capitalize(customer.getAddress().getLine2()))
|
| 437 |
+ ", " + customer.getAddress().getCity() + " - " + customer.getAddress().getPinCode(),
|
446 |
+ ", " + customer.getAddress().getCity() + " - " + customer.getAddress().getPinCode(),
|
| 438 |
FONT_NORMAL));
|
447 |
FONT_NORMAL));
|
| 439 |
|
448 |
|
| 440 |
partnerInfo.addElement(new Paragraph(
|
449 |
partnerInfo.addElement(new Paragraph(
|
| 441 |
StringUtils.capitalize(customer.getAddress().getState()) + "(" + customerAddressStateCode + ")",
|
450 |
StringUtils.capitalize(customer.getAddress().getState()) + "(" + customerAddressStateCode + ")",
|
| Line 450... |
Line 459... |
| 450 |
sellerParty.addElement(
|
459 |
sellerParty.addElement(
|
| 451 |
new Paragraph(StringUtils.capitalize(retailer.getAddress().getName()), FONT_NORMAL));
|
460 |
new Paragraph(StringUtils.capitalize(retailer.getAddress().getName()), FONT_NORMAL));
|
| 452 |
sellerParty.addElement(new Paragraph((retailer.getAddress().getLine1() == null ? ""
|
461 |
sellerParty.addElement(new Paragraph((retailer.getAddress().getLine1() == null ? ""
|
| 453 |
: StringUtils.capitalize(retailer.getAddress().getLine1()) + ", ")
|
462 |
: StringUtils.capitalize(retailer.getAddress().getLine1()) + ", ")
|
| 454 |
+ (retailer.getAddress().getLine2() == null ? ""
|
463 |
+ (retailer.getAddress().getLine2() == null ? ""
|
| 455 |
: StringUtils.capitalize(retailer.getAddress().getLine2()) + ", ")
|
464 |
: StringUtils.capitalize(retailer.getAddress().getLine2()) + ", ")
|
| 456 |
+ StringUtils.capitalize(retailer.getAddress().getCity()) + "-"
|
465 |
+ StringUtils.capitalize(retailer.getAddress().getCity()) + "-"
|
| 457 |
+ retailer.getAddress().getPinCode() + ", ", FONT_NORMAL));
|
466 |
+ retailer.getAddress().getPinCode() + ", ", FONT_NORMAL));
|
| 458 |
sellerParty.addElement(new Paragraph(
|
467 |
sellerParty.addElement(new Paragraph(
|
| 459 |
retailer.getAddress().getState() + "(" + retailerAddressStateCode + ")", FONT_NORMAL));
|
468 |
retailer.getAddress().getState() + "(" + retailerAddressStateCode + ")", FONT_NORMAL));
|
| 460 |
sellerParty
|
469 |
sellerParty
|
| Line 574... |
Line 583... |
| 574 |
document.add(Chunk.NEWLINE);
|
583 |
document.add(Chunk.NEWLINE);
|
| 575 |
document.add(orders);
|
584 |
document.add(orders);
|
| 576 |
|
585 |
|
| 577 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
586 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
| 578 |
if (stateGst) {
|
587 |
if (stateGst) {
|
| 579 |
grandTotalTable.setWidths(new float[] { 6.6f, .6f, .8f });
|
588 |
grandTotalTable.setWidths(new float[]{6.6f, .6f, .8f});
|
| 580 |
} else {
|
589 |
} else {
|
| 581 |
grandTotalTable.setWidths(new float[] { 6.5f, .6f, .9f });
|
590 |
grandTotalTable.setWidths(new float[]{6.5f, .6f, .9f});
|
| 582 |
}
|
591 |
}
|
| 583 |
grandTotalTable.setWidthPercentage(95);
|
592 |
grandTotalTable.setWidthPercentage(95);
|
| 584 |
|
593 |
|
| 585 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
594 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
| 586 |
grandTotalParagraph.setIndentationRight(20);
|
595 |
grandTotalParagraph.setIndentationRight(20);
|
| Line 592... |
Line 601... |
| 592 |
|
601 |
|
| 593 |
document.add(grandTotalTable);
|
602 |
document.add(grandTotalTable);
|
| 594 |
|
603 |
|
| 595 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
604 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
| 596 |
if (!stateGst) {
|
605 |
if (!stateGst) {
|
| 597 |
amountInWordsTable.setWidths(new float[] { 2, 5.1f, 0.9f });
|
606 |
amountInWordsTable.setWidths(new float[]{2, 5.1f, 0.9f});
|
| 598 |
} else {
|
607 |
} else {
|
| 599 |
amountInWordsTable.setWidths(new float[] { 2, 5.2f, 0.8f });
|
608 |
amountInWordsTable.setWidths(new float[]{2, 5.2f, 0.8f});
|
| 600 |
}
|
609 |
}
|
| 601 |
amountInWordsTable.setWidthPercentage(95);
|
610 |
amountInWordsTable.setWidthPercentage(95);
|
| 602 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
611 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
| 603 |
|
612 |
|
| 604 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
613 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
| Line 627... |
Line 636... |
| 627 |
amountInWords.append(" paise");
|
636 |
amountInWords.append(" paise");
|
| 628 |
return amountInWords.toString();
|
637 |
return amountInWords.toString();
|
| 629 |
}
|
638 |
}
|
| 630 |
|
639 |
|
| 631 |
public static void generateAndWriteCustomerCreditNotes(List<CreditNotePdfModel> creditNotes,
|
640 |
public static void generateAndWriteCustomerCreditNotes(List<CreditNotePdfModel> creditNotes,
|
| 632 |
OutputStream outputStream) {
|
641 |
OutputStream outputStream) {
|
| 633 |
Document document = new Document();
|
642 |
Document document = new Document();
|
| 634 |
document.setMargins(0, 0, 25, 0);
|
643 |
document.setMargins(0, 0, 25, 0);
|
| 635 |
try {
|
644 |
try {
|
| 636 |
PdfWriter.getInstance(document, outputStream);
|
645 |
PdfWriter.getInstance(document, outputStream);
|
| 637 |
|
646 |
|
| Line 666... |
Line 675... |
| 666 |
partnerInfo.addElement(
|
675 |
partnerInfo.addElement(
|
| 667 |
new Paragraph(StringUtils.capitalize(customer.getAddress().getName()), FONT_NORMAL));
|
676 |
new Paragraph(StringUtils.capitalize(customer.getAddress().getName()), FONT_NORMAL));
|
| 668 |
partnerInfo.addElement(new Paragraph(
|
677 |
partnerInfo.addElement(new Paragraph(
|
| 669 |
StringUtils.capitalize(customer.getAddress().getLine1()) + ", "
|
678 |
StringUtils.capitalize(customer.getAddress().getLine1()) + ", "
|
| 670 |
+ (customer.getAddress().getLine2() == null ? ""
|
679 |
+ (customer.getAddress().getLine2() == null ? ""
|
| 671 |
: StringUtils.capitalize(customer.getAddress().getLine2()))
|
680 |
: StringUtils.capitalize(customer.getAddress().getLine2()))
|
| 672 |
+ ", " + customer.getAddress().getCity() + " - " + customer.getAddress().getPinCode(),
|
681 |
+ ", " + customer.getAddress().getCity() + " - " + customer.getAddress().getPinCode(),
|
| 673 |
FONT_NORMAL));
|
682 |
FONT_NORMAL));
|
| 674 |
|
683 |
|
| 675 |
partnerInfo.addElement(new Paragraph(
|
684 |
partnerInfo.addElement(new Paragraph(
|
| 676 |
StringUtils.capitalize(customer.getAddress().getState()) + "(" + customerAddressStateCode + ")",
|
685 |
StringUtils.capitalize(customer.getAddress().getState()) + "(" + customerAddressStateCode + ")",
|
| Line 685... |
Line 694... |
| 685 |
sellerParty.addElement(
|
694 |
sellerParty.addElement(
|
| 686 |
new Paragraph(StringUtils.capitalize(retailer.getAddress().getName()), FONT_NORMAL));
|
695 |
new Paragraph(StringUtils.capitalize(retailer.getAddress().getName()), FONT_NORMAL));
|
| 687 |
sellerParty.addElement(new Paragraph((retailer.getAddress().getLine1() == null ? ""
|
696 |
sellerParty.addElement(new Paragraph((retailer.getAddress().getLine1() == null ? ""
|
| 688 |
: StringUtils.capitalize(retailer.getAddress().getLine1()) + ", ")
|
697 |
: StringUtils.capitalize(retailer.getAddress().getLine1()) + ", ")
|
| 689 |
+ (retailer.getAddress().getLine2() == null ? ""
|
698 |
+ (retailer.getAddress().getLine2() == null ? ""
|
| 690 |
: StringUtils.capitalize(retailer.getAddress().getLine2()) + ", ")
|
699 |
: StringUtils.capitalize(retailer.getAddress().getLine2()) + ", ")
|
| 691 |
+ StringUtils.capitalize(retailer.getAddress().getCity()) + "-"
|
700 |
+ StringUtils.capitalize(retailer.getAddress().getCity()) + "-"
|
| 692 |
+ retailer.getAddress().getPinCode() + ", ", FONT_NORMAL));
|
701 |
+ retailer.getAddress().getPinCode() + ", ", FONT_NORMAL));
|
| 693 |
sellerParty.addElement(new Paragraph(
|
702 |
sellerParty.addElement(new Paragraph(
|
| 694 |
retailer.getAddress().getState() + "(" + retailerAddressStateCode + ")", FONT_NORMAL));
|
703 |
retailer.getAddress().getState() + "(" + retailerAddressStateCode + ")", FONT_NORMAL));
|
| 695 |
sellerParty
|
704 |
sellerParty
|
| Line 808... |
Line 817... |
| 808 |
document.add(Chunk.NEWLINE);
|
817 |
document.add(Chunk.NEWLINE);
|
| 809 |
document.add(orders);
|
818 |
document.add(orders);
|
| 810 |
|
819 |
|
| 811 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
820 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
| 812 |
if (stateGst) {
|
821 |
if (stateGst) {
|
| 813 |
grandTotalTable.setWidths(new float[] { 6.6f, .6f, .8f });
|
822 |
grandTotalTable.setWidths(new float[]{6.6f, .6f, .8f});
|
| 814 |
} else {
|
823 |
} else {
|
| 815 |
grandTotalTable.setWidths(new float[] { 6.5f, .6f, .9f });
|
824 |
grandTotalTable.setWidths(new float[]{6.5f, .6f, .9f});
|
| 816 |
}
|
825 |
}
|
| 817 |
grandTotalTable.setWidthPercentage(95);
|
826 |
grandTotalTable.setWidthPercentage(95);
|
| 818 |
|
827 |
|
| 819 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
828 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
| 820 |
grandTotalParagraph.setIndentationRight(20);
|
829 |
grandTotalParagraph.setIndentationRight(20);
|
| Line 826... |
Line 835... |
| 826 |
|
835 |
|
| 827 |
document.add(grandTotalTable);
|
836 |
document.add(grandTotalTable);
|
| 828 |
|
837 |
|
| 829 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
838 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
| 830 |
if (!stateGst) {
|
839 |
if (!stateGst) {
|
| 831 |
amountInWordsTable.setWidths(new float[] { 2, 5.1f, 0.9f });
|
840 |
amountInWordsTable.setWidths(new float[]{2, 5.1f, 0.9f});
|
| 832 |
} else {
|
841 |
} else {
|
| 833 |
amountInWordsTable.setWidths(new float[] { 2, 5.2f, 0.8f });
|
842 |
amountInWordsTable.setWidths(new float[]{2, 5.2f, 0.8f});
|
| 834 |
}
|
843 |
}
|
| 835 |
amountInWordsTable.setWidthPercentage(95);
|
844 |
amountInWordsTable.setWidthPercentage(95);
|
| 836 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
845 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
| 837 |
|
846 |
|
| 838 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
847 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|