Subversion Repositories SmartDukaan

Rev

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

Rev 5945 Rev 5948
Line 4... Line 4...
4
import in.shop2020.logistics.DeliveryType;
4
import in.shop2020.logistics.DeliveryType;
5
import in.shop2020.logistics.LogisticsServiceException;
5
import in.shop2020.logistics.LogisticsServiceException;
6
import in.shop2020.logistics.PickUpType;
6
import in.shop2020.logistics.PickUpType;
7
import in.shop2020.logistics.PickupStore;
7
import in.shop2020.logistics.PickupStore;
8
import in.shop2020.logistics.Provider;
8
import in.shop2020.logistics.Provider;
9
import in.shop2020.model.v1.catalog.CatalogServiceException;
9
import in.shop2020.model.v1.inventory.InventoryServiceException;
10
import in.shop2020.model.v1.inventory.Warehouse;
10
import in.shop2020.model.v1.inventory.Warehouse;
11
import in.shop2020.model.v1.catalog.CatalogService.Client;
11
import in.shop2020.model.v1.catalog.CatalogService.Client;
12
import in.shop2020.model.v1.order.Attribute;
12
import in.shop2020.model.v1.order.Attribute;
13
import in.shop2020.model.v1.order.LineItem;
13
import in.shop2020.model.v1.order.LineItem;
14
import in.shop2020.model.v1.order.Order;
14
import in.shop2020.model.v1.order.Order;
Line 16... Line 16...
16
import in.shop2020.model.v1.order.OrderType;
16
import in.shop2020.model.v1.order.OrderType;
17
import in.shop2020.thrift.clients.CatalogClient;
17
import in.shop2020.thrift.clients.CatalogClient;
18
import in.shop2020.thrift.clients.LogisticsClient;
18
import in.shop2020.thrift.clients.LogisticsClient;
19
import in.shop2020.thrift.clients.TransactionClient;
19
import in.shop2020.thrift.clients.TransactionClient;
20
import in.shop2020.thrift.clients.config.ConfigClient;
20
import in.shop2020.thrift.clients.config.ConfigClient;
-
 
21
import in.shop2020.thrift.clients.InventoryClient;
21
 
22
 
22
import java.io.ByteArrayOutputStream;
23
import java.io.ByteArrayOutputStream;
23
import java.io.File;
24
import java.io.File;
24
import java.io.FileOutputStream;
25
import java.io.FileOutputStream;
25
import java.io.IOException;
26
import java.io.IOException;
Line 107... Line 108...
107
class InvoiceGenerationService {
108
class InvoiceGenerationService {
108
    
109
    
109
    private static Logger logger = LoggerFactory.getLogger(InvoiceGenerationService.class);
110
    private static Logger logger = LoggerFactory.getLogger(InvoiceGenerationService.class);
110
    
111
    
111
    private TransactionClient tsc = null;
112
    private TransactionClient tsc = null;
112
    private CatalogClient csc = null;
113
    private InventoryClient csc = null;
113
    private LogisticsClient lsc = null;
114
    private LogisticsClient lsc = null;
114
    
115
    
115
    private static Locale indianLocale = new Locale("en", "IN");
116
    private static Locale indianLocale = new Locale("en", "IN");
116
    private DecimalFormat amountFormat = new DecimalFormat("#,##0.00");
117
    private DecimalFormat amountFormat = new DecimalFormat("#,##0.00");
117
 
118
 
Line 148... Line 149...
148
    }
149
    }
149
    
150
    
150
    public InvoiceGenerationService() {
151
    public InvoiceGenerationService() {
151
        try {
152
        try {
152
            tsc = new TransactionClient();
153
            tsc = new TransactionClient();
153
            csc = new CatalogClient();
154
            csc = new InventoryClient();
154
            lsc = new LogisticsClient();
155
            lsc = new LogisticsClient();
155
        } catch (Exception e) {
156
        } catch (Exception e) {
156
            logger.error("Error while instantiating thrift clients.", e);
157
            logger.error("Error while instantiating thrift clients.", e);
157
        }
158
        }
158
    }
159
    }
159
 
160
 
160
    public ByteArrayOutputStream generateInvoice(long orderId, boolean withBill, boolean printAll, long warehouseId) {
161
    public ByteArrayOutputStream generateInvoice(long orderId, boolean withBill, boolean printAll, long warehouseId) {
161
        ByteArrayOutputStream baosPDF = null;
162
        ByteArrayOutputStream baosPDF = null;
162
        in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
163
        in.shop2020.model.v1.order.TransactionService.Client tclient = tsc.getClient();
163
        Client iclient = csc.getClient();
164
        in.shop2020.model.v1.inventory.InventoryService.Client iclient = csc.getClient();
164
        in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
165
        in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
165
 
166
 
166
        
167
        
167
        try {
168
        try {
168
            baosPDF = new ByteArrayOutputStream();
169
            baosPDF = new ByteArrayOutputStream();
Line 200... Line 201...
200
            			destCode = provider.getPickup().toString();
201
            			destCode = provider.getPickup().toString();
201
            		else
202
            		else
202
            			destCode = logisticsClient.getDestinationCode(providerId, order.getCustomer_pincode());
203
            			destCode = logisticsClient.getDestinationCode(providerId, order.getCustomer_pincode());
203
 
204
 
204
            		barcodeFontSize = Integer.parseInt(ConfigClient.getClient().get(provider.getName().toLowerCase() + "_barcode_fontsize"));
205
            		barcodeFontSize = Integer.parseInt(ConfigClient.getClient().get(provider.getName().toLowerCase() + "_barcode_fontsize"));
205
            	} catch (CatalogServiceException ise) {
206
            	} catch (InventoryServiceException ise) {
206
            		logger.error("Error while getting the warehouse information.", ise);
207
            		logger.error("Error while getting the warehouse information.", ise);
207
            		return baosPDF;
208
            		return baosPDF;
208
            	} catch (LogisticsServiceException lse) {
209
            	} catch (LogisticsServiceException lse) {
209
            		logger.error("Error while getting the provider information.", lse);
210
            		logger.error("Error while getting the provider information.", lse);
210
            		return baosPDF;
211
            		return baosPDF;