Subversion Repositories SmartDukaan

Rev

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

Rev 32537 Rev 32564
Line 1000... Line 1000...
1000
    @Autowired
1000
    @Autowired
1001
    PurchaseReturnService purchaseReturnService;
1001
    PurchaseReturnService purchaseReturnService;
1002
 
1002
 
1003
    public void test() throws Exception {
1003
    public void test() throws Exception {
1004
        //Create return
1004
        //Create return
1005
        Map<Integer, Set<String>> fofoIdImeiReturnMap = new TreeMap<>();
-
 
1006
        ///fofoIdImeiReturnMap.put(175139421, new HashSet<>(Arrays.asList("862628067316096", "864920065652657", "864920067190839", "866399065078304", "866399065720244", "866807066673139", "866807068288472")));
-
 
1007
        ///fofoIdImeiReturnMap.put(167996137, new HashSet<>(Arrays.asList("357415663618188")));
-
 
1008
        //fofoIdImeiReturnMap.put(167996137, new HashSet<>(Arrays.asList("357415663627767", "866399066670844", "866399066672022", "866399066715284", "866399066718205", "866399066721126", "866399066725069", "869350065039538", "869350065061318", "869350065067596", "869350065068016", "869350065068974", "869350065086794", "869350065090317", "869350065094558", "869350065098435", "869350065136177", "869350065155391")));
-
 
1009
        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")));
-
 
1010
        fofoIdImeiReturnMap.put(175138823, new HashSet<>(Arrays.asList("861530062830587", "861530063587103", "861530063599348", "861679065410440", "864985066215804", "864985066876621", "865210065762170")));
-
 
1011
        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")));
-
 
1012
        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")));
-
 
1013
        fofoIdImeiReturnMap.put(175138942, new HashSet<>(Arrays.asList("350031479190473", "350250293972177", "350250293974942", "353140544973073", "353397823400224", "353397824106911", "353397824214244", "359118661998473")));
-
 
1014
        fofoIdImeiReturnMap.put(175139107, new HashSet<>(Arrays.asList("351733712184093", "351733712368928", "353140545077080", "353140545590280")));
-
 
1015
        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")));
-
 
1016
        fofoIdImeiReturnMap.put(175139180, new HashSet<>(Arrays.asList("865279060303819", "865279060948159", "866399065674821", "866399065696840", "866399065701541", "866559062503097", "866807064663835", "866807064664536", "866807064664577", "866807064683379", "866807065123896", "869236065764458", "869236065883670")));
-
 
1017
        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")));
-
 
1018
        fofoIdImeiReturnMap.put(175139223, new HashSet<>(Arrays.asList("350250293971054", "353140545612282", "863879062572436", "864920063982718", "864987060011015")));
-
 
1019
        fofoIdImeiReturnMap.put(175139242, new HashSet<>(Arrays.asList("862628066855359", "862628068472815", "863879060436170", "863879061140474", "864690068767337", "864920067190219")));
-
 
1020
        fofoIdImeiReturnMap.put(175139261, new HashSet<>(Arrays.asList("865037063916197", "865037063921239", "866807066673311")));
-
 
1021
        fofoIdImeiReturnMap.put(175139295, new HashSet<>(Arrays.asList("353305256516622", "353305256517703", "354849877296808", "354849877299240", "359691642157203", "359691642159746", "359691642167608", "860374069783197", "861530062947282", "864985066061448", "866399062765986", "866399065001280", "866399066743625", "866726066870570", "866807064443717", "866807064654396")));
-
 
1022
        fofoIdImeiReturnMap.put(175139328, new HashSet<>(Arrays.asList("861784060313035", "862628068090153", "862628068262117", "863879062228856", "863879062320554", "864985062056681", "864985062215402", "865210064597296", "865210065180431", "866132066506233")));
1005
        creditNoteService.sendCnMails(YearMonth.now().minusMonths(1));
1023
        fofoIdImeiReturnMap.put(175139329, new HashSet<>(Arrays.asList("351733714004521", "359118663635321", "865279064602331", "866399062751085", "866399062758882")));
-
 
1024
        fofoIdImeiReturnMap.put(175139333, new HashSet<>(Arrays.asList("864985062090243", "864985065791169", "864985065840040", "864985065844984", "866399065642240", "866399066060848", "866399066707505", "866399066753624", "869350061832191", "869350061851415", "869350062255178", "869350062608657")));
-
 
1025
        fofoIdImeiReturnMap.put(175139364, new HashSet<>(Arrays.asList("353305256533601", "353305256536968", "359691642106465", "359691642139300", "359749531615929", "862628066855631", "863653060019751", "863653060270255", "863879060439919", "865279066559992", "865821063929064", "865821064323424", "866807065289937", "867158060809637", "868666068787083", "868905064544076")));
-
 
1026
        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")));
-
 
1027
        fofoIdImeiReturnMap.put(175139386, new HashSet<>(Arrays.asList("350250292546261", "350250293896210", "350386305533381", "352450543770565", "353397822543180", "357014953173978", "359749531155942", "863879068182354", "865037067599551", "867492060235059", "869350061949755")));
-
 
1028
        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")));
-
 
1029
        fofoIdImeiReturnMap.put(175139392, new HashSet<>(Arrays.asList("354301731104828", "354301731181784", "860398069424833", "861784061894090", "864480066119602", "864480066130047", "866399065988924", "866399066060061", "866807064683999", "867158060809975", "867492060235752")));
-
 
1030
        fofoIdImeiReturnMap.put(175139396, new HashSet<>(Arrays.asList("350339951029758", "864848067933108", "864848067965860", "865279060304411", "865753067321909", "865753068700747", "866399066669069", "866399066721365", "869076064651763", "869350061904495", "869350062192991")));
-
 
1031
        fofoIdImeiReturnMap.put(175139404, new HashSet<>(Arrays.asList("352450544013585", "352450544013940", "352450544014344", "352450547322587", "352450547322744", "358142883505941", "359749531269867", "868905065214570")));
-
 
1032
        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")));
-
 
1033
        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")));
-
 
1034
        fofoIdImeiReturnMap.put(175139425, new HashSet<>(Arrays.asList("350386305671629", "350386306043125", "863653060563873", "863653060564970", "865037065022895", "865037065094795", "868905065657356", "868905066089856")));
-
 
1035
        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")));
-
 
1036
        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")));
-
 
1037
        fofoIdImeiReturnMap.put(175139505, new HashSet<>(Arrays.asList("352450547876988", "353305256493285", "354301731180687", "862628066338018", "863653064984612", "865037066073772", "865210064252231", "865210064255556", "865279066156054", "866399065988643", "867158063267031", "867492063304399", "869076064640725", "869236066123035")));
-
 
1038
        fofoIdImeiReturnMap.put(175139431, new HashSet<>(Arrays.asList("860374069332672", "862892060190615", "863879063992419", "864985061894884", "865210064232472", "865753069696365", "865821063930708", "865821064719324", "865821065112404", "866807067509712", "867212063822897", "867212068439556", "868701069306573")));
-
 
1039
        fofoIdImeiReturnMap.put(175139440, new HashSet<>(Arrays.asList("354849877295602", "354849877296600", "861663069285230", "864985066226280", "864985066330744", "866399065940081", "866399066065086", "866807064443857", "866807067122359", "867212068441537", "867212068443053", "869350065159799", "869350065160276", "869916067368859")));
-
 
1040
        fofoIdImeiReturnMap.put(175139442, new HashSet<>(Arrays.asList("861530062218262", "861530062870823", "861530062965466", "866559062488851", "866559062489834", "866559062491699")));
-
 
1041
        fofoIdImeiReturnMap.put(175139449, new HashSet<>(Arrays.asList("359749531470226", "359749531473402", "359749531625381", "359749531637501", "359749531767209", "861784061890593", "865279065935557", "865279066560370", "866399064536229", "866399065066721", "866399065302282", "866399065699125", "866399065717349", "866399065734161")));
-
 
1042
        fofoIdImeiReturnMap.put(175139451, new HashSet<>(Arrays.asList("352450547378647", "862628068576730", "865865067474338", "866132066698774", "867492062851556", "868666065861022")));
-
 
1043
        fofoIdImeiReturnMap.put(175139452, new HashSet<>(Arrays.asList("350031479647969", "350191506027955", "350655759940262", "351733714485035", "353140544946657", "353397823356202", "353397823400539", "355724848507774", "864848068287108", "864985065787142", "864985065837145", "868701061018192", "869106063245851", "869106065767977")));
-
 
1044
        fofoIdImeiReturnMap.put(175139457, new HashSet<>(Arrays.asList("357014950300871", "861530062195841", "863653061134492", "863653061138915", "864848068172664", "864985065981687", "866399062770705", "866399065110404", "868701063248771")));
-
 
1045
        fofoIdImeiReturnMap.put(175139459, new HashSet<>(Arrays.asList("352450543885389", "352450544527246", "354301731188268", "359680163322346", "866641067145718", "868701063374437", "869076063987929", "869076064359821")));
-
 
1046
        fofoIdImeiReturnMap.put(175139463, new HashSet<>(Arrays.asList("350923626635949", "350923626636269", "350923626690902", "861784060309637", "864848068046108", "864848068051546", "866807064687750", "869916067368297")));
-
 
1047
        fofoIdImeiReturnMap.put(175139465, new HashSet<>(Arrays.asList("351613386249440", "351613387095180", "861663068329336", "861663069069253", "861784060309918", "864985065810969", "865753067325041", "865753067353860", "866807064687131", "867212067917156", "867212068434714", "869350061950019", "869350062195671", "869350062386452", "869916067369071")));
-
 
1048
        fofoIdImeiReturnMap.put(175139466, new HashSet<>(Arrays.asList("359749531534823", "359749531619442", "861663069053398", "861663069069857", "863879062138451", "866399065107301", "866399065212788", "866807067493537", "866807067515230", "867212063830312", "867212068447013", "869916067366572")));
-
 
1049
        fofoIdImeiReturnMap.put(175139467, new HashSet<>(Arrays.asList("350250294009631", "350250294416570", "351613386626407", "351613386634724", "351613386881341", "351613386881721", "866807063687975", "866807064692651", "867212063830239", "867212067915812", "867212068434896", "867212068443756", "867212068445470")));
-
 
1050
        fofoIdImeiReturnMap.put(175139468, new HashSet<>(Arrays.asList("863653065382279", "864690068728354", "864690068728412", "865279066339650", "866132063736916", "866132064179710")));
-
 
1051
        fofoIdImeiReturnMap.put(175139472, new HashSet<>(Arrays.asList("351613386632884", "351613386906387", "357415663628286", "860374069457230", "863879063994217", "863879063996659", "864848068065868", "865037066313699", "866399066697367", "866807064662399", "867212067916190", "867212068443236", "868905065660756", "869236068140771", "869350062605497")));
-
 
1052
        fofoIdImeiReturnMap.put(175139477, new HashSet<>(Arrays.asList("861663068335796", "861663069050774", "861663069051590", "863879061279330", "863879062320612", "864288064231455", "864647061805472", "866807063530852", "866807063565775", "867212063825619", "867212068442154")));
-
 
1053
        fofoIdImeiReturnMap.put(175139489, new HashSet<>(Arrays.asList("350031476683801", "350031477646419", "863653067155012", "865037065748796", "865037068846316", "865210063382351", "865279065239570", "866399066070789", "866559062481237", "866641067273452", "867492061243532", "868652062503601", "868666065959727", "868666067777804", "868701062941111", "868701069479172")));
-
 
1054
        fofoIdImeiReturnMap.put(175139490, new HashSet<>(Arrays.asList("350031477636618", "351733715724002", "352120260187174", "352953554051643", "355724848426439", "357014954930939", "863653061893972", "865821060228742", "866399066062984", "866399066069989", "868652062617484", "868666065958901", "868905064290456", "868905064825012", "869076064649502")));
-
 
1055
        fofoIdImeiReturnMap.put(175139493, new HashSet<>(Arrays.asList("350250294029969", "350250294131203", "350339951594819", "351733715279890", "351733715611290", "356612605730052", "358382747584456", "358382747584910", "860695063377770", "862628066338554", "862628067568811", "863879066397897", "864920064911971", "868701063410017", "868701067287973")));
-
 
1056
        fofoIdImeiReturnMap.put(175139496, new HashSet<>(Arrays.asList("350386305879537", "860695063378810", "863879062651750", "864920069103590", "865037066073517", "865210064600017", "865279067176432", "865865062952171", "866807068662916", "866807069402130", "867158063179178", "867492063171996", "868905065232135")));
-
 
1057
 
1006
 
1058
        //System.out.println(fofoIdImeiReturnMap.entrySet().stream().flatMap(x -> x.getValue().stream()).collect(Collectors.toList()).size());
-
 
1059
 
-
 
1060
        List<String> serialNumbers = fofoIdImeiReturnMap.entrySet().stream().flatMap(x -> x.getValue().stream()).collect(Collectors.toList());
-
 
1061
        List<WarehouseInventoryItem> warehouseInventoryItems = warehouseInventoryItemRepository.selectWarehouseInventoryItemBySerailNumbers(serialNumbers);
-
 
1062
        for (WarehouseInventoryItem warehouseInventoryItem : warehouseInventoryItems) {
-
 
1063
            if (warehouseInventoryItem.getCurrentQuantity() - warehouseInventoryItem.getInitialQuantity() >= 0) {
-
 
1064
                int diff = 1 + warehouseInventoryItem.getCurrentQuantity() - warehouseInventoryItem.getInitialQuantity();
-
 
1065
                System.out.println(warehouseInventoryItem.getId() + " --- " + diff);
-
 
1066
                List<WarehouseScan> warehouseScans = warehouseScanRepository.selectAllByInventoryItemIds(Arrays.asList(warehouseInventoryItem.getId()));
-
 
1067
                WarehouseScan previousSaleScan = warehouseScans.stream().filter(x->x.getType().equals(in.shop2020.warehouse.ScanType.SALE)).sorted(Comparator.comparingInt(WarehouseScan::getOrderId).reversed()).skip(1).findFirst().get();
-
 
1068
                List<WarehouseScan> scansToDelete = warehouseScans.stream().filter(x -> x.getType().equals(in.shop2020.warehouse.ScanType.SALE_RET) && x.getSupplierWarehouseId()==0).skip(1).collect(Collectors.toList());
-
 
1069
                if(scansToDelete.size() > 0) {
-
 
1070
                    WarehouseScan warehouseScan = warehouseScans.stream().filter(x -> x.getType().equals(in.shop2020.warehouse.ScanType.SALE_RET)).findFirst().get();
-
 
1071
                    warehouseScan.setSupplierWarehouseId(warehouseInventoryItem.getCurrentWarehouseId());
-
 
1072
                    warehouseScan.setOrderId(previousSaleScan.getOrderId());
-
 
1073
                    System.out.println(scansToDelete.toString());
-
 
1074
                    for (WarehouseScan scan : scansToDelete) {
-
 
1075
                        warehouseScanRepository.delete(scan);
-
 
1076
                    }
-
 
1077
                    warehouseInventoryService.addQuantity(warehouseInventoryItem.getId(), -diff);
-
 
1078
                }
-
 
1079
            }
-
 
1080
        }
-
 
1081
 
1007
 
1082
        /*for (Entry<Integer, Set<String>> fofoIdImeiReturnEntry : fofoIdImeiReturnMap.entrySet()) {
1008
        /*for (Entry<Integer, Set<String>> fofoIdImeiReturnEntry : fofoIdImeiReturnMap.entrySet()) {
1083
            int fofoId = fofoIdImeiReturnEntry.getKey();
1009
            int fofoId = fofoIdImeiReturnEntry.getKey();
1084
            Set<String> imeis = fofoIdImeiReturnEntry.getValue();
1010
            Set<String> imeis = fofoIdImeiReturnEntry.getValue();
1085
            List<InventoryItem> inventoryItems = inventoryItemRepository.selectByFofoIdSerialNumbers(fofoId, imeis, true);
1011
            List<InventoryItem> inventoryItems = inventoryItemRepository.selectByFofoIdSerialNumbers(fofoId, imeis, true);
Line 1108... Line 1034...
1108
 
1034
 
1109
            //List<DebitNotePdfModel> debitNotePdfModels = purchaseReturnService.generateDebitNotes(purchaseInventoryMap, warehouseId);
1035
            //List<DebitNotePdfModel> debitNotePdfModels = purchaseReturnService.generateDebitNotes(purchaseInventoryMap, warehouseId);
1110
        }*/
1036
        }*/
1111
    }
