Subversion Repositories SmartDukaan

Rev

Rev 23081 | Rev 24012 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4687 mandeep.dh 1
package in.shop2020.inventory.service;
2
 
21844 amit.gupta 3
import in.shop2020.model.v1.catalog.CatalogServiceException;
4
import in.shop2020.model.v1.catalog.GstRate;
5
import in.shop2020.model.v1.catalog.StateGstRates;
6
import in.shop2020.model.v1.inventory.StateInfo;
7
import in.shop2020.model.v1.order.BuyerInfo;
8
import in.shop2020.model.v1.order.WarehouseAddress;
9
import in.shop2020.purchase.PurchaseOrder;
10
import in.shop2020.purchase.Supplier;
11
import in.shop2020.purchase.TaxType;
12
import in.shop2020.thrift.clients.CatalogClient;
13
import in.shop2020.thrift.clients.InventoryClient;
14
import in.shop2020.thrift.clients.TransactionClient;
15
 
4687 mandeep.dh 16
import java.io.ByteArrayOutputStream;
17
import java.io.File;
18
import java.io.FileOutputStream;
19
import java.io.IOException;
20
import java.text.DateFormat;
21844 amit.gupta 21
import java.text.MessageFormat;
14082 manish.sha 22
import java.util.Calendar;
4687 mandeep.dh 23
import java.util.Date;
14072 manish.sha 24
import java.util.Map;
4687 mandeep.dh 25
 
21844 amit.gupta 26
import org.apache.commons.lang.StringUtils;
14072 manish.sha 27
import org.apache.thrift.TException;
4687 mandeep.dh 28
import org.slf4j.Logger;
29
import org.slf4j.LoggerFactory;
30
 
31
import com.itextpdf.text.Document;
32
import com.itextpdf.text.Element;
33
import com.itextpdf.text.Font;
34
import com.itextpdf.text.Font.FontFamily;
35
import com.itextpdf.text.FontFactory;
36
import com.itextpdf.text.Paragraph;
37
import com.itextpdf.text.Phrase;
38
import com.itextpdf.text.Rectangle;
39
import com.itextpdf.text.pdf.PdfPCell;
40
import com.itextpdf.text.pdf.PdfPTable;
41
import com.itextpdf.text.pdf.PdfWriter;
19950 amit.gupta 42
 
4687 mandeep.dh 43
public class PdfPoSheetGenerator {
44
 
21844 amit.gupta 45
	private static Logger logger = LoggerFactory.getLogger(PdfPoSheetGenerator.class);
4687 mandeep.dh 46
 
21844 amit.gupta 47
	private static final Font helvetica8 = FontFactory.getFont(FontFactory.HELVETICA, 8);
4687 mandeep.dh 48
 
21844 amit.gupta 49
	private static final Font helveticaBold8 = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 8);
50
	private static final Font helveticaBold12 = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12);
4687 mandeep.dh 51
 
21844 amit.gupta 52
	public static Map<Long, StateInfo> stateIdMap = null;
4687 mandeep.dh 53
 
21844 amit.gupta 54
	static String CONTACT_FORMAT = "Mr. {0}, Contact No. +91 {1}";
55
 
56
	static {
57
		try {
14072 manish.sha 58
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
59
			stateIdMap = inventoryClient.getStateMaster();
21844 amit.gupta 60
 
61
		} catch (Exception e) {
20025 amit.gupta 62
			logger.error("Unable to get State Info Map", e);
14072 manish.sha 63
		}
64
	}
65
 
