Subversion Repositories SmartDukaan

Rev

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

Rev 32526 Rev 32533
Line 35... Line 35...
35
import com.spice.profitmandi.dao.entity.fofo.*;
35
import com.spice.profitmandi.dao.entity.fofo.*;
36
import com.spice.profitmandi.dao.entity.inventory.*;
36
import com.spice.profitmandi.dao.entity.inventory.*;
37
import com.spice.profitmandi.dao.entity.transaction.*;
37
import com.spice.profitmandi.dao.entity.transaction.*;
38
import com.spice.profitmandi.dao.entity.user.*;
38
import com.spice.profitmandi.dao.entity.user.*;
39
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
39
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
40
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInvoiceItem;
-
 
41
import com.spice.profitmandi.dao.entity.warehouse.WarehouseScan;
40
import com.spice.profitmandi.dao.entity.warehouse.WarehouseScan;
42
import com.spice.profitmandi.dao.entity.warehouse.WarehouseSupplierInvoice;
-
 
43
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
41
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
44
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
42
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
45
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
43
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
46
import com.spice.profitmandi.dao.enumuration.dtr.RefferalStatus;
44
import com.spice.profitmandi.dao.enumuration.dtr.RefferalStatus;
47
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
45
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
Line 51... Line 49...
51
import com.spice.profitmandi.dao.enumuration.inventory.VendorCatalogPricingStatus;
49
import com.spice.profitmandi.dao.enumuration.inventory.VendorCatalogPricingStatus;
52
import com.spice.profitmandi.dao.enumuration.transaction.CreditRisk;
50
import com.spice.profitmandi.dao.enumuration.transaction.CreditRisk;
53
import com.spice.profitmandi.dao.enumuration.transaction.LoanReferenceType;
51
import com.spice.profitmandi.dao.enumuration.transaction.LoanReferenceType;
54
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
52
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
55
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
53
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
56
import com.spice.profitmandi.dao.enumuration.warehouse.WarehouseInvoiceStatus;
-
 
57
import com.spice.profitmandi.dao.model.*;
54
import com.spice.profitmandi.dao.model.*;
58
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
55
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
59
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
56
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
60
import com.spice.profitmandi.dao.repository.catalog.*;
57
import com.spice.profitmandi.dao.repository.catalog.*;
61
import com.spice.profitmandi.dao.repository.cs.*;
58
import com.spice.profitmandi.dao.repository.cs.*;
Line 69... Line 66...
69
import com.spice.profitmandi.dao.service.solr.FofoSolr;
66
import com.spice.profitmandi.dao.service.solr.FofoSolr;
70
import com.spice.profitmandi.service.*;
67
import com.spice.profitmandi.service.*;
71
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
68
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
72
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
69
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
73
import com.spice.profitmandi.service.integrations.bharti.model.BAGInsuranceModel;
70
import com.spice.profitmandi.service.integrations.bharti.model.BAGInsuranceModel;
74
import com.spice.profitmandi.service.integrations.bharti.model.Sample;
-
 
75
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
71
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
76
import com.spice.profitmandi.service.inventory.*;
72
import com.spice.profitmandi.service.inventory.*;
77
import com.spice.profitmandi.service.offers.OfferService;
73
import com.spice.profitmandi.service.offers.OfferService;
78
import com.spice.profitmandi.service.order.OrderService;
74
import com.spice.profitmandi.service.order.OrderService;
79
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
-
 
80
import com.spice.profitmandi.service.pricing.PriceDropService;
75
import com.spice.profitmandi.service.pricing.PriceDropService;
81
import com.spice.profitmandi.service.recharge.provider.OxigenRechargeProviderService;
76
import com.spice.profitmandi.service.recharge.provider.OxigenRechargeProviderService;
82
import com.spice.profitmandi.service.recharge.provider.ThinkWalnutDigitalRechargeProviderService;
77
import com.spice.profitmandi.service.recharge.provider.ThinkWalnutDigitalRechargeProviderService;
83
import com.spice.profitmandi.service.scheme.SchemeService;
78
import com.spice.profitmandi.service.scheme.SchemeService;
84
import com.spice.profitmandi.service.serviceConfig.ServiceConfigService;
79
import com.spice.profitmandi.service.serviceConfig.ServiceConfigService;
Line 90... Line 85...
90
import com.spice.profitmandi.service.wallet.WalletService;
85
import com.spice.profitmandi.service.wallet.WalletService;
91
import com.spice.profitmandi.service.warehouse.PurchaseOrderService;
86
import com.spice.profitmandi.service.warehouse.PurchaseOrderService;
92
import com.spice.profitmandi.service.warehouse.WarehouseInventoryService;
87
import com.spice.profitmandi.service.warehouse.WarehouseInventoryService;
93
import in.shop2020.model.v1.order.OrderStatus;
88
import in.shop2020.model.v1.order.OrderStatus;
94
import in.shop2020.model.v1.order.WalletReferenceType;
89
import in.shop2020.model.v1.order.WalletReferenceType;
95
import in.shop2020.payments.PaymentService;
-
 
96
import okhttp3.OkHttpClient;
90
import okhttp3.OkHttpClient;
97
import okhttp3.Request;
91
import okhttp3.Request;
98
import okhttp3.Response;
92
import okhttp3.Response;
99
import org.apache.commons.csv.CSVRecord;
-
 
100
import org.apache.commons.io.output.ByteArrayOutputStream;
93
import org.apache.commons.io.output.ByteArrayOutputStream;
101
import org.apache.commons.lang.StringUtils;
94
import org.apache.commons.lang.StringUtils;
102
import org.apache.http.client.methods.CloseableHttpResponse;
95
import org.apache.http.client.methods.CloseableHttpResponse;
103
import org.apache.http.client.methods.HttpPost;
96
import org.apache.http.client.methods.HttpPost;
104
import org.apache.http.conn.HttpHostConnectException;
97
import org.apache.http.conn.HttpHostConnectException;
105
import org.apache.http.entity.StringEntity;
98
import org.apache.http.entity.StringEntity;
106
import org.apache.http.impl.client.CloseableHttpClient;
99
import org.apache.http.impl.client.CloseableHttpClient;
107
import org.apache.http.impl.client.HttpClients;
100
import org.apache.http.impl.client.HttpClients;
108
import org.apache.logging.log4j.LogManager;
101
import org.apache.logging.log4j.LogManager;
109
import org.apache.logging.log4j.Logger;
102
import org.apache.logging.log4j.Logger;
110
import org.apache.poi.ss.usermodel.CellType;
-
 
111
import org.apache.poi.xssf.usermodel.XSSFCell;
-
 
112
import org.apache.poi.xssf.usermodel.XSSFRow;
-
 