1037
    }
1112
 
1038
 
-
 
1039
    //TODO:Important method for Order return refund and reordering
-
 
1040
    private void importantMethodCo() {
-
 
1041
        Map<Integer, Set<String>> fofoIdImeiReturnMap = new TreeMap<>();
-
 
1042
        fofoIdImeiReturnMap.put(175139496, new HashSet<>(Arrays.asList("350386305879537", "860695063378810", "863879062651750", "864920069103590", "865037066073517", "865210064600017", "865279067176432", "865865062952171", "866807068662916", "866807069402130", "867158063179178", "867492063171996", "868905065232135")));
-
 
1043
        List<String> serialNumbers = fofoIdImeiReturnMap.entrySet().stream().flatMap(x -> x.getValue().stream()).collect(Collectors.toList());
-
 
1044
        List<WarehouseInventoryItem> warehouseInventoryItems = warehouseInventoryItemRepository.selectWarehouseInventoryItemBySerailNumbers(serialNumbers);
-
 
1045
        for (WarehouseInventoryItem warehouseInventoryItem : warehouseInventoryItems) {
-
 
1046
            if (warehouseInventoryItem.getCurrentQuantity() - warehouseInventoryItem.getInitialQuantity() >= 0) {
-
 
1047
                int diff = 1 + warehouseInventoryItem.getCurrentQuantity() - warehouseInventoryItem.getInitialQuantity();
-
 
1048
                System.out.println(warehouseInventoryItem.getId() + " --- " + diff);
-
 
1049
                List<WarehouseScan> warehouseScans = warehouseScanRepository.selectAllByInventoryItemIds(Arrays.asList(warehouseInventoryItem.getId()));
-
 
1050
                WarehouseScan previousSaleScan = warehouseScans.stream().filter(x->x.getType().equals(in.shop2020.warehouse.ScanType.SALE)).sorted(Comparator.comparingInt(WarehouseScan::getOrderId).reversed()).skip(1).findFirst().get();
-
 
1051
                List<WarehouseScan> scansToDelete = warehouseScans.stream().filter(x -> x.getType().equals(in.shop2020.warehouse.ScanType.SALE_RET) && x.getSupplierWarehouseId()==0).skip(1).collect(Collectors.toList());
-
 
1052
                if(scansToDelete.size() > 0) {
-
 
1053
                    WarehouseScan warehouseScan = warehouseScans.stream().filter(x -> x.getType().equals(in.shop2020.warehouse.ScanType.SALE_RET)).findFirst().get();
-
 
1054
                    warehouseScan.setSupplierWarehouseId(warehouseInventoryItem.getCurrentWarehouseId());
-
 
1055
                    warehouseScan.setOrderId(previousSaleScan.getOrderId());
-
 
1056
                    System.out.println(scansToDelete.toString());
-
 
1057
                    for (WarehouseScan scan : scansToDelete) {
-
 
1058
                        warehouseScanRepository.delete(scan);
-
 
1059
                    }
-
 
1060
                    warehouseInventoryService.addQuantity(warehouseInventoryItem.getId(), -diff);
-
 
1061
                }
-
 
1062
            }
-
 
1063
        }
-
 
1064
    }
-
 
1065
 
1113
    @Autowired
1066
    @Autowired
1114
    CartService cartService;
1067
    CartService cartService;
1115
    @Autowired
1068
    @Autowired
1116
    UserRepository userRepository;
1069
    UserRepository userRepository;
1117
 
1070