21844 amit.gupta 66
	public static String generatePdfSheet(PurchaseOrder purchaseOrder, Supplier supplier) throws IOException {
67
		ByteArrayOutputStream baosPDF = null;
68
		try {
69
			in.shop2020.model.v1.order.TransactionService.Client tClient = new TransactionClient().getClient();
70
			BuyerInfo binfo = tClient.getBuyerByWarehouse(purchaseOrder.getWarehouseId());
71
			baosPDF = new ByteArrayOutputStream();
4687 mandeep.dh 72
 
21844 amit.gupta 73
			Document document = new Document();
74
			PdfWriter.getInstance(document, baosPDF);
75
			document.addAuthor("shop2020");
76
			document.addTitle("Purchase Order No: " + purchaseOrder.getPoNumber());
77
			document.open();
4687 mandeep.dh 78
 
21844 amit.gupta 79
			PdfPTable poTable = getPoTable(purchaseOrder, supplier, binfo);
80
			poTable.setSpacingAfter(10.0f);
81
			poTable.setWidthPercentage(100.0f);
4687 mandeep.dh 82
 
21844 amit.gupta 83
			document.add(poTable);
84
			document.close();
85
			baosPDF.close();
86
		} catch (Exception e) {
87
			logger.error("Error while generating Invoice: ", e);
88
			e.printStackTrace();
89
		}
4687 mandeep.dh 90
 
21844 amit.gupta 91
		String tmpDir = System.getProperty("java.io.tmpdir");
92
		String filename = tmpDir + "/po-" + purchaseOrder.getId() + ".pdf";
93
		File f = new File(filename);
94
		FileOutputStream fos = new FileOutputStream(f);
95
		baosPDF.writeTo(fos);
96
		return filename;
97
	}
4687 mandeep.dh 98
 
21844 amit.gupta 99
	private static PdfPTable getPoTable(PurchaseOrder purchaseOrder, Supplier supplier, BuyerInfo binfo) throws Exception {
100
		PdfPTable poTable = new PdfPTable(1);
101
		poTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
102
		poTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
4687 mandeep.dh 103
 
21844 amit.gupta 104
		PdfPCell poTitleCell = new PdfPCell(new Phrase("Purchase Order", helveticaBold12));
105
		poTitleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
106
		poTitleCell.setBorder(Rectangle.NO_BORDER);
4687 mandeep.dh 107
 
21844 amit.gupta 108
		long poValidityLimit = supplier.getPoValidityLimit();
109
		Calendar cal1 = Calendar.getInstance();
110
		cal1.setTimeInMillis(purchaseOrder.getCreatedAt());
111
		cal1.add(Calendar.DAY_OF_MONTH, (int) poValidityLimit);
112
		Date poDate = new Date(purchaseOrder.getCreatedAt());
113
		Date poExpiryDate = new Date(cal1.getTimeInMillis());
4687 mandeep.dh 114
 
21844 amit.gupta 115
		PdfPTable poSummaryTable = new PdfPTable(new float[] { 0.3f, 0.3f, 0.4f });
116
		poSummaryTable.addCell(new PdfPCell(new Phrase("PO No: " + purchaseOrder.getPoNumber())));
117
		poSummaryTable.addCell(new PdfPCell(new Phrase("Date: " + DateFormat.getDateInstance(DateFormat.MEDIUM).format(poDate))));
118
		poSummaryTable.addCell(new PdfPCell(new Phrase("PO Valid for delivery by: "
119
				+ DateFormat.getDateInstance(DateFormat.MEDIUM).format(poExpiryDate))));
120
		poSummaryTable.setSpacingBefore(10.0f);
4687 mandeep.dh 121
 
21844 amit.gupta 122
		poTable.addCell(poTitleCell);
123
		poTable.addCell(getAddressCell(purchaseOrder, binfo));
124
		poTable.addCell(poSummaryTable);
125
		poTable.addCell(getSalutationTable(supplier));
126
		poTable.addCell(getPoDetailsTable(purchaseOrder, supplier, binfo));
127
		poTable.addCell(getBillToTable(purchaseOrder));
128
		// poTable.addCell(getCFormCell(purchaseOrder.getTaxType()));
23081 amit.gupta 129
 
130
		if(supplier.isSetTnc()) {
131
			poTable.addCell(getTncTable(supplier.getTnc()));
132
		}
4687 mandeep.dh 133
 
21844 amit.gupta 134
		return poTable;
135
	}
9416 amar.kumar 136
 
21844 amit.gupta 137
	/*
138
	 * private static PdfPCell getCFormCell(TaxType taxType) { PdfPCell
139
	 * cFormCell = null; if(taxType == TaxType.CFORM) { cFormCell = new
140
	 * PdfPCell(new Paragraph("*To be billed on CST Against C-Form ", new
141
	 * Font(FontFamily.TIMES_ROMAN, 8f))); } else { cFormCell = new PdfPCell();
142
	 * } cFormCell.setBorder(Rectangle.NO_BORDER);
143
	 * cFormCell.setHorizontalAlignment(Element.ALIGN_LEFT); return cFormCell; }
144
	 */
