Subversion Repositories SmartDukaan

Rev

Rev 22068 | Rev 22351 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22068 Rev 22215
Line 1... Line 1...
1
package com.spice.profitmandi.common.util;
1
package com.spice.profitmandi.common.util;
2
 
2
 
3
 
3
 
4
import java.io.OutputStream;
4
import java.io.OutputStream;
5
 
-
 
6
import java.time.LocalDateTime;
5
import java.time.LocalDateTime;
7
import java.util.Locale;
6
import java.util.Locale;
8
import java.util.Set;
7
import java.util.Set;
9
 
8
 
10
import org.slf4j.Logger;
9
import org.slf4j.Logger;
Line 22... Line 21...
22
import com.itextpdf.text.pdf.PdfPCell;
21
import com.itextpdf.text.pdf.PdfPCell;
23
import com.itextpdf.text.pdf.PdfPTable;
22
import com.itextpdf.text.pdf.PdfPTable;
24
import com.itextpdf.text.pdf.PdfWriter;
23
import com.itextpdf.text.pdf.PdfWriter;
25
import com.spice.profitmandi.common.model.CustomCustomer;
24
import com.spice.profitmandi.common.model.CustomCustomer;
26
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
25
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
-
 
26
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
27
import com.spice.profitmandi.common.model.CustomRetailer;
27
import com.spice.profitmandi.common.model.CustomRetailer;
28
import com.spice.profitmandi.common.model.PdfModel;
28
import com.spice.profitmandi.common.model.PdfModel;
29
import org.apache.commons.lang3.text.*;
-
 
30
 
29
 
31
public class PdfUtils {
30
public class PdfUtils {
32
	
31
	
33
	private static final Font FONT_TITLE = new Font(Font.FontFamily.HELVETICA  , 18, Font.BOLD);
32
	private static final Font FONT_TITLE = new Font(Font.FontFamily.HELVETICA  , 18, Font.BOLD);
34
	private static Font FONT_NORMAL = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL);
33
	private static Font FONT_NORMAL = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL);
Line 70... Line 69...
70
            blankCell.setBorder(Rectangle.NO_BORDER);
69
            blankCell.setBorder(Rectangle.NO_BORDER);
71
            PdfPTable tableCustomerRetailer = new PdfPTable(3);
70
            PdfPTable tableCustomerRetailer = new PdfPTable(3);
72
            tableCustomerRetailer.setWidthPercentage(90);
71
            tableCustomerRetailer.setWidthPercentage(90);
73
            tableCustomerRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
72
            tableCustomerRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
74
            PdfPCell columnCustomerInfo = new PdfPCell();
73
            PdfPCell columnCustomerInfo = new PdfPCell();
75
            columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getName()), FONT_NORMAL));
74
            columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getFirstName() + " " + customer.getLastName()), FONT_NORMAL));
76
            columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getLine1()) + ", " + StringUtils.capitalize(customer.getAddress().getLine2()), FONT_NORMAL));
75
            columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getLine1()) + ", " + StringUtils.capitalize(customer.getAddress().getLine2()), FONT_NORMAL));
77
            columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getCity()) + ", " + StringUtils.capitalize(customer.getAddress().getState()) + "(" + customerAddressStateCode + ")" + "\n" + customer.getAddress().getPinCode(), FONT_NORMAL));
76
            columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getCity()) + ", " + StringUtils.capitalize(customer.getAddress().getState()) + "(" + customerAddressStateCode + ")" + "\n" + customer.getAddress().getPinCode(), FONT_NORMAL));
78
            columnCustomerInfo.addElement(new Paragraph(customer.getMobileNumber(), FONT_NORMAL));
77
            columnCustomerInfo.addElement(new Paragraph(customer.getMobileNumber(), FONT_NORMAL));
79
            columnCustomerInfo.setBorder(Rectangle.NO_BORDER);
78
            columnCustomerInfo.setBorder(Rectangle.NO_BORDER);
80
            PdfPCell columnRetailerInfo = new PdfPCell();
79
            PdfPCell columnRetailerInfo = new PdfPCell();
Line 183... Line 182...
183
            		cgstTotalAmount = cgstTotalAmount + orderItem.getCgstAmount();
182
            		cgstTotalAmount = cgstTotalAmount + orderItem.getCgstAmount();
184
            		sgstTotalAmount = sgstTotalAmount + orderItem.getSgstAmount();
183
            		sgstTotalAmount = sgstTotalAmount + orderItem.getSgstAmount();
185
            	}
184
            	}
186
            	//orders.addCell(new Paragraph(String.format("%.2f", orderItem.getItemTotal()), FONT_NORMAL));
185
            	//orders.addCell(new Paragraph(String.format("%.2f", orderItem.getItemTotal()), FONT_NORMAL));
187
            }
186
            }
-
 
187
        	
-
 
188
        	for(CustomInsurancePolicy insurancePolicy : pdfModel.getInsurancePolicies()){
-
 
189
        		orders.addCell(new Paragraph(String.valueOf(index++), FONT_NORMAL));
-
 
190
            	orders.addCell(new Paragraph(insurancePolicy.getDescription(), FONT_NORMAL));
-
 
191
            	orders.addCell(new Paragraph(insurancePolicy.getHsnCode(), FONT_NORMAL));
-
 
192
            	orders.addCell(new Paragraph("1", FONT_NORMAL));
-
 
193
            	orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
-
 
194
            	orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
-
 
195
            	if(!gstWithInState){
-
 
196
            		orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getIgstRate()), FONT_NORMAL));
-
 
197
            		orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getIgstAmount()), FONT_NORMAL));
-
 
198
            		igstTotalAmount = igstTotalAmount + insurancePolicy.getIgstAmount();
-
 
199
            	}else{
-
 
200
            		orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getCgstRate()), FONT_NORMAL));
-
 
201
            		orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getCgstAmount()), FONT_NORMAL));
-
 
202
            		orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getSgstRate()), FONT_NORMAL));
-
 
203
            		orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getSgstAmount()), FONT_NORMAL));
-
 
204
            		cgstTotalAmount = cgstTotalAmount + insurancePolicy.getCgstAmount();
-
 
205
            		sgstTotalAmount = sgstTotalAmount + insurancePolicy.getSgstAmount();
-
 
206
            	}
-
 
207
        	}
188
            //orders.addCell("1");
208
            //orders.addCell("1");
189
            //orders.addCell("Sansui X71Activ Ta2s");
209
            //orders.addCell("Sansui X71Activ Ta2s");
190
            //orders.setHeaderRows(1);
210
            //orders.setHeaderRows(1);
191
            //orders.getDefaultCell().setBorder(Rectangle.NO_BORDER);
211
            //orders.getDefaultCell().setBorder(Rectangle.NO_BORDER);
192
            //orders.addCell(orderDetail);
212
            //orders.addCell(orderDetail);