Subversion Repositories SmartDukaan

Rev

Rev 25714 | Rev 25725 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25714 Rev 25724
Line 43... Line 43...
43
import com.spice.profitmandi.common.model.PdfModel;
43
import com.spice.profitmandi.common.model.PdfModel;
44
import com.spice.profitmandi.common.model.PriceModel;
44
import com.spice.profitmandi.common.model.PriceModel;
45
import com.spice.profitmandi.common.model.ProfitMandiConstants;
45
import com.spice.profitmandi.common.model.ProfitMandiConstants;
46
import com.spice.profitmandi.common.model.Quantity;
46
import com.spice.profitmandi.common.model.Quantity;
47
import com.spice.profitmandi.common.model.SerialNumberDetail;
47
import com.spice.profitmandi.common.model.SerialNumberDetail;
48
import com.spice.profitmandi.common.model.WiseAppInsuaranceModel;
-
 
49
import com.spice.profitmandi.common.util.FormattingUtils;
48
import com.spice.profitmandi.common.util.FormattingUtils;
50
import com.spice.profitmandi.common.util.InsuranceUtils;
-
 
51
import com.spice.profitmandi.common.util.StringUtils;
49
import com.spice.profitmandi.common.util.StringUtils;
52
import com.spice.profitmandi.common.util.Utils;
50
import com.spice.profitmandi.common.util.Utils;
53
import com.spice.profitmandi.dao.entity.catalog.Item;
51
import com.spice.profitmandi.dao.entity.catalog.Item;
54
import com.spice.profitmandi.dao.entity.catalog.TagListing;
52
import com.spice.profitmandi.dao.entity.catalog.TagListing;
55
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
53
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
Line 78... Line 76...
78
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
76
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
79
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
77
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
80
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
78
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
81
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
79
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
82
import com.spice.profitmandi.dao.enumuration.fofo.SettlementType;
80
import com.spice.profitmandi.dao.enumuration.fofo.SettlementType;
83
 
-
 
84
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
81
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
85
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
82
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
86
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
83
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
87
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
84
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
88
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
85
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
Line 110... Line 107...
110
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
107
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
111
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
108
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
112
import com.spice.profitmandi.dao.repository.user.AddressRepository;
109
import com.spice.profitmandi.dao.repository.user.AddressRepository;
113
import com.spice.profitmandi.dao.repository.user.CounterRepository;
110
import com.spice.profitmandi.dao.repository.user.CounterRepository;
114
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
111
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
115
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
-
 
116
import com.spice.profitmandi.service.integrations.zest.ZestService;
112
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
117
import com.spice.profitmandi.service.inventory.InventoryService;
113
import com.spice.profitmandi.service.inventory.InventoryService;
118
import com.spice.profitmandi.service.inventory.PurchaseReturnService;
114
import com.spice.profitmandi.service.inventory.PurchaseReturnService;
119
import com.spice.profitmandi.service.pricing.PricingService;
115
import com.spice.profitmandi.service.pricing.PricingService;
120
import com.spice.profitmandi.service.scheme.SchemeService;
116
import com.spice.profitmandi.service.scheme.SchemeService;
121
import com.spice.profitmandi.service.user.RetailerService;
117
import com.spice.profitmandi.service.user.RetailerService;
122
import com.spice.profitmandi.service.wallet.WalletService;
118
import com.spice.profitmandi.service.wallet.WalletService;
123
 
119
 
124
import in.shop2020.model.v1.order.WalletReferenceType;
-
 
125
 
-
 