145
 
146
	private static PdfPTable getAddressCell(PurchaseOrder purchaseOrder, BuyerInfo binfo) {
147
		// TODO Write this code in a proper configurable way
148
		String address = "";
149
		String tinNo = "";
150
		String shippingAddress = "";
151
		try {
152
			in.shop2020.model.v1.order.TransactionService.Client tClient = new TransactionClient().getClient();
20073 amit.gupta 153
			WarehouseAddress addr = tClient.getWarehouseAddress(purchaseOrder.getWarehouseAddressId());
20025 amit.gupta 154
			tinNo = binfo.getTin();
155
			address = binfo.getOrganisationName() + "\n" + addr.getAddress() + "\n" + "-" + addr.getPin();
21844 amit.gupta 156
		} catch (Exception e) {
157
			logger.error("This should not happen", e);
158
		}
159
 
160
		PdfPTable billToShipToTable = new PdfPTable(2);
161
		Paragraph addressParagraph = new Paragraph(address, new Font(FontFamily.TIMES_ROMAN, 8f));
162
		PdfPCell addressCell = new PdfPCell();
163
		if (purchaseOrder.getWarehouseId() != purchaseOrder.getShippingWarehouseId()) {
164
			addressParagraph = new Paragraph("Bill To :\n" + address + "\n\nTIN NO. " + tinNo, new Font(FontFamily.TIMES_ROMAN, 8f));
165
		}
166
		addressCell.addElement(addressParagraph);
167
		// addressCell.setHorizontalAlignment(Element.ALIGN_CENTER);
168
		addressCell.setBorder(Rectangle.NO_BORDER);
169
 
170
		if (purchaseOrder.getWarehouseId() != purchaseOrder.getShippingWarehouseId()) {
171
			try {
172
				in.shop2020.model.v1.order.TransactionService.Client tClient = new TransactionClient().getClient();
173
				WarehouseAddress addr = tClient.getWarehouseAddress(purchaseOrder.getShippingWarehouseAddressId());
174
				address = binfo.getOrganisationName() + "\n" + addr.getAddress() + "\n" + "-" + addr.getPin();
175
			} catch (Exception e) {
176
				logger.error("This should not happen", e);
177
			}
9925 amar.kumar 178
			PdfPCell billToShipToCell = new PdfPCell();
179
			billToShipToCell.setHorizontalAlignment(Element.ALIGN_LEFT);
180
			billToShipToCell.setBorder(Rectangle.NO_BORDER);
21844 amit.gupta 181
 
9925 amar.kumar 182
			PdfPCell shippingAddressCell = new PdfPCell();
21844 amit.gupta 183
			shippingAddressCell.addElement(new Paragraph("Ship To :\n" + shippingAddress + "\nTIN NO. " + tinNo, new Font(
184
					FontFamily.TIMES_ROMAN, 8f)));
9925 amar.kumar 185
			shippingAddressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
21844 amit.gupta 186
			shippingAddressCell.setBorder(Rectangle.LEFT);
187
			billToShipToTable.addCell(addressCell);
188
			billToShipToTable.addCell(shippingAddressCell);
189
			billToShipToCell.addElement(billToShipToTable);
190
			return billToShipToTable;
4687 mandeep.dh 191
 
21844 amit.gupta 192
		}
193
		billToShipToTable.addCell(addressCell);
194
		PdfPCell placeHolderCell = new PdfPCell();
195
		placeHolderCell.setBorder(Rectangle.NO_BORDER);
196
		billToShipToTable.addCell(placeHolderCell);
197
		return billToShipToTable;
198
	}
4687 mandeep.dh 199
 
