Subversion Repositories SmartDukaan

Rev

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