126
@Component
120
@Component
127
public class OrderServiceImpl implements OrderService {
121
public class OrderServiceImpl implements OrderService {
128
 
122
 
129
	private static final Logger LOGGER = LogManager.getLogger(OrderServiceImpl.class);
123
	private static final Logger LOGGER = LogManager.getLogger(OrderServiceImpl.class);
130
 
124
 
Line 134... Line 128...
134
 
128
 
135
	@Autowired
129
	@Autowired
136
	private LiveDemoBillingRespository liveDemoBillingRespository;
130
	private LiveDemoBillingRespository liveDemoBillingRespository;
137
 
131
 
138
	@Autowired
132
	@Autowired
-
 
133
	private InsuranceService insuranceService;
-
 
134
 
-
 
135
	@Autowired
139
	private WalletService walletService;
136
	private WalletService walletService;
140
 
137
 
141
	@Autowired
138
	@Autowired
142
	@Qualifier("fofoCurrentInventorySnapshotRepository")
139
	@Qualifier("fofoCurrentInventorySnapshotRepository")
143
	private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
140
	private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
Line 147... Line 144...
147
 
144
 
148
	@Autowired
145
	@Autowired
149
	private PurchaseReturnService purchaseReturnService;
146
	private PurchaseReturnService purchaseReturnService;
150
 
147
 
151
	@Autowired
148
	@Autowired
152
	private ZestService zestService;
149
	private InsuranceService zestService;
153
 
150
 
154
	@Autowired
151
	@Autowired
155
	private RetailerService retailerService;
152
	private RetailerService retailerService;
156
 
153
 
157
	@Autowired
154
	@Autowired
Line 248... Line 245...
248
	private HygieneDataRepository hygieneDataRepository;
245
	private HygieneDataRepository hygieneDataRepository;
249
 
246
 
250
	@Override
247
	@Override
251
	public int createOrder(CreateOrderRequest createOrderRequest, int fofoId, boolean accessoriesDeals)
248
	public int createOrder(CreateOrderRequest createOrderRequest, int fofoId, boolean accessoriesDeals)
252
			throws ProfitMandiBusinessException {
249
			throws ProfitMandiBusinessException {
253
 
-
 
-
 
250
		LOGGER.info("fofoId -- {} Order Request -- {}", fofoId, createOrderRequest);
254
		CustomCustomer customCustomer = createOrderRequest.getCustomer();
251
		CustomCustomer customCustomer = createOrderRequest.getCustomer();
255
 
252
 
256
		if (!StringUtils.isValidEmailAddress(customCustomer.getEmailId())) {
253
		if (!StringUtils.isValidEmailAddress(customCustomer.getEmailId())) {
257
			LOGGER.error("invalid customer emailId {} ", customCustomer.getEmailId());
254
			LOGGER.error("invalid customer emailId {} ", customCustomer.getEmailId());
258
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, customCustomer.getEmailId(),
255
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, customCustomer.getEmailId(),
Line 328... Line 325...
328
 
325
 
329
		Map<Integer, Item> itemMap = this.toItemMap(items);
326
		Map<Integer, Item> itemMap = this.toItemMap(items);
330
 
327
 
331
		Set<Integer> nonSerializedItemIds = new HashSet<>();
328
		Set<Integer> nonSerializedItemIds = new HashSet<>();
332
		Set<String> serialNumbers = new HashSet<>();
329
		Set<String> serialNumbers = new HashSet<>();
333
		Map<String, InsuranceModel> insuranceSerialNumberMap = new HashMap<>();
330
		List<InsuranceModel> insuredModels = new ArrayList<>();
334
		for (CustomFofoOrderItem customFofoOrderItem : createOrderRequest.getFofoOrderItems()) {
331
		for (CustomFofoOrderItem customFofoOrderItem : createOrderRequest.getFofoOrderItems()) {
335
			Item item = itemMap.get(customFofoOrderItem.getItemId());
332
			Item item = itemMap.get(customFofoOrderItem.getItemId());
336
			noGST = item.getHsnCode().equals("NOGST");
333
			noGST = item.getHsnCode().equals("NOGST");
337
			if (item.getType().equals(ItemType.SERIALIZED)) {
334
			if (item.getType().equals(ItemType.SERIALIZED)) {
338
				for (SerialNumberDetail serialNumberDetail : customFofoOrderItem.getSerialNumberDetails()) {
335
				for (SerialNumberDetail serialNumberDetail : customFofoOrderItem.getSerialNumberDetails()) {
339
					serialNumbers.add(serialNumberDetail.getSerialNumber());
336
					serialNumbers.add(serialNumberDetail.getSerialNumber());
340
					if (serialNumberDetail.getAmount() > 0) {
337
					if (serialNumberDetail.getAmount() > 0) {
341
						InsuranceModel im = new InsuranceModel();
338
						InsuranceModel im = new InsuranceModel();
342
						im.setBrand(item.getBrand());
339
						im.setBrand(item.getBrand());
343
						im.setModelName(item.getModelName());
340
						im.setColor(item.getColor());
-
 
341
						im.setModelName(item.getModelName() + item.getModelNumber());
344
						im.setInsuranceAmount(serialNumberDetail.getAmount());
342
						im.setInsuranceAmount(serialNumberDetail.getAmount());
345
						im.setDeviceSellingPrice(customFofoOrderItem.getSellingPrice());
343
						im.setDeviceSellingPrice(customFofoOrderItem.getSellingPrice());
346
						im.setInsuranceId(serialNumberDetail.getInsurance() + "");
344
						im.setInsuranceId(serialNumberDetail.getInsurance());
347
						insuranceSerialNumberMap.put(serialNumberDetail.getSerialNumber(), im);
345
						im.setSerialNumber(serialNumberDetail.getSerialNumber());
-
 
346
						insuredModels.add(im);
348
					}
347
					}
349
				}
348
				}
350
			} else {
349
			} else {
351
				nonSerializedItemIds.add(customFofoOrderItem.getItemId());
350
				nonSerializedItemIds.add(customFofoOrderItem.getItemId());
352
			}
351
			}
Line 403... Line 402...
403
				// TODO:handle null
402
				// TODO:handle null
404
				if (serializedInventoryItemMap.get(item.getId()) == null
403
				if (serializedInventoryItemMap.get(item.getId()) == null
405
						|| itemIdCustomFofoOrderItemMap.get(item.getId()).getSerialNumberDetails()
404
						|| itemIdCustomFofoOrderItemMap.get(item.getId()).getSerialNumberDetails()
406
								.size() != serializedInventoryItemMap.get(item.getId()).size()) {
405
								.size() != serializedInventoryItemMap.get(item.getId()).size()) {
407
 
406
 
408
					LOGGER.error("itemId {} => mismatch size of requested serial numbers", item.getId());
-
 
409
					List<String> invalidSerialNumbers = itemIdCustomFofoOrderItemMap.get(item.getId())
407
					List<String> invalidSerialNumbers = itemIdCustomFofoOrderItemMap.get(item.getId())
410
							.getSerialNumberDetails().stream().map(x -> x.getSerialNumber())
408
							.getSerialNumberDetails().stream().map(x -> x.getSerialNumber())
411
							.collect(Collectors.toList());
409
							.collect(Collectors.toList());
412
					throw new ProfitMandiBusinessException("invalidSerialNumbers", invalidSerialNumbers, "FFORDR_1004");
410
					throw new ProfitMandiBusinessException("invalidSerialNumbers", invalidSerialNumbers, "FFORDR_1004");
413
				}
411
				}
Line 513... Line 511...
513
				this.createAndGetHygieneData(fofoOrder.getId(), fofoOrder.getFofoId());
511
				this.createAndGetHygieneData(fofoOrder.getId(), fofoOrder.getFofoId());
514
			}
512
			}
515
		}
513
		}
516
		// insurance calculation is insurance flag is enabled
514
		// insurance calculation is insurance flag is enabled
517
		//
515
		//
518
		if (!insuranceSerialNumberMap.isEmpty()) {
516
		if (insuredModels.size() > 0) {
519
			LOGGER.info("Processing insurane for serialNumbers");
517
			LOGGER.info("Processing insurane for serialNumbers");
520
 
-
 
521
			LocalDate customerDateOfBirth = LocalDate.from(createOrderRequest.getCustomer().getDateOfBirth());
518
			LocalDate customerDateOfBirth = LocalDate.from(createOrderRequest.getCustomer().getDateOfBirth());
522
 
-
 
523
			for (Map.Entry<String, InsuranceModel> entry : insuranceSerialNumberMap.entrySet()) {
519
			fofoOrder.setDateOfBirth(customerDateOfBirth);
524
				InsuranceModel insuranceModel = entry.getValue();
520
			for (InsuranceModel insuranceModel : insuredModels) {
525
				MobileInsurancePlan mobileInsurancePlan = zestService.getAllPlansMap()
-
 
526
						.get(insuranceModel.getInsuranceId());
-
 
527
				InsurancePolicy insurancePolicy = this.createInsurancePolicy(fofoOrder.getInvoiceNumber(), fofoId,
-
 
528
						insuranceModel.getInsuranceAmount() - mobileInsurancePlan.getPartnerCommission(),
-
 
529
						insuranceModel.getInsuranceAmount(), insuranceModel.getDeviceSellingPrice(), entry.getKey(),
-
 
530
						insuranceModel.getModelName(), insuranceModel.getBrand(), customer, customerDateOfBirth,
-
 
531
						customerAddress,
-
 
532
						mobileInsurancePlan.getProductName() + " for " + mobileInsurancePlan.getDuration() + " Months");
-
 
533
 
-
 
534
				String walletDescription = null;
-
 
535
				if (mobileInsurancePlan.getProviderId().equals("0")) {
-
 
536
					insurancePolicy.setProviderId(1);
-
 
537
					int policyNumberGenerationSequence = this.createPolicyNumberGenerationSequence().getSequence();
-
 
538
					insurancePolicy.setPolicyNumber(StringUtils.generatePolicyNumber(
-
 
539
							ProfitMandiConstants.POLICY_NUMBER_PREFIX, policyNumberGenerationSequence));
-
 
540
					GadgetCopsInsuranceModel gadgetCopsInsuranceModel = this.createGadgetCopsInsuranceModel(
-
 
541
							entry.getValue().getBrand(), entry.getValue().getModelName(), entry.getKey(),
-
 
542
							customerDateOfBirth, customer, customerAddress, insurancePolicy);
-
 
543
 
-
 
544
					try {
-
 
545
						InsuranceUtils.submitToGadgetCops(gadgetCopsInsuranceModel);
-
 
546
						insurancePolicy.setPosted(true);
-
 
547
						walletDescription = "Sale of " + insurancePolicy.getPolicyNumber() + " for "
-
 
548
								+ fofoOrder.getInvoiceNumber();
-
 
549
					} catch (ProfitMandiBusinessException profitMandiBusinessException) {
-
 
550
						LOGGER.info("Unable to submit insurance policy details to {}", insuranceModel.getProviderName(),
-
 
551
								profitMandiBusinessException);
-
 
552
						throw new ProfitMandiBusinessException("Insurance", mobileInsurancePlan.getProductName(),
-
 
553
								"Could not generate insurance for Gadget Cop");
-
 
554
					}
-
 
555
				} else {
-
 
556
					try {
521
				try {
557
						WiseAppInsuaranceModel wiseAppInsuaranceModel = this
-
 
558
								.createWiseAppInsuranceModel(mobileInsurancePlan, insurancePolicy, customCustomer);
-
 
559
						String wiseAppInsuranceCode = zestService.createInsurance(wiseAppInsuaranceModel);
522
					insuranceService.createInsurance(fofoOrder, insuranceModel);
560
						insurancePolicy.setPolicyNumber(wiseAppInsuranceCode);
-
 
561
						// TODO: remove hardcoding
-
 
562
						insurancePolicy.setProviderId(2);
-
 
563
						walletDescription = "Sale of " + insurancePolicy.getProductName() + " against "
-
 
564
								+ fofoOrder.getInvoiceNumber();
-
 
565
					} catch (ProfitMandiBusinessException pbe) {
523
				} catch (Exception e) {
566
						pbe.printStackTrace();
524
					e.printStackTrace();
567
						throw new ProfitMandiBusinessException("Insurance", mobileInsurancePlan.getProductName(),
525
					throw new ProfitMandiBusinessException("Insurance creation", insuranceModel,
568
								pbe.getMessage());
526
							"Failed to create insurance");
569
					}
-
 
570
				}
527
				}
571
				walletService.consumeAmountFromWallet(fofoId, insurancePolicy.getId(),
-
 
572
						WalletReferenceType.DAMAGE_PROTECTION, walletDescription, insurancePolicy.getPurchaseAmount());
-
 
573
				insurancePolicyRepository.persist(insurancePolicy);
-
 
574
			}
528
			}
575
		}
529
		}
576
		schemeService.processSchemeOut(fofoOrder.getId(), fofoId);
530
		schemeService.processSchemeOut(fofoOrder.getId(), fofoId);
577
		return fofoOrder.getId();
531
		return fofoOrder.getId();
578
	}
532
	}
Line 585... Line 539...
585
		hygieneDataRepository.persist(hygieneData);
539
		hygieneDataRepository.persist(hygieneData);
586
 
540
 
587
		return hygieneData;
541
		return hygieneData;
588
	}
542
	}
