Subversion Repositories SmartDukaan

Rev

Rev 24818 | Rev 24883 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23755 amit.gupta 1
package com.smartdukaan.cron.migrations;
2
 
24819 amit.gupta 3
import java.io.Serializable;
23824 amit.gupta 4
import java.time.LocalDate;
23755 amit.gupta 5
import java.time.LocalDateTime;
23824 amit.gupta 6
import java.time.LocalTime;
24819 amit.gupta 7
import java.util.ArrayList;
23755 amit.gupta 8
import java.util.Arrays;
23827 amit.gupta 9
import java.util.Collections;
24002 amit.gupta 10
import java.util.HashMap;
24005 amit.gupta 11
import java.util.HashSet;
23755 amit.gupta 12
import java.util.List;
24002 amit.gupta 13
import java.util.Map;
24641 amit.gupta 14
import java.util.stream.Collectors;
23755 amit.gupta 15
 
24819 amit.gupta 16
import org.apache.commons.io.output.ByteArrayOutputStream;
23755 amit.gupta 17
import org.apache.commons.lang.StringUtils;
18
import org.apache.logging.log4j.LogManager;
19
import org.apache.logging.log4j.Logger;
20
import org.springframework.beans.factory.annotation.Autowired;
24819 amit.gupta 21
import org.springframework.core.io.ByteArrayResource;
24767 amit.gupta 22
import org.springframework.mail.javamail.JavaMailSender;
23755 amit.gupta 23
import org.springframework.stereotype.Component;
24
import org.springframework.transaction.annotation.Transactional;
25
 
24819 amit.gupta 26
import com.spice.profitmandi.common.util.FileUtil;
27
import com.spice.profitmandi.common.util.Utils;
24716 amit.gupta 28
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
24806 amit.gupta 29
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
30
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
24005 amit.gupta 31
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
23898 amit.gupta 32
import com.spice.profitmandi.dao.entity.fofo.Purchase;
24716 amit.gupta 33
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
23824 amit.gupta 34
import com.spice.profitmandi.dao.entity.transaction.LineItem;
23755 amit.gupta 35
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
36
import com.spice.profitmandi.dao.entity.transaction.Order;
24802 amit.gupta 37
import com.spice.profitmandi.dao.entity.transaction.SellerWarehouse;
24722 amit.gupta 38
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
24716 amit.gupta 39
import com.spice.profitmandi.dao.repository.GenericRepository;
23899 amit.gupta 40
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
24716 amit.gupta 41
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
24002 amit.gupta 42
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
24806 amit.gupta 43
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
44
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
24002 amit.gupta 45
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
24806 amit.gupta 46
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
23898 amit.gupta 47
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
24716 amit.gupta 48
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
24002 amit.gupta 49
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
23755 amit.gupta 50
import com.spice.profitmandi.dao.repository.transaction.LineItemImeisRepository;
23824 amit.gupta 51
import com.spice.profitmandi.dao.repository.transaction.LineItemRepository;
23755 amit.gupta 52
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
24772 amit.gupta 53
import com.spice.profitmandi.dao.repository.transaction.ReturnOrderRepository;
24802 amit.gupta 54
import com.spice.profitmandi.dao.repository.transaction.SellerWarehouseRepository;
24767 amit.gupta 55
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
56
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
24002 amit.gupta 57
import com.spice.profitmandi.dao.repository.user.UserRepository;
23899 amit.gupta 58
import com.spice.profitmandi.service.inventory.InventoryService;
24266 amit.gupta 59
import com.spice.profitmandi.service.order.OrderService;
24005 amit.gupta 60
import com.spice.profitmandi.service.pricing.PriceDropService;
61
import com.spice.profitmandi.service.scheme.SchemeService;
23899 amit.gupta 62
import com.spice.profitmandi.service.transaction.TransactionService;
63
import com.spice.profitmandi.service.user.RetailerService;
64
import com.spice.profitmandi.service.wallet.WalletService;
23755 amit.gupta 65
 
24002 amit.gupta 66
import in.shop2020.model.v1.order.WalletReferenceType;
67
 
