Subversion Repositories SmartDukaan

Rev

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

Rev 2843 Rev 2915
Line 183... Line 183...
183
            PdfWriter.getInstance(document, baosPDF);
183
            PdfWriter.getInstance(document, baosPDF);
184
            document.addAuthor("shop2020");
184
            document.addAuthor("shop2020");
185
            document.addTitle("Invoice No: " + order.getInvoice_number());
185
            document.addTitle("Invoice No: " + order.getInvoice_number());
186
            document.open();
186
            document.open();
187
            
187
            
188
            PdfPTable dispatchAdviceTable = getDispatchAdviceTable(order, warehouse, provider, barcodeFontSize, destCode);
188
            PdfPTable dispatchAdviceTable = getDispatchAdviceTable(order, warehouse, provider, barcodeFontSize, destCode, withBill);
189
            dispatchAdviceTable.setSpacingAfter(10.0f);
189
            dispatchAdviceTable.setSpacingAfter(10.0f);
190
            dispatchAdviceTable.setWidthPercentage(90.0f);
190
            dispatchAdviceTable.setWidthPercentage(90.0f);
191
            
191
            
192
            PdfPTable taxTable = getTaxCumRetailInvoiceTable(order, provider);
192
            PdfPTable taxTable = getTaxCumRetailInvoiceTable(order, provider);
193
            taxTable.setSpacingBefore(5.0f);
193
            taxTable.setSpacingBefore(5.0f);
Line 204... Line 204...
204
            logger.error("Error while generating Invoice: ", e);
204
            logger.error("Error while generating Invoice: ", e);
205
        }
205
        }
206
        return baosPDF;
206
        return baosPDF;
207
    }
207
    }
208
    
208
    
209
    private PdfPTable getDispatchAdviceTable(Order order, Warehouse warehouse, Provider provider, float barcodeFontSize, String destCode){
209
    private PdfPTable getDispatchAdviceTable(Order order, Warehouse warehouse, Provider provider, float barcodeFontSize, String destCode, boolean withBill){
210
        Font barCodeFont = getBarCodeFont(provider, barcodeFontSize);
210
        Font barCodeFont = getBarCodeFont(provider, barcodeFontSize);
211
        
211
        
212
        PdfPTable table = new PdfPTable(1);
212
        PdfPTable table = new PdfPTable(1);
213
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
213
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
214
 
214
 
Line 221... Line 221...
221
        dispatchTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
221
        dispatchTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
222
        dispatchTable.addCell(customerTable);
222
        dispatchTable.addCell(customerTable);
223
        dispatchTable.addCell(new Phrase(" "));
223
        dispatchTable.addCell(new Phrase(" "));
224
        dispatchTable.addCell(providerInfoTable);
224
        dispatchTable.addCell(providerInfoTable);
225
        
225
        
-
 
226
        
-
 
227
        PdfPTable invoiceTable = null;
-
 
228
        if(withBill)
226
        PdfPTable invoiceTable = getTopInvoiceTable(order);
229
            invoiceTable = getTopInvoiceTable(order, tinNo);
-
 
230
        else
-
 
231
            invoiceTable = getTopInvoiceTable(order, warehouse.getTinNumber());
227
 
232
 
228
        PdfPCell addressCell = getAddressCell();
233
        PdfPCell addressCell = null;
-
 
234
        if(withBill)
-
 
235
            addressCell = getAddressCell(ourAddress);
-
 
236
        else
-
 
237
            addressCell = getAddressCell(warehouse.getLocation() + "\nPIN " + warehouse.getPincode() + "\n\n");
229
        
238
        
230
        table.addCell(logoCell);
239
        table.addCell(logoCell);
231
        table.addCell(titleCell);
240
        table.addCell(titleCell);
232
        table.addCell(dispatchTable);
241
        table.addCell(dispatchTable);
233
        table.addCell(invoiceTable);
242
        table.addCell(invoiceTable);
Line 284... Line 293...
284
        providerInfoTable.addCell(new Phrase("AWB Date   : " + DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date()), helvetica8));
293
        providerInfoTable.addCell(new Phrase("AWB Date   : " + DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date()), helvetica8));
285
        providerInfoTable.addCell(new Phrase("Weight         : " + order.getTotal_weight() + " Kg", helvetica8));
294
        providerInfoTable.addCell(new Phrase("Weight         : " + order.getTotal_weight() + " Kg", helvetica8));
286
        return providerInfoTable;
295
        return providerInfoTable;
287
    }
296
    }
288
 
297
 
289
    private PdfPTable getTopInvoiceTable(Order order){
298
    private PdfPTable getTopInvoiceTable(Order order, String tinNo){
290
        PdfPTable invoiceTable = new PdfPTable(new float[]{0.2f, 0.2f, 0.3f, 0.1f, 0.1f, 0.1f});
299
        PdfPTable invoiceTable = new PdfPTable(new float[]{0.2f, 0.2f, 0.3f, 0.1f, 0.1f, 0.1f});
291
        invoiceTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
300
        invoiceTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
292
 
301
 
293
        invoiceTable.addCell(getInvoiceTableHeader(6));
302
        invoiceTable.addCell(getInvoiceTableHeader(6));
294
 
303
 
Line 326... Line 335...
326
 
335
 
327
            invoiceTable.addCell(getPriceCell(lineitem.getTotal_price()));
336
            invoiceTable.addCell(getPriceCell(lineitem.getTotal_price()));
328
        }
337
        }
329
    }
338
    }
330
    
339
    
331
    private PdfPCell getAddressCell() {
340
    private PdfPCell getAddressCell(String address) {
332
        Paragraph addressParagraph = new Paragraph(ourAddress, new Font(FontFamily.TIMES_ROMAN, 8f));
341
        Paragraph addressParagraph = new Paragraph(address, new Font(FontFamily.TIMES_ROMAN, 8f));
333
        PdfPCell addressCell = new PdfPCell();
342
        PdfPCell addressCell = new PdfPCell();
334
        addressCell.addElement(addressParagraph);
343
        addressCell.addElement(addressParagraph);
335
        addressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
344
        addressCell.setHorizontalAlignment(Element.ALIGN_LEFT);
336
        addressCell.setBorder(Rectangle.NO_BORDER);
345
        addressCell.setBorder(Rectangle.NO_BORDER);
337
        return addressCell;
346
        return addressCell;