589
 
543
 
590
	private WiseAppInsuaranceModel createWiseAppInsuranceModel(MobileInsurancePlan mobileInsurancePlan,
-
 
591
			InsurancePolicy insurancePolicy, CustomCustomer customer) throws ProfitMandiBusinessException {
-
 
592
		WiseAppInsuaranceModel wiseAppInsuranceModel = new WiseAppInsuaranceModel();
-
 
593
		CustomAddress address = customer.getAddress();
-
 
594
 
-
 
595
		String sAddress = (address.getLine1() + " " + address.getLine2()).replaceAll("  ", " ");
-
 
596
		wiseAppInsuranceModel.setAddress(sAddress);
-
 
597
		wiseAppInsuranceModel.setBrand(insurancePolicy.getBrand());
-
 
598
		wiseAppInsuranceModel.setBalanceType("4");
-
 
599
		wiseAppInsuranceModel.setProduct(mobileInsurancePlan.getProductId());
-
 
600
		wiseAppInsuranceModel
-
 
601
				.setName((insurancePolicy.getCustomerFirstName() + " " + insurancePolicy.getCustomerLastName()));
-
 
602
		wiseAppInsuranceModel.setCity(address.getCity());
-
 
603
		wiseAppInsuranceModel.setDob(StringUtils.toHyphenatedString(customer.getDateOfBirth()));
-
 
604
		wiseAppInsuranceModel.setDuration(mobileInsurancePlan.getDuration());
-
 
605
		wiseAppInsuranceModel.setPincode(address.getPinCode());
-
 
606
		wiseAppInsuranceModel.setEmail(customer.getEmailId());
-
 
607
		wiseAppInsuranceModel.setDeviceType(mobileInsurancePlan.getDeviceTypeId());
-
 
608
		wiseAppInsuranceModel.setImeiNo(insurancePolicy.getSerialNumber());
-
 
609
		wiseAppInsuranceModel.setPlanValue(String.valueOf(insurancePolicy.getSaleAmount()));
-
 
610
		wiseAppInsuranceModel.setRetailerId(zestService.getWiseAppPartnerCode(insurancePolicy.getRetailerId()));
-
 
611
		wiseAppInsuranceModel.setDuration(mobileInsurancePlan.getDuration());
-
 
612
		wiseAppInsuranceModel.setGender(customer.getGender());
-
 
613
		wiseAppInsuranceModel.setInvoiceNo(insurancePolicy.getInvoiceNumber());
-
 
614
		wiseAppInsuranceModel.setNumber(insurancePolicy.getCustomerMobileNumber());
-
 
615
		wiseAppInsuranceModel
-
 
616
				.setPurchaseDate(StringUtils.toHyphenatedString(insurancePolicy.getCreateTimestamp().toLocalDate()));
-
 
617
		wiseAppInsuranceModel.setModel(insurancePolicy.getModelName());
-
 
618
		wiseAppInsuranceModel.setHandSetValue(String.valueOf(insurancePolicy.getSellingPrice()));
-
 
619
		wiseAppInsuranceModel.setInsurerCompany(mobileInsurancePlan.getProviderId());
-
 
620
		return wiseAppInsuranceModel;
-
 
621
	}
