| Line 129... |
Line 129... |
| 129 |
"Spice Online Retail Pvt. Ltd.\nKhasra No. 819, Block-K\nMahipalpur, New Delhi-110037\n");
|
129 |
"Spice Online Retail Pvt. Ltd.\nKhasra No. 819, Block-K\nMahipalpur, New Delhi-110037\n");
|
| 130 |
private static final String tinNo = properties.getProperty("sales_tax_tin", "07250399732");
|
130 |
private static final String tinNo = properties.getProperty("sales_tax_tin", "07250399732");
|
| 131 |
|
131 |
|
| 132 |
private static final String delhiPincodePrefix = "11";
|
132 |
private static final String delhiPincodePrefix = "11";
|
| 133 |
|
133 |
|
| 134 |
private static final double salesTaxLowRate = Double.parseDouble(properties.getProperty("sales_tax_low_rate", "5.0"));
|
- |
|
| 135 |
private static final double salesTaxHighRate = Double.parseDouble(properties.getProperty("sales_tax_high_rate", "12.5"));
|
- |
|
| 136 |
private static final double salesTaxCutOff = Double.parseDouble(properties.getProperty("sales_tax_cutoff", "10000"));
|
- |
|
| 137 |
|
- |
|
| 138 |
private static Properties readProperties(){
|
134 |
private static Properties readProperties(){
|
| 139 |
ResourceBundle resource = ResourceBundle.getBundle(InvoiceGenerationService.class.getName());
|
135 |
ResourceBundle resource = ResourceBundle.getBundle(InvoiceGenerationService.class.getName());
|
| 140 |
Properties props = new Properties();
|
136 |
Properties props = new Properties();
|
| 141 |
|
137 |
|
| 142 |
Enumeration<String> keys = resource.getKeys();
|
138 |
Enumeration<String> keys = resource.getKeys();
|
| Line 184... |
Line 180... |
| 184 |
return baosPDF;
|
180 |
return baosPDF;
|
| 185 |
}
|
181 |
}
|
| 186 |
}else{
|
182 |
}else{
|
| 187 |
orders.add(tclient.getOrder(orderId));
|
183 |
orders.add(tclient.getOrder(orderId));
|
| 188 |
}
|
184 |
}
|
| - |
|
185 |
boolean isFirst = true;
|
| 189 |
|
186 |
|
| 190 |
for(Order order: orders){
|
187 |
for(Order order: orders){
|
| 191 |
Warehouse warehouse = null;
|
188 |
Warehouse warehouse = null;
|
| 192 |
Provider provider = null;
|
189 |
Provider provider = null;
|
| 193 |
String destCode = null;
|
190 |
String destCode = null;
|
| Line 215... |
Line 212... |
| 215 |
logger.error("Error while getting some essential information from the services", te);
|
212 |
logger.error("Error while getting some essential information from the services", te);
|
| 216 |
return baosPDF;
|
213 |
return baosPDF;
|
| 217 |
}
|
214 |
}
|
| 218 |
|
215 |
|
| 219 |
if(printAll && warehouse.getBillingType() == BillingType.OURS_EXTERNAL){
|
216 |
if(printAll && warehouse.getBillingType() == BillingType.OURS_EXTERNAL){
|
| - |
|
217 |
if(isFirst){
|
| - |
|
218 |
document.add(getFixedTextTable(16, "Spice Online Retail Pvt Ltd"));
|
| - |
|
219 |
isFirst = false;
|
| - |
|
220 |
}
|
| 220 |
document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
|
221 |
document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
|
| 221 |
continue;
|
222 |
continue;
|
| 222 |
}
|
223 |
}
|
| 223 |
|
224 |
|
| 224 |
PdfPTable dispatchAdviceTable = getDispatchAdviceTable(order, warehouse, provider, barcodeFontSize, destCode, withBill);
|
225 |
PdfPTable dispatchAdviceTable = getDispatchAdviceTable(order, warehouse, provider, barcodeFontSize, destCode, withBill);
|
| Line 761... |
Line 762... |
| 761 |
|
762 |
|
| 762 |
PdfPCell extraInfoCell;
|
763 |
PdfPCell extraInfoCell;
|
| 763 |
if(billingType == BillingType.EXTERNAL){
|
764 |
if(billingType == BillingType.EXTERNAL){
|
| 764 |
extraInfoCell = new PdfPCell(new Paragraph( "*" + order.getId() + "* *" + order.getCustomer_name() + "* *" + order.getTotal_amount() + "*", barCodeFont));
|
765 |
extraInfoCell = new PdfPCell(new Paragraph( "*" + order.getId() + "* *" + order.getCustomer_name() + "* *" + order.getTotal_amount() + "*", barCodeFont));
|
| 765 |
}else{
|
766 |
}else{
|
| 766 |
extraInfoCell = new PdfPCell(new Paragraph( "*" + order.getId() + "* *" + "Spice Online Retail Pvt Ltd" + "* *" + order.getLineitems().get(0).getTransfer_price() + "*", barCodeFont));
|
767 |
extraInfoCell = new PdfPCell(new Paragraph( "*" + order.getId() + "* *" + order.getLineitems().get(0).getTransfer_price() + "*", barCodeFont));
|
| 767 |
}
|
768 |
}
|
| 768 |
|
769 |
|
| 769 |
extraInfoCell.setPaddingTop(20.0f);
|
770 |
extraInfoCell.setPaddingTop(20.0f);
|
| 770 |
extraInfoCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
771 |
extraInfoCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
| 771 |
extraInfoCell.setBorder(Rectangle.NO_BORDER);
|
772 |
extraInfoCell.setBorder(Rectangle.NO_BORDER);
|
| Line 773... |
Line 774... |
| 773 |
extraInfoTable.addCell(extraInfoCell);
|
774 |
extraInfoTable.addCell(extraInfoCell);
|
| 774 |
|
775 |
|
| 775 |
|
776 |
|
| 776 |
return extraInfoTable;
|
777 |
return extraInfoTable;
|
| 777 |
}
|
778 |
}
|
| - |
|
779 |
|
| - |
|
780 |
private PdfPTable getFixedTextTable(float barcodeFontSize, String printText){
|
| - |
|
781 |
PdfPTable extraInfoTable = new PdfPTable(1);
|
| - |
|
782 |
extraInfoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| - |
|
783 |
extraInfoTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
|
| - |
|
784 |
|
| - |
|
785 |
String fontPath = InvoiceGenerationService.class.getResource("/saholic-wn.TTF").getPath();
|
| - |
|
786 |
FontFactoryImp ttfFontFactory = new FontFactoryImp();
|
| - |
|
787 |
ttfFontFactory.register(fontPath, "barcode");
|
| - |
|
788 |
Font barCodeFont = ttfFontFactory.getFont("barcode", BaseFont.CP1252, true, barcodeFontSize);
|
| - |
|
789 |
|
| - |
|
790 |
PdfPCell extraInfoCell = new PdfPCell(new Paragraph( "*" + printText + "*", barCodeFont));
|
| - |
|
791 |
|
| - |
|
792 |
extraInfoCell.setPaddingTop(20.0f);
|
| - |
|
793 |
extraInfoCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
| - |
|
794 |
extraInfoCell.setBorder(Rectangle.NO_BORDER);
|
| - |
|
795 |
|
| - |
|
796 |
extraInfoTable.addCell(extraInfoCell);
|
| - |
|
797 |
|
| - |
|
798 |
return extraInfoTable;
|
| - |
|
799 |
}
|
| 778 |
|
800 |
|
| 779 |
public static void main(String[] args) throws IOException {
|
801 |
public static void main(String[] args) throws IOException {
|
| 780 |
InvoiceGenerationService invoiceGenerationService = new InvoiceGenerationService();
|
802 |
InvoiceGenerationService invoiceGenerationService = new InvoiceGenerationService();
|
| 781 |
long orderId = 148574;
|
803 |
long orderId = 148574;
|
| 782 |
ByteArrayOutputStream baos = invoiceGenerationService.generateInvoice(orderId, false, false, 1);
|
804 |
ByteArrayOutputStream baos = invoiceGenerationService.generateInvoice(orderId, false, false, 1);
|