23755 amit.gupta 68
@Component
69
@Transactional(rollbackFor = Throwable.class)
70
public class RunOnceTasks {
71
 
72
	private static final Logger LOGGER = LogManager.getLogger(RunOnceTasks.class);
73
 
74
	@Autowired
23824 amit.gupta 75
	private LineItemRepository lineItemRepository;
24711 amit.gupta 76
 
23905 amit.gupta 77
	@Autowired
24802 amit.gupta 78
	private SellerWarehouseRepository sellerWarehouseRepository;
24814 amit.gupta 79
 
24802 amit.gupta 80
	@Autowired
24806 amit.gupta 81
	private FofoOrderItemRepository fofoOrderItemRepository;
24814 amit.gupta 82
 
24806 amit.gupta 83
	@Autowired
84
	private FofoOrderRepository fofoOrderRepository;
24814 amit.gupta 85
 
24806 amit.gupta 86
	@Autowired
24767 amit.gupta 87
	private UserWalletRepository userWalletRepository;
88
 
89
	@Autowired
90
	private UserWalletHistoryRepository userWalletHistoryRepository;
91
 
92
	@Autowired
24002 amit.gupta 93
	private UserRepository userRepository;
24711 amit.gupta 94
 
24002 amit.gupta 95
	@Autowired
23899 amit.gupta 96
	private WalletService walletService;
97
 
98
	@Autowired
99
	private InventoryService inventoryService;
100
 
101
	@Autowired
102
	private TransactionService transactionService;
103
 
24711 amit.gupta 104
	// Service for Tertiary/Partner Orders
24266 amit.gupta 105
	@Autowired
106
	private OrderService orderService;
23767 amit.gupta 107
 
23755 amit.gupta 108
	@Autowired
24772 amit.gupta 109
	private ReturnOrderRepository returnOrderRepository;
110
 
111
	@Autowired
23899 amit.gupta 112
	private FofoStoreRepository fofoStoreRepository;
113
 
114
	@Autowired
23755 amit.gupta 115
	private LineItemImeisRepository lineItemImeisRepository;
24711 amit.gupta 116
 
24002 amit.gupta 117
	@Autowired
118
	private InventoryItemRepository inventoryItemRepository;
24814 amit.gupta 119
 
24806 amit.gupta 120
	@Autowired
121
	private InvoiceNumberGenerationSequenceRepository invoiceNumberGenerationSequenceRepository;
23901 amit.gupta 122
 
23898 amit.gupta 123
	@Autowired
23899 amit.gupta 124
	private RetailerService retailerService;
24711 amit.gupta 125
 
24002 amit.gupta 126
	@Autowired
127
	private SchemeInOutRepository schemeInOutRepository;
24711 amit.gupta 128
 
24002 amit.gupta 129
	@Autowired
130
	private DebitNoteRepository debitNoteRepository;
23899 amit.gupta 131
 
132
	@Autowired
24716 amit.gupta 133
	private GenericRepository genericRepository;
134
 
135
	@Autowired
23898 amit.gupta 136
	private PurchaseRepository purchaseRepository;
24711 amit.gupta 137
 
24005 amit.gupta 138
	@Autowired
139
	private PriceDropService priceDropService;
24819 amit.gupta 140
 
141
	@Autowired
142
	private JavaMailSender googleMailSender;
24711 amit.gupta 143
 
24005 amit.gupta 144
	@Autowired
145
	private SchemeService schemeService;
24711 amit.gupta 146
 
24716 amit.gupta 147
	@Autowired
148
	private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
149
 
150
	@Autowired
24767 amit.gupta 151
	private OrderRepository orderRepository;
152
 
153
	@Autowired
24716 amit.gupta 154
	private ScanRecordRepository scanRecordRepository;
155
 
24767 amit.gupta 156
	@Autowired
157
	private JavaMailSender mailSender;
158
 
24005 amit.gupta 159
	public void dropCorrection() throws Exception {
160
 
24711 amit.gupta 161
		walletService.rollbackAmountFromWallet(175128034, 274, 4, WalletReferenceType.PRICE_DROP,
162
				"Scheme  differential for Price Drop of Rs.712 on Samsung J6 J600GG, on 01-08-2018 for missing 1pc");
163
		walletService.rollbackAmountFromWallet(175128034, -259, 4, WalletReferenceType.PRICE_DROP,
164
				"Scheme  differential for Price Drop of Rs.712 on Samsung J6 J600GG, on 01-08-2018 for missing 1pc");
165
		List<InventoryItem> iis = inventoryItemRepository.selectByIds(new HashSet<>(Arrays.asList(3518, 3516)));
166
		schemeService.reverseSchemes(iis, 8,
167
				"Scheme  differential for Price Drop of Rs.712 on Samsung J6 J600GG, on 01-08-2018. Total 2 item(s)");
168
		List<InventoryItem> iis1 = inventoryItemRepository.selectByIds(new HashSet<>(Arrays.asList(3502, 3334, 3503)));
169
		schemeService.reverseSchemes(iis1, 13,
170
				"Scheme  differential for Price Drop of Rs.485 on Samsung Galaxy J4 J400FD, on 18-07-2018. Total 3 item(s)");
171
 
172
		List<InventoryItem> iis2 = inventoryItemRepository.selectByIds(new HashSet<>(Arrays.asList(3319)));
173
		schemeService.reverseSchemes(iis2, 13,
174
				"Scheme  differential for Price Drop of Rs.485 on Samsung Galaxy J4 J400FD, on 18-07-2018. Total 1 item(s)");
24005 amit.gupta 175
	}
24711 amit.gupta 176
 
24002 amit.gupta 177
	public void schemeRollback() {
178
		Map<Integer, Float> fofoIdAmount = new HashMap<>();
24003 amit.gupta 179
		fofoIdAmount.put(175135218, 1942f);
180
		String description = "Price drop/differential rolled out as, they were already returned, Total 2pcs.";
24711 amit.gupta 181
		for (Map.Entry<Integer, Float> fofoIdAmountEntry : fofoIdAmount.entrySet()) {
182
			Integer fofoId = fofoIdAmountEntry.getKey();
24002 amit.gupta 183
			Float amount = fofoIdAmountEntry.getValue();
24003 amit.gupta 184
			walletService.rollbackAmountFromWallet(fofoId, amount, 4, WalletReferenceType.PRICE_DROP, description);
24002 amit.gupta 185
		}
24004 amit.gupta 186
		fofoIdAmount.put(175135218, 438f);
24711 amit.gupta 187
		for (Map.Entry<Integer, Float> fofoIdAmountEntry : fofoIdAmount.entrySet()) {
188
			Integer fofoId = fofoIdAmountEntry.getKey();
24004 amit.gupta 189
			Float amount = fofoIdAmountEntry.getValue();
190
			walletService.rollbackAmountFromWallet(fofoId, amount, 4, WalletReferenceType.PRICE_DROP, description);
191
		}
24002 amit.gupta 192
	}
23755 amit.gupta 193
 
23898 amit.gupta 194
	public void populateGrnTimestamp() {
195
		List<Purchase> allPurchases = purchaseRepository.selectAll();
23899 amit.gupta 196
		for (Purchase p : allPurchases) {
23898 amit.gupta 197
			String invoiceNumber = p.getPurchaseReference();
23899 amit.gupta 198
			if (p.getCompleteTimestamp() == null) {
23898 amit.gupta 199
				LOGGER.info("GRN for invoice {} is delivered but partially Completed.", p.getPurchaseReference());
200
			} else {
201
				List<Order> orders = orderRepository.selectByAirwayBillOrInvoiceNumber(invoiceNumber, p.getFofoId());
23899 amit.gupta 202
				for (Order order : orders) {
23902 amit.gupta 203
					if (order.getPartnerGrnTimestamp() == null) {
204
						order.setPartnerGrnTimestamp(p.getCompleteTimestamp());
23898 amit.gupta 205
						orderRepository.persist(order);
206
					}
207
				}
208
			}
209
		}
23899 amit.gupta 210
 
23898 amit.gupta 211
	}
23899 amit.gupta 212
 
24716 amit.gupta 213
	public void migarateLineItemsToNewTable() throws Exception {
23755 amit.gupta 214
		LOGGER.info("Before Migrated LineItems Successfully");
23824 amit.gupta 215
		int lineItemImeiId = 0;
216
		LocalDateTime startDate = null;
217
		try {
218
			lineItemImeiId = lineItemImeisRepository.selectMaxId();
23899 amit.gupta 219
			LineItem lineItem = lineItemRepository
220
					.selectById(lineItemImeisRepository.selectById(lineItemImeiId).getLineItemId());
23824 amit.gupta 221
			Order order = orderRepository.selectById(lineItem.getOrderId());
222
			startDate = order.getBillingTimestamp();
223
		} catch (Exception e) {
224
			LOGGER.info("Running before first time");
23826 amit.gupta 225
			startDate = LocalDateTime.of(LocalDate.of(2017, 7, 1), LocalTime.MIDNIGHT);
23824 amit.gupta 226
		}
227
		List<Order> orders = orderRepository.selectAllByBillingDatesBetween(startDate, LocalDateTime.now());
23827 amit.gupta 228
		Collections.reverse(orders);
23899 amit.gupta 229
 
23755 amit.gupta 230
		for (Order order : orders) {
23824 amit.gupta 231
			try {
23767 amit.gupta 232
				String serialNumbers = order.getLineItem().getSerialNumber();
233
				if (!StringUtils.isEmpty(serialNumbers)) {
234
					List<String> serialNumberList = Arrays.asList(serialNumbers.split(","));
235
					for (String serialNumber : serialNumberList) {
236
						int lineItemId = order.getLineItem().getId();
237
						LineItemImei lineItemImei = new LineItemImei();
238
						lineItemImei.setSerialNumber(serialNumber);
239
						lineItemImei.setLineItemId(lineItemId);
240
						lineItemImeisRepository.persist(lineItemImei);
241
					}
242
				} else {
243
					LOGGER.info("Serial Numbers dont exist for Order {}", order.getId());
23755 amit.gupta 244
				}
23824 amit.gupta 245
			} catch (Exception e) {
23899 amit.gupta 246
				LOGGER.info("Error occurred while creating lineitem imei {}, because of {}", order.getId(),
247
						e.getMessage());
23755 amit.gupta 248
			}
249
		}
250
		LOGGER.info("Migrated LineItems Successfully");
251
	}
24266 amit.gupta 252
 
253
	public void cancelOrder(List<String> invoiceNumbers) throws Exception {
254
		orderService.cancelOrder(invoiceNumbers);
255
	}
24711 amit.gupta 256
 
24722 amit.gupta 257
	public void migratePurchase() throws Exception {
24641 amit.gupta 258
		List<Purchase> purchases = purchaseRepository.selectPurchaseAllPurchasesLessThanZero();
24706 amit.gupta 259
		System.out.printf("Total Purchases count is %s", purchases.size());
24711 amit.gupta 260
		for (Purchase purchase : purchases) {
261
			List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchase.getId());
262
			Map<Integer, List<InventoryItem>> itemIdInventoryMap = inventoryItems.stream()
263
					.collect(Collectors.groupingBy(InventoryItem::getItemId));
264
			List<Order> orders = orderRepository.selectByAirwayBillOrInvoiceNumber(purchase.getPurchaseReference(),
265
					purchase.getFofoId());
266
			Map<Integer, Integer> ourSaleItemQtyMap = orders.stream().collect(Collectors.groupingBy(
267
					x -> x.getLineItem().getItemId(), Collectors.summingInt(x -> x.getLineItem().getQuantity())));
268
			Map<Integer, Integer> theirPurchaseItemQtyMap = inventoryItems.stream().collect(Collectors
269
					.groupingBy(InventoryItem::getItemId, Collectors.summingInt(InventoryItem::getInitialQuantity)));
24709 amit.gupta 270
			for (Map.Entry<Integer, Integer> itemQtyEntry : theirPurchaseItemQtyMap.entrySet()) {
24711 amit.gupta 271
				if (!ourSaleItemQtyMap.containsKey(itemQtyEntry.getKey())) {
272
					LOGGER.info("Cannot find in Invoice {} item {}", purchase.getPurchaseReference(),
273
							itemQtyEntry.getKey());
24646 amit.gupta 274
					continue;
24645 amit.gupta 275
				}
24709 amit.gupta 276
				int ourSale = ourSaleItemQtyMap.get(itemQtyEntry.getKey());
24713 amit.gupta 277
				int quantityToReduce = itemQtyEntry.getValue() - ourSale;
24716 amit.gupta 278
				List<InventoryItem> itemIis = itemIdInventoryMap.get(itemQtyEntry.getKey());
279
				if (itemIdInventoryMap != null) {
280
					for (InventoryItem ii : itemIis) {
24732 amit.gupta 281
						if (quantityToReduce > 0 && ii.getGoodQuantity() > 0) {
24734 amit.gupta 282
							LOGGER.info("Changed in inventoryItems {}, {}, {}, {}, {}, {}",
24716 amit.gupta 283
									purchase.getPurchaseReference(), ii.getId(), ii.getItemId(),
24734 amit.gupta 284
									ii.getInitialQuantity(), ii.getGoodQuantity(), quantityToReduce);
24730 amit.gupta 285
							if (ii.getGoodQuantity() > 0) {
24716 amit.gupta 286
								List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
24722 amit.gupta 287
								for (ScanRecord scanRecord : scanRecords) {
288
									if (scanRecord.getType().equals(ScanType.PURCHASE)) {
289
										CurrentInventorySnapshot cis = currentInventorySnapshotRepository
290
												.selectByItemIdAndFofoId(itemQtyEntry.getKey(), purchase.getFofoId());
24733 amit.gupta 291
										scanRecord.setQuantity(scanRecord.getQuantity() - ii.getGoodQuantity());
292
										ii.setInitialQuantity(ii.getInitialQuantity() - ii.getBadQuantity());
24735 amit.gupta 293
										quantityToReduce = quantityToReduce - ii.getGoodQuantity();
24733 amit.gupta 294
										ii.setGoodQuantity(0);
295
										cis.setAvailability(cis.getAvailability() - ii.getGoodQuantity());
296
										purchase.setUnfullfilledNonSerializedQuantity(
297
												purchase.getUnfullfilledNonSerializedQuantity() + quantityToReduce);
24767 amit.gupta 298
										LOGGER.info("Rectified {}, {}, {}, {}, {}, {}", purchase.getPurchaseReference(),
299
												ii.getId(), ii.getItemId(), ii.getInitialQuantity(),
300
												ii.getGoodQuantity(), quantityToReduce);
24733 amit.gupta 301
										break;
24716 amit.gupta 302
									}
303
								}
24711 amit.gupta 304
							}
24641 amit.gupta 305
						}
306
					}
307
				}
308
			}
309
		}
24767 amit.gupta 310
		// throw new Exception();
24641 amit.gupta 311
	}