-
 
622
 
-
 
623
	@Override
544
	@Override
624
	public String getInvoiceNumber(int fofoId, String fofoStoreCode) {
545
	public String getInvoiceNumber(int fofoId, String fofoStoreCode) {
625
		InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = null;
546
		InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = null;
626
		try {
547
		try {
627
			invoiceNumberGenerationSequence = invoiceNumberGenerationSequenceRepository.selectByFofoId(fofoId);
548
			invoiceNumberGenerationSequence = invoiceNumberGenerationSequenceRepository.selectByFofoId(fofoId);
Line 1017... Line 938...
1017
			}
938
			}
1018
		}
939
		}
1019
		return serialNumbers;
940
		return serialNumbers;
1020
	}
941
	}
1021
 
942
 
1022
	private PolicyNumberGenerationSequence createPolicyNumberGenerationSequence() {
-
 
1023
		PolicyNumberGenerationSequence policyNumberGenerationSequence = null;
-
 
1024
		try {
-
 
1025
			policyNumberGenerationSequence = policyNumberGenerationSequenceRepository.select();
-
 
1026
			policyNumberGenerationSequence.setSequence(policyNumberGenerationSequence.getSequence() + 1);
-
 
1027
			policyNumberGenerationSequenceRepository.persist(policyNumberGenerationSequence);
-
 
1028
		} catch (ProfitMandiBusinessException profitMandiBusinessException) {
-
 
1029
			policyNumberGenerationSequence = new PolicyNumberGenerationSequence();
-
 
1030
			policyNumberGenerationSequence.setSequence(1);
-
 
1031
			policyNumberGenerationSequenceRepository.persist(policyNumberGenerationSequence);
-
 
1032
		}
-
 
1033
		return policyNumberGenerationSequence;
-
 
1034
	}
