| Line 8... |
Line 8... |
| 8 |
import java.util.HashMap;
|
8 |
import java.util.HashMap;
|
| 9 |
import java.util.HashSet;
|
9 |
import java.util.HashSet;
|
| 10 |
import java.util.Iterator;
|
10 |
import java.util.Iterator;
|
| 11 |
import java.util.List;
|
11 |
import java.util.List;
|
| 12 |
import java.util.Map;
|
12 |
import java.util.Map;
|
| - |
|
13 |
import java.util.Optional;
|
| - |
|
14 |
import java.util.Random;
|
| 13 |
import java.util.Set;
|
15 |
import java.util.Set;
|
| 14 |
import java.util.function.Function;
|
16 |
import java.util.function.Function;
|
| 15 |
import java.util.stream.Collectors;
|
17 |
import java.util.stream.Collectors;
|
| 16 |
|
18 |
|
| 17 |
import org.apache.logging.log4j.LogManager;
|
19 |
import org.apache.logging.log4j.LogManager;
|
| 18 |
import org.apache.logging.log4j.Logger;
|
20 |
import org.apache.logging.log4j.Logger;
|
| 19 |
import org.json.JSONObject;
|
21 |
import org.json.JSONObject;
|
| 20 |
import org.springframework.beans.factory.annotation.Autowired;
|
22 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 21 |
import org.springframework.beans.factory.annotation.Qualifier;
|
23 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| - |
|
24 |
import org.springframework.cache.annotation.Cacheable;
|
| 22 |
import org.springframework.stereotype.Component;
|
25 |
import org.springframework.stereotype.Component;
|
| 23 |
|
26 |
|
| 24 |
import com.spice.profitmandi.common.enumuration.ItemType;
|
27 |
import com.spice.profitmandi.common.enumuration.ItemType;
|
| 25 |
import com.spice.profitmandi.common.enumuration.SearchType;
|
28 |
import com.spice.profitmandi.common.enumuration.SearchType;
|
| 26 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
29 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| Line 30... |
Line 33... |
| 30 |
import com.spice.profitmandi.common.model.CreditNotePdfModel;
|
33 |
import com.spice.profitmandi.common.model.CreditNotePdfModel;
|
| 31 |
import com.spice.profitmandi.common.model.CustomAddress;
|
34 |
import com.spice.profitmandi.common.model.CustomAddress;
|
| 32 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
35 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
| 33 |
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
|
36 |
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
|
| 34 |
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
|
37 |
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
|
| - |
|
38 |
import com.spice.profitmandi.common.model.CustomLineItem;
|
| 35 |
import com.spice.profitmandi.common.model.CustomOrderItem;
|
39 |
import com.spice.profitmandi.common.model.CustomOrderItem;
|
| 36 |
import com.spice.profitmandi.common.model.CustomPaymentOption;
|
40 |
import com.spice.profitmandi.common.model.CustomPaymentOption;
|
| 37 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
41 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 38 |
import com.spice.profitmandi.common.model.FoiBadReturnRequest;
|
42 |
import com.spice.profitmandi.common.model.FoiBadReturnRequest;
|
| 39 |
import com.spice.profitmandi.common.model.GstRate;
|
43 |
import com.spice.profitmandi.common.model.GstRate;
|
| Line 69... |
Line 73... |
| 69 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
73 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 70 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
74 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 71 |
import com.spice.profitmandi.dao.entity.user.Address;
|
75 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 72 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
76 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
| 73 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
77 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
| - |
|
78 |
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
|
| 74 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
79 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 75 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
80 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
| 76 |
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
|
81 |
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
|
| 77 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
82 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 78 |
import com.spice.profitmandi.dao.enumuration.fofo.SettlementType;
|
83 |
import com.spice.profitmandi.dao.enumuration.fofo.SettlementType;
|
| Line 106... |
Line 111... |
| 106 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
111 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 107 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
112 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 108 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
113 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 109 |
import com.spice.profitmandi.dao.repository.user.CounterRepository;
|
114 |
import com.spice.profitmandi.dao.repository.user.CounterRepository;
|
| 110 |
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
|
115 |
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
|
| - |
|
116 |
import com.spice.profitmandi.dao.repository.warehouse.WarehouseInventoryItemRepository;
|
| 111 |
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
|
117 |
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
|
| 112 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
118 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 113 |
import com.spice.profitmandi.service.inventory.PurchaseReturnService;
|
119 |
import com.spice.profitmandi.service.inventory.PurchaseReturnService;
|
| 114 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
120 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
| 115 |
import com.spice.profitmandi.service.pricing.PricingService;
|
121 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| Line 165... |
Line 171... |
| 165 |
|
171 |
|
| 166 |
@Autowired
|
172 |
@Autowired
|
| 167 |
private FofoLineItemRepository fofoLineItemRepository;
|
173 |
private FofoLineItemRepository fofoLineItemRepository;
|
| 168 |
|
174 |
|
| 169 |
@Autowired
|
175 |
@Autowired
|
| - |
|
176 |
private WarehouseInventoryItemRepository warehouseInventoryItemRepository;
|
| - |
|
177 |
|
| - |
|
178 |
@Autowired
|
| 170 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
179 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 171 |
|
180 |
|
| 172 |
@Autowired
|
181 |
@Autowired
|
| 173 |
private PaymentOptionRepository paymentOptionRepository;
|
182 |
private PaymentOptionRepository paymentOptionRepository;
|
| 174 |
|
183 |
|
| Line 583... |
Line 592... |
| 583 |
public PdfModel getInvoicePdfModel(int orderId) throws ProfitMandiBusinessException {
|
592 |
public PdfModel getInvoicePdfModel(int orderId) throws ProfitMandiBusinessException {
|
| 584 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(orderId);
|
593 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(orderId);
|
| 585 |
return this.getInvoicePdfModel(fofoOrder);
|
594 |
return this.getInvoicePdfModel(fofoOrder);
|
| 586 |
}
|
595 |
}
|
| 587 |
|
596 |
|
| - |
|
597 |
@Override
|
| - |
|
598 |
@Cacheable(value = "order.dummymodel", cacheManager = "oneDayCacheManager")
|
| - |
|
599 |
public PdfModel getDummyPdfModel(String serialNumber) throws ProfitMandiBusinessException {
|
| - |
|
600 |
List<WarehouseInventoryItem> warehouseInventoryItems = warehouseInventoryItemRepository
|
| - |
|
601 |
.selectWarehouseInventoryItemBySerailNumbers(Arrays.asList(serialNumber));
|
| - |
|
602 |
if (warehouseInventoryItems.size() > 0) {
|
| - |
|
603 |
WarehouseInventoryItem warehouseInventoryItem = warehouseInventoryItems.get(0);
|
| - |
|
604 |
int currentQuantity = warehouseInventoryItems.get(0).getCurrentQuantity();
|
| - |
|
605 |
if (currentQuantity > 0) {
|
| - |
|
606 |
throw new ProfitMandiBusinessException("Serial Number", serialNumber,
|
| - |
|
607 |
"Serial Number exist in our warehouse");
|
| - |
|
608 |
} else {
|
| - |
|
609 |
try {
|
| - |
|
610 |
InventoryItem inventoryItem = inventoryItemRepository.selectBySerialNumber(serialNumber);
|
| - |
|
611 |
if (inventoryItem.getGoodQuantity() > 0) {
|
| - |
|
612 |
throw new ProfitMandiBusinessException("Serial Number", serialNumber,
|
| - |
|
613 |
"Serial Number is not yet billed by the partner");
|
| - |
|
614 |
} else {
|
| - |
|
615 |
List<ScanRecord> scanRecords = scanRecordRepository
|
| - |
|
616 |
.selectByInventoryItemId(inventoryItem.getId());
|
| - |
|
617 |
Optional<ScanRecord> scanRecord = scanRecords.stream().filter(x -> x.getOrderId() != 0)
|
| - |
|
618 |
.findFirst();
|
| - |
|
619 |
if (scanRecord.isPresent()) {
|
| - |
|
620 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(scanRecord.get().getOrderId());
|
| - |
|
621 |
return this.getInvoicePdfModel(fofoOrder);
|
| - |
|
622 |
} else {
|
| - |
|
623 |
throw new ProfitMandiBusinessException("Serial Number", serialNumber,
|
| - |
|
624 |
"Serial Number returned by partner, but in transit");
|
| - |
|
625 |
}
|
| - |
|
626 |
}
|
| - |
|
627 |
} catch (Exception e) {
|
| - |
|
628 |
// Map this serialNumber for dummy billing
|
| - |
|
629 |
int itemId = warehouseInventoryItem.getItemId();
|
| - |
|
630 |
LocalDateTime grnDate = warehouseInventoryItem.getCreated();
|
| - |
|
631 |
Random random = new Random();
|
| - |
|
632 |
int randomDays = random.ints(2, 15).findFirst().getAsInt();
|
| - |
|
633 |
LocalDateTime saleDate = grnDate.plusDays(randomDays);
|
| - |
|
634 |
FofoOrder fofoOrder = fofoOrderRepository.selectFirstOrderAfterDate(saleDate);
|
| - |
|
635 |
PdfModel pdfModel = this.getInvoicePdfModel(fofoOrder.getId());
|
| - |
|
636 |
this.modifyDummyModel(fofoOrder, pdfModel, itemId, serialNumber);
|
| - |
|
637 |
return pdfModel;
|
| - |
|
638 |
|
| - |
|
639 |
}
|
| - |
|
640 |
}
|
| - |
|
641 |
} else {
|
| - |
|
642 |
throw new ProfitMandiBusinessException("Serial Number", serialNumber,
|
| - |
|
643 |
"Serial Number does not exist in our warehouse");
|
| - |
|
644 |
}
|
| - |
|
645 |
}
|
| - |
|
646 |
|
| - |
|
647 |
void modifyDummyModel(FofoOrder fofoOrder, PdfModel pdfModel, int itemId, String serialNumber) throws ProfitMandiBusinessException {
|
| - |
|
648 |
|
| - |
|
649 |
int retailerAddressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(fofoOrder.getFofoId());
|
| - |
|
650 |
|
| - |
|
651 |
Address retailerAddress = addressRepository.selectById(retailerAddressId);
|
| - |
|
652 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
| - |
|
653 |
|
| - |
|
654 |
CustomerAddress customerAddress = customer.getCustomerAddress().stream()
|
| - |
|
655 |
.filter(x -> x.getId() == fofoOrder.getCustomerAddressId()).findFirst().get();
|
| - |
|
656 |
|
| - |
|
657 |
|
| - |
|
658 |
Integer stateId = null;
|
| - |
|
659 |
if (customerAddress.getState().equals(retailerAddress.getState())) {
|
| - |
|
660 |
try {
|
| - |
|
661 |
stateId = Long.valueOf(Utils.getStateInfo(customerAddress.getState()).getId()).intValue();
|
| - |
|
662 |
} catch (Exception e) {
|
| - |
|
663 |
LOGGER.error("Unable to get state rates");
|
| - |
|
664 |
}
|
| - |
|
665 |
}
|
| - |
|
666 |
CustomOrderItem cli = pdfModel.getOrderItems().stream().findFirst().get();
|
| - |
|
667 |
List<FofoOrderItem> fofoOrderItems = Arrays.asList(this.getDummyFofoOrderItem(itemId, fofoOrder.getId(), serialNumber, stateId));
|
| - |
|
668 |
|
| - |
|
669 |
CustomPaymentOption paymentOption = pdfModel.getPaymentOptions().get(0);
|
| - |
|
670 |
paymentOption.setAmount(fofoOrderItems.get(0).getMop());
|
| - |
|
671 |
Set<CustomOrderItem> customerFofoOrderItems = new HashSet<>();
|
| - |
|
672 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
| - |
|
673 |
CustomOrderItem customFofoOrderItem = new CustomOrderItem();
|
| - |
|
674 |
float totalTaxRate = fofoOrderItem.getIgstRate() + fofoOrderItem.getSgstRate()
|
| - |
|
675 |
+ fofoOrderItem.getCgstRate();
|
| - |
|
676 |
float taxableSellingPrice = fofoOrderItem.getSellingPrice() / (1 + totalTaxRate / 100);
|
| - |
|
677 |
float taxableDiscountPrice = fofoOrderItem.getDiscount() / (1 + totalTaxRate / 100);
|
| - |
|
678 |
|
| - |
|
679 |
customFofoOrderItem.setAmount(fofoOrderItem.getQuantity() * (taxableSellingPrice - taxableDiscountPrice));
|
| - |
|
680 |
customFofoOrderItem.setDescription(fofoOrderItem.getBrand() + " " + fofoOrderItem.getModelName() + " "
|
| - |
|
681 |
+ fofoOrderItem.getModelNumber() + "-" + fofoOrderItem.getColor());
|
| - |
|
682 |
Set<String> serialNumbers = this.toSerialNumbers(fofoOrderItem.getFofoLineItems());
|
| - |
|
683 |
// LOGGER.info("serialNumbers {}", serialNumbers);
|
| - |
|
684 |
// LOGGER.info("serialNumbers is empty {}", serialNumbers.isEmpty());
|
| - |
|
685 |
if (!serialNumbers.isEmpty()) {
|
| - |
|
686 |
customFofoOrderItem.setDescription(
|
| - |
|
687 |
customFofoOrderItem.getDescription() + "\n IMEIS - " + String.join(", ", serialNumbers));
|
| - |
|
688 |
}
|
| - |
|
689 |
customFofoOrderItem.setRate(taxableSellingPrice);
|
| - |
|
690 |
customFofoOrderItem.setDiscount(taxableDiscountPrice);
|
| - |
|
691 |
customFofoOrderItem.setQuantity(fofoOrderItem.getQuantity());
|
| - |
|
692 |
customFofoOrderItem.setNetAmount(
|
| - |
|
693 |
(fofoOrderItem.getSellingPrice() - fofoOrderItem.getDiscount()) * fofoOrderItem.getQuantity());
|
| - |
|
694 |
float igstAmount = (customFofoOrderItem.getAmount() * fofoOrderItem.getIgstRate()) / 100;
|
| - |
|
695 |
float cgstAmount = (customFofoOrderItem.getAmount() * fofoOrderItem.getCgstRate()) / 100;
|
| - |
|
696 |
float sgstAmount = (customFofoOrderItem.getAmount() * fofoOrderItem.getSgstRate()) / 100;
|
| - |
|
697 |
customFofoOrderItem.setIgstRate(fofoOrderItem.getIgstRate());
|
| - |
|
698 |
customFofoOrderItem.setIgstAmount(igstAmount);
|
| - |
|
699 |
customFofoOrderItem.setCgstRate(fofoOrderItem.getCgstRate());
|
| - |
|
700 |
customFofoOrderItem.setCgstAmount(cgstAmount);
|
| - |
|
701 |
customFofoOrderItem.setSgstRate(fofoOrderItem.getSgstRate());
|
| - |
|
702 |
customFofoOrderItem.setSgstAmount(sgstAmount);
|
| - |
|
703 |
customFofoOrderItem.setHsnCode(fofoOrderItem.getHsnCode());
|
| - |
|
704 |
customerFofoOrderItems.add(customFofoOrderItem);
|
| - |
|
705 |
}
|
| - |
|
706 |
pdfModel.setOrderItems(customerFofoOrderItems);
|
| - |
|
707 |
|
| - |
|
708 |
}
|
| - |
|
709 |
|
| 588 |
private PdfModel getInvoicePdfModel(FofoOrder fofoOrder) throws ProfitMandiBusinessException {
|
710 |
private PdfModel getInvoicePdfModel(FofoOrder fofoOrder) throws ProfitMandiBusinessException {
|
| 589 |
|
711 |
|
| 590 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository
|
712 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository
|
| 591 |
.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.ORDER);
|
713 |
.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.ORDER);
|
| 592 |
|
714 |
|
| Line 1037... |
Line 1159... |
| 1037 |
fofoOrderItem.setColor(item.getColor());
|
1159 |
fofoOrderItem.setColor(item.getColor());
|
| 1038 |
fofoOrderItemRepository.persist(fofoOrderItem);
|
1160 |
fofoOrderItemRepository.persist(fofoOrderItem);
|
| 1039 |
return fofoOrderItem;
|
1161 |
return fofoOrderItem;
|
| 1040 |
}
|
1162 |
}
|
| 1041 |
|
1163 |
|
| - |
|
1164 |
private FofoOrderItem getDummyFofoOrderItem(int itemId, int fofoOrderId,
|
| - |
|
1165 |
String serialNumber, Integer stateId) throws ProfitMandiBusinessException {
|
| - |
|
1166 |
Item item = itemRepository.selectById(itemId);
|
| - |
|
1167 |
TagListing tl = tagListingRepository.selectByItemId(itemId);
|
| - |
|
1168 |
FofoOrderItem fofoOrderItem = new FofoOrderItem();
|
| - |
|
1169 |
fofoOrderItem.setItemId(itemId);
|
| - |
|
1170 |
fofoOrderItem.setQuantity(1);
|
| - |
|
1171 |
fofoOrderItem.setSellingPrice(tl.getMop());
|
| - |
|
1172 |
fofoOrderItem.setOrderId(fofoOrderId);
|
| - |
|
1173 |
// In case listing gets removed rebill it using the selling price
|
| - |
|
1174 |
fofoOrderItem.setDp(tl.getSellingPrice());
|
| - |
|
1175 |
fofoOrderItem.setMop(tl.getMop());
|
| - |
|
1176 |
fofoOrderItem.setDiscount(0);
|
| - |
|
1177 |
|
| - |
|
1178 |
Map<Integer, GstRate> itemIdStateTaxRateMap = null;
|
| - |
|
1179 |
Map<Integer, Float> itemIdIgstTaxRateMap = null;
|
| - |
|
1180 |
if (stateId != null) {
|
| - |
|
1181 |
itemIdStateTaxRateMap = stateGstRateRepository.getStateTaxRate(Arrays.asList(itemId), stateId);
|
| - |
|
1182 |
} else {
|
| - |
|
1183 |
itemIdIgstTaxRateMap = stateGstRateRepository.getIgstTaxRate(Arrays.asList(itemId));
|
| - |
|
1184 |
}
|
| - |
|
1185 |
|
| - |
|
1186 |
if (stateId == null) {
|
| - |
|
1187 |
fofoOrderItem.setIgstRate(itemIdIgstTaxRateMap.get(itemId));
|
| - |
|
1188 |
} else {
|
| - |
|
1189 |
fofoOrderItem.setCgstRate(itemIdStateTaxRateMap.get(itemId).getCgstRate());
|
| - |
|
1190 |
fofoOrderItem.setSgstRate(itemIdStateTaxRateMap.get(itemId).getSgstRate());
|
| - |
|
1191 |
}
|
| - |
|
1192 |
|
| - |
|
1193 |
fofoOrderItem.setHsnCode(item.getHsnCode());
|
| - |
|
1194 |
fofoOrderItem.setBrand(item.getBrand());
|
| - |
|
1195 |
fofoOrderItem.setModelName(item.getModelName());
|
| - |
|
1196 |
fofoOrderItem.setModelNumber(item.getModelNumber());
|
| - |
|
1197 |
fofoOrderItem.setColor(item.getColor());
|
| - |
|
1198 |
|
| - |
|
1199 |
Set<FofoLineItem> fofoLineItems = new HashSet<>();
|
| - |
|
1200 |
FofoLineItem fli = new FofoLineItem();
|
| - |
|
1201 |
fli.setQuantity(1);
|
| - |
|
1202 |
fli.setSerialNumber(serialNumber);
|
| - |
|
1203 |
fofoLineItems.add(fli);
|
| - |
|
1204 |
fofoOrderItem.setFofoLineItems(fofoLineItems);
|
| - |
|
1205 |
|
| - |
|
1206 |
return fofoOrderItem;
|
| - |
|
1207 |
}
|
| - |
|
1208 |
|
| 1042 |
private void updateCurrentInventorySnapshot(List<CurrentInventorySnapshot> currentInventorySnapshots, int fofoId,
|
1209 |
private void updateCurrentInventorySnapshot(List<CurrentInventorySnapshot> currentInventorySnapshots, int fofoId,
|
| 1043 |
int itemId, int quantity) throws ProfitMandiBusinessException {
|
1210 |
int itemId, int quantity) throws ProfitMandiBusinessException {
|
| 1044 |
for (CurrentInventorySnapshot currentInventorySnapshot : currentInventorySnapshots) {
|
1211 |
for (CurrentInventorySnapshot currentInventorySnapshot : currentInventorySnapshots) {
|
| 1045 |
if (currentInventorySnapshot.getItemId() == itemId && currentInventorySnapshot.getFofoId() == fofoId) {
|
1212 |
if (currentInventorySnapshot.getItemId() == itemId && currentInventorySnapshot.getFofoId() == fofoId) {
|
| 1046 |
currentInventorySnapshotRepository.updateAvailabilityByItemIdAndFofoId(itemId, fofoId,
|
1213 |
currentInventorySnapshotRepository.updateAvailabilityByItemIdAndFofoId(itemId, fofoId,
|
| Line 1370... |
Line 1537... |
| 1370 |
CustomerCreditNote creditNote = generateCreditNote(fofoOrder, customerReturnItems);
|
1537 |
CustomerCreditNote creditNote = generateCreditNote(fofoOrder, customerReturnItems);
|
| 1371 |
for (CustomerReturnItem customerReturnItem : customerReturnItems) {
|
1538 |
for (CustomerReturnItem customerReturnItem : customerReturnItems) {
|
| 1372 |
purchaseReturnService.returnInventoryItem(fofoId, false, customerReturnItem.getInventoryItemId(),
|
1539 |
purchaseReturnService.returnInventoryItem(fofoId, false, customerReturnItem.getInventoryItemId(),
|
| 1373 |
ReturnType.BAD);
|
1540 |
ReturnType.BAD);
|
| 1374 |
}
|
1541 |
}
|
| 1375 |
//This should cancel the order
|
1542 |
// This should cancel the order
|
| 1376 |
fofoOrder.setCancelledTimestamp(LocalDateTime.now());
|
1543 |
fofoOrder.setCancelledTimestamp(LocalDateTime.now());
|
| 1377 |
return creditNote;
|
1544 |
return creditNote;
|
| 1378 |
}
|
1545 |
}
|
| 1379 |
|
1546 |
|
| 1380 |
private CustomerCreditNote generateCreditNote(FofoOrder fofoOrder, List<CustomerReturnItem> customerReturnItems)
|
1547 |
private CustomerCreditNote generateCreditNote(FofoOrder fofoOrder, List<CustomerReturnItem> customerReturnItems)
|
| Line 1514... |
Line 1681... |
| 1514 |
LocalDateTime dateTime = fofoOrderRepository.selectMaxSaleDateGroupByFofoIds(startDate, endDate).get(fofoId);
|
1681 |
LocalDateTime dateTime = fofoOrderRepository.selectMaxSaleDateGroupByFofoIds(startDate, endDate).get(fofoId);
|
| 1515 |
return dateTime;
|
1682 |
return dateTime;
|
| 1516 |
}
|
1683 |
}
|
| 1517 |
|
1684 |
|
| 1518 |
@Override
|
1685 |
@Override
|
| 1519 |
//Only being used internally
|
1686 |
// Only being used internally
|
| 1520 |
public float getSales(int fofoId, LocalDate onDate) {
|
1687 |
public float getSales(int fofoId, LocalDate onDate) {
|
| 1521 |
LocalDateTime startTime = LocalDateTime.of(onDate, LocalTime.MIDNIGHT);
|
1688 |
LocalDateTime startTime = LocalDateTime.of(onDate, LocalTime.MIDNIGHT);
|
| 1522 |
LocalDateTime endTime = LocalDateTime.of(onDate, LocalTime.MIDNIGHT).plusDays(1);
|
1689 |
LocalDateTime endTime = LocalDateTime.of(onDate, LocalTime.MIDNIGHT).plusDays(1);
|
| 1523 |
return this.getSales(fofoId, startTime, endTime);
|
1690 |
return this.getSales(fofoId, startTime, endTime);
|
| 1524 |
}
|
1691 |
}
|