24767 amit.gupta 312
 
24802 amit.gupta 313
	public void migrateChallansToInvoices() throws Exception {
24814 amit.gupta 314
		Map<String, List<Order>> invoiceOrdersMap = orderRepository.selectAllChallans().stream()
315
				.filter(x -> !x.getLineItem().getHsnCode().equals("NOGST"))
24794 amit.gupta 316
				.collect(Collectors.groupingBy(Order::getInvoiceNumber, Collectors.toList()));
24814 amit.gupta 317
 
24819 amit.gupta 318
		List<List<? extends Serializable>> rows = new ArrayList<>();
24814 amit.gupta 319
		for (String invoice : invoiceOrdersMap.keySet()) {
24794 amit.gupta 320
			Order oneOrder = invoiceOrdersMap.get(invoice).get(0);
321
			int totalOrders = invoiceOrdersMap.get(invoice).size();
322
			LineItem lineItem = oneOrder.getLineItem();
24802 amit.gupta 323
			oneOrder.setBillingTimestamp(LocalDateTime.now());
324
			oneOrder.setInvoiceNumber(getInvoiceNumber(oneOrder));
24819 amit.gupta 325
			rows.add(Arrays.asList(oneOrder.getId(), invoice, oneOrder.getInvoiceNumber(), lineItem.getQuantity()));
326
			LOGGER.info(invoice + "\t" + oneOrder.getInvoiceNumber() + oneOrder.getId() + "\t", "\t" + totalOrders + "\t" + lineItem.getQuantity());
24814 amit.gupta 327
			Purchase p = null;
328
			try {
329
				p = purchaseRepository.selectByPurchaseReferenceAndFofoId(invoice, oneOrder.getRetailerId());
330
			} catch (Exception e) {
24815 amit.gupta 331
				LOGGER.info("Could not find purchase for invoice {}", invoice);
24812 amit.gupta 332
			}
24814 amit.gupta 333
			if (p != null) {
334
				List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(p.getId());
335
				for (InventoryItem inventoryItem : inventoryItems) {
24815 amit.gupta 336
					LOGGER.info(inventoryItem.getItemId() + " " + inventoryItem.getGoodQuantity() + " "
24816 amit.gupta 337
							+ inventoryItem.getHsnCode() + " " + inventoryItem.getSerialNumber() + " " + p.getPurchaseReference());
24814 amit.gupta 338
				}
339
			}
340
 
24794 amit.gupta 341
		}
24818 amit.gupta 342
		changePartnerInvoices();
24819 amit.gupta 343
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(Arrays.asList("Order id", "Challan", "Invoice", "Quantity"), rows);
344
 
345
		Utils.sendMailWithAttachment(googleMailSender,
346
				new String[] { "amit.gupta@shop2020.in", "sunny.yadav@smartdukaan.com" }, null,
347
				"Challans Converted to Invoice", "PFA", "Challans-To-Invoice.csv", new ByteArrayResource(baos.toByteArray()));
348
		//throw new Exception();
24794 amit.gupta 349
	}
