| Line 18... |
Line 18... |
| 18 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
18 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
| 19 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
19 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
| 20 |
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
|
20 |
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
|
| 21 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
21 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
| 22 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
22 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 23 |
import com.spice.profitmandi.dao.entity.transaction.TransactionApproval;
|
- |
|
| 24 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
23 |
import com.spice.profitmandi.dao.entity.transaction.*;
|
| 25 |
import com.spice.profitmandi.dao.entity.user.Address;
|
24 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 26 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
25 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 27 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
26 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
| 28 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
27 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| 29 |
import com.spice.profitmandi.dao.enumuration.transaction.TransactionApprovalStatus;
|
28 |
import com.spice.profitmandi.dao.enumuration.transaction.TransactionApprovalStatus;
|
| - |
|
29 |
import com.spice.profitmandi.dao.model.hdfc.IrnResetOrderModel;
|
| 30 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
30 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
31 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| 32 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
32 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 33 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
33 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 34 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
34 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 35 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
35 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| - |
|
36 |
import com.spice.profitmandi.dao.repository.onboarding.LoiBrandCommitmentRepository;
|
| 36 |
import com.spice.profitmandi.dao.repository.transaction.*;
|
37 |
import com.spice.profitmandi.dao.repository.transaction.*;
|
| 37 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
38 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 38 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
39 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
| 39 |
import com.spice.profitmandi.service.EmailService;
|
40 |
import com.spice.profitmandi.service.EmailService;
|
| 40 |
import com.spice.profitmandi.service.NotificationService;
|
41 |
import com.spice.profitmandi.service.NotificationService;
|
| Line 82... |
Line 83... |
| 82 |
import java.time.LocalDateTime;
|
83 |
import java.time.LocalDateTime;
|
| 83 |
import java.time.format.DateTimeFormatter;
|
84 |
import java.time.format.DateTimeFormatter;
|
| 84 |
import java.time.temporal.ChronoUnit;
|
85 |
import java.time.temporal.ChronoUnit;
|
| 85 |
import java.util.*;
|
86 |
import java.util.*;
|
| 86 |
import java.util.stream.Collectors;
|
87 |
import java.util.stream.Collectors;
|
| - |
|
88 |
import java.util.stream.Stream;
|
| 87 |
|
89 |
|
| 88 |
@Controller
|
90 |
@Controller
|
| 89 |
@Transactional(rollbackFor = Throwable.class)
|
91 |
@Transactional(rollbackFor = Throwable.class)
|
| 90 |
public class OrderController {
|
92 |
public class OrderController {
|
| 91 |
|
93 |
|
| Line 199... |
Line 201... |
| 199 |
PositionRepository positionRepository;
|
201 |
PositionRepository positionRepository;
|
| 200 |
|
202 |
|
| 201 |
@Autowired
|
203 |
@Autowired
|
| 202 |
PendingOrderPlanRepository pendingOrderPlanRepository;
|
204 |
PendingOrderPlanRepository pendingOrderPlanRepository;
|
| 203 |
|
205 |
|
| - |
|
206 |
@Autowired
|
| - |
|
207 |
PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
| - |
|
208 |
|
| - |
|
209 |
@Autowired
|
| - |
|
210 |
SDCreditService sdCreditService;
|
| - |
|
211 |
|
| 204 |
@RequestMapping(value = "/wa-send-invoice", method = RequestMethod.GET)
|
212 |
@RequestMapping(value = "/wa-send-invoice", method = RequestMethod.GET)
|
| 205 |
public String sendWhatsappMessage(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId, Model model) {
|
213 |
public String sendWhatsappMessage(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId, Model model) {
|
| 206 |
try {
|
214 |
try {
|
| 207 |
this.sendWhatsappInvoice(fofoOrderRepository.selectByOrderId(orderId));
|
215 |
this.sendWhatsappInvoice(fofoOrderRepository.selectByOrderId(orderId));
|
| 208 |
} catch (Exception e) {
|
216 |
} catch (Exception e) {
|
| Line 569... |
Line 577... |
| 569 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
577 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 570 |
CustomerCreditNote custmoerCreditNote;
|
578 |
CustomerCreditNote custmoerCreditNote;
|
| 571 |
if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
|
579 |
if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
|
| 572 |
FofoOrderItem foi = fofoOrderItemRepository.selectById(foiBadReturnRequest.getFofoOrderItemId());
|
580 |
FofoOrderItem foi = fofoOrderItemRepository.selectById(foiBadReturnRequest.getFofoOrderItemId());
|
| 573 |
FofoOrder fo = fofoOrderRepository.selectByOrderId(foi.getOrderId());
|
581 |
FofoOrder fo = fofoOrderRepository.selectByOrderId(foi.getOrderId());
|
| 574 |
custmoerCreditNote = orderService.badReturn(fofoDetails.getEmailId(),fo.getFofoId(), foiBadReturnRequest);
|
582 |
custmoerCreditNote = orderService.badReturn(fofoDetails.getEmailId(), fo.getFofoId(), foiBadReturnRequest);
|
| 575 |
} else {
|
583 |
} else {
|
| 576 |
custmoerCreditNote = orderService.badReturn(fofoDetails.getFofoId(), foiBadReturnRequest);
|
584 |
custmoerCreditNote = orderService.badReturn(fofoDetails.getFofoId(), foiBadReturnRequest);
|
| 577 |
}
|
585 |
}
|
| 578 |
return responseSender.ok(custmoerCreditNote.getId());
|
586 |
return responseSender.ok(custmoerCreditNote.getId());
|
| 579 |
}
|
587 |
}
|
| Line 1614... |
Line 1622... |
| 1614 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
1622 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 1615 |
return "response";
|
1623 |
return "response";
|
| 1616 |
|
1624 |
|
| 1617 |
}
|
1625 |
}
|
| 1618 |
|
1626 |
|
| 1619 |
@Autowired
|
- |
|
| 1620 |
SDCreditService sdCreditService;
|
- |
|
| 1621 |
|
1627 |
|
| 1622 |
private void updateApprovalStatus(int transactionId, int approvalId, String approvedBy, LocalDateTime approvedOn, String remark, TransactionApprovalStatus transactionApprovalStatus) throws Exception {
|
1628 |
private void updateApprovalStatus(int transactionId, int approvalId, String approvedBy, LocalDateTime approvedOn, String remark, TransactionApprovalStatus transactionApprovalStatus) throws Exception {
|
| 1623 |
TransactionApproval transactionApproval = transactionApprovalRepository.selectById(transactionId);
|
1629 |
TransactionApproval transactionApproval = transactionApprovalRepository.selectById(transactionId);
|
| 1624 |
int retailerId = transactionRepository.selectById(transactionId).getRetailerId();
|
1630 |
int retailerId = transactionRepository.selectById(transactionId).getRetailerId();
|
| 1625 |
if (!transactionApproval.getStatus().equals(TransactionApprovalStatus.PENDING)) {
|
1631 |
if (!transactionApproval.getStatus().equals(TransactionApprovalStatus.PENDING)) {
|
| Line 1657... |
Line 1663... |
| 1657 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Bulk order template");
|
1663 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Bulk order template");
|
| 1658 |
|
1664 |
|
| 1659 |
return responseEntity;
|
1665 |
return responseEntity;
|
| 1660 |
|
1666 |
|
| 1661 |
}
|
1667 |
}
|
| - |
|
1668 |
|
| - |
|
1669 |
@Autowired
|
| - |
|
1670 |
EInvoiceDetailsRepository eInvoiceDetailsRepository;
|
| - |
|
1671 |
|
| - |
|
1672 |
@GetMapping("/resetIrnGeneratedPanel")
|
| - |
|
1673 |
public String resetIrnGeneratedPanel() {
|
| - |
|
1674 |
return "reset-irn-panel";
|
| - |
|
1675 |
}
|
| - |
|
1676 |
|
| - |
|
1677 |
@GetMapping("/getTransactionForIrnReset")
|
| - |
|
1678 |
public String getTransactionForIrnReset(@RequestParam String invoiceNumber, Model model) throws Exception {
|
| - |
|
1679 |
List<String> invoiceNumbers = Arrays.asList(invoiceNumber.split(","));
|
| - |
|
1680 |
List<EInvoiceDetails> eInvoiceDetailsList = eInvoiceDetailsRepository.selectByInvoiceNumbers(invoiceNumbers);
|
| - |
|
1681 |
if (invoiceNumbers.size() == eInvoiceDetailsList.size()) {
|
| - |
|
1682 |
model.addAttribute("irnResetOrderModelList", new ArrayList<>());
|
| - |
|
1683 |
model.addAttribute("notEligibleInvoiceNumbers", invoiceNumber);
|
| - |
|
1684 |
return "eligible-irn-reset-orders";
|
| - |
|
1685 |
}
|
| - |
|
1686 |
Set<String> existingInvoiceInEInvoiceDtl = eInvoiceDetailsList.stream().map(x -> x.getInvoiceNumber()).collect(Collectors.toSet());
|
| - |
|
1687 |
List<String> missingInvoiceInEInvoiceDtl = invoiceNumbers.stream().filter(x -> !existingInvoiceInEInvoiceDtl.contains(x)).collect(Collectors.toList());
|
| - |
|
1688 |
|
| - |
|
1689 |
List<Order> orderList = orderRepository.selectByInvoiceNumbers(missingInvoiceInEInvoiceDtl).stream().filter(x -> x.getIrnGenerated() != null).collect(Collectors.toList());
|
| - |
|
1690 |
Map<String, List<Order>> invoiceMap = orderList.stream().collect(Collectors.groupingBy(x -> x.getInvoiceNumber()));
|
| - |
|
1691 |
Set<String> notEligibleInvoiceNumbers = new HashSet<>();
|
| - |
|
1692 |
notEligibleInvoiceNumbers.addAll(existingInvoiceInEInvoiceDtl);
|
| - |
|
1693 |
List<IrnResetOrderModel> irnResetOrderModelList = new ArrayList<>();
|
| - |
|
1694 |
for (Map.Entry<String, List<Order>> invoiceMapEntry : invoiceMap.entrySet()) {
|
| - |
|
1695 |
String invoice = invoiceMapEntry.getKey();
|
| - |
|
1696 |
List<Order> orders = invoiceMapEntry.getValue();
|
| - |
|
1697 |
boolean isEligible = !orders.isEmpty() && orders.stream().allMatch(x -> x.getBillingTimestamp().toLocalDate().isAfter(LocalDate.now().minusDays(5)) && x.getIrnGenerated() != null);
|
| - |
|
1698 |
if (isEligible) {
|
| - |
|
1699 |
Order order = orders.get(0);
|
| - |
|
1700 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(order.getRetailerId());
|
| - |
|
1701 |
|
| - |
|
1702 |
IrnResetOrderModel irnResetOrderModel = new IrnResetOrderModel();
|
| - |
|
1703 |
irnResetOrderModel.setName(partnerOnBoardingPanelRepository.selectByCode(fofoStore.getCode()).getOutLetName());
|
| - |
|
1704 |
irnResetOrderModel.setInvoiceNumber(order.getInvoiceNumber());
|
| - |
|
1705 |
irnResetOrderModel.setInvoiceDate(order.getBillingTimestamp());
|
| - |
|
1706 |
irnResetOrderModel.setWarehouseId(ProfitMandiConstants.WAREHOUSE_MAP.get(order.getWarehouseId()));
|
| - |
|
1707 |
irnResetOrderModel.setTotalOrderValue(orders.stream().mapToDouble(Order::getTotalAmount).sum());
|
| - |
|
1708 |
irnResetOrderModelList.add(irnResetOrderModel);
|
| - |
|
1709 |
} else {
|
| - |
|
1710 |
notEligibleInvoiceNumbers.add(invoice);
|
| - |
|
1711 |
}
|
| - |
|
1712 |
}
|
| - |
|
1713 |
model.addAttribute("irnResetOrderModelList", irnResetOrderModelList);
|
| - |
|
1714 |
model.addAttribute("notEligibleInvoiceNumbers", notEligibleInvoiceNumbers.stream().collect(Collectors.joining(", ")));
|
| - |
|
1715 |
return "eligible-irn-reset-orders";
|
| - |
|
1716 |
}
|
| - |
|
1717 |
|
| - |
|
1718 |
@PutMapping("/resetOrdersIrn")
|
| - |
|
1719 |
public String resetIrn(@RequestParam String invoiceNumbers, Model model) throws Exception {
|
| - |
|
1720 |
List<String> invoices = new ArrayList<>();
|
| - |
|
1721 |
if (!invoiceNumbers.isEmpty()) {
|
| - |
|
1722 |
invoices = Arrays.asList(invoiceNumbers.split(","));
|
| - |
|
1723 |
}
|
| - |
|
1724 |
List<Order> orderList = orderRepository.selectByInvoiceNumbers(invoices);
|
| - |
|
1725 |
orderList.forEach(order -> {
|
| - |
|
1726 |
order.setIrnGenerated(null);
|
| - |
|
1727 |
});
|
| - |
|
1728 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
1729 |
return "response";
|
| - |
|
1730 |
}
|
| 1662 |
}
|
1731 |
}
|
| 1663 |
|
1732 |
|
| 1664 |
|
1733 |
|
| 1665 |
|
1734 |
|
| 1666 |
|
1735 |
|