| 21612 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 21689 |
ashik.ali |
3 |
import java.io.ByteArrayInputStream;
|
|
|
4 |
import java.io.ByteArrayOutputStream;
|
|
|
5 |
import java.io.InputStream;
|
| 22217 |
ashik.ali |
6 |
import java.time.DateTimeException;
|
|
|
7 |
import java.time.LocalDate;
|
| 22244 |
ashik.ali |
8 |
import java.time.LocalDateTime;
|
| 21680 |
ashik.ali |
9 |
import java.util.ArrayList;
|
| 21985 |
kshitij.so |
10 |
import java.util.Collection;
|
| 21680 |
ashik.ali |
11 |
import java.util.HashMap;
|
| 21612 |
ashik.ali |
12 |
import java.util.HashSet;
|
| 21985 |
kshitij.so |
13 |
import java.util.Iterator;
|
| 21680 |
ashik.ali |
14 |
import java.util.List;
|
|
|
15 |
import java.util.Map;
|
| 21612 |
ashik.ali |
16 |
import java.util.Set;
|
|
|
17 |
|
|
|
18 |
import javax.servlet.http.HttpServletRequest;
|
| 21689 |
ashik.ali |
19 |
import javax.servlet.http.HttpServletResponse;
|
| 21612 |
ashik.ali |
20 |
|
| 21985 |
kshitij.so |
21 |
import org.json.JSONObject;
|
| 21612 |
ashik.ali |
22 |
import org.slf4j.Logger;
|
|
|
23 |
import org.slf4j.LoggerFactory;
|
|
|
24 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 21689 |
ashik.ali |
25 |
import org.springframework.core.io.InputStreamResource;
|
|
|
26 |
import org.springframework.http.HttpHeaders;
|
|
|
27 |
import org.springframework.http.HttpStatus;
|
|
|
28 |
import org.springframework.http.MediaType;
|
|
|
29 |
import org.springframework.http.ResponseEntity;
|
| 21612 |
ashik.ali |
30 |
import org.springframework.stereotype.Controller;
|
| 22064 |
ashik.ali |
31 |
import org.springframework.transaction.annotation.Transactional;
|
| 21985 |
kshitij.so |
32 |
import org.springframework.ui.Model;
|
| 21612 |
ashik.ali |
33 |
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
34 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
35 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 21689 |
ashik.ali |
36 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21612 |
ashik.ali |
37 |
|
|
|
38 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 21985 |
kshitij.so |
39 |
import com.spice.profitmandi.common.model.CartFofo;
|
| 21680 |
ashik.ali |
40 |
import com.spice.profitmandi.common.model.CustomAddress;
|
| 21689 |
ashik.ali |
41 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
|
|
42 |
import com.spice.profitmandi.common.model.CustomFofoLineItem;
|
|
|
43 |
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
|
| 22217 |
ashik.ali |
44 |
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
|
| 21689 |
ashik.ali |
45 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 22217 |
ashik.ali |
46 |
import com.spice.profitmandi.common.model.GadgetCopsInsuranceModel;
|
| 21896 |
ashik.ali |
47 |
import com.spice.profitmandi.common.model.GstRate;
|
| 22660 |
ashik.ali |
48 |
import com.spice.profitmandi.common.model.PdfModel;
|
| 22581 |
ashik.ali |
49 |
import com.spice.profitmandi.common.model.PriceModel;
|
| 21612 |
ashik.ali |
50 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 22217 |
ashik.ali |
51 |
import com.spice.profitmandi.common.model.SerialNumberDetail;
|
|
|
52 |
import com.spice.profitmandi.common.util.InsuranceUtils;
|
| 21689 |
ashik.ali |
53 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 21680 |
ashik.ali |
54 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 21896 |
ashik.ali |
55 |
import com.spice.profitmandi.common.util.Utils;
|
| 22244 |
ashik.ali |
56 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 21728 |
ashik.ali |
57 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 22217 |
ashik.ali |
58 |
import com.spice.profitmandi.dao.entity.dtr.GadgetCopsInsuranceCalc;
|
|
|
59 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
|
|
60 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
|
|
61 |
import com.spice.profitmandi.dao.entity.dtr.PolicyNumberGenerationSequence;
|
| 21728 |
ashik.ali |
62 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
|
|
63 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
|
|
64 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
|
|
65 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
|
|
66 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
| 21896 |
ashik.ali |
67 |
import com.spice.profitmandi.dao.entity.fofo.FofoItemId;
|
| 21728 |
ashik.ali |
68 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
|
|
69 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItemSerialNumber;
|
|
|
70 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
|
|
71 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
|
|
72 |
import com.spice.profitmandi.dao.entity.fofo.InvoiceNumberGenerationSequence;
|
|
|
73 |
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
|
|
|
74 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
|
|
75 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 22354 |
ashik.ali |
76 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
|
|
77 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
| 21728 |
ashik.ali |
78 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 21883 |
kshitij.so |
79 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 22217 |
ashik.ali |
80 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
|
|
81 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
|
|
82 |
import com.spice.profitmandi.dao.repository.dtr.PolicyNumberGenerationSequenceRepository;
|
| 21728 |
ashik.ali |
83 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
|
|
84 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
|
|
85 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
|
|
86 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
|
|
87 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
|
|
88 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
|
|
89 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
|
|
90 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
|
|
91 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemSerialNumberRepository;
|
|
|
92 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
|
|
93 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
|
|
94 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
|
|
95 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
|
|
96 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
|
|
97 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
|
|
98 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 22354 |
ashik.ali |
99 |
import com.spice.profitmandi.dao.repository.user.CounterRepository;
|
|
|
100 |
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
|
| 22069 |
ashik.ali |
101 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 22139 |
amit.gupta |
102 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 21612 |
ashik.ali |
103 |
import com.spice.profitmandi.web.request.CreateOrderRequest;
|
|
|
104 |
import com.spice.profitmandi.web.request.CustomPaymentOption;
|
| 21680 |
ashik.ali |
105 |
import com.spice.profitmandi.web.response.ItemIdQuantityAvailability;
|
|
|
106 |
import com.spice.profitmandi.web.response.Quantity;
|
| 22069 |
ashik.ali |
107 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 21612 |
ashik.ali |
108 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
|
|
109 |
|
| 21985 |
kshitij.so |
110 |
import in.shop2020.model.v1.catalog.ItemType;
|
|
|
111 |
|
| 21612 |
ashik.ali |
112 |
@Controller
|
| 22037 |
amit.gupta |
113 |
@Transactional(rollbackFor=Throwable.class)
|
| 21612 |
ashik.ali |
114 |
public class OrderController {
|
|
|
115 |
|
|
|
116 |
private static final Logger LOGGER = LoggerFactory.getLogger(OrderController.class);
|
| 21985 |
kshitij.so |
117 |
|
| 21612 |
ashik.ali |
118 |
@Autowired
|
|
|
119 |
OrderRepository orderRepository;
|
| 21985 |
kshitij.so |
120 |
|
| 21612 |
ashik.ali |
121 |
@Autowired
|
|
|
122 |
InventoryItemRepository inventoryItemRepository;
|
| 21985 |
kshitij.so |
123 |
|
| 21612 |
ashik.ali |
124 |
@Autowired
|
| 21680 |
ashik.ali |
125 |
CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 21985 |
kshitij.so |
126 |
|
| 21680 |
ashik.ali |
127 |
@Autowired
|
|
|
128 |
InvoiceNumberGenerationSequenceRepository invoiceNumberGenerationSequenceRepository;
|
| 21985 |
kshitij.so |
129 |
|
| 21680 |
ashik.ali |
130 |
@Autowired
|
|
|
131 |
CustomerRepository customerRepository;
|
| 21985 |
kshitij.so |
132 |
|
| 21680 |
ashik.ali |
133 |
@Autowired
|
|
|
134 |
AddressRepository addressRepository;
|
| 21985 |
kshitij.so |
135 |
|
| 21680 |
ashik.ali |
136 |
@Autowired
|
|
|
137 |
FofoLineItemSerialNumberRepository fofoLineItemSerialNumberRepository;
|
| 21985 |
kshitij.so |
138 |
|
| 21680 |
ashik.ali |
139 |
@Autowired
|
|
|
140 |
FofoLineItemRepository fofoLineItemRepository;
|
| 21985 |
kshitij.so |
141 |
|
| 21680 |
ashik.ali |
142 |
@Autowired
|
|
|
143 |
PaymentOptionRepository paymentOptionRepository;
|
| 21985 |
kshitij.so |
144 |
|
| 21680 |
ashik.ali |
145 |
@Autowired
|
|
|
146 |
ScanRecordRepository scanRecordRepository;
|
| 21985 |
kshitij.so |
147 |
|
| 21680 |
ashik.ali |
148 |
@Autowired
|
|
|
149 |
FofoOrderRepository fofoOrderRepository;
|
| 21985 |
kshitij.so |
150 |
|
| 21680 |
ashik.ali |
151 |
@Autowired
|
| 21689 |
ashik.ali |
152 |
RetailerRepository retailerRepository;
|
| 21985 |
kshitij.so |
153 |
|
| 21689 |
ashik.ali |
154 |
@Autowired
|
|
|
155 |
UserRepository userRepository;
|
| 21985 |
kshitij.so |
156 |
|
| 21689 |
ashik.ali |
157 |
@Autowired
|
|
|
158 |
UserAccountRepository userAccountRepository;
|
| 21985 |
kshitij.so |
159 |
|
| 21689 |
ashik.ali |
160 |
@Autowired
|
|
|
161 |
RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
|
| 21985 |
kshitij.so |
162 |
|
| 21689 |
ashik.ali |
163 |
@Autowired
|
| 21711 |
ashik.ali |
164 |
CustomerAddressRepository customerAddressRepository;
|
| 21985 |
kshitij.so |
165 |
|
| 21711 |
ashik.ali |
166 |
@Autowired
|
| 21896 |
ashik.ali |
167 |
ItemRepository itemRepository;
|
| 22217 |
ashik.ali |
168 |
|
|
|
169 |
@Autowired
|
|
|
170 |
InsuranceProviderRepository insuranceProviderRepository;
|
|
|
171 |
|
|
|
172 |
@Autowired
|
|
|
173 |
InsurancePolicyRepository insurancePolicyRepository;
|
|
|
174 |
|
|
|
175 |
@Autowired
|
|
|
176 |
PolicyNumberGenerationSequenceRepository policyNumberGenerationSequenceRepository;
|
| 21985 |
kshitij.so |
177 |
|
| 21896 |
ashik.ali |
178 |
@Autowired
|
| 21612 |
ashik.ali |
179 |
MVCResponseSender mvcResponseSender;
|
| 21985 |
kshitij.so |
180 |
|
| 21612 |
ashik.ali |
181 |
@Autowired
|
| 22069 |
ashik.ali |
182 |
CookiesProcessor cookiesProcessor;
|
|
|
183 |
|
|
|
184 |
@Autowired
|
|
|
185 |
PricingService pricingService;
|
| 22244 |
ashik.ali |
186 |
|
| 22354 |
ashik.ali |
187 |
@Autowired
|
|
|
188 |
PrivateDealUserRepository privateDealUserRepository;
|
| 22244 |
ashik.ali |
189 |
|
|
|
190 |
@Autowired
|
| 22354 |
ashik.ali |
191 |
CounterRepository counterRepository;
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
@Autowired
|
| 22244 |
ashik.ali |
195 |
ResponseSender<?> responseSender;
|
| 21985 |
kshitij.so |
196 |
|
|
|
197 |
@RequestMapping(value = "/order")
|
|
|
198 |
public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model) throws Exception{
|
| 22244 |
ashik.ali |
199 |
LoginDetails loginDetails = null;
|
| 21985 |
kshitij.so |
200 |
try {
|
| 22244 |
ashik.ali |
201 |
loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 21985 |
kshitij.so |
202 |
} catch (ProfitMandiBusinessException e) {
|
|
|
203 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
|
|
204 |
return "response";
|
|
|
205 |
}
|
| 22275 |
ashik.ali |
206 |
try{
|
|
|
207 |
JSONObject cartObject = new JSONObject(cartData);
|
|
|
208 |
Iterator<?> keys = cartObject.keys();
|
|
|
209 |
|
|
|
210 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
211 |
List<CartFofo> cartItems = new ArrayList<CartFofo>();
|
|
|
212 |
|
|
|
213 |
while( keys.hasNext() ) {
|
|
|
214 |
String key = (String)keys.next();
|
|
|
215 |
if ( cartObject.get(key) instanceof JSONObject ) {
|
|
|
216 |
System.out.println(cartObject.get(key));
|
|
|
217 |
}
|
|
|
218 |
CartFofo cf = new CartFofo();
|
|
|
219 |
cf.setItemId(cartObject.getJSONObject(key).getInt("itemId"));
|
|
|
220 |
cf.setQuantity(cartObject.getJSONObject(key).getInt("quantity"));
|
|
|
221 |
|
|
|
222 |
if (cf.getQuantity() <= 0){
|
|
|
223 |
continue;
|
|
|
224 |
}
|
|
|
225 |
cartItems.add(cf);
|
|
|
226 |
itemIds.add(cartObject.getJSONObject(key).getInt("itemId"));
|
| 21985 |
kshitij.so |
227 |
}
|
| 22275 |
ashik.ali |
228 |
Map<Integer, Item> itemMap = new HashMap<Integer, Item>();
|
|
|
229 |
if (itemIds.size() > 0){
|
|
|
230 |
List<Item> items = itemRepository.selectByIds(itemIds);
|
|
|
231 |
for (Item i : items){
|
|
|
232 |
itemMap.put(i.getId(), i);
|
|
|
233 |
}
|
|
|
234 |
|
| 21985 |
kshitij.so |
235 |
}
|
| 22275 |
ashik.ali |
236 |
for (CartFofo cf : cartItems){
|
|
|
237 |
Item i = itemMap.get(cf.getItemId());
|
|
|
238 |
if (i == null){
|
|
|
239 |
continue;
|
|
|
240 |
}
|
|
|
241 |
cf.setDisplayName(getValidName(i.getBrand())+" "+getValidName(i.getModelName())+" "+getValidName(i.getModelNumber())+" "+getValidName(i.getColor()).replaceAll("\\s+", " "));
|
|
|
242 |
cf.setItemType(i.getType());
|
| 21985 |
kshitij.so |
243 |
}
|
| 22581 |
ashik.ali |
244 |
Map<Integer, PriceModel> mopPriceMap = pricingService.getPurchasePriceMopPriceNotFound(itemIds, loginDetails.getFofoId());
|
| 22275 |
ashik.ali |
245 |
LOGGER.info("mopPriceMap {}", mopPriceMap);
|
|
|
246 |
model.addAttribute("cartObj", cartItems);
|
|
|
247 |
model.addAttribute("mopPriceMap", mopPriceMap);
|
|
|
248 |
return "order-index";
|
|
|
249 |
}catch (Exception e) {
|
|
|
250 |
LOGGER.error("Unable to Prepare cart to place order...", e);
|
|
|
251 |
return "error";
|
| 21985 |
kshitij.so |
252 |
}
|
|
|
253 |
}
|
| 22660 |
ashik.ali |
254 |
|
| 21985 |
kshitij.so |
255 |
private String getValidName(String name){
|
|
|
256 |
return name!=null?name:"";
|
|
|
257 |
}
|
| 21612 |
ashik.ali |
258 |
|
| 22244 |
ashik.ali |
259 |
@RequestMapping(value = "/insurancePrices", method = RequestMethod.GET)
|
|
|
260 |
public ResponseEntity<?> getInsurancePrices(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PRICE) float price){
|
|
|
261 |
LOGGER.info("Request received at url : {}", request.getRequestURI());
|
|
|
262 |
try{
|
|
|
263 |
Set<Float> prices = new HashSet<>();
|
|
|
264 |
prices.add(price);
|
|
|
265 |
return responseSender.ok(pricingService.getInsurancePrices(prices, ProfitMandiConstants.GADGET_COPS));
|
|
|
266 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
|
|
267 |
return responseSender.notFound(profitMandiBusinessException);
|
|
|
268 |
}
|
|
|
269 |
}
|
|
|
270 |
|
|
|
271 |
|
| 21985 |
kshitij.so |
272 |
@RequestMapping(value = "/get-order", method = RequestMethod.GET)
|
| 22244 |
ashik.ali |
273 |
public String getOrder(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId, Model model) throws ProfitMandiBusinessException, Exception{
|
| 22139 |
amit.gupta |
274 |
LoginDetails fofoDetails;
|
| 21985 |
kshitij.so |
275 |
try {
|
| 22069 |
ashik.ali |
276 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 21985 |
kshitij.so |
277 |
} catch (ProfitMandiBusinessException e) {
|
|
|
278 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
|
|
279 |
return "response";
|
|
|
280 |
}
|
| 22277 |
ashik.ali |
281 |
try{
|
|
|
282 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
|
|
283 |
List<FofoLineItem> fofoLineItems = fofoLineItemRepository.selectByOrderId(fofoOrder.getId());
|
|
|
284 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
| 22666 |
amit.gupta |
285 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
|
|
286 |
customerAddress.setPhoneNumber(customer.getMobileNumber());
|
| 22277 |
ashik.ali |
287 |
List<PaymentOption> paymentOptions = paymentOptionRepository.selectByOrderId(fofoOrder.getId());
|
| 22680 |
amit.gupta |
288 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectByRetailerInvoiceNumber(fofoOrder.getFofoId(), fofoOrder.getInvoiceNumber());
|
| 22277 |
ashik.ali |
289 |
model.addAttribute("fofoOrder", fofoOrder);
|
|
|
290 |
model.addAttribute("fofoLineItems", fofoLineItems);
|
|
|
291 |
model.addAttribute("customerBillingAddress", getBillingAddress(customerAddress));
|
|
|
292 |
model.addAttribute("customerBillingAddressObj", customerAddress);
|
|
|
293 |
model.addAttribute("paymentOptions", paymentOptions);
|
|
|
294 |
model.addAttribute("insurancePolicies", insurancePolicies);
|
|
|
295 |
return "order-details";
|
|
|
296 |
}catch (Exception e) {
|
|
|
297 |
LOGGER.error("Unable to get Order details...", e);
|
|
|
298 |
return "error";
|
|
|
299 |
}
|
| 21985 |
kshitij.so |
300 |
}
|
| 22244 |
ashik.ali |
301 |
|
|
|
302 |
|
|
|
303 |
@RequestMapping(value = "/saleDetails", method = RequestMethod.GET)
|
|
|
304 |
public String getSaleDetails(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId, Model model) throws ProfitMandiBusinessException, Exception{
|
|
|
305 |
LoginDetails fofoDetails;
|
|
|
306 |
try {
|
|
|
307 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
308 |
} catch (ProfitMandiBusinessException e) {
|
|
|
309 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
|
|
310 |
return "response";
|
|
|
311 |
}
|
| 22279 |
ashik.ali |
312 |
try{
|
|
|
313 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
|
|
314 |
List<FofoLineItem> fofoLineItems = fofoLineItemRepository.selectByOrderId(fofoOrder.getId());
|
|
|
315 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
|
|
316 |
List<PaymentOption> paymentOptions = paymentOptionRepository.selectByOrderId(fofoOrder.getId());
|
| 22680 |
amit.gupta |
317 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectByRetailerInvoiceNumber(fofoOrder.getFofoId(), fofoOrder.getInvoiceNumber());
|
| 22279 |
ashik.ali |
318 |
model.addAttribute("fofoOrder", fofoOrder);
|
|
|
319 |
model.addAttribute("fofoLineItems", fofoLineItems);
|
|
|
320 |
model.addAttribute("customerBillingAddress", getBillingAddress(customerAddress));
|
|
|
321 |
model.addAttribute("customerBillingAddressObj", customerAddress);
|
|
|
322 |
model.addAttribute("paymentOptions", paymentOptions);
|
|
|
323 |
model.addAttribute("insurancePolicies", insurancePolicies);
|
|
|
324 |
return "sale-details";
|
|
|
325 |
}catch (Exception e) {
|
|
|
326 |
LOGGER.error("Unble to fetch sale details... ", e);
|
|
|
327 |
return "error";
|
|
|
328 |
}
|
| 22244 |
ashik.ali |
329 |
}
|
|
|
330 |
|
|
|
331 |
|
| 21985 |
kshitij.so |
332 |
|
| 22098 |
kshitij.so |
333 |
private String getBillingAddress(CustomerAddress customerAddress) {
|
|
|
334 |
String address = "";
|
|
|
335 |
if ((customerAddress.getLine1() != null) && (!customerAddress.getLine1().isEmpty())) {
|
|
|
336 |
address = address + customerAddress.getLine1();
|
|
|
337 |
address = address + ", ";
|
|
|
338 |
}
|
|
|
339 |
|
|
|
340 |
if ((customerAddress.getLine2() != null) && (!customerAddress.getLine2().isEmpty())) {
|
|
|
341 |
address = address + customerAddress.getLine2();
|
|
|
342 |
address = address + ", ";
|
|
|
343 |
}
|
|
|
344 |
|
|
|
345 |
if ((customerAddress.getLandmark() != null) && (!customerAddress.getLandmark().isEmpty())) {
|
|
|
346 |
address = address + customerAddress.getLandmark();
|
|
|
347 |
address = address + ", ";
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
if ((customerAddress.getCity() != null) && (!customerAddress.getCity().isEmpty())) {
|
|
|
351 |
address = address + customerAddress.getCity();
|
|
|
352 |
address = address + ", ";
|
|
|
353 |
}
|
|
|
354 |
|
|
|
355 |
if ((customerAddress.getState() != null) && (!customerAddress.getState().isEmpty())) {
|
|
|
356 |
address = address + customerAddress.getState();
|
|
|
357 |
}
|
|
|
358 |
|
|
|
359 |
if ((customerAddress.getPinCode() != null) && (!customerAddress.getPinCode().isEmpty())) {
|
|
|
360 |
address = address + "- " + customerAddress.getPinCode();
|
|
|
361 |
}
|
|
|
362 |
|
|
|
363 |
return address;
|
|
|
364 |
}
|
|
|
365 |
|
| 21985 |
kshitij.so |
366 |
@RequestMapping(value = "/create-order", method = RequestMethod.POST)
|
|
|
367 |
public String createOrder(HttpServletRequest request, @RequestBody CreateOrderRequest createOrderRequest, Model model) throws Throwable{
|
| 22064 |
ashik.ali |
368 |
LOGGER.info("request at uri {} body {}", request.getRequestURI(), createOrderRequest);
|
| 22139 |
amit.gupta |
369 |
LoginDetails fofoDetails;
|
| 21985 |
kshitij.so |
370 |
try {
|
| 22069 |
ashik.ali |
371 |
fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 21985 |
kshitij.so |
372 |
} catch (ProfitMandiBusinessException e) {
|
|
|
373 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
|
|
374 |
return "response";
|
|
|
375 |
}
|
| 22280 |
ashik.ali |
376 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
377 |
Map<Integer, Integer> itemIdQuantity = new HashMap<>(); //this is for error
|
| 22682 |
amit.gupta |
378 |
Map<Integer, List<CustomFofoLineItem>> customFofoLineItemMap = new HashMap<>();
|
| 22280 |
ashik.ali |
379 |
Map<Integer, Float> lineItemPrice = new HashMap<>(); //this is for pricing error
|
| 22472 |
ashik.ali |
380 |
|
|
|
381 |
Map<Integer, Set<String>> itemIdSerialNumbers = new HashMap<>(); //
|
|
|
382 |
|
| 22280 |
ashik.ali |
383 |
float totalAmount = 0;
|
|
|
384 |
for(CustomFofoLineItem customFofoLineItem : createOrderRequest.getFofoLineItems()){
|
|
|
385 |
itemIds.add(customFofoLineItem.getItemId());
|
|
|
386 |
if(!customFofoLineItem.getSerialNumberDetails().isEmpty() && customFofoLineItem.getQuantity() != customFofoLineItem.getSerialNumberDetails().size()){
|
|
|
387 |
itemIdQuantity.put(customFofoLineItem.getItemId(), customFofoLineItem.getQuantity());
|
|
|
388 |
}
|
|
|
389 |
if(!(customFofoLineItem.getSellingPrice() > 0)){
|
|
|
390 |
lineItemPrice.put(customFofoLineItem.getItemId(), customFofoLineItem.getSellingPrice());
|
|
|
391 |
}else{
|
| 22654 |
ashik.ali |
392 |
totalAmount = totalAmount + customFofoLineItem.getSellingPrice() * customFofoLineItem.getQuantity() - customFofoLineItem.getDiscountAmount();
|
| 22280 |
ashik.ali |
393 |
for(SerialNumberDetail serialNumberDetail : customFofoLineItem.getSerialNumberDetails()){
|
|
|
394 |
if(serialNumberDetail.isInsurance() && serialNumberDetail.getAmount() > 0){
|
|
|
395 |
totalAmount = totalAmount + serialNumberDetail.getAmount();
|
| 22217 |
ashik.ali |
396 |
}
|
|
|
397 |
}
|
| 21680 |
ashik.ali |
398 |
}
|
| 22682 |
amit.gupta |
399 |
|
|
|
400 |
List<CustomFofoLineItem> customFofoLineItems;
|
|
|
401 |
if(customFofoLineItemMap.containsKey(customFofoLineItem.getItemId())) {
|
|
|
402 |
customFofoLineItems = customFofoLineItemMap.get(customFofoLineItem.getItemId());
|
|
|
403 |
} else {
|
|
|
404 |
customFofoLineItems = new ArrayList<>();
|
|
|
405 |
}
|
|
|
406 |
customFofoLineItemMap.put(customFofoLineItem.getItemId(), customFofoLineItems);
|
|
|
407 |
|
| 22678 |
amit.gupta |
408 |
Set<String> serialNumbers;
|
| 22679 |
amit.gupta |
409 |
if(!itemIdSerialNumbers.containsKey(customFofoLineItem.getItemId())){
|
| 22678 |
amit.gupta |
410 |
serialNumbers = new HashSet<>();
|
|
|
411 |
} else {
|
|
|
412 |
serialNumbers = itemIdSerialNumbers.get(customFofoLineItem.getItemId());
|
| 22472 |
ashik.ali |
413 |
}
|
| 22678 |
amit.gupta |
414 |
for(SerialNumberDetail serialNumberDetail : customFofoLineItem.getSerialNumberDetails()){
|
|
|
415 |
serialNumbers.add(serialNumberDetail.getSerialNumber());
|
|
|
416 |
}
|
|
|
417 |
itemIdSerialNumbers.put(customFofoLineItem.getItemId(), serialNumbers);
|
| 22280 |
ashik.ali |
418 |
}
|
|
|
419 |
if(!itemIdQuantity.isEmpty()){
|
|
|
420 |
// if item quantity does not match with given serialnumbers size
|
|
|
421 |
LOGGER.error("itemId's quantity should be equal to given serialnumber size {} ", itemIdQuantity);
|
|
|
422 |
throw new ProfitMandiBusinessException("itemIdQuantity", itemIdQuantity, "");
|
|
|
423 |
//return "error";
|
|
|
424 |
}
|
|
|
425 |
try{
|
|
|
426 |
this.validatePaymentOptionsAndTotalAmount(createOrderRequest.getPaymentOptions(), totalAmount);
|
|
|
427 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
|
|
428 |
LOGGER.error("Error occured while validating payment options : ", profitMandiBusinessException);
|
|
|
429 |
throw profitMandiBusinessException;
|
|
|
430 |
}
|
|
|
431 |
if(!lineItemPrice.isEmpty()){
|
|
|
432 |
// given fofo line item price must be greater than zero
|
|
|
433 |
LOGGER.error("requested itemId's selling price must greater than 0");
|
|
|
434 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.PRICE, lineItemPrice, "");
|
|
|
435 |
}
|
|
|
436 |
|
|
|
437 |
List<CurrentInventorySnapshot> currentInventorySnapshots = currentInventorySnapshotRepository.selectByFofoItemIds(fofoDetails.getFofoId(), itemIds);
|
|
|
438 |
if(itemIds.size() != currentInventorySnapshots.size()){
|
|
|
439 |
// error
|
|
|
440 |
}
|
|
|
441 |
List<ItemIdQuantityAvailability> itemIdQuantityAvailabilities = new ArrayList<>(); //this is for error
|
|
|
442 |
LOGGER.info("currentInventorySnapshots "+currentInventorySnapshots);
|
|
|
443 |
for(CurrentInventorySnapshot currentInventorySnapshot : currentInventorySnapshots){
|
| 22682 |
amit.gupta |
444 |
List<CustomFofoLineItem> customFofoLineItems = customFofoLineItemMap.get(currentInventorySnapshot.getId().getItemId());
|
|
|
445 |
LOGGER.info("customFofoLineItems "+customFofoLineItems);
|
|
|
446 |
for (CustomFofoLineItem customFofoLineItem : customFofoLineItems) {
|
|
|
447 |
if(customFofoLineItem.getQuantity() > currentInventorySnapshot.getAvailability()){
|
|
|
448 |
ItemIdQuantityAvailability itemIdQuantityAvailability = new ItemIdQuantityAvailability();
|
|
|
449 |
itemIdQuantityAvailability.setItemId(customFofoLineItem.getItemId());
|
|
|
450 |
Quantity quantity = new Quantity();
|
|
|
451 |
quantity.setAvailable(currentInventorySnapshot.getAvailability());
|
|
|
452 |
quantity.setRequested(customFofoLineItem.getQuantity());
|
|
|
453 |
itemIdQuantityAvailability.setQuantity(quantity);
|
|
|
454 |
itemIdQuantityAvailabilities.add(itemIdQuantityAvailability);
|
|
|
455 |
}
|
| 21896 |
ashik.ali |
456 |
}
|
| 22280 |
ashik.ali |
457 |
|
|
|
458 |
}
|
|
|
459 |
|
|
|
460 |
|
|
|
461 |
|
|
|
462 |
if(!itemIdQuantityAvailabilities.isEmpty()){
|
|
|
463 |
// itemIdQuantity request is not valid
|
|
|
464 |
LOGGER.error("Requested quantities should not be greater than currently available quantities {}", itemIdQuantityAvailabilities);
|
|
|
465 |
throw new ProfitMandiBusinessException("itemIdQuantityAvailabilities", itemIdQuantityAvailabilities, "");
|
|
|
466 |
}
|
|
|
467 |
|
|
|
468 |
|
|
|
469 |
Map<Integer, Item> itemMap = new HashMap<Integer, Item>();
|
|
|
470 |
List<Item> items = itemRepository.selectByIds(itemIds);
|
|
|
471 |
for (Item i : items){
|
|
|
472 |
itemMap.put(i.getId(), i);
|
|
|
473 |
}
|
|
|
474 |
|
|
|
475 |
Set<Integer> nonSerializedItemIds = new HashSet<>();
|
|
|
476 |
Set<String> serialNumbers = new HashSet<>();
|
|
|
477 |
Map<String, Float> insuranceSerialNumberItemPrice = new HashMap<>();
|
|
|
478 |
Map<String, Float> insuranceSerialNumberSaleAmount = new HashMap<>();
|
|
|
479 |
Map<String, String> serialNumberModelName = new HashMap<>();
|
|
|
480 |
Map<String, String> serialNumberBrand = new HashMap<>();
|
| 22682 |
amit.gupta |
481 |
for (CustomFofoLineItem cli : createOrderRequest.getFofoLineItems()){
|
| 22280 |
ashik.ali |
482 |
Item item = itemMap.get(cli.getItemId());
|
|
|
483 |
if (item.getType().equals(ItemType.SERIALIZED)){
|
|
|
484 |
for (SerialNumberDetail serialNumberDetail : cli.getSerialNumberDetails()){
|
|
|
485 |
serialNumbers.add(serialNumberDetail.getSerialNumber());
|
|
|
486 |
if(serialNumberDetail.isInsurance()){
|
|
|
487 |
insuranceSerialNumberItemPrice.put(serialNumberDetail.getSerialNumber(), cli.getSellingPrice());
|
|
|
488 |
insuranceSerialNumberSaleAmount.put(serialNumberDetail.getSerialNumber(), serialNumberDetail.getAmount());
|
|
|
489 |
serialNumberModelName.put(serialNumberDetail.getSerialNumber(), item.getModelName());
|
|
|
490 |
serialNumberBrand.put(serialNumberDetail.getSerialNumber(), item.getBrand());
|
|
|
491 |
}
|
| 21680 |
ashik.ali |
492 |
}
|
|
|
493 |
}
|
| 22280 |
ashik.ali |
494 |
else{
|
|
|
495 |
nonSerializedItemIds.add(cli.getItemId());
|
| 22244 |
ashik.ali |
496 |
}
|
| 22280 |
ashik.ali |
497 |
}
|
|
|
498 |
|
|
|
499 |
Map<Integer, List<InventoryItem>> serializedInventoryItemMap = new HashMap<Integer, List<InventoryItem>>();
|
|
|
500 |
Map<Integer, List<InventoryItem>> nonSerializedInventoryItemMap = new HashMap<Integer, List<InventoryItem>>();
|
|
|
501 |
Map<Integer, List<Float>> itemIdPriceDropAmount = new HashMap<>();
|
| 22472 |
ashik.ali |
502 |
//Map<String, Float> serialNumberItemPrice = new HashMap<>();
|
|
|
503 |
|
| 22280 |
ashik.ali |
504 |
if (!serialNumbers.isEmpty()){
|
|
|
505 |
List<InventoryItem> serializedInventoryItems = inventoryItemRepository.selectByFofoIdSerialNumbers(fofoDetails.getFofoId(), serialNumbers);
|
|
|
506 |
LOGGER.info("serializedInventoryItems {}", serializedInventoryItems);
|
|
|
507 |
for (InventoryItem it : serializedInventoryItems){
|
|
|
508 |
if (it.getGoodQuantity() == 1){
|
|
|
509 |
if (serializedInventoryItemMap.containsKey(it.getItemId())){
|
|
|
510 |
serializedInventoryItemMap.get(it.getItemId()).add(it);
|
|
|
511 |
itemIdPriceDropAmount.get(it.getItemId()).
|
|
|
512 |
add(it.getUnitPrice() - (it.getPriceDropAmount()==null?0:it.getPriceDropAmount()));
|
| 21985 |
kshitij.so |
513 |
}
|
| 22280 |
ashik.ali |
514 |
else{
|
|
|
515 |
ArrayList<InventoryItem> tmp = new ArrayList<InventoryItem>();
|
|
|
516 |
tmp.add(it);
|
|
|
517 |
serializedInventoryItemMap.put(it.getItemId(), tmp);
|
|
|
518 |
ArrayList<Float> priceDropAmouts = new ArrayList<>();
|
|
|
519 |
priceDropAmouts.add(it.getUnitPrice() - (it.getPriceDropAmount()==null?0:it.getPriceDropAmount()));
|
|
|
520 |
itemIdPriceDropAmount.put(it.getItemId(), priceDropAmouts);
|
|
|
521 |
}
|
| 21985 |
kshitij.so |
522 |
}
|
|
|
523 |
}
|
| 22280 |
ashik.ali |
524 |
}
|
|
|
525 |
|
|
|
526 |
if (!nonSerializedItemIds.isEmpty()){
|
|
|
527 |
List<InventoryItem> nonSerializedInventoryItems = inventoryItemRepository.selectByFofoIdItemIds(fofoDetails.getFofoId(), nonSerializedItemIds);
|
|
|
528 |
for (InventoryItem it : nonSerializedInventoryItems){
|
|
|
529 |
if (it.getGoodQuantity() > 0){
|
|
|
530 |
if (nonSerializedInventoryItemMap.containsKey(it.getItemId())){
|
|
|
531 |
nonSerializedInventoryItemMap.get(it.getItemId()).add(it);
|
| 22244 |
ashik.ali |
532 |
}
|
| 22280 |
ashik.ali |
533 |
else{
|
|
|
534 |
ArrayList<InventoryItem> tmp = new ArrayList<InventoryItem>();
|
|
|
535 |
tmp.add(it);
|
|
|
536 |
nonSerializedInventoryItemMap.put(it.getItemId(), tmp);
|
|
|
537 |
}
|
| 21985 |
kshitij.so |
538 |
}
|
|
|
539 |
}
|
| 22280 |
ashik.ali |
540 |
}
|
|
|
541 |
|
|
|
542 |
List<Integer> invalidItemIdSerialNumbers = new ArrayList<Integer>();
|
| 22472 |
ashik.ali |
543 |
List<Integer> itemIdNonSerializedSerialNumbers = new ArrayList<Integer>();
|
| 22280 |
ashik.ali |
544 |
|
|
|
545 |
for (Item i : items){
|
| 22682 |
amit.gupta |
546 |
List<CustomFofoLineItem> customFofoLineItems = customFofoLineItemMap.get(i.getId());
|
|
|
547 |
for(CustomFofoLineItem customFofoLineItem: customFofoLineItems) {
|
|
|
548 |
if (i.getType().equals(ItemType.SERIALIZED)){
|
|
|
549 |
if (customFofoLineItem ==null || customFofoLineItem.getSerialNumberDetails().isEmpty()){
|
|
|
550 |
invalidItemIdSerialNumbers.add(i.getId());
|
|
|
551 |
}
|
| 21985 |
kshitij.so |
552 |
}
|
| 22682 |
amit.gupta |
553 |
else{
|
|
|
554 |
if (customFofoLineItem == null || !customFofoLineItem.getSerialNumberDetails().isEmpty()){
|
|
|
555 |
itemIdNonSerializedSerialNumbers.add(i.getId());
|
|
|
556 |
}
|
| 21985 |
kshitij.so |
557 |
}
|
| 22280 |
ashik.ali |
558 |
}
|
|
|
559 |
}
|
|
|
560 |
|
|
|
561 |
if(!invalidItemIdSerialNumbers.isEmpty()){
|
|
|
562 |
LOGGER.error("Invalid itemId's serialNumbers {}", invalidItemIdSerialNumbers);
|
|
|
563 |
// itemId's are serialized you are saying these are not serialized
|
|
|
564 |
throw new ProfitMandiBusinessException("invalidItemIdSerialNumbers", invalidItemIdSerialNumbers, "");
|
|
|
565 |
}
|
|
|
566 |
|
| 22472 |
ashik.ali |
567 |
if(!itemIdNonSerializedSerialNumbers.isEmpty()){
|
|
|
568 |
LOGGER.error("Invalid itemId's serialNumbers {}", itemIdNonSerializedSerialNumbers);
|
| 22280 |
ashik.ali |
569 |
// itemId's are non serialized you are saying these are serialized
|
| 22472 |
ashik.ali |
570 |
throw new ProfitMandiBusinessException("itemIdNonSerializedSerialNumbers", itemIdNonSerializedSerialNumbers, "");
|
| 22280 |
ashik.ali |
571 |
}
|
|
|
572 |
|
|
|
573 |
if(items.size() != itemIds.size()){
|
|
|
574 |
LOGGER.error("Requested ItemIds not found in catalog");
|
|
|
575 |
// invalid itemIds
|
|
|
576 |
throw new ProfitMandiBusinessException("invalidItemIds", "", "");
|
|
|
577 |
}
|
|
|
578 |
|
|
|
579 |
Map<Integer, List<InventoryItem>> inventoryItemsToBill = new HashMap<Integer,List<InventoryItem>>();
|
|
|
580 |
Map<Integer, Integer> inventoryItemQuantityUsed = new HashMap<>(); //to keep track of inventoryitem quanity used for scan records insertion
|
|
|
581 |
|
|
|
582 |
LOGGER.info("itemMap keys {}", itemMap.keySet());
|
|
|
583 |
//Lets reduce quantity and decide what inventory items to use.
|
|
|
584 |
for (Item i : items){
|
|
|
585 |
if (i.getType().equals(ItemType.SERIALIZED)){
|
|
|
586 |
//TODO:handle null
|
| 22682 |
amit.gupta |
587 |
if (serializedInventoryItemMap.get(i.getId()) == null || customFofoLineItemMap.get(i.getId()).size() != serializedInventoryItemMap.get(i.getId()).size()){
|
| 22280 |
ashik.ali |
588 |
//not enough serial numbers
|
|
|
589 |
//LOGGER.info("serialNumbers {}", serialNumbers);
|
|
|
590 |
LOGGER.info("serializedInventoryItemMap {}", serializedInventoryItemMap);
|
|
|
591 |
LOGGER.info("itemId {}", i.getId());
|
|
|
592 |
LOGGER.error("not enough serial numbers");
|
|
|
593 |
throw new ProfitMandiBusinessException("notEnoughSerialNumbers", "", "");
|
| 21985 |
kshitij.so |
594 |
}
|
| 22280 |
ashik.ali |
595 |
List<InventoryItem> inventoryItemsSerializedserialized = serializedInventoryItemMap.get(i.getId());
|
|
|
596 |
for (InventoryItem it : inventoryItemsSerializedserialized){
|
|
|
597 |
it.setGoodQuantity(0);
|
|
|
598 |
inventoryItemQuantityUsed.put(it.getId(), 1);
|
|
|
599 |
}
|
|
|
600 |
inventoryItemsToBill.put(i.getId(), inventoryItemsSerializedserialized);
|
| 21985 |
kshitij.so |
601 |
}
|
| 22280 |
ashik.ali |
602 |
else{
|
|
|
603 |
List<InventoryItem> inventoryItemsNonSerialized = nonSerializedInventoryItemMap.get(i.getId());
|
| 22682 |
amit.gupta |
604 |
int quantityToBill = customFofoLineItemMap.get(i.getId()).get(0).getQuantity();
|
| 22280 |
ashik.ali |
605 |
int totalLeft = quantityToBill;
|
|
|
606 |
List<InventoryItem> inventoryItemsNonSerializedUsed = new ArrayList<InventoryItem>();
|
|
|
607 |
if (inventoryItemsNonSerialized!=null){
|
|
|
608 |
for (InventoryItem it : inventoryItemsNonSerialized){
|
|
|
609 |
if (totalLeft > 0){
|
|
|
610 |
int toUse = Math.min(totalLeft, it.getGoodQuantity());
|
|
|
611 |
inventoryItemQuantityUsed.put(it.getId(), toUse);
|
|
|
612 |
it.setGoodQuantity(it.getGoodQuantity() - toUse);
|
|
|
613 |
totalLeft = totalLeft - toUse;
|
|
|
614 |
inventoryItemsNonSerializedUsed.add(it);
|
| 22244 |
ashik.ali |
615 |
}
|
|
|
616 |
}
|
| 21896 |
ashik.ali |
617 |
}
|
| 22280 |
ashik.ali |
618 |
|
|
|
619 |
if (totalLeft > 0){
|
|
|
620 |
//not enough quanity for non-serialized
|
| 22682 |
amit.gupta |
621 |
LOGGER.error("not enough quanity for non-serialized");
|
| 22280 |
ashik.ali |
622 |
throw new ProfitMandiBusinessException("notEnoughQuantityForNonSerialized", "", "");
|
|
|
623 |
}
|
|
|
624 |
inventoryItemsToBill.put(i.getId(), inventoryItemsNonSerializedUsed);
|
| 21896 |
ashik.ali |
625 |
}
|
| 22280 |
ashik.ali |
626 |
}
|
|
|
627 |
|
|
|
628 |
// mop price validation
|
|
|
629 |
Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
|
| 22581 |
ashik.ali |
630 |
Map<Integer, Float> invalidDiscountAmountMap = new HashMap<>();
|
|
|
631 |
Map<Integer, PriceModel> itemIdMopPriceMap = pricingService.getPurchasePriceMopPriceNotFound(itemIds, fofoDetails.getFofoId());
|
|
|
632 |
for(Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()){
|
| 22682 |
amit.gupta |
633 |
List<CustomFofoLineItem>customFofoLineItems = customFofoLineItemMap.get(entry.getKey());
|
|
|
634 |
for(CustomFofoLineItem customFofoLineItem : customFofoLineItems) {
|
|
|
635 |
if(entry.getValue().getPrice() < Float.MAX_VALUE && customFofoLineItem.getSellingPrice() < entry.getValue().getPrice()){
|
|
|
636 |
invalidMopItemIdPriceMap.put(entry.getKey(), customFofoLineItem.getSellingPrice());
|
|
|
637 |
}
|
|
|
638 |
if(entry.getValue().isMop() && customFofoLineItem.getDiscountAmount() > entry.getValue().getMaxDiscountAmount()){
|
|
|
639 |
invalidDiscountAmountMap.put(entry.getKey(), customFofoLineItem.getDiscountAmount());
|
|
|
640 |
}
|
| 22280 |
ashik.ali |
641 |
}
|
|
|
642 |
}
|
|
|
643 |
|
|
|
644 |
if(!invalidMopItemIdPriceMap.isEmpty()){
|
|
|
645 |
LOGGER.error("Invalid itemIds selling prices{} should be greater than mop prices {}", invalidMopItemIdPriceMap, itemIdMopPriceMap);
|
|
|
646 |
throw new ProfitMandiBusinessException("invalidMopItemIdPrice", invalidMopItemIdPriceMap, "");
|
|
|
647 |
}
|
| 22581 |
ashik.ali |
648 |
|
|
|
649 |
if(!invalidMopItemIdPriceMap.isEmpty()){
|
|
|
650 |
LOGGER.error("Invalid itemIds discount amounts {} should be less than maxDiscount prices {}", invalidDiscountAmountMap, itemIdMopPriceMap);
|
|
|
651 |
throw new ProfitMandiBusinessException("invalidMopItemIdPrice", invalidDiscountAmountMap, "");
|
|
|
652 |
}
|
| 22280 |
ashik.ali |
653 |
|
|
|
654 |
InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = null;
|
|
|
655 |
try{
|
|
|
656 |
invoiceNumberGenerationSequence = invoiceNumberGenerationSequenceRepository.selectByFofoId(fofoDetails.getFofoId());
|
|
|
657 |
invoiceNumberGenerationSequence.setSequence(invoiceNumberGenerationSequence.getSequence() + 1);
|
|
|
658 |
invoiceNumberGenerationSequenceRepository.persist(invoiceNumberGenerationSequence);
|
|
|
659 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
|
|
660 |
invoiceNumberGenerationSequence = new InvoiceNumberGenerationSequence();
|
|
|
661 |
invoiceNumberGenerationSequence.setFofoId(fofoDetails.getFofoId());
|
|
|
662 |
invoiceNumberGenerationSequence.setPrefix("INVOICE");
|
|
|
663 |
invoiceNumberGenerationSequence.setSequence(1);
|
|
|
664 |
invoiceNumberGenerationSequenceRepository.persist(invoiceNumberGenerationSequence);
|
|
|
665 |
}
|
|
|
666 |
|
|
|
667 |
CustomCustomer customCustomer = createOrderRequest.getCustomer();
|
|
|
668 |
|
|
|
669 |
if(!StringUtils.isValidEmailAddress(customCustomer.getEmailId())){
|
|
|
670 |
LOGGER.error("invalid customer emailId {} ", customCustomer.getEmailId());
|
|
|
671 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, customCustomer.getEmailId(), "");
|
|
|
672 |
}
|
|
|
673 |
|
|
|
674 |
if(!StringUtils.isValidMobile(customCustomer.getMobileNumber())){
|
|
|
675 |
LOGGER.error("invalid customer mobileNumber {} ", customCustomer.getMobileNumber());
|
|
|
676 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.MOBILE_NUMBER, customCustomer.getMobileNumber(), "");
|
|
|
677 |
}
|
|
|
678 |
|
|
|
679 |
boolean insurance = false;
|
|
|
680 |
for(CustomFofoLineItem customFofoLineItem : createOrderRequest.getFofoLineItems()){
|
|
|
681 |
for(SerialNumberDetail serialNumberDetail : customFofoLineItem.getSerialNumberDetails()){
|
|
|
682 |
if(serialNumberDetail.getAmount() > 0){
|
|
|
683 |
insurance = true;
|
|
|
684 |
break;
|
| 22217 |
ashik.ali |
685 |
}
|
|
|
686 |
}
|
| 22280 |
ashik.ali |
687 |
}
|
|
|
688 |
LOGGER.info("insurance [{}] processing ....", insurance);
|
|
|
689 |
|
|
|
690 |
LocalDate customerDateOfBirth = null;
|
|
|
691 |
if(insurance){
|
| 22244 |
ashik.ali |
692 |
try{
|
| 22280 |
ashik.ali |
693 |
customerDateOfBirth = StringUtils.toDate(createOrderRequest.getCustomerDateOfBirth());
|
|
|
694 |
}catch(DateTimeException dateTimeException){
|
|
|
695 |
LOGGER.error("Unable to parse dateOfBirth", dateTimeException);
|
|
|
696 |
throw new ProfitMandiBusinessException("dateOfBirth", createOrderRequest.getCustomerDateOfBirth(), "");
|
| 22244 |
ashik.ali |
697 |
}
|
| 22280 |
ashik.ali |
698 |
}
|
|
|
699 |
|
|
|
700 |
Customer customer = null;
|
|
|
701 |
try{
|
|
|
702 |
customer = customerRepository.selectByMobileNumber(customCustomer.getMobileNumber());
|
|
|
703 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
|
|
704 |
LOGGER.error("Error : ", profitMandiBusinessException);
|
|
|
705 |
customer = new Customer();
|
|
|
706 |
customer.setFirstName(customCustomer.getFirstName());
|
|
|
707 |
customer.setLastName(customCustomer.getLastName());
|
|
|
708 |
customer.setEmailId(customCustomer.getEmailId());
|
|
|
709 |
customer.setMobileNumber(customCustomer.getMobileNumber());
|
|
|
710 |
customerRepository.persist(customer);
|
|
|
711 |
}
|
|
|
712 |
//TODO:Check if createOrderRequest contains addressId
|
|
|
713 |
CustomerAddress customerAddress = this.createCustomerAddress(customCustomer.getAddress());
|
|
|
714 |
customerAddress.setCustomerId(customer.getId());
|
|
|
715 |
customerAddressRepository.persist(customerAddress);
|
|
|
716 |
|
|
|
717 |
FofoOrder fofoOrder = new FofoOrder();
|
|
|
718 |
fofoOrder.setCustomerId(customer.getId());
|
|
|
719 |
fofoOrder.setFofoId(fofoDetails.getFofoId());
|
|
|
720 |
fofoOrder.setInvoiceNumber(invoiceNumberGenerationSequence.getPrefix() + invoiceNumberGenerationSequence.getSequence());
|
|
|
721 |
fofoOrder.setTotalAmount(totalAmount);
|
|
|
722 |
fofoOrder.setCustomerAddressId(customerAddress.getId());
|
|
|
723 |
fofoOrderRepository.persist(fofoOrder);
|
|
|
724 |
|
|
|
725 |
for(CustomPaymentOption customPaymentOption : createOrderRequest.getPaymentOptions()){
|
|
|
726 |
PaymentOption paymentOption = new PaymentOption();
|
|
|
727 |
paymentOption.setOrderId(fofoOrder.getId());
|
|
|
728 |
paymentOption.setAmount(customPaymentOption.getAmount());
|
|
|
729 |
paymentOption.setType(customPaymentOption.getType());
|
|
|
730 |
paymentOptionRepository.persist(paymentOption);
|
|
|
731 |
}
|
|
|
732 |
|
|
|
733 |
Address retailerAddress = addressRepository.selectById(retailerRegisteredAddressRepository.selectAddressIdByRetailerId(fofoDetails.getFofoId()));
|
|
|
734 |
Map<String, GstRate> gstRateMap = null;
|
|
|
735 |
if(retailerAddress.getState().equals(customerAddress.getState())){
|
|
|
736 |
gstRateMap = Utils.getGstRates(retailerAddress.getState());
|
|
|
737 |
}else{
|
|
|
738 |
LOGGER.info("inter gstRate = true");
|
|
|
739 |
gstRateMap = Utils.getInterGstRates();
|
|
|
740 |
}
|
|
|
741 |
LOGGER.info("gstRateMap {}", gstRateMap);
|
|
|
742 |
for(CustomFofoLineItem customFofoLineItem : createOrderRequest.getFofoLineItems()){
|
|
|
743 |
FofoLineItem fofoLineItem = new FofoLineItem();
|
|
|
744 |
fofoLineItem.setItemId(customFofoLineItem.getItemId());
|
|
|
745 |
fofoLineItem.setQuantity(customFofoLineItem.getQuantity());
|
|
|
746 |
fofoLineItem.setSellingPrice(customFofoLineItem.getSellingPrice());
|
|
|
747 |
fofoLineItem.setOrderId(fofoOrder.getId());
|
|
|
748 |
fofoLineItem.setDp(customFofoLineItem.getSellingPrice());
|
| 22581 |
ashik.ali |
749 |
fofoLineItem.setDiscount(customFofoLineItem.getDiscountAmount());
|
| 22280 |
ashik.ali |
750 |
Item item = itemMap.get(customFofoLineItem.getItemId());
|
|
|
751 |
GstRate gstRate = gstRateMap.get(item.getHsnCode());
|
|
|
752 |
fofoLineItem.setIgstRate(gstRate.getIgstRate());
|
|
|
753 |
fofoLineItem.setCgstRate(gstRate.getCgstRate());
|
|
|
754 |
fofoLineItem.setSgstRate(gstRate.getSgstRate());
|
|
|
755 |
fofoLineItem.setHsnCode(gstRate.getHsnCode());
|
|
|
756 |
List<Float> priceDropAmounts = itemIdPriceDropAmount.get(customFofoLineItem.getItemId());
|
|
|
757 |
float cost = 0;
|
|
|
758 |
if (priceDropAmounts!=null){
|
|
|
759 |
for (Float pda : priceDropAmounts){
|
|
|
760 |
cost = cost + pda;
|
|
|
761 |
}
|
| 22217 |
ashik.ali |
762 |
}
|
| 22280 |
ashik.ali |
763 |
else{
|
|
|
764 |
cost = customFofoLineItem.getSellingPrice()* customFofoLineItem.getQuantity();
|
| 22244 |
ashik.ali |
765 |
}
|
| 22280 |
ashik.ali |
766 |
fofoLineItem.setCost(cost);
|
|
|
767 |
fofoLineItem.setBrand(item.getBrand());
|
|
|
768 |
fofoLineItem.setModelName(item.getModelName());
|
|
|
769 |
fofoLineItem.setModelNumber(item.getModelNumber());
|
|
|
770 |
fofoLineItem.setColor(item.getColor());
|
|
|
771 |
fofoLineItemRepository.persist(fofoLineItem);
|
|
|
772 |
LOGGER.info("\n\n");
|
|
|
773 |
if(!customFofoLineItem.getSerialNumberDetails().isEmpty()){
|
| 22244 |
ashik.ali |
774 |
for(SerialNumberDetail serialNumberDetail : customFofoLineItem.getSerialNumberDetails()){
|
| 22280 |
ashik.ali |
775 |
FofoLineItemSerialNumber fofoLineItemSerialNumber = new FofoLineItemSerialNumber();
|
|
|
776 |
fofoLineItemSerialNumber.setFofoLineItemId(fofoLineItem.getId());
|
|
|
777 |
fofoLineItemSerialNumber.setSerialNumber(serialNumberDetail.getSerialNumber());
|
|
|
778 |
fofoLineItemSerialNumberRepository.persist(fofoLineItemSerialNumber);
|
| 22244 |
ashik.ali |
779 |
}
|
|
|
780 |
}
|
| 22280 |
ashik.ali |
781 |
|
|
|
782 |
for(CurrentInventorySnapshot currentInventorySnapshot : currentInventorySnapshots){
|
|
|
783 |
FofoItemId fofoItemId = new FofoItemId();
|
|
|
784 |
fofoItemId.setFofoId(fofoDetails.getFofoId());
|
|
|
785 |
fofoItemId.setItemId(fofoLineItem.getItemId());
|
|
|
786 |
if(currentInventorySnapshot.getId().equals(fofoItemId)){
|
|
|
787 |
currentInventorySnapshotRepository.updateAvailabilityByFofoItemId(fofoItemId, currentInventorySnapshot.getAvailability() - customFofoLineItem.getQuantity());
|
| 22217 |
ashik.ali |
788 |
}
|
|
|
789 |
}
|
| 22280 |
ashik.ali |
790 |
List<InventoryItem> inventoryItems = inventoryItemsToBill.get(fofoLineItem.getItemId());
|
|
|
791 |
for(InventoryItem inventoryItem : inventoryItems){
|
|
|
792 |
inventoryItem.setLastScanType(ScanType.SALE);
|
|
|
793 |
inventoryItemRepository.persist(inventoryItem);
|
|
|
794 |
ScanRecord scanRecord = new ScanRecord();
|
|
|
795 |
scanRecord.setInventoryItemId(inventoryItem.getId());
|
|
|
796 |
scanRecord.setFofoId(fofoDetails.getFofoId());
|
|
|
797 |
//correct this
|
|
|
798 |
scanRecord.setQuantity(inventoryItemQuantityUsed.get(inventoryItem.getId()));
|
|
|
799 |
scanRecord.setType(ScanType.SALE);
|
|
|
800 |
scanRecordRepository.persist(scanRecord);
|
|
|
801 |
}
|
|
|
802 |
}
|
|
|
803 |
|
|
|
804 |
// insurance calculation is insurance flag is enabled
|
|
|
805 |
if(!insuranceSerialNumberItemPrice.isEmpty()){
|
|
|
806 |
LOGGER.info("Processing for insurence for serialNumbers");
|
|
|
807 |
Map<Float, GadgetCopsInsuranceCalc> insurancePricesMap = pricingService.getInsurancePrices(new HashSet<>(insuranceSerialNumberItemPrice.values()), ProfitMandiConstants.GADGET_COPS);
|
|
|
808 |
InsuranceProvider insuranceProvider = insuranceProviderRepository.selectByName(ProfitMandiConstants.GADGET_COPS);
|
| 22244 |
ashik.ali |
809 |
|
| 22280 |
ashik.ali |
810 |
|
|
|
811 |
Map<Float, Float> invalidInsurancePurchaseSaleAmount = new HashMap<>();
|
|
|
812 |
Map<Float, Float> invalidInsuranceSalePurchaseAmount = new HashMap<>();
|
|
|
813 |
for(Map.Entry<String, Float> entry : insuranceSerialNumberItemPrice.entrySet()){
|
|
|
814 |
if(insuranceSerialNumberSaleAmount.get(entry.getKey()) < insurancePricesMap.get(entry.getValue()).getDealerPrice()){
|
|
|
815 |
invalidInsurancePurchaseSaleAmount.put(insurancePricesMap.get(entry.getValue()).getDealerPrice(), insuranceSerialNumberSaleAmount.get(entry.getKey()));
|
| 22244 |
ashik.ali |
816 |
}
|
| 22280 |
ashik.ali |
817 |
|
|
|
818 |
if(insuranceSerialNumberSaleAmount.get(entry.getKey()) > insurancePricesMap.get(entry.getValue()).getSellingPrice()){
|
|
|
819 |
invalidInsuranceSalePurchaseAmount.put(insuranceSerialNumberSaleAmount.get(entry.getKey()), insurancePricesMap.get(entry.getValue()).getDealerPrice());
|
| 22244 |
ashik.ali |
820 |
}
|
|
|
821 |
}
|
|
|
822 |
|
| 22280 |
ashik.ali |
823 |
// insurance sale amount can not be lesser than insurance purchase amount
|
|
|
824 |
if(!invalidInsurancePurchaseSaleAmount.isEmpty()){
|
|
|
825 |
LOGGER.error("Invalid Insurance prices [{}], insurance sale amount can not be lesser than insurance purchase amount", invalidInsurancePurchaseSaleAmount);
|
|
|
826 |
return "error";
|
|
|
827 |
}
|
|
|
828 |
|
|
|
829 |
if(!invalidInsuranceSalePurchaseAmount.isEmpty()){
|
|
|
830 |
LOGGER.error("Invalid Insurance prices [{}], insurance sale amount can not be greater than than insurance max amount", invalidInsuranceSalePurchaseAmount);
|
|
|
831 |
return "error";
|
|
|
832 |
}
|
|
|
833 |
|
| 22472 |
ashik.ali |
834 |
Map<Float, Float> invalidInsuranceMarginAmount = new HashMap<>();
|
| 22280 |
ashik.ali |
835 |
|
|
|
836 |
for(Map.Entry<String, Float> entry : insuranceSerialNumberItemPrice.entrySet()){
|
| 22472 |
ashik.ali |
837 |
int itemId = this.getItemIdFromSerialNumber(itemIdSerialNumbers, entry.getKey());
|
| 22676 |
amit.gupta |
838 |
LOGGER.info("itemId -->{}", itemId);
|
| 22675 |
amit.gupta |
839 |
LOGGER.info("itemIdMopPriceMap.get(itemId) -->{}", itemIdMopPriceMap.get(itemId));
|
| 22677 |
amit.gupta |
840 |
LOGGER.info("itemIdSerialNumbers -->{}", itemIdSerialNumbers);
|
| 22676 |
amit.gupta |
841 |
LOGGER.info("entry -->{}, {}", entry.getKey(), entry.getValue());
|
| 22551 |
ashik.ali |
842 |
float itemPurchasePrice = itemIdMopPriceMap.get(itemId).getPrice();
|
| 22472 |
ashik.ali |
843 |
float itemSellingPrice = entry.getValue();
|
|
|
844 |
float itemMargin = itemSellingPrice - itemPurchasePrice;
|
|
|
845 |
float insurancePurchasePrice = insurancePricesMap.get(entry.getValue()).getDealerPrice();
|
|
|
846 |
float insuranceSellingPrice = insuranceSerialNumberSaleAmount.get(entry.getKey());
|
|
|
847 |
float insuranceMargin = insuranceSellingPrice - insurancePurchasePrice;
|
|
|
848 |
if(insuranceMargin < (itemMargin * 30 / 100)){
|
|
|
849 |
invalidInsuranceMarginAmount.put(insuranceMargin, (itemMargin * 30 / 100));
|
|
|
850 |
}
|
|
|
851 |
}
|
|
|
852 |
|
|
|
853 |
if(!invalidInsuranceMarginAmount.isEmpty()){
|
|
|
854 |
LOGGER.error("insurance marging should be greater than equal to item profit margin insuranceMarginItemIdMargin {}", invalidInsuranceMarginAmount);
|
| 22486 |
ashik.ali |
855 |
return "error";
|
| 22472 |
ashik.ali |
856 |
}
|
|
|
857 |
|
|
|
858 |
|
|
|
859 |
for(Map.Entry<String, Float> entry : insuranceSerialNumberItemPrice.entrySet()){
|
| 22280 |
ashik.ali |
860 |
PolicyNumberGenerationSequence policyNumberGenerationSequence = null;
|
|
|
861 |
try{
|
|
|
862 |
policyNumberGenerationSequence = policyNumberGenerationSequenceRepository.select();
|
|
|
863 |
policyNumberGenerationSequence.setSequence(policyNumberGenerationSequence.getSequence() + 1);
|
|
|
864 |
policyNumberGenerationSequenceRepository.persist(policyNumberGenerationSequence);
|
|
|
865 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
|
|
866 |
policyNumberGenerationSequence = new PolicyNumberGenerationSequence();
|
|
|
867 |
policyNumberGenerationSequence.setSequence(1);
|
|
|
868 |
policyNumberGenerationSequenceRepository.persist(policyNumberGenerationSequence);
|
| 22244 |
ashik.ali |
869 |
}
|
|
|
870 |
|
| 22280 |
ashik.ali |
871 |
InsurancePolicy insurancePolicy = new InsurancePolicy();
|
|
|
872 |
insurancePolicy.setInvoiceNumber(invoiceNumberGenerationSequence.getPrefix() + invoiceNumberGenerationSequence.getSequence());
|
|
|
873 |
insurancePolicy.setRetailerId(fofoDetails.getFofoId());
|
|
|
874 |
insurancePolicy.setPurchaseAmount(insurancePricesMap.get(entry.getValue()).getDealerPrice());
|
|
|
875 |
insurancePolicy.setSaleAmount(insuranceSerialNumberSaleAmount.get(entry.getKey()));
|
|
|
876 |
insurancePolicy.setSellingPrice(entry.getValue());
|
|
|
877 |
insurancePolicy.setSerialNumber(entry.getKey());
|
|
|
878 |
insurancePolicy.setModelName(serialNumberModelName.get(entry.getKey()));
|
|
|
879 |
insurancePolicy.setBrand(serialNumberBrand.get(entry.getKey()));
|
|
|
880 |
insurancePolicy.setPolicyNumber(StringUtils.generatePolicyNumber(ProfitMandiConstants.POLICY_NUMBER_PREFIX, policyNumberGenerationSequence.getSequence()));
|
|
|
881 |
insurancePolicy.setProviderId(insuranceProvider.getId());
|
|
|
882 |
insurancePolicy.setCustomerFirstName(customer.getFirstName());
|
|
|
883 |
insurancePolicy.setCustomerLastName(customer.getLastName());
|
|
|
884 |
insurancePolicy.setCustomerMobileNumber(customer.getMobileNumber());
|
|
|
885 |
insurancePolicy.setCustomerEmailId(customer.getEmailId());
|
|
|
886 |
insurancePolicy.setCustomerDateOfBirth(customerDateOfBirth);
|
|
|
887 |
insurancePolicy.setCustomerAddress1(customerAddress.getLine1());
|
|
|
888 |
insurancePolicy.setCustomerAddress2(customerAddress.getLine2());
|
|
|
889 |
insurancePolicy.setCustomerCity(customerAddress.getCity());
|
|
|
890 |
insurancePolicy.setCustomerPinCode(customerAddress.getPinCode());
|
|
|
891 |
insurancePolicy.setCustomerState(customerAddress.getState());
|
| 22244 |
ashik.ali |
892 |
|
| 22280 |
ashik.ali |
893 |
GadgetCopsInsuranceModel gadgetCopsInsuranceModel = new GadgetCopsInsuranceModel();
|
|
|
894 |
gadgetCopsInsuranceModel.setBrand(serialNumberBrand.get(entry.getKey()));
|
|
|
895 |
gadgetCopsInsuranceModel.setModelName(serialNumberModelName.get(entry.getKey()));
|
|
|
896 |
gadgetCopsInsuranceModel.setSerialNumber(entry.getKey());
|
|
|
897 |
gadgetCopsInsuranceModel.setCustomerFirstName(customer.getFirstName());
|
|
|
898 |
gadgetCopsInsuranceModel.setCustomerLastName(customer.getLastName());
|
|
|
899 |
gadgetCopsInsuranceModel.setCustomerDateOfBirth(customerDateOfBirth);
|
|
|
900 |
gadgetCopsInsuranceModel.setCustomerMobileNumber(customer.getMobileNumber());
|
|
|
901 |
gadgetCopsInsuranceModel.setCustomerEmailId(customer.getEmailId());
|
|
|
902 |
gadgetCopsInsuranceModel.setCustomerAddress1(customerAddress.getLine1());
|
|
|
903 |
gadgetCopsInsuranceModel.setCustomerAddress2(customerAddress.getLine2());
|
|
|
904 |
gadgetCopsInsuranceModel.setCustomerCity(customerAddress.getCity());
|
|
|
905 |
gadgetCopsInsuranceModel.setCustomerPinCode(customerAddress.getPinCode());
|
|
|
906 |
gadgetCopsInsuranceModel.setCustomerState(customerAddress.getState());
|
|
|
907 |
gadgetCopsInsuranceModel.setPrice(insurancePolicy.getSellingPrice());
|
|
|
908 |
gadgetCopsInsuranceModel.setInvoiceNumber(insurancePolicy.getInvoiceNumber());
|
|
|
909 |
gadgetCopsInsuranceModel.setPolicyNumber(insurancePolicy.getPolicyNumber());
|
| 22244 |
ashik.ali |
910 |
|
| 22280 |
ashik.ali |
911 |
try{
|
|
|
912 |
InsuranceUtils.submitToGadgetCops(gadgetCopsInsuranceModel);
|
|
|
913 |
insurancePolicy.setPosted(true);
|
|
|
914 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
|
|
915 |
LOGGER.info("Unable to submit insurance policy details to {}", insuranceProvider.getName(), profitMandiBusinessException);
|
| 22244 |
ashik.ali |
916 |
}
|
| 22280 |
ashik.ali |
917 |
insurancePolicyRepository.persist(insurancePolicy);
|
| 22244 |
ashik.ali |
918 |
}
|
| 22217 |
ashik.ali |
919 |
}
|
| 22280 |
ashik.ali |
920 |
LOGGER.info("Order has been created successfully...");
|
|
|
921 |
return "redirect:/get-order/?orderId="+fofoOrder.getId();
|
| 21612 |
ashik.ali |
922 |
}
|
| 22472 |
ashik.ali |
923 |
|
|
|
924 |
private int getItemIdFromSerialNumber(Map<Integer, Set<String>> itemIdSerialNumbers, String serialNumber){
|
|
|
925 |
for(Map.Entry<Integer, Set<String>> entry : itemIdSerialNumbers.entrySet()){
|
|
|
926 |
if(entry.getValue().contains(serialNumber)){
|
|
|
927 |
return entry.getKey();
|
|
|
928 |
}
|
|
|
929 |
}
|
|
|
930 |
return 0;
|
|
|
931 |
}
|
| 21985 |
kshitij.so |
932 |
|
| 21711 |
ashik.ali |
933 |
private CustomerAddress createCustomerAddress(CustomAddress customAddress){
|
|
|
934 |
CustomerAddress customerAddress = new CustomerAddress();
|
|
|
935 |
customerAddress.setName(customAddress.getName());
|
|
|
936 |
customerAddress.setLine1(customAddress.getLine1());
|
|
|
937 |
customerAddress.setLine2(customAddress.getLine2());
|
|
|
938 |
customerAddress.setLandmark(customAddress.getLandmark());
|
|
|
939 |
customerAddress.setCity(customAddress.getCity());
|
|
|
940 |
customerAddress.setPinCode(customAddress.getPinCode());
|
|
|
941 |
customerAddress.setState(customAddress.getState());
|
|
|
942 |
customerAddress.setCountry(customAddress.getCountry());
|
|
|
943 |
customerAddress.setPhoneNumber(customAddress.getPhoneNumber());
|
|
|
944 |
return customerAddress;
|
| 21680 |
ashik.ali |
945 |
}
|
| 21985 |
kshitij.so |
946 |
|
| 21689 |
ashik.ali |
947 |
private CustomAddress createCustomAddress(Address address){
|
|
|
948 |
CustomAddress customAddress = new CustomAddress();
|
|
|
949 |
customAddress.setName(address.getName());
|
|
|
950 |
customAddress.setLine1(address.getLine1());
|
|
|
951 |
customAddress.setLine2(address.getLine2());
|
|
|
952 |
customAddress.setLandmark(address.getLandmark());
|
|
|
953 |
customAddress.setCity(address.getCity());
|
|
|
954 |
customAddress.setPinCode(address.getPinCode());
|
|
|
955 |
customAddress.setState(address.getState());
|
|
|
956 |
customAddress.setCountry(address.getCountry());
|
|
|
957 |
customAddress.setPhoneNumber(address.getPhoneNumber());
|
|
|
958 |
return customAddress;
|
| 21680 |
ashik.ali |
959 |
}
|
| 21985 |
kshitij.so |
960 |
|
| 21711 |
ashik.ali |
961 |
private CustomAddress createCustomAddress(CustomerAddress customerAddress){
|
|
|
962 |
CustomAddress customAddress = new CustomAddress();
|
|
|
963 |
customAddress.setName(customerAddress.getName());
|
|
|
964 |
customAddress.setLine1(customerAddress.getLine1());
|
|
|
965 |
customAddress.setLine2(customerAddress.getLine2());
|
|
|
966 |
customAddress.setLandmark(customerAddress.getLandmark());
|
|
|
967 |
customAddress.setCity(customerAddress.getCity());
|
|
|
968 |
customAddress.setPinCode(customerAddress.getPinCode());
|
|
|
969 |
customAddress.setState(customerAddress.getState());
|
|
|
970 |
customAddress.setCountry(customerAddress.getCountry());
|
|
|
971 |
customAddress.setPhoneNumber(customerAddress.getPhoneNumber());
|
|
|
972 |
return customAddress;
|
|
|
973 |
}
|
| 21985 |
kshitij.so |
974 |
|
| 21680 |
ashik.ali |
975 |
private void validatePaymentOptionsAndTotalAmount(Set<CustomPaymentOption> customPaymentOptions, float totalAmount) throws ProfitMandiBusinessException
|
| 21612 |
ashik.ali |
976 |
{
|
|
|
977 |
float calculatedAmount = 0;
|
|
|
978 |
Set<String> paymentOptionTypes = new HashSet<>();
|
|
|
979 |
for(CustomPaymentOption customPaymentOption : customPaymentOptions){
|
| 21680 |
ashik.ali |
980 |
if(paymentOptionTypes.contains(customPaymentOption.getType().name())){
|
| 21612 |
ashik.ali |
981 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.PAYMENT_OPTION_TYPE, customPaymentOption.getType().name(), "");
|
| 21680 |
ashik.ali |
982 |
}else{
|
|
|
983 |
paymentOptionTypes.add(customPaymentOption.getType().name());
|
|
|
984 |
calculatedAmount = calculatedAmount + customPaymentOption.getAmount();
|
| 21612 |
ashik.ali |
985 |
}
|
|
|
986 |
}
|
|
|
987 |
if(calculatedAmount != totalAmount){
|
| 22244 |
ashik.ali |
988 |
LOGGER.error("PaymentOptionCalculatedAmount [{}] != TotalAmount [{}]", calculatedAmount, totalAmount);
|
| 21612 |
ashik.ali |
989 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.PAYMENT_OPTION_CALCULATED_AMOUNT, calculatedAmount, "");
|
|
|
990 |
}
|
|
|
991 |
}
|
| 21985 |
kshitij.so |
992 |
|
|
|
993 |
|
| 21689 |
ashik.ali |
994 |
@RequestMapping(value = "/generateInvoice")
|
| 21896 |
ashik.ali |
995 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws Throwable{
|
| 22064 |
ashik.ali |
996 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(), ProfitMandiConstants.ORDER_ID, orderId);
|
| 22139 |
amit.gupta |
997 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 22217 |
ashik.ali |
998 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
| 22026 |
ashik.ali |
999 |
|
| 21689 |
ashik.ali |
1000 |
PdfModel pdfModel = new PdfModel();
|
|
|
1001 |
pdfModel.setAuther("profitmandi");
|
|
|
1002 |
pdfModel.setTitle("Retailer Invoice");
|
| 22217 |
ashik.ali |
1003 |
|
|
|
1004 |
// insurance calculation
|
| 22680 |
amit.gupta |
1005 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectByRetailerInvoiceNumber(fofoDetails.getFofoId(), fofoOrder.getInvoiceNumber());
|
| 22217 |
ashik.ali |
1006 |
Set<CustomInsurancePolicy> customInsurancePolicies = new HashSet<>();
|
|
|
1007 |
final float totalInsuranceTaxRate = 18;
|
|
|
1008 |
for(InsurancePolicy insurancePolicy : insurancePolicies){
|
|
|
1009 |
float taxableInsurancePrice = insurancePolicy.getSaleAmount() / (1 + totalInsuranceTaxRate / 100);
|
|
|
1010 |
CustomInsurancePolicy customInsurancePolicy = new CustomInsurancePolicy();
|
| 22681 |
amit.gupta |
1011 |
customInsurancePolicy.setDescription("Damage Protection Plan for device IMEI #" + insurancePolicy.getSerialNumber() + "\n Certificate No. " + insurancePolicy.getPolicyNumber());
|
| 22684 |
amit.gupta |
1012 |
customInsurancePolicy.setHsnCode("998716");
|
| 22217 |
ashik.ali |
1013 |
customInsurancePolicy.setRate(taxableInsurancePrice);
|
|
|
1014 |
customInsurancePolicy.setIgstRate(18);
|
|
|
1015 |
customInsurancePolicy.setIgstAmount(taxableInsurancePrice * 18 /100);
|
|
|
1016 |
customInsurancePolicy.setCgstRate(18);
|
|
|
1017 |
customInsurancePolicy.setCgstAmount(taxableInsurancePrice * 9 /100);
|
|
|
1018 |
customInsurancePolicy.setSgstRate(9);
|
|
|
1019 |
customInsurancePolicy.setSgstAmount(taxableInsurancePrice * 9 /100);
|
| 22684 |
amit.gupta |
1020 |
customInsurancePolicy.setNetAmount(insurancePolicy.getSaleAmount());
|
| 22217 |
ashik.ali |
1021 |
customInsurancePolicies.add(customInsurancePolicy);
|
|
|
1022 |
}
|
|
|
1023 |
pdfModel.setInsurancePolicies(customInsurancePolicies);
|
| 21689 |
ashik.ali |
1024 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
|
|
1025 |
CustomCustomer customCustomer = new CustomCustomer();
|
| 22217 |
ashik.ali |
1026 |
customCustomer.setFirstName(customer.getFirstName());
|
|
|
1027 |
customCustomer.setLastName(customer.getLastName());
|
| 21689 |
ashik.ali |
1028 |
customCustomer.setEmailId(customer.getEmailId());
|
|
|
1029 |
customCustomer.setMobileNumber(customer.getMobileNumber());
|
| 21711 |
ashik.ali |
1030 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
| 21689 |
ashik.ali |
1031 |
customCustomer.setAddress(this.createCustomAddress(customerAddress));
|
|
|
1032 |
pdfModel.setCustomer(customCustomer);
|
|
|
1033 |
pdfModel.setInvoiceNumber(fofoOrder.getInvoiceNumber());
|
| 22244 |
ashik.ali |
1034 |
pdfModel.setTotalAmount(fofoOrder.getTotalAmount());
|
| 22026 |
ashik.ali |
1035 |
|
| 21689 |
ashik.ali |
1036 |
Retailer retailer = retailerRepository.selectById(fofoDetails.getFofoId());
|
| 22592 |
ashik.ali |
1037 |
PrivateDealUser privateDealUser = null;
|
|
|
1038 |
try{
|
|
|
1039 |
privateDealUser = privateDealUserRepository.selectById(retailer.getId());
|
|
|
1040 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
|
|
1041 |
LOGGER.error("Private Deal User not found : ", profitMandiBusinessException);
|
|
|
1042 |
}
|
| 22354 |
ashik.ali |
1043 |
|
| 21689 |
ashik.ali |
1044 |
User user = userRepository.selectById(userAccountRepository.selectUserIdByRetailerId(retailer.getId()));
|
|
|
1045 |
CustomRetailer customRetailer = new CustomRetailer();
|
|
|
1046 |
customRetailer.setBusinessName(retailer.getName());
|
|
|
1047 |
customRetailer.setMobileNumber(user.getMobileNumber());
|
|
|
1048 |
customRetailer.setTinNumber(retailer.getNumber());
|
| 22592 |
ashik.ali |
1049 |
if(privateDealUser == null){
|
|
|
1050 |
customRetailer.setGstNumber(null);
|
|
|
1051 |
}else{
|
| 22595 |
ashik.ali |
1052 |
if(null != privateDealUser.getCounterId()){
|
|
|
1053 |
Counter counter = counterRepository.selectById(privateDealUser.getCounterId());
|
|
|
1054 |
customRetailer.setGstNumber(counter.getGstin());
|
|
|
1055 |
}else{
|
|
|
1056 |
customRetailer.setGstNumber(null);
|
|
|
1057 |
}
|
| 22354 |
ashik.ali |
1058 |
}
|
| 21689 |
ashik.ali |
1059 |
Address retailerAddress = addressRepository.selectById(retailerRegisteredAddressRepository.selectAddressIdByRetailerId(retailer.getId()));
|
|
|
1060 |
customRetailer.setAddress(this.createCustomAddress(retailerAddress));
|
|
|
1061 |
pdfModel.setRetailer(customRetailer);
|
|
|
1062 |
List<FofoLineItem> fofoLineItems = fofoLineItemRepository.selectByOrderId(fofoOrder.getId());
|
| 22026 |
ashik.ali |
1063 |
|
| 21689 |
ashik.ali |
1064 |
Set<CustomFofoOrderItem> customerFofoOrderItems = new HashSet<>();
|
|
|
1065 |
for(FofoLineItem fofoLineItem : fofoLineItems){
|
|
|
1066 |
CustomFofoOrderItem customFofoOrderItem = new CustomFofoOrderItem();
|
| 22026 |
ashik.ali |
1067 |
float totalTaxRate = fofoLineItem.getIgstRate() + fofoLineItem.getSgstRate() + fofoLineItem.getCgstRate();
|
|
|
1068 |
float taxableSellingPrice = fofoLineItem.getSellingPrice() / (1 + totalTaxRate / 100);
|
| 22668 |
amit.gupta |
1069 |
float taxableDiscountPrice = fofoLineItem.getDiscount() / (1 + totalTaxRate / 100);
|
| 22026 |
ashik.ali |
1070 |
|
| 22668 |
amit.gupta |
1071 |
customFofoOrderItem.setAmount(fofoLineItem.getQuantity() * (taxableSellingPrice-taxableDiscountPrice));
|
| 22672 |
amit.gupta |
1072 |
customFofoOrderItem.setDescription(fofoLineItem.getBrand() + " " + fofoLineItem.getModelName() + " " + fofoLineItem.getModelNumber() + "-" + fofoLineItem.getColor() + "\n IMEIS - " + String.join(", ",this.toSerialNumbers(fofoLineItem.getFofoLineItemSerialNumbers())));
|
| 22026 |
ashik.ali |
1073 |
customFofoOrderItem.setRate(taxableSellingPrice);
|
| 22668 |
amit.gupta |
1074 |
customFofoOrderItem.setDiscount(taxableDiscountPrice);
|
| 21689 |
ashik.ali |
1075 |
customFofoOrderItem.setQuantity(fofoLineItem.getQuantity());
|
| 22684 |
amit.gupta |
1076 |
customFofoOrderItem.setNetAmount((fofoLineItem.getSellingPrice()-fofoLineItem.getDiscount())*fofoLineItem.getQuantity());
|
| 22026 |
ashik.ali |
1077 |
float igstAmount = (customFofoOrderItem.getAmount() * fofoLineItem.getIgstRate()) / 100;
|
|
|
1078 |
float cgstAmount = (customFofoOrderItem.getAmount() * fofoLineItem.getCgstRate()) / 100;
|
|
|
1079 |
float sgstAmount = (customFofoOrderItem.getAmount() * fofoLineItem.getSgstRate()) / 100;
|
| 21896 |
ashik.ali |
1080 |
customFofoOrderItem.setIgstRate(fofoLineItem.getIgstRate());
|
| 22026 |
ashik.ali |
1081 |
customFofoOrderItem.setIgstAmount(igstAmount);
|
|
|
1082 |
customFofoOrderItem.setCgstRate(fofoLineItem.getCgstRate());
|
|
|
1083 |
customFofoOrderItem.setCgstAmount(cgstAmount);
|
|
|
1084 |
customFofoOrderItem.setSgstRate(fofoLineItem.getSgstRate());
|
|
|
1085 |
customFofoOrderItem.setSgstAmount(sgstAmount);
|
| 21896 |
ashik.ali |
1086 |
customFofoOrderItem.setHsnCode(fofoLineItem.getHsnCode());
|
| 21689 |
ashik.ali |
1087 |
customerFofoOrderItems.add(customFofoOrderItem);
|
|
|
1088 |
}
|
|
|
1089 |
pdfModel.setOrderItems(customerFofoOrderItems);
|
|
|
1090 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
1091 |
PdfUtils.generateAndWrite(pdfModel, byteArrayOutputStream);
|
|
|
1092 |
//final MediaType mediaType=MediaType.parseMediaType(profilePhotoModel.getContentType().getValue());
|
|
|
1093 |
LOGGER.info("Pdf Stream length {}", byteArrayOutputStream.toByteArray().length);
|
| 22026 |
ashik.ali |
1094 |
final HttpHeaders headers=new HttpHeaders();
|
|
|
1095 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
| 22099 |
kshitij.so |
1096 |
headers.set("Content-disposition", "inline; filename=invoice-" + fofoOrder.getInvoiceNumber() + ".pdf");
|
| 22026 |
ashik.ali |
1097 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
1098 |
final InputStream inputStream=new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
1099 |
final InputStreamResource inputStreamResource=new InputStreamResource(inputStream);
|
|
|
1100 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| 21689 |
ashik.ali |
1101 |
}
|
| 21985 |
kshitij.so |
1102 |
|
| 21689 |
ashik.ali |
1103 |
private Set<String> toSerialNumbers(Set<FofoLineItemSerialNumber> fofoLineItemSerialNumbers){
|
|
|
1104 |
Set<String> serialNumbers = new HashSet<>(fofoLineItemSerialNumbers.size());
|
|
|
1105 |
for(FofoLineItemSerialNumber fofoLineItemSerialNumber : fofoLineItemSerialNumbers){
|
|
|
1106 |
serialNumbers.add(fofoLineItemSerialNumber.getSerialNumber());
|
|
|
1107 |
}
|
|
|
1108 |
return serialNumbers;
|
|
|
1109 |
}
|
| 22244 |
ashik.ali |
1110 |
|
|
|
1111 |
@RequestMapping(value = "/saleHistory")
|
|
|
1112 |
public String saleHistory(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.START_TIME, required = false) String startTimeString, @RequestParam(name = ProfitMandiConstants.END_TIME, required = false) String endTimeString, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam(name = ProfitMandiConstants.INVOICE_NUMBER, defaultValue = "") String invoiceNumber, @RequestParam(name = "searchType",defaultValue="") String searchType, Model model) throws Exception{
|
|
|
1113 |
LoginDetails loginDetails = null;
|
|
|
1114 |
try {
|
|
|
1115 |
loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1116 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1117 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
|
|
1118 |
return "response";
|
|
|
1119 |
}
|
|
|
1120 |
|
|
|
1121 |
LocalDateTime startDateTime = StringUtils.toDateTime(startTimeString);
|
|
|
1122 |
LocalDateTime endDateTime = StringUtils.toDateTime(endTimeString);
|
|
|
1123 |
long countItems = 0;
|
|
|
1124 |
List<FofoOrder> fofoOrders = new ArrayList<>();
|
| 22284 |
ashik.ali |
1125 |
if(searchType.equalsIgnoreCase(ProfitMandiConstants.INVOICE_NUMBER) && !invoiceNumber.isEmpty()){
|
| 22244 |
ashik.ali |
1126 |
try {
|
|
|
1127 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndInvoiceNumber(loginDetails.getFofoId(), invoiceNumber);
|
|
|
1128 |
fofoOrders.add(fofoOrder);
|
|
|
1129 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1130 |
LOGGER.info("Sale history not found : ", e);
|
|
|
1131 |
}
|
|
|
1132 |
}else{
|
|
|
1133 |
fofoOrders = fofoOrderRepository.selectByFofoId(loginDetails.getFofoId(),startDateTime, endDateTime, offset, limit);
|
|
|
1134 |
countItems = fofoOrderRepository.selectCount(loginDetails.getFofoId(), startDateTime, endDateTime, invoiceNumber, searchType);
|
|
|
1135 |
}
|
|
|
1136 |
|
|
|
1137 |
model.addAttribute("saleHistories", fofoOrders);
|
| 22551 |
ashik.ali |
1138 |
model.addAttribute("start", offset + 1);
|
|
|
1139 |
model.addAttribute("size", countItems);
|
|
|
1140 |
model.addAttribute("searchType", searchType);
|
| 22244 |
ashik.ali |
1141 |
model.addAttribute(ProfitMandiConstants.START_TIME, startTimeString);
|
|
|
1142 |
model.addAttribute(ProfitMandiConstants.END_TIME, endTimeString);
|
|
|
1143 |
if (fofoOrders.size() < limit){
|
| 22551 |
ashik.ali |
1144 |
model.addAttribute("end", offset + fofoOrders.size());
|
| 22244 |
ashik.ali |
1145 |
}
|
|
|
1146 |
else{
|
| 22551 |
ashik.ali |
1147 |
model.addAttribute("end", offset + limit);
|
| 22244 |
ashik.ali |
1148 |
}
|
|
|
1149 |
|
|
|
1150 |
return "sale-history";
|
|
|
1151 |
}
|
| 22291 |
ashik.ali |
1152 |
|
|
|
1153 |
|
|
|
1154 |
@RequestMapping(value = "/getPaginatedSaleHistory")
|
|
|
1155 |
public String getSaleHistoryPaginated(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.START_TIME, required = false) String startTimeString, @RequestParam(name = ProfitMandiConstants.END_TIME, required = false) String endTimeString, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue="10") int limit, @RequestParam(name = ProfitMandiConstants.INVOICE_NUMBER, defaultValue="") String invoiceNumber, @RequestParam(name = "searchType", defaultValue = "") String searchType, Model model) throws Exception{
|
|
|
1156 |
LoginDetails loginDetails;
|
|
|
1157 |
try {
|
|
|
1158 |
loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1159 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1160 |
model.addAttribute("loginResponse", mvcResponseSender.createResponseString("RTLR_1009", false, "/login"));
|
|
|
1161 |
return "response";
|
|
|
1162 |
}
|
|
|
1163 |
LocalDateTime startDateTime = StringUtils.toDateTime(startTimeString);
|
|
|
1164 |
LocalDateTime endDateTime = StringUtils.toDateTime(endTimeString);
|
| 21985 |
kshitij.so |
1165 |
|
| 22291 |
ashik.ali |
1166 |
List<FofoOrder> saleHistories = fofoOrderRepository.selectByFofoId(loginDetails.getFofoId(), startDateTime, endDateTime, offset, limit);
|
|
|
1167 |
model.addAttribute("saleHistories", saleHistories);
|
|
|
1168 |
return "sale-history-paginated";
|
|
|
1169 |
}
|
|
|
1170 |
|
| 21612 |
ashik.ali |
1171 |
}
|