113
import org.apache.poi.xssf.usermodel.XSSFSheet;
-
 
114
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-
 
115
import org.hibernate.Session;
103
import org.hibernate.Session;
116
import org.hibernate.SessionFactory;
104
import org.hibernate.SessionFactory;
117
import org.hibernate.query.NativeQuery;
105
import org.hibernate.query.NativeQuery;
118
import org.json.JSONArray;
106
import org.json.JSONArray;
119
import org.json.JSONObject;
107
import org.json.JSONObject;
Line 1013... Line 1001...
1013
    PurchaseReturnService purchaseReturnService;
1001
    PurchaseReturnService purchaseReturnService;
1014
 
1002
 
1015
    public void test() throws Exception {
1003
    public void test() throws Exception {
1016
        //Create return
1004
        //Create return
1017
        Map<Integer, Set<String>> fofoIdImeiReturnMap = new TreeMap<>();
1005
        Map<Integer, Set<String>> fofoIdImeiReturnMap = new TreeMap<>();
1018
        //fofoIdImeiReturnMap.put(167996137, new HashSet<>(Arrays.asList("357415663618188", "357415663627767", "866399066670844", "866399066672022", "866399066715284", "866399066718205", "866399066721126", "866399066725069", "869350065039538", "869350065061318", "869350065067596", "869350065068016", "869350065068974", "869350065086794", "869350065090317", "869350065094558", "869350065098435", "869350065136177", "869350065155391")));
1006
        fofoIdImeiReturnMap.put(167996137, new HashSet<>(Arrays.asList("357415663618188", "357415663627767", "866399066670844", "866399066672022", "866399066715284", "866399066718205", "866399066721126", "866399066725069", "869350065039538", "869350065061318", "869350065067596", "869350065068016", "869350065068974", "869350065086794", "869350065090317", "869350065094558", "869350065098435", "869350065136177", "869350065155391")));
1019
        /*fofoIdImeiReturnMap.put(175135227, new HashSet<>(Arrays.asList("356612600793998", "356612600803870", "359691642134905", "359691642145604", "862628060221475", "863879060089334", "864985065856988", "865210064246753", "865753067332328", "865753069773248", "866399065879826", "866399066626606", "866399066664540", "866399066734129", "866807068958710", "867158063179137", "868905064220974", "868905065216294", "869350065013970", "869350065182791")));
1007
        fofoIdImeiReturnMap.put(175135227, new HashSet<>(Arrays.asList("356612600793998", "356612600803870", "359691642134905", "359691642145604", "862628060221475", "863879060089334", "864985065856988", "865210064246753", "865753067332328", "865753069773248", "866399065879826", "866399066626606", "866399066664540", "866399066734129", "866807068958710", "867158063179137", "868905064220974", "868905065216294", "869350065013970", "869350065182791")));
1020
        fofoIdImeiReturnMap.put(175138823, new HashSet<>(Arrays.asList("861530062830587", "861530063587103", "861530063599348", "861679065410440", "864985066215804", "864985066876621", "865210065762170")));
1008
        fofoIdImeiReturnMap.put(175138823, new HashSet<>(Arrays.asList("861530062830587", "861530063587103", "861530063599348", "861679065410440", "864985066215804", "864985066876621", "865210065762170")));
1021
        fofoIdImeiReturnMap.put(175138863, new HashSet<>(Arrays.asList("356393508712964", "356393508722468", "356393508722823", "356393508723342", "356393508723383", "356393508724720", "356393508728820", "356393508744124", "356393508745527", "356393508747341", "356393508748760", "356393508759668", "356393508762829", "356393508775607", "356393508793485", "356393509343983", "356393509344924", "356393509345723", "356393509351200", "356393509352489", "356612600709275", "356612600709317", "356612600712238", "356612600713210", "356612600716791", "356612600719654", "356612600720215", "356612600720694", "356612600721353", "356612600721734", "356612600722690", "356612600722815", "356612600724753", "356612600725511", "356612600725792", "356612600726378", "356612600726899", "356612600727673", "356612600727996", "356612600730719", "356612600733291", "356612600733770", "356612600733952", "356612600737532", "356612600738217", "356612600738530", "356612600740395", "356612600747192", "356612600748778", "356612600749438", "356612600750154", "356612600752218", "356612600752739", "356612600756011", "356612600757738", "356612600758256", "356612600758470", "356612600758850", "356612600758876", "356612600761573", "356612600804555", "356612600812210", "356612600817938", "356612600824231", "356612600826178", "356612600827010", "356612600827135", "356612600827234", "356612600827713", "356612600829511", "356612600829974", "356612600830816", "356612600830873", "356612600831517", "356612600833158", "356612600834651", "356612600836094", "356612600837555", "356612600928594", "356612600930459", "356612600942892", "356612600959219", "356612600965877", "356612600966974", "356612600967378", "356612600969135", "356612600973194", "356612600974192", "356612600974739", "356612600975017", "356612600975553", "356612600977435", "356612600980751", "356612600980876", "356612600981411", "356612600981932", "356612600981973", "356612604433070", "356612604454373", "356612604455479", "356612604455750", "356612605269556", "356612605278318", "356612605280736", "356612605281130", "356612605286410", "356612605289455", "356612605289679", "356612605290438", "356612605290933", "356612605291394", "356612605292152", "356612605293697", "356612605294091", "356612605294455", "356612605294554", "356612605295254", "356612605296559", "356612605296575", "356612605296633", "356612605297110", "356612605710179", "356612605715095", "356612605716911", "356612605717919", "356612605718412", "356612605718495", "356612605718636", "356612605718651", "356612605718776", "356612605718818", "356612605718834", "356612605718859", "356612605718891", "356612605718917", "356612605718933", "356612605718990", "356612605719139", "356612605719212", "356612605719253", "356612605719410", "357014953177490", "357014953186731", "357014953187713", "357014953187754", "357014953188810", "357014953189099", "357014953189412", "357014953189917", "357014953190071", "357014953191392", "357014953191871", "357014953191897", "357014953191913", "357014953191970", "357014953192291", "357014953192556", "357014953193018", "357014953193091", "357014953193174", "357014953193356", "358382747351997", "358382747523579", "358382747523975", "358382747555217", "358382747557916", "358382747572691", "358382747573152", "358382747575231", "358382747575579", "358382747575652", "358382747576395", "358382747576510", "358382747576619", "358382747576692", "358382747576759", "358382747576791", "358382747576973", "358382747576999", "358382747577138", "358382747577377", "358382747577690", "358382747577856", "358382747578276", "358382747578292", "358382747584373", "358382747584514", "359197382621184", "359197382647106", "359197382647387", "359197382648427", "359197382648443")));
1009
        fofoIdImeiReturnMap.put(175138863, new HashSet<>(Arrays.asList("356393508712964", "356393508722468", "356393508722823", "356393508723342", "356393508723383", "356393508724720", "356393508728820", "356393508744124", "356393508745527", "356393508747341", "356393508748760", "356393508759668", "356393508762829", "356393508775607", "356393508793485", "356393509343983", "356393509344924", "356393509345723", "356393509351200", "356393509352489", "356612600709275", "356612600709317", "356612600712238", "356612600713210", "356612600716791", "356612600719654", "356612600720215", "356612600720694", "356612600721353", "356612600721734", "356612600722690", "356612600722815", "356612600724753", "356612600725511", "356612600725792", "356612600726378", "356612600726899", "356612600727673", "356612600727996", "356612600730719", "356612600733291", "356612600733770", "356612600733952", "356612600737532", "356612600738217", "356612600738530", "356612600740395", "356612600747192", "356612600748778", "356612600749438", "356612600750154", "356612600752218", "356612600752739", "356612600756011", "356612600757738", "356612600758256", "356612600758470", "356612600758850", "356612600758876", "356612600761573", "356612600804555", "356612600812210", "356612600817938", "356612600824231", "356612600826178", "356612600827010", "356612600827135", "356612600827234", "356612600827713", "356612600829511", "356612600829974", "356612600830816", "356612600830873", "356612600831517", "356612600833158", "356612600834651", "356612600836094", "356612600837555", "356612600928594", "356612600930459", "356612600942892", "356612600959219", "356612600965877", "356612600966974", "356612600967378", "356612600969135", "356612600973194", "356612600974192", "356612600974739", "356612600975017", "356612600975553", "356612600977435", "356612600980751", "356612600980876", "356612600981411", "356612600981932", "356612600981973", "356612604433070", "356612604454373", "356612604455479", "356612604455750", "356612605269556", "356612605278318", "356612605280736", "356612605281130", "356612605286410", "356612605289455", "356612605289679", "356612605290438", "356612605290933", "356612605291394", "356612605292152", "356612605293697", "356612605294091", "356612605294455", "356612605294554", "356612605295254", "356612605296559", "356612605296575", "356612605296633", "356612605297110", "356612605710179", "356612605715095", "356612605716911", "356612605717919", "356612605718412", "356612605718495", "356612605718636", "356612605718651", "356612605718776", "356612605718818", "356612605718834", "356612605718859", "356612605718891", "356612605718917", "356612605718933", "356612605718990", "356612605719139", "356612605719212", "356612605719253", "356612605719410", "357014953177490", "357014953186731", "357014953187713", "357014953187754", "357014953188810", "357014953189099", "357014953189412", "357014953189917", "357014953190071", "357014953191392", "357014953191871", "357014953191897", "357014953191913", "357014953191970", "357014953192291", "357014953192556", "357014953193018", "357014953193091", "357014953193174", "357014953193356", "358382747351997", "358382747523579", "358382747523975", "358382747555217", "358382747557916", "358382747572691", "358382747573152", "358382747575231", "358382747575579", "358382747575652", "358382747576395", "358382747576510", "358382747576619", "358382747576692", "358382747576759", "358382747576791", "358382747576973", "358382747576999", "358382747577138", "358382747577377", "358382747577690", "358382747577856", "358382747578276", "358382747578292", "358382747584373", "358382747584514", "359197382621184", "359197382647106", "359197382647387", "359197382648427", "359197382648443")));
1022
        fofoIdImeiReturnMap.put(175138870, new HashSet<>(Arrays.asList("350923627169328", "350923627198863", "350923627875049", "351336673336049", "351336673340546", "355724848495830", "355724848499154", "356455410153452", "356455410159277", "356612605719956", "356612605720194", "359508181975748", "359508182024801", "359691642145406", "861831062564667", "861831062599507", "861831062599762", "865753069263646", "865753069651063", "865821064720405", "865821064760781", "865821065335666", "866399065697467", "866399065730789", "866399065732082", "869350061853536", "869350061926514", "869350062669832", "869350062681233", "869350062681373", "869350062684294")));
1010
        fofoIdImeiReturnMap.put(175138870, new HashSet<>(Arrays.asList("350923627169328", "350923627198863", "350923627875049", "351336673336049", "351336673340546", "355724848495830", "355724848499154", "356455410153452", "356455410159277", "356612605719956", "356612605720194", "359508181975748", "359508182024801", "359691642145406", "861831062564667", "861831062599507", "861831062599762", "865753069263646", "865753069651063", "865821064720405", "865821064760781", "865821065335666", "866399065697467", "866399065730789", "866399065732082", "869350061853536", "869350061926514", "869350062669832", "869350062681233", "869350062681373", "869350062684294")));
1023
        fofoIdImeiReturnMap.put(175138942, new HashSet<>(Arrays.asList("350031479190473", "350250293972177", "350250293974942", "353140544973073", "353397823400224", "353397824106911", "353397824214244", "359118661998473")));
1011
        fofoIdImeiReturnMap.put(175138942, new HashSet<>(Arrays.asList("350031479190473", "350250293972177", "350250293974942", "353140544973073", "353397823400224", "353397824106911", "353397824214244", "359118661998473")));
1024
        fofoIdImeiReturnMap.put(175139107, new HashSet<>(Arrays.asList("351733712184093", "351733712368928", "353140545077080", "353140545590280")));
1012
        fofoIdImeiReturnMap.put(175139107, new HashSet<>(Arrays.asList("351733712184093", "351733712368928", "353140545077080", "353140545590280")));
1025
        fofoIdImeiReturnMap.put(175139176, new HashSet<>(Arrays.asList("359691642003241", "359691642003506", "359691642010907", "359691642019742", "359691642061785", "359691642068624", "359691642076148", "359691642083284", "359691642115706", "359691642115888", "359691642134921", "359691642137346", "359691642137882", "359691642138443", "359691642141561", "359691642141660", "359691642141868", "359691642142288", "359691642144508", "359691642144904", "359691642146545", "359691642147725", "359691642151404", "359691642151727", "359691642152808", "359691642179207", "359691642179629", "866807067510173", "866807067519232", "869296069014474", "869296069015158", "869296069020299", "869296069020596", "869296069021271")));
1013
        fofoIdImeiReturnMap.put(175139176, new HashSet<>(Arrays.asList("359691642003241", "359691642003506", "359691642010907", "359691642019742", "359691642061785", "359691642068624", "359691642076148", "359691642083284", "359691642115706", "359691642115888", "359691642134921", "359691642137346", "359691642137882", "359691642138443", "359691642141561", "359691642141660", "359691642141868", "359691642142288", "359691642144508", "359691642144904", "359691642146545", "359691642147725", "359691642151404", "359691642151727", "359691642152808", "359691642179207", "359691642179629", "866807067510173", "866807067519232", "869296069014474", "869296069015158", "869296069020299", "869296069020596", "869296069021271")));
1026
        fofoIdImeiReturnMap.put(175139180, new HashSet<>(Arrays.asList("865279060303819", "865279060948159", "866399065674821", "866399065696840", "866399065701541", "866559062503097", "866807064663835", "866807064664536", "866807064664577", "866807064683379", "866807065123896", "869236065764458", "869236065883670")));
1014
        fofoIdImeiReturnMap.put(175139180, new HashSet<>(Arrays.asList("865279060303819", "865279060948159", "866399065674821", "866399065696840", "866399065701541", "866559062503097", "866807064663835", "866807064664536", "866807064664577", "866807064683379", "866807065123896", "869236065764458", "869236065883670")));
1027
        fofoIdImeiReturnMap.put(175139187, new HashSet<>(Arrays.asList("351166973169331", "351166973171592", "356393509346663", "356393509355805", "356612604544991", "356612604545691", "357014954899233", "357014954901153", "357014954934873", "357014954935672", "357014954937231", "357014954937678", "357014954938890", "359197382629682", "359197382647866", "359197382647882", "359691642142205", "862628068228175", "863879068173957", "864985065825629", "866399066067009", "866399066075705", "866641067104095", "867158061549711", "867492061861176")));*/
1015
        fofoIdImeiReturnMap.put(175139187, new HashSet<>(Arrays.asList("351166973169331", "351166973171592", "356393509346663", "356393509355805", "356612604544991", "356612604545691", "357014954899233", "357014954901153", "357014954934873", "357014954935672", "357014954937231", "357014954937678", "357014954938890", "359197382629682", "359197382647866", "359197382647882", "359691642142205", "862628068228175", "863879068173957", "864985065825629", "866399066067009", "866399066075705", "866641067104095", "867158061549711", "867492061861176")));
1028
        //fofoIdImeiReturnMap.put(175139223, new HashSet<>(Arrays.asList("350250293971054", "353140545612282", "863879062572436", "864920063982718", "864987060011015")));
1016
        fofoIdImeiReturnMap.put(175139223, new HashSet<>(Arrays.asList("350250293971054", "353140545612282", "863879062572436", "864920063982718", "864987060011015")));
1029
        /*fofoIdImeiReturnMap.put(175139242, new HashSet<>(Arrays.asList("862628066855359", "862628068472815", "863879060436170", "863879061140474", "864690068767337", "864920067190219")));
1017
        fofoIdImeiReturnMap.put(175139242, new HashSet<>(Arrays.asList("862628066855359", "862628068472815", "863879060436170", "863879061140474", "864690068767337", "864920067190219")));
1030
        fofoIdImeiReturnMap.put(175139261, new HashSet<>(Arrays.asList("865037063916197", "865037063921239", "866807066673311")));
1018
        fofoIdImeiReturnMap.put(175139261, new HashSet<>(Arrays.asList("865037063916197", "865037063921239", "866807066673311")));
1031
        fofoIdImeiReturnMap.put(175139295, new HashSet<>(Arrays.asList("353305256516622", "353305256517703", "354849877296808", "354849877299240", "359691642157203", "359691642159746", "359691642167608", "860374069783197", "861530062947282", "864985066061448", "866399062765986", "866399065001280", "866399066743625", "866726066870570", "866807064443717", "866807064654396")));
1019
        fofoIdImeiReturnMap.put(175139295, new HashSet<>(Arrays.asList("353305256516622", "353305256517703", "354849877296808", "354849877299240", "359691642157203", "359691642159746", "359691642167608", "860374069783197", "861530062947282", "864985066061448", "866399062765986", "866399065001280", "866399066743625", "866726066870570", "866807064443717", "866807064654396")));
1032
        fofoIdImeiReturnMap.put(175139328, new HashSet<>(Arrays.asList("861784060313035", "862628068090153", "862628068262117", "863879062228856", "863879062320554", "864985062056681", "864985062215402", "865210064597296", "865210065180431", "866132066506233")));
1020
        fofoIdImeiReturnMap.put(175139328, new HashSet<>(Arrays.asList("861784060313035", "862628068090153", "862628068262117", "863879062228856", "863879062320554", "864985062056681", "864985062215402", "865210064597296", "865210065180431", "866132066506233")));
1033
        fofoIdImeiReturnMap.put(175139329, new HashSet<>(Arrays.asList("351733714004521", "359118663635321", "865279064602331", "866399062751085", "866399062758882")));
1021
        fofoIdImeiReturnMap.put(175139329, new HashSet<>(Arrays.asList("351733714004521", "359118663635321", "865279064602331", "866399062751085", "866399062758882")));
1034
        fofoIdImeiReturnMap.put(175139333, new HashSet<>(Arrays.asList("864985062090243", "864985065791169", "864985065840040", "864985065844984", "866399065642240", "866399066060848", "866399066707505", "866399066753624", "869350061832191", "869350061851415", "869350062255178", "869350062608657")));
1022
        fofoIdImeiReturnMap.put(175139333, new HashSet<>(Arrays.asList("864985062090243", "864985065791169", "864985065840040", "864985065844984", "866399065642240", "866399066060848", "866399066707505", "866399066753624", "869350061832191", "869350061851415", "869350062255178", "869350062608657")));
1035
        fofoIdImeiReturnMap.put(175139364, new HashSet<>(Arrays.asList("353305256533601", "353305256536968", "359691642106465", "359691642139300", "359749531615929", "862628066855631", "863653060019751", "863653060270255", "863879060439919", "865279066559992", "865821063929064", "865821064323424", "866807065289937", "867158060809637", "868666068787083", "868905064544076")));
1023
        fofoIdImeiReturnMap.put(175139364, new HashSet<>(Arrays.asList("353305256533601", "353305256536968", "359691642106465", "359691642139300", "359749531615929", "862628066855631", "863653060019751", "863653060270255", "863879060439919", "865279066559992", "865821063929064", "865821064323424", "866807065289937", "867158060809637", "868666068787083", "868905064544076")));
1036
        fofoIdImeiReturnMap.put(175139372, new HashSet<>(Arrays.asList("351166972285419", "351166975524178", "351166976059059", "351166976064158", "351166976067094", "357014952943934", "357014952944353", "357014952945574", "357014952949154", "357014952949196", "357014952950657", "357014952951937", "357014952952950", "357014952953214", "357014952953750", "357014952953990", "357014952954550", "357014953188570", "357014953189578", "357014953190576", "357014953191152", "357014953191236", "357014953192572", "357014953192796", "357014953193836", "864985061925787", "864985061993587")));
1024
        fofoIdImeiReturnMap.put(175139372, new HashSet<>(Arrays.asList("351166972285419", "351166975524178", "351166976059059", "351166976064158", "351166976067094", "357014952943934", "357014952944353", "357014952945574", "357014952949154", "357014952949196", "357014952950657", "357014952951937", "357014952952950", "357014952953214", "357014952953750", "357014952953990", "357014952954550", "357014953188570", "357014953189578", "357014953190576", "357014953191152", "357014953191236", "357014953192572", "357014953192796", "357014953193836", "864985061925787", "864985061993587")));
1037
        fofoIdImeiReturnMap.put(175139386, new HashSet<>(Arrays.asList("350250292546261", "350250293896210", "350386305533381", "352450543770565", "353397822543180", "357014953173978", "359749531155942", "863879068182354", "865037067599551", "867492060235059", "869350061949755")));
1025
        fofoIdImeiReturnMap.put(175139386, new HashSet<>(Arrays.asList("350250292546261", "350250293896210", "350386305533381", "352450543770565", "353397822543180", "357014953173978", "359749531155942", "863879068182354", "865037067599551", "867492060235059", "869350061949755")));
1038
        fofoIdImeiReturnMap.put(175139390, new HashSet<>(Arrays.asList("350339951003118", "352450548485607", "353397824198728", "353397824258225", "354849877087843", "354849877105843", "354849877151664", "354849877296162", "860607069060599", "863879062659092", "864848067855947", "865037065956555", "865865062255872", "866807066486896", "866807068958298", "868701069311433", "868905064220750", "869076064654809", "869350062196075", "869350062666473")));
1026
        fofoIdImeiReturnMap.put(175139390, new HashSet<>(Arrays.asList("350339951003118", "352450548485607", "353397824198728", "353397824258225", "354849877087843", "354849877105843", "354849877151664", "354849877296162", "860607069060599", "863879062659092", "864848067855947", "865037065956555", "865865062255872", "866807066486896", "866807068958298", "868701069311433", "868905064220750", "869076064654809", "869350062196075", "869350062666473")));
1039
        fofoIdImeiReturnMap.put(175139392, new HashSet<>(Arrays.asList("354301731104828", "354301731181784", "860398069424833", "861784061894090", "864480066119602", "864480066130047", "866399065988924", "866399066060061", "866807064683999", "867158060809975", "867492060235752")));
1027
        fofoIdImeiReturnMap.put(175139392, new HashSet<>(Arrays.asList("354301731104828", "354301731181784", "860398069424833", "861784061894090", "864480066119602", "864480066130047", "866399065988924", "866399066060061", "866807064683999", "867158060809975", "867492060235752")));
1040
        fofoIdImeiReturnMap.put(175139396, new HashSet<>(Arrays.asList("350339951029758", "864848067933108", "864848067965860", "865279060304411", "865753067321909", "865753068700747", "866399066669069", "866399066721365", "869076064651763", "869350061904495", "869350062192991")));*/
1028
        fofoIdImeiReturnMap.put(175139396, new HashSet<>(Arrays.asList("350339951029758", "864848067933108", "864848067965860", "865279060304411", "865753067321909", "865753068700747", "866399066669069", "866399066721365", "869076064651763", "869350061904495", "869350062192991")));
1041
        //fofoIdImeiReturnMap.put(175139404, new HashSet<>(Arrays.asList("352450544013585", "352450544013940", "352450544014344", "352450547322587", "352450547322744", "358142883505941", "359749531269867", "868905065214570")));
1029
        fofoIdImeiReturnMap.put(175139404, new HashSet<>(Arrays.asList("352450544013585", "352450544013940", "352450544014344", "352450547322587", "352450547322744", "358142883505941", "359749531269867", "868905065214570")));
1042
        //fofoIdImeiReturnMap.put(175139410, new HashSet<>(Arrays.asList("350923626587702", "350923626677503", "350923626689383", "350923627241283", "350923627259541", "351336673333228", "351336673334580", "351336673344449", "352450544501886", "352450545460561", "352450545826068", "353305256494044", "353305256519709", "356393509343744", "356393509347224", "357983840349969", "357983840350322", "357983840350546", "357983840351486", "357983840352344", "357983840352823", "357983840352864", "357983840353144", "357983840357582", "357983840359067", "359691642108461", "359691642174968", "863653061135671", "863653061177012", "863653062654993", "863653062669439", "864288064103175", "864985065813260", "865279063733434", "865753069777728", "866399065698101", "866399065717323", "866399065719949", "866399065726944")));
1030
        fofoIdImeiReturnMap.put(175139410, new HashSet<>(Arrays.asList("350923626587702", "350923626677503", "350923626689383", "350923627241283", "350923627259541", "351336673333228", "351336673334580", "351336673344449", "352450544501886", "352450545460561", "352450545826068", "353305256494044", "353305256519709", "356393509343744", "356393509347224", "357983840349969", "357983840350322", "357983840350546", "357983840351486", "357983840352344", "357983840352823", "357983840352864", "357983840353144", "357983840357582", "357983840359067", "359691642108461", "359691642174968", "863653061135671", "863653061177012", "863653062654993", "863653062669439", "864288064103175", "864985065813260", "865279063733434", "865753069777728", "866399065698101", "866399065717323", "866399065719949", "866399065726944")));
1043
        fofoIdImeiReturnMap.put(175139421, new HashSet<>(Arrays.asList("862628067316096", "864920065652657", "864920067190839", "866399065078304", "866399065720244", "866807066673139", "866807068288472")));
1031
        ///fofoIdImeiReturnMap.put(175139421, new HashSet<>(Arrays.asList("862628067316096", "864920065652657", "864920067190839", "866399065078304", "866399065720244", "866807066673139", "866807068288472")));
1044
        /*fofoIdImeiReturnMap.put(175139422, new HashSet<>(Arrays.asList("351166975963533", "351166975976295", "354849877717662", "354849877719742", "354849877726705", "354849877729444", "354849877729642", "354849877730046", "354849877730665", "354849877731903", "354849877734063", "354849877743221", "355724848410193", "355724848412058", "355724848423378", "355724848425316", "355724848425357", "355724848426454", "355724848426595", "355724848426736", "355724848426777", "355724848428617", "356393508695383", "356393508713046", "356393508722385", "356393508722542", "356393508727806", "356393508733424", "356393508736880", "356393508737680", "356393508738902", "356393508768206", "356393508768560", "356393508773263", "356393508796926", "356612600716692", "356612600735577", "356612600736195", "356612600736997", "356612600740155", "356612600742854", "356612600743613", "356612600746616", "356612600747051", "356612600748455", "356612600926655", "356612600928131", "356612600928230", "356612600929675", "356612600934873", "356612600936019", "356612600943858", "356612600945135", "356612600947453", "356612600949996", "356612600951455", "356612600951810", "356612600953758", "356612600956934", "356612600962254", "356612600963393", "356612600963419", "356612600981551", "356612600983375", "356612600983912", "359691642043445", "359691642047909", "359691642049368", "359691642051380", "359691642089901", "359691642114766", "359691642135084", "359691642135241", "359691642141223", "359691642144565", "359691642145109", "359691642152600", "359691642153160", "359691642155645", "359691642156841", "861530062172105", "861530062174382", "864985065768787", "864985065792944", "866807064663710")));
1032
        fofoIdImeiReturnMap.put(175139422, new HashSet<>(Arrays.asList("351166975963533", "351166975976295", "354849877717662", "354849877719742", "354849877726705", "354849877729444", "354849877729642", "354849877730046", "354849877730665", "354849877731903", "354849877734063", "354849877743221", "355724848410193", "355724848412058", "355724848423378", "355724848425316", "355724848425357", "355724848426454", "355724848426595", "355724848426736", "355724848426777", "355724848428617", "356393508695383", "356393508713046", "356393508722385", "356393508722542", "356393508727806", "356393508733424", "356393508736880", "356393508737680", "356393508738902", "356393508768206", "356393508768560", "356393508773263", "356393508796926", "356612600716692", "356612600735577", "356612600736195", "356612600736997", "356612600740155", "356612600742854", "356612600743613", "356612600746616", "356612600747051", "356612600748455", "356612600926655", "356612600928131", "356612600928230", "356612600929675", "356612600934873", "356612600936019", "356612600943858", "356612600945135", "356612600947453", "356612600949996", "356612600951455", "356612600951810", "356612600953758", "356612600956934", "356612600962254", "356612600963393", "356612600963419", "356612600981551", "356612600983375", "356612600983912", "359691642043445", "359691642047909", "359691642049368", "359691642051380", "359691642089901", "359691642114766", "359691642135084", "359691642135241", "359691642141223", "359691642144565", "359691642145109", "359691642152600", "359691642153160", "359691642155645", "359691642156841", "861530062172105", "861530062174382", "864985065768787", "864985065792944", "866807064663710")));
1045
        fofoIdImeiReturnMap.put(175139425, new HashSet<>(Arrays.asList("350386305671629", "350386306043125", "863653060563873", "863653060564970", "865037065022895", "865037065094795", "868905065657356", "868905066089856")));
1033
        fofoIdImeiReturnMap.put(175139425, new HashSet<>(Arrays.asList("350386305671629", "350386306043125", "863653060563873", "863653060564970", "865037065022895", "865037065094795", "868905065657356", "868905066089856")));
1046
        fofoIdImeiReturnMap.put(175139426, new HashSet<>(Arrays.asList("359197382598762", "359197382619329", "359197382623701", "359197382629302", "359197382630680", "359197382637305", "359197382641943", "359197382645480", "359197382647304", "359197382647528", "860374069742052", "861530063115582", "862628068090534", "862628068266092", "863653061146876", "863653061150217", "866807064452577", "867158060215595")));
1034
        fofoIdImeiReturnMap.put(175139426, new HashSet<>(Arrays.asList("359197382598762", "359197382619329", "359197382623701", "359197382629302", "359197382630680", "359197382637305", "359197382641943", "359197382645480", "359197382647304", "359197382647528", "860374069742052", "861530063115582", "862628068090534", "862628068266092", "863653061146876", "863653061150217", "866807064452577", "867158060215595")));
1047
        fofoIdImeiReturnMap.put(175139429, new HashSet<>(Arrays.asList("352094722900948", "352094722908982", "353305256468261", "353305256536604", "355724848504375", "356612605716879", "358382747569358", "358382747580439", "359197382650704", "359197382651967", "359691642166485", "359691642172160", "861530063122463", "864848067843141", "864848067935947", "864985066066827", "866132060383811", "866399062773725", "866399065623760", "868666065635608", "868666065730581", "868666067425545", "868666067819143")));
1035
        fofoIdImeiReturnMap.put(175139429, new HashSet<>(Arrays.asList("352094722900948", "352094722908982", "353305256468261", "353305256536604", "355724848504375", "356612605716879", "358382747569358", "358382747580439", "359197382650704", "359197382651967", "359691642166485", "359691642172160", "861530063122463", "864848067843141", "864848067935947", "864985066066827", "866132060383811", "866399062773725", "866399065623760", "868666065635608", "868666065730581", "868666067425545", "868666067819143")));
1048
        fofoIdImeiReturnMap.put(175139505, new HashSet<>(Arrays.asList("352450547876988", "353305256493285", "354301731180687", "862628066338018", "863653064984612", "865037066073772", "865210064252231", "865210064255556", "865279066156054", "866399065988643", "867158063267031", "867492063304399", "869076064640725", "869236066123035")));
1036
        fofoIdImeiReturnMap.put(175139505, new HashSet<>(Arrays.asList("352450547876988", "353305256493285", "354301731180687", "862628066338018", "863653064984612", "865037066073772", "865210064252231", "865210064255556", "865279066156054", "866399065988643", "867158063267031", "867492063304399", "869076064640725", "869236066123035")));
1049
        fofoIdImeiReturnMap.put(175139431, new HashSet<>(Arrays.asList("860374069332672", "862892060190615", "863879063992419", "864985061894884", "865210064232472", "865753069696365", "865821063930708", "865821064719324", "865821065112404", "866807067509712", "867212063822897", "867212068439556", "868701069306573")));
1037
        fofoIdImeiReturnMap.put(175139431, new HashSet<>(Arrays.asList("860374069332672", "862892060190615", "863879063992419", "864985061894884", "865210064232472", "865753069696365", "865821063930708", "865821064719324", "865821065112404", "866807067509712", "867212063822897", "867212068439556", "868701069306573")));
Line 1062... Line 1050...
1062
        fofoIdImeiReturnMap.put(175139472, new HashSet<>(Arrays.asList("351613386632884", "351613386906387", "357415663628286", "860374069457230", "863879063994217", "863879063996659", "864848068065868", "865037066313699", "866399066697367", "866807064662399", "867212067916190", "867212068443236", "868905065660756", "869236068140771", "869350062605497")));
1050
        fofoIdImeiReturnMap.put(175139472, new HashSet<>(Arrays.asList("351613386632884", "351613386906387", "357415663628286", "860374069457230", "863879063994217", "863879063996659", "864848068065868", "865037066313699", "866399066697367", "866807064662399", "867212067916190", "867212068443236", "868905065660756", "869236068140771", "869350062605497")));
1063
        fofoIdImeiReturnMap.put(175139477, new HashSet<>(Arrays.asList("861663068335796", "861663069050774", "861663069051590", "863879061279330", "863879062320612", "864288064231455", "864647061805472", "866807063530852", "866807063565775", "867212063825619", "867212068442154")));
1051
        fofoIdImeiReturnMap.put(175139477, new HashSet<>(Arrays.asList("861663068335796", "861663069050774", "861663069051590", "863879061279330", "863879062320612", "864288064231455", "864647061805472", "866807063530852", "866807063565775", "867212063825619", "867212068442154")));
1064
        fofoIdImeiReturnMap.put(175139489, new HashSet<>(Arrays.asList("350031476683801", "350031477646419", "863653067155012", "865037065748796", "865037068846316", "865210063382351", "865279065239570", "866399066070789", "866559062481237", "866641067273452", "867492061243532", "868652062503601", "868666065959727", "868666067777804", "868701062941111", "868701069479172")));
1052
        fofoIdImeiReturnMap.put(175139489, new HashSet<>(Arrays.asList("350031476683801", "350031477646419", "863653067155012", "865037065748796", "865037068846316", "865210063382351", "865279065239570", "866399066070789", "866559062481237", "866641067273452", "867492061243532", "868652062503601", "868666065959727", "868666067777804", "868701062941111", "868701069479172")));
1065
        fofoIdImeiReturnMap.put(175139490, new HashSet<>(Arrays.asList("350031477636618", "351733715724002", "352120260187174", "352953554051643", "355724848426439", "357014954930939", "863653061893972", "865821060228742", "866399066062984", "866399066069989", "868652062617484", "868666065958901", "868905064290456", "868905064825012", "869076064649502")));
1053
        fofoIdImeiReturnMap.put(175139490, new HashSet<>(Arrays.asList("350031477636618", "351733715724002", "352120260187174", "352953554051643", "355724848426439", "357014954930939", "863653061893972", "865821060228742", "866399066062984", "866399066069989", "868652062617484", "868666065958901", "868905064290456", "868905064825012", "869076064649502")));
1066
        fofoIdImeiReturnMap.put(175139493, new HashSet<>(Arrays.asList("350250294029969", "350250294131203", "350339951594819", "351733715279890", "351733715611290", "356612605730052", "358382747584456", "358382747584910", "860695063377770", "862628066338554", "862628067568811", "863879066397897", "864920064911971", "868701063410017", "868701067287973")));
1054
        fofoIdImeiReturnMap.put(175139493, new HashSet<>(Arrays.asList("350250294029969", "350250294131203", "350339951594819", "351733715279890", "351733715611290", "356612605730052", "358382747584456", "358382747584910", "860695063377770", "862628066338554", "862628067568811", "863879066397897", "864920064911971", "868701063410017", "868701067287973")));
1067
        fofoIdImeiReturnMap.put(175139496, new HashSet<>(Arrays.asList("350386305879537", "860695063378810", "863879062651750", "864920069103590", "865037066073517", "865210064600017", "865279067176432", "865865062952171", "866807068662916", "866807069402130", "867158063179178", "867492063171996", "868905065232135")));*/
1055
        fofoIdImeiReturnMap.put(175139496, new HashSet<>(Arrays.asList("350386305879537", "860695063378810", "863879062651750", "864920069103590", "865037066073517", "865210064600017", "865279067176432", "865865062952171", "866807068662916", "866807069402130", "867158063179178", "867492063171996", "868905065232135")));
1068
 
1056
 
1069
        System.out.println(fofoIdImeiReturnMap.entrySet().stream().flatMap(x->x.getValue().stream()).collect(Collectors.toList()).size());
1057
        System.out.println(fofoIdImeiReturnMap.entrySet().stream().flatMap(x -> x.getValue().stream()).collect(Collectors.toList()).size());
-
 
1058
 
-
 
1059
        List<String> serialNumbers = fofoIdImeiReturnMap.entrySet().stream().flatMap(x -> x.getValue().stream()).collect(Collectors.toList());
-
 
1060
        List<WarehouseInventoryItem> warehouseInventoryItems = warehouseInventoryItemRepository.selectWarehouseInventoryItemBySerailNumbers(serialNumbers);
-
 
1061
        for (WarehouseInventoryItem warehouseInventoryItem : warehouseInventoryItems) {
-
 
1062
            if (warehouseInventoryItem.getCurrentQuantity() - warehouseInventoryItem.getInitialQuantity() > 0) {
-
 
1063
                int diff = warehouseInventoryItem.getCurrentQuantity() - warehouseInventoryItem.getInitialQuantity();
-
 
1064
                System.out.println(warehouseInventoryItem.getId() + " --- " + diff);
-
 
1065
                List<WarehouseScan> warehouseScans = warehouseScanRepository.selectAllByInventoryItemIds(Arrays.asList(warehouseInventoryItem.getId()));
-
 
1066
                WarehouseScan previousSaleScan = warehouseScans.stream().filter(x->x.getType().equals(in.shop2020.warehouse.ScanType.SALE)).sorted(Comparator.comparingInt(WarehouseScan::getOrderId).reversed()).skip(1).findFirst().get();
-
 
1067
                List<WarehouseScan> scansToDelete = warehouseScans.stream().filter(x -> x.getType().equals(in.shop2020.warehouse.ScanType.SALE_RET) && x.getSupplierWarehouseId()==0).skip(1).collect(Collectors.toList());
-
 
1068
                if(scansToDelete.size() > 0) {
-
 
1069
                    WarehouseScan warehouseScan = warehouseScans.stream().filter(x -> x.getType().equals(in.shop2020.warehouse.ScanType.SALE_RET)).findFirst().get();
-
 
1070
                    warehouseScan.setSupplierWarehouseId(warehouseInventoryItem.getCurrentWarehouseId());
-
 
1071
                    warehouseScan.setOrderId(previousSaleScan.getOrderId());
-
 
1072
                    System.out.println(scansToDelete.toString());
-
 
1073
                    for (WarehouseScan scan : scansToDelete) {
-
 
1074
                        warehouseScanRepository.delete(scan);
-
 
1075
                    }
-
 
1076
                    warehouseInventoryService.addQuantity(warehouseInventoryItem.getId(), -diff);
1070
        //return;
1077
                }
-
 
1078
            }
-
 
1079
        }
-
 
1080
 
1071
        for (Entry<Integer, Set<String>> fofoIdImeiReturnEntry : fofoIdImeiReturnMap.entrySet()) {
1081
        /*for (Entry<Integer, Set<String>> fofoIdImeiReturnEntry : fofoIdImeiReturnMap.entrySet()) {
1072
            int fofoId = fofoIdImeiReturnEntry.getKey();
1082
            int fofoId = fofoIdImeiReturnEntry.getKey();
1073
            Set<String> imeis = fofoIdImeiReturnEntry.getValue();
1083
            Set<String> imeis = fofoIdImeiReturnEntry.getValue();
1074
            List<InventoryItem> inventoryItems = inventoryItemRepository.selectByFofoIdSerialNumbers(fofoId, imeis, true);
1084
            List<InventoryItem> inventoryItems = inventoryItemRepository.selectByFofoIdSerialNumbers(fofoId, imeis, true);
1075
            for (InventoryItem inventoryItem : inventoryItems) {
1085
            for (InventoryItem inventoryItem : inventoryItems) {
1076
                //inventoryItem.getId();
1086
                //inventoryItem.getId();
Line 1094... Line 1104...
1094
                //Try to refund amount per debit note
1104
                //Try to refund amount per debit note
1095
                this.refundDnAmount(debitNote);
1105
                this.refundDnAmount(debitNote);
1096
            }
1106
            }
1097
 
1107
 
1098
            //List<DebitNotePdfModel> debitNotePdfModels = purchaseReturnService.generateDebitNotes(purchaseInventoryMap, warehouseId);
1108
            //List<DebitNotePdfModel> debitNotePdfModels = purchaseReturnService.generateDebitNotes(purchaseInventoryMap, warehouseId);
1099
        }
-
 
1100
 
-
 
1101
        //transactionService.billOrder(Arrays.asList(1800765), )
-
 
1102
        //purchaseMigration.migrateDebitNote();
-
 
1103
        //this.sendMailForSamsungRebilling();
-
 
1104
        /*List<PurchaseReturnItem> purchaseReturnItems = purchaseReturnItemRepository.selectPurchaseReturnByStatuses(Arrays.asList(PurchaseReturnStatus.DEBIT_NOTE_CREATED));
-
 
1105
        Map<Integer, List<PurchaseReturnItem>> inventoryItemsMap = purchaseReturnItems.stream().collect(Collectors.groupingBy(x -> x.getDebitNoteId()));
-
 
1106
        for (Map.Entry<Integer, List<PurchaseReturnItem>> debitNotePurcahseReturnMap : inventoryItemsMap.entrySet()) {
-
 
1107
            List<InventoryItem> inventoryItems = inventoryItemRepository.selectAllByIds(debitNotePurcahseReturnMap.getValue().stream().map(x -> x.getInventoryItemId()).collect(Collectors.toList()));
-
 
1108
            offerService.reverseAdditionalSelloutSchemes(debitNotePurcahseReturnMap.getValue().get(0).getFofoId(), inventoryItems);
-
 
1109
        }*/
1109
        }*/
1110
        //this.sendMailForAgeingAlert();
-
 
1111
        //this.sendMailForAgeingAlert();
-
 
1112
        //System.out.println(brandRegionMappingRepository.getAvailabilityToVendorWarehouse(Arrays.asList(33353), 7720));
-
 
1113
 
-
 
1114
    }
1110
    }
