Subversion Repositories SmartDukaan

Rev

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