Subversion Repositories SmartDukaan

Rev

Rev 12752 | Rev 12863 | 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
 
3
import in.shop2020.purchase.PurchaseOrder;
4
import in.shop2020.purchase.Supplier;
9416 amar.kumar 5
import in.shop2020.purchase.TaxType;
4687 mandeep.dh 6
 
7
import java.io.ByteArrayOutputStream;
8
import java.io.File;
9
import java.io.FileOutputStream;
10
import java.io.IOException;
11
import java.text.DateFormat;
12
import java.util.Date;
13
 
14
import org.slf4j.Logger;
15
import org.slf4j.LoggerFactory;
16
 
17
import com.itextpdf.text.Document;
18
import com.itextpdf.text.Element;
19
import com.itextpdf.text.Font;
20
import com.itextpdf.text.Font.FontFamily;
21
import com.itextpdf.text.FontFactory;
22
import com.itextpdf.text.Paragraph;
23
import com.itextpdf.text.Phrase;
24
import com.itextpdf.text.Rectangle;
25
import com.itextpdf.text.pdf.PdfPCell;
26
import com.itextpdf.text.pdf.PdfPTable;
27
import com.itextpdf.text.pdf.PdfWriter;
28
 
29
public class PdfPoSheetGenerator {
30
 
31
    private static Logger logger = LoggerFactory
32
            .getLogger(PdfPoSheetGenerator.class);
33
 
34
    // private static final Properties properties = readProperties();
7410 amar.kumar 35
    private static final String ourAddressDelhi = "Spice Online Retail Pvt. Ltd.\nC/O,PIBCO LIMITED, Basement,Punjsons\n2,Kalkaji Industrial Area, New Delhi-110019\n";
7676 amar.kumar 36
    private static final String ourAddressBhiwandi = "Spice Online Retail Pvt. Ltd.\nC/O. FedEx Express Transportation and Supply Chain Services (India) Private Limited.\nC/O NDR WAREHOUSING, SURVEY NO.95, MUMBAI - NASIK HIGHWAY, WADAPE VILLAGE\nBHIWANDI (NR. SAI DHABA), Thane,Maharashtra -421302\n";                   
7410 amar.kumar 37
    private static final String ourAddressGoregaon = "Spice Online Retail Pvt. Ltd.\n93/743, Motilal Nagar-1, Goregaon(WEST),\nMotilal Nagar, Mumbai, Maharashtra-400062\n";
10877 manish.sha 38
    private static final String ourAddressBangalore = "Spice Online Retail Pvt. Ltd.\n C/O.Drive India Enterprise Solutions Limited)\n Survey No. 86, Korulur Village, Kasab Hobli\n Hoskote Taluka\n Bangalore – 560067, Karnataka\n";
39
    private static final String ourAddressBangaloreSR = "Spice Online Retail Pvt. Ltd.\n Shop No. 320, Municipal 59th Cross,\n Next to Rammandir Ground,\n 3rd Block, Rajaji Nagar,\nBangalore - 560010, Karnataka\n";
12769 manish.sha 40
    private static final String ourAddressGurgaon = "Spice Online Retail Private Limited,\n SHOP NO. 10 & 11,\n OLD DELHI ROAD,OPP SECTOR-14, GURGAON-122001 Haryana\n";
41
    private static final String ourAddressHyderabad = "Spice Online Retail Pvt. Ltd, Drive India Enterprise Solutions Limited, 16,17&18, Gundllapochampalli, Kompalli, Medchal Mandal, Secandrabad-500014, Dist- Hyderabad";
10877 manish.sha 42
 
9925 amar.kumar 43
    private static final String amazonAddress = "Spice Online Retail Pvt. Ltd. C/O Amazon Seller Services  Pvt. Ltd.,\nBuilding H Prathmesh Complex, Saravali Village,\nOpp Hotel Vatika Kalyan, Bhivandi Junction,\nBhiwandi, Maharashtra\n";
10877 manish.sha 44
    private static final String amazonAddreseBangalore = "Spice Online Retail Pvt. Ltd.\n C/O Amazon Seller Services Pvt. Ltd.\n 38 & 39, Soukya Road,\n kacherakanahalli,\n Hoskote Taluka,\n Bangalore  -560067, Karnataka\n";
12752 manish.sha 45
    private static final String amazonAddressMewat = "Spice Online Retail Pvt. Ltd.\n C/O AMAZON Seller Services Pvt. Limited,\n  Gokaldas Warehousing Corporation,  Unit No 1,\n Village Taoru,  Tehsil Taoru, Distt Mewat - 122105";
12543 manish.sha 46
    private static final String flipkartAddressGgn = "Spice Online Retail Pvt. Ltd.\n C/O. Flipkart Internet Pvt. Ltd, \n KILLA NO.219/15-16 25/1 220/11 12/1 12/2 13/1/113/1/2 20 21/1 21/2/1 22/1 23/1/1,\n Bohra Kalan, PATAUDI, GURGAON - 122001, Haryana\n";
7410 amar.kumar 47
    private static final String tinNoDelhi = "07250399732";
48
    private static final String tinNoMum = "27450984008";
10877 manish.sha 49
    private static final String tinNoBan = "29171183852";
12543 manish.sha 50
    private static final String tinNoFkGgn = "06681944625";
51
    private static final String tinNoOurGgn = "06681944625";
12769 manish.sha 52
    private static final String tinNoOurHyd = "36601220768";
12543 manish.sha 53
 
4687 mandeep.dh 54
 
55
    private static final Font helvetica8 = FontFactory.getFont(
56
            FontFactory.HELVETICA, 8);
57
 
58
    private static final Font helveticaBold8 = FontFactory.getFont(
59
            FontFactory.HELVETICA_BOLD, 8);
60
    private static final Font helveticaBold12 = FontFactory.getFont(
61
            FontFactory.HELVETICA_BOLD, 12);
62
 
63
    public static String generatePdfSheet(PurchaseOrder purchaseOrder,
64
            Supplier supplier) throws IOException {
65
        ByteArrayOutputStream baosPDF = null;
66
        try {
67
            baosPDF = new ByteArrayOutputStream();
68
 
69
            Document document = new Document();
70
            PdfWriter.getInstance(document, baosPDF);
71
            document.addAuthor("shop2020");
72
            document.addTitle("Purchase Order No: "
73
                    + purchaseOrder.getPoNumber());
74
            document.open();
75
 
76
            PdfPTable poTable = getPoTable(purchaseOrder, supplier);
77
            poTable.setSpacingAfter(10.0f);
78
            poTable.setWidthPercentage(90.0f);
79
 
80
            document.add(poTable);
81
            document.close();
82
            baosPDF.close();
83
        } catch (Exception e) {
84
            logger.error("Error while generating Invoice: ", e);
85
        }
86
 
87
        String tmpDir = System.getProperty("java.io.tmpdir");
88
        String filename = tmpDir + "/po-" + purchaseOrder.getId() + ".pdf";
89
        File f = new File(filename);
90
        FileOutputStream fos = new FileOutputStream(f);
91
        baosPDF.writeTo(fos);
92
        return filename;
93
    }
94
 
95
    private static PdfPTable getPoTable(PurchaseOrder purchaseOrder,
96
            Supplier supplier) throws Exception {
97
        PdfPTable poTable = new PdfPTable(1);
98
        poTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
99
        poTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
100
 
101
        PdfPCell poTitleCell = new PdfPCell(new Phrase("Purchase Order",
102
                helveticaBold12));
103
        poTitleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
104
        poTitleCell.setBorder(Rectangle.NO_BORDER);
105
 
106
        Date poDate = new Date(purchaseOrder.getCreatedAt());
107
        PdfPTable poSummaryTable = new PdfPTable(new float[] { 0.5f, 0.5f });
108
        poSummaryTable.addCell(new PdfPCell(new Phrase("PO No: "
109
                + purchaseOrder.getPoNumber())));
9416 amar.kumar 110
        poSummaryTable.addCell(new PdfPCell(new Phrase("Date: "
111
        		+ DateFormat.getDateInstance(DateFormat.MEDIUM).format(
112
        				poDate))));
4687 mandeep.dh 113
        poSummaryTable.setSpacingBefore(10.0f);
114
 
115
        poTable.addCell(poTitleCell);
9925 amar.kumar 116
        poTable.addCell(getAddressCell(purchaseOrder.getWarehouseId(), purchaseOrder.getShippingWarehouseId()));
4687 mandeep.dh 117
        poTable.addCell(poSummaryTable);
118
        poTable.addCell(getSalutationTable(supplier));
119
        poTable.addCell(getPoDetailsTable(purchaseOrder));
9591 amar.kumar 120
        poTable.addCell(getBillToTable(purchaseOrder.getWarehouseId(), purchaseOrder.getTaxType()));
121
        //poTable.addCell(getCFormCell(purchaseOrder.getTaxType()));
4687 mandeep.dh 122
 
123
        return poTable;
124
    }
125
 
9416 amar.kumar 126
    private static PdfPCell getCFormCell(TaxType taxType) {
127
    	PdfPCell cFormCell = null;
128
		if(taxType == TaxType.CFORM) {
9586 amar.kumar 129
			cFormCell = new PdfPCell(new Paragraph("*To be billed on CST Against C-Form ", new Font(FontFamily.TIMES_ROMAN, 8f)));
9416 amar.kumar 130
		} else {
131
			cFormCell = new PdfPCell();
132
		}
133
		cFormCell.setBorder(Rectangle.NO_BORDER);
134
		cFormCell.setHorizontalAlignment(Element.ALIGN_LEFT);
135
		return cFormCell;
136
	}
137
 
9925 amar.kumar 138
	private static PdfPTable getAddressCell(long warehouseId, long shippingWarehouseId) {
7410 amar.kumar 139
    	//TODO Write this code in a proper configurable way
140
    	String address = "";
141
    	String tinNo = "";
9925 amar.kumar 142
    	String shippingAddress = "";
143
    	String shippingTinNo = "";
7410 amar.kumar 144
    	if(warehouseId ==7) {
145
    		address = ourAddressDelhi;
146
    		tinNo = tinNoDelhi;
147
    	} else if(warehouseId == 12) {
148
    		address = ourAddressGoregaon;
149
    		tinNo = tinNoMum;
150
    	} else if(warehouseId == 13) {
151
    		address = ourAddressBhiwandi;
152
    		tinNo = tinNoMum;
7466 amar.kumar 153
    	} else if(warehouseId ==16) {
7464 amar.kumar 154
    		address = amazonAddress;
155
    		tinNo = tinNoMum;
10877 manish.sha 156
    	} else if(warehouseId ==1765){
157
    		address = ourAddressBangalore;
158
    		tinNo = tinNoBan;
159
    	} else if(warehouseId ==1768){
160
    		address = ourAddressBangaloreSR;
161
    		tinNo = tinNoBan;
162
    	} else if(warehouseId ==1771){
163
    		address = amazonAddreseBangalore;
164
    		tinNo = tinNoBan;
12543 manish.sha 165
    	} else if(warehouseId == 2854){
166
    		address = flipkartAddressGgn;
167
    		tinNo = tinNoFkGgn;
168
    	} else if(warehouseId == 2857){
169
    		address = ourAddressGurgaon;
170
    		tinNo = tinNoOurGgn;
12769 manish.sha 171
    	} else if(warehouseId == 3295){
172
    		address = amazonAddressMewat;
173
    		tinNo = tinNoOurGgn;
7410 amar.kumar 174
    	}
12769 manish.sha 175
    	else if(warehouseId == 3298){
176
    		address = ourAddressHyderabad;
177
    		tinNo = tinNoOurHyd;
178
    	}
9925 amar.kumar 179
    	PdfPTable billToShipToTable  = new PdfPTable(2);
7410 amar.kumar 180
        Paragraph addressParagraph = new Paragraph(address + "\nTIN NO. "
4687 mandeep.dh 181
                + tinNo, new Font(FontFamily.TIMES_ROMAN, 8f));
182
        PdfPCell addressCell = new PdfPCell();
9925 amar.kumar 183
        if(warehouseId != shippingWarehouseId) {
184
           	addressParagraph = new Paragraph("Bill To :\n" + address + "\n\nTIN NO. "
185
                    + tinNo, new Font(FontFamily.TIMES_ROMAN, 8f));
186
        }
4687 mandeep.dh 187
        addressCell.addElement(addressParagraph);
9925 amar.kumar 188
        //addressCell.setHorizontalAlignment(Element.ALIGN_CENTER);
4687 mandeep.dh 189
        addressCell.setBorder(Rectangle.NO_BORDER);
9925 amar.kumar 190
 
191
        if(warehouseId != shippingWarehouseId) {
192
			if(shippingWarehouseId ==7) {
193
				shippingAddress = ourAddressDelhi;
194
				shippingTinNo = tinNoDelhi;
195
	    	} else if(shippingWarehouseId == 12) {
196
	    		shippingAddress = ourAddressGoregaon;
197
	    		shippingTinNo = tinNoMum;
198
	    	} else if(shippingWarehouseId == 13) {
199
	    		shippingAddress = ourAddressBhiwandi;
200
	    		shippingTinNo = tinNoMum;
201
	    	} else if(shippingWarehouseId ==16) {
202
	    		shippingAddress = amazonAddress;
203
	    		shippingTinNo = tinNoMum;
10877 manish.sha 204
	    	} else if(shippingWarehouseId ==1765){
205
	    		shippingAddress = ourAddressBangalore;
206
	    		shippingTinNo = tinNoBan;
207
	    	} else if(shippingWarehouseId ==1768){
208
	    		shippingAddress = ourAddressBangaloreSR;
209
	    		shippingTinNo = tinNoBan;
210
	    	} else if(shippingWarehouseId ==1771){
211
	    		shippingAddress = amazonAddreseBangalore;
212
	    		shippingTinNo = tinNoBan;
12543 manish.sha 213
	    	} else if(shippingWarehouseId == 2854){
214
	    		shippingAddress = flipkartAddressGgn;
215
	    		shippingTinNo = tinNoFkGgn;
216
	    	} else if(shippingWarehouseId == 2857){
217
	    		shippingAddress = ourAddressGurgaon;
218
	    		shippingTinNo = tinNoOurGgn;
12729 manish.sha 219
	    	} else if(shippingWarehouseId == 3295){
220
	    		shippingAddress = amazonAddressMewat;
221
	    		shippingTinNo = tinNoOurGgn;
12769 manish.sha 222
	    	} else if(shippingWarehouseId == 3298){
223
	    		shippingAddress = ourAddressHyderabad;
224
	    		shippingTinNo = tinNoOurHyd;
9925 amar.kumar 225
	    	}
226
 
227
			PdfPCell billToShipToCell = new PdfPCell();
228
			billToShipToCell.setHorizontalAlignment(Element.ALIGN_LEFT);
229
			billToShipToCell.setBorder(Rectangle.NO_BORDER);
230
 
231
			PdfPCell shippingAddressCell = new PdfPCell();
232
			shippingAddressCell.addElement(new Paragraph("Ship To :\n" +shippingAddress + "\nTIN NO. "
233
	                + shippingTinNo, new Font(FontFamily.TIMES_ROMAN, 8f)));
234
			shippingAddressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
235
	        shippingAddressCell.setBorder(Rectangle.LEFT);
236
	        billToShipToTable.addCell(addressCell);
237
	        billToShipToTable.addCell(shippingAddressCell);
238
	        billToShipToCell.addElement(billToShipToTable);
239
	        return billToShipToTable;
240
 
241
    	}
242
        billToShipToTable.addCell(addressCell);
243
        PdfPCell placeHolderCell = new PdfPCell();
244
        placeHolderCell.setBorder(Rectangle.NO_BORDER);
245
        billToShipToTable.addCell(placeHolderCell);
246
        return billToShipToTable;
4687 mandeep.dh 247
    }
248
 
249
    private static PdfPTable getSalutationTable(Supplier supplier)
250
            throws Exception {
251
        PdfPTable salutationTable = new PdfPTable(1);
252
        salutationTable.getDefaultCell().setHorizontalAlignment(
253
                Element.ALIGN_LEFT);
254
        salutationTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
255
        salutationTable.addCell(new Phrase("To", helvetica8));
8712 amar.kumar 256
        if(supplier.getName().equals("Smobility Ltd.")) {
257
        	salutationTable.addCell(new Phrase("Spice Retail Ltd.", helvetica8));
8713 amar.kumar 258
        } else if(supplier.getName().equals("Smobility Ltd. - Mumbai")) {
259
        	salutationTable.addCell(new Phrase("Spice Retail Ltd. Mumbai", helvetica8));
8712 amar.kumar 260
        } else {
261
        	salutationTable.addCell(new Phrase(supplier
262
                    .getName(), helvetica8));
263
        }
264
 
4687 mandeep.dh 265
        salutationTable.addCell(new Paragraph(supplier
266
                .getCommunicationAddress(), helvetica8));
267
        salutationTable.addCell(new Phrase("Dear Sir/Madam", helveticaBold8));
268
        salutationTable
269
                .addCell(new Phrase(
270
                        "Please supply the following stocks as per the details given below:",
271
                        helvetica8));
272
        salutationTable.addCell(new Phrase(" "));
273
        return salutationTable;
274
    }
275
 
276
    private static PdfPTable getPoDetailsTable(PurchaseOrder purchaseOrder) {
277
        PdfPTable detailsTable = new PdfPTable(new float[] { 0.1f, 0.5f, 0.1f,
9591 amar.kumar 278
                0.1f, 0.15f, 0.15f });
4687 mandeep.dh 279
        detailsTable.addCell(new Phrase("Sl. No.", helveticaBold8));
280
        detailsTable.addCell(new Phrase("Description", helveticaBold8));
281
        detailsTable.addCell(new Phrase("Quantity", helveticaBold8));
9591 amar.kumar 282
        detailsTable.addCell(new Phrase("Mrp", helveticaBold8));
4687 mandeep.dh 283
        detailsTable.addCell(new Phrase("Rate (Rs)", helveticaBold8));
284
        detailsTable.addCell(new Phrase("Amount (Rs)", helveticaBold8));
285
 
286
        int slNo = 0;
287
        double total = 0;
288
        for (in.shop2020.purchase.LineItem lineitem : purchaseOrder
289
                .getLineitems()) {
290
            slNo++;
291
            detailsTable.addCell(new Phrase(slNo + "", helvetica8));
292
            detailsTable.addCell(getProductNameCell(lineitem));
293
            detailsTable.addCell(new Phrase(lineitem.getQuantity() + "",
294
                    helvetica8));
9591 amar.kumar 295
            detailsTable.addCell(new Phrase(lineitem.getMrp() + "",
296
                    helvetica8));
4687 mandeep.dh 297
            detailsTable.addCell(new Phrase(lineitem.getUnitPrice() + "",
298
                    helvetica8));
299
            double lineTotal = lineitem.getQuantity() * lineitem.getUnitPrice();
300
            total += lineTotal;
301
            detailsTable.addCell(new Phrase("" + lineTotal, helvetica8));
302
        }
9634 amar.kumar 303
        detailsTable.addCell(getTotalCell(5));
4687 mandeep.dh 304
        detailsTable.addCell(new Phrase("" + total, helvetica8));
305
        return detailsTable;
306
    }
307
 
9591 amar.kumar 308
    private static PdfPTable getBillToTable(long warehouseId, TaxType taxType) {
7410 amar.kumar 309
    	//TODO Write this code in a proper configurable way
310
    	String address = "";
311
    	String tinNo = "";
312
    	String contactPerson = "";
313
    	if(warehouseId ==7) {
314
    		address = ourAddressDelhi;
315
    		tinNo = tinNoDelhi;
12729 manish.sha 316
    		contactPerson = "Mr. Shiv Kumar, Contact No. +91 9953858076";
7410 amar.kumar 317
    	} else if(warehouseId == 12) {
318
    		address = ourAddressGoregaon;
319
    		tinNo = tinNoMum;
7421 amar.kumar 320
    		contactPerson = "Mr. Avinash Sambhaji Lavange, Contact No. +91 9004049589";
7410 amar.kumar 321
    	} else if(warehouseId == 13) {
322
    		address = ourAddressBhiwandi;
323
    		tinNo = tinNoMum;
12729 manish.sha 324
    		contactPerson = "Mr. Vishal Tayade, Contact No. +91 9819231651";
7466 amar.kumar 325
    	} else if(warehouseId ==16) {
326
    		address = amazonAddress;
327
    		tinNo = tinNoMum;
328
    		contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
10877 manish.sha 329
    	} else if(warehouseId ==16) {
330
    		address = amazonAddress;
331
    		tinNo = tinNoMum;
332
    		contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
333
    	} else if(warehouseId ==16) {
334
    		address = amazonAddress;
335
    		tinNo = tinNoMum;
336
    		contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
7410 amar.kumar 337
    	}
10877 manish.sha 338
    	else if(warehouseId ==1765) {
339
    		address = ourAddressBangalore;
340
    		tinNo = tinNoBan;
12729 manish.sha 341
    		contactPerson = "Mr. Ravi Kumar, Contact No. +91 9686392567";
10877 manish.sha 342
    	}
343
    	else if(warehouseId ==1768) {
344
    		address = ourAddressBangaloreSR;
345
    		tinNo = tinNoBan;
12729 manish.sha 346
    		contactPerson = "Mr. Ravi Kumar, Contact No. +91 9686392567";
10877 manish.sha 347
    	}
348
    	else if(warehouseId ==1771) {
349
    		address = amazonAddreseBangalore;
350
    		tinNo = tinNoBan;
12729 manish.sha 351
    		contactPerson = "Mr. Ravi Kumar, Contact No. +91 9686392567";
10877 manish.sha 352
    	}
12543 manish.sha 353
    	else if(warehouseId ==2854) {
354
    		address = flipkartAddressGgn;
355
    		tinNo = tinNoFkGgn;
356
    		contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
357
    	} 
358
    	else if(warehouseId ==2857) {
359
    		address = ourAddressGurgaon;
360
    		tinNo = tinNoOurGgn;
361
    		contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
12729 manish.sha 362
    	} 
363
    	else if(warehouseId == 3295) {
364
    		address = amazonAddressMewat;
365
    		tinNo = tinNoOurGgn;
366
    		contactPerson = "Mr. Sandeep Sachdeva, Contact No. +91 9716691287";
12543 manish.sha 367
    	}
12769 manish.sha 368
    	else if(warehouseId == 3298) {
369
    		address = ourAddressHyderabad;
370
    		tinNo = tinNoOurHyd;
371
    		contactPerson = "Mr. Achyuta Ramaiah A, Contact No. +91 9246581582";
372
    	}
7410 amar.kumar 373
 
4687 mandeep.dh 374
        PdfPTable billToTable = new PdfPTable(new float[] { 0.2f, 0.8f });
375
        billToTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
376
 
9925 amar.kumar 377
        billToTable.addCell(new Phrase("Bill To :", helvetica8));
7410 amar.kumar 378
        billToTable.addCell(new PdfPCell(new Paragraph(address
4687 mandeep.dh 379
                + "\nTIN NO. " + tinNo, helvetica8)));
380
 
381
        billToTable.addCell(new Phrase("Contact Person:", helvetica8));
7410 amar.kumar 382
        billToTable.addCell(new Phrase(contactPerson, helvetica8));
4687 mandeep.dh 383
 
384
        billToTable.addCell(new Phrase("Taxes:", helvetica8));
9591 amar.kumar 385
        if(taxType == TaxType.CFORM) {
386
        	billToTable.addCell(new Phrase("Prices inclusive of all taxes (To be billed on CST Against C-Form)",
387
        			helvetica8));
388
        } else {
389
        	billToTable.addCell(new Phrase("Prices inclusive of all taxes",
390
        			helvetica8));
391
        }
4687 mandeep.dh 392
 
393
        return billToTable;
394
    }
395
 
396
    private static PdfPCell getProductNameCell(
397
            in.shop2020.purchase.LineItem lineitem) {
398
        String itemName = getItemDisplayName(lineitem);
399
        PdfPCell productNameCell = new PdfPCell(
400
                new Phrase(itemName, helvetica8));
401
        productNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
402
        return productNameCell;
403
    }
404
 
405
    private static String getItemDisplayName(
406
            in.shop2020.purchase.LineItem lineitem) {
407
        StringBuffer itemName = new StringBuffer();
408
        if (lineitem.getBrand() != null)
409
            itemName.append(lineitem.getBrand() + " ");
410
        if (lineitem.getModelName() != null)
411
            itemName.append(lineitem.getModelName() + " ");
412
        if (lineitem.getModelNumber() != null)
413
            itemName.append(lineitem.getModelNumber() + " ");
414
        if (lineitem.getColor() != null
415
                && !lineitem.getColor().trim().equals("NA"))
416
            itemName.append("(" + lineitem.getColor() + ")");
417
 
418
        return itemName.toString();
419
    }
420
 
421
    private static PdfPCell getTotalCell(int colspan) {
422
        PdfPCell totalCell = new PdfPCell(new Phrase("Total", helveticaBold8));
423
        totalCell.setColspan(colspan);
424
        totalCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
425
        return totalCell;
426
    }
427
 
428
}