Subversion Repositories SmartDukaan

Rev

Rev 7672 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7672 Rev 21617
Line 10... Line 10...
10
import in.shop2020.thrift.clients.PurchaseClient;
10
import in.shop2020.thrift.clients.PurchaseClient;
11
import in.shop2020.warehouse.ScanType;
11
import in.shop2020.warehouse.ScanType;
12
import in.shop2020.warehouse.TransferLotStatus;
12
import in.shop2020.warehouse.TransferLotStatus;
13
import in.shop2020.warehouse.WarehouseServiceException;
13
import in.shop2020.warehouse.WarehouseServiceException;
14
 
14
 
-
 
15
import java.util.Date;
-
 
16
 
15
import org.apache.commons.logging.Log;
17
import org.apache.commons.logging.Log;
16
import org.apache.commons.logging.LogFactory;
18
import org.apache.commons.logging.LogFactory;
17
 
19
 
18
 
20
 
19
/**
21
/**
Line 31... Line 33...
31
    private long currentQuantity;
33
    private long currentQuantity;
32
    private long purchaseId;
34
    private long purchaseId;
33
    private long purchaseReturnId;
35
    private long purchaseReturnId;
34
    private long currentWarehouseId;
36
    private long currentWarehouseId;
35
    private ScanType lastScanType;
37
    private ScanType lastScanType;
-
 
38
    private Date activated;
-
 
39
    private Date created;
36
    private long physicalWarehouseId;
40
    private long physicalWarehouseId;
37
    private TransferLotStatus transferStatus;
41
    private TransferLotStatus transferStatus;
38
 
42
 
39
    public static InventoryItem create(in.shop2020.warehouse.InventoryItem thriftInventoryItem) {
43
    public static InventoryItem create(in.shop2020.warehouse.InventoryItem thriftInventoryItem) {
40
        InventoryItem inventoryItem = new InventoryItem();
44
        InventoryItem inventoryItem = new InventoryItem();
Line 48... Line 52...
48
        inventoryItem.purchaseReturnId = thriftInventoryItem.getPurchaseReturnId();
52
        inventoryItem.purchaseReturnId = thriftInventoryItem.getPurchaseReturnId();
49
        inventoryItem.currentWarehouseId = thriftInventoryItem.getCurrentWarehouseId();
53
        inventoryItem.currentWarehouseId = thriftInventoryItem.getCurrentWarehouseId();
50
        inventoryItem.lastScanType = thriftInventoryItem.getLastScanType();
54
        inventoryItem.lastScanType = thriftInventoryItem.getLastScanType();
51
        inventoryItem.physicalWarehouseId = thriftInventoryItem.getPhysicalWarehouseId();
55
        inventoryItem.physicalWarehouseId = thriftInventoryItem.getPhysicalWarehouseId();
52
        inventoryItem.transferStatus = thriftInventoryItem.getTransferStatus();
56
        inventoryItem.transferStatus = thriftInventoryItem.getTransferStatus();
-
 
57
        inventoryItem.created = new Date();
53
 
58
 
54
        return inventoryItem;
59
        return inventoryItem;
55
    }
60
    }
56
 
61
 
57
    public in.shop2020.warehouse.InventoryItem convert() throws WarehouseServiceException {
62
    public in.shop2020.warehouse.InventoryItem convert() throws WarehouseServiceException {
Line 65... Line 70...
65
        inventoryItem.setPurchaseReturnId(purchaseReturnId);
70
        inventoryItem.setPurchaseReturnId(purchaseReturnId);
66
        inventoryItem.setSerialNumber(serialNumber);
71
        inventoryItem.setSerialNumber(serialNumber);
67
        inventoryItem.setCurrentWarehouseId(currentWarehouseId);
72
        inventoryItem.setCurrentWarehouseId(currentWarehouseId);
68
        inventoryItem.setLastScanType(lastScanType);        
73
        inventoryItem.setLastScanType(lastScanType);        
69
        inventoryItem.setTransferStatus(transferStatus);        
74
        inventoryItem.setTransferStatus(transferStatus);        
70
        inventoryItem.setPhysicalWarehouseId(physicalWarehouseId);        
75
        inventoryItem.setPhysicalWarehouseId(physicalWarehouseId);
-
 
76
        if(this.activated!=null) {
-
 
77
        	inventoryItem.setActivated(this.activated.getTime());
-
 
78
        }
-
 
79
        if(this.created != null) {
-
 
80
        	inventoryItem.setCreated(this.created.getTime());
-
 
81
        }
71
 
82
 
72
        // Setting derived fields
83
        // Setting derived fields
73
        try {
84
        try {
74
            Client client = new PurchaseClient().getClient();
85
            Client client = new PurchaseClient().getClient();
75
            PurchaseOrder purchaseOrder = client.getPurchaseOrderForPurchase(purchaseId);
86
            PurchaseOrder purchaseOrder = client.getPurchaseOrderForPurchase(purchaseId);
Line 87... Line 98...
87
        }
98
        }
88
 
99
 
89
        return inventoryItem;
100
        return inventoryItem;
90
    }
101
    }
91
 
102
 
-
 
103
    public in.shop2020.warehouse.InventoryItem convert(boolean derived) throws WarehouseServiceException {
-
 
104
    	in.shop2020.warehouse.InventoryItem inventoryItem = new in.shop2020.warehouse.InventoryItem();
-
 
105
    	inventoryItem.setId(id);
-
 
106
    	inventoryItem.setItemId(itemId);
-
 
107
    	inventoryItem.setCurrentQuantity(currentQuantity);
-
 
108
    	inventoryItem.setInitialQuantity(initialQuantity);
-
 
109
    	inventoryItem.setItemNumber(itemNumber);
-
 
110
    	inventoryItem.setPurchaseId(purchaseId);
-
 
111
    	inventoryItem.setPurchaseReturnId(purchaseReturnId);
-
 
112
    	inventoryItem.setSerialNumber(serialNumber);
-
 
113
    	inventoryItem.setCurrentWarehouseId(currentWarehouseId);
-
 
114
    	inventoryItem.setLastScanType(lastScanType);        
-
 
115
    	inventoryItem.setTransferStatus(transferStatus);        
-
 
116
    	inventoryItem.setPhysicalWarehouseId(physicalWarehouseId);
-
 
117
    	if(this.activated!=null) {
-
 
118
        	inventoryItem.setActivated(this.activated.getTime());
-
 
119
        }
-
 
120
        if(this.created != null) {
-
 
121
        	inventoryItem.setCreated(this.created.getTime());
-
 
122
        }
-
 
123
    	// Setting derived fields
-
 
124
    	if(derived) {
-
 
125
	    	try {
-
 
126
	    		Client client = new PurchaseClient().getClient();
-
 
127
	    		PurchaseOrder purchaseOrder = client.getPurchaseOrderForPurchase(purchaseId);
-
 
128
	    		inventoryItem.setSupplierId(purchaseOrder.getSupplierId());
-
 
129
	    		for (LineItem lineItem : purchaseOrder.getLineitems()) {
-
 
130
	    			if (lineItem.getItemId() == itemId) {
-
 
131
	    				inventoryItem.setUnitPrice(lineItem.getUnitPrice());
-
 
132
	    				inventoryItem.setNlc(lineItem.getNlc());
-
 
133
	    				break;
-
 
134
	    			}
-
 
135
	    		}
-
 
136
	    	} catch (Exception e) {
-
 
137
	    		logger.error("Could not fetch purchase order for purchase id: " + purchaseId, e);
-
 
138
	    		throw new WarehouseServiceException(ExceptionType.DATABASE_ERROR, "Could not find item in PO.");
-
 
139
	    	}
-
 
140
    	}
-
 
141
    	return inventoryItem;
-
 
142
    }
-
 
143
 
92
    public long getId() {
144
    public long getId() {
93
        return id;
145
        return id;
94
    }
146
    }
95
    public void setId(long id) {
147
    public void setId(long id) {
96
        this.id = id;
148
        this.id = id;
Line 169... Line 221...
169
	}
221
	}
170
 
222
 
171
	public void setPhysicalWarehouseId(long physicalWarehouseId) {
223
	public void setPhysicalWarehouseId(long physicalWarehouseId) {
172
		this.physicalWarehouseId = physicalWarehouseId;
224
		this.physicalWarehouseId = physicalWarehouseId;
173
	}
225
	}
-
 
226
 
-
 
227
	public Date getActivated() {
-
 
228
		return activated;
-
 
229
	}
-
 
230
 
-
 
231
	public void setActivated(Date activated) {
-
 
232
		this.activated = activated;
-
 
233
	}
-
 
234
 
-
 
235
	public Date getCreated() {
-
 
236
		return created;
-
 
237
	}
-
 
238
 
-
 
239
	public void setCreated(Date created) {
-
 
240
		this.created = created;
-
 
241
	}
-
 
242
	
-
 
243
	
174
	
244
	
175
}
245
}