24767 amit.gupta 350
 
24802 amit.gupta 351
	private String getInvoiceNumber(Order oneOrder) {
24805 amit.gupta 352
		String prefix = oneOrder.getInvoiceNumber().split("-")[1].replaceAll("\\d*", "");
24803 amit.gupta 353
		System.out.println("Prefix is " + prefix);
24802 amit.gupta 354
		SellerWarehouse sellerWarehouse = sellerWarehouseRepository.selectByPrefix(prefix);
355
		int newSequence = sellerWarehouse.getInvoiceSequence() + 1;
356
		sellerWarehouse.setInvoiceSequence(newSequence);
24814 amit.gupta 357
		return prefix + newSequence;
24802 amit.gupta 358
	}
24814 amit.gupta 359
 
24806 amit.gupta 360
	private void changePartnerInvoices() throws Exception {
24814 amit.gupta 361
		List<FofoOrder> fofoOrders = fofoOrderRepository.selectByInvoiceNumberLike("%SEC%");
362
		for (FofoOrder fofoOrder : fofoOrders) {
24806 amit.gupta 363
			FofoOrderItem fofoOrderItem = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId()).get(0);
24814 amit.gupta 364
			if (fofoOrderItem.getBrand().equals("Vivo")) {
24806 amit.gupta 365
				String challanString = fofoOrder.getInvoiceNumber();
24814 amit.gupta 366
				String storeCode = invoiceNumberGenerationSequenceRepository.selectByFofoId(fofoOrder.getFofoId())
367
						.getPrefix();
24806 amit.gupta 368
				String invoiceNumber = orderService.getInvoiceNumber(fofoOrder.getFofoId(), storeCode);
369
				fofoOrder.setInvoiceNumber(invoiceNumber);
370
				fofoOrder.setCreateTimestamp(LocalDateTime.now());
24818 amit.gupta 371
				LOGGER.info(challanString + "\t" + invoiceNumber + "\t" + fofoOrderItem.getQuantity());
24806 amit.gupta 372
			}
24814 amit.gupta 373
 
24806 amit.gupta 374
		}
375
	}
24802 amit.gupta 376
 
23755 amit.gupta 377
}