21844 amit.gupta 200
	private static PdfPTable getSalutationTable(Supplier supplier) throws Exception {
201
		PdfPTable salutationTable = new PdfPTable(1);
202
		salutationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
203
		salutationTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
204
		salutationTable.addCell(new Phrase("To", helvetica8));
205
		if (supplier.getName().equals("Smobility Ltd.")) {
206
			salutationTable.addCell(new Phrase("Spice Retail Ltd.", helvetica8));
207
		} else if (supplier.getName().equals("Smobility Ltd. - Mumbai")) {
208
			salutationTable.addCell(new Phrase("Spice Retail Ltd. Mumbai", helvetica8));
209
		} else {
210
			salutationTable.addCell(new Phrase(supplier.getName(), helvetica8));
211
		}
4687 mandeep.dh 212
 
21844 amit.gupta 213
		salutationTable.addCell(new Paragraph(supplier.getCommunicationAddress(), helvetica8));
214
		salutationTable.addCell(new Phrase("Dear Sir/Madam", helveticaBold8));
215
		salutationTable.addCell(new Phrase("Please supply the following stocks as per the details given below:", helvetica8));
216
		salutationTable.addCell(new Phrase(" "));
217
		return salutationTable;
218
	}
219
 
220
	private static PdfPTable getPoDetailsTable(PurchaseOrder purchaseOrder, Supplier supplier, BuyerInfo binfo)
221
			throws CatalogServiceException, TException {
222
		float[] widths;
21854 amit.gupta 223
		TaxType taxType = purchaseOrder.getTaxType();
21844 amit.gupta 224
		if(taxType.equals(TaxType.SGST)){
225
			widths = new float[] { 0.05f, 0.25f, 0.09f, 0.1f, 0.09f, 0.09f, 0.09f, 0.07f, 0.1f, 0.07f, 0.1f };
226
		} else {
227
			widths = new float[] { 0.1f, 0.27f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.08f, 0.1f };
14072 manish.sha 228
		}
21844 amit.gupta 229
		PdfPTable detailsTable = new PdfPTable(widths);
230
 
231
		PdfPCell slNoCell = getHeaderCell("Sl. No");
232
		detailsTable.addCell(slNoCell);
233
 
234
		PdfPCell description = getHeaderCell("Description");
235
		detailsTable.addCell(description);
4687 mandeep.dh 236
 
21844 amit.gupta 237
 
238
		PdfPCell hsnCodeCell = getHeaderCell("HSN Code");
239
		detailsTable.addCell(hsnCodeCell);
240
 
241
		PdfPCell qtyCell = getHeaderCell("Qty");
242
		detailsTable.addCell(qtyCell);
243
 
244
		PdfPCell rateCell = getHeaderCell("Rate");
245
		detailsTable.addCell(rateCell);
246
 
247
		PdfPCell totalCell = getHeaderCell("Total Value");
248
		detailsTable.addCell(totalCell);
249
 
250
		PdfPCell taxableAmontCell = getHeaderCell("Taxable Value");
251
		taxableAmontCell.setRowspan(2);
252
		detailsTable.addCell(taxableAmontCell);
253
 
254
 
255
		if(taxType.equals(TaxType.SGST)) {
256
			PdfPCell cell1 = new PdfPCell(new Phrase("CGST", helveticaBold8));
257
			cell1.setColspan(2);
258
			cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
259
			detailsTable.addCell(cell1);
260
 
261
			PdfPCell cell2 = new PdfPCell(new Phrase("SGST", helveticaBold8));
262
			cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
263
			cell2.setColspan(2);
264
			detailsTable.addCell(cell2);
265
		} else {
266
			PdfPCell cell3 = new PdfPCell(new Phrase("IGST", helveticaBold8));
267
			cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
268
			cell3.setRowspan(2);
21854 amit.gupta 269
			detailsTable.addCell(cell3);
21844 amit.gupta 270
		}
271
 
272
		if(taxType.equals(TaxType.SGST)) {
273
			detailsTable.addCell(new Phrase("Rate(%)", helveticaBold8));
274
			detailsTable.addCell(new Phrase("Amount", helveticaBold8));
275
			detailsTable.addCell(new Phrase("Rate(%)", helveticaBold8));
276
			detailsTable.addCell(new Phrase("Amount", helveticaBold8));
277
		}else {
278
			detailsTable.addCell(new Phrase("Rate(%)", helveticaBold8));
279
			detailsTable.addCell(new Phrase("Amount", helveticaBold8));
280
		}
281
 
282
		int slNo = 0;
283
		double total = 0;
284
		double vatFactor = 0;
285
		double totalUnits = 0;
286
		String stateCode = null;
287
		CatalogClient cClient = new CatalogClient();
288
		in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = cClient.getClient();
289
		for (in.shop2020.purchase.LineItem lineitem : purchaseOrder.getLineitems()) {
290
			slNo++;
291
			detailsTable.addCell(new Phrase(slNo + "", helvetica8));
292
			detailsTable.addCell(getProductNameCell(lineitem));
293
			detailsTable.addCell(new Phrase(lineitem.getHsnCode(), helvetica8));
294
			detailsTable.addCell(new Phrase(String.format("%d Units", (int)lineitem.getQuantity()), helvetica8));
295
			detailsTable.addCell(new Phrase(String.format("%.2f", lineitem.getUnitPrice()), helvetica8));
296
 
297
			double totalAmount = lineitem.getUnitPrice()*lineitem.getQuantity();
298
			detailsTable.addCell(new Phrase(String.format("%.2f", totalAmount), helvetica8));
299
 
300
			double totalTaxRate = lineitem.getIgstRate() + lineitem.getSgstRate() + lineitem.getCgstRate();
301
			double taxableAmount = totalAmount / (1 + (totalTaxRate / 100));
302
			detailsTable.addCell(new Phrase(String.format("%.2f", taxableAmount), helvetica8));
303
 
304
			if(purchaseOrder.getTaxType().equals(TaxType.SGST)) {
305
				double cgstAmount = taxableAmount * (lineitem.getCgstRate() / 100);
306
				detailsTable.addCell(new Phrase(String.format("%.2f", lineitem.getCgstRate()), helvetica8));
307
				detailsTable.addCell(new Phrase(String.format("%.2f", cgstAmount), helvetica8));
308
 
309
				double sgstAmount = taxableAmount * (lineitem.getSgstRate() / 100);
310
				detailsTable.addCell(new Phrase(String.format("%.2f", lineitem.getSgstRate()), helvetica8));
311
				detailsTable.addCell(new Phrase(String.format("%.2f", sgstAmount), helvetica8));
312
			} else {
313
				double igstAmount = taxableAmount * (lineitem.getIgstRate() / 100);
314
				detailsTable.addCell(new Phrase(String.format("%.2f", lineitem.getIgstRate()), helvetica8));
315
				detailsTable.addCell(new Phrase(String.format("%.2f", igstAmount), helvetica8));
316
			}
317
 
318
			totalUnits += lineitem.getQuantity();
319
			total += totalAmount;
320
		}
23828 amit.gupta 321
		if(purchaseOrder.getTaxType().equals(TaxType.SGST)) {
322
 
323
			detailsTable.addCell(getTotalCell(3));
324
			detailsTable.addCell(new Phrase(String.format("%.0f", totalUnits), helvetica8));
325
			detailsTable.addCell(getTotalAmountCell(7, total));
326
		} else {
327
			detailsTable.addCell(getTotalCell(2));
328
			detailsTable.addCell(new Phrase(String.format("%.0f", totalUnits), helvetica8));
329
			detailsTable.addCell(getTotalAmountCell(6, total));
330
		}
21844 amit.gupta 331
		return detailsTable;
332
	}
