| Line 16... |
Line 16... |
| 16 |
import org.apache.logging.log4j.Logger;
|
16 |
import org.apache.logging.log4j.Logger;
|
| 17 |
import org.springframework.beans.factory.annotation.Autowired;
|
17 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 18 |
import org.springframework.stereotype.Component;
|
18 |
import org.springframework.stereotype.Component;
|
| 19 |
import org.springframework.transaction.annotation.Transactional;
|
19 |
import org.springframework.transaction.annotation.Transactional;
|
| 20 |
|
20 |
|
| - |
|
21 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 21 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
22 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 22 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
23 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| - |
|
24 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 23 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
25 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
| 24 |
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
|
26 |
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
|
| 25 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
27 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| - |
|
28 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| 26 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
29 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
30 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 27 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
31 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
32 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
33 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| - |
|
34 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
35 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.transaction.LineItemImeisRepository;
|
36 |
import com.spice.profitmandi.dao.repository.transaction.LineItemImeisRepository;
|
| 32 |
import com.spice.profitmandi.dao.repository.transaction.LineItemRepository;
|
37 |
import com.spice.profitmandi.dao.repository.transaction.LineItemRepository;
|
| 33 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
38 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 34 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
39 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 35 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
40 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 36 |
import com.spice.profitmandi.service.inventory.PurchaseService;
|
- |
|
| 37 |
import com.spice.profitmandi.service.order.OrderService;
|
41 |
import com.spice.profitmandi.service.order.OrderService;
|
| 38 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
42 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
| 39 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
43 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 40 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
44 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 41 |
import com.spice.profitmandi.service.user.RetailerService;
|
45 |
import com.spice.profitmandi.service.user.RetailerService;
|
| Line 88... |
Line 92... |
| 88 |
|
92 |
|
| 89 |
@Autowired
|
93 |
@Autowired
|
| 90 |
private DebitNoteRepository debitNoteRepository;
|
94 |
private DebitNoteRepository debitNoteRepository;
|
| 91 |
|
95 |
|
| 92 |
@Autowired
|
96 |
@Autowired
|
| - |
|
97 |
private GenericRepository genericRepository;
|
| - |
|
98 |
|
| - |
|
99 |
@Autowired
|
| 93 |
private PurchaseRepository purchaseRepository;
|
100 |
private PurchaseRepository purchaseRepository;
|
| 94 |
|
101 |
|
| 95 |
@Autowired
|
102 |
@Autowired
|
| 96 |
private PriceDropService priceDropService;
|
103 |
private PriceDropService priceDropService;
|
| 97 |
|
104 |
|
| 98 |
@Autowired
|
105 |
@Autowired
|
| 99 |
private SchemeService schemeService;
|
106 |
private SchemeService schemeService;
|
| 100 |
|
107 |
|
| - |
|
108 |
@Autowired
|
| - |
|
109 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| - |
|
110 |
|
| - |
|
111 |
@Autowired
|
| - |
|
112 |
private ScanRecordRepository scanRecordRepository;
|
| - |
|
113 |
|
| 101 |
public void dropCorrection() throws Exception {
|
114 |
public void dropCorrection() throws Exception {
|
| 102 |
|
115 |
|
| 103 |
walletService.rollbackAmountFromWallet(175128034, 274, 4, WalletReferenceType.PRICE_DROP,
|
116 |
walletService.rollbackAmountFromWallet(175128034, 274, 4, WalletReferenceType.PRICE_DROP,
|
| 104 |
"Scheme differential for Price Drop of Rs.712 on Samsung J6 J600GG, on 01-08-2018 for missing 1pc");
|
117 |
"Scheme differential for Price Drop of Rs.712 on Samsung J6 J600GG, on 01-08-2018 for missing 1pc");
|
| 105 |
walletService.rollbackAmountFromWallet(175128034, -259, 4, WalletReferenceType.PRICE_DROP,
|
118 |
walletService.rollbackAmountFromWallet(175128034, -259, 4, WalletReferenceType.PRICE_DROP,
|
| Line 150... |
Line 163... |
| 150 |
}
|
163 |
}
|
| 151 |
}
|
164 |
}
|
| 152 |
|
165 |
|
| 153 |
}
|
166 |
}
|
| 154 |
|
167 |
|
| 155 |
public void migarateLineItemsToNewTable() {
|
168 |
public void migarateLineItemsToNewTable() throws Exception {
|
| 156 |
LOGGER.info("Before Migrated LineItems Successfully");
|
169 |
LOGGER.info("Before Migrated LineItems Successfully");
|
| 157 |
int lineItemImeiId = 0;
|
170 |
int lineItemImeiId = 0;
|
| 158 |
LocalDateTime startDate = null;
|
171 |
LocalDateTime startDate = null;
|
| 159 |
try {
|
172 |
try {
|
| 160 |
lineItemImeiId = lineItemImeisRepository.selectMaxId();
|
173 |
lineItemImeiId = lineItemImeisRepository.selectMaxId();
|
| Line 194... |
Line 207... |
| 194 |
|
207 |
|
| 195 |
public void cancelOrder(List<String> invoiceNumbers) throws Exception {
|
208 |
public void cancelOrder(List<String> invoiceNumbers) throws Exception {
|
| 196 |
orderService.cancelOrder(invoiceNumbers);
|
209 |
orderService.cancelOrder(invoiceNumbers);
|
| 197 |
}
|
210 |
}
|
| 198 |
|
211 |
|
| 199 |
public void migratePurchase() {
|
212 |
public void migratePurchase() throws Exception{
|
| 200 |
List<Purchase> purchases = purchaseRepository.selectPurchaseAllPurchasesLessThanZero();
|
213 |
List<Purchase> purchases = purchaseRepository.selectPurchaseAllPurchasesLessThanZero();
|
| 201 |
System.out.printf("Total Purchases count is %s", purchases.size());
|
214 |
System.out.printf("Total Purchases count is %s", purchases.size());
|
| 202 |
for (Purchase purchase : purchases) {
|
215 |
for (Purchase purchase : purchases) {
|
| 203 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchase.getId());
|
216 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchase.getId());
|
| 204 |
Map<Integer, List<InventoryItem>> itemIdInventoryMap = inventoryItems.stream()
|
217 |
Map<Integer, List<InventoryItem>> itemIdInventoryMap = inventoryItems.stream()
|
| Line 215... |
Line 228... |
| 215 |
itemQtyEntry.getKey());
|
228 |
itemQtyEntry.getKey());
|
| 216 |
continue;
|
229 |
continue;
|
| 217 |
}
|
230 |
}
|
| 218 |
int ourSale = ourSaleItemQtyMap.get(itemQtyEntry.getKey());
|
231 |
int ourSale = ourSaleItemQtyMap.get(itemQtyEntry.getKey());
|
| 219 |
int quantityToReduce = itemQtyEntry.getValue() - ourSale;
|
232 |
int quantityToReduce = itemQtyEntry.getValue() - ourSale;
|
| 220 |
if (quantityToReduce > 0) {
|
- |
|
| 221 |
List<InventoryItem> itemIis = itemIdInventoryMap.get(itemQtyEntry.getKey());
|
233 |
List<InventoryItem> itemIis = itemIdInventoryMap.get(itemQtyEntry.getKey());
|
| 222 |
if (itemIdInventoryMap != null) {
|
234 |
if (itemIdInventoryMap != null) {
|
| 223 |
for (InventoryItem ii : itemIis) {
|
235 |
for (InventoryItem ii : itemIis) {
|
| - |
|
236 |
if (ii.getGoodQuantity() >= quantityToReduce && ii.getInitialQuantity() >= quantityToReduce) {
|
| - |
|
237 |
LOGGER.info("Changed in inventoryItems {}, {}, {}, {}, {}, {}, {}",
|
| - |
|
238 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
| - |
|
239 |
ii.getInitialQuantity(), ii.getGoodQuantity(), ii.getBadQuantity(),
|
| - |
|
240 |
quantityToReduce);
|
| 224 |
if (ii.getGoodQuantity() >= quantityToReduce
|
241 |
if (ii.getGoodQuantity() == quantityToReduce) {
|
| - |
|
242 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
| - |
|
243 |
if (scanRecords.size() == 1) {
|
| - |
|
244 |
CurrentInventorySnapshot cis = currentInventorySnapshotRepository
|
| - |
|
245 |
.selectByItemIdAndFofoId(itemQtyEntry.getKey(), purchase.getFofoId());
|
| 225 |
&& ii.getInitialQuantity() >= quantityToReduce) {
|
246 |
if (cis.getAvailability() - quantityToReduce >= 0) {
|
| - |
|
247 |
scanRecordRepository.delete(scanRecords.get(0));
|
| - |
|
248 |
genericRepository.delete(ii);
|
| - |
|
249 |
cis.setAvailability(cis.getAvailability() - quantityToReduce);
|
| - |
|
250 |
LOGGER.info("Rectified {}, {}, {}, {}, {}, {}, {}",
|
| - |
|
251 |
purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
|
| - |
|
252 |
ii.getInitialQuantity(), ii.getGoodQuantity(), ii.getBadQuantity(),
|
| - |
|
253 |
quantityToReduce);
|
| - |
|
254 |
break;
|
| - |
|
255 |
}
|
| - |
|
256 |
} else if (scanRecords.size() == 0) {
|
| 226 |
LOGGER.info("Changed in inventoryItems {}, {}, {}, {}, {}, {}, {}", purchase.getPurchaseReference(),
|
257 |
LOGGER.info("Skipped {}, {}, {}, {}, {}, {}, {}", purchase.getPurchaseReference(),
|
| 227 |
ii.getId(), ii.getItemId(), ii.getInitialQuantity(), ii.getGoodQuantity(), ii.getBadQuantity(), quantityToReduce);
|
258 |
ii.getId(), ii.getItemId(), ii.getInitialQuantity(), ii.getGoodQuantity(),
|
| - |
|
259 |
ii.getBadQuantity(), quantityToReduce);
|
| - |
|
260 |
}
|
| - |
|
261 |
// Delete it immediately and make changes.
|
| 228 |
}
|
262 |
}
|
| 229 |
}
|
263 |
}
|
| 230 |
}
|
264 |
}
|
| 231 |
}
|
265 |
}
|
| 232 |
}
|
266 |
}
|
| 233 |
}
|
267 |
}
|
| - |
|
268 |
throw new Exception();
|
| 234 |
}
|
269 |
}
|
| 235 |
}
|
270 |
}
|
| 236 |
|
271 |
|