-
 
1035
 
-
 
1036
	private GadgetCopsInsuranceModel createGadgetCopsInsuranceModel(String brand, String modelName, String serialNumber,
-
 
1037
			LocalDate customerDateOfBirth, Customer customer, CustomerAddress customerAddress,
-
 
1038
			InsurancePolicy insurancePolicy) {
-
 
1039
		GadgetCopsInsuranceModel gadgetCopsInsuranceModel = new GadgetCopsInsuranceModel();
-
 
1040
		gadgetCopsInsuranceModel.setBrand(brand);
-
 
1041
		gadgetCopsInsuranceModel.setModelName(modelName);
-
 
1042
		gadgetCopsInsuranceModel.setSerialNumber(serialNumber);
-
 
1043
		gadgetCopsInsuranceModel.setCustomerFirstName(customer.getFirstName());
-
 
1044
		gadgetCopsInsuranceModel.setCustomerLastName(customer.getLastName());
-
 
1045
		gadgetCopsInsuranceModel.setCustomerDateOfBirth(customerDateOfBirth);
-
 
1046
		gadgetCopsInsuranceModel.setCustomerMobileNumber(customer.getMobileNumber());
-
 
1047
		gadgetCopsInsuranceModel.setCustomerEmailId(customer.getEmailId());
-
 
1048
		gadgetCopsInsuranceModel.setCustomerAddress1(customerAddress.getLine1());
-
 
1049
		gadgetCopsInsuranceModel.setCustomerAddress2(customerAddress.getLine2());
-
 
1050
		gadgetCopsInsuranceModel.setCustomerCity(customerAddress.getCity());
-
 
1051
		gadgetCopsInsuranceModel.setCustomerPinCode(customerAddress.getPinCode());
-
 
1052
		gadgetCopsInsuranceModel.setCustomerState(customerAddress.getState());
-
 
1053
		gadgetCopsInsuranceModel.setPrice(insurancePolicy.getSellingPrice());
-
 
1054
		gadgetCopsInsuranceModel.setInvoiceNumber(insurancePolicy.getInvoiceNumber());
-
 
1055
		gadgetCopsInsuranceModel.setPolicyNumber(insurancePolicy.getPolicyNumber());
-
 
1056
		return gadgetCopsInsuranceModel;
-
 
1057
	}