1115
 
1111
 
1116
    @Autowired
1112
    @Autowired
1117
    CartService cartService;
1113
    CartService cartService;
1118
    @Autowired
1114
    @Autowired
Line 1125... Line 1121...
1125
    WarehouseInventoryService warehouseInventoryService;
1121
    WarehouseInventoryService warehouseInventoryService;
1126
 
1122
 
1127
    @Autowired
1123
    @Autowired
1128
    CommonPaymentService commonPaymentService;
1124
    CommonPaymentService commonPaymentService;
1129
 
1125
 
-
 
1126
    @Autowired
-
 
1127
    LineItemImeisRepository lineItemImeisRepository;
-
 
1128
 
1130
    //Also create order
1129
    //Also create order
1131
    private void refundDnAmount(DebitNote debitNote) throws ProfitMandiBusinessException {
1130
    private void refundDnAmount(DebitNote debitNote, boolean createOrder) throws ProfitMandiBusinessException {
1132
        List<Integer> inventoryItemIds = purchaseReturnItemRepository.selectAllByDebitNoteId(debitNote.getId()).stream().map(x -> x.getInventoryItemId()).collect(Collectors.toList());
1131
        List<Integer> inventoryItemIds = purchaseReturnItemRepository.selectAllByDebitNoteId(debitNote.getId()).stream().map(x -> x.getInventoryItemId()).collect(Collectors.toList());
1133
        Map<Integer, Long> inventoryItemCountMap = inventoryItemIds.stream().collect(Collectors.groupingBy(x -> x, Collectors.counting()));
1132
        Map<Integer, Long> inventoryItemCountMap = inventoryItemIds.stream().collect(Collectors.groupingBy(x -> x, Collectors.counting()));
1134
        List<InventoryItem> inventoryItems = inventoryItemRepository.selectAllByIds(new ArrayList<>(inventoryItemCountMap.keySet()));
1133
        List<InventoryItem> inventoryItems = inventoryItemRepository.selectAllByIds(new ArrayList<>(inventoryItemCountMap.keySet()));
1135
        Purchase purchase = purchaseRepository.selectById(inventoryItems.get(0).getPurchaseId());
1134
        Purchase purchase = purchaseRepository.selectById(inventoryItems.get(0).getPurchaseId());
-
 
1135
        List<String> serialNumbers = inventoryItems.stream().map(x -> x.getSerialNumber()).collect(Collectors.toList());
1136
        String invoice = purchase.getPurchaseReference();
1136
        String invoice = purchase.getPurchaseReference();
1137
        List<Order> orders = orderRepository.selectByInvoiceNumber(invoice);
1137
        List<Order> orders = orderRepository.selectByInvoiceNumber(invoice);
-
 
1138
        List<Integer> lineItemIds = orders.stream().map(x -> x.getLineItem().getId()).collect(Collectors.toList());
-
 
1139
        List<LineItemImei> lineItemImeis = lineItemImeisRepository.selectByLineItemIdsSerialNumbers(lineItemIds, serialNumbers);
1138
        Set<Integer> orderIds = orders.stream().map(x -> x.getId()).collect(Collectors.toSet());
1140
        Set<Integer> orderIds = orders.stream().map(x -> x.getId()).collect(Collectors.toSet());
1139
        Order order = orders.get(0);
1141
        Order order = orders.get(0);
1140
        float totalAmount = 0;
1142
        float totalAmount = 0;
1141
        float walletTotalAmount = 0;
1143
        float walletTotalAmount = 0;
1142
        int totalQty = 0;
1144
        int totalQty = 0;