333
 
334
	private static PdfPCell getHeaderCell(String headerName) {
335
		PdfPCell cell = new PdfPCell(new Phrase(headerName, helveticaBold8));
336
		cell.setRowspan(2);
337
		cell.setHorizontalAlignment(Element.ALIGN_CENTER);
338
		cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
339
		return cell;
340
	}
23081 amit.gupta 341
	private static PdfPTable getTncTable(String tnc) {
342
		PdfPTable tncTable = new PdfPTable(new float[] { 1f });
343
		tncTable.addCell(new Phrase("Terms & Conditions", helveticaBold8));
344
		tncTable.addCell(new Phrase(tnc, helvetica8));
345
		return tncTable;
346
	}
21844 amit.gupta 347
	private static PdfPTable getBillToTable(PurchaseOrder po) {
348
		// TODO Write this code in a proper configurable way
349
		String address = "";
350
		String gstin = "";
351
		String contactPerson = "Neeraj Gupta";
352
		String contactNumber = "9873802000";
353
		BuyerInfo binfo = new BuyerInfo();
354
		try {
355
			in.shop2020.model.v1.order.TransactionService.Client tClient = new TransactionClient().getClient();
20067 amit.gupta 356
			binfo = tClient.getBuyerByWarehouse(po.getWarehouseId());
21844 amit.gupta 357
			gstin = binfo.getGstin();
20067 amit.gupta 358
			WarehouseAddress addr = tClient.getWarehouseAddress(po.getWarehouseAddressId());
359
			address = binfo.getOrganisationName() + "\n" + addr.getAddress() + "\n" + "-" + addr.getPin();
21844 amit.gupta 360
			if (StringUtils.isNotBlank(addr.getContact_person())) {
361
				contactPerson = addr.getContact_person();
362
			}
363
			if (StringUtils.isNotBlank(addr.getContact_number())) {
364
				contactNumber = addr.getContact_number();
365
			}
366
		} catch (Exception e) {
367
			logger.error("This should not happen", e);
368
		}
7410 amar.kumar 369
 
21844 amit.gupta 370
		contactPerson = MessageFormat.format(CONTACT_FORMAT, contactPerson, contactNumber);
371
		PdfPTable billToTable = new PdfPTable(new float[] { 0.2f, 0.8f });
372
		billToTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
4687 mandeep.dh 373
 
21844 amit.gupta 374
		billToTable.addCell(new Phrase("Bill To :", helvetica8));
375
		billToTable.addCell(new PdfPCell(new Paragraph(address 
376
				+ "\n\nPlace of Supply - " 
377
				+ MessageFormat.format("{0}({1})", stateIdMap.get(binfo.getStateId()).getStateName(),stateIdMap.get(binfo.getStateId()).getStateCode())
378
				+ "\nGST NO. " + gstin, helvetica8)));
4687 mandeep.dh 379
 
21844 amit.gupta 380
		billToTable.addCell(new Phrase("Contact Person:", helvetica8));
381
		billToTable.addCell(new Phrase(contactPerson, helvetica8));
4687 mandeep.dh 382
 
21844 amit.gupta 383
		billToTable.addCell(new Phrase("Taxes:", helvetica8));
384
		if (po.getTaxType() == TaxType.CFORM) {
385
			billToTable.addCell(new Phrase("Prices inclusive of all taxes (To be billed on CST Against C-Form)", helvetica8));
386
		} else {
387
			billToTable.addCell(new Phrase("Prices inclusive of all taxes", helvetica8));
388
		}
4687 mandeep.dh 389
 
21844 amit.gupta 390
		return billToTable;
391
	}