-
 
1058
 
-
 
1059
	private InsurancePolicy createInsurancePolicy(String invoiceNumber, int retailerId, float purchaseAmount,
-
 
1060
			float saleAmount, float sellingPrice, String serialNumber, String modelName, String brand,
-
 
1061
			Customer customer, LocalDate customerDateOfBirth, CustomerAddress customerAddress, String productName) {
-
 
1062
		InsurancePolicy insurancePolicy = new InsurancePolicy();
-
 
1063
		insurancePolicy.setInvoiceNumber(invoiceNumber);
-
 
1064
		insurancePolicy.setRetailerId(retailerId);
-
 
1065
		insurancePolicy.setPurchaseAmount(purchaseAmount);
-
 
1066
		insurancePolicy.setSaleAmount(saleAmount);
-
 
1067
		insurancePolicy.setSellingPrice(sellingPrice);
-
 
1068
		insurancePolicy.setSerialNumber(serialNumber);
-
 
1069
		insurancePolicy.setModelName(modelName);
-
 
1070
		insurancePolicy.setBrand(brand);
-
 
1071
		insurancePolicy.setCustomerFirstName(customer.getFirstName());
-
 
1072
		insurancePolicy.setCustomerLastName(customer.getLastName());
-
 
1073
		insurancePolicy.setCustomerMobileNumber(customer.getMobileNumber());
-
 
1074
		insurancePolicy.setCustomerEmailId(customer.getEmailId());
-
 
1075
		insurancePolicy.setCustomerDateOfBirth(customerDateOfBirth);
-
 
1076
		insurancePolicy.setCustomerAddress1(customerAddress.getLine1());
-
 
1077
		insurancePolicy.setCustomerAddress2(customerAddress.getLine2());
-
 
1078
		insurancePolicy.setCustomerCity(customerAddress.getCity());
-
 
1079
		insurancePolicy.setCustomerPinCode(customerAddress.getPinCode());
-
 
1080
		insurancePolicy.setCustomerState(customerAddress.getState());
-
 
1081
		insurancePolicy.setProductName(productName);
-
 
1082
		return insurancePolicy;
-
 
1083
	}