4687 mandeep.dh 392
 
21844 amit.gupta 393
	private static PdfPCell getProductNameCell(in.shop2020.purchase.LineItem lineitem) {
394
		String itemName = getItemDisplayName(lineitem);
395
		PdfPCell productNameCell = new PdfPCell(new Phrase(itemName, helvetica8));
396
		productNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
397
		return productNameCell;
398
	}
4687 mandeep.dh 399
 
21844 amit.gupta 400
	private static String getItemDisplayName(in.shop2020.purchase.LineItem lineitem) {
401
		StringBuffer itemName = new StringBuffer();
402
		if (lineitem.getBrand() != null)
403
			itemName.append(lineitem.getBrand() + " ");
404
		if (lineitem.getModelName() != null)
405
			itemName.append(lineitem.getModelName() + " ");
406
		if (lineitem.getModelNumber() != null)
407
			itemName.append(lineitem.getModelNumber() + " ");
408
		if (lineitem.getColor() != null && !lineitem.getColor().trim().equals("NA"))
409
			itemName.append("(" + lineitem.getColor() + ")");
4687 mandeep.dh 410
 
21844 amit.gupta 411
		return itemName.toString();
412
	}
4687 mandeep.dh 413
 
21844 amit.gupta 414
	private static PdfPCell getTotalCell(int colspan) {
415
		PdfPCell totalCell = new PdfPCell(new Phrase("Total", helveticaBold8));
416
		totalCell.setColspan(colspan);
417
		totalCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
418
		return totalCell;
419
	}
4687 mandeep.dh 420
 
21844 amit.gupta 421
	private static PdfPCell getTotalAmountCell(int colspan, double totalAmount) {
422
		PdfPCell totalCell = new PdfPCell(new Phrase(String.format("%.2f", totalAmount), helvetica8));
423
		totalCell.setColspan(colspan);
424
		totalCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
425
		return totalCell;
426
	}
427
 
4687 mandeep.dh 428
}