-
 
1084
 
-
 
1085
	private void validateDpPrice(Map<Integer, PriceModel> itemIdMopPriceMap,
943
	private void validateDpPrice(Map<Integer, PriceModel> itemIdMopPriceMap,
1086
			Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
944
			Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
1087
		for (Map.Entry<Integer, CustomFofoOrderItem> entry : itemIdCustomFofoLineItemMap.entrySet()) {
945
		for (Map.Entry<Integer, CustomFofoOrderItem> entry : itemIdCustomFofoLineItemMap.entrySet()) {
1088
			int itemId = entry.getKey();
946
			int itemId = entry.getKey();
1089
			CustomFofoOrderItem customFofoOrderItem = entry.getValue();
947
			CustomFofoOrderItem customFofoOrderItem = entry.getValue();
Line 1702... Line 1560...
1702
	}
1560
	}
1703
 
1561
 
1704
	@Override
1562
	@Override
1705
	public boolean notifyColorChange(int orderId, int itemId) throws ProfitMandiBusinessException {
1563
	public boolean notifyColorChange(int orderId, int itemId) throws ProfitMandiBusinessException {
1706
		Order order = orderRepository.selectById(orderId);
1564
		Order order = orderRepository.selectById(orderId);
1707
		inventoryService.reservationCount(itemId, order);
1565
		inventoryService.reservationCountByColor(itemId, order);
1708
 
1566
 
1709
		order.getLineItem().setItemId(itemId);
1567
		order.getLineItem().setItemId(itemId);
1710
		Item item = itemRepository.selectById(itemId);
1568
		Item item = itemRepository.selectById(itemId);
1711
		order.getLineItem().setColor(item.getColor());
1569
		order.getLineItem().setColor(item.getColor());
1712
		return true;
1570
		return true;
Line 1723... Line 1581...
1723
			return fofoOrder;
1581
			return fofoOrder;
1724
		} else {
1582
		} else {
1725
			throw new Exception(String.format("Could not find inventoryItemId - %s", inventoryItemId));
1583
			throw new Exception(String.format("Could not find inventoryItemId - %s", inventoryItemId));
1726
		}
1584
		}
1727
	}
1585
	}
1728
 
-
 
1729
}
1586
}
1730
1587