123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821 |
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Infos;
- (function (Infos) {
- class OrderItem {
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new OrderItem();
- }
- return this.instance;
- }
- }
- Infos.OrderItem = OrderItem;
- class FoCItem {
- }
- Infos.FoCItem = FoCItem;
- class ValidOrderFoCItem {
- }
- Infos.ValidOrderFoCItem = ValidOrderFoCItem;
- class AppliedOffer {
- }
- Infos.AppliedOffer = AppliedOffer;
- class OrderTotals {
- }
- Infos.OrderTotals = OrderTotals;
- class UOMSchemaDetails {
- }
- Infos.UOMSchemaDetails = UOMSchemaDetails;
- class POSOrderItem {
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new OrderItem();
- }
- return this.instance;
- }
- }
- Infos.POSOrderItem = POSOrderItem;
- class Cart_Item {
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new Cart_Item();
- }
- return this.instance;
- }
- }
- Infos.Cart_Item = Cart_Item;
- class ValidFoCItem {
- }
- Infos.ValidFoCItem = ValidFoCItem;
- class RawMaterial {
- }
- Infos.RawMaterial = RawMaterial;
- class Operation {
- }
- Infos.Operation = Operation;
- })(Infos = Transact.Infos || (Transact.Infos = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
-
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Controls;
- (function (Controls) {
- class OrderItems extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this._order = Bizgaze.Apps.Transact.Controls.Order.Instance();
- this.g_ValidFocItems = [];
- this.g_SelectedItems = [];
- this.g_AppliedOffers = [];
- this.g_LoadedItems = [];
- this.g_UOMs = [];
- this.g_PurPlanData = [];
- this.g_ItemsUnitPrice_New = [];
- this.g_CartItems_New = [];
- this.g_SC_PC_CartItems = [];
- this.g_AppliedTaxGroups = [];
- this.g_PageIndex = 0;
- this.g_PriceTypeId = 1;
- this.g_IsEnablePieces = false;
- this.g_IsEnablePacks = false;
- this.g_IsEnablePiecePrice = false;
- this.g_IsEnableCompositePrice = false;
- this.g_IsEnableCompositePiecePrice = false;
- this.g_BodyWidth = $('body').width();
- this.g_IsExcise = false;
- this.g_PacksFocus = true;
- this.g_PiecesFocus = false;
- this.g_OfferApplyDate = new Date();
- this.g_FromWidget = false;
- this.g_FromWidgetEditOrderItemId = 0;
- this.g_FromContinueShopping = false;
- this.g_IsFilterApplied = false;
- this.g_TagArray = [];
- this.g_ContainerId = "";
- this.g_VisibleContainerId = "";
- this.Modified_Discount = 0;
- }
- init(formpropertyid, prop, callback) {
- let instance = this;
- instance.fileCacheHelper.loadJsFile("apps/transact/enums/enum.js", function () {
- instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
- instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
- });
- }
- loadControl(containerid, prop) {
- let instance = this;
- instance.g_ContainerId = containerid;
- instance.g_VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
- instance._order.g_OrderTypeId = Number($("#" + instance.g_VisibleContainerId).find(".hdn_ordertypeid").val());
- let html = '<div class="w-100">' +
- '<input type = "hidden" id = "hdn_customcontrol" class="value-control" value = "Bizgaze.Apps.Transact.Controls.OrderItems.Instance().getOrderItems();"' +
- '<div class="floating-label-form-group div_SearchItem">' +
- '<div class="input-group">' +
- '<span class="input-group-prepend"></span>' +
- '<input type="search" id="txt_SearchItem" class="form-control floating-label-control pl-0" data-isdynamic="false" placeholder="Search Items" data-placeholder="Item Name (or) SKU" data-label="Search Items" autocomplete="on" />' + '<a href="javascript:;" id="crpnrd_btn_OpenScanner" class="input-group-append helo" ><span class="input-group-text" > <i class="fa fa-qrcode" > </i></span ></a>' +
- `<a href = "javascript:;" class="search-clear-items d-none" id = "` + containerid + `" onclick="Bizgaze.Apps.Transact.Controls.OrderItems.Instance().clearItemSearch()"> <i class="zmdi zmdi-close"></i></a> ` +
- '<span class="input-group-prepend input-group-btn p-0">';
- instance.fileCacheHelper.loadJsFile("apps/transact/enums/enum.js", function () {
- if (instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.SalesClaim || instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim) {
- html += '<select id="ItemLoadType" class="bg-transparent rounded-4 px-2 font-12"><option value="1">All</option><option value="2">Filter</option></select>';
- }
- else {
- html += '<select id="ItemLoadType" class="bg-transparent rounded-4 px-2 font-12"><option value="1">All</option><option value="2">Offers</option><option value="3">Filter</option></select>';
- }
- html += '</span>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '<br/> <div class="InventorySettings"> </div>';
- $("#" + instance.g_VisibleContainerId).find("#" + containerid).html(html);
- instance.ItemsQrScan();
- });
- $("#" + instance.g_VisibleContainerId).find("#ItemLoadType").unbind().click(function () {
- $("#" + instance.g_VisibleContainerId).find(".div_SearchItem").removeClass("floating-label-form-group-with-value");
- });
- $("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").focusout(function () {
- if ($("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").val() == "") {
- $("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").attr("placeholder", "Search Items");
- }
- });
- }
- ItemsQrScan() {
- $("#crpnrd_btn_OpenScanner").addClass("hidden");
- if (isMobileApp()) {
- $("#crpnrd_btn_OpenScanner").removeClass("hidden");
- $("#crpnrd_btn_OpenScanner").click(function () {
- Unibase.Platform.Helpers.MobileHelper.Instance().openQrScanner("Bizgaze.Apps.Transact.Controls.OrderItems.Instance().readScanner", "txt_SearchItem");
- });
- }
- else {
- $("#crpnrd_btn_OpenScanner").addClass("hidden");
- }
- }
- loadControlSettings(controlsettingjson, formpropertyid) {
- return null;
- }
- loadPropertySettings(propertysettings, formpropertyid) {
- return null;
- }
- bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
- return null;
- }
- loadItems(SearchItem, UpdateAvailability = false) {
- let instance = this;
- $("#" + instance.g_VisibleContainerId).find('.section_Items').removeClass('hidden');
- let OrganizationId = instance._order.g_OrganizationId;
- let LoBId = $("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_lobid").val();
- let ShipTo = $("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_shippingaddressid").val();
- if (ShipTo == null) {
- ShipTo = 0;
- }
- let BranchId = $("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_billfromaddressid").val();
- if (SearchItem == "Offers" || SearchItem == "All Items" || SearchItem == "Filter" || SearchItem == "Eligible Items") { }
- else
- SearchItem = (encodeURIComponent(encodeURIComponent(SearchItem).replace('*', '%2A').replace('.', '%2E'))).replace(/\%/g, '!');
- if (!instance._order.g_IsPurchasePlanning) {
- if (SearchItem == undefined || SearchItem == '') {
- SearchItem = ' ';
- }
- if (SearchItem == "Offers") {
- instance._order.g_LoadOffersOnly = true;
- SearchItem = '';
- if (instance.g_IsFilterApplied) {
- instance.g_IsFilterApplied = false;
- instance.g_FilteredTags = '';
- instance.g_TagArray = [];
- Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_Tags = "";
- }
- }
- else if (SearchItem == "All Items") {
- instance._order.g_LoadOffersOnly = false;
- instance._order.g_LoadEligibleItemsOnly = false;
- instance.g_FilteredTags = '';
- instance.g_TagArray = [];
- Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_Tags = "";
- SearchItem = "";
- }
- else if (SearchItem == "Filter") {
- instance._order.g_LoadOffersOnly = false;
- }
- else if (SearchItem == "Eligible Items") {
- instance._order.g_LoadEligibleItemsOnly = true;
- SearchItem = "";
- }
- let PriceCodeId = instance._order.g_PriceCodeId;
- let ContactId = OrganizationId;
- if (instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales || instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim) {
- instance.g_WarehouseId = $("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_shipfromaddressid").val();
- }
- else if (instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Purchase || instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.SalesClaim) {
- instance.g_WarehouseId = $("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_shippingaddressid").val();
- }
- let varianturl;
- if (SearchItem.replace(" ", "") == "") {
- SearchItem = null;
- }
- if (Number(LoBId) == 0) {
- $("#" + instance.g_VisibleContainerId).find(".InventorySettings").empty();
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").html('<li id="0" class="cartitem list-group-item col-xs-12 hidden clear no-border"></li> <li class="list-group-item col-xs-12 no-border EmptyCartLi"><strong>Your Shopping Cart is empty.</strong></li>');
- }
- else {
- instance.fileCacheHelper.loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () {
- let ItemIds = "0";
- let Rows = 10;
- if (instance._order.g_IsSC_to_PC) {
- ItemIds = "";
- instance.g_CartItems_New.forEach(x => {
- ItemIds += x.ItemId + ",";
- });
- ItemIds = ItemIds.replace(/,\s*$/, "");
- Rows = 0;
- $("#" + instance.g_VisibleContainerId).find('.section_Items').addClass('hidden');
- }
- let postdata = {
- PriceCodeId: Number(PriceCodeId),
- ContactId: ContactId,
- ShippingAddressId: Number(ShipTo),
- BranchId: Number(BranchId),
- WareHouseId: Number(instance.g_WarehouseId),
- LobId: Number(LoBId),
- OrderType: instance._order.g_OrderTypeId,
- OfferOnly: instance._order.g_LoadOffersOnly,
- IsExcise: instance.g_IsExcise,
- SearchTerm: SearchItem,
- Page: instance.g_PageIndex,
- IsCompositePrice: instance.g_IsEnableCompositePrice,
- IsPiecePrice: instance.g_IsEnablePiecePrice,
- IsCompositePiecePrice: instance.g_IsEnableCompositePiecePrice,
- Rows: Rows,
- ItemId: ItemIds,
- CountryId: instance._order.g_CountryId,
- ItemGroupId: 0,
- Tags: Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_Tags,
- IsPoints: instance._order.g_IsPointsOrder,
- Points: instance._order.g_LoyaltyPoints,
- IsEligibleItemsOnly: instance._order.g_LoadEligibleItemsOnly
- };
- let cntId = instance._order.g_OrganizationId;
- if (cntId == 0)
- cntId = instance._order.g_OrgContactId;
- if ($("#" + instance.g_VisibleContainerId).find("#ItemLoadType option:selected").text() != "Filter" || (Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_Tags.length == 0 && $("#" + instance.g_VisibleContainerId).find("#ItemLoadType option:selected").text() == "Filter")) {
- if (Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_Tags.length == 0 && $("#" + instance.g_VisibleContainerId).find("#ItemLoadType option:selected").text() == "Filter") {
- instance._order.g_LoadOffersOnly = false;
- }
- }
- varianturl = Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItemsForOrder(postdata);
- instance.navigationHelper.showLoading();
- varianturl.then(function (response) {
- instance.navigationHelper.hideLoading();
- if (UpdateAvailability) {
- instance.updateItemsAvailability(response.result);
- }
- else if (response.result.length > 0) {
- instance.itemPagination(response);
- if (!instance._order.g_IsPurchasePlanning) {
- $("#" + instance.g_VisibleContainerId).find("#btn_CheckOutOrder").removeClass("hidden");
- }
- if (instance.g_CartItems_New.length == 0) {
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").html('<li id="0" class="cartitem list-group-item col-xs-12 hidden clear no-border"></li> <li class="list-group-item col-xs-12 no-border EmptyCartLi"><strong>Your Shopping Cart is empty.</strong></li>');
- }
- instance.navigationHelper.hideLoading();
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(".div_titledetails").addClass("hidden");
- if (instance._order.g_LoadOffersOnly) {
- $("#" + instance.g_VisibleContainerId).find("#div_ItemList").html('<ul class="variant-list list-group" style="margin:0px -21px" id="Items-list"><li class="variant-item"><div class="text-center">Offer Items not found.</div></li></ul>');
- }
- else if (instance._order.g_LoadEligibleItemsOnly) {
- $("#" + instance.g_VisibleContainerId).find("#div_ItemList").html('<ul class="variant-list list-group" style="margin:0px -21px" id="Items-list"><li class="variant-item"><div class="text-center">Eligible Items not found.</div></li></ul>');
- }
- else {
- if (instance._order.g_CreateItem == 1 || instance._order.g_IsAdmin == 1) {
- $("#" + instance.g_VisibleContainerId).find("#div_ItemList").html('<ul class="variant-list list-group" style="margin:0px -21px" id="Items-list"><li class="variant-item"> <div class="text-center">Items not found.</div><br><div class="text-center"><button id="btn_AddNewItem" class="btn btn-primary">Create New Item</button></li></ul>');
- }
- else {
- $("#" + instance.g_VisibleContainerId).find("#div_ItemList").html('<ul class="variant-list list-group" style="margin:0px -21px" id="Items-list"><li class="variant-item"><div class="text-center">Items not found.</div></li></ul>');
- }
- }
- if (instance.g_CartItems_New.length == 0 && instance._order.g_IsFromPurchaseIndent) {
- let text = "Your Shopping Cart is empty.";
- if (instance._order.g_IsFromPurchaseIndent) {
- text = "No Pending Purchase Indent Items.";
- }
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").html('<li id="0" class="cartitem list-group-item col-xs-12 hidden clear no-border"></li> <li class="list-group-item col-xs-12 no-border EmptyCartLi"><strong>' + text + '</strong></li>');
- }
- $("#btn_AddNewItem").click(function () {
- Bizgaze.Apps.Transact.Controls.OrderItems.Instance().getItemForm();
- });
- }
- });
- });
- }
- }
- }
- getItemForm() {
- let instance = Bizgaze.Apps.Transact.Controls.OrderItems.Instance();
- instance.fileCacheHelper.loadJsFiles(['platform/forms/managers/formmanager.js', 'platform/apps/managers/appmanager.js'], function () {
- var FormUniqueId = 'Bizgaze_Extension_Transact_Items_App_Items_CreateForm';
- Unibase.Platform.Forms.Managers.FormManager.Instance().getFormbyUniqueId(FormUniqueId).then(function (response) {
- var successCallBack = {
- CallBack: function (ItemId) {
- instance.bindNewAddedItem(ItemId);
- },
- Parameters: null,
- };
- var onLoadAddItem = {
- CallBack: function (ItemId) {
- let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
- let Parameters = [
- { ColumnName: 'lobid', Value: instance._order.g_LobId },
- ];
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($("#" + VisibleContainerId).find(".txtAutoComplete_productid"), Parameters);
- },
- Parameters: null,
- };
- var formviewerObj = {
- FormId: response.result.FormId,
- AppConfigurationId: 0,
- Pk_Value: 0,
- PortletWidgetId: 0,
- OnSuccess: successCallBack,
- OnFail: null,
- OnLoad: onLoadAddItem,
- };
- Unibase.Platform.Forms.Components.FormViewer.Instance().init(formviewerObj);
- instance.navigationHelper.hideLoading();
- });
- });
- }
- bindNewAddedItem(ItemId) {
- let instance = this;
- let LoBId = $("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_lobid").val();
- let ShipTo = $("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_shippingaddressid").val();
- if (ShipTo == null) {
- ShipTo = 0;
- }
- let BranchId = $("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_billfromaddressid").val();
- let postdata = {
- PriceCodeId: Number(instance._order.g_PriceCodeId),
- ContactId: instance._order.g_OrganizationId,
- ShippingAddressId: Number(ShipTo),
- BranchId: Number(BranchId),
- WareHouseId: Number(instance.g_WarehouseId),
- LobId: Number(LoBId),
- OrderType: instance._order.g_OrderTypeId,
- OfferOnly: false,
- IsExcise: instance.g_IsExcise,
- SearchTerm: "",
- Page: 0,
- IsCompositePrice: instance.g_IsEnableCompositePrice,
- IsPiecePrice: instance.g_IsEnablePiecePrice,
- IsCompositePiecePrice: instance.g_IsEnableCompositePiecePrice,
- Rows: 10,
- ItemId: ItemId.toString(),
- CountryId: instance._order.g_CountryId,
- ItemGroupId: 0,
- Tags: "",
- IsPoints: instance._order.g_IsPointsOrder,
- Points: instance._order.g_LoyaltyPoints,
- IsEligibleItemsOnly: instance._order.g_LoadEligibleItemsOnly,
- ApplyDate: instance.g_OfferApplyDate
- };
- Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItemsForOrder(postdata).then(function (res) {
- instance.itemPagination(res);
- });
- }
- loadPurchasePlanItems(SearchTerm) {
- let instance = this;
- let LoadTypeId = Number($("#" + instance.g_VisibleContainerId).find("#ItemLoadType option:selected").val());
- SearchTerm = SearchTerm == "" ? null : SearchTerm;
- instance.navigationHelper.showLoading();
- $("#" + instance.g_VisibleContainerId).find(".divselectall").removeClass('hidden');
- let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
- $("#" + instance.g_VisibleContainerId).find("#" + VisibleContainerId).find(".Section").addClass("hidden");
- $("#" + instance.g_VisibleContainerId).find("#" + VisibleContainerId).find(".section_Items, .section_Calculations").removeClass("hidden");
- $("#" + instance.g_VisibleContainerId).find("#" + VisibleContainerId).find("#btn_Checkout").addClass("hidden");
- let InputParameters = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters;
- let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- let EstimateId = Number(InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_estimateid").Value);
- Bizgaze.Apps.Transact.Managers.OrderManager.Instance().getPurchasePlanItems(EstimateId, LoadTypeId, SearchTerm, 0).then(function (response) {
- instance.navigationHelper.hideLoading();
- if (response.code == "0") {
- var data = response.result;
- $("#" + instance.g_VisibleContainerId).find(".variant-addeditem").empty();
- instance.itemPagination(response);
- }
- else {
- Unibase.Platform.Forms.Components.FormViewer.Instance().showError(response.code);
- }
- });
- }
- itemPagination(response) {
- let instance = this;
- response.result.forEach(x => {
- let LoadedItem_Index = instance.g_LoadedItems.findIndex(z => z.ItemId == x.ItemId);
- if (LoadedItem_Index == -1) {
- instance.g_LoadedItems.push(x);
- }
- else {
- instance.g_LoadedItems[LoadedItem_Index].TaxPercentList = x.TaxPercentList;
- }
- });
- instance.bindItemList(response.result);
- if (response.result.length <= 10 && response.result.length != 0) {
- $("#" + instance.g_VisibleContainerId).find('#div_OrderItems_pagination').removeClass('hidden');
- $("#" + instance.g_VisibleContainerId).find('#ItemsListPagination').removeClass('hidden');
- let totalCount = response.result[0].TotalRecords;
- if (instance._order.g_IsPurchasePlanning) {
- totalCount = response.result.length;
- }
- let startingValue = 0;
- let _count = 0;
- let t = (instance.g_PageIndex + 1) * 10;
- if (totalCount > 0) {
- startingValue = 1;
- _count = totalCount;
- }
- if (totalCount > t)
- _count = t;
- if (instance.g_PageIndex > 0) {
- startingValue += t - 10;
- }
- let res = startingValue + " - " + _count + " of " + totalCount;
- $("#" + instance.g_VisibleContainerId).find('#lblItemTotalRecords').text(res);
- $("#" + instance.g_VisibleContainerId).find('.labelSection_ItemsCount').text("Total: " + response.result.length + " Items").addClass("col-sm-12").addClass("text-right").addClass("h5");
- let elem = $("#" + instance.g_VisibleContainerId).find('#ItemsListPagination');
- elem.pagination(response.result[0].TotalRecords, 10, {
- items_per_page: 10,
- callback: function (page, component) {
- instance.g_PageIndex = page;
- instance.loadItems($("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").val());
- }, current_page: instance.g_PageIndex
- });
- }
- else {
- $("#" + instance.g_VisibleContainerId).find('#lblItemTotalRecords').text(response.result.length);
- $("#" + instance.g_VisibleContainerId).find('.labelSection_ItemsCount').text("Total: " + response.result.length + " Items").addClass("col-sm-12").addClass("text-right").addClass("h5");
- $("#" + instance.g_VisibleContainerId).find("#ItemsListPagination").addClass("hidden");
- }
- }
- bindItemList(items) {
- let instance = this;
- let LobId = Number($("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_lobid").val());
- let BillingAddressId = Number($("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_billingaddressid").val());
- let BranchId = Number($("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_billfromaddressid").val());
- $("#" + instance.g_VisibleContainerId).find("#div_ItemList").html('<ul class="variant-list list-group" id="Items-list" style="margin:0px -21px"><li class="variant-item hidden"></li>');
- if (items.length == 0) {
- if (instance._order.g_LoadOffersOnly) {
- $("#" + instance.g_VisibleContainerId).find(".variant-list").html('<li><div class="text-center">Offer Items not found.</div></li></ul>');
- }
- else if (instance._order.g_LoadEligibleItemsOnly) {
- $("#" + instance.g_VisibleContainerId).find(".variant-list").html('<li><div class="text-center">Eligible Items not found.</div></li></ul>');
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(".variant-list").html('<li><div class="text-center">Items not found.</div></li></ul>');
- }
- $("#" + instance.g_VisibleContainerId).find(".div_titledetails").addClass("hidden");
- return false;
- }
- else
- $("#" + instance.g_VisibleContainerId).find(".div_titledetails").removeClass("hidden");
- let kpi_totalqty = 0;
- let kpi_itemscount = 0;
- let kpi_totalamount = 0;
- let kpi_totalinwardqty = 0;
- let kpi_totalinwardamount = 0;
- let kpi_ExtraItems = 0;
- let kpi_offeritems = 0;
- let lbl_Carton = "ml-95";
- let lbl_Pieces = "pl-75";
- if (instance.g_BodyWidth > 320 && instance.g_BodyWidth < 400) {
- lbl_Carton = "ml-45";
- lbl_Pieces = "pl-10";
- }
- if (instance.g_BodyWidth > 400 && instance.g_BodyWidth < 470) {
- lbl_Carton = "ml-55";
- lbl_Pieces = "pl-25";
- }
- if (instance.g_BodyWidth > 1300 && instance.g_BodyWidth <= 1600) {
- lbl_Carton = "ml-65";
- lbl_Pieces = "pl-55";
- }
- if (instance._order.g_IsPurchasePlanning) {
- let temptext = instance.getItemDesignWithTokens_PurchasePlan();
- var templateScript = Handlebars.compile(temptext);
- var html = "";
- $("#" + instance.g_VisibleContainerId).find(".div_PurchasePlanningFooterValues").remove();
- $("#" + instance.g_VisibleContainerId).find("#formFooter").append(`<div class="div_PurchasePlanningFooterValues col-sm-10 row"> <div class="col-sm-6" > <strong class="font-15">Total Suggested Qty: <span id="spn_Total_Suggested_Qty"> 0 </span> </span></div><div class="col-sm-6"> <strong class="font-15">Total Suggested Value: <span id="spn_Total_Suggested_Value"> 0 </span> </span></div></div>`);
- let TotalSuggestedQty = 0;
- let TotalSuggestedValue = 0;
- items.forEach(x => {
- let url = '';
- let ItemImg = "";
- let imgtag = "";
- let faimg = "";
- let LoadedItemIndex = instance.g_LoadedItems.findIndex(y => y.ItemId == x.ItemId);
- if (LoadedItemIndex != -1) {
- url = instance.g_LoadedItems[LoadedItemIndex].ImageUrl;
- if (url == "" || url == undefined || url == null) {
- faimg = "";
- imgtag = "hidden";
- }
- else {
- faimg = "hidden";
- imgtag = "";
- }
- }
- else {
- if (x.ImageUrl == "" || x.ImageUrl == undefined || x.ImageUrl == null) {
- faimg = "";
- imgtag = "hidden";
- }
- else {
- url = x.ImageUrl;
- faimg = "hidden";
- imgtag = "";
- }
- }
- let Mod_UnitPrice = 0;
- let Items_up = instance.g_ItemsUnitPrice_New.filter(y => y.ItemId == x.ItemId);
- if (Items_up.length == 0) {
- Mod_UnitPrice = x.ConfirmedUnitPrice;
- instance.g_ItemsUnitPrice_New.push({
- ItemId: x.ItemId,
- UnitPrice: x.UnitPrice,
- TaxRateAmount: x.TaxRateAmount
- });
- }
- else {
- Mod_UnitPrice = Items_up[0].ConfirmedUnitPrice;
- }
- let PurchasePlanChecked = "";
- if (x.IsConfirmed) {
- PurchasePlanChecked = "checked";
- }
- let OrderQuantity = "";
- let multiplevalue = "";
- if (x.ConfirmedPacks > 0 && x.ConfirmedQty > 0) {
- x.SuggestedPacks = x.ConfirmedPacks;
- }
- if ((x.SuggestedPacks) != 0 && (x.SuggestedPacks) != null && (x.SuggestedPacks) != undefined) {
- let unitprice = Number(Mod_UnitPrice);
- let packCount = Number(x.PackCount);
- let packSize = Number(x.PackSize);
- let baseqty = packCount * packSize * x.SuggestedPacks;
- OrderQuantity = " X " + (baseqty);
- multiplevalue = " = " + (unitprice * baseqty);
- TotalSuggestedQty += baseqty;
- TotalSuggestedValue += (unitprice * baseqty);
- }
- let offerDiscountClass = "";
- if (x.IsOfferAvailable && x.IsOfferDiscountApplied && !instance._order.g_IsManageOfferDiscount) {
- offerDiscountClass = "readonly";
- }
- let Discount = 0;
- if (x.ConfirmedDiscountValue > 0) {
- Discount = x.ConfirmedDiscountValue;
- }
- if (x.ConfirmedDiscountPercent > 0) {
- Discount = x.ConfirmedDiscountPercent;
- }
- let fltngclass_Cartons = "", fltngclass_Pieces = "", PP_Cartons = "", PP_Pieces = "";
- if (x.SuggestedPacks != 0) {
- PP_Cartons = x.ConfirmedPacks.toString();
- }
- let CartItem_Index = -1;
- CartItem_Index = instance.g_CartItems_New.findIndex(y => y.ItemId == x.ItemId && y.RefItemIds == "");
- let CartItem = instance.g_CartItems_New[CartItem_Index];
- if (CartItem != undefined) {
- PP_Cartons = CartItem.Packs.toString();
- PP_Pieces = CartItem.Pieces.toString();
- }
- if (PP_Cartons == "0") {
- PP_Cartons = "";
- }
- if (PP_Cartons != "") {
- fltngclass_Cartons = "floating-label-form-group-with-value";
- }
- if (PP_Pieces == "0") {
- PP_Pieces = "";
- }
- if (PP_Pieces != "") {
- fltngclass_Pieces = "floating-label-form-group-with-value";
- }
- x.imgurl = url;
- x.faimg = faimg;
- x.imgtag = imgtag;
- x.ItemImg = ItemImg;
- x.OrderQuantity = OrderQuantity;
- x.multiplevalue = multiplevalue;
- x.Mod_UnitPrice = Mod_UnitPrice;
- x.offerDiscountClass = offerDiscountClass;
- x.PP_Cartons = PP_Cartons;
- x.PP_Pieces = PP_Pieces;
- x.fltngclass_Cartons = fltngclass_Cartons;
- x.fltngclass_Pieces = fltngclass_Pieces;
- x.PurchasePlanChecked = PurchasePlanChecked;
- x.Discount = Discount;
- x.BranchId = '"' + x.BranchId.toString() + '"';
- x.IsDisabledCheckBox = x.SuggestedPacks > 0 ? "" : "disabled";
- let ItemId = x.ItemId;
- html = templateScript(x);
- $("#" + instance.g_VisibleContainerId).find(".variant-item:last").after(html);
- let element = $("#" + instance.g_VisibleContainerId).find(".variant-item:last");
- if (x.UnitPrice == 0 && instance.roundOff(x.SuggestedPacks, 0) > 0) {
- if (element.find(".tax-error").text() == "") {
- element.find(".tax-error").text("Unit price is zero").removeClass("text-danger").addClass("text-warning");
- }
- }
- instance.allItemEvents(element);
- let SelItem = instance.g_SelectedItems.find(x => x.ItemId == ItemId);
- if (SelItem != null) {
- let element = $("#" + instance.g_VisibleContainerId).find(".variant-item:last");
- instance.updateItemsDesign(element, "BindItemList");
- if (SelItem.Packs == 0) {
- $("#" + instance.g_VisibleContainerId).find(element).find(".txtOrder_ItemCount").val("");
- }
- if (SelItem.Pieces == 0) {
- $("#" + instance.g_VisibleContainerId).find(element).find(".txtOrder_ItemPieceCount").val("");
- }
- instance.checkValidations(ItemId, false);
- }
- else {
- if (instance._order.g_IsPurchasePlanning && x.SuggestedPacks > 0) {
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(element).find(".txtOrder_ItemCount").val("");
- $("#" + instance.g_VisibleContainerId).find(element).find(".txtOrder_ItemPieceCount").val("");
- }
- }
- });
- TotalSuggestedQty = instance.roundOffIgnoreZerosAfterDecimal(TotalSuggestedQty);
- TotalSuggestedValue = instance.roundOffIgnoreZerosAfterDecimal(TotalSuggestedValue);
- $("#" + instance.g_VisibleContainerId).find("#spn_Total_Suggested_Qty").text(TotalSuggestedQty);
- $("#" + instance.g_VisibleContainerId).find("#spn_Total_Suggested_Value").text(TotalSuggestedValue);
- if ($("#" + instance.g_VisibleContainerId).find(".chk_PurPlanItem:visible").length != $("#" + instance.g_VisibleContainerId).find(".chk_PurPlanItem:visible:checked").length) {
- $("#" + instance.g_VisibleContainerId).find('#chk_AllItems').prop('checked', false);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find('#chk_AllItems').prop('checked', true);
- }
- instance.navigationHelper.showLoading();
- $("#" + instance.g_VisibleContainerId).find(".variant-list").find(".chk_PurPlanItem:checked").each(function () {
- let element = $("#" + instance.g_VisibleContainerId).find(this).closest(".variant-item");
- if (element.find("#txt_Cartons").val() != 0 && element.find("#txt_Cartons").val() != "") {
- instance.updateItemsArray(element, "PurPlan_AllItems", false);
- $("#" + instance.g_VisibleContainerId).find(element).find(".chk_PurPlanItem").prop("checked", true);
- }
- });
- instance.navigationHelper.hideLoading();
- instance.getPurchasePlanTotals(true, false);
- }
- else {
- for (let i = 0; i < items.length; i++) {
- let data;
- if (instance._order.g_IsPurchasePlanning) {
- data = items[i];
- let kpi_suggestedPacks = items[i].SuggestedPacks;
- let kpi_inwardPacks = items[i].InwardOrderPacks;
- let kpi_packSize = data.PackSize;
- let kpi_packCount = data.PackCount;
- let kpi_unitprice = data.UnitPrice;
- kpi_totalqty += (Number(kpi_suggestedPacks) * Number(kpi_packSize) * Number(kpi_packCount));
- kpi_totalamount += (Number(kpi_suggestedPacks) * Number(kpi_unitprice) * Number(kpi_packSize) * Number(kpi_packCount));
- if (Number(kpi_suggestedPacks) > 0) {
- kpi_itemscount += kpi_suggestedPacks;
- }
- kpi_totalinwardqty += (Number(kpi_inwardPacks) * Number(kpi_packSize) * Number(kpi_packCount));
- kpi_totalinwardamount += (Number(kpi_inwardPacks) * Number(kpi_unitprice) * Number(kpi_packSize) * Number(kpi_packCount));
- }
- else {
- data = items[i];
- }
- let ItemId = data.ItemId;
- let html = "";
- if (instance._order.g_IsPurchasePlanning) {
- if ((items[i].SuggestedPacks) != 0 && (items[i].SuggestedPacks) != null && (items[i].SuggestedPacks) != undefined) {
- }
- else if (data.IsOfferAvailable)
- kpi_offeritems++;
- else
- kpi_ExtraItems++;
- html = instance.getItemDesign(items[i]);
- }
- else {
- html = instance.getItemDesign(data);
- }
- $("#" + instance.g_VisibleContainerId).find(".variant-item:last").after(html);
- let element = $("#" + instance.g_VisibleContainerId).find(".variant-item:last");
- if (instance._order.g_IsPurchasePlanning) {
- if (data.UnitPrice == 0 && instance.roundOff(items[i].SuggestedPacks, 0) > 0) {
- if (element.find(".tax-error").text() == "") {
- element.find(".tax-error").text("Unit price is zero").removeClass("text-danger").addClass("text-warning");
- }
- }
- }
- instance.allItemEvents(element);
- let SelItem = instance.g_SelectedItems.find(x => x.ItemId == ItemId);
- if (SelItem != null) {
- let element = $("#" + instance.g_VisibleContainerId).find(".variant-item:last");
- instance.updateItemsDesign(element, "BindItemList");
- if (SelItem.Packs == 0) {
- $("#" + instance.g_VisibleContainerId).find(element).find(".txtOrder_ItemCount").val("");
- }
- if (SelItem.Pieces == 0) {
- $("#" + instance.g_VisibleContainerId).find(element).find(".txtOrder_ItemPieceCount").val("");
- }
- instance.checkValidations(ItemId, false);
- }
- else {
- if (instance._order.g_IsPurchasePlanning && items[i].SuggestedPacks > 0) {
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(element).find(".txtOrder_ItemCount").val("");
- $("#" + instance.g_VisibleContainerId).find(element).find(".txtOrder_ItemPieceCount").val("");
- }
- }
- }
- }
- let pageHtml = "";
- pageHtml = '<div class="row mt-15 col-sm-12"> ' +
- '<div class="col-sm-3">' +
- '<span class="text-dark ml-30">Total : <span id="lblItemTotalRecords" class="">0</span></span>' +
- '</div>' +
- '<div class="col-sm-9 hidden" id="div_OrderItems_pagination">' +
- '<div id="ItemsListPagination" class="pagination custom-pagination pagination-rounded pull-right mr-20"></div>' +
- '</div>' +
- '</div>';
- $("#" + instance.g_VisibleContainerId).find(".variant-item:last").after(pageHtml);
- if (instance._order.g_IsPurchasePlanning) {
- $("#" + instance.g_VisibleContainerId).find("#span_SuggPurchaseOrderValue").text(kpi_totalamount);
- $("#" + instance.g_VisibleContainerId).find("#span_SuggPurchaseOrderVolume").text(kpi_itemscount);
- $("#" + instance.g_VisibleContainerId).find("#span_PurchaseOrderVolume").text(kpi_totalinwardqty);
- $("#" + instance.g_VisibleContainerId).find("#span_PurchaseOrderValue").text(kpi_totalinwardamount);
- $("#" + instance.g_VisibleContainerId).find("#span_OfferItems").text(kpi_offeritems);
- $("#" + instance.g_VisibleContainerId).find("#span_ExtraItems").text(kpi_ExtraItems);
- }
- if (instance._order.g_IsSC_to_PC) {
- for (let i = 0; i < instance.g_CartItems_New.length; i++) {
- let Itm = instance.g_CartItems_New[i];
- let elem = $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + Itm.ItemId);
- if (elem != undefined && elem.length > 0) {
- let row = instance.g_LoadedItems.find(x => x.ItemId == Itm.ItemId);
- if (row != undefined && row != null) {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#txt_editItemPrice").val(row.UnitPrice);
- }
- if (instance._order.g_InventoryApplyType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemCount").val(Itm.Quantity);
- }
- else {
- let onlyPacks = parseInt((Number(Itm.Quantity) / Number(row.PackCount * row.PackSize)).toString());
- let remainingQty = Itm.Quantity - (onlyPacks * row.PackCount * row.PackSize);
- let onlyPieces = remainingQty / row.PackSize;
- Itm.Packs = Number(onlyPacks);
- Itm.Pieces = Number(instance.roundOff(onlyPieces));
- $("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemCount").val(Itm.Packs);
- $("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemPieceCount").val(Itm.Pieces);
- }
- $("#" + instance.g_VisibleContainerId).find(elem).find(".btnOrder_DiscType").val(Itm.DiscountType);
- if (Itm.DiscountPercent > 0) {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#Ord_txtdiscount").val(Itm.DiscountPercent);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#Ord_txtdiscount").val(Itm.DiscountValue);
- }
- instance.updateItemsArray(elem, "Bind_SC_PC_CartItems", false, 0);
- }
- let cart_elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + Itm.ItemId);
- if (cart_elem.length == 0) {
- instance.addCartItem(Itm.ItemId);
- }
- cart_elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + Itm.ItemId);
- if (cart_elem != undefined && cart_elem.length > 0) {
- let row = instance.g_LoadedItems.find(x => x.ItemId == Itm.ItemId);
- if (row != undefined && row != null) {
- $("#" + instance.g_VisibleContainerId).find(cart_elem).find("#txt_editItemPrice").val(row.UnitPrice);
- }
- if (instance._order.g_InventoryApplyType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- $("#" + instance.g_VisibleContainerId).find(cart_elem).find(".txtOrder_ItemCount").val(Itm.Quantity);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(cart_elem).find(".txtOrder_ItemCount").val(Itm.Packs);
- $("#" + instance.g_VisibleContainerId).find(cart_elem).find(".txtOrder_ItemPieceCount").val(Itm.Pieces);
- }
- $("#" + instance.g_VisibleContainerId).find(cart_elem).find(".btnOrder_DiscType").val(Itm.DiscountType);
- if (Itm.DiscountPercent > 0) {
- $("#" + instance.g_VisibleContainerId).find(cart_elem).find("#Ord_txtdiscount").val(Itm.DiscountPercent);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(cart_elem).find("#Ord_txtdiscount").val(Itm.DiscountValue);
- }
- instance.updateItemsArray(cart_elem, "Bind_SC_PC_CartItems", false);
- }
- }
- }
- }
- updateItemsArray(elem, event, FromWidget = false, Qty = 0, Pcs = 0) {
- let instance = this;
- let OrderItemId = 0;
- let RefOrderItemId = 0;
- let SelectedUnitId = 1;
- let SelectedUnitName = "";
- let DefaultSize = 0;
- if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0 && !instance._order.g_IsSC_to_PC && !instance._order.g_IsPurchasePlanning && !instance._order.g_IsFromPurchaseIndent) {
- FromWidget = true;
- }
- let DiscountPercent = 0, DiscountValue = 0, DiscountAmount = 0, AfterDiscountValue = 0, BaseQty = 0, TaxGroupId = 0, TaxGroupName = "", TaxAmount = 0, StrTaxPercents = "", TaxRateAmount = 0, Amount = 0, IsCheckPendingItems = false, IsLeverageError = false, IsTaxError = false;
- let IsCalculateTax = instance._order.g_IsCalculateTax;
- let ItemIndex = instance.g_CartItems_New.length + 1;
- let optoutAmount = 0;
- let ItemId = Number($("#" + instance.g_VisibleContainerId).find(elem).find(".hfOrder_ItemId").val());
- let Packs = isNaN(Number($("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemCount").val())) ? 0 : Number($("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemCount").val());
- let Pieces = isNaN(Number($("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemPieceCount").val())) ? 0 : Number($("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemPieceCount").val());
- if (Pieces == 0 && Pcs > 0) {
- Pieces = Pcs;
- }
- let UnitPrice = Number($("#" + instance.g_VisibleContainerId).find(elem).find("#txt_editItemPrice").val());
- let UnitPriceWithOutTax = UnitPrice;
- let DiscountType = Number($("#" + instance.g_VisibleContainerId).find(elem).find(".btnOrder_DiscType").val());
- let IsExchangeDC = $("#" + instance.g_VisibleContainerId).find(elem).find(".chkItem_ExchangeDC").prop("checked");
- if (IsExchangeDC == undefined) {
- IsExchangeDC = false;
- }
- let IsAfterTax = $("#" + instance.g_VisibleContainerId).find(elem).find(".divAfterTax").is(':checked');
- if (DiscountType == 1) {
- DiscountPercent = Number($("#" + instance.g_VisibleContainerId).find(elem).find("#Ord_txtdiscount").val());
- DiscountAmount = Number($("#" + instance.g_VisibleContainerId).find(elem).find("#txt_editItemPrice").val()) * Number(DiscountPercent / 100);
- AfterDiscountValue = Number($("#" + instance.g_VisibleContainerId).find(elem).find("#txt_editItemPrice").val()) - Number(DiscountAmount);
- }
- else if (DiscountType == 2) {
- DiscountValue = Number($("#" + instance.g_VisibleContainerId).find(elem).find("#Ord_txtdiscount").val());
- DiscountAmount = DiscountValue;
- AfterDiscountValue = Number($("#" + instance.g_VisibleContainerId).find(elem).find("#txt_editItemPrice").val()) - DiscountValue;
- }
- let LoadedItems_Index = instance.g_LoadedItems.findIndex(x => x.ItemId == ItemId);
- let SelectedItems_Index = -1;
- if (instance.g_SelectedItems != undefined) {
- SelectedItems_Index = instance.g_SelectedItems.findIndex(x => x.ItemId == ItemId && x.RefItemIds == "");
- }
- let CartItems_Index = -1;
- if (instance.g_CartItems_New != undefined) {
- CartItems_Index = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId && x.RefItemIds == "");
- }
- let row = instance.g_LoadedItems[LoadedItems_Index];
- let PurPlan_Index = instance.g_PurPlanData.findIndex(x => x.ItemId == ItemId);
- let PurPlanRow = [];
- if (PurPlan_Index != -1) {
- PurPlanRow = instance.g_PurPlanData[PurPlan_Index];
- }
- else {
- PurPlanRow = row;
- }
- let PartNo = row.PartNo;
- if (PartNo == undefined || PartNo == "null" || PartNo == null) {
- PartNo = "";
- }
- let Items_up = instance.g_ItemsUnitPrice_New.find(x => x.ItemId == ItemId);
- Items_up.UnitPrice = UnitPrice;
- if (Items_up.length == 0) {
- instance.g_ItemsUnitPrice_New.push({
- ItemId: ItemId,
- UnitPrice: UnitPrice,
- TaxRateAmount: TaxRateAmount
- });
- }
- let Quantity = 0;
- let UOMQuantity = 0;
- if (instance._order.g_InventoryApplyType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- BaseQty = Number(Packs);
- Quantity = Packs;
- let onlyPacks = parseInt((Number(Quantity) / Number(row.PackCount * row.PackSize)).toString());
- let remainingQty = Quantity - (onlyPacks * row.PackCount * row.PackSize);
- let onlyPieces = remainingQty / row.PackSize;
- Packs = Number(onlyPacks);
- Pieces = Number(instance.roundOff(onlyPieces));
- }
- else {
- if (Qty != 0) {
- BaseQty = Qty;
- Quantity = Qty;
- }
- else {
- BaseQty = Number(row.PackCount) * Number(row.PackSize) * Number(Packs) + (Pieces * row.PackSize);
- Quantity = ((row.PackCount * row.PackSize) * Packs) + (Pieces * row.PackSize);
- }
- }
- if (row.IsMultipleUOMs) {
- SelectedUnitId = Number($("#" + instance.g_VisibleContainerId).find(elem).find("#ddl_MultipleUOMs_" + ItemId).val());
- if (SelectedUnitId != 1 && SelectedUnitId != 0) {
- let MultipleUOM = row.MultipleUOMs.find(x => x.SchemaDetailId == SelectedUnitId);
- UOMQuantity = instance.roundOff(Quantity * (MultipleUOM.AlternateSize / MultipleUOM.DefaultSize));
- BaseQty = UOMQuantity;
- DefaultSize = MultipleUOM.DefaultSize;
- SelectedUnitName = MultipleUOM.AlternateUnitName;
- }
- }
- if (row.IsManualUOM && instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales) {
- SelectedUnitId = Number($("#" + instance.g_VisibleContainerId).find(elem).find("#ddl_ManualUOMs_" + ItemId).val());
- if (isNaN(SelectedUnitId)) {
- SelectedUnitId = 1;
- }
- UOMQuantity = Number($("#" + instance.g_VisibleContainerId).find(elem).find("#txt_ManualConversionQty").val());
- if (UOMQuantity <= 0 || isNaN(UOMQuantity)) {
- UOMQuantity = Packs;
- }
- BaseQty = UOMQuantity;
- SelectedUnitName = $("#ddl_ManualUOMs_" + ItemId + " option:selected").text();
- }
- Quantity = instance.roundOffIgnoreZerosAfterDecimal(Quantity);
- UOMQuantity = instance.roundOffIgnoreZerosAfterDecimal(UOMQuantity);
- if (event == "Plus" || event == "Packs" || event == "Pieces") {
- IsCheckPendingItems = true;
- }
- else {
- if (Quantity == 0 && !FromWidget) {
- IsCheckPendingItems = true;
- }
- }
- if (SelectedItems_Index != -1) {
- if (event == "Plus" || event == "Packs" || event == "Pieces" || event == "ApplyOffer") {
- IsCheckPendingItems = instance.g_SelectedItems[SelectedItems_Index].IsCheckPendingItems;
- let qty = instance.g_SelectedItems[SelectedItems_Index].BaseQty;
- if (IsCheckPendingItems && qty > 0 && !FromWidget) {
- IsCheckPendingItems = false;
- }
- }
- ItemIndex = instance.g_SelectedItems[SelectedItems_Index].ItemIndex;
- OrderItemId = instance.g_SelectedItems[SelectedItems_Index].OrderItemId;
- RefOrderItemId = instance.g_SelectedItems[SelectedItems_Index].RefOrderItemId;
- $("#" + instance.g_VisibleContainerId).find(elem).find(".tax-error").text("");
- $("#" + instance.g_VisibleContainerId).find(elem).find("#LeverageErrorTxt").addClass("hidden");
- }
- if (instance.g_IsEnableCompositePiecePrice) {
- Amount = (UnitPriceWithOutTax * Number(BaseQty)) + Number(row.TaxRate);
- if (Number(BaseQty) == 0)
- Amount = 0;
- UnitPrice = instance.roundOffIgnoreZerosAfterDecimal(row.CompositePiecePrice);
- }
- else if (instance.g_IsEnableCompositePrice) {
- let amnt = Number(UnitPriceWithOutTax) * Number(row.TaxPercentage) / 100;
- TaxRateAmount = Number(UnitPriceWithOutTax) + Number(amnt);
- Amount = Number(BaseQty) * TaxRateAmount;
- UnitPrice = instance.roundOffIgnoreZerosAfterDecimal(row.CompositePrice);
- }
- else if (instance.g_IsEnablePiecePrice) {
- Amount = Number(BaseQty) * UnitPriceWithOutTax;
- UnitPrice = instance.roundOffIgnoreZerosAfterDecimal(row.PiecePrice);
- }
- else {
- Amount = Number(BaseQty) * UnitPriceWithOutTax;
- }
- Items_up.TaxRateAmount = TaxRateAmount;
- let AssessableAmount = Number(Amount);
- let discVal = Number(DiscountValue) * Number(BaseQty);
- let discPercent = Number(DiscountPercent);
- let DiscAmount = Number((Amount * discPercent) / 100) + Number(discVal);
- let discAmt = DiscAmount + Number(optoutAmount);
- AssessableAmount = Number(AssessableAmount) - Number(discAmt);
- let AmountWithDiscount = instance.roundOffIgnoreZerosAfterDecimal(Number(Amount) - Number(discAmt));
- if (IsCalculateTax) {
- if (instance.g_IsEnableCompositePiecePrice || instance.g_IsEnableCompositePrice) {
- if (row.TaxGroupId == 0) {
- IsTaxError = true;
- }
- else {
- TaxGroupId = row.TaxGroupId;
- TaxGroupName = row.TaxGroupName;
- for (let p = 0; p < row.TaxPercentList.length; p++) {
- let percen = row.TaxPercentList[p];
- let tax = AssessableAmount * percen.Percentage / 100;
- TaxAmount += tax;
- }
- StrTaxPercents = row.strTaxPercents;
- instance.getPriceTypeValues(ItemId, Packs, Pieces);
- if (instance.g_IsEnablePiecePrice) {
- UnitPrice = row.PiecePrice;
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.PiecePrice;
- }
- else if (instance.g_IsEnableCompositePrice) {
- UnitPrice = row.CompositePrice;
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.CompositePrice;
- }
- else if (instance.g_IsEnableCompositePiecePrice) {
- UnitPrice = row.CompositePiecePrice;
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.Both;
- }
- else {
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.None;
- }
- }
- }
- }
- else {
- $("#" + instance.g_VisibleContainerId).find("#TotalTax").addClass("hidden");
- $("#" + instance.g_VisibleContainerId).find(".divCustomProperties_istaxinclusive").addClass("hidden");
- }
- let Description = "";
- if (instance.g_FromWidgetEditOrderItemId > 0) {
- Description = $("#" + instance.g_VisibleContainerId).find("#txt_Description").val().toString();
- }
- else {
- Description = $("#" + instance.g_VisibleContainerId).find(elem).find("#txt_Description").val().toString();
- }
- if (Description == "") {
- Description = row.Description != null ? row.Description : "";
- }
- if (event == "PendingPopCancel") {
- IsCheckPendingItems = true;
- }
- let ItemData = {
- OrderItemId: OrderItemId,
- ItemIndex: ItemIndex,
- ItemId: ItemId,
- HSNId: row.HSNId,
- ItemName: row.ItemName,
- Packs: Packs,
- Pieces: Pieces,
- PriceListId: row.PriceListId,
- UnitPrice: UnitPrice,
- UnitPriceWithOutTax: UnitPriceWithOutTax,
- ExpectedPrice: row.UnitPrice,
- ActualPrice: row.UnitPrice,
- PackCount: row.PackCount,
- PackSize: row.PackSize,
- UnitName: row.UnitName,
- Quantity: Quantity,
- SKU: row.SKU,
- PartNo: PartNo,
- Amount: Amount,
- AmountWithDiscount: AmountWithDiscount,
- DiscountPercent: DiscountPercent,
- DiscountValue: DiscountValue,
- DiscountType: DiscountType,
- DiscountAmount: DiscountAmount,
- ItemValueAfterDiscount: AfterDiscountValue,
- StrTaxPercents: StrTaxPercents,
- AvailableQuantity: row.AvailableQuantity,
- AvailablePacks: row.AvailablePacks,
- AvailablePieces: row.AvailablePieces,
- TotalAvailablePieces: row.TotalAvailablePieces,
- ExchangeDC: IsExchangeDC,
- IsAfterTax: IsAfterTax,
- BaseQty: BaseQty,
- IsFocItem: false,
- optoutAmount: optoutAmount,
- TaxGroupId: TaxGroupId,
- TaxGroupName: TaxGroupName,
- TaxAmount: TaxAmount,
- TaxRateAmount: TaxRateAmount,
- TaxRate: row.TaxRate,
- TaxPercentage: row.TaxPercentage,
- IsOfferAvailable: row.IsOfferAvailable,
- Description: Description == undefined ? "" : Description,
- Discountable: row.Discountable,
- PiecePrice: row.PiecePrice,
- CompositePrice: row.CompositePrice,
- CompositePiecePrice: row.CompositePiecePrice,
- IsCheckPendingItems: IsCheckPendingItems,
- IsError: false,
- ErrorMsg: "",
- ErrorClass: "text-danger",
- IsTaxError: IsTaxError,
- IsLeverageError: IsLeverageError,
- IsFocAdded: false,
- RefOrderItemId: RefOrderItemId,
- RefItemIds: "",
- RefItemSKUs: "",
- FocItemIds: "",
- DiscountGroupId: 0,
- IsOfferDiscountApplied: false,
- AppliedOfferVolume: 0,
- AppliedPlanVolumeId: 0,
- AppliedOfferId: 0,
- optoutOfferGroupId: 0,
- SuggestedPacks: PurPlanRow.SuggestedPacks,
- MinPacks: PurPlanRow.MinPacks,
- AvgPacks: PurPlanRow.AvgPacks,
- InwardOrderPacks: PurPlanRow.InwardOrderPacks,
- OutwardOrderPacks: PurPlanRow.OutwardOrderPacks,
- IsManualUOM: row.IsManualUOM,
- UOMs: row.UOMs,
- IsMultipleUOMs: row.IsMultipleUOMs,
- UOMSchemaId: row.UOMSchemaId,
- MultipleUOMs: row.MultipleUOMs,
- SelectedUnitId: SelectedUnitId,
- SelectedUnitName: SelectedUnitName == "" ? row.UnitName : SelectedUnitName,
- DefaultSize: DefaultSize,
- IsBoMAvailable: row.IsBoMAvailable,
- IsSpecialPrice: row.IsSpecialPrice,
- ConversionQuantity: UOMQuantity,
- RowTotal: 0,
- RowDiscount: 0,
- TaxTotal: 0
- };
- if (SelectedItems_Index == -1) {
- instance.g_SelectedItems.push(ItemData);
- }
- else {
- instance.g_SelectedItems[SelectedItems_Index] = ItemData;
- }
- if (CartItems_Index == -1) {
- instance.g_CartItems_New.push(ItemData);
- }
- else {
- instance.g_CartItems_New[CartItems_Index] = ItemData;
- }
- let ItemElm = $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + ItemId);
- if (ItemElm.length > 0) {
- instance.updateItemsDesign(ItemElm, event);
- }
- let IsCart = false;
- if ($("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").is(":visible")) {
- IsCart = true;
- }
- if (!FromWidget) {
- if (instance.g_CartItems_New.length == 0) {
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").html('<li id="0" class="cartitem list-group-item col-xs-12 hidden clear no-border"></li> <li class="list-group-item col-xs-12 no-border EmptyCartLi"><strong>Your Shopping Cart is empty.</strong></li>');
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(".EmptyCartLi").remove();
- }
- if ($("#" + instance.g_VisibleContainerId).find("#cartItemsSearch").val() != undefined) {
- let value = $("#" + instance.g_VisibleContainerId).find("#cartItemsSearch").val().toString().toLowerCase();
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart li:not(:first-child)").filter(function () {
- $("#" + instance.g_VisibleContainerId).find(this).toggle($("#" + instance.g_VisibleContainerId).find(this).text().toLowerCase().indexOf(value) > -1);
- });
- }
- if (IsCheckPendingItems && $("#" + instance.g_VisibleContainerId).find(".bootbox-confirm").length == 0 && BaseQty != 0 && (instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales || instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Purchase)) {
- if (!IsTaxError && event != "PendingPopCancel") {
- instance.checkPendingPopup(ItemId, CartItems_Index, FromWidget);
- }
- }
- else {
- if (CartItems_Index != -1) {
- let Cart_elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId);
- if (Cart_elem.length > 0 && !FromWidget) {
- let evnt = "EditCartItem";
- if (event == "RefreshAllItems_InventoryClickEvents") {
- evnt = event;
- }
- instance.updateItemsDesign(Cart_elem, evnt, true);
- }
- }
- else {
- instance.addCartItem(ItemId);
- }
- }
- }
- else {
- if (IsCheckPendingItems && $("#" + instance.g_VisibleContainerId).find(".bootbox-confirm").length == 0) {
- if (!IsTaxError && event != "PendingPopCancel") {
- instance.checkPendingPopup(ItemId, CartItems_Index, FromWidget);
- }
- }
- }
- if (BaseQty != 0) {
- instance.checkValidations(ItemId, false);
- instance.checkValidations(ItemId, true);
- }
- else {
- instance.checkEnablePieces();
- instance.checkEnablePacks();
- }
- if (!instance._order.g_IsPointsOrder && (IsCart || FromWidget || instance.g_FromContinueShopping)) {
- if (row.IsOfferAvailable && !FromWidget) {
- instance.checkOffers(FromWidget, "UpdateItemsArray");
- }
- else if (FromWidget) {
- instance.checkOffers(FromWidget, "UpdateItemsArray");
- }
- else {
- if (IsCart || instance._order.g_IsPurchasePlanning) {
- if (event != "PurPlan_AllItems") {
- instance.getTotals(ItemId);
- }
- }
- }
- }
- else {
- if (IsCart || instance._order.g_IsPurchasePlanning) {
- if (event != "PurPlan_AllItems") {
- if (BaseQty != 0) {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".chk_PurPlanItem").prop("checked", true);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".chk_PurPlanItem").prop("checked", false);
- }
- instance.getTotals(ItemId);
- }
- }
- }
- if (event == "FromWidget") {
- if (SelectedItems_Index != -1) {
- instance.g_SelectedItems[SelectedItems_Index].IsCheckPendingItems = true;
- }
- if (CartItems_Index == -1) {
- instance.g_CartItems_New[CartItems_Index].IsCheckPendingItems = true;
- }
- }
- instance.g_CartItems_New.filter(x => x.BaseQty == 0).forEach(function (c) {
- let ItemId = c.ItemId;
- let ItemElm = $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + ItemId);
- let CartElm = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId);
- $("#" + instance.g_VisibleContainerId).find(ItemElm).find(".divOrders_ItemCount").removeClass("floating-label-form-group-with-value");
- $("#" + instance.g_VisibleContainerId).find(CartElm).find(".divOrders_ItemCount").removeClass("floating-label-form-group-with-value");
- });
- }
- getInventoryDesign(ItemId, IsCart, SuggestedPacks = 0, RefItemIds) {
- let instance = this;
- let html = "";
- let InvType = "", fltngclass_Cartons = "", fltngclass_Pieces = "", PP_Cartons = "", PP_Pieces = "", IsFocItem = false, DisableQuantityTxtBox = "", HideMinusPlusBtns = "";
- if (SuggestedPacks != 0) {
- PP_Cartons = SuggestedPacks.toString();
- }
- let CartItem_Index = -1;
- CartItem_Index = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId && x.RefItemIds == RefItemIds);
- let InventoryTypeId = instance._order.g_InventoryApplyType;
- let CartItem = instance.g_CartItems_New[CartItem_Index];
- if (CartItem != undefined) {
- PP_Cartons = CartItem.Packs.toString();
- PP_Pieces = CartItem.Pieces.toString();
- IsFocItem = CartItem.IsFocItem;
- if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- PP_Cartons = CartItem.Quantity.toString();
- }
- }
- if (PP_Cartons == "0") {
- PP_Cartons = "";
- }
- if (PP_Cartons != "") {
- fltngclass_Cartons = "floating-label-form-group-with-value";
- }
- if (PP_Pieces == "0") {
- PP_Pieces = "";
- }
- if (PP_Pieces != "") {
- fltngclass_Pieces = "floating-label-form-group-with-value";
- }
- if (IsFocItem) {
- DisableQuantityTxtBox = "disabled style='cursor:not-allowed'";
- HideMinusPlusBtns = "hidden";
- }
- let IsEnablePacks = instance.g_IsEnablePacks, IsEnablePieces = instance.g_IsEnablePieces;
- if (IsFocItem) {
- InventoryTypeId = Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity;
- IsEnablePacks = true;
- IsEnablePieces = false;
- }
- if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Packs || InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Pieces || InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.PacksAndPieces) {
- if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Pieces && !instance.g_IsEnablePacks) {
- $("#" + instance.g_VisibleContainerId).find("#spn_picesTitle").removeClass("hidden").removeClass("col-sm-6").addClass("col-sm-12").removeClass("pr-90");
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").addClass("hidden").removeClass("pl-40");
- $("#" + instance.g_VisibleContainerId).find(".ItemDetails").addClass("col-sm-8").removeClass("col-sm-6");
- $("#" + instance.g_VisibleContainerId).find(".InventoryTypesTextboxes").addClass("col-sm-4").removeClass("col-sm-6");
- }
- else if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Packs && !instance.g_IsEnablePieces) {
- $("#" + instance.g_VisibleContainerId).find("#spn_picesTitle").addClass("hidden").removeClass("pr-90");
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").removeClass("hidden").removeClass("col-sm-6").addClass("col-sm-12").removeClass("pl-40");
- $("#" + instance.g_VisibleContainerId).find(".ItemDetails").addClass("col-sm-8").removeClass("col-sm-6");
- $("#" + instance.g_VisibleContainerId).find(".InventoryTypesTextboxes").addClass("col-sm-4").removeClass("col-sm-6");
- }
- else if (instance.g_IsEnablePacks && instance.g_IsEnablePieces) {
- $("#" + instance.g_VisibleContainerId).find("#spn_picesTitle").removeClass("hidden").removeClass("col-sm-12").addClass("col-sm-6").addClass("pr-90");
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").removeClass("hidden").removeClass("col-sm-12").addClass("col-sm-6").addClass("pl-40");
- $("#" + instance.g_VisibleContainerId).find(".ItemDetails").removeClass("col-sm-8").addClass("col-sm-6");
- $("#" + instance.g_VisibleContainerId).find(".InventoryTypesTextboxes").removeClass("col-sm-4").addClass("col-sm-6");
- }
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").text("Cartons");
- $("#" + instance.g_VisibleContainerId).find("#spn_picesTitle").text("Pieces");
- }
- else if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").text("Quantity");
- $("#" + instance.g_VisibleContainerId).find("#spn_picesTitle").addClass("hidden");
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").removeClass("hidden").removeClass("col-sm-6").addClass("col-sm-12");
- }
- if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- InvType = "Quantity";
- }
- else if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Packs) {
- InvType = "Cartons";
- }
- else if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Pieces) {
- InvType = "Pieces";
- }
- let cartItemQtyClass = "";
- if (IsCart) {
- cartItemQtyClass = "_editCartItemQuantity";
- }
- if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- html += '<div class="col-sm-12 ' + cartItemQtyClass + '">' +
- '<div class="floating-label-form-group defaultSelectedCartons divOrders_ItemCount ' + fltngclass_Cartons + '">' +
- '<label class="text-center">' + InvType + '</label>' +
- '<div class="input-group" id="div_Cartons">' +
- '<span class="input-group-prepend">' +
- '<a href="javascript:;" class="input-group-addon btn quantity-minus "' + HideMinusPlusBtns + ' draggable="false"><i class="fa fa-minus"></i></a>' +
- '</span>' +
- '<input type="text" id="txt_Cartons" ' + DisableQuantityTxtBox + 'class="form-control text-center txtOrder_ItemCount floating-label-control" inputmode="numeric" onpaste = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().isNumberKey(event)" oninput = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" data-isdynamic="false" placeholder="' + InvType + '" data-placeholder="' + InvType + '" data-label="' + InvType + '"value=' + PP_Cartons + '>' +
- '<span class="input-group-append">' +
- '<a href="javascript:;" class="quantity-plus input-group-addon btn "' + HideMinusPlusBtns + ' draggable="false"><i class="fa fa-plus"></i></a>' +
- '</span>' +
- '</div>' +
- '</div>' +
- '</div>';
- }
- else if (IsEnablePacks && !IsEnablePieces && InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Packs) {
- html += '<div class="col-sm-12 ' + cartItemQtyClass + '">' +
- '<div class="floating-label-form-group defaultSelectedCartons divOrders_ItemCount ' + fltngclass_Cartons + '">' +
- '<label class="text-center">' + InvType + '</label>' +
- '<div class="input-group" id="div_Cartons">' +
- '<span class="input-group-prepend">' +
- '<a href="javascript:;" class="input-group-addon btn quantity-minus "' + HideMinusPlusBtns + ' draggable="false"><i class="fa fa-minus"></i></a>' +
- '</span>' +
- '<input type="text" id="txt_Cartons" ' + DisableQuantityTxtBox + 'class="form-control text-center txtOrder_ItemCount floating-label-control" inputmode="numeric" onpaste = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().isNumberKey(event)" oninput = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().isNumberKey(event)" data-isdynamic="false" placeholder="' + InvType + '" data-placeholder="' + InvType + '" data-label="' + InvType + '"value=' + PP_Cartons + '>' +
- '<span class="input-group-append">' +
- '<a href="javascript:;" class="quantity-plus input-group-addon btn "' + HideMinusPlusBtns + ' draggable="false"><i class="fa fa-plus"></i></a>' +
- '</span>' +
- '</div>' +
- '</div>' +
- '</div>';
- }
- else if (!IsEnablePacks && IsEnablePieces) {
- html += '<div class="col-sm-12 ' + cartItemQtyClass + '">' +
- '<div class="floating-label-form-group defaultSelectedPieces divOrders_ItemPieceCount ' + fltngclass_Pieces + '">' +
- '<label class="text-center">' + InvType + '</label>' +
- '<div class="input-group" id="div_Pieces">' +
- '<span class="input-group-prepend">' +
- '<a href="javascript:;" class="input-group-addon btn quantity-minus" draggable="false"><i class="fa fa-minus"></i></a>' +
- '</span>' +
- '<input type="text" id="txt_Pieces" class="form-control text-center txtOrder_ItemPieceCount floating-label-control" inputmode="numeric" data-isdynamic="false" placeholder="' + InvType + '" data-placeholder="' + InvType + '" data-label="' + InvType + '" oninput="return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" value=' + PP_Pieces + '>' +
- '<span class="input-group-append">' +
- '<a href="javascript:;" class="quantity-plus input-group-addon btn" draggable="false"><i class="fa fa-plus"></i></a>' +
- '</span>' +
- '</div>' +
- '</div>' +
- '</div>';
- }
- if ((IsEnablePacks && IsEnablePieces) && InventoryTypeId != Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- html += '<div class="col-sm-12 ' + cartItemQtyClass + '"><div class="row"><div class="col-6">' +
- '<div class="floating-label-form-group defaultSelectedCartons divOrders_ItemCount ' + fltngclass_Cartons + '">' +
- '<label class="text-center pl-40">Cartons</label>' +
- '<div class="input-group" id="div_Cartons">' +
- '<span class="input-group-prepend">' +
- '<a href="javascript:;" class="input-group-addon btn quantity-minus" draggable="false"><i class="fa fa-minus"></i></a>' +
- '</span>' +
- '<input type="text" id="txt_Cartons" class="form-control text-center txtOrder_ItemCount floating-label-control" inputmode="numeric" onpaste = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().isNumberKey(event)" oninput = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().isNumberKey(event)" data-isdynamic="false" placeholder="Cartons" data-placeholder="Cartons" data-label="Cartons" value=' + PP_Cartons + '>' +
- '</div>' +
- '</div>' +
- ' </div>';
- html +=
- '<div class="col-6 ' + cartItemQtyClass + '">' +
- '<div class="floating-label-form-group defaultSelectedPieces divOrders_ItemPieceCount ' + fltngclass_Pieces + '"> ' +
- '<label class="text-center pr-20">Pieces</label>' +
- '<div class="input-group" id="div_Pieces">' +
- '<input type="text" id="txt_Pieces" class="form-control text-center floating-label-control txtOrder_ItemPieceCount" inputmode="numeric" data-isdynamic="false" style = "margin-left: 13px;" placeholder="Pieces" data-placeholder="Pieces" data-label="Pieces" oninput="return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" value=' + PP_Pieces + '>' +
- '<span class="input-group-append">' +
- '<a href="javascript:;" class="quantity-plus input-group-addon btn" draggable="false"><i class="fa fa-plus"></i></a>' +
- '</span>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</div>';
- }
- html += '</div>';
- return html;
- }
- getInventoryDesignWithTokens_PurchasePlan() {
- let instance = this;
- let html = "";
- let InvType = "";
- let InventoryTypeId = instance._order.g_InventoryApplyType;
- let IsEnablePacks = instance.g_IsEnablePacks, IsEnablePieces = instance.g_IsEnablePieces;
- if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Packs || InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Pieces || InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.PacksAndPieces) {
- if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Pieces && !instance.g_IsEnablePacks) {
- $("#" + instance.g_VisibleContainerId).find("#spn_picesTitle").removeClass("hidden").removeClass("col-sm-6").addClass("col-sm-12").removeClass("pr-90");
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").addClass("hidden").removeClass("pl-40");
- $("#" + instance.g_VisibleContainerId).find(".ItemDetails").addClass("col-sm-8").removeClass("col-sm-6");
- $("#" + instance.g_VisibleContainerId).find(".InventoryTypesTextboxes").addClass("col-sm-4").removeClass("col-sm-6");
- }
- else if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Packs && !instance.g_IsEnablePieces) {
- $("#" + instance.g_VisibleContainerId).find("#spn_picesTitle").addClass("hidden").removeClass("pr-90");
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").removeClass("hidden").removeClass("col-sm-6").addClass("col-sm-12").removeClass("pl-40");
- $("#" + instance.g_VisibleContainerId).find(".ItemDetails").addClass("col-sm-8").removeClass("col-sm-6");
- $("#" + instance.g_VisibleContainerId).find(".InventoryTypesTextboxes").addClass("col-sm-4").removeClass("col-sm-6");
- }
- else if (instance.g_IsEnablePacks && instance.g_IsEnablePieces) {
- $("#" + instance.g_VisibleContainerId).find("#spn_picesTitle").removeClass("hidden").removeClass("col-sm-12").addClass("col-sm-6").addClass("pr-90");
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").removeClass("hidden").removeClass("col-sm-12").addClass("col-sm-6").addClass("pl-40");
- $("#" + instance.g_VisibleContainerId).find(".ItemDetails").removeClass("col-sm-8").addClass("col-sm-6");
- $("#" + instance.g_VisibleContainerId).find(".InventoryTypesTextboxes").removeClass("col-sm-4").addClass("col-sm-6");
- }
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").text("Cartons");
- $("#" + instance.g_VisibleContainerId).find("#spn_picesTitle").text("Pieces");
- }
- else if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").text("Quantity");
- $("#" + instance.g_VisibleContainerId).find("#spn_picesTitle").addClass("hidden");
- $("#" + instance.g_VisibleContainerId).find("#spn_InventoryTitle").removeClass("hidden").removeClass("col-sm-6").addClass("col-sm-12");
- }
- if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- InvType = "Quantity";
- }
- else if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Packs) {
- InvType = "Cartons";
- }
- else if (InventoryTypeId == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Pieces) {
- InvType = "Pieces";
- }
- if (IsEnablePacks && !IsEnablePieces) {
- html += '<div class="col-sm-12">' +
- '<div class="floating-label-form-group defaultSelectedCartons divOrders_ItemCount {{fltngclass_Cartons}}">' +
- '<label class="text-center">' + InvType + '</label>' +
- '<div class="input-group" id="div_Cartons">' +
- '<span class="input-group-prepend">' +
- '<a href="javascript:;" class="input-group-addon btn quantity-minus" draggable="false"><i class="fa fa-minus"></i></a>' +
- '</span>' +
- '<input type="text" id="txt_Cartons" class="form-control text-center txtOrder_ItemCount floating-label-control" inputmode="numeric" onpaste = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().isNumberKey(event)" oninput = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().isNumberKey(event)" data-isdynamic="false" placeholder="' + InvType + '" data-placeholder="' + InvType + '" data-label="' + InvType + '" value={{PP_Cartons}}>' +
- '<span class="input-group-append">' +
- '<a href="javascript:;" class="quantity-plus input-group-addon btn" draggable="false"><i class="fa fa-plus"></i></a>' +
- '</span>' +
- '</div>' +
- '</div>' +
- '</div>';
- }
- else if (!IsEnablePacks && IsEnablePieces) {
- html += '<div class="col-sm-12">' +
- '<div class="floating-label-form-group defaultSelectedPieces divOrders_ItemPieceCount {{fltngclass_Pieces}}">' +
- '<label class="text-center">' + InvType + '</label>' +
- '<div class="input-group" id="div_Pieces">' +
- '<span class="input-group-prepend">' +
- '<a href="javascript:;" class="input-group-addon btn quantity-minus" draggable="false"><i class="fa fa-minus"></i></a>' +
- '</span>' +
- '<input type="text" id="txt_Pieces" class="form-control text-center txtOrder_ItemPieceCount floating-label-control" inputmode="numeric" data-isdynamic="false" placeholder="' + InvType + '" data-placeholder="' + InvType + '" data-label="' + InvType + '" oninput="return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" value={{PP_Pieces}}>' +
- '<span class="input-group-append">' +
- '<a href="javascript:;" class="quantity-plus input-group-addon btn" draggable="false"><i class="fa fa-plus"></i></a>' +
- '</span>' +
- '</div>' +
- '</div>' +
- '</div>';
- }
- if (IsEnablePacks && IsEnablePieces) {
- html += '<div class="col-sm-12"><div class="row"><div class="col-6">' +
- '<div class="floating-label-form-group defaultSelectedCartons divOrders_ItemCount {{fltngclass_Cartons}}">' +
- '<label class="text-center pl-40">Cartons</label>' +
- '<div class="input-group" id="div_Cartons">' +
- '<span class="input-group-prepend">' +
- '<a href="javascript:;" class="input-group-addon btn quantity-minus" draggable="false"><i class="fa fa-minus"></i></a>' +
- '</span>' +
- '<input type="text" id="txt_Cartons" class="form-control text-center txtOrder_ItemCount floating-label-control" inputmode="numeric" onpaste = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().isNumberKey(event)" oninput = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().isNumberKey(event)" data-isdynamic="false" placeholder="Cartons" data-placeholder="Cartons" data-label="Cartons" value={{PP_Cartons}}>' +
- '</div>' +
- '</div>' +
- ' </div>';
- html +=
- '<div class="col-6">' +
- '<div class="floating-label-form-group defaultSelectedPieces divOrders_ItemPieceCount {{fltngclass_Pieces}}"> ' +
- '<label class="text-center pr-20">Pieces</label>' +
- '<div class="input-group" id="div_Pieces">' +
- '<input type="text" id="txt_Pieces" class="form-control text-center floating-label-control txtOrder_ItemPieceCount" inputmode="numeric" data-isdynamic="false" style="margin-left: 13px;" placeholder="Pieces" data-placeholder="Pieces" data-label="Pieces" oninput="return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" value={{PP_Pieces}}>' +
- '<span class="input-group-append">' +
- '<a href="javascript:;" class="quantity-plus input-group-addon btn" draggable="false"><i class="fa fa-plus"></i></a>' +
- '</span>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</div>';
- }
- html += '</div>';
- return html;
- }
- getItemDesign(res, FromWidget = false, IsCart = false) {
- let instance = this;
- let html = "";
- let data = res;
- let ItemId = data.ItemId;
- let InventoryType = instance._order.g_InventoryApplyType;
- let url = '';
- let ItemImg = "";
- let LoadedItemIndex = instance.g_LoadedItems.findIndex(x => x.ItemId == ItemId);
- if (LoadedItemIndex != -1) {
- url = instance.g_LoadedItems[LoadedItemIndex].ImageUrl;
- if (url == "" || url == undefined || url == null) {
- ItemImg = ``;
- }
- else {
- ItemImg = `<img class="avatar" style="width:70px;height:70px;" onerror="ReloadImage(event)" data-dynamic="1" src="` + url + `">`;
- }
- }
- else {
- if (data.ImageUrl == "" || data.ImageUrl == undefined || data.ImageUrl == null) {
- ItemImg = ``;
- }
- else {
- url = data.ImageUrl;
- ItemImg = `<img class="avatar" style="width:70px;height:70px;" onerror="ReloadImage(event)" data-dynamic="1" src="` + url + `">`;
- }
- }
- let hidden = "";
- let OrderQuantity = "";
- let multiplevalue = "";
- let Mod_UnitPrice = 0;
- let Items_up = instance.g_ItemsUnitPrice_New.filter(x => x.ItemId == data.ItemId);
- if (Items_up.length == 0) {
- Mod_UnitPrice = data.UnitPrice;
- instance.g_ItemsUnitPrice_New.push({
- ItemId: ItemId,
- UnitPrice: data.UnitPrice,
- TaxRateAmount: data.TaxRateAmount
- });
- }
- else {
- Mod_UnitPrice = Items_up[0].UnitPrice;
- }
- if (instance._order.g_IsPurchasePlanning) {
- if ((res.SuggestedPacks) != 0 && (res.SuggestedPacks) != null && (res.SuggestedPacks) != undefined) {
- let unitprice = Number(Mod_UnitPrice);
- let packCount = Number(data.PackCount);
- let packSize = Number(data.PackSize);
- let baseqty = packCount * packSize * res.SuggestedPacks;
- OrderQuantity = " X " + (baseqty);
- multiplevalue = " = " + (unitprice * baseqty);
- }
- }
- let LiClass = "variant-item variant-addeditem variant-addeditem-" + ItemId;
- let EditUnitPriceClass = 'editItemPriceAccordion_';
- let AvailClass = "ItemAvailability";
- let ExchangeClass = "chkItem_ExchangeDC_" + ItemId;
- let HideDeleteBtn = "";
- let RefItemIds = data.RefItemIds;
- if (RefItemIds == undefined) {
- RefItemIds = "";
- }
- if (IsCart) {
- LiClass = "cartitem cartitem-" + ItemId;
- EditUnitPriceClass = 'editCartItemPriceAccordion_';
- AvailClass = "CartAvailability";
- ExchangeClass = "chkCartItem_ExchangeDC_" + ItemId;
- if (data.IsFocItem) {
- HideDeleteBtn = "hidden";
- if (RefItemIds != "") {
- LiClass = "cartitem cartitem-" + ItemId + "-" + RefItemIds.replace(/,/g, "-");
- }
- }
- }
- else if (FromWidget) {
- if (Bizgaze.Apps.Transact.Controls.AddOrderItems.Instance().g_Edit_OrderItemId > 0) {
- HideDeleteBtn = "hidden";
- }
- if (RefItemIds != "") {
- LiClass = "variant-item variant-addeditem variant-addeditem-" + ItemId + "-" + RefItemIds.replace(/,/g, "-");
- }
- }
- html = '<li id="' + ItemId + '" class="list-group-item ' + LiClass + ' li no-border">' +
- '<input type="hidden" class="hfOrder_ItemId" value="' + ItemId + '" />' +
- '<input type="hidden" class="hfOrder_RefItemId" value="' + RefItemIds + '" />' +
- '<input type="hidden" class="hfOrder_ItemName" value="' + data.ItemName + '" />' +
- '<input type="hidden" class="hfOrder_ItemSKU" value="' + data.SKU + '" />';
- let DivClass = 'col-sm-8';
- let InventoryTypeDivClass = 'col-sm-4';
- if (instance.g_IsEnablePacks && instance.g_IsEnablePieces) {
- DivClass = 'col-sm-6';
- InventoryTypeDivClass = 'col-sm-6';
- }
- if (`${ItemImg}`.length == 0) {
- html += `<div class="row position-relative">
- <div class="position-absolute t-0 z-index-1" style="right: 10px;"><a href="javascript:;" class="btn btn-icon btn-flush-biz-theme btn-rounded flush-soft-hover d-30 cart-item-remove d-none"><span class="btn-icon-wrap"><i class="fa fa-times text-danger"></i></span></a><input type="checkbox" class="cart-item-chk d-none" id="cartItemChk_${ItemId}" style="transform: scale(1.3);"/></div>
- <div class="ItemDetails ${DivClass} d-flex" id="ItemDetails">
- <div class="img_div_tag_${ItemId} d-none"><a class="pull-left" style="cursor:pointer;height:80px; width:80px;"onclick="Bizgaze.Apps.Transact.Controls.OrderItems.Instance().getItemPreview(${ItemId});">${ItemImg}</a></div>`;
- }
- else {
- html += `<div class="row position-relative">
- <div class="position-absolute t-0 z-index-1" style="right: 10px;"><a href="javascript:;" class="btn btn-icon btn-flush-biz-theme btn-rounded flush-soft-hover d-30 cart-item-remove d-none"><span class="btn-icon-wrap"><i class="fa fa-times text-danger"></i></span></a><input type="checkbox" class="cart-item-chk d-none" id="cartItemChk_${ItemId}" style="transform: scale(1.3);"/></div>
- <div class="ItemDetails ${DivClass} d-flex" id="ItemDetails">
- <div class="img_div_tag_${ItemId}"><a class="pull-left" style="cursor:pointer;height:80px; width:80px;"onclick="Bizgaze.Apps.Transact.Controls.OrderItems.Instance().getItemPreview(${ItemId});">${ItemImg}</a></div>`;
- }
- let deleteBtnHtml = '';
- if (IsCart || FromWidget) {
- deleteBtnHtml += '<a href="javascript:;" id="deleteCartItem"><span class="pa-5 delete ' + HideDeleteBtn + '" style="cursor:Pointer;" title="Remove Item"><i class="m-r fa fa-trash text-danger fa-lg" id=""></i></span></a>';
- }
- if (!instance._order.g_IsPurchasePlanning) {
- if ($(window).width() < 768) {
- html += `<div><div><div>${deleteBtnHtml}</div><span class="block text-sm mouseHoverClass CartItemName order-cart-name font-weight-600 font-14 text-dark">${data.ItemName}</span><span class="ml-2 sales-is-offer-avail">`;
- }
- else {
- html += `<div><div><div>${deleteBtnHtml}</div><span class="block text-sm mouseHoverClass CartItemName order-cart-name font-weight-600 font-14 text-dark">${data.ItemName}</span><span class="ml-2 sales-is-offer-avail">`;
- }
- }
- else {
- html += 'div class="d-flex"><div><span> <strong> Edit </strong><span> <i class="fa fa-pencil ml-10"> </i> </span> </span> <br/> <input type="checkbox" id="chk_PurPlanItem_' + ItemId + '" class="chk_PurPlanItem css-checkbox"/>' +
- '<span class="ml-10 pull-right text-danger tax-error"></span><span class="block text-sm ml-2 mouseHoverClass CartItemName" style="color: #5ba8fb;">' + data.ItemName + '</span></div><div class="ml-2 text-right sales-is-offer-avail">';
- }
- if (data.IsOfferAvailable == true && (data.RefItemId == undefined || data.RefItemId == 0)) {
- if (instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.SalesClaim && instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim) {
- html += '<input type="hidden" class="IsOfferAvailableItem" value="true">';
- html += '<a class="btn btn-xs btn-outline-primary line-height-12 font-10 offerBadge_cls" onclick="Bizgaze.Apps.Transact.Controls.OrderItems.Instance().showOfferItems(' + instance._order.g_OrganizationId + ',' + ItemId + ",'" + data.ItemName + "'," + instance._order.g_OrderTypeId + ',' + 'this)"><span class="count"><i class="la la-award"></i> offer</span></a>';
- }
- }
- if (data.IsBoMAvailable) {
- if (instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.SalesClaim && instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim) {
- html += '<a class="btn btn-xs line-height-12 font-10 btn-outline-info ml-2" onclick="Bizgaze.Apps.Transact.Controls.OrderItems.Instance().showBOMItems(' + ItemId + ",'" + data.ItemName + "'" + ')"><span class=" count" > BOM </span></a>';
- }
- }
- if (data.IsSpecialPrice && instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.SalesClaim && instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim)
- html += '<span class="btn btn-xs up btn-outline-blue line-height-12 font-10 ml-2 btnItemSpecial ">SP</span>';
- html += '<span class="font-10 focBadge hidden"><span class="text-warning up m-l-n-sm ml-2 count" style="">Free of SKU - <span id="FocBadgeSKU" class="font-10"> </span> </span></span>';
- html += '</span></div>';
- if (data.PartNo != "" && data.PartNo != null) {
- html += '<span class="font-weight-300 font-12">SKU : ' + data.SKU + '</span> <span class="font-weight-300"> ( ' + data.PartNo + ' )';
- }
- else {
- html += '<span class="font-weight-300 font-12">SKU : ' + data.SKU;
- }
- if (instance._order.g_IsAdmin == 1 || instance._order.g_IsShowAvailability == 1) {
- html += ', </span> ';
- }
- if (InventoryType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Packs || InventoryType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Pieces || InventoryType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.PacksAndPieces) {
- if (instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.SalesClaim && instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim) {
- if (instance._order.g_IsAdmin == 1 || instance._order.g_IsShowAvailability == 1) {
- if (instance._order.g_IsPurchasePlanning) {
- html += `<span class="font-12 ` + AvailClass + `">Avail : ` + data.AvailablePacks + ` / ` + data.AvailablePieces + ` (` + data.AvailableQuantity + `)` + ` Pur PO: <a onclick='var filter = []; filter.push({"Key" : "estimateid", "Value": "` + res.EstimateId + `", ExpOp: 1}, {"Key" : "itemid", "Value": "` + ItemId + `", ExpOp: 1}, {"Key" : "ordertypeid", "Value": "2", ExpOp: 1}); Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_PurchasePlan_PendingDetails", null, filter, null);' style="color: #5ba8fb;text-decoration: underline;" class="PurPendingOrders">` + res.InwardOrderPacks + `</a> Sales PO: <a onclick='var filter = []; filter.push({"Key" : "estimateid", "Value": "` + res.EstimateId + `", ExpOp: 1}, {"Key" : "itemid", "Value": "` + ItemId + `", ExpOp: 1}, {"Key" : "ordertypeid", "Value": "1", ExpOp: 1}); Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_PurchasePlan_PendingDetails", null, filter, null);' style="color: #5ba8fb;text-decoration: underline;" class="SalesPendingOrders">` + res.OutwardOrderPacks + `</a></span><span class="text-danger pull-right LessUnitPrice-error"></span><br/>`;
- }
- else {
- if (InventoryType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Pieces && !instance.g_IsEnablePacks) {
- html += '<span class="font-12 ' + AvailClass + '">Avail : ' + data.TotalAvailablePieces + ' (' + data.AvailableQuantity + ') </span><span class="text-danger pull-right LessUnitPrice-error"></span>';
- }
- else {
- html += '<span class="font-12 ' + AvailClass + '">Avail : ' + data.AvailablePacks + ' / ' + data.AvailablePieces + ' (' + data.AvailableQuantity + ') </span><span class="text-danger pull-right LessUnitPrice-error"></span>';
- }
- }
- }
- }
- else {
- html += '<span class="font-12 ' + AvailClass + '">Claim Avail : ' + data.AvailablePacks + ' / ' + data.AvailablePieces + ' (' + data.AvailableQuantity + ')</span>';
- }
- }
- else if (InventoryType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- if (instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.SalesClaim && instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim) {
- if (instance._order.g_IsAdmin == 1 || instance._order.g_IsShowAvailability == 1) {
- if (instance._order.g_IsPurchasePlanning) {
- html += '<span class="font-12 ' + AvailClass + '">Avail : ' + data.Packs + ' Pur PO: <a href="javascript:;"style="color: #5ba8fb;text-decoration: underline;" class="PendingOrders">' + res.InwardOrderPacks + '</a> Sales PO: <a href="javascript:;"style="color: #5ba8fb;text-decoration: underline;" class="PendingOrders">' + res.OutwardOrderPacks + '</a></span><span class="text-danger pull-right LessUnitPrice-error"></span><br/>';
- }
- else
- html += '<span class="font-12 ' + AvailClass + '">Avail : ' + data.AvailableQuantity + '</span>';
- }
- }
- else
- html += '<span class="font-12 ' + AvailClass + '">Claim Avail : ' + data.AvailableQuantity + '</span>';
- }
- if (instance._order.g_IsPurchasePlanning) {
- html += '<span class="block">MOQ : {{MinPacks}} | ROQ : {{ReorderPacks}} | Suggested : {{SuggestedPacks}} | Avg : {{AvgPacks}} </span>';
- }
- let Price_dataToggle = "";
- if (instance._order.g_IsAdmin == 1 || instance._order.g_ShowPrice == 1) {
- Price_dataToggle = `data-toggle="collapse"`;
- }
- instance.getPriceTypeValues(ItemId);
- let compositeDecimalValue = 0;
- let piecePriceDecimalValue = 0;
- let compositePiecePriceDecimalvalue = 0;
- let Item = instance.g_LoadedItems.find(x => x.ItemId == ItemId);
- if (Item != undefined) {
- compositeDecimalValue = Item.CompositePrice;
- piecePriceDecimalValue = Item.PiecePrice;
- compositePiecePriceDecimalvalue = Item.CompositePiecePrice;
- }
- html += '<br>';
- if (instance.g_IsEnablePiecePrice) {
- if (instance._order.g_IsPurchasePlanning && (res.SuggestedPacks) != 0 && (res.SuggestedPacks) != null && (res.SuggestedPacks) != undefined && Mod_UnitPrice != 0) {
- html += '<span class="sp_PriceType">Piece Price : </span> <span id="DiscountOpenBracket" class="hidden">(</span><a href="javascript:;" class="text-sm editItemPrice" style="text-decoration: underline;"' + Price_dataToggle + 'data-target="#' + EditUnitPriceClass + '' + ItemId + '">' + Number(instance.roundOff(piecePriceDecimalValue)) + '</a> <span class="CompositePriceCalBreak"> </span> <span id="QuantityAndDiscountSpan" class="' + hidden + '"><span id="OrderQuantity_' + ItemId + '" class="OrderQuantity hidden" >' + OrderQuantity + '</span><span id="multipliedvalue_' + ItemId + '" class="multipliedvalue hidden" >' + multiplevalue + '</span></span>';
- }
- else
- html += '<span class="sp_PriceType">Piece Price : </span> <span id="DiscountOpenBracket" class="hidden">(</span><a href="javascript:;" class="text-sm editItemPrice" style="text-decoration: underline;"' + Price_dataToggle + 'data-target="#' + EditUnitPriceClass + '' + ItemId + '">' + Number(instance.roundOff(piecePriceDecimalValue)) + '</a> <span class="CompositePriceCalBreak"> </span> <span id="QuantityAndDiscountSpan" class="' + hidden + '"><span id="OrderQuantity_' + ItemId + '" class="OrderQuantity hidden" ></span><span id="multipliedvalue_' + ItemId + '" class="multipliedvalue hidden" ></span></span>';
- }
- else if (instance.g_IsEnableCompositePrice) {
- if ((instance._order.g_IsPurchasePlanning && data.SuggestedPacks) != 0 && (data.SuggestedPacks) != null && (data.SuggestedPacks) != undefined && Mod_UnitPrice != 0) {
- html += '<span class="sp_PriceType">Comp. Price : </span> <span id="DiscountOpenBracket" class="hidden">(</span> <a href="javascript:;" class="text-sm editItemPrice " style="text-decoration: underline;"' + Price_dataToggle + 'data-target="#' + EditUnitPriceClass + '' + ItemId + '">' + Number(instance.roundOff(compositeDecimalValue)) + '</a> <span class="CompositePriceCalBreak"> </span> <span id="QuantityAndDiscountSpan" class="' + hidden + '"><span id="OrderQuantity_' + ItemId + '" class="OrderQuantity hidden" >' + OrderQuantity + '</span><span id="multipliedvalue_' + ItemId + '" class="multipliedvalue hidden" >' + multiplevalue + '</span></span>';
- }
- else {
- html += '<span class="sp_PriceType">Comp. Price : </span> <span id="DiscountOpenBracket" class="hidden">(</span> <a href="javascript:;" class="text-sm editItemPrice " style="text-decoration: underline;"' + Price_dataToggle + 'data-target="#' + EditUnitPriceClass + '' + ItemId + '">' + Number(instance.roundOff(compositeDecimalValue)) + '</a> <span class="CompositePriceCalBreak"> </span> <span id="QuantityAndDiscountSpan" class="' + hidden + '"><span id="OrderQuantity_' + ItemId + '" class="OrderQuantity hidden" ></span><span id="multipliedvalue_' + ItemId + '" class="multipliedvalue hidden" ></span></span>';
- }
- }
- else if (instance.g_IsEnableCompositePiecePrice) {
- if (instance._order.g_IsPurchasePlanning && (data.SuggestedPacks) != 0 && (data.SuggestedPacks) != null && (data.SuggestedPacks) != undefined && Mod_UnitPrice != 0) {
- html += '<span class="sp_PriceType">Comp. Piece Price : </span><span id="DiscountOpenBracket" class="hidden">(</span><a href="javascript:;" class="text-sm editItemPrice CompositePiecePrice" style="color: #5ba8fb;text-decoration: underline;"' + Price_dataToggle + 'data-target="#' + EditUnitPriceClass + '' + ItemId + '">' + Number(instance.roundOff(compositePiecePriceDecimalvalue)) + '</a> <span class="CompositePriceCalBreak"> </span> <span id="QuantityAndDiscountSpan" class="' + hidden + '"><span id="OrderQuantity_' + ItemId + '" class="OrderQuantity hidden" >' + OrderQuantity + '</span><span id="multipliedvalue_' + ItemId + '" class="multipliedvalue hidden" >' + multiplevalue + '</span></span>';
- }
- else
- html += '<span class="sp_PriceType">Comp. Piece Price : </span><span id="DiscountOpenBracket" class="hidden">(</span><a href="javascript:;" class="text-sm editItemPrice CompositePiecePrice" style="color: #5ba8fb;text-decoration: underline;"' + Price_dataToggle + 'data-target="#' + EditUnitPriceClass + '' + ItemId + '">' + Number(instance.roundOff(compositePiecePriceDecimalvalue)) + '</a> <span class="CompositePriceCalBreak"> </span> <span id="QuantityAndDiscountSpan" class="' + hidden + '"><span id="OrderQuantity_' + ItemId + '" class="OrderQuantity hidden" ></span><span id="multipliedvalue_' + ItemId + '" class="multipliedvalue hidden" ></span></span>';
- }
- else {
- if (instance._order.g_IsPurchasePlanning && (res.SuggestedPacks) != 0 && (res.SuggestedPacks) != null && (res.SuggestedPacks) != undefined && Mod_UnitPrice != 0) {
- html += '<span class="sp_PriceType font-12">Price : </span><span id="DiscountOpenBracket" class="hidden">(</span><a href="javascript:;" class="text-sm editItemPrice font-12 text-dark " style="text-decoration: underline;"' + Price_dataToggle + 'data-target="#' + EditUnitPriceClass + '' + ItemId + '">' + Mod_UnitPrice + '</a> <span class="CompositePriceCalBreak"> </span> <span id="QuantityAndDiscountSpan" class="' + hidden + '"><span id="OrderQuantity_' + ItemId + '" class="OrderQuantity hidden" >' + OrderQuantity + '</span><span id="multipliedvalue_' + ItemId + '" class="multipliedvalue hidden" >' + multiplevalue + '</span></span>';
- }
- else {
- let PointsorPrice = "Price";
- if (instance._order.g_IsPointsOrder) {
- PointsorPrice = "Points";
- }
- if (data.IsManualUOM && instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales) {
- html += '<span class="sp_PriceType font-12">' + PointsorPrice + ' : </span><span id="DiscountOpenBracket" class="hidden">(</span><a href="javascript:;" class="text-sm editItemPrice font-12" style="color: #5ba8fb;text-decoration: underline;"' + Price_dataToggle + 'data-target="#' + EditUnitPriceClass + '' + ItemId + '">' + Mod_UnitPrice + '</a> <span class="CompositePriceCalBreak"> </span> <span id="QuantityAndDiscountSpan" class=" font-12 ' + hidden + '"><span id="OrderQuantity_' + ItemId + '" class="OrderQuantity hidden" ></span><span id="multipliedvalue_' + ItemId + '" class="multipliedvalue hidden" ></span></span> <span class="ManualUOM_' + ItemId + ' hidden">' + instance.getManualUOMDesign(data) + '</span> <span class="ManualUOM_RowTotal hidden"> </span>';
- }
- else {
- html += '<span class="sp_PriceType font-12">' + PointsorPrice + ' : </span><span id="DiscountOpenBracket" class="hidden">(</span><a href="javascript:;" class="text-sm editItemPrice font-12" style="color: #5ba8fb;text-decoration: underline;"' + Price_dataToggle + 'data-target="#' + EditUnitPriceClass + '' + ItemId + '">' + Mod_UnitPrice + '</a> <span class="CompositePriceCalBreak"> </span> <span id="QuantityAndDiscountSpan" class=" font-12 ' + hidden + '"><span id="OrderQuantity_' + ItemId + '" class="OrderQuantity hidden" ></span><span id="multipliedvalue_' + ItemId + '" class="multipliedvalue hidden" ></span></span>';
- }
- }
- }
- html += '<div id="LeverageErrorTxt" class="text-warning hidden">Leverage % Exceeded</div><div class=" text-danger tax-error"></div>';
- html += '</div>';
- html += '</div>';
- let SuggestedPacks = 0;
- if (instance._order.g_IsPurchasePlanning) {
- SuggestedPacks = res.SuggestedPacks;
- }
- html += '<div id="InventoryTypesTextboxes" class="InventoryTypesTextboxes ' + InventoryTypeDivClass + ' p-0">';
- html += instance.getInventoryDesign(ItemId, IsCart, SuggestedPacks, RefItemIds);
- html += '</div>';
- let classclaim = "";
- if (instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.SalesClaim || instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim) {
- classclaim = "col-sm-7";
- }
- else {
- classclaim = "col-sm-2";
- }
- let IsExpandItem = "";
- if (instance._order.g_ExpandItemSettings && (instance._order.g_IsAdmin == 1 || instance._order.g_ShowPrice == 1)) {
- IsExpandItem = "";
- }
- else {
- IsExpandItem = "collapse";
- }
- html += '<div class="row card py-2 mt-2 mb-0 ' + IsExpandItem + '" id="' + EditUnitPriceClass + '' + ItemId + '">' +
- '<div class="col-sm-12 p-0">' +
- '<div class="input-group">' +
- '<div class="col-sm-2">' +
- '<div class="floating-label-form-group floating-label-form-group-with-value">';
- html += '<label for="txt_editItemPrice">Unit price </label><input type="text" id="txt_editItemPrice" class="form-control floating-label-control txteditItemPrice" value="' + Mod_UnitPrice + '" inputmode="numeric" data-isdynamic="false" placeholder="Unit Price" data-placeholder="Enter Unit Price" data-label="Unit Price" onpaste = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" oninput="return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" min="0"></div>';
- let offerDiscountClass = "";
- if (data.IsOfferAvailable && data.IsOfferDiscountApplied && IsCart && !instance._order.g_IsManageOfferDiscount) {
- offerDiscountClass = "readonly";
- }
- let IsDiscountHidden = "";
- if (instance._order.g_IsPointsOrder) {
- IsDiscountHidden = "hidden";
- }
- html += '</div>' +
- '<div class="col-sm-2 ' + IsDiscountHidden + '">' +
- '<div class="floating-label-form-group discountFloatLabels">' +
- '<label>Discount</label>' +
- '<div class="input-group">' +
- '<input type="text" id="Ord_txtdiscount" placeholder="Discount" inputmode="numeric" data-isdynamic="false" onpaste = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" oninput="return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" data-placeholder="0.00" data-label="Discount" class="form-control ord_txtaddldiscount floating-label-control" value="" ' + offerDiscountClass + '>' +
- '<div class="input-group-btn">' +
- '<select class="btnOrder_DiscType mt-10 border-blue"><option value="2">Val</option><option value="1">%</option></select>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</div>';
- if (instance.g_FromWidgetEditOrderItemId == 0) {
- html += '<div class="' + classclaim + '">' +
- '<div class="floating-label-form-group descriptionFloatLabels">' +
- '<label>Description</label>' +
- '<input type="text" id="txt_Description" class="form-control floating-label-control " data-isdynamic="false" placeholder="Description" data-placeholder="Description" data-label="Description">' +
- '</div>' +
- '</div>';
- }
- offerDiscountClass = "";
- let IsItemExchangable = data.Discountable;
- if (instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.SalesClaim && instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim) {
- if ((instance._order.g_IsAdmin == 1 && IsItemExchangable) || (instance._order.g_IsShowExchangeDc == 1 && IsItemExchangable)) {
- html += '<div class="col-sm-2 mt-40">' +
- '<div class="custom-control custom-checkbox checkbox-primary">' +
- '<input type="checkbox" class="custom-control-input chkItem_ExchangeDC" id="' + ExchangeClass + '">' +
- '<label class="custom-control-label lbl_ExchangeDC_' + ItemId + '" for="' + ExchangeClass + '">Exchange</label>' +
- '</div>' +
- ' </div>';
- }
- }
- let IsMultipleUOMs = data.IsMultipleUOMs;
- let MultipleUOMs = data.MultipleUOMs;
- if (IsMultipleUOMs) {
- html += '<div id="div_MultipleUOMs_' + ItemId + '" class="div_MultipleUOMs floating-label-form-group-with-value col-sm-4" > ' +
- '<label for= "lbl" id ="lbl_MultipleUOMs_' + ItemId + '"> UOM </label>';
- html += '<select id="ddl_MultipleUOMs_' + ItemId + '" class="form-control type-control value-control dropdown_MultipleUOMs" placeholder="Select UOM" data-placeholder="Select UOM" data-label="UOM" data-isparent="false">';
- if (MultipleUOMs.length > 0) {
- html += '<option value="1"> ' + MultipleUOMs[0].DefaultUnitName + ' ( Default Unit ) </option>';
- }
- else {
- html += '<option value="1"> -- Select -- </option>';
- }
- for (var i = 0; i < MultipleUOMs.length; i++) {
- let UOM = MultipleUOMs[i];
- let Conversion = UOM.DefaultSize + " " + UOM.DefaultUnitName + " = " + UOM.AlternateSize + " " + UOM.AlternateUnitName;
- html += '<option value="' + MultipleUOMs[i].SchemaDetailId + '">' + MultipleUOMs[i].AlternateUnitName + ' ( ' + Conversion + ' ) </option>';
- }
- html += '</div> </select>';
- html += '<p class="mt-10 text-warning ItemConversion_' + ItemId + '"> </p>';
- }
- html += '</div>' +
- '</div>';
- html += ' </div>';
- html += '</li>';
- return html;
- }
- getItemDesignWithTokens_PurchasePlan() {
- let instance = this;
- let html = "";
- let InventoryType = instance._order.g_InventoryApplyType;
- html = '<li id="{{ItemId}}" class="list-group-item variant-item variant-addeditem variant-addeditem-{{ItemId}} li no-border">' +
- '<input type="hidden" class="hfOrder_ItemId" value="{{ItemId}}" />' +
- '<input type="hidden" class="hfOrder_RefItemId" value="{{RefItemIds}}" />' +
- '<input type="hidden" class="hfOrder_ItemName" value="{{ItemName}}" />' +
- '<input type="hidden" class="hfOrder_ItemSKU" value="{{SKU}}" />';
- let DivClass = 'col-sm-8';
- let InventoryTypeDivClass = 'col-sm-4';
- if (instance.g_IsEnablePacks && instance.g_IsEnablePieces) {
- DivClass = 'col-sm-6';
- InventoryTypeDivClass = 'col-sm-6';
- }
- html += ' <div class="row">' +
- '<div class="ItemDetails ' + DivClass + '" id="ItemDetails">' +
- '<a class="pull-left mt-20 {{faimg}}" style="cursor:pointer;height:100px; width:100px;"> <i class="fa fa-image orderItem font-40 ml-3"></i> </a>' +
- '<a class="pull-left {{imgtag}}" style="cursor:pointer;height:80px; width:100px;"> <img class="avatar" style="width: 70px; height: 70px;" onerror="ReloadImage(event)" data-dynamic="1" src="{{imgurl}}"> </a>';
- html += '<span id="EditROQ_{{ItemId}}" onclick="Bizgaze.Apps.Transact.Components.PurchasePlan.Instance().loadEditROQ({{ItemId}})"> <strong> Edit </strong><span> <i class="fa fa-pencil ml-5"> </i> </span> </span> <br/> <input type="checkbox" id="chk_PurPlanItem_{{ItemId}}" class="chk_PurPlanItem css-checkbox" {{IsDisabledCheckBox}} {{PurchasePlanChecked}}/>' +
- '<span class="ml-10 pull-right text-danger tax-error"></span><span class="block text-sm ml-2 mouseHoverClass CartItemName" style="color: #5ba8fb;">{{ItemName}}</span> <br>';
- html += '<span>SKU : {{SKU}}';
- if (instance._order.g_IsAdmin == 1 || instance._order.g_IsShowAvailability == 1) {
- html += ', </span> ';
- }
- let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- let InputParameters = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters;
- let BranchId = Number(InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_branchid").Value);
- if (InventoryType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Packs || InventoryType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Pieces || InventoryType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.PacksAndPieces) {
- if (instance._order.g_IsAdmin == 1 || instance._order.g_IsShowAvailability == 1) {
- html += `<span class="ItemAvailability">Avail : {{AvailablePacks}} / {{AvailablePieces}} ({{AvailableQuantity}})` + ` Pur PO: <a onclick='var filter = []; filter.push({"Key" : "estimateid", "Value": "{{EstimateId}}", ExpOp: 1}, {"Key" : "itemid", "Value": "{{ItemId}}", ExpOp: 1}, {"Key" : "ordertypeid", "Value": "2", ExpOp: 1}); Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_PurchasePlan_PendingDetails", null, filter, null);' style="color: #5ba8fb;text-decoration: underline;" class="PurPendingOrders"> {{InwardOrderPacks}} </a> Sales PO: <a onclick='var filter = []; filter.push({"Key" : "estimateid", "Value": "{{EstimateId}}", ExpOp: 1}, {"Key" : "itemid", "Value": "{{ItemId}}", ExpOp: 1}, {"Key" : "ordertypeid", "Value": "1", ExpOp: 1}); Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_PurchasePlan_PendingDetails", null, filter, null);' style="color: #5ba8fb;text-decoration: underline;" class="SalesPendingOrders">{{OutwardOrderPacks}}</a></span><span class="text-danger pull-right LessUnitPrice-error"></span><br/>`;
- }
- }
- else if (InventoryType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- if (instance._order.g_IsAdmin == 1 || instance._order.g_IsShowAvailability == 1) {
- html += '<span class="ItemAvailability">Avail : {{Packs}} Pur PO: <a href="javascript:;"style="color: #5ba8fb;text-decoration: underline;" class="PendingOrders">{{InwardOrderPacks}}</a> Sales PO: <a href="javascript:;"style="color: #5ba8fb;text-decoration: underline;" class="PendingOrders">{{OutwardOrderPacks}}</a></span><span class="text-danger pull-right LessUnitPrice-error"></span><br/>';
- }
- }
- html += '<span class="block">Saftey Stock : {{MinPacks}} | Suggested : {{SuggestedPacks}} | Avg : {{AvgPacks}} </span>';
- let Price_dataToggle = "";
- if (instance._order.g_IsAdmin == 1 || instance._order.g_ShowPrice == 1) {
- Price_dataToggle = `data-toggle="collapse"`;
- }
- html += '<br>';
- html += '<span class="sp_PriceType font-12">Price : </span><span id="DiscountOpenBracket" class="hidden">(</span><a href="javascript:;" class="text-sm editItemPrice text-dark font-12" text-decoration: underline;"' + Price_dataToggle + 'data-target="#editItemPriceAccordion_{{ItemId}}"> {{ConfirmedUnitPrice}} </a> <span class="CompositePriceCalBreak"> </span> <span id="QuantityAndDiscountSpan font-12" class=""><span id="OrderQuantity_{{ItemId}}" class="OrderQuantity hidden">{{OrderQuantity}}</span><span id="multipliedvalue_{{ItemId}}" class="multipliedvalue hidden">{{multiplevalue}}</span></span>';
- html += '<div id="LeverageErrorTxt" class="text-warning hidden font-10 ">Leverage % Exceeded</div>';
- html += '</div>';
- html += '<div id="InventoryTypesTextboxes" class="InventoryTypesTextboxes ' + InventoryTypeDivClass + '">';
- html += instance.getInventoryDesignWithTokens_PurchasePlan();
- html += '</div>';
- html += '<div class="row collapse card py-2 mt-2 mb-0 " id="editItemPriceAccordion_{{ItemId}}">' +
- '<div class="col-sm-12">' +
- '<div class="input-group">' +
- '<div class="col-sm-2">' +
- '<div class="floating-label-form-group floating-label-form-group-with-value">';
- html += '<label for="txt_editItemPrice">Unit price </label><input type="text" id="txt_editItemPrice" class="form-control floating-label-control txteditItemPrice" inputmode="numeric" value="{{ConfirmedUnitPrice}}" data-isdynamic="false" placeholder="Unit Price" data-placeholder="Enter Unit Price" data-label="Unit Price" onpaste = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" oninput="return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" min="0"></div>';
- html += '</div>' +
- '<div class="col-sm-2">' +
- '<div class="floating-label-form-group discountFloatLabels floating-label-form-group-with-value">' +
- '<label>Discount</label>' +
- '<div class="input-group">' +
- '<input type="text" id="Ord_txtdiscount" placeholder="Discount" inputmode="numeric" data-isdynamic="false" onpaste = "return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" oninput="return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().validateFloatKeyPress(this,event)" data-placeholder="0.00" data-label="Discount" class="form-control ord_txtaddldiscount floating-label-control" value="{{Discount}}" {{offerDiscountClass}}>' +
- '<div class="input-group-btn">' +
- '<select class="btnOrder_DiscType mt-10 border-blue"><option value="2">Val</option><option value="1">%</option></select>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '<div class="col-sm-2">' +
- '<div class="floating-label-form-group descriptionFloatLabels">' +
- '<label>Description</label>' +
- '<input type="text" id="txt_Description" class="form-control floating-label-control " data-isdynamic="false" placeholder="Description" data-placeholder="Description" data-label="Description">' +
- '</div>' +
- '</div>';
- html += '</div>' +
- ' </div>' +
- ' </div>';
- html += '</li>';
- return html;
- }
- getManualUOMDesign(Itm) {
- let html = `<input type="text" id="txt_ManualConversionQty" class="form-control floating-label-control col-sm-2" inputmode="numeric" onpaste="return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().isNumberKey(event)" oninput="return Bizgaze.Apps.Transact.Controls.OrderItems.Instance().isNumberKey(event)" data-isdynamic="false" placeholder="" data-placeholder="" data-label="" value="` + Itm.ConversionQuantity + `" style="display: inline">
-
- <select id="ddl_ManualUOMs_` + Itm.ItemId + `" class="type-control value-control dropdown_ManualUOMs" placeholder="Select UOM" data-placeholder="Select UOM" data-label="UOM" data-isparent="false" style="display: inline">`;
- for (let i = 0; i < Itm.UOMs.length; i++) {
- let Selected = "";
- if (Itm.UOMs[i].UnitId == Itm.UOMSchemaId) {
- Selected = "selected";
- }
- html += `<option value="` + Itm.UOMs[i].UnitId + `" ` + Selected + `>` + Itm.UOMs[i].UnitName + `</option>`;
- }
- html += `</select>`;
- return html;
- }
- bindManualUOMData(elem, Itm, AmountWithDiscount) {
- let instance = this;
- $("#" + instance.g_VisibleContainerId).find(elem).find(".ManualUOM_" + Itm.ItemId).removeClass("hidden");
- $("#" + instance.g_VisibleContainerId).find(elem).find(".ManualUOM_RowTotal").removeClass("hidden").text(" = " + AmountWithDiscount);
- $("#" + instance.g_VisibleContainerId).find(elem).find("#txt_ManualConversionQty").val(Itm.ConversionQuantity);
- $("#" + instance.g_VisibleContainerId).find(elem).find(".dropdown_ManualUOMs").val(Itm.SelectedUnitId);
- }
- updateItemsDesign(elem, evnt, IsCart = false, IsFocItem = false) {
- debugger;
- let instance = this;
- if (elem.length != 0) {
- let ItemId = $("#" + instance.g_VisibleContainerId).find(elem).find(".hfOrder_ItemId").val();
- let RefItemIds = $("#" + instance.g_VisibleContainerId).find(elem).find(".hfOrder_RefItemId").val();
- let CartItem_Index = -1;
- if (IsFocItem) {
- CartItem_Index = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId && x.RefItemIds == RefItemIds);
- }
- else {
- CartItem_Index = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId && x.RefItemIds == "");
- }
- let Itm = instance.g_CartItems_New[CartItem_Index];
- if (Itm == undefined) {
- return false;
- }
- Itm.UnitPrice = Math.abs(Itm.UnitPrice);
- Itm.UnitPriceWithOutTax = Math.abs(Itm.UnitPriceWithOutTax);
- let UnitPrice = Itm.UnitPrice;
- let UnitName = Itm.UnitName;
- let pricelabel = "Price";
- if (instance._order.g_IsPointsOrder) {
- pricelabel = "Points";
- }
- if (instance.g_IsEnablePiecePrice)
- pricelabel = "Piece Price";
- if (instance.g_IsEnableCompositePrice) {
- pricelabel = "Comp. Price";
- }
- if (instance.g_IsEnableCompositePiecePrice) {
- pricelabel = "Comp. Piece Price";
- }
- $("#" + instance.g_VisibleContainerId).find(".sp_PriceType").text(pricelabel + " : ");
- $("#" + instance.g_VisibleContainerId).find(".sp_PriceType").addClass("font-12");
- let Cond = $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").is(":visible") || evnt == "BindItemList" || evnt == "FromWidget_FocItem" || evnt == "EditOrderItem" || evnt == "FromWidget" || evnt == "AddFocItem_IsOfferDiscountApplied" || evnt == "EditFocItem_IsOfferDiscountApplied" || evnt == "DeleteCartItem";
- if (IsCart) {
- Cond = !$("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").is(":visible") || evnt == "EditFocItem" || evnt == "AddFocItem_IsOfferDiscountApplied" || evnt == "EditFocItem_IsOfferDiscountApplied" || instance._order.g_IsSC_to_PC;
- }
- if (Cond) {
- let Cartons = Itm.Quantity;
- if (instance._order.g_InventoryApplyType != Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- Cartons = Itm.Packs;
- }
- $("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemCount").val(Cartons);
- $("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemPieceCount").val(Itm.Pieces);
- $("#" + instance.g_VisibleContainerId).find(elem).find("#txt_editItemPrice").val(Itm.UnitPriceWithOutTax);
- $("#" + instance.g_VisibleContainerId).find(elem).find(".btnOrder_DiscType").val(Itm.DiscountType);
- let Discount = Itm.DiscountValue == 0 ? Itm.DiscountPercent : Itm.DiscountValue;
- if (Discount == 0) {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#Ord_txtdiscount").val("");
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#Ord_txtdiscount").val(Discount);
- }
- }
- if (Itm.Description != "" && Itm.Description != null) {
- if (instance.g_FromWidgetEditOrderItemId > 0) {
- $("#" + instance.g_VisibleContainerId).find("#txt_Description").val(Itm.Description);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#txt_Description").val(Itm.Description);
- }
- $("#" + instance.g_VisibleContainerId).find(elem).find(".descriptionFloatLabels").addClass("floating-label-form-group-with-value");
- }
- if (Itm.Packs > 0) {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".defaultSelectedCartons").addClass("floating-label-form-group-with-value");
- }
- if (Itm.Pieces > 0) {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".defaultSelectedPieces").addClass("floating-label-form-group-with-value");
- }
- $("#" + instance.g_VisibleContainerId).find(elem).find(".CompositePriceCalBreak").html('');
- if (Itm.ExchangeDC) {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".chkItem_ExchangeDC").prop("checked", true);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".chkItem_ExchangeDC").prop("checked", false);
- }
- let ItemIndex = $("#" + instance.g_VisibleContainerId).find(elem).attr("class").toString().indexOf("variant-addeditem-" + Itm.ItemId);
- if ((Itm.IsOfferAvailable && Itm.IsOfferDiscountApplied && IsCart && ItemIndex == -1 && !instance._order.g_IsManageOfferDiscount) || (Itm.ExchangeDC)) {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#Ord_txtdiscount").attr("disabled", "disabled").css("cursor", "not-allowed");
- $("#" + instance.g_VisibleContainerId).find(elem).find(".btnOrder_DiscType").attr("disabled", "disabled").css("cursor", "not-allowed");
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#Ord_txtdiscount").removeAttr("disabled").removeAttr("style");
- $("#" + instance.g_VisibleContainerId).find(elem).find(".btnOrder_DiscType").removeAttr("disabled").removeAttr("style");
- }
- if (Itm.IsMultipleUOMs) {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#ddl_MultipleUOMs_" + ItemId).val(Itm.SelectedUnitId);
- if (Itm.SelectedUnitId != 1 && Itm.SelectedUnitId != 0) {
- let UOM = Itm.MultipleUOMs.find(x => x.SchemaDetailId == Itm.SelectedUnitId);
- let Conversion = UOM.DefaultSize + " " + UOM.DefaultUnitName + " = " + UOM.AlternateSize + " " + UOM.AlternateUnitName;
- $("#" + instance.g_VisibleContainerId).find(".ItemConversion_" + Itm.ItemId).text(Conversion);
- UnitName = Itm.SelectedUnitName;
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(".ItemConversion_" + Itm.ItemId).text("");
- }
- }
- if (IsCart) {
- if (Itm.ExchangeDC) {
- UnitPrice = -Itm.UnitPrice;
- let ItemName = Itm.ItemName + " (Exchange) ";
- $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId).find(".CartItemName").html(ItemName);
- $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId).find(".CartItemName").append("<input type='checkbox' class='divAfterTax' checked/> After Tax");
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId).find(".CartItemName").html(Itm.ItemName);
- $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId).find(".CartItemName").find(".divAfterTax").remove();
- }
- }
- if (instance.g_FromWidget) {
- if (Itm.ExchangeDC) {
- UnitPrice = -Itm.UnitPrice;
- let ItemName = Itm.ItemName + " (Exchange) ";
- $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + ItemId).find(".CartItemName").html(ItemName);
- $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + ItemId).find(".CartItemName").append("<input type='checkbox' class='divAfterTax' checked/> After Tax");
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + ItemId).find(".CartItemName").html(Itm.ItemName);
- $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + ItemId).find(".CartItemName").find(".divAfterTax").remove();
- }
- }
- let _quantity = instance.roundOffIgnoreZerosAfterDecimal(Itm.BaseQty);
- if (Itm.IsMultipleUOMs && Itm.ConversionQuantity > 0) {
- _quantity = Itm.ConversionQuantity;
- }
- let AmountWithDiscount = instance.roundOffIgnoreZerosAfterDecimal(Number(Itm.AmountWithDiscount));
- if (Itm.Packs == 0 && Itm.Pieces == 0) {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text(Itm.UnitPrice).css({ 'text-decoration': 'underline', 'color': '#5ba8fb' });
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text("");
- $("#" + instance.g_VisibleContainerId).find(elem).find(".chk_PurPlanItem").prop("checked", false).attr("disabled", "true");
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".chk_PurPlanItem").prop("checked", true).removeAttr("disabled");
- if (Itm.DiscountValue > 0) {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text("(" + Itm.UnitPrice).css({ 'text-decoration': 'underline', 'color': '#5ba8fb' });
- if (Itm.IsManualUOM && instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales) {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(" - " + Number(Itm.DiscountValue) + ") X ");
- instance.bindManualUOMData(elem, Itm, AmountWithDiscount);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(" - " + Number(Itm.DiscountValue) + ") X " + _quantity + '(' + UnitName + ')' + " = " + AmountWithDiscount);
- }
- $("#" + instance.g_VisibleContainerId).find(elem).find(".discountFloatLabels").addClass("floating-label-form-group-with-value");
- }
- else if (Itm.DiscountPercent > 0) {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text("(" + Itm.UnitPrice).css({ 'text-decoration': 'underline', 'color': '#5ba8fb' });
- if (Itm.IsManualUOM && instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales) {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(" - " + Number(Itm.DiscountPercent) + "%) X ");
- instance.bindManualUOMData(elem, Itm, AmountWithDiscount);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(" - " + Number(Itm.DiscountPercent) + "%) X " + _quantity + '(' + UnitName + ')' + " = " + AmountWithDiscount);
- }
- $("#" + instance.g_VisibleContainerId).find(elem).find(".discountFloatLabels").addClass("floating-label-form-group-with-value");
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text(Number(UnitPrice)).css({
- 'text-decoration': 'underline', 'color': '#5ba8fb'
- });
- if (Itm.IsManualUOM && instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales) {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(" X ");
- instance.bindManualUOMData(elem, Itm, AmountWithDiscount);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(" X " + _quantity + '(' + UnitName + ')' + " = " + AmountWithDiscount);
- }
- $("#" + instance.g_VisibleContainerId).find(elem).find(".discountFloatLabels").removeClass("floating-label-form-group-with-value");
- }
- }
- if (Itm.IsFocItem) {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").removeAttr("style").removeAttr("data-toggle").removeAttr("data-collapse").attr("disabled", "true").css("cursor", "not-allowed");
- $("#" + instance.g_VisibleContainerId).find(elem).find(".focBadge").removeClass("hidden");
- $("#" + instance.g_VisibleContainerId).find(elem).find("#FocBadgeSKU").text(Itm.RefItemSKUs);
- }
- $("#" + instance.g_VisibleContainerId).find(elem).find("#DiscountOpenBracket").addClass("hidden");
- instance.getPriceTypeValues(ItemId, Itm.Packs, Itm.Pieces);
- let PiecePrice = instance.roundOffIgnoreZerosAfterDecimal(Itm.PiecePrice);
- let CompositePrice = instance.roundOffIgnoreZerosAfterDecimal(Itm.CompositePrice);
- let CompositePiecePrice = instance.roundOffIgnoreZerosAfterDecimal(Itm.CompositePiecePrice);
- if (instance.g_IsEnablePiecePrice) {
- let TotalPieces = (Itm.Packs * Itm.PackCount) + Itm.Pieces;
- if (Itm.DiscountValue == 0 && Itm.DiscountPercent == 0) {
- let RowTotal = PiecePrice * TotalPieces;
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text(PiecePrice);
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(' X ' + TotalPieces + ' Pieces = ' + RowTotal);
- }
- else if (Itm.DiscountValue > 0) {
- let DiscountAmount = Itm.DiscountValue * Itm.PackSize;
- let RowTotal = (PiecePrice - DiscountAmount) * TotalPieces;
- $("#" + instance.g_VisibleContainerId).find(elem).find("#DiscountOpenBracket").removeClass("hidden").text('(');
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text(PiecePrice);
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(' - ' + DiscountAmount + ') X ' + TotalPieces + ' Pieces = ' + RowTotal);
- }
- else if (Itm.DiscountPercent > 0) {
- let DiscountAmount = (PiecePrice * Itm.DiscountPercent) / 100;
- let RowTotal = (PiecePrice - DiscountAmount) * TotalPieces;
- $("#" + instance.g_VisibleContainerId).find(elem).find("#DiscountOpenBracket").removeClass("hidden");
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text(PiecePrice);
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(' - ' + Itm.DiscountPercent + '%) X ' + TotalPieces + ' Pieces = ' + RowTotal);
- }
- }
- if (instance.g_IsEnableCompositePrice) {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text(CompositePrice);
- if (Itm.DiscountValue == 0 && Itm.DiscountPercent == 0) {
- let RowTotal = instance.roundOffIgnoreZerosAfterDecimal(CompositePrice * _quantity);
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(' X ' + _quantity + ' ' + UnitName + ' = ' + RowTotal);
- }
- else if (Itm.DiscountValue > 0) {
- let DiscountAmount = Itm.DiscountValue * _quantity;
- let RowTotal = (Itm.UnitPriceWithOutTax * _quantity) - DiscountAmount;
- let AmountWithTax = instance.getAmountWithTax(Itm.ItemId, RowTotal).split('|');
- let RowTotalWithTax = instance.roundOffIgnoreZerosAfterDecimal(AmountWithTax[0]);
- let RowTax = AmountWithTax[1];
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text('(' + Itm.UnitPriceWithOutTax);
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(' - ' + Itm.DiscountValue + ') X ' + _quantity + ' ' + UnitName + ' + (' + RowTax + ') = ' + RowTotalWithTax);
- }
- else if (Itm.DiscountPercent > 0) {
- let Amount = (Itm.BaseQty * Itm.UnitPriceWithOutTax);
- let DiscountAmount = (Amount * Itm.DiscountPercent) / 100;
- let RowTotal = (Itm.UnitPriceWithOutTax * _quantity) - DiscountAmount;
- let AmountWithTax = instance.getAmountWithTax(Itm.ItemId, RowTotal).split('|');
- let RowTotalWithTax = instance.roundOffIgnoreZerosAfterDecimal(AmountWithTax[0]);
- let RowTax = AmountWithTax[1];
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text('(' + Itm.UnitPriceWithOutTax);
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(' - ' + Itm.DiscountPercent + '%) X ' + _quantity + ' ' + UnitName + ' + (' + RowTax + ') = ' + RowTotalWithTax);
- }
- }
- if (instance.g_IsEnableCompositePiecePrice) {
- let CompositePiecePrice = instance.roundOffIgnoreZerosAfterDecimal(Itm.CompositePiecePrice);
- let PiecePrice = instance.roundOffIgnoreZerosAfterDecimal(Itm.PiecePrice);
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text(CompositePiecePrice);
- if (Itm.DiscountValue == 0 && Itm.DiscountPercent == 0) {
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(' (' + _quantity + ' ' + UnitName + ')');
- }
- else if (Itm.DiscountValue > 0) {
- let DiscountAmount = Itm.DiscountValue * _quantity;
- let RowTotal = PiecePrice - DiscountAmount;
- let AmountWithTax = instance.getAmountWithTax(Itm.ItemId, RowTotal).split('|');
- let RowTotalWithTax = instance.roundOffIgnoreZerosAfterDecimal(AmountWithTax[0]);
- let RowTax = AmountWithTax[1];
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text('(' + Itm.UnitPriceWithOutTax);
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(' - ' + Itm.DiscountValue + ') X ' + _quantity + ' ' + UnitName + ' + (' + RowTax + ') = ' + RowTotalWithTax);
- }
- else if (Itm.DiscountPercent > 0) {
- let Amount = (Itm.BaseQty * Itm.UnitPriceWithOutTax);
- let DiscountAmount = (Amount * Itm.DiscountPercent) / 100;
- let RowTotal = PiecePrice - DiscountAmount;
- let AmountWithTax = instance.getAmountWithTax(Itm.ItemId, RowTotal).split('|');
- let RowTotalWithTax = instance.roundOffIgnoreZerosAfterDecimal(AmountWithTax[0]);
- let RowTax = AmountWithTax[1];
- $("#" + instance.g_VisibleContainerId).find(elem).find(".editItemPrice").text('(' + Itm.UnitPriceWithOutTax);
- $("#" + instance.g_VisibleContainerId).find(elem).find("#QuantityAndDiscountSpan").text(' - ' + Itm.DiscountPercent + '%) X ' + _quantity + ' ' + UnitName + ' + (' + RowTax + ') = ' + RowTotalWithTax);
- }
- }
- if (evnt == "RefreshAllItems_InventoryClickEvents" || evnt == "FromWidget") {
- let html = instance.getInventoryDesign(ItemId, IsCart, 0, Itm.RefItemIds);
- $("#" + instance.g_VisibleContainerId).find(elem).find("#InventoryTypesTextboxes").html(html);
- instance.allItemEvents(elem);
- }
- if (instance._order.g_ExpandItemSettings && (instance._order.g_IsAdmin == 1 || instance._order.g_ShowPrice == 1)) {
- $("#editItemPriceAccordion_" + ItemId).removeClass("collapse");
- }
- else {
- $("#editItemPriceAccordion_" + ItemId).addClass("collapse");
- }
- instance.checkErrors();
- instance.checkLoyalityErrors(elem);
- }
- }
- updateItemsAvailability(res) {
- let instance = this;
- let Items = $("#" + instance.g_VisibleContainerId).find(".variant-list").find("li");
- for (let i = 0; i < Items.length; i++) {
- let elem = Items[i];
- let ItemId = $("#" + instance.g_VisibleContainerId).find(elem).find(".hfOrder_ItemId").val();
- if (ItemId > 0) {
- let data = res.find(x => x.ItemId == ItemId);
- $("#" + instance.g_VisibleContainerId).find(elem).find(".ItemAvailability").text('Avail : ' + data.AvailablePacks + ' / ' + data.AvailablePieces + ' (' + data.AvailableQuantity + ')');
- }
- }
- let CartItems = $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").find("li");
- for (let c = 0; c < CartItems.length; c++) {
- let elem = CartItems[c];
- let ItemId = $("#" + instance.g_VisibleContainerId).find(elem).find(".hfOrder_ItemId").val();
- if (ItemId > 0) {
- let data = res.find(x => x.ItemId == ItemId);
- $("#" + instance.g_VisibleContainerId).find(elem).find(".CartAvailability").text('Avail : ' + data.AvailablePacks + ' / ' + data.AvailablePieces + ' (' + data.AvailableQuantity + ')');
- }
- }
- }
- allItemEvents(elem) {
- let instance = this;
- if (!instance.g_PacksFocus && !instance.g_PiecesFocus) {
- if (instance.g_IsEnablePacks) {
- instance.g_PacksFocus = true;
- }
- else if (instance.g_IsEnablePieces) {
- instance.g_PiecesFocus = false;
- }
- }
- let timer;
- if (instance._order.g_IsSC_to_PC && !instance._order.g_IsFromPurchaseIndent) {
- $("#" + instance.g_VisibleContainerId).find(elem).find(".quantity-plus").addClass("disabled");
- $("#" + instance.g_VisibleContainerId).find(elem).find("#div_Cartons").find(".input-group-append").css("cursor", "not-allowed");
- }
- $("#" + instance.g_VisibleContainerId).find(".mouseHoverClass").hover(function () {
- $("#" + instance.g_VisibleContainerId).find(this).closest(".variant-item").find('.mouseHoverClass').css({ 'font-weight': '' });
- }, function () { $("#" + instance.g_VisibleContainerId).find(this).closest(".variant-item").find('.mouseHoverClass').css({ 'font-weight': '' }); });
- $("#" + instance.g_VisibleContainerId).find(elem).find(".chk_PurPlanItem").unbind().click(function () {
- let element = elem;
- let ItemId = element.find(".hfOrder_ItemId").val();
- if ($("#" + instance.g_VisibleContainerId).find(this).is(':checked')) {
- instance.updateItemsArray(element, "PurPlan");
- }
- else {
- instance.deleteCartItems(ItemId);
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").find(".cartitem-" + ItemId).remove();
- }
- });
- $("#" + instance.g_VisibleContainerId).find(".editCartItemQuantity").unbind().click(function () {
- let element = elem;
- element.find("._editCartItemQuantity").toggleClass("hidden");
- element.find(".editCartItemQuantity").toggleClass("hidden");
- element.find(".CartAvailability").toggleClass("hidden");
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find('.txtOrder_ItemCount').unbind().click(function () {
- instance.g_PacksFocus = true;
- instance.g_PiecesFocus = false;
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find('.txtOrder_ItemPieceCount').unbind().click(function () {
- instance.g_PiecesFocus = true;
- instance.g_PacksFocus = false;
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find(".txteditItemPrice").unbind().keyup(function () {
- clearTimeout(timer);
- timer = setTimeout(function () {
- let element = elem;
- instance.updateItemsArray(element, "UnitPrice");
- }, 300);
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find("#txt_ManualConversionQty").unbind().keyup(function () {
- clearTimeout(timer);
- timer = setTimeout(function () {
- let element = elem;
- instance.updateItemsArray(element, "ManualConversionQty");
- }, 300);
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find(".dropdown_ManualUOMs").unbind().change(function () {
- let element = elem;
- let ItemId = element.find(".hfOrder_ItemId").val();
- let ItmIndex = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId);
- if (ItmIndex != -1) {
- let SelectedUnitId = Number($("#" + instance.g_VisibleContainerId).find(elem).find(".dropdown_ManualUOMs").val());
- let SelectedUnitName = $("#" + instance.g_VisibleContainerId).find(elem).find(".dropdown_ManualUOMs option:selected").text();
- instance.g_CartItems_New[ItmIndex].SelectedUnitId = SelectedUnitId;
- instance.g_CartItems_New[ItmIndex].SelectedUnitName = SelectedUnitName;
- $("#ulOrder_Cart").find("#ddl_ManualUOMs_" + ItemId).val(SelectedUnitId);
- }
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find(".quantity-plus").unbind().click(function () {
- let element = elem;
- let Packs = Number(element.find(".txtOrder_ItemCount").val());
- let Pieces = 0;
- if (instance.g_IsEnablePieces) {
- Pieces = Number(element.find(".txtOrder_ItemPieceCount").val());
- }
- if (Packs == 0 && Pieces > 0) {
- instance.g_PacksFocus = false;
- instance.g_PiecesFocus = true;
- }
- if (instance.g_PacksFocus) {
- if (element.find("#txt_Pieces").val() == 0) {
- element.find('.divOrders_ItemPieceCount').removeClass('floating-label-form-group-with-value');
- }
- element.find('.divOrders_ItemCount').addClass('floating-label-form-group-with-value');
- let Packs = Number(element.find(".txtOrder_ItemCount").val());
- let incVal = instance.getIncrementValue(Packs);
- let val = instance.roundOffIgnoreZerosAfterDecimal(Packs + incVal);
- element.find(".txtOrder_ItemCount").val(val);
- }
- if (instance.g_PiecesFocus) {
- element.find('.divOrders_ItemPieceCount').addClass('floating-label-form-group-with-value');
- let Pieces = Number(element.find(".txtOrder_ItemPieceCount").val());
- let incVal = instance.getIncrementValue(Pieces);
- let val = instance.roundOffIgnoreZerosAfterDecimal(Pieces + incVal);
- element.find(".txtOrder_ItemPieceCount").val(val);
- }
- instance.updateItemsArray(element, "Plus");
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find(".quantity-minus").unbind().click(function () {
- let element = elem;
- let ItemId = element.find(".hfOrder_ItemId").val();
- let Packs = Number(element.find(".txtOrder_ItemCount").val());
- let Pieces = Number(element.find(".txtOrder_ItemPieceCount").val());
- if (Packs == 0 && Pieces > 0) {
- instance.g_PacksFocus = false;
- instance.g_PiecesFocus = true;
- }
- if (instance.g_PacksFocus) {
- if (element.find("#txt_Pieces").val() == 0) {
- element.find('.divOrders_ItemPieceCount').removeClass('floating-label-form-group-with-value');
- }
- element.find('.divOrders_ItemCount').addClass('floating-label-form-group-with-value');
- let incVal = instance.getIncrementValue(Packs);
- if (Packs > 0) {
- let val = instance.roundOffIgnoreZerosAfterDecimal(Packs - incVal);
- element.find(".txtOrder_ItemCount").val(val);
- }
- else if (Packs == 0 && Pieces > 0) {
- element.find(".txtOrder_ItemCount").val(instance.roundOffIgnoreZerosAfterDecimal(Packs));
- }
- else {
- element.find('.divOrders_ItemCount').removeClass('floating-label-form-group-with-value');
- instance.deleteCartItems(ItemId);
- return false;
- }
- }
- if (instance.g_PiecesFocus) {
- element.find('.divOrders_ItemPieceCount').addClass('floating-label-form-group-with-value');
- let Pieces = Number(element.find(".txtOrder_ItemPieceCount").val());
- let incVal = instance.getIncrementValue(Pieces);
- if (Pieces > 0) {
- let val = instance.roundOffIgnoreZerosAfterDecimal(Pieces - incVal);
- element.find(".txtOrder_ItemPieceCount").val(val);
- }
- else if (Pieces == 0 && Packs > 0) {
- element.find(".txtOrder_ItemPieceCount").val(instance.roundOffIgnoreZerosAfterDecimal(Pieces));
- }
- else {
- element.find('.divOrders_ItemPieceCount').removeClass('floating-label-form-group-with-value');
- instance.deleteCartItems(ItemId);
- return false;
- }
- }
- instance.updateItemsArray(element, "Minus");
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find('.chkItem_ExchangeDC').unbind().change(function () {
- let element = elem;
- let ItemId = element.find(".hfOrder_ItemId").val();
- if (element.find('.chkItem_ExchangeDC').prop("checked")) {
- element.find('#Ord_txtdiscount').val('').prop("disabled", true).css("cursor", "not-allowed");
- $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId).find("#Ord_txtdiscount").val('').prop("disabled", true).css("cursor", "not-allowed");
- }
- else {
- element.find('#Ord_txtdiscount').prop("disabled", false).css("cursor", "auto");
- $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId).find('#Ord_txtdiscount').prop("disabled", false).css("cursor", "auto");
- }
- instance.updateItemsArray(element, "Exchange");
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemCount").keyup(function () {
- clearTimeout(timer);
- timer = setTimeout(function () {
- instance.updateItemsArray(elem, "Packs");
- }, 300);
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemPieceCount").keyup(function () {
- clearTimeout(timer);
- timer = setTimeout(function () {
- instance.updateItemsArray(elem, "Pieces");
- }, 300);
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find(".btnOrder_DiscType").unbind().change(function () {
- instance.updateItemsArray(elem, "DiscountType");
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find("#Ord_txtdiscount").unbind().keyup(function () {
- clearTimeout(timer);
- timer = setTimeout(function () {
- instance.updateItemsArray(elem, "Discount");
- }, 300);
- });
- let DescriptionElem = $("#" + instance.g_VisibleContainerId).find(elem).find("#txt_Description");
- if (instance.g_FromWidgetEditOrderItemId > 0) {
- DescriptionElem = $("#" + instance.g_VisibleContainerId).find("#txt_Description");
- }
- $(DescriptionElem).unbind().keyup(function () {
- clearTimeout(timer);
- timer = setTimeout(function () {
- let ItemId = elem.find(".hfOrder_ItemId").val();
- let CartItem = instance.g_CartItems_New.find(x => x.ItemId == ItemId && x.RefItemIds == "");
- if (CartItem != undefined) {
- if (instance.g_FromWidgetEditOrderItemId > 0) {
- CartItem.Description = $("#txt_Description").val().toString();
- }
- else {
- CartItem.Description = elem.find("#txt_Description").val().toString();
- }
- }
- }, 300);
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find(".delete").unbind().click(function () {
- let FromWidget = false;
- if (instance.g_CartItems_New.length <= 10) {
- $("#" + instance.g_VisibleContainerId).find(".CartItemFindTxt").addClass('hidden');
- }
- let message = "Do you really want to delete this item";
- if (instance.g_CartItems_New.length == 1)
- message = "Your cart is going to empty.";
- let itemid = $("#" + instance.g_VisibleContainerId).find(this).parents(".cartitem").find(".hfOrder_ItemId").val();
- if (itemid == undefined) {
- itemid = $("#" + instance.g_VisibleContainerId).find(this).parents(".variant-addeditem").find(".hfOrder_ItemId").val();
- }
- if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0) {
- FromWidget = true;
- }
- bootbox.confirm({
- message: message,
- closeButton: false,
- buttons: {
- confirm: {
- label: 'Yes',
- className: 'btn-success'
- },
- cancel: {
- label: 'No',
- className: 'btn-danger'
- }
- },
- callback: function (result) {
- if (result) {
- instance.deleteCartItems(itemid, FromWidget);
- if (instance._order.g_IsPurchasePlanning)
- $("#" + instance.g_VisibleContainerId).find("#chk_PurPlanItem_" + itemid).prop("checked", false);
- }
- }
- });
- });
- $("#" + instance.g_VisibleContainerId).find(elem).find(".div_MultipleUOMs").change(function () {
- instance.updateItemsArray(elem, "UOMChange");
- });
- }
- readScanner(capturedValue, uniqueId) {
- if (capturedValue != "" && capturedValue != null && capturedValue != undefined) {
- $("#txt_SearchItem").val(capturedValue);
- }
- }
- refreshAllItems(FromWidget = false, evnt) {
- let instance = this;
- for (let i = 0; i < instance.g_LoadedItems.length; i++) {
- let Itm = instance.g_LoadedItems[i];
- let elem = $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + Itm.ItemId);
- if (elem != undefined && elem.length > 0) {
- instance.updateItemsArray(elem, "RefreshAllItems_" + evnt, FromWidget);
- }
- }
- }
- bindAllItemsQty(FromWidget = false, evnt) {
- let instance = this;
- for (let i = 0; i < instance.g_LoadedItems.length; i++) {
- let Itm = instance.g_LoadedItems[i];
- let elem = $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + Itm.ItemId);
- if (elem != undefined && elem.length > 0) {
- let CartIndex = instance.g_CartItems_New.findIndex(x => x.ItemId == Itm.ItemId);
- if (CartIndex != -1) {
- let inventoryApplyType = instance._order.g_InventoryApplyType;
- if (inventoryApplyType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- elem.find("#txt_Cartons").val(instance.g_CartItems_New[CartIndex].Quantity);
- elem.find("#txt_Pieces").val(0);
- }
- else if (inventoryApplyType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Packs) {
- elem.find("#txt_Cartons").val(instance.g_CartItems_New[CartIndex].Packs);
- elem.find("#txt_Pieces").val(instance.g_CartItems_New[CartIndex].Pieces);
- }
- else if (inventoryApplyType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.PacksAndPieces) {
- elem.find("#txt_Cartons").val(instance.g_CartItems_New[CartIndex].Packs);
- elem.find("#txt_Pieces").val(instance.g_CartItems_New[CartIndex].Pieces);
- }
- instance.updateItemsArray(elem, "RefreshAllItems_" + evnt, FromWidget, 0, instance.g_CartItems_New[CartIndex].Pieces);
- }
- else {
- instance.updateItemsArray(elem, "RefreshAllItems_" + evnt, FromWidget);
- }
- }
- }
- }
- showBOMItems(ItemId, ItemName, element) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/components/orders/itembomselection.js"], function () {
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(0, "", Bizgaze.Apps.Transact.Components.Orders.ItemBOMSelection.Instance(), function () {
- Bizgaze.Apps.Transact.Components.Orders.ItemBOMSelection.Instance().LoadBOMItems(ItemId, ItemName);
- }, Unibase.Platform.Helpers.Size.Large);
- });
- }
- itemSettings(FromWidget = false) {
- let instance = this;
- let inventoryHtml = `<div class="row" id="div_chkpieces"><div class="col-sm-3 hidden divselectall"><div class="custom-control custom-checkbox divselectall checkbox-primary"><input type="checkbox" class="custom-control-input" id="chk_AllItems"><label class="custom-control-label" for="chk_AllItems">Select All</label></div></div><div class="col-sm-4 div_chk_Packs hidden"><div class="custom-control custom-checkbox divEnablePacks checkbox-primary"><input type="checkbox" class="custom-control-input" id="chk_Packs"><label class="custom-control-label" for="chk_Packs">Enable Packs</label></div></div><div class="col-sm-4 div_chk_Pieces hidden"><div class="custom-control custom-checkbox divEnablePieces checkbox-primary"><input type="checkbox" class="custom-control-input" id="chk_Pieces"><label class="custom-control-label" for="chk_Pieces">Enable Pieces</label></div></div><div class="col-sm-4 hidden div_chk_CompositePrice"><div class="custom-control custom-checkbox checkbox-primary"><input type="checkbox" class="custom-control-input" id="chk_CompositePrice"><label class="custom-control-label" for="chk_CompositePrice">Enable Composite Price</label></div></div><div class="col-sm-4 hidden div_chk_PiecePrice"><div class="custom-control custom-checkbox checkbox-primary"><input type="checkbox" class="custom-control-input" id="chk_PiecePrice"><label class="custom-control-label" for="chk_PiecePrice">Enable Piece Price</label></div></div></div><br />`;
- if (instance._order.g_InventoryApplyType != Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity) {
- inventoryHtml += `<div class="row mb-20 div_chk_Qty" id="div_chk_Qty">
- <div class="col-sm-12">
- <div class="custom-control custom-checkbox divEnableQty checkbox-primary pull-right col-sm-3">
- <input type="checkbox" class="custom-control-input" id="chk_Qty">
- <label class="custom-control-label" for="chk_Qty"> Quantity </label>
- </div>
- </div>
- </div>`;
- }
- inventoryHtml += `<div class="d-none d-md-block"><div class="row div_titledetails font-weight-500 text-dark"><div class="col-sm-8 ItemDetails">Item Details</div><div class="col-sm-4 Inventory_Title InventoryTypesTextboxes text-center"> <div class="p-0"> <div class="row p-0"> <span id="spn_InventoryTitle" class="col-6">Cartons</span><span id="spn_picesTitle" class="col-6 pull-right hidden"> Pieces</span></div></div></div></div></div><div class="mt-2" id="div_ItemList"></div>`;
- $("#" + instance.g_VisibleContainerId).find(".InventorySettings").html(inventoryHtml);
- $("#" + instance.g_VisibleContainerId).find("#div_ItemList").html('<ul class="variant-list list-group" style="0px -21px"><li class="variant-item hidden"></li>');
- if (!instance._order.g_IsSC_to_PC) {
- instance.g_CartItems_New = [];
- instance.g_SC_PC_CartItems = [];
- instance.g_ItemsUnitPrice_New = [];
- instance.g_SelectedItems = [];
- instance.g_LoadedItems = [];
- }
- $("#" + instance.g_VisibleContainerId).find("#chk_AllItems").unbind().click(function () {
- if ($("#" + instance.g_VisibleContainerId).find('#chk_AllItems').is(':checked')) {
- instance.navigationHelper.showLoading();
- $("#" + instance.g_VisibleContainerId).find(".variant-list").find(".chk_PurPlanItem").each(function () {
- let element = $("#" + instance.g_VisibleContainerId).find(this).closest(".variant-item");
- if (element.find("#txt_Cartons").val() != 0 && element.find("#txt_Cartons").val() != "") {
- instance.updateItemsArray(element, "PurPlan_AllItems", false);
- $("#" + instance.g_VisibleContainerId).find(element).find(".chk_PurPlanItem").prop("checked", true);
- }
- });
- instance.navigationHelper.hideLoading();
- instance.getPurchasePlanTotals(false, true);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(".variant-list").find(".chk_PurPlanItem").prop("checked", false);
- instance.g_CartItems_New = [];
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").find(".cartitem").remove();
- $("#" + instance.g_VisibleContainerId).find("#OverallOrderQuantity").text("0");
- $("#" + instance.g_VisibleContainerId).find("#totalOrderItems").text("0");
- instance.getPurchasePlanTotals(false, true);
- }
- });
- instance.inventoryTypeClickEvents(FromWidget);
- instance.priceTypeClickEvents(FromWidget);
- }
- clearItemSearch() {
- let instance = this;
- $("#" + instance.g_VisibleContainerId).find(".search-clear-items").addClass("d-none");
- $("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").val("");
- Bizgaze.Apps.Transact.Controls.OrderItems.Instance().loadItems("", false);
- }
- itemSettingsEvents() {
- var instance = this;
- let timer;
- $("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").on('input', function () {
- clearTimeout(timer);
- timer = setTimeout(function () {
- var checkvalue = $("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").val();
- let check = checkvalue.toString();
- if (check.length != 0) {
- $("#" + instance.g_VisibleContainerId).find(".search-clear-items").removeClass("d-none");
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(".search-clear-items").addClass("d-none");
- }
- instance.g_PageIndex = 0;
- if (instance._order.g_IsPurchasePlanning)
- instance.loadPurchasePlanItems($("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").val());
- else
- instance.loadItems($("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").val());
- }, 1500);
- });
- $("#" + instance.g_VisibleContainerId).find("#ItemLoadType").change(function () {
- $("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").val('');
- $("#" + instance.g_VisibleContainerId).find("#ItemLoadType option[value='0']").remove();
- let type = $("#" + instance.g_VisibleContainerId).find("#ItemLoadType option:selected").text();
- if (type != "Filter" && !Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_OnlyFilters) {
- instance.g_IsFilterApplied = false;
- instance.g_FilteredTags = '';
- Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_TagArray = [];
- Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_ClearingTags = "";
- }
- instance.g_PageIndex = 0;
- if (instance._order.g_IsPurchasePlanning) {
- instance.loadPurchasePlanItems('');
- }
- else {
- if (type == "Filter") {
- instance.navigationHelper.popup(0, '', Bizgaze.Apps.Transact.Components.OrderFilter.Instance(), null, Unibase.Platform.Helpers.Size.Medium);
- }
- else {
- instance.loadItems(type);
- }
- }
- });
- $("#" + instance.g_VisibleContainerId).find(".ContinueShopping").unbind().click(function () {
- instance.continueShopping();
- });
- }
- inventoryTypeClickEvents(FromWidget) {
- let instance = this;
- $("#" + instance.g_VisibleContainerId).find('#chk_Pieces').click(function () {
- if ($("#" + instance.g_VisibleContainerId).find('#chk_Pieces').is(':checked')) {
- instance.g_IsEnablePieces = true;
- }
- else {
- instance.g_IsEnablePieces = false;
- instance.g_PacksFocus = true;
- instance.g_PiecesFocus = false;
- }
- instance.refreshAllItems(FromWidget, "InventoryClickEvents");
- });
- $("#" + instance.g_VisibleContainerId).find('#chk_Packs').click(function () {
- if ($("#" + instance.g_VisibleContainerId).find('#chk_Packs').is(':checked')) {
- instance.g_IsEnablePacks = true;
- }
- else {
- instance.g_IsEnablePacks = false;
- instance.g_PacksFocus = false;
- instance.g_PiecesFocus = true;
- }
- instance.refreshAllItems(FromWidget, "InventoryClickEvents");
- });
- $("#" + instance.g_VisibleContainerId).find('#chk_Qty').click(function () {
- if ($("#" + instance.g_VisibleContainerId).find('#chk_Qty').is(':checked')) {
- instance.g_IsEnablePacks = true;
- instance.g_PacksFocus = true;
- instance._order.g_InventoryApplyType = Bizgaze.Apps.Transact.Enums.InventoryApplyType.Quantity;
- instance._order.setInventorySettings(instance._order.g_InventoryApplyType, false);
- }
- else {
- instance._order.g_InventoryApplyType = instance._order.g_LobInventoryApplyType;
- instance._order.setInventorySettings(instance._order.g_InventoryApplyType, false);
- }
- instance.bindAllItemsQty(FromWidget, "InventoryClickEvents");
- });
- }
- setPriceType() {
- var instance = this;
- if (instance.g_IsEnablePiecePrice) {
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.PiecePrice;
- }
- else if (instance.g_IsEnableCompositePrice) {
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.CompositePrice;
- }
- else if (instance.g_IsEnableCompositePiecePrice) {
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.Both;
- }
- else {
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.None;
- }
- }
- priceTypeClickEvents(FromWidget) {
- let instance = this;
- $("#" + instance.g_VisibleContainerId).find('#chk_PiecePrice').click(function () {
- if ($("#" + instance.g_VisibleContainerId).find('#chk_PiecePrice').is(':checked')) {
- if (instance.g_IsEnableCompositePrice) {
- instance.g_IsEnableCompositePrice = false;
- instance.g_IsEnablePiecePrice = false;
- instance.g_IsEnableCompositePiecePrice = true;
- }
- else {
- instance.g_IsEnablePiecePrice = true;
- instance.g_IsEnableCompositePiecePrice = false;
- instance.g_IsEnableCompositePrice = false;
- }
- }
- else {
- instance.g_IsEnablePiecePrice = false;
- instance.g_IsEnableCompositePiecePrice = false;
- instance.g_IsEnableCompositePrice = $("#" + instance.g_VisibleContainerId).find('#chk_CompositePrice').is(':checked');
- }
- instance.clearItemSearch();
- instance.refreshAllItems(FromWidget, "PriceTypeClickEvents");
- });
- $("#" + instance.g_VisibleContainerId).find('#chk_CompositePrice').click(function () {
- if ($("#" + instance.g_VisibleContainerId).find('#chk_CompositePrice').is(':checked')) {
- if (instance.g_IsEnablePiecePrice) {
- instance.g_IsEnableCompositePrice = false;
- instance.g_IsEnableCompositePiecePrice = true;
- instance.g_IsEnablePiecePrice = false;
- }
- else {
- instance.g_IsEnableCompositePrice = true;
- instance.g_IsEnableCompositePiecePrice = false;
- instance.g_IsEnablePiecePrice = false;
- }
- }
- else {
- instance.g_IsEnableCompositePrice = false;
- instance.g_IsEnableCompositePiecePrice = false;
- instance.g_IsEnablePiecePrice = $("#" + instance.g_VisibleContainerId).find('#chk_PiecePrice').is(':checked');
- }
- instance.setPriceType();
- if (instance._order.g_IsPurchasePlanning)
- instance.loadPurchasePlanItems($("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").val());
- else {
- instance.clearItemSearch();
- instance.refreshAllItems(FromWidget, "PriceTypeClickEvents");
- }
- });
- }
- continueShopping() {
- let instance = this;
- instance.g_FromContinueShopping = true;
- $("#" + instance.g_VisibleContainerId).find(".modal-body").scrollTop(0);
- $("#" + instance.g_VisibleContainerId).find(".tax-error").text("");
- let SearchItem = $("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").val();
- if (SearchItem != "" || instance.g_PageIndex != 0) {
- instance.g_PageIndex = 0;
- $("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").val("");
- instance.loadItems($("#" + instance.g_VisibleContainerId).find("#txt_SearchItem").val());
- }
- $("#" + instance.g_VisibleContainerId).find(".div_SearchItem").removeClass('floating-label-form-group-with-value');
- $("#" + instance.g_VisibleContainerId).find(".section_CartDetails").addClass('hidden');
- $("#" + instance.g_VisibleContainerId).find(".section_Summary").addClass('hidden');
- $("#" + instance.g_VisibleContainerId).find("#dropup_save").addClass("hidden");
- $("#" + instance.g_VisibleContainerId).find("#btn_Save_New").addClass("hidden");
- $("#" + instance.g_VisibleContainerId).find(".btn_Save_Form").addClass("hidden");
- $("#" + instance.g_VisibleContainerId).find(".section_PriceDetails").addClass('hidden');
- $("#" + instance.g_VisibleContainerId).find(".OrgContactNameLink").removeClass('hidden');
- $("#" + instance.g_VisibleContainerId).find(".section_OrderDetails").addClass("hidden");
- $("#" + instance.g_VisibleContainerId).find(".section_Items").removeClass('hidden');
- if ($("#" + instance.g_VisibleContainerId).find(".section_CartDetails").hasClass('hidden')) {
- $("#" + instance.g_VisibleContainerId).find("#btn_CloseForm_" + $("#" + instance.g_VisibleContainerId).find("#hf_FormId").val()).removeClass('hidden');
- }
- if (!$("#" + instance.g_VisibleContainerId).find(".section_Items").hasClass('hidden')) {
- $("#" + instance.g_VisibleContainerId).find("#btn_Save").addClass('hidden');
- instance._order.showOrHideSaveAsDraft();
- $("#" + instance.g_VisibleContainerId).find(".CheckOutButton").removeClass('hidden');
- }
- if (instance._order.g_IsPurchasePlanning) {
- $("#" + instance.g_VisibleContainerId).find(".section_PurchasePlanSummary").removeClass('hidden');
- $("#" + instance.g_VisibleContainerId).find(".section_PurchasePlan").removeClass('hidden');
- $("#" + instance.g_VisibleContainerId).find(".section_PriceDetails").find(".card-header").text('Description');
- }
- $("#" + instance.g_VisibleContainerId).find(".btn_OrderSaveAsDraft").addClass('hidden');
- $("#" + instance.g_VisibleContainerId).find("#btn_CloseForm_" + $("#" + instance.g_VisibleContainerId).find("#hf_FormId").val()).addClass("mr-auto");
- $("#" + instance.g_VisibleContainerId).find('#ulOrder_Cart .cart-item-chk').addClass('d-none');
- }
- showOfferItems(OrganizationId, ItemId, ItemName, OrderType, element) {
- let instance = this;
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/components/invoices/itemofferselection.js", "apps/transact/controls/invoices/invoiceitem.component.js"], function () {
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(0, "", Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection.Instance(), function () {
- Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection.Instance().LoadOfferItems(OrganizationId, ItemId, ItemName, OrderType, $("#" + instance.g_VisibleContainerId).find(element), "Order");
- }, Unibase.Platform.Helpers.Size.Large);
- });
- }
- applyOffer(Item) {
- let instance = this;
- let ItemId = Item[0].ItemId;
- let Qty = Item[0].Volume;
- let LoadedItem = instance.g_LoadedItems.find(x => x.ItemId == ItemId);
- let Cartons = Math.ceil(Qty / (LoadedItem.PackCount * LoadedItem.PackSize));
- Qty = ((LoadedItem.PackCount * LoadedItem.PackSize) * Cartons);
- Qty = instance.roundOff(Qty);
- if (instance._order.g_InventoryApplyType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Packs) {
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find('#txt_Cartons').val(Cartons);
- $("#" + instance.g_VisibleContainerId).find('.cartitem-' + ItemId).find('#txt_Cartons').val(Cartons);
- }
- else if (instance._order.g_InventoryApplyType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.Pieces) {
- let Pieces = Math.ceil((Qty) / LoadedItem.PackSize);
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find('#txt_Pieces').val(Pieces);
- $("#" + instance.g_VisibleContainerId).find('.cartitem-' + ItemId).find('#txt_Pieces').val(Pieces);
- }
- else if (instance._order.g_InventoryApplyType == Bizgaze.Apps.Transact.Enums.InventoryApplyType.PacksAndPieces) {
- if (Cartons > 0) {
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find('#txt_Cartons').val(Cartons);
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find('#txt_Pieces').val("");
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find('.defaultSelectedPieces').removeClass("floating-label-form-group-with-value");
- $("#" + instance.g_VisibleContainerId).find('.cartitem-' + ItemId).find('#txt_Cartons').val(Cartons);
- $("#" + instance.g_VisibleContainerId).find('.cartitem-' + ItemId).find('#txt_Pieces').val("");
- $("#" + instance.g_VisibleContainerId).find('.cartitem-' + ItemId).find('.defaultSelectedPieces').removeClass("floating-label-form-group-with-value");
- instance.g_PacksFocus = true;
- instance.g_PiecesFocus = false;
- }
- else {
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find('#txt_Cartons').val("");
- $("#" + instance.g_VisibleContainerId).find('.cartitem-' + ItemId).find('#txt_Cartons').val("");
- }
- }
- else {
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find('#txt_Cartons').val(Qty);
- $("#" + instance.g_VisibleContainerId).find('.cartitem-' + ItemId).find('#txt_Cartons').val(Qty);
- }
- let element = $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId);
- instance.updateItemsArray(element, "ApplyOffer", false, Qty);
- }
- checkOffers(FromWidget, evnt) {
- return __awaiter(this, void 0, void 0, function* () {
- let instance = this;
- if (instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.SalesClaim && instance._order.g_OrderTypeId != Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim) {
- let ordItems = new Array();
- let applyType = '';
- if (instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales || instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.SalesClaim) {
- applyType = 'Sales';
- }
- else if (instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Purchase || instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim)
- applyType = 'Purchases';
- instance.g_CartItems_New.filter(x => x.IsFocItem == false).forEach(function (c) {
- c.IsFocAdded = false;
- c.FocItemIds = '';
- c.IsOfferDiscountApplied = false;
- c.AppliedOfferVolume = 0;
- let ItemId = c.ItemId;
- let baseqty = Number(c.BaseQty);
- if ((c.IsManualUOM && instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales) || c.IsMultipleUOMs) {
- baseqty = c.Quantity;
- }
- let unitPrice = Number(c.UnitPrice);
- let rowTotal = instance.roundOff(baseqty * unitPrice);
- ordItems.push({
- ItemId: Number(ItemId),
- Quantity: Number(instance.roundOff(baseqty)),
- RowTotal: Number(rowTotal),
- });
- });
- if (FromWidget) {
- let OrderId = Bizgaze.Apps.Transact.Controls.Order.Instance().g_OrderId;
- let OrderItemId = Bizgaze.Apps.Transact.Controls.AddOrderItems.Instance().g_Edit_OrderItemId;
- instance.fileCacheHelper.loadJsFile("apps/transact/managers/orders/ordermanager.js", function () {
- Bizgaze.Apps.Transact.Managers.OrderManager.Instance().getOrderItems(OrderId, 0).then(function (response) {
- let data = response.result;
- data = data.filter(x => x.OrderItemId != OrderItemId && x.IsFoc == false);
- for (let d = 0; d < data.length; d++) {
- let ItemId = data[d].ItemId;
- let baseqty = Number(data[d].Quantity);
- let unitPrice = Number(data[d].UnitPrice);
- let rowTotal = instance.roundOff(baseqty * unitPrice);
- ordItems.push({
- ItemId: Number(ItemId),
- Quantity: Number(instance.roundOff(baseqty)),
- RowTotal: Number(rowTotal),
- });
- }
- instance.bindOfferItems(FromWidget, ordItems);
- });
- });
- }
- else {
- instance.bindOfferItems(FromWidget, ordItems);
- }
- }
- else {
- instance.getTotals();
- }
- });
- }
- bindOfferItems(FromWidget, ordItems) {
- var instance = this;
- let IsCart = false;
- if ($("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").is(":visible")) {
- IsCart = true;
- }
- let ApplyDate1 = moment(instance.g_OfferApplyDate, "DD/MM/YYYY").add(1, 'days').format("YYYY/MM/DD");
- let ApplyDate = new Date(ApplyDate1);
- let postData = {
- OrderItems: ordItems,
- ContactId: instance._order.g_OrganizationId,
- ApplyType: instance._order.g_OrderTypeId,
- ApplyDate: ApplyDate
- };
- Bizgaze.Apps.Transact.Managers.OfferManager.Instance().getRelatedOffersByItem(postData).then(function (response) {
- return __awaiter(this, void 0, void 0, function* () {
- instance.g_AppliedOffers = [];
- if (response != null && response.Result.length != 0) {
- let AllFocItems = [];
- for (let i = 0; i < response.Result.length; i++) {
- let data = response.Result[i];
- let appliedItems = data.applyIds.replace(/,\s*$/, "").split(',');
- let discValue = 0;
- let discPercent = 0;
- if (data.PayoutValue > 0)
- discValue = data.PayoutValue;
- else if (data.OPayoutValue > 0)
- discValue = data.OPayoutValue;
- else if (data.PayoutPercent > 0)
- discPercent = data.PayoutPercent;
- let volume = data.Volume;
- let focItems = data.ItemVolumePayouts;
- for (let f = 0; f < focItems.length; f++) {
- if (focItems[f].Quantity != 0) {
- AllFocItems.push(focItems[f]);
- }
- }
- let contactId = instance._order.g_OrganizationId;
- for (let j = 0; j < focItems.length; j++) {
- let focItem_RefItemIds = focItems[j].RefItemIds;
- let focItem_RefItemSKUs = focItems[j].RefItemSKUs;
- let ValidFocIndex = instance.g_ValidFocItems.findIndex(x => x.ItemId == focItems[j].ItemId && focItem_RefItemIds.indexOf(x.RefItemIds) != -1);
- let CartItemIndex = instance.g_CartItems_New.findIndex(x => x.ItemId == focItems[j].ItemId && x.RefItemIds == focItem_RefItemIds);
- if (focItems[j].Quantity > 0 && ((ValidFocIndex != -1 && focItems[j].IsFoC) || (!focItems[j].IsFoC))) {
- let FocItem_Index = instance.g_CartItems_New.findIndex(x => x.ItemId == focItems[j].ItemId && x.RefItemIds == focItem_RefItemIds);
- if (FocItem_Index == -1) {
- instance.addFocItemToCart(contactId, focItems[j].ItemId, focItems[j].Quantity, focItems[j].Discount, focItem_RefItemIds, FromWidget, focItem_RefItemSKUs);
- }
- else {
- instance.editFocCartItem(focItems[j].ItemId, focItems[j].Quantity, FromWidget);
- }
- }
- else if (CartItemIndex != -1) {
- instance.deleteCartItems(focItems[j].ItemId, FromWidget, focItem_RefItemIds);
- }
- }
- for (let m = 0; m < appliedItems.length; m++) {
- let IsSelected = false;
- var sp_ItemIndex = Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection.Instance().g_Selected_Plan.findIndex(x => x.PlanVolumeId == data.PlanVolumeId && x.ItemId == Number(appliedItems[m]));
- if (sp_ItemIndex != -1) {
- IsSelected = true;
- }
- instance.g_AppliedOffers.push({
- ItemId: Number(appliedItems[m]),
- OfferId: data.OfferId,
- PlanId: data.PlanId,
- PlanVolumeId: data.PlanVolumeId,
- IsSelected: IsSelected
- });
- let n = instance.g_CartItems_New.findIndex(x => x.ItemId == appliedItems[m] && x.RefItemIds == "");
- if (n != -1) {
- if (!instance._order.g_IsManageOfferDiscount || (instance.g_CartItems_New[n].DiscountValue == 0 && instance.g_CartItems_New[n].DiscountPercent == 0)) {
- if (discValue > 0 || discPercent > 0) {
- instance.g_CartItems_New[n].DiscountValue = discValue;
- instance.g_CartItems_New[n].DiscountPercent = discPercent;
- instance.g_CartItems_New[n].IsFocAdded = true;
- instance.g_CartItems_New[n].IsOfferDiscountApplied = true;
- instance.g_CartItems_New[n].AppliedOfferVolume = volume;
- instance.g_CartItems_New[n].AppliedPlanVolumeId = data.PlanVolumeId;
- instance.g_CartItems_New[n].AppliedOfferId = data.OfferId;
- let Elem = $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + instance.g_CartItems_New[n].ItemId);
- let Cart_Elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + instance.g_CartItems_New[n].ItemId);
- let Discount = discValue == 0 ? discPercent : discValue;
- $("#" + instance.g_VisibleContainerId).find(Elem).find("#Ord_txtdiscount").val(Discount);
- $("#" + instance.g_VisibleContainerId).find(Cart_Elem).find("#Ord_txtdiscount").val(Discount);
- let DiscountType = discValue == 0 ? 1 : 2;
- $("#" + instance.g_VisibleContainerId).find(Elem).find(".btnOrder_DiscType").val(DiscountType);
- $("#" + instance.g_VisibleContainerId).find(Cart_Elem).find(".btnOrder_DiscType").val(DiscountType);
- let AssessableAmount = Number(instance.g_CartItems_New[n].Amount);
- let discVal = Number(instance.g_CartItems_New[n].DiscountValue) * Number(instance.g_CartItems_New[n].BaseQty);
- let DiscAmount = Number((instance.g_CartItems_New[n].Amount * discPercent) / 100) + Number(discVal);
- let discAmt = DiscAmount + Number(instance.g_CartItems_New[n].optoutAmount);
- AssessableAmount = Number(AssessableAmount) - Number(discAmt);
- let AmountWithDiscount = Number(instance.g_CartItems_New[n].Amount) - Number(DiscAmount);
- instance.g_CartItems_New[n].DiscountAmount = discAmt;
- instance.g_CartItems_New[n].AmountWithDiscount = AmountWithDiscount;
- instance.g_CartItems_New[n].DiscountType = DiscountType;
- }
- }
- let amount = Number(instance.g_CartItems_New[n].UnitPrice) * Number(instance.g_CartItems_New[n].BaseQty);
- let discAmt = Number(instance.roundOff((amount * discPercent) / 100)) + Number(instance.roundOff(discValue));
- if (discAmt != 0) {
- let assessableAmount = Number(amount) - Number(discAmt);
- }
- else {
- }
- }
- instance.g_CartItems_New.filter(x => x.IsFocItem == false).forEach(function (c) {
- let Elem = $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + c.ItemId);
- let Cart_Elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + c.ItemId);
- instance.updateItemsDesign(Elem, "AddFocItem_IsOfferDiscountApplied", IsCart);
- instance.updateItemsDesign(Cart_Elem, "AddFocItem_IsOfferDiscountApplied", IsCart);
- });
- }
- }
- let Ref_Items = instance.g_CartItems_New.filter(x => x.RefItemIds != "");
- for (let r = 0; r < Ref_Items.length; r++) {
- let a = AllFocItems.findIndex(x => x.ItemId == Ref_Items[r].ItemId);
- if (a == -1) {
- instance.deleteCartItems(Ref_Items[r].ItemId, FromWidget, Ref_Items[r].RefItemIds);
- }
- }
- }
- else {
- instance.g_CartItems_New.filter(x => x.IsFocItem == true).forEach(function (c) {
- let Foc_Index = instance.g_CartItems_New.findIndex(x => x.ItemId == c.ItemId && x.RefItemIds != "");
- instance.g_CartItems_New.splice(Foc_Index, 1);
- $("#" + instance.g_VisibleContainerId).find(".cartitem-" + c.ItemId + "-" + c.RefItemIds.replace(/,/g, "-")).remove();
- if (FromWidget) {
- $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + c.ItemId + "-" + c.RefItemIds.replace(/,/g, "-")).remove();
- }
- });
- instance.g_CartItems_New.filter(x => x.IsFocItem == false && x.IsOfferAvailable == true && !instance._order.g_IsManageOfferDiscount).forEach(function (c) {
- if (!FromWidget) {
- let Elem = $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + c.ItemId);
- let Cart_Elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + c.ItemId);
- let CartItemIndex = instance.g_CartItems_New.findIndex(x => x.ItemId == c.ItemId);
- if (CartItemIndex != -1) {
- instance.g_CartItems_New[CartItemIndex].DiscountValue = 0;
- instance.g_CartItems_New[CartItemIndex].DiscountPercent = 0;
- instance.g_CartItems_New[CartItemIndex].IsFocAdded = false;
- instance.g_CartItems_New[CartItemIndex].IsOfferDiscountApplied = false;
- instance.g_CartItems_New[CartItemIndex].AppliedOfferVolume = 0;
- instance.g_CartItems_New[CartItemIndex].DiscountAmount = 0;
- instance.g_CartItems_New[CartItemIndex].AmountWithDiscount = instance.g_CartItems_New[CartItemIndex].Amount;
- instance.g_CartItems_New[CartItemIndex].DiscountType = 2;
- }
- instance.updateItemsDesign(Elem, "AddFocItem_IsOfferDiscountApplied", IsCart);
- instance.updateItemsDesign(Cart_Elem, "AddFocItem_IsOfferDiscountApplied", IsCart);
- }
- });
- }
- instance.getTotals();
- if (instance.g_CartItems_New.length == 0) {
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").html('<li id="0" class="cartitem list-group-item col-xs-12 hidden clear no-border"></li> <li class="list-group-item col-xs-12 no-border EmptyCartLi"><strong>Your Shopping Cart is empty.</strong></li>');
- }
- else {
- $("#" + instance.g_VisibleContainerId).find(".EmptyCartLi").remove();
- }
- });
- });
- }
- addFocItemToCart(ContactId, ItemId, Quantity, Discount, RefItemIds, FromWidget, RefItemSKUs = "") {
- let instance = this;
- let ShippingAddressId = $("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_shippingaddressid").val();
- let BranchId = $("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_billfromaddressid").val();
- let LobId = $("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_lobid").val();
- let OrderItemId = 0;
- if (FromWidget) {
- ShippingAddressId = Bizgaze.Apps.Transact.Controls.AddOrderItems.Instance().g_ShippingAddressId;
- BranchId = Bizgaze.Apps.Transact.Controls.AddOrderItems.Instance().g_BranchId;
- LobId = Bizgaze.Apps.Transact.Controls.AddOrderItems.Instance().g_LobId;
- let FocItem = Bizgaze.Apps.Transact.Controls.AddOrderItems.Instance().g_FocItems.find(x => x.ItemId == ItemId);
- if (FocItem != undefined) {
- OrderItemId = FocItem.OrderItemId;
- }
- }
- let ApplyDate1 = moment(instance.g_OfferApplyDate, "DD/MM/YYYY").add(1, 'days').format("YYYY/MM/DD");
- let ApplyDate = new Date(ApplyDate1);
- let postdata = {
- PriceCodeId: Number(instance._order.g_PriceCodeId),
- ContactId: ContactId,
- ShippingAddressId: Number(ShippingAddressId),
- BranchId: Number(BranchId),
- WareHouseId: Number(instance.g_WarehouseId),
- LobId: Number(LobId),
- OrderType: instance._order.g_OrderTypeId,
- OfferOnly: false,
- IsExcise: instance.g_IsExcise,
- SearchTerm: "",
- Page: 0,
- IsCompositePrice: instance.g_IsEnableCompositePrice,
- IsPiecePrice: instance.g_IsEnablePiecePrice,
- IsCompositePiecePrice: instance.g_IsEnableCompositePiecePrice,
- Rows: 10,
- ItemId: ItemId.toString(),
- CountryId: instance._order.g_CountryId,
- ItemGroupId: 0,
- Tags: "",
- IsPoints: instance._order.g_IsPointsOrder,
- Points: instance._order.g_LoyaltyPoints,
- IsEligibleItemsOnly: instance._order.g_LoadEligibleItemsOnly,
- ApplyDate: ApplyDate
- };
- Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItemsForOrder(postdata).then(function (response) {
- let data = response.result[0];
- let LoadedItem_Index = instance.g_LoadedItems.findIndex(z => z.ItemId == data.ItemId);
- if (LoadedItem_Index == -1) {
- instance.g_LoadedItems.push(data);
- }
- else {
- instance.g_LoadedItems[LoadedItem_Index].TaxPercentList = data.TaxPercentList;
- }
- let ItemName = data.ItemName;
- let ItemId = Number(data.ItemId);
- let Packs = 0;
- let PackCount = data.PackCount;
- let PackSize = data.PackSize;
- let UnitPrice = data.UnitPrice;
- let UnitName = data.UnitName;
- let ExpectedPrice = data.UnitPrice;
- let discType = 1;
- let DiscPercent = 0;
- let DiscVal = 0;
- let PriceListId = 0;
- let AvailablePacks = data.AvailablePacks;
- let AvailablePieces = data.AvailablePieces;
- let AvailableQuantity = data.AvailableQuantity;
- let TotalAvailablePieces = data.TotalAvailablePieces;
- let SKU = data.SKU;
- if (Number(PackCount) == 0)
- PackCount = 1;
- if (Number(PackSize) == 0)
- PackSize = 1;
- Quantity = instance.roundOffIgnoreZerosAfterDecimal(Quantity);
- Packs = Number(Quantity) / (PackCount * PackSize);
- let amount = Number(Quantity) * UnitPrice;
- let assessableAmount = Number(amount);
- let discAmt = 0;
- if (discType == 2) {
- DiscVal = Discount;
- discAmt = Number(DiscVal) * Number(Quantity);
- assessableAmount = instance.roundOff(amount - discAmt);
- }
- else if (discType == 1) {
- DiscPercent = Discount;
- discAmt = Number((amount * DiscPercent) / 100);
- assessableAmount = instance.roundOff(Number(assessableAmount) - Number(discAmt));
- if (amount == 0)
- assessableAmount = 0;
- }
- let BaseQty = Number(PackCount) * Number(PackSize) * Number(Packs);
- let IsCalculateTax = instance._order.g_IsCalculateTax;
- let TaxGroupId = 0;
- let TaxAmount = 0;
- let StrTaxPercents = "";
- let TaxGroupName = "";
- let IsTaxError = false;
- if (IsCalculateTax) {
- if (data.TaxGroupId == 0) {
- IsTaxError = true;
- }
- else {
- TaxGroupId = data.TaxGroupId;
- TaxGroupName = data.TaxGroupName;
- for (let p = 0; p < data.TaxPercentList.length; p++) {
- let percen = data.TaxPercentList[p];
- let tax = assessableAmount * percen.Percentage / 100;
- TaxAmount += tax;
- }
- StrTaxPercents = data.strTaxPercents;
- instance.getPriceTypeValues(ItemId);
- if (instance.g_IsEnablePiecePrice) {
- UnitPrice = data.PiecePrice;
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.PiecePrice;
- }
- else if (instance.g_IsEnableCompositePrice) {
- UnitPrice = data.CompositePrice;
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.CompositePrice;
- }
- else if (instance.g_IsEnableCompositePiecePrice) {
- UnitPrice = data.CompositePiecePrice;
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.Both;
- }
- else {
- instance.g_PriceTypeId = Bizgaze.Apps.Transact.Enums.PriceType.None;
- }
- }
- }
- let CItemIndex = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId && x.RefItemIds != "");
- if (CItemIndex != -1) {
- instance.g_CartItems_New.splice(CItemIndex, 1);
- }
- let ItemIndex = instance.g_CartItems_New.length + 1;
- instance.g_CartItems_New.push({
- OrderItemId: OrderItemId,
- ItemIndex: ItemIndex,
- ItemId: ItemId,
- ItemName: ItemName,
- Packs: Quantity,
- Pieces: 0,
- PriceListId: 0,
- UnitPrice: UnitPrice,
- UnitPriceWithOutTax: UnitPrice,
- ExpectedPrice: ExpectedPrice,
- ActualPrice: UnitPrice,
- PackCount: PackCount,
- PackSize: PackSize,
- UnitName: UnitName,
- Quantity: Quantity,
- SKU: SKU,
- PartNo: "",
- Amount: amount,
- AmountWithDiscount: assessableAmount,
- DiscountPercent: DiscPercent,
- DiscountValue: DiscVal,
- DiscountType: discType,
- DiscountAmount: discAmt,
- ItemValueAfterDiscount: assessableAmount,
- StrTaxPercents: StrTaxPercents,
- AvailableQuantity: AvailableQuantity,
- AvailablePacks: AvailablePacks,
- AvailablePieces: AvailablePieces,
- TotalAvailablePieces: TotalAvailablePieces,
- ExchangeDC: false,
- IsAfterTax: false,
- BaseQty: BaseQty,
- IsFocItem: true,
- optoutAmount: 0,
- TaxGroupId: TaxGroupId,
- TaxGroupName: TaxGroupName,
- TaxAmount: TaxAmount,
- TaxRateAmount: 0,
- TaxRate: data.TaxRate,
- TaxPercentage: data.TaxPercentage,
- IsOfferAvailable: false,
- Description: "",
- Discountable: false,
- PiecePrice: 0,
- CompositePrice: 0,
- CompositePiecePrice: 0,
- IsCheckPendingItems: false,
- IsError: false,
- ErrorMsg: "",
- ErrorClass: "text-danger",
- IsTaxError: IsTaxError,
- IsLeverageError: false,
- IsFocAdded: false,
- RefOrderItemId: 0,
- RefItemIds: RefItemIds,
- RefItemSKUs: RefItemSKUs,
- FocItemIds: "",
- DiscountGroupId: 0,
- IsOfferDiscountApplied: false,
- AppliedOfferVolume: 0,
- AppliedPlanVolumeId: 0,
- AppliedOfferId: 0,
- optoutOfferGroupId: 0,
- SuggestedPacks: 0,
- MinPacks: 0,
- AvgPacks: 0,
- InwardOrderPacks: 0,
- OutwardOrderPacks: 0,
- IsManualUOM: data.IsManualUOM,
- UOMs: data.UOMs,
- IsMultipleUOMs: data.IsMultipleUOMs,
- UOMSchemaId: data.UOMSchemaId,
- MultipleUOMs: data.MultipleUOMs,
- SelectedUnitId: 1,
- SelectedUnitName: UnitName,
- DefaultSize: data.DefaultSize,
- IsBoMAvailable: data.IsBoMAvailable,
- IsSpecialPrice: data.IsSpecialPrice,
- ConversionQuantity: 0,
- HSNId: data.HSNId,
- RowTotal: 0,
- RowDiscount: 0,
- TaxTotal: 0
- });
- if (FromWidget) {
- if (RefItemIds == undefined) {
- RefItemIds = "";
- }
- data.RefItemIds = RefItemIds;
- if (RefItemIds != "") {
- $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + ItemId + "-" + RefItemIds.replace(/,/g, "-")).remove();
- $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId + "-" + RefItemIds.replace(/,/g, "-")).remove();
- }
- let html = instance.getItemDesign(data, FromWidget);
- $("#" + instance.g_VisibleContainerId).find(".variant-item:last").after(html);
- let elem = $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId + "-" + RefItemIds.replace(/,/g, "-"));
- if (elem != undefined && elem.length > 0) {
- instance.updateItemsDesign(elem, "FromWidget_FocItem", false, true);
- }
- $("#" + instance.g_VisibleContainerId).find(".defaultSelectedCartons").addClass("floating-label-form-group-with-value");
- }
- else {
- instance.addCartItem(ItemId, true);
- }
- instance.getTotals();
- });
- }
- editFocCartItem(ItemId, Quantity, FromWidget) {
- let instance = this;
- let CartItem = instance.g_CartItems_New.find(x => x.ItemId == ItemId && x.RefItemIds != "");
- let PackCount = CartItem.PackCount;
- let PackSize = CartItem.PackSize;
- let UnitPrice = CartItem.UnitPrice;
- let discType = CartItem.DiscountType;
- let DiscVal = CartItem.DiscountValue;
- let DiscPercent = CartItem.DiscountPercent;
- let discAmt = CartItem.DiscountAmount;
- Quantity = instance.roundOffIgnoreZerosAfterDecimal(Quantity);
- let Packs = Number(Quantity) / (PackCount * PackSize);
- let amount = Number(Quantity) * UnitPrice;
- let assessableAmount = Number(amount);
- let DiscAmount = Number((amount * DiscPercent) / 100) + Number(DiscVal);
- assessableAmount = instance.roundOff(amount - DiscAmount);
- if (amount == 0)
- assessableAmount = 0;
- let BaseQty = Number(PackCount) * Number(PackSize) * Number(Packs);
- let IsCalculateTax = instance._order.g_IsCalculateTax;
- let AmountWithDiscount = Number(amount) - Number(DiscAmount);
- let TaxAmount = 0;
- let LoadedItem = instance.g_LoadedItems.find(x => x.ItemId == ItemId);
- if (IsCalculateTax) {
- if (LoadedItem.TaxGroupId != 0) {
- for (let p = 0; p < LoadedItem.TaxPercentList.length; p++) {
- let percen = LoadedItem.TaxPercentList[p];
- let tax = assessableAmount * percen.Percentage / 100;
- TaxAmount += tax;
- }
- }
- }
- CartItem.BaseQty = BaseQty;
- CartItem.TaxAmount = TaxAmount;
- CartItem.Packs = Quantity;
- CartItem.Amount = amount;
- CartItem.Quantity = Quantity;
- CartItem.AmountWithDiscount = AmountWithDiscount;
- let Foc_elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId + "-" + CartItem.RefItemIds.replace(/,/g, "-"));
- if (FromWidget) {
- Foc_elem = $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId + "-" + CartItem.RefItemIds.replace(/,/g, "-"));
- }
- instance.updateItemsDesign(Foc_elem, "EditFocItem_IsOfferDiscountApplied", true, true);
- }
- getSelectionStart(o) {
- }
- isNumberKey(evt) {
- let instance = this;
- if (evt.type == "paste") {
- let pastedData = evt.clipboardData.getData('text');
- let regExp = /[a-zA-Z]/g;
- if (regExp.test(pastedData)) {
- evt.preventDefault();
- return false;
- }
- }
- else if (evt.type == "input") {
- const inputVal = $("#" + instance.g_VisibleContainerId).find(evt.currentTarget).val();
- $("#" + instance.g_VisibleContainerId).find(evt.currentTarget).val(inputVal.replace(/\D/g, ''));
- }
- else {
- if (evt.which != 8 && evt.which != 0 && (evt.which < 48 || evt.which > 57)) {
- return false;
- }
- }
- return true;
- }
- validateFloatKeyPress(el, evt) {
- var instance = this;
- if (evt.type == "input") {
- const inputVal = $("#" + instance.g_VisibleContainerId).find(el).val();
- $("#" + instance.g_VisibleContainerId).find(el).val(inputVal.replace(/[^\d.]|\.(?=.*\.)/g, ''));
- return;
- }
- if (evt.type == "paste") {
- let pastedData = evt.clipboardData.getData('text');
- let regExp = /[^\d.]|\.(?=.*\.)/g;
- if (regExp.test(pastedData)) {
- evt.preventDefault();
- return false;
- }
- return;
- }
- let charCode = (evt.which) ? evt.which : evt.keyCode;
- let number = el.value.split('.');
- if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
- return false;
- }
- if (number.length > 1 && charCode == 46) {
- return false;
- }
- let caratPos = instance.getSelectionStart(el);
- let dotPos = el.value.indexOf(".");
- if (caratPos > dotPos && dotPos > -1 && (number[1].length > 1)) {
- return false;
- }
- return true;
- }
- countDecimals(n) {
- let decimalcount = 0;
- let decimal = n.toString().split(".");
- if (decimal.length == 1) {
- decimalcount = 0;
- }
- else {
- decimalcount = decimal[1].length;
- }
- return decimalcount;
- }
- getIncrementValue(n) {
- let instance = this;
- let incVal = 1;
- let decimalCount = instance.countDecimals(n);
- if (decimalCount == 0) {
- incVal = 1;
- }
- else {
- let dv = "0.";
- for (let i = 0; i < decimalCount - 1; i++) {
- dv += "0";
- }
- dv += "1";
- incVal = Number(dv);
- }
- return incVal;
- }
- checkValidations(ItemId, IsCart) {
- let instance = this;
- let errormessage = "";
- if (ItemId != 0) {
- let element;
- let Item;
- if (IsCart) {
- let CartItem_Index = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId && x.RefItemIds == "");
- Item = instance.g_CartItems_New[CartItem_Index];
- element = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId);
- }
- else {
- let SelectedItem_Index = instance.g_SelectedItems.findIndex(x => x.ItemId == ItemId && x.RefItemIds == "");
- Item = instance.g_SelectedItems[SelectedItem_Index];
- element = $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + ItemId);
- }
- if (Item != undefined) {
- element.find(".tax-error").text("");
- Item.IsError = false;
- let price = Item.UnitPrice;
- let actualprice = Item.ActualPrice;
- if (price == 0) {
- Item.ErrorMsg += "\n Unit price is zero";
- element.find(".tax-error").text("Unit price is zero").removeClass("text-danger").addClass("text-warning");
- }
- if (price < actualprice && instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales) {
- Item.IsError = true;
- element.find(".tax-error").text("Unit price must be greater than " + actualprice + "").addClass("text-danger").removeClass("text-warning");
- Item.ErrorMsg += "\n Unit price must greater than " + actualprice + "";
- }
- if (!instance._order.g_IsAdmin) {
- if (((Item.DiscountPercent > instance._order.g_LeveragePercent) || (((Item.DiscountValue / Item.UnitPrice) * 100) > instance._order.g_LeveragePercent)) && instance._order.g_IsLeverageApplied == true) {
- Item.IsLeverageError = true;
- $("#" + instance.g_VisibleContainerId).find(element).find("#LeverageErrorTxt").removeClass("hidden");
- $("#" + instance.g_VisibleContainerId).find('.empLeverage').text(instance._order.g_LeveragePercent.toString());
- if ($("#" + instance.g_VisibleContainerId).find('.leverage-Warning').hasClass('hidden'))
- $("#" + instance.g_VisibleContainerId).find('.leverage-Warning').removeClass('hidden');
- }
- else {
- Item.IsLeverageError = false;
- $("#" + instance.g_VisibleContainerId).find(element).find("#LeverageErrorTxt").addClass("hidden");
- if (!$("#" + instance.g_VisibleContainerId).find('.leverage-Warning').hasClass('hidden'))
- $("#" + instance.g_VisibleContainerId).find('.leverage-Warning').addClass('hidden');
- }
- }
- else {
- Item.IsLeverageError = false;
- }
- if (Item.HSNId == 0 && !instance._order.g_IsPointsOrder) {
- Item.IsError = true;
- Item.ErrorMsg = "HSN not assigned";
- element.find(".tax-error").text("HSN not assigned").addClass("text-danger").removeClass("text-warning");
- }
- if (Item.IsTaxError && Item.BaseQty != 0 && !instance._order.g_IsPurchasePlanning && IsCart) {
- Item.IsError = true;
- Item.ErrorMsg = "Tax not assigned";
- element.find(".tax-error").text("Tax not assigned").addClass("text-danger").removeClass("text-warning");
- }
- if (Item.DiscountPercent > 100) {
- element.find(".tax-error").text("Discount % can't be greater than 100").addClass("text-danger").removeClass("text-warning");
- Item.ErrorMsg += "\n Discount % can't be greater than 100";
- Item.IsError = true;
- }
- if (Item.AmountWithDiscount < 0) {
- element.find(".tax-error").text("Item total can't be less than zero").addClass("text-danger").removeClass("text-warning");
- Item.ErrorMsg += "\n Item total can't be less than zero";
- Item.IsError = true;
- }
- if (instance._order.g_IsSC_to_PC && !instance._order.g_IsFromPurchaseIndent) {
- let g_SC_PC_Index = instance.g_SC_PC_CartItems.findIndex(x => x.ItemId == Item.ItemId);
- let ActualQty = instance.g_SC_PC_CartItems[g_SC_PC_Index].Quantity;
- if (g_SC_PC_Index != -1) {
- if (Item.Quantity > ActualQty) {
- element.find(".tax-error").text("Qty can't be greater than " + ActualQty).addClass("text-danger").removeClass("text-warning");
- Item.ErrorMsg += "\n Qty can't be greater than " + ActualQty;
- Item.IsError = true;
- }
- }
- }
- }
- }
- instance.checkErrors();
- instance.checkEnablePieces();
- instance.checkEnablePacks();
- return errormessage;
- }
- checkErrors() {
- let instance = this;
- let IsCart = false;
- if (!$("#" + instance.g_VisibleContainerId).find("#Items-list").is(":visible")) {
- IsCart = true;
- }
- let Items = [];
- if (IsCart) {
- Items = instance.g_CartItems_New;
- }
- else {
- Items = instance.g_SelectedItems;
- }
- let errors = Items.filter(x => x.IsError == true);
- let leverageErrors = Items.filter(x => x.IsLeverageError == true);
- if (leverageErrors.length == 0) {
- instance._order.g_IsApprovalRequired = false;
- if (!$("#" + instance.g_VisibleContainerId).find('.leverage-Warning').hasClass('hidden'))
- $("#" + instance.g_VisibleContainerId).find('.leverage-Warning').addClass('hidden');
- }
- else {
- instance._order.g_IsApprovalRequired = true;
- $("#" + instance.g_VisibleContainerId).find('.empLeverage').text(instance._order.g_LeveragePercent.toString());
- if ($("#" + instance.g_VisibleContainerId).find('.leverage-Warning').hasClass('hidden'))
- $("#" + instance.g_VisibleContainerId).find('.leverage-Warning').removeClass('hidden');
- }
- if (errors.length == 0) {
- instance.enableSave();
- }
- else {
- instance.disableSave();
- }
- }
- checkEnablePieces() {
- let instance = this;
- let picesfound = instance.g_CartItems_New.filter(x => x.Pieces > 0);
- if (picesfound.length > 0) {
- $("#" + instance.g_VisibleContainerId).find('#chk_Pieces').attr('disabled', "true");
- $("#" + instance.g_VisibleContainerId).find(".divEnablePieces").removeClass("checkbox-primary");
- }
- else {
- $("#" + instance.g_VisibleContainerId).find('#chk_Pieces').removeAttr('disabled');
- $("#" + instance.g_VisibleContainerId).find(".divEnablePieces").addClass("checkbox-primary");
- }
- }
- checkEnablePacks() {
- let instance = this;
- let packsfound = instance.g_CartItems_New.filter(x => x.Packs > 0);
- if (packsfound.length > 0) {
- $("#" + instance.g_VisibleContainerId).find('#chk_Packs').attr('disabled', "true");
- $("#" + instance.g_VisibleContainerId).find(".divEnablePacks").removeClass("checkbox-primary");
- }
- else {
- $("#" + instance.g_VisibleContainerId).find('#chk_Packs').removeAttr('disabled');
- $("#" + instance.g_VisibleContainerId).find(".divEnablePacks").addClass("checkbox-primary");
- }
- }
- checkLoyalityErrors(element) {
- let instance = this;
- if (instance._order.g_IsPointsOrder) {
- let TotalQty = 0;
- let TotalCartQty = 0;
- let GrossAmount = 0;
- let ItemId = Number($("#" + instance.g_VisibleContainerId).find(element).find(".hfOrder_ItemId").val());
- let TotalPoints = instance._order.g_LoyaltyPoints;
- instance.g_CartItems_New.forEach(x => TotalQty += x.UnitPrice * x.BaseQty);
- if (instance._order.g_LoyaltyPoints < TotalQty) {
- element.find("#txt_Cartons").val(0);
- instance.updateItemsArray(element, "LoyaltyError", false);
- element.find(".tax-error").text("Redeem Quantity can't be greater than Loyalty Points").removeClass("text-danger").addClass("text-warning");
- instance.deleteCartItems(ItemId);
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").find(".cartitem-" + ItemId).remove();
- let ItemIndex = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId && x.RefItemIds == "");
- if (ItemIndex != -1) {
- instance.g_CartItems_New.splice(ItemIndex, 1);
- }
- TotalQty = 0;
- instance.g_CartItems_New.forEach(x => TotalQty += x.UnitPrice * x.BaseQty);
- }
- instance.g_CartItems_New.forEach(x => TotalCartQty += x.BaseQty);
- instance.g_CartItems_New.forEach(x => GrossAmount += x.UnitPrice * x.BaseQty);
- $("#" + instance.g_VisibleContainerId).find("#lblSummary_GrossAmount, #lblSummary_AssessableTotal, #lblSummary_NetTotal").text(GrossAmount);
- $("#" + instance.g_VisibleContainerId).find("#lblSummary_TotalDiscount").text("0.00");
- $("#" + instance.g_VisibleContainerId).find("#OverallOrderQuantity").text(TotalCartQty);
- $("#" + instance.g_VisibleContainerId).find("#AvailablePoints").text(TotalPoints - TotalQty);
- $("#" + instance.g_VisibleContainerId).find("#AvailablePoints_header").text(TotalPoints - TotalQty);
- $("#" + instance.g_VisibleContainerId).find("#RedeemPoints").text(TotalQty);
- }
- }
- disableSave() {
- let instance = this;
- $("#" + instance.g_VisibleContainerId).find(".btn_Save_Form").find("button").attr("disabled", "disabled").css("cursor", "not-allowed");
- $("#" + instance.g_VisibleContainerId).find(".btn_OrderSaveAsDraft").attr("disabled", "disabled").css("cursor", "not-allowed");
- return false;
- }
- enableSave() {
- let instance = this;
- $("#" + instance.g_VisibleContainerId).find(".btn_Save_Form").find("button").removeAttr("disabled").css("cursor", "auto");
- $("#" + instance.g_VisibleContainerId).find(".btn_OrderSaveAsDraft").removeAttr("disabled").css("cursor", "auto");
- }
- checkPendingPopup(ItemId, CartItemIndex, FromWidget = false) {
- let instance = this;
- let branchId = instance._order.g_BranchId;
- Bizgaze.Apps.Transact.Managers.OrderManager.Instance().getPendingOrderItemsByItemAndCustomer(instance._order.g_OrderTypeId, ItemId, instance._order.g_OrganizationId, 0, 20, branchId, instance._order.g_OrderId).then(function (response) {
- if (response.result.length > 0) {
- let quantity = 0;
- let item = [];
- for (let i = 0; i < response.result.length; i++) {
- item = response.result[i];
- quantity += item.Quantity - item.DeliveredQuantity;
- }
- quantity = instance.roundOff(quantity);
- let msg = item.ItemName + " have " + quantity + " pending quantity..! Are you sure to continue ??";
- bootbox.confirm({
- message: msg,
- closeButton: false,
- buttons: {
- confirm: {
- label: 'Yes',
- className: 'btn-success'
- },
- cancel: {
- label: 'No',
- className: 'btn-danger'
- }
- },
- callback: function (result) {
- debugger;
- let Item = instance.g_SelectedItems.find(x => x.ItemId == ItemId);
- let elem = $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + ItemId);
- if (result) {
- if (Item != null) {
- Item.IsCheckPendingItems = false;
- }
- if (FromWidget) {
- instance.checkOffers(FromWidget, "CheckPendingPopUp_FromWidget");
- }
- else {
- if (Item == null) {
- instance.addCartItem(ItemId);
- }
- else {
- instance.updateItemsArray(elem, "Plus");
- }
- }
- }
- else {
- $("#" + instance.g_VisibleContainerId).find('#modal_popup_EditLineItem').modal('hide');
- bootbox.hideAll();
- $("#" + instance.g_VisibleContainerId).find(elem).find(".txtOrder_ItemCount").val(0);
- instance.updateItemsArray(elem, "PendingPopCancel");
- if (instance._order.g_IsPurchasePlanning)
- $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + ItemId).find(".chk_PurPlanItem").prop("checked", false);
- return false;
- }
- }
- });
- }
- else {
- if (CartItemIndex != -1) {
- let elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId);
- if (FromWidget) {
- elem = $("#" + instance.g_VisibleContainerId).find(".variant-addeditem-" + ItemId);
- }
- instance.updateItemsDesign(elem, "EditCartItem", true);
- }
- else {
- instance.addCartItem(ItemId);
- }
- }
- });
- }
- addCartItem(ItemId, IsFocItem = false) {
- debugger;
- let instance = this;
- let CartItems_Index = -1;
- if (IsFocItem) {
- CartItems_Index = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId && x.RefItemIds != "");
- }
- else {
- CartItems_Index = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId && x.RefItemIds == "");
- }
- let CartItm = instance.g_CartItems_New[CartItems_Index];
- let elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId);
- let RefItemIds = CartItm.RefItemIds;
- if (RefItemIds != "") {
- elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId + "-" + RefItemIds.replace(/,/g, "-"));
- $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId + "-" + RefItemIds.replace(/,/g, "-")).remove();
- }
- let html = instance.getItemDesign(CartItm, false, true);
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").append(html);
- elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId);
- let evnt = "EditCartItem";
- if (CartItm.IsFocItem) {
- evnt = "EditFocItem";
- }
- if (RefItemIds != "") {
- elem = $("#" + instance.g_VisibleContainerId).find(".cartitem-" + ItemId + "-" + RefItemIds.replace(/,/g, "-"));
- }
- instance.updateItemsDesign(elem, evnt, true, IsFocItem);
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").find(".chk_PurPlanItem").addClass("hidden");
- instance.allItemEvents(elem);
- }
- deleteCartItems(ItemId, FromWidget = false, RefItemIds = "", event = "") {
- let instance = this;
- let itemelement = $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId);
- let element_name = "cartitem-";
- if (FromWidget) {
- element_name = "variant-addeditem-";
- }
- $("#" + instance.g_VisibleContainerId).find("." + element_name + ItemId).remove();
- let FocItems = instance.g_CartItems_New.filter(x => x.RefItemIds.indexOf(ItemId) != -1);
- for (let f = 0; f < FocItems.length; f++) {
- let Foc_Index = instance.g_CartItems_New.findIndex(x => x.ItemId == FocItems[f].ItemId && x.RefItemIds == FocItems[f].RefItemIds);
- $("#" + instance.g_VisibleContainerId).find("." + element_name + FocItems[f].ItemId + "-" + FocItems[f].RefItemIds.replace(/,/g, "-")).remove();
- instance.g_CartItems_New.splice(Foc_Index, 1);
- }
- let deletecartitemindex = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId && x.RefItemIds == RefItemIds);
- let deleteitemindex = instance.g_SelectedItems.findIndex(x => x.ItemId == ItemId && x.RefItemIds == RefItemIds);
- if (deleteitemindex != -1) {
- instance.g_SelectedItems.splice(deleteitemindex, 1);
- }
- if (deletecartitemindex != -1) {
- if (!instance._order.g_IsPurchasePlanning) {
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find(".txtOrder_ItemCount,.txtOrder_ItemPieceCount").val("");
- if (event == "") {
- instance.resetItemDetails(ItemId);
- }
- else {
- if (event == "Plus" || event == "Minus" || event == "Packs" || event == "Minus") {
- instance.resetItemDetails(ItemId);
- }
- }
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find("#DiscountOpenBracket").addClass('hidden');
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find("#QuantityAndDiscountSpan").text('');
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find(".defaultSelectedCartons").removeClass('floating-label-form-group-with-value');
- }
- if (deletecartitemindex != -1) {
- instance.g_CartItems_New.splice(deletecartitemindex, 1);
- if (RefItemIds != "") {
- $("#" + instance.g_VisibleContainerId).find("." + element_name + ItemId + "-" + RefItemIds.replace(/,/g, "-")).remove();
- }
- else {
- $("#" + instance.g_VisibleContainerId).find("." + element_name + ItemId).remove();
- }
- }
- $(this).parents(".cartitem").remove();
- if (!instance._order.g_IsPointsOrder && !instance._order.g_IsPurchasePlanning) {
- instance.checkOffers(false, "DeleteCartItem");
- }
- if (instance.g_CartItems_New.length == 0) {
- $("#" + instance.g_VisibleContainerId).find("#ulOrder_Cart").html('<li id="0" class="cartitem list-group-item col-xs-12 hidden clear no-border"></li> <li class="list-group-item col-xs-12 no-border EmptyCartLi"><strong>Your Shopping Cart is empty.</strong></li>');
- }
- instance.getTotals(ItemId);
- instance.checkErrors();
- instance.checkLoyalityErrors(itemelement);
- }
- }
- resetItemDetails(ItemId) {
- let instance = this;
- let LoadedItem_Index = instance.g_LoadedItems.findIndex(x => x.ItemId == ItemId);
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find("#Ord_txtdiscount, #txt_Description").val("");
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find(".discountFloatLabels, .descriptionFloatLabels").removeClass('floating-label-form-group-with-value');
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find(".btnOrder_DiscType").val(2);
- let Items_Price_Index = instance.g_ItemsUnitPrice_New.findIndex(x => x.ItemId == ItemId);
- if (Items_Price_Index != -1) {
- let UnitPrice = instance.g_LoadedItems[LoadedItem_Index].UnitPrice;
- instance.g_ItemsUnitPrice_New[Items_Price_Index].UnitPrice = UnitPrice;
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find("#txt_editItemPrice").val(UnitPrice);
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find(".editItemPrice").text(UnitPrice);
- $("#" + instance.g_VisibleContainerId).find('.variant-addeditem-' + ItemId).find("#chkItem_ExchangeDC_" + ItemId).prop("checked", false);
- }
- }
- roundOff(n, decimalValue = 2) {
- return Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(n, decimalValue);
- }
- roundOffIgnoreZerosAfterDecimal(n, decimalValue = 2) {
- n = Number(n);
- return Number(n.toFixed(decimalValue));
- }
- getPriceTypeValues(ItemId, Packs = 0, Pieces = 0) {
- let instance = this;
- let taxpercentage = 0, TaxRate = 0, TaxRateAmount = 0, strTaxPercents = "", CompositePiecePriceTaxRate = 0;
- let LoadedItem = instance.g_LoadedItems.find(x => x.ItemId == ItemId);
- if (LoadedItem != undefined) {
- let taxPercentList = LoadedItem.TaxPercentList;
- let PackSize = LoadedItem.PackSize;
- let ItemUnitPrices = instance.g_ItemsUnitPrice_New.find(x => x.ItemId == ItemId);
- let UnitPrice = 0;
- if (ItemUnitPrices != undefined) {
- UnitPrice = ItemUnitPrices.UnitPrice;
- }
- let CartItemIndex = instance.g_CartItems_New.findIndex(x => x.ItemId == ItemId);
- let PiecePrice = Number(UnitPrice) * Number(PackSize);
- if (taxPercentList != null) {
- for (let i = 0; i < taxPercentList.length; i++) {
- let percen = taxPercentList[i];
- taxpercentage += percen.Percentage;
- TaxRate += UnitPrice * percen.Percentage / 100;
- CompositePiecePriceTaxRate += PiecePrice * percen.Percentage / 100;
- strTaxPercents += percen.LedgerId + ":" + percen.Percentage + ",";
- }
- TaxRateAmount = UnitPrice + TaxRate;
- }
- if (TaxRateAmount == 0) {
- TaxRateAmount = UnitPrice;
- }
- let CompositePrice = Number(TaxRateAmount);
- let CompositePiecePrice = 0;
- if (instance.g_IsEnableCompositePiecePrice) {
- CompositePiecePrice = Number(CompositePiecePriceTaxRate) + PiecePrice;
- }
- LoadedItem.CompositePrice = Number(instance.roundOff(CompositePrice));
- LoadedItem.PiecePrice = Number(instance.roundOff(PiecePrice));
- LoadedItem.CompositePiecePrice = Number(instance.roundOff(CompositePiecePrice));
- if (CartItemIndex != -1) {
- instance.g_CartItems_New[CartItemIndex].CompositePrice = Number(instance.roundOff(CompositePrice));
- instance.g_CartItems_New[CartItemIndex].PiecePrice = Number(instance.roundOff(PiecePrice));
- instance.g_CartItems_New[CartItemIndex].CompositePiecePrice = Number(instance.roundOff(CompositePiecePrice));
- }
- }
- }
- getAmountWithTax(ItemId, Amount) {
- let instance = this;
- let TaxRate = 0, AmountWithTax = 0;
- let LoadedItem = instance.g_LoadedItems.find(x => x.ItemId == ItemId);
- if (LoadedItem != undefined) {
- let taxPercentList = LoadedItem.TaxPercentList;
- if (taxPercentList != null) {
- for (let i = 0; i < taxPercentList.length; i++) {
- let percen = taxPercentList[i];
- TaxRate += Amount * percen.Percentage / 100;
- }
- AmountWithTax = Amount + TaxRate;
- }
- }
- return instance.roundOffIgnoreZerosAfterDecimal(AmountWithTax) + '|' + instance.roundOffIgnoreZerosAfterDecimal(TaxRate);
- }
- getTotals(ModifiedItemId = 0) {
- let instance = this;
- let BranchId = 0;
- let BillingAddressId = 0;
- if (instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales || instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim)
- BranchId = Number($("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_billfromaddressid").val());
- else
- BranchId = Number($("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_billingaddressid").val());
- $("#" + instance.g_VisibleContainerId).find(".hdn_branchid").val(BranchId);
- if (instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales || instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim)
- BillingAddressId = Number($("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_billingaddressid").val());
- else
- BillingAddressId = Number($("#" + instance.g_VisibleContainerId).find(".txtAutoComplete_billfromaddressid").val());
- if (isNaN(BillingAddressId)) {
- let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- let InputParameters = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters;
- if (instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.Sales || instance._order.g_OrderTypeId == Bizgaze.Apps.Transact.Enums.OrderType.PurchaseClaim)
- BillingAddressId = Number(InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_billingaddressid").Value);
- else
- BillingAddressId = Number(InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_billfromaddressid").Value);
- }
- let EstimateId = 0;
- let IsSelectAll = false;
- if (instance._order.g_IsPurchasePlanning) {
- if ($("#" + instance.g_VisibleContainerId).find(".chk_PurPlanItem:visible").length != $("#" + instance.g_VisibleContainerId).find(".chk_PurPlanItem:visible:checked").length) {
- $("#" + instance.g_VisibleContainerId).find('#chk_AllItems').prop('checked', false);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find('#chk_AllItems').prop('checked', true);
- }
- let InputParameters = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters;
- let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- if (InputParameters.length > 0 && InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_estimateid") != undefined) {
- EstimateId = Number(InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_estimateid").Value);
- }
- IsSelectAll = $("#" + instance.g_VisibleContainerId).find('#chk_AllItems').is(':checked');
- }
- else {
- ModifiedItemId = 0;
- }
- if (instance._order.g_IsPointsOrder) {
- let GrossAmount = 0;
- let TotalCartQty = 0;
- instance.g_CartItems_New.forEach(x => GrossAmount += x.UnitPrice * x.BaseQty);
- $("#" + instance.g_VisibleContainerId).find("#lblSummary_GrossAmount, #lblSummary_AssessableTotal, #lblSummary_NetTotal").text(instance.roundOff(GrossAmount));
- $("#" + instance.g_VisibleContainerId).find("#lblSummary_TotalDiscount").text("0.00");
- instance.g_CartItems_New.forEach(x => TotalCartQty += x.BaseQty);
- $("#" + instance.g_VisibleContainerId).find("#OverallOrderQuantity").text(TotalCartQty);
- $("#" + instance.g_VisibleContainerId).find(".netpacks").text(instance.g_CartItems_New.length);
- $("#" + instance.g_VisibleContainerId).find("#PriceDetails_Discount, #PriceDetails_AssblAmount").addClass("hidden");
- }
- else {
- let postdata = {
- OrderItems: instance.g_CartItems_New,
- IsCompositePrice: instance.g_IsEnableCompositePrice,
- IsPiecePrice: instance.g_IsEnablePiecePrice,
- IsTaxInclusive: instance._order.g_IsTaxInclusive == undefined ? false : instance._order.g_IsTaxInclusive,
- IsCalculateTax: instance._order.g_IsCalculateTax == undefined ? false : instance._order.g_IsCalculateTax,
- OrderTypeId: instance._order.g_OrderTypeId,
- BranchId: instance._order.g_BranchId,
- BillingAddressId: BillingAddressId,
- InventoryApplyType: instance._order.g_InventoryApplyType,
- PurchasePlanModifiedItemId: Number(ModifiedItemId),
- IsSelectAll: IsSelectAll,
- EstimateId: EstimateId
- };
- instance.g_AppliedTaxGroups = new Array();
- Bizgaze.Apps.Transact.Managers.OrderManager.Instance().getTotals(postdata).then(function (response) {
- instance.g_Totals = response.result;
- let res = instance.g_Totals;
- instance.g_CartItems_New.forEach(c => {
- if (res.ItemWiseTaxGroups != null) {
- let TaxGroupId = res.ItemWiseTaxGroups[c.ItemId];
- c.TaxGroupId = TaxGroupId;
- }
- c.RowTotal = res.OrderItems.find(x => x.ItemId == c.ItemId).RowTotal;
- c.RowDiscount = res.OrderItems.find(x => x.ItemId == c.ItemId).RowDiscount;
- c.TaxTotal = res.OrderItems.find(x => x.ItemId == c.ItemId).TaxTotal;
- });
- if (instance.roundOff(res.TotalScrapDiscountAmount) > 0)
- $("#" + instance.g_VisibleContainerId).find("#div_ScrapDiscount").removeClass("hidden");
- else
- $("#" + instance.g_VisibleContainerId).find("#div_ScrapDiscount").addClass("hidden");
- $("#" + instance.g_VisibleContainerId).find('#lblSummary_GrossAmount, .labelSection_Gross_Value').text(instance.roundOff(res.GrossAmount));
- $("#" + instance.g_VisibleContainerId).find('#lblSummary_TotalDiscount, .labelSection_Discount_Value').text(instance.roundOff(res.TotalDiscount));
- $("#" + instance.g_VisibleContainerId).find('#lblSummary_NetTotal, .labelSection_Total_Value').text(instance.roundOff(res.NetTotal));
- $("#" + instance.g_VisibleContainerId).find('#lblSummary_AssessableTotal').text(instance.roundOff(res.AssessableAmount));
- $("#" + instance.g_VisibleContainerId).find('#lblSummary_TaxTotal').text(instance.roundOff(res.TotalTax));
- $("#" + instance.g_VisibleContainerId).find('#lblSummary_ScrapDiscountAmount').text('-' + (instance.roundOff(res.TotalScrapDiscountAmount)));
- $("#" + instance.g_VisibleContainerId).find(".hdn_scrapdiscountamount").val(instance.roundOff(res.TotalScrapDiscountAmount));
- if (instance._order.g_IsPurchasePlanning) {
- $("#" + instance.g_VisibleContainerId).find(".labelSection_Gross_Value, .labelSection_Discount_Value, .labelSection_Total_Value, .labelSection_GrossAmount, .labelSection_DiscountAmount, .labelSection_NetTotal").addClass("font-weight-bold").addClass("col-sm-12").addClass("text-center");
- if (instance.g_CartItems_New.length == 0) {
- $("#" + instance.g_VisibleContainerId).find("#btnDynamicSave").addClass("disabled").css("cursor", "not-allowed");
- }
- else {
- $("#" + instance.g_VisibleContainerId).find("#btnDynamicSave").removeClass("disabled").css("cursor", "auto");
- }
- }
- $("#" + instance.g_VisibleContainerId).find('#OverallOrderQuantity').text(instance.roundOffIgnoreZerosAfterDecimal(res.TotalQuantity, 2));
- $("#" + instance.g_VisibleContainerId).find(".netpacks").text(instance.g_CartItems_New.length);
- });
- }
- }
- getPurchasePlanTotals(OnlyTotals, IsChangedSelectAllChkbx) {
- let instance = this;
- if ($("#" + instance.g_VisibleContainerId).find(".chk_PurPlanItem:visible").length != $("#" + instance.g_VisibleContainerId).find(".chk_PurPlanItem:visible:checked").length) {
- $("#" + instance.g_VisibleContainerId).find('#chk_AllItems').prop('checked', false);
- }
- else {
- $("#" + instance.g_VisibleContainerId).find('#chk_AllItems').prop('checked', true);
- }
- let EstimateId = 0;
- let IsSelectAll = false;
- if (instance._order.g_IsPurchasePlanning) {
- let InputParameters = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters;
- let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- if (InputParameters.length > 0 && InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_estimateid") != undefined) {
- EstimateId = Number(InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_estimateid").Value);
- }
- IsSelectAll = $("#" + instance.g_VisibleContainerId).find('#chk_AllItems').is(':checked');
- }
- let postdata = {
- IsChangedSelectAll: IsChangedSelectAllChkbx,
- IsConfirmed: IsSelectAll,
- IsSelectAll: IsSelectAll,
- EstimateId: EstimateId,
- OnlyTotals: OnlyTotals
- };
- Bizgaze.Apps.Transact.Managers.OrderManager.Instance().getPurchasePlanTotals(postdata).then(function (response) {
- instance.g_Totals = response.result;
- let res = instance.g_Totals;
- if (instance.roundOff(res.TotalScrapDiscountAmount) > 0)
- $("#" + instance.g_VisibleContainerId).find("#div_ScrapDiscount").removeClass("hidden");
- else
- $("#" + instance.g_VisibleContainerId).find("#div_ScrapDiscount").addClass("hidden");
- $("#" + instance.g_VisibleContainerId).find('#lblSummary_GrossAmount, .labelSection_Gross_Value').text(instance.roundOff(res.GrossAmount));
- $("#" + instance.g_VisibleContainerId).find('#lblSummary_TotalDiscount, .labelSection_Discount_Value').text(instance.roundOff(res.TotalDiscount));
- $("#" + instance.g_VisibleContainerId).find('#lblSummary_NetTotal, .labelSection_Total_Value').text(instance.roundOff(res.AssessableAmount));
- });
- }
- getOrderItems(OrderId = 0) {
- let instance = this;
- let ItemList = new Array();
- for (let c = 0; c < instance.g_CartItems_New.length; c++) {
- let orderItemIndex = c;
- let CartItem = instance.g_CartItems_New[c];
- let FocItemIds = "";
- instance.g_CartItems_New.filter(z => z.RefItemIds.indexOf(CartItem.ItemId.toString()) > -1).forEach(x => {
- FocItemIds += x.ItemId + "|";
- });
- if (CartItem.IsFocItem || CartItem.Quantity == 0) {
- continue;
- }
- let Quantity = CartItem.Quantity;
- var Category_Id = $($(".cartitem-" + CartItem.ItemId).parentsUntil("cartItemsSortable")[0]).attr("id");
- if (Category_Id != undefined) {
- Category_Id = Category_Id.replace("catItemsSortable_", "");
- }
- let CategoryName = $("#catTitleSpan_" + Category_Id).text();
- ItemList.push({
- OrderItemId: CartItem.OrderItemId,
- OrderId: OrderId,
- OrderItemIndex: orderItemIndex,
- ItemId: CartItem.ItemId,
- ItemName: CartItem.ItemName,
- UnitPrice: CartItem.UnitPriceWithOutTax,
- PriceListId: CartItem.PriceListId,
- ExpectedPrice: CartItem.ExpectedPrice,
- Quantity: Quantity,
- ConversionQuantity: CartItem.ConversionQuantity,
- TaxGroupId: CartItem.TaxGroupId,
- TaxGroupName: CartItem.TaxGroupName,
- Description: CartItem.Description,
- DiscountPercent: CartItem.DiscountPercent,
- DiscountAmount: CartItem.DiscountAmount,
- DiscountValue: CartItem.DiscountValue,
- DiscountGroupId: CartItem.DiscountGroupId,
- RefNo: "",
- AvailableQty: CartItem.AvailableQuantity,
- ExchangeDC: CartItem.ExchangeDC,
- HideOnInvoice: false,
- Packs: CartItem.Packs,
- Pieces: CartItem.Pieces,
- IsAfterTax: CartItem.IsAfterTax,
- OptOutAmount: CartItem.optoutAmount,
- OptOutCampaignGroupId: CartItem.optoutOfferGroupId,
- IsFoc: CartItem.IsFocItem,
- OrderFromEstimate: false,
- PriceTypeId: Number(instance.g_PriceTypeId),
- RefOrderItemId: Number(CartItem.RefOrderItemId),
- RefItemIds: CartItem.RefItemIds,
- FocItemIds: FocItemIds,
- AlternateUnitId: CartItem.SelectedUnitId,
- DefaultSize: CartItem.DefaultSize,
- SKU: CartItem.SKU,
- RowTotal: CartItem.RowTotal,
- RowDiscount: CartItem.RowDiscount,
- TaxTotal: CartItem.TaxTotal,
- CategoryName: CategoryName
- });
- }
- return ItemList;
- }
- getItemPreview(Itemid) {
- var instance = this;
- instance.fileCacheHelper.loadJsFile('apps/transact/controls/itemdetails/itemscarousel.js', function () {
- instance.navigationHelper.popup(Itemid, '', Bizgaze.Apps.Transact.Controls.ItemDetails.ItemsCarousel.Instance(), null, Unibase.Platform.Helpers.Size.Medium);
- });
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new OrderItems();
- }
- return this.instance;
- }
- }
- Controls.OrderItems = OrderItems;
- })(Controls = Transact.Controls || (Transact.Controls = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
-
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Components;
- (function (Components) {
- class OrderFilter extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.g_TagArray = [];
- this.g_ClearingTags = "";
- this.g_ContainerId = "";
- this.g_Tags = "";
- this.g_OnlyFilters = false;
- this.g_TagCategoryId = 0;
- this.g_LobId = 0;
- }
- cssFiles() {
- return [];
- }
- jsFiles() {
- var jsFiles = ['apps/crm/lobs/managers/lobmanager.js', 'apps/transact/managers/inventory/itemmanager.js'];
- return jsFiles;
- }
- html(id, containerid) {
- var instance = this;
- instance.g_ContainerId = containerid;
- var html = `<header class="b-b bg-white modal-header pt-10 pb-10">
- <strong class="text-dark titlename">Filters</strong>
- <div class="btn-group ml-auto"> <a class="btn btn-sm"><i class="ti-help-alt" title="help" href="" target="_blank"></i></a></div>
- </header>
- <div style="overflow-x:hidden;" class="scrollable">
- <div class="card">
- <div class="card-body">
- <div class="divTagList"></div>
- </div>
- </div>
- </div>
- <footer class="bg-white modal-footer pt-10 pb-10">
- <a href="javascript:;" id="btn_CancelFilter" class="btn btn-light btn-sm mr-auto"> Close </a>
- <a href="javascript:;" id="btn_ApplyFilter" class="btn btn-primary btn-sm">Apply</a>
- <a href="javascript:;" id="btn_ClearFilter" class="btn btn-primary btn-sm">Clear</a>
- </footer>`;
- return html;
- }
- load(id, containerid, callback) {
- var instance = this;
- instance.g_LobId = Number($(".txtAutoComplete_LobId").val());
- instance.categoryTagItem();
- if (id == "POS") {
- instance.g_order = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance();
- instance.g_orderItem = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance();
- }
- else {
- instance.g_order = Bizgaze.Apps.Transact.Controls.Order.Instance();
- instance.g_orderItem = Bizgaze.Apps.Transact.Controls.OrderItems.Instance();
- }
- if (isNaN(instance.g_LobId)) {
- instance.g_LobId = instance.g_order.g_LobId;
- }
- $('#btn_CancelFilter').click(function () {
- for (var i = 0; i < instance.g_TagArray.length; i++) {
- instance.g_ClearingTags += instance.g_TagArray[i].TagId + "|";
- }
- instance.g_ClearingTags = instance.g_ClearingTags.replace(/\:$/, '');
- instance.g_Tags = instance.g_ClearingTags;
- instance.filterItemsByTags(instance.g_ClearingTags, false);
- });
- $('#btn_ClearFilter').click(function () {
- instance.g_orderItem.g_IsFilterApplied = false;
- instance.g_orderItem.g_FilteredTags = '';
- instance.clearAll();
- });
- $('#btn_ApplyFilter').click(function () {
- instance.g_orderItem.g_IsFilterApplied = true;
- instance.showFilteredItems();
- });
- }
- bindCustomerTags(id = "") {
- var instance = this;
- if (id == "POS") {
- instance.g_order = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance();
- instance.g_orderItem = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance();
- }
- else {
- instance.g_order = Bizgaze.Apps.Transact.Controls.Order.Instance();
- instance.g_orderItem = Bizgaze.Apps.Transact.Controls.OrderItems.Instance();
- }
- var TagGroupId = instance.g_order.g_TagGroupId;
- var OrganizationId = instance.g_order.g_OrganizationId;
- Unibase.Platform.Forms.Managers.TagManager.Instance().GetTagsByRefId(OrganizationId, TagGroupId).then(function (response) {
- var data = response.result;
- var options = '';
- var tags = '';
- instance.g_TagArray = [];
- for (var i = 0; i < data.length; i++) {
- if (data[i] != undefined) {
- instance.g_TagArray.push({ TagId: data[i].TagId, TagName: data[i].TagName, ParentId: data[i].ParentRootId });
- options += data[i].TagId + "|";
- }
- }
- if (options != '') {
- options = options.replace(/\|$/, '');
- tags = options;
- }
- if (tags != '') {
- tags = tags.replace(/\:$/, '');
- }
- instance.g_Tags = tags;
- instance.filterItemsByTags(tags, true);
- if (Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_TagArray.length != 0) {
- $("#ItemLoadType option[value='1']").remove();
- instance.g_OnlyFilters = true;
- }
- });
- }
- addTagItem(TagGroupId) {
- var instance = this;
- if (TagGroupId != 0) {
- Unibase.Platform.Forms.Managers.TagManager.Instance().getTagParentsByCategoryId(Number(instance.g_TagCategoryId), TagGroupId).then(function (response) {
- var taghtml = '';
- var disabled = "";
- if (Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_OnlyFilters) {
- disabled = "disabled";
- $("#btn_ApplyOrderFilter, #btn_ClearOrderFilter").addClass("hidden");
- }
- for (var i = 0; i < response.result.length; i++) {
- var tagName = response.result[i].TagName;
- if (i % 2 == 0) {
- taghtml += '<div class="row"><div class="col-sm-12">';
- }
- taghtml += '<div class="col-sm-6 lobTagItems">';
- taghtml += '<div class="floating-label-form-group floating-label-form-group-with-value no-border" style="border-bottom:0;"><label>' + tagName + '</label>' +
- '<select multiple="multiple" style="width:100%" class="txtTagsSelect2_' + i + ' " id="txtBizgazeNotifications_Tags_' + i + '" data-id=' + i + ' ' + disabled + ' > </select>' +
- '<input type="hidden" class="hfTagCloud_ParentTagId-' + i + '" value="' + response.result[i].TagId + '" />' +
- '</div></div>';
- if (i % 2 == 1) {
- taghtml += '</div></div>';
- }
- }
- if (response.result.length == 0) {
- taghtml += '' + '<h5><span">No Tags Assigned For This Lob.</span></h5>';
- }
- $('.divTagList').html(taghtml);
- if (response.result.length != 0) {
- instance.refreshTags();
- }
- });
- }
- }
- refreshTags() {
- var instance = this;
- var y = 0;
- var lobid = $(".txtAutoComplete_lobid").val();
- var categoryId = instance.g_TagCategoryId;
- var PARENTID = "";
- let serviceurl = "apis/v4/unibase/platform/forms/autotagsforassignment";
- serviceurl = _appsettings.server_url() + (serviceurl.startsWith('/') ? serviceurl : ('/' + serviceurl));
- $(".lobTagItems").each(function () {
- var parentId = $(this).find(".hfTagCloud_ParentTagId-" + y).val();
- PARENTID += parentId + ",";
- if (parentId != undefined) {
- var Tags = [];
- var Ids = [];
- if (instance.g_TagArray != undefined && instance.g_TagArray != '') {
- for (var i = 0; i < instance.g_TagArray.length; i++) {
- var Tag = instance.g_TagArray[i];
- if (parentId == Tag.ParentId) {
- Tags.push({ id: Tag.TagId, text: Tag.TagName });
- Ids.push(Tag.TagId);
- }
- }
- }
- var Parameters = [
- { ColumnName: 'LobId', Value: lobid },
- { ColumnName: 'CategoryId', Value: categoryId },
- { ColumnName: 'ParentId', Value: PARENTID },
- ];
- var ColumnName = "", Value = "";
- if (Parameters != null) {
- ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString();
- Value = Parameters.map(function (item) { return item.Value + "|"; }).toString();
- }
- $(".txtTagsSelect2_" + y).select2({
- placeholder: "Select",
- data: Tags,
- ajax: {
- url: serviceurl,
- contentType: 'application/json',
- dataType: 'json',
- type: "POST",
- traditional: true,
- crossDomain: true,
- async: true,
- data: function (params) {
- var y = $(this).attr("id").replace("txtBizgazeNotifications_Tags_", "");
- parentId = $(".hfTagCloud_ParentTagId-" + y).val();
- var ParticipantsCount = new Array();
- var Participants = "";
- if ($(".txtTagsSelect2_" + Number($(this).attr('data-id'))).val().toString() != "") {
- var Participant = $(".txtTagsSelect2_" + Number($(this).attr('data-id'))).val().toString();
- ParticipantsCount = Participant.split(',');
- for (var i = 0; i < ParticipantsCount.length; i++) {
- Participants += "|" + ParticipantsCount[i];
- }
- Participants;
- }
- var Term = params.term != undefined ? params.term : "";
- var postData = {
- DocPropertyId: 0,
- ColumnName: ColumnName,
- FormPropertyId: Number($(this).attr('data-id')),
- Value: Value,
- bindedData: Participants.substring(1, Participants.length),
- term: Term,
- TagGroupId: Number(instance.g_order.g_TagGroupId),
- TagCatagoryId: Number(categoryId),
- TagId: Number(parentId),
- };
- return JSON.stringify(postData);
- },
- processResults: function (data) {
- var json_data = JSON.parse(data.result);
- var cols = [];
- for (let i = 0; i < json_data.length; i++) {
- var ids = {
- id: json_data[i].Value,
- text: json_data[i].DisplayText
- };
- cols.push(ids);
- }
- return { results: cols };
- },
- beforeSend: function (xhr) {
- if (Unibase.Platform.Membership.Infos.Identity.getCurrentUser() !== undefined && Unibase.Platform.Membership.Infos.Identity.getCurrentUser() !== null) {
- xhr.setRequestHeader('Authorization', 'Basic ' + Unibase.Platform.Membership.Infos.Identity.getCurrentUser().sessionId);
- xhr.setRequestHeader('geoposition', Unibase.Platform.Membership.Infos.Identity.getCurrentUser().latd + ':' + Unibase.Platform.Membership.Infos.Identity.getCurrentUser().lgId);
- }
- },
- },
- });
- jQuery(".txtTagsSelect2_" + y).val(Ids).trigger('change');
- }
- y++;
- });
- y = 0;
- }
- categoryTagItem() {
- var instance = this;
- Unibase.Platform.Forms.Managers.TagManager.Instance().getTagCategoryByName("Items").then(function (response) {
- var data = response.result;
- instance.g_TagCategoryId = data.TagCategoryId;
- var TagGroupId = instance.g_order.g_TagGroupId;
- if (TagGroupId != null && TagGroupId != 0) {
- instance.addTagItem(TagGroupId);
- }
- });
- }
- showFilteredItems() {
- var instance = this;
- var tags = '';
- var select2Id = 0;
- instance.g_TagArray = [];
- $(".lobTagItems").each(function () {
- var data = $(this).find('#txtBizgazeNotifications_Tags_' + select2Id + '').select2('data');
- var parentId = $(this).find(".hfTagCloud_ParentTagId-" + select2Id).val();
- if (data.length > 0) {
- var options = '';
- for (var i = 0; i < data.length; i++) {
- if (data[i] != '000' && data[i] != undefined) {
- instance.g_TagArray.push({ TagId: data[i].id, TagName: data[i].text, ParentId: parentId });
- options += data[i].id + "|";
- }
- }
- if (options != '') {
- options = options.replace(/\|$/, '');
- tags += options + "|";
- }
- }
- select2Id++;
- });
- if (tags != '') {
- tags = tags.replace(/\:$/, '');
- }
- instance.g_Tags = tags;
- instance.filterItemsByTags(tags, false);
- }
- clearAll() {
- var select2Id = 0;
- $(".lobTagItems").each(function () {
- $(this).find('#txtBizgazeNotifications_Tags_' + select2Id + '').val(null).trigger('change');
- select2Id++;
- });
- }
- filterItemsByTags(Tags, Ispagination) {
- var instance = this;
- instance.g_order.g_LoadOffersOnly = false;
- if (Tags == "" || Tags == null || Tags == undefined) {
- if (instance.g_order.g_IsPurchasePlanning)
- instance.g_orderItem.loadPurchasePlanItems('');
- else
- instance.g_orderItem.loadItems($("#txt_SearchItem").val());
- if (instance.g_ContainerId != "") {
- if ($('#' + instance.g_ContainerId).length > 0) {
- $('#' + instance.g_ContainerId).modal('hide');
- }
- }
- $("#ItemLoadType").val(1);
- if (!Ispagination) {
- $('#' + instance.g_ContainerId).modal('hide');
- $('#' + instance.g_ContainerId).remove();
- }
- }
- else {
- var SearchTerm = $("#txt_SearchItem").val();
- if (SearchTerm == "")
- SearchTerm = null;
- instance.g_orderItem.g_FilteredTags = Tags;
- var contactId = instance.g_order.g_OrganizationId;
- if (contactId == 0)
- contactId = instance.g_order.g_OrgContactId;
- instance.fileCacheHelper.loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () {
- instance.g_Tags = Tags;
- instance.g_orderItem.loadItems($("#txt_SearchItem").val());
- $("#ItemLoadType").val(3);
- if (!Ispagination) {
- $('#' + instance.g_ContainerId).modal('hide');
- $('#' + instance.g_ContainerId).remove();
- }
- });
- }
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new OrderFilter();
- }
- return this.instance;
- }
- }
- Components.OrderFilter = OrderFilter;
- })(Components = Transact.Components || (Transact.Components = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
-
- var Unibase;
- (function (Unibase) {
- let Platform;
- (function (Platform) {
- let Helpers;
- (function (Helpers) {
- class PrintHelper {
- printPopup(PrintHtml) {
- if (isMobileApp()) {
- Unibase.Platform.Helpers.MobileHelper.Instance().previewHtml(PrintHtml);
- }
- else {
- var mywindow = window.open('', 'my Print', 'height=400,width=850');
- var content = '<html><head><title>Print</title><link rel="stylesheet" href="lib/bizgaze/print.css" /><link rel="stylesheet" href="lib/bootstrap/bootstrap-theme.min.css" /></head><body>';
- content += PrintHtml;
- content += "<script>print();</script>";
- content += '</body></html>';
- mywindow.document.write(content);
- }
- return true;
- }
- static Instance() {
- if (this.instance === null || this.instance === undefined)
- this.instance = new PrintHelper();
- return this.instance;
- }
- }
- Helpers.PrintHelper = PrintHelper;
- })(Helpers = Platform.Helpers || (Platform.Helpers = {}));
- })(Platform = Unibase.Platform || (Unibase.Platform = {}));
- })(Unibase || (Unibase = {}));
-
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Components;
- (function (Components) {
- let Invoices;
- (function (Invoices) {
- class ItemOfferSelection extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.Bizgaze_Transact_Selected_Plan = new Array();
- this.g_Selected_Plan = new Array();
- this.OfferIds = [];
- }
- jsFiles() {
- return ['platform/core/helpers/numberhelper/numberhelper.js', 'apps/transact/managers/invoicemanager.js', 'apps/transact/controls/invoices/pos.component.js'];
- }
- cssFiles() {
- return [];
- }
- html() {
- let html = '<form id="frm_Bizgazetransact_ItemOfferSelection" method="post" data-validate="parsley"><div class="b-b bg-white modal-header"><strong class="text-dark titlename">Offer of <strong id="sg_item"></strong></strong></div><div data-simplebar class="bg-light simple-scroll-bar control-sorting modal-body"><div class=""><div class="col-sm-12"><div class="li_Invoice_OfferItem_header"></div><ul><li class="hidden list-group-item Plan_Vlm_row" id ="li_Invoice_OfferItem"> </li> <div class="Offer_Header"> </ul> </div></div></div><div class="bg-white modal-footer"><a href="javascript:;" class="btn btn-light btn-sm mr-auto btn_close" id="offer_btnclose">Close</a><span class="mr-auto" id="spn_Quantity"></span> <a href="javascript:;" class="btn btn-primary btn-sm btn_pos_apply disabled" style="cursor:not-allowed" id ="btn_Apply">Apply</a></div></form>';
- return html;
- }
- load(item) {
- var instance = this;
- instance.Bizgaze_Transact_Selected_Plan = new Array();
- $(".btn_close").click(function () {
- instance.navigationHelper.closePopUp();
- });
- }
- PlanSelection(Volume, value, DiscountType, PlanVolumeId, ItemId, len, focItemId) {
- var instance = this;
- $('.Plan_Vlm_row').css('background-color', '');
- $('#spn_Quantity').text(Volume);
- $("#frm_Bizgazetransact_ItemOfferSelection").find("#btn_Apply").removeAttr("style").removeClass("disabled");
- instance.Bizgaze_Transact_Selected_Plan = new Array();
- instance.Bizgaze_Transact_Selected_Plan.push({
- Volume: Volume, value: value, DiscountType: DiscountType, PlanVolumeId: PlanVolumeId, ItemId: ItemId, focItemId: focItemId
- });
- instance.g_Selected_Plan.push({
- Volume: Volume, value: value, DiscountType: DiscountType, PlanVolumeId: PlanVolumeId, ItemId: ItemId, focItemId: focItemId
- });
- }
- LoadOfferItems(OrganizationId, ItemId, ItemName, InvoiceApplyType, element, Type) {
- var instance = this;
- instance.Bizgaze_Transact_Selected_Plan = new Array();
- $('#sg_item').text(ItemName);
- ItemOfferSelection.Instance().GetPlanVolume(OrganizationId, ItemId, InvoiceApplyType, Type);
- $('#btn_Apply').click(function () {
- if (Type == 'Invoice') {
- ItemOfferSelection.Instance().Apply(element);
- }
- else if (Type == 'Order') {
- instance.navigationHelper.closePopUp();
- if (instance.Bizgaze_Transact_Selected_Plan.length > 0) {
- Bizgaze.Apps.Transact.Controls.OrderItems.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan);
- }
- }
- else if (Type == 'Estimate') {
- instance.navigationHelper.closePopUp();
- if (instance.Bizgaze_Transact_Selected_Plan.length > 0) {
- Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan);
- }
- }
- else if (Type == 'Opportunity') {
- instance.navigationHelper.closePopUp();
- if (instance.Bizgaze_Transact_Selected_Plan.length > 0) {
- Bizgaze.Apps.Transact.Controls.OpportunityItem.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan);
- }
- }
- else if (Type == 'POS_Order') {
- let elem = $(".variant-addeditem-" + ItemId);
- let html = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().getInventoryDesign(ItemId, false, 0, 0, "ApplyOffer");
- $(elem).find(".InventoryTypesTextboxes").html(html);
- Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().allItemEvents(elem);
- instance.navigationHelper.closePopUp();
- if (instance.Bizgaze_Transact_Selected_Plan.length > 0) {
- Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan);
- }
- }
- else if (Type == 'Pos') {
- instance.navigationHelper.closePopUp();
- if (instance.Bizgaze_Transact_Selected_Plan.length > 0) {
- Bizgaze.Apps.Transact.Controls.Pos.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan);
- }
- }
- });
- }
- GetPlanVolume(OrganizationId, ItemId, InvoiceApplyType, Type) {
- let instance = this;
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getPlanVolume(ItemId, OrganizationId, InvoiceApplyType).then(function (result) {
- instance.OfferIds = [];
- for (var i = 0; i < result.result.length; i++) {
- ItemOfferSelection.Instance().ShowItemOffers(result.result[i], ItemId, Type);
- }
- });
- }
- ShowItemOffers(data, ItemId, Type) {
- let instance = this;
- var value;
- if (data.DiscountType == 1) {
- value = data.PayoutValue;
- }
- else {
- if (data.DiscountType == 2) {
- value = data.PayoutPercent;
- }
- else {
- if (data.DiscountType == 3) {
- value = data.OPayoutValue;
- }
- }
- }
- var len = $('.Plan_Vlm_row').length;
- var html_header = '<div class="card col-sm-12 Offer_Header pt-20" id="Offer_Header_' + data.OfferId + '"> <div class="pl-0 pb-2"> <input type="hidden" class="hf_Pln_Vlm_OfferId" value="' + data.OfferId + '"/> <span class="list-item-main-title font-weight-600 font-20">' + data.OfferName + '</span> <span class="text-dark"> - ' + data.SchemeName + '</span></div>';
- var html = '<div class="card card-body pa-15 Card_Plan_Vlm_row Card_Plan_Vlm_row_' + data.PlanVolumeId + '" id="Card_Plan_Vlm_row_' + data.PlanVolumeId + '"> <div class="text-dark plan_Name font-weight-600 border-bottom border-2 pb-2">' + data.PlanName + ' </div> <div class="main-heading py-2">';
- var html_body = '<li class="Plan_Vlm_row Plan_Vlm_row_' + data.PlanVolumeId + '">' +
- '<a href="javascript:;" class="text-dark">' +
- '<div class="" id="div_PlanVlm_' + len + '">' +
- '<div class="d-flex justify-content-between align-items-center w-100" style="line-height: 0.8;"><div class="biz-highlight-text-color font-36 w-100 font-weight-600"><span id="spn_Discount"></span> <span id="spn_DiscountType" class="font-12"> </span> <span class="font-12 spn_off">OFF</span></div><div class="text-success font-14 font-widget-300 px-2 offers_applied" id="li_Pln_Vlm' + len + '"><u>Apply</u></div></div><div class="font-weight-600 w-100">On Purchase of Min-Qty : ' + data.Volume + '</div>' +
- '</div></a></li></div>';
- let offerIndex = instance.OfferIds.findIndex(x => x.OfferId == data.OfferId);
- if (offerIndex == -1) {
- instance.OfferIds.push({ OfferId: data.OfferId });
- html = html_header + html + html_body;
- html += '</div>';
- $('.Offer_Header:last').after(html);
- }
- else {
- html += html_body;
- $('#Offer_Header_' + data.OfferId).append(html);
- }
- var ss = data.PlanName;
- $("#li_Pln_Vlm" + len).click(function () {
- let Clicked_Id = $(this).attr("id");
- var focElement = document.getElementById("li_Pln_Vlm" + len);
- var focItemIdElement = focElement.querySelector(".selectedfocitem");
- var focItemId = "0";
- if (focItemIdElement != null) {
- focItemId = focItemIdElement.id;
- }
- let checkstatus = $(this).find("u").text();
- let AppliedPlanVolumeId = $(this).parents(".Card_Plan_Vlm_row").attr("id").replace("Card_Plan_Vlm_row_", "");
- if (checkstatus == "Apply") {
- $(".Card_Plan_Vlm_row").removeAttr("style");
- var offerItemIndex = instance.Bizgaze_Transact_Selected_Plan.findIndex(x => x.ItemId == ItemId);
- if (offerItemIndex != -1) {
- instance.Bizgaze_Transact_Selected_Plan.splice(offerItemIndex, 1);
- }
- var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId);
- if (offerItemIndex != -1) {
- instance.g_Selected_Plan.splice(sp_ItemIndex, 1);
- }
- $(".Plan_Vlm_row").find(".offers_applied").find("u").text("Apply").addClass("text-primary").removeClass("text-danger");
- instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, true);
- ItemOfferSelection.Instance().PlanSelection(data.Volume, value, data.DiscountType, data.PlanVolumeId, ItemId, len, Number(focItemId));
- }
- else {
- var msg = 'Do you what to remove Applied Offer';
- bootbox.confirm({
- message: msg,
- closeButton: false,
- buttons: {
- confirm: {
- label: 'Remove',
- className: 'btn-success'
- },
- cancel: {
- label: 'Cancel',
- className: 'btn-danger'
- }
- },
- callback: function (result) {
- if (result) {
- instance.UnHighlightPlan(AppliedPlanVolumeId, ItemId, Type);
- $("#spn_Quantity").text("");
- }
- else {
- $('#modal_popup_EditLineItem').modal('hide');
- bootbox.hideAll();
- return false;
- }
- }
- });
- }
- });
- if (value > 0) {
- $("#div_PlanVlm_" + len).find('#spn_Discount').text(value);
- if (data.DiscountType == 2) {
- $("#div_PlanVlm_" + len).find('#spn_DiscountType').text(" %");
- }
- else {
- if (data.DiscountType == 1)
- $("#div_PlanVlm_" + len).find('#spn_DiscountType').text(" Val");
- if (data.DiscountType == 3) {
- $("#div_PlanVlm_" + len).find('#spn_DiscountType').text(" Fixed Val");
- }
- }
- }
- else {
- $("#div_PlanVlm_" + len).find('.spn_off').addClass("hidden");
- }
- if (data.ItemVolumePayouts.length > 0) {
- html = '<div class="" id="div_Foc_' + len + '"></div>';
- $('#div_PlanVlm_' + len).after(html);
- for (var i = 0; i < data.ItemVolumePayouts.length; i++) {
- ItemOfferSelection.Instance().AddFoCItem(data.ItemVolumePayouts[i], len, Type, ItemId);
- }
- }
- if (Type == "POS_Order") {
- let CartItem_Index = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_CartItems_New.findIndex(x => x.ItemId == ItemId);
- if (CartItem_Index != -1) {
- let AppliedPlanVolumeId = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_CartItems_New[CartItem_Index].AppliedPlanVolumeId;
- if (AppliedPlanVolumeId != 0) {
- instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, false);
- }
- }
- }
- else if (Type == "Order") {
- let IsCart = false;
- if ($("#ulOrder_Cart").is(":visible")) {
- IsCart = true;
- }
- if (!IsCart && !Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_FromContinueShopping) {
- Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.filter(x => x.ItemId != ItemId);
- var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId);
- if (sp_ItemIndex != -1) {
- let selectedPlan = instance.g_Selected_Plan[sp_ItemIndex];
- Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.push({
- ItemId: selectedPlan.ItemId,
- OfferId: 0,
- PlanId: 0,
- PlanVolumeId: selectedPlan.PlanVolumeId,
- IsSelected: true
- });
- }
- }
- let AppliedOffers = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.filter(x => x.ItemId == ItemId);
- for (var ao = 0; ao < AppliedOffers.length; ao++) {
- let AppliedPlanVolumeId = AppliedOffers[ao].PlanVolumeId;
- let IsSelected = AppliedOffers[ao].IsSelected;
- instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, IsSelected);
- }
- }
- else if (Type == "Estimate") {
- let IsCart = false;
- if ($("#ulOrder_Cart").is(":visible")) {
- IsCart = true;
- }
- if (!IsCart && !Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_FromContinueShopping) {
- Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.filter(x => x.ItemId != ItemId);
- var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId);
- if (sp_ItemIndex != -1) {
- let selectedPlan = instance.g_Selected_Plan[sp_ItemIndex];
- Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.push({
- ItemId: selectedPlan.ItemId,
- OfferId: 0,
- PlanId: 0,
- PlanVolumeId: selectedPlan.PlanVolumeId,
- IsSelected: true
- });
- }
- }
- let AppliedOffers = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.filter(x => x.ItemId == ItemId);
- for (var ao = 0; ao < AppliedOffers.length; ao++) {
- let AppliedPlanVolumeId = AppliedOffers[ao].PlanVolumeId;
- let IsSelected = AppliedOffers[ao].IsSelected;
- instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, IsSelected);
- }
- }
- }
- HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, IsSelected) {
- let instance = this;
- if (IsSelected) {
- $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).css("background-color", "lavender");
- var checkoffer = $(".Plan_Vlm_row_" + AppliedPlanVolumeId).find(".offers_applied").attr("id");
- $("#" + checkoffer).find("u").text("Remove").removeClass('text-sucess').addClass('text-danger');
- var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId);
- if (sp_ItemIndex != -1) {
- let selectedPlan = instance.g_Selected_Plan[sp_ItemIndex];
- instance.Bizgaze_Transact_Selected_Plan.push({
- Volume: selectedPlan.Volume, value: selectedPlan.value, DiscountType: selectedPlan.DiscountType, PlanVolumeId: AppliedPlanVolumeId, ItemId: ItemId, focItemId: selectedPlan.focItemId
- });
- }
- }
- else {
- $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).css("background-color", "lightgoldenrodyellow");
- $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).find("u").text("Apply").addClass('text-sucess').removeClass('text-danger');
- }
- $("#frm_Bizgazetransact_ItemOfferSelection").find("#btn_Apply").removeAttr("style").removeClass("disabled");
- }
- UnHighlightPlan(AppliedPlanVolumeId, ItemId, Type) {
- let instance = this;
- $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).find("u").text("Apply").addClass('text-sucess').removeClass('text-danger');
- $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).removeAttr("style");
- var offerItemIndex = instance.Bizgaze_Transact_Selected_Plan.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId);
- if (offerItemIndex != -1) {
- instance.Bizgaze_Transact_Selected_Plan.splice(offerItemIndex, 1);
- }
- var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId);
- if (offerItemIndex != -1) {
- instance.g_Selected_Plan.splice(sp_ItemIndex, 1);
- }
- if (Type == "Order") {
- var appliedoffers_ItemIndex = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId);
- if (appliedoffers_ItemIndex != -1) {
- Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.splice(appliedoffers_ItemIndex, 1);
- }
- }
- if (Type == "Estimate") {
- var appliedoffers_ItemIndex = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId);
- if (appliedoffers_ItemIndex != -1) {
- Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.splice(appliedoffers_ItemIndex, 1);
- }
- }
- }
- AddFoCItem(FocItem, len, Type, RefItemId) {
- var html = '<div class="mt-2 shadow px-2"><input type="hidden" id=' + FocItem.ItemId + ' class="selectedfocitem"><div class="d-flex align-items-center"><div class="check-btn mt-2"><input type="checkbox" id="IsApplyOffer_' + FocItem.ItemVolumePayoutId + '" class="mr-2 h-20p w-20p li_Pln_items_with_Checked"> <span class="checkmark"></span></div><div class="p-0"><span class="biz-highlight-text-color font-weight-600 mr-1">' + FocItem.Discount + '% </span> off on purchase of every <span class="list-item-main-title px-1">' + FocItem.Recur + ' </span> Quantity <br><span class="list-item-main-title px-1">' + FocItem.Quantity + ' </span> x <span class="list-item-main-title px-1 word-break">' + FocItem.ItemName + '</span><div></div>' +
- '</div>';
- $('#div_Foc_' + len).before(html);
- var seen = '';
- $('.plan_Name').each(function () {
- var see = $(this).text();
- if (seen.match(see)) {
- $(this).remove();
- }
- else {
- seen = seen + $(this).text();
- }
- });
- if (Type == "Order") {
- var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds == RefItemId);
- if (!FocItem.IsFoC) {
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true");
- }
- else if (FocItem.IsFoC && ValidFocItemIndex != -1) {
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
- }
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () {
- var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked");
- var FocItemIndex = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.toString().indexOf(RefItemId) != -1);
- if (Checked) {
- if (FocItemIndex == -1) {
- Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.push({ ItemId: FocItem.ItemId, RefItemIds: RefItemId });
- }
- }
- else {
- if (FocItemIndex != -1) {
- Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.splice(FocItemIndex, 1);
- }
- }
- });
- }
- if (Type == "Estimate") {
- var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds == RefItemId);
- if (!FocItem.IsFoC) {
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true");
- }
- else if (FocItem.IsFoC && ValidFocItemIndex != -1) {
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
- }
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () {
- var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked");
- var FocItemIndex = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.toString().indexOf(RefItemId) != -1);
- if (Checked) {
- if (FocItemIndex == -1) {
- Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.push({ ItemId: FocItem.ItemId, RefItemIds: RefItemId });
- }
- }
- else {
- if (FocItemIndex != -1) {
- Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.splice(FocItemIndex, 1);
- }
- }
- });
- }
- if (Type == "POS_Order") {
- var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.indexOf(RefItemId) != -1);
- if (!FocItem.IsFoC) {
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true");
- }
- else if (FocItem.IsFoC && ValidFocItemIndex != -1) {
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
- }
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () {
- var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked");
- var FocItemIndex = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.indexOf(RefItemId) != -1);
- if (Checked) {
- if (FocItemIndex == -1) {
- Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.push({ ItemId: FocItem.ItemId, RefItemIds: RefItemId });
- }
- }
- else {
- if (FocItemIndex != -1) {
- Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.splice(FocItemIndex, 1);
- }
- }
- });
- }
- if (Type == "Pos") {
- var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.Pos.Instance().offerItemsArray.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemId == RefItemId);
- if (!FocItem.IsFoC) {
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true").addClass("opacity-30");
- }
- else if (FocItem.IsFoC && ValidFocItemIndex != -1) {
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
- }
- $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () {
- var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked");
- var FocItemIndex = Bizgaze.Apps.Transact.Controls.Pos.Instance().offerItemsArray.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemId == RefItemId);
- if (Checked) {
- if (FocItemIndex == -1) {
- Bizgaze.Apps.Transact.Controls.Pos.Instance().offerItemsArray.push({ ItemId: FocItem.ItemId, RefItemId: RefItemId });
- }
- }
- });
- }
- }
- Apply(element) {
- let instance = this;
- instance.navigationHelper.closePopUp();
- ItemOfferSelection.Instance().ApplyOffer(instance.Bizgaze_Transact_Selected_Plan, element);
- }
- AddSpliItem(element) {
- var array = {
- orderItemId: 0,
- invoiceItemId: 0,
- itemId: element.find('.selectedItemId').val(),
- packSize: 0,
- packCount: 0,
- packs: 0,
- quantity: 0,
- availPacks: 0,
- availQty: 0,
- Description: "",
- isTaxInclusive: $("#hfIsTaxInclusive").val(),
- addlDiscountPercent: 0,
- addlDiscountValue: 0,
- creditNote: 0,
- priceListId: element.find('.hf_PriceList').val(),
- invoiceallocations: null,
- exciseInvoiceItem: null,
- walletId: 0,
- Adjustment: 0,
- IsFoc: 0,
- TariffNo: "",
- exciseAmount: 0,
- discountName: "",
- discountId: 0,
- description: "",
- RefNo: "",
- DiscountGroupId: 0,
- DiscountGroupName: '',
- RefInvoiceItemId: 0,
- taxAdjustment: element.find('.hfItemTaxAdjsutmentVal').val(),
- assesableAdjustment: element.find('.hfItemAssesableAdjustmentVal').val(),
- inventoryTypeId: 0,
- dcItemId: element.find('.dcItemId').val(),
- ExchangeItem: element.find('.IsExchangeItem').val(),
- unitPrice: element.find('.prodPrice').val(),
- taxGroupId: element.find(".hfProdTax").val(),
- BatchId: 0,
- MrpId: 0,
- SerialId: 0,
- Name: '',
- maxQty: 0,
- accountId: element.find(".hf_Account").val(),
- accountName: element.find(".txt_AccountName").val(),
- taxGroupName: element.find(".txtProdTax").val(),
- };
- return array;
- }
- AddItemRowToSplitArray(Item, element, Quantity) {
- var DcType = 2;
- var BranchId = $(".txtAutoComplete_shiptoaddressid").val();
- if ($('.hdn_invoicetypeid').val() == '1' || $('.hdn_invoicetypeid').val() == '4' || $('.hdn_invoicetypeid').val() == '5') {
- BranchId = $(".txtAutoComplete_shipfromaddressid").val();
- }
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "5") {
- DcType = 1;
- }
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemSetting(Item, BranchId, DcType).then(function (result) {
- var EnableMrp = result.result.EnableMRP;
- var EnableBatch = result.result.EnableBatchNo;
- var Info = [];
- if (EnableMrp == true) {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getMrps(element.find(".selectedItemId").val(), DcType, BranchId).then(function (res) {
- Info = res.result;
- });
- }
- if (EnableBatch == true) {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getBatches(element.find(".selectedItemId").val(), DcType, BranchId).then(function (res) {
- Info = res.result;
- });
- }
- if (Info.length > 0) {
- var TotalQuantity = 0;
- var TotalDisc = 0;
- var TotalAmount = 0;
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "5") {
- var itemQty = Quantity;
- for (var x = 0; x < Info.length; x++) {
- if (itemQty > 0) {
- var itemrow = ItemOfferSelection.Instance().AddSpliItem(element);
- let Qty = 0;
- if (EnableMrp == true) {
- itemrow.MrpId = Info[x].MrpId;
- itemrow.Name = Info[x].Mrp + ' ( ' + Info[x].MrpQuantity + ' ) ';
- Qty = Info[x].MrpQuantity;
- }
- else if (EnableBatch == true) {
- itemrow.BatchId = Info[x].BatchId;
- itemrow.Name = Info[0].BatchNo;
- Qty = Info[0].BatchQuantity;
- }
- if (Qty > itemQty) {
- itemrow.quantity = itemQty;
- itemQty = itemQty - Info[x].Quantity;
- }
- else {
- itemrow.quantity = Qty;
- itemQty = itemQty - Qty;
- }
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.push(itemrow);
- TotalQuantity += Number(itemrow.quantity);
- var discount = 0;
- var qyt = Number(itemrow.quantity);
- var price = Number(itemrow.unitPrice);
- var excamt = Number(itemrow.exciseAmount);
- var assesableAdjustment = Number(itemrow.assesableAdjustment);
- var ItemAdjustment = Number(itemrow.Adjustment);
- var discountAmount = Number(itemrow.addlDiscountValue);
- var discountPercent = Number(itemrow.addlDiscountPercent);
- discount = (((qyt * price) + assesableAdjustment + ItemAdjustment - excamt) * Number(discountPercent) / 100) + (Number(qyt) * Number(discountAmount));
- discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3));
- TotalDisc += discount;
- var rowtotal = Number((qyt * price) + excamt + ItemAdjustment + assesableAdjustment);
- var RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3);
- TotalAmount += RowTotal;
- }
- }
- }
- else {
- var itemrow = ItemOfferSelection.Instance().AddSpliItem(element);
- if (EnableMrp == true) {
- itemrow.MrpId = Info[0].MrpId;
- itemrow.Name = Info[0].Mrp + ' ( ' + Info[0].Quantity + ' ) ';
- }
- else if (EnableBatch == true) {
- itemrow.BatchId = Info[0].BatchId;
- itemrow.Name = Info[0].BatchNo;
- }
- itemrow.quantity = Quantity;
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.push(itemrow);
- TotalQuantity += Number(itemrow.quantity);
- var discount = 0;
- var qyt = Number(itemrow.quantity);
- var price = Number(itemrow.unitPrice);
- var excamt = Number(itemrow.exciseAmount);
- var assesableAdjustment = Number(itemrow.assesableAdjustment);
- var ItemAdjustment = Number(itemrow.Adjustment);
- var discountAmount = Number(itemrow.addlDiscountValue);
- var discountPercent = Number(itemrow.addlDiscountPercent);
- discount = (((qyt * price) + assesableAdjustment + ItemAdjustment - excamt) * Number(discountPercent) / 100) + (Number(qyt) * Number(discountAmount));
- discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3));
- TotalDisc += discount;
- var rowtotal = Number((qyt * price) + excamt + ItemAdjustment + assesableAdjustment);
- var RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3);
- TotalAmount += RowTotal;
- }
- if (EnableMrp == true)
- element.find('.spn_InvoiceItem').text("View MRP");
- else
- element.find('.spn_InvoiceItem').text("View Batch");
- element.find('.prodQuantity').val();
- element.find('.prodQuantity').val(TotalQuantity);
- element.find('#inv_txtdiscount').val();
- element.find('#inv_txtdiscount').val(TotalDisc);
- if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "6") {
- element.find(".txtRowTotalwithAdjustment").val();
- element.find(".txtRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(TotalAmount, 3));
- }
- else {
- element.find('.prodTotalPrice').text('');
- element.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(TotalAmount, 3));
- }
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().GetPlanItems(element.find(".selectedItemId").val(), element.find('.prodQuantity').val(), element);
- }
- });
- }
- ApplyOffer(Item, element) {
- if (element.hasClass('SplitItem')) {
- var Qty = Number(element.find(".prodQuantity").val());
- if (Qty == 0) {
- ItemOfferSelection.Instance().AddItemRowToSplitArray(Item, element, Item[0].Volume);
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_total();
- }
- else if (Qty < Item[0].Volume) {
- var ItemQty = Item[0].Volume - Qty;
- ItemOfferSelection.Instance().AddItemRowToSplitArray(Item, element, ItemQty);
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_total();
- }
- else {
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().GetPlanItems(element.find(".selectedItemId").val(), Qty, element);
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_total();
- }
- }
- else {
- element.find(".prodQuantity").val(Item[0].Volume);
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().GetPlanItems(element.find(".selectedItemId").val(), element.find(".prodQuantity").val(), element);
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_total();
- }
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection();
- }
- return this.instance;
- }
- }
- Invoices.ItemOfferSelection = ItemOfferSelection;
- })(Invoices = Components.Invoices || (Components.Invoices = {}));
- })(Components = Transact.Components || (Transact.Components = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
-
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Controls;
- (function (Controls) {
- class InvoiceItem extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.rowIndex = 0;
- this.itemIds = new Array();
- this.dcItemIds = new Array();
- this.SplitedInvoiceItemList = new Array();
- this.deleted_invoiceItems = new Array();
- this.invItemTaxAdjustmentList = new Array();
- this.container = "";
- this.AutoDc = false;
- this.OrderSettingId = 0;
- this.orderid = 0;
- this.dcid = 0;
- this.ClaimId = 0;
- this.TurnOver = 0;
- this.TaxRate = 0;
- this.ContactTcsEnable = false;
- this.EnableTenantTcs = false;
- this.PanAvailable = false;
- this.IswalkinCustomer = false;
- this.ManageInvoice = 2;
- this.ManageInvoiceTax = 2;
- this.UOMs = [];
- this.ChangedUOM = false;
- this.isOfferChargeApplied = false;
- }
- init(formpropertyid, prop, callback) {
- var instance = InvoiceItem.Instance();
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/core/helpers/numberhelper/numberhelper.js", function () {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/invoicemanager.js", function () {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/paymentterms/paymenttermmanager.js", function () {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/offers/offermanager.js", function () {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/compact/components/details/details.js", function () {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/forms/components/formviewer/formviewer.js", function () {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("libs/parsley/parsley.min.js", function () {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
- instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
- instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
- });
- });
- });
- });
- });
- });
- });
- });
- }
- loadControl(containerid, prop) {
- let instance = this;
- var html = '<div class="section_ItemDetails card"><div class="card-header d-flex flex-row align-item-center"><span class="my-auto">Item Details</span><div class="ml-auto w-60 d-flex flex-row-reverse align-items-center"><a href="javascript:void(0);" class="advanced-opitions mx-3"><i class="fa fa-sliders"></i></a><div class="hidden-element d-flex justify-content-end w-30 advchange_taxgroup"><input type="hidden" id="hdn_changetaxgroup" class="" value=""><select class="form-control change_taxgroup" value="" id="change_taxgroup" placeholder="Tax Group" data-label="Select Tax Group"style="width:100%;"></select></div></div><span class="ml-2"><a href="javascript:;" class="btn mr-20 btn-sm btn-primary btn-rounded text-white" id = "Item_Count">0</a></span></div><div class="card-body"><div class="row"><div id="control-container" class="control-group divCustomProperties divCustomProperties_InvoiceItemEntity controldata_0 col-sm-12 " data-size="12" data-propertyname="null" data-propertyid="0" data-doctypeid="0" data-level="0" data-doctypetable="null" data-doctypename="InvoiceItemEntity" data-isdefault="false" data-rowindex="13" data-formpropertyid="" data-controlname="InvoiceItems" data-validatename="InvoiceItems"><div class="panel panel-default" style="padding-bottom:10px" id="invoiceitem"><input type="hidden" id="hdn_customcontrol" class="value-control" value="Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().getobj();"><input type="hidden" id="hdninvoiceitem" class="" value="" data-isdynamic="true" data-propdoctypename=""><div class=""> <div id="tbl_InvoiceItems" class="col-sm-12 d-none d-lg-block pb-10"><div class="row lineheight wrapper-sm" style="border-bottom: 2px solid grey;"><div class="col-sm-4 min-padding"><strong class="ml-10">Item Name</strong></div><div class="col-sm-2 text-center"><strong class="">Qty</strong></div><div class="col-sm-2 text-center min-padding"><strong>Unit Price</strong></div><div class="col-sm-2 text-center min-padding"><strong>Disc.</strong></div><div class="col-sm-2 text-right min-padding"><strong>Total</strong></div></div></div></div><div class="panel-body InvoiceItems"><div class="item-row added-row InvoiceitemRow-0 "></div><div class="discount-row hidden"></div></div></div><div class="col-sm-12 row pr-0"><div class="col-sm-6"><a class="btn btn-outline-primary mt-2" title="Add Item" id="btnInvoiceItem"><span class="px-1"><i class="la la-plus"></i></span><span>Add Item</span></a><span> </span><a class="btn btn-outline-primary mt-2" title="Add Discount Item" id="btndiscountItem"> <span class="px-1"><i class="la la-plus"></i></span><span>Add Discount Item</span></a></div><div class="col-sm-6 pr-0"><div class="pull-right" style="padding-left:0px;padding-right:0px;"></div></div></div></div></div></div></div>';
- $("#" + containerid).html(html);
- $('.advanced-opitions').on('click', function () {
- $('#change_taxgroup').val(null).trigger('change');
- $('.advchange_taxgroup').toggleClass('hidden-element');
- $('.advchange_taxgroup').find('.select2-selection__placeholder span').text('Select Tax Group');
- });
- InvoiceItem.instance.container = containerid;
- InvoiceItem.Instance().loadChangeTaxGroupAutoComplete();
- }
- invoiceinit() {
- if (InvoiceItem.Instance().orderid != 0) {
- var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorderbranchsettings(InvoiceItem.Instance().orderid).then(function (response) {
- if (response.result != null) {
- if (response.result.SettingValue == "Invoice First") {
- InvoiceItem.Instance().OrderSettingId = 2;
- }
- else if (response.result.SettingValue == "DC First" || response.result.SettingValue == "GRN First") {
- InvoiceItem.Instance().OrderSettingId = 1;
- }
- }
- });
- }
- $(".dropdown_istaxinclusive option[value='false']").attr('selected', 'true');
- $(".dropdown_paymentmethodid option[value='0']").attr('selected', 'true');
- $(".nettotal").remove();
- var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
- $("#" + VisibleContainerId).find(".btn_Save_Form").addClass("hidden");
- var nettotal = '<strong class="nettotal mt-5 mr-5">0.00</strong>';
- if ($('.Title').siblings('.btn-group').length > 0)
- $('.Title').siblings('.btn-group').prepend(nettotal);
- else
- $('.Title').after('<strong class="nettotal mt-5 mr-5 ml-auto">0.00</strong>');
- $('.txtAutoComplete_paymenttermid').change(function () {
- InvoiceItem.Instance().LoadDueDays();
- });
- $('.date_journaldate').blur(function () {
- InvoiceItem.Instance().LoadDueDays();
- if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") && $("#chk_tcsapplied").val() != undefined)
- InvoiceItem.Instance().GetCustomerTurnOver();
- });
- $('.date_journaldate').change(function () {
- var invdate = $('.date_journaldate').val().toString().split('/');
- let todaydate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(), "").split('/');
- var Invoicedate = new Date(Number(invdate[2]), Number(invdate[1]) - 1, Number(invdate[0]));
- var CurrentDate = new Date(Number(todaydate[2]), Number(todaydate[1]) - 1, Number(todaydate[0]));
- if (Invoicedate > CurrentDate) {
- bootbox.confirm("Are You Sure,You want to Continue with Future Invoice", function (result) {
- if (result) {
- InvoiceItem.Instance().GetAvailableWallets(Number($(".hdn_invoiceid").val()));
- }
- else {
- var f = new Date();
- $('.date_journaldate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, ""));
- let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, "");
- var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
- $('.hfdate_journaldate').val(tdate);
- InvoiceItem.Instance().GetAvailableWallets(Number($(".hdn_invoiceid").val()));
- }
- });
- }
- else {
- InvoiceItem.Instance().GetAvailableWallets(Number($(".hdn_invoiceid").val()));
- }
- InvoiceItem.Instance().GetDiscounts();
- });
- $('.date_refdate').blur(function () {
- let refdate = $(".date_refdate").val();
- if (refdate == "" || refdate == null) {
- var f = new Date();
- $('.date_refdate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, ""));
- let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, "");
- var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
- $('.hfdate_refdate').val(tdate);
- $(".divCustomProperties_refdate").children().addClass("floating-label-form-group-with-value");
- }
- });
- $(".section_Ebs").addClass("hidden");
- $(".section_Details").addClass('hidden');
- $(".section_ItemDetails").addClass('hidden');
- $(".section_Ebs").addClass('hidden');
- $(".section_InvoiceAmount").addClass('hidden');
- $(".section_Description").addClass('hidden');
- $(".section_BillingAndShippingDetails").addClass('hidden');
- $(".section_AdvancedOptions").addClass("hidden");
- $(".section_Description").addClass("hidden");
- $(".section_Wallets").addClass("hidden");
- $(".section_TCS").addClass("hidden");
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- $(".number_tcsamount").prop("disabled", true);
- $(".number_tdsamount").prop("disabled", true);
- $(".number_tdstaxrate").prop("disabled", true);
- $('#chk_excludefromcampaign').prop('checked', false);
- $(".txt_gstno").prop("disabled", true);
- $(".section_InvoiceAmount .card-header").first().text('Amount');
- $(".hrefSection_MoreOptions").click(function () {
- if ($(".hrefSection_MoreOptions").text() == 'Less Options') {
- $(".hrefSection_MoreOptions").text('More Options');
- $(".section_AdvancedOptions").addClass("hidden");
- }
- else if ($(".hrefSection_MoreOptions").text() == 'More Options') {
- $(".hrefSection_MoreOptions").text('Less Options');
- $(".section_AdvancedOptions").removeClass("hidden");
- }
- });
- if (Unibase.Platform.Membership.Infos.Identity.getCurrentUser().settings == null) {
- $(".txtAutoComplete_orgcontactid").prop("disabled", true);
- MessageHelper.Instance().showError("Please Configure Default Branch", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- else if (Unibase.Platform.Membership.Infos.Identity.getSetting("companyid") == null || Unibase.Platform.Membership.Infos.Identity.getSetting("companyid") == undefined) {
- $(".txtAutoComplete_orgcontactid").prop("disabled", true);
- MessageHelper.Instance().showError("Please Configure Default Branch", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- else {
- var companyId = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("companyid"));
- if ($(".hdn_invoicetypeid").val() != "6" && $(".hdn_invoicetypeid").val() != "7") {
- var Parameters = [{ "ColumnName": "companyid", "Value": companyId }];
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_orgcontactid"), Parameters);
- }
- }
- if ($(".hdn_invoiceid").val() == 0 && InvoiceItem.Instance().orderid == 0 && InvoiceItem.Instance().dcid == 0) {
- $(".txtAutoComplete_orgcontactid").change(function () {
- var orgid = Number($(".hfAutoCompleteId_orgcontactid").val());
- if (orgid > 0) {
- if ($(".section_Details").hasClass('hidden')) {
- $(".section_Details").removeClass('hidden');
- }
- if ($(".section_ItemDetails").hasClass('hidden')) {
- $(".section_ItemDetails").removeClass('hidden');
- }
- if ($(".section_InvoiceAmount").hasClass('hidden')) {
- $(".section_InvoiceAmount").removeClass('hidden');
- }
- if ($(".section_Description").hasClass('hidden')) {
- $(".section_Description").removeClass('hidden');
- }
- if ($(".section_BillingAndShippingDetails").hasClass('hidden')) {
- $(".section_BillingAndShippingDetails").removeClass('hidden');
- }
- if ($(".section_Wallets").hasClass('hidden')) {
- $(".section_Wallets").removeClass("hidden");
- }
- if ($(".section_TCS").hasClass('hidden')) {
- $(".section_TCS").removeClass("hidden");
- }
- var organiztionid = $(".hfAutoCompleteId_orgcontactid").val();
- if (organiztionid != 0 && organiztionid != undefined && organiztionid != -1) {
- InvoiceItem.Instance().LoadContactDetails();
- }
- $("#btn_Save").removeClass('hidden');
- var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
- $("#" + VisibleContainerId).find(".btn_Save_Form").removeClass("hidden");
- }
- });
- }
- $('.dropdown_istaxinclusive').change(function () {
- var invItems = InvoiceItem.Instance().getInvoiceItems();
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- if (Unibase.Platform.Membership.Infos.Identity.getCurrentUser().isAdmin == true) {
- InvoiceItem.Instance().ManageInvoice = 2;
- InvoiceItem.Instance().ManageInvoiceTax = 2;
- }
- else {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().GetInvoicePermissions(Number($(".hdn_invoicetypeid").val())).then(function (response) {
- if (response.result.length > 0) {
- for (var i = 0; i < response.result.length; i++) {
- if (response.result[i].SettingName == Unibase.Platform.Apps.Enums.SettingType.Manage.toString()) {
- InvoiceItem.Instance().ManageInvoice = response.result[i].SettingValue;
- InvoiceItem.Instance().ManageInvoiceTax = response.result[i].SettingValue;
- }
- }
- }
- });
- }
- if ($(".WalletItems").hasClass('show')) {
- $(".WalletItems").removeClass('show');
- }
- let invoiceid = $(".hdn_invoiceid").val();
- if (invoiceid == "0") {
- if (InvoiceItem.Instance().orderid != 0 || InvoiceItem.Instance().dcid != 0)
- InvoiceItem.Instance().getDcDetails();
- $('#txt_Adjustment').keypress(function (event) {
- if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8) || (event.which == 45)) {
- }
- else {
- event.preventDefault();
- }
- }).on('paste', function (event) {
- event.preventDefault();
- });
- }
- else {
- InvoiceItem.Instance().bindEditInvoiceDetails(invoiceid);
- }
- $('#change_taxgroup').change(function () {
- if ($('#change_taxgroup option:selected').val() != undefined && $('#change_taxgroup option:selected').val() != 0) {
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- InvoiceItem.Instance().SplitedInvoiceItemList[i].taxGroupId = Number($('#change_taxgroup option:selected').val());
- Controls.Invoices.SplitItem.Instance().update_TaxPercentage($('#change_taxgroup option:selected').val());
- }
- $(".InvoiceItems").find(".item-row").each(function () {
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- var TaxGroupId = Number($('#change_taxgroup option:selected').val());
- var txtTaxGroup = $(this).find(".prodTax");
- var hfProdTax = $(this).find(".hfProdTax");
- hfProdTax.val(TaxGroupId);
- txtTaxGroup.empty();
- txtTaxGroup.append(new Option($('#change_taxgroup option:selected').text(), TaxGroupId.toString(), true));
- if (hfProdTax.val() != '')
- InvoiceItem.Instance().update_tax($(this), hfProdTax.val());
- }
- });
- }
- });
- }
- addNetDiscountRow() {
- InvoiceItem.Instance().adddiscountrow(null, "", "", true);
- }
- getDcDetails() {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/invoicemanager.js", function () {
- var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
- $("#" + VisibleContainerId).find(".btn_Save_Form").removeClass("hidden");
- $("#btn_Save").removeClass('hidden');
- InvoiceItem.Instance().AutoDc = false;
- let url = "";
- if (InvoiceItem.Instance().dcid != 0) {
- url = 'apis/v4/bizgaze/transact/dcs/getdc/dcid/' + InvoiceItem.Instance().dcid;
- }
- else {
- url = "apis/v4/bizgaze/transact/orders/getorderbyorderid/id/" + InvoiceItem.Instance().orderid;
- }
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getOrderDcDetails(url).then(function (response) {
- if (response.result != null) {
- if ($(".hdn_invoicetypeid").val() == "1")
- $("#div_FormName").text("Create Sales Invoice");
- else if ($(".hdn_invoicetypeid").val() == "2")
- $("#div_FormName").text("Create Purchase Invoice");
- if ($(".section_Details").hasClass('hidden')) {
- $(".section_Details").removeClass('hidden');
- }
- if ($(".section_ItemDetails").hasClass('hidden')) {
- $(".section_ItemDetails").removeClass('hidden');
- }
- if ($(".section_Ebs").hasClass('hidden')) {
- $(".section_Ebs").removeClass('hidden');
- }
- if ($(".section_InvoiceAmount").hasClass('hidden')) {
- $(".section_InvoiceAmount").removeClass('hidden');
- }
- if ($(".section_Description").hasClass('hidden')) {
- $(".section_Description").removeClass('hidden');
- }
- if ($(".section_BillingAndShippingDetails ").hasClass('hidden')) {
- $(".section_BillingAndShippingDetails ").removeClass('hidden');
- }
- if ($(".section_Wallets").hasClass('hidden')) {
- $(".section_Wallets").removeClass("hidden");
- }
- if ($(".section_TCS").hasClass('hidden')) {
- $(".section_TCS").removeClass("hidden");
- }
- let data = response.result;
- $(".txtAutoComplete_orgcontactid").empty();
- if (data.OrgContactId == 0) {
- InvoiceItem.Instance().IswalkinCustomer = true;
- $(".hfAutoCompleteId_orgcontactid").val(data.OrganizationId);
- var selectedCompany = new Option(data.OrganizationName, data.OrganizationId, true);
- $(".txtAutoComplete_orgcontactid").append(selectedCompany);
- }
- else {
- InvoiceItem.Instance().IswalkinCustomer = false;
- $(".hfAutoCompleteId_orgcontactid").val(data.OrgContactId);
- var selectedCompany = new Option(data.OrganizationName + " - " + data.OrgContactName, data.OrgContactId, true);
- $(".txtAutoComplete_orgcontactid").append(selectedCompany);
- }
- if (data.OrganizationId != 0) {
- $(".hdn_organizationid").val(data.OrganizationId);
- $("#hfInv_OrganizationName").val(data.OrganizationName);
- }
- else {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorgcontact(data.OrgContactId).then(function (response) {
- var data = response.result;
- if (response.result != null && data.OrganizationId != 0) {
- $(".hdn_organizationid").val(response.result.OrganizationId);
- $("#hfInv_OrganizationName").val(data.OrganizationName);
- }
- });
- }
- $(".txt_gstno").val(response.result.GSTInNo);
- $(".txtAutoComplete_billfromaddressid").append(new Option(data.BillFromAddressName, data.BillFromAddressId, true));
- $(".txtAutoComplete_shipfromaddressid").append(new Option(data.ShipFromAddressName, data.ShipFromAddressId, true));
- if (InvoiceItem.Instance().orderid != 0 && InvoiceItem.Instance().dcid == 0) {
- $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillingAddressName, data.BillingAddressId, true));
- $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShippingAddressName, data.ShippingAddressId, true));
- }
- else {
- $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillToAddressName, data.BillToAddressId, true));
- $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShipToAddressName, data.ShipToAddressId, true));
- }
- if ((InvoiceItem.Instance().orderid != 0 || InvoiceItem.Instance().dcid != 0) && InvoiceItem.Instance().AutoDc == false) {
- $('.txtAutoComplete_billfromaddressid').prop('disabled', true);
- $('.txtAutoComplete_shipfromaddressid').prop('disabled', true);
- $('.txtAutoComplete_billtoaddressid').prop('disabled', true);
- $('.txtAutoComplete_shiptoaddressid').prop('disabled', true);
- }
- $(".txtAutoComplete_orgcontactid").prop('disabled', true);
- $('.hfAutoCompleteId_lobid').val(data.LobId);
- $('.txtAutoComplete_lobid').empty();
- $('.txtAutoComplete_lobid').append(new Option(data.LobName, data.LobId, true));
- $('.txtAutoComplete_lobid').prop('disabled', true);
- if (data.RefNo != "" && data.RefNo != null) {
- $(".txt_refno").val(data.RefNo);
- $(".div_refno").addClass("floating-label-form-group-with-value");
- }
- else {
- $(".txt_refno").val("");
- $(".div_refno").removeClass("floating-label-form-group-with-value");
- }
- $('.txtAutoComplete_salespersonid').append(new Option(data.SalesPersonName, data.SalesPersonId, true));
- $('.hfAutoCompleteId_salespersonid').val(data.SalesPersonId);
- if (InvoiceItem.Instance().orderid != 0 && InvoiceItem.Instance().orderid != undefined) {
- if (data.PaymentTermId != 0) {
- $('.hfAutoCompleteId_paymenttermid').val(data.PaymentTermId);
- $('.txtAutoComplete_paymenttermid').append(new Option(data.PaymentTermName, data.PaymentTermId, true));
- InvoiceItem.Instance().LoadDueDays();
- $(".txtAutoComplete_paymenttermid").prop('disabled', true);
- }
- $(".dropdown_paymentmethodid").val(data.PaymentMethodId);
- $(".dropdown_paymentmethodid").prop('disabled', true);
- if (data.BranchId != 0)
- $(".hdn_branchid").val(data.BranchId);
- $(".dropdown_istaxinclusive").val(data.IsTaxInclusive.toString());
- $(".dropdown_istaxinclusive").prop('disabled', true);
- }
- if (data.Description != null && data.Description != "")
- $(".divCustomProperties_systemnotes").find("textarea").val(data.Description);
- else
- $(".divCustomProperties_systemnotes").find("textarea").val("");
- $("#txt_AdjustmentAccountName").empty();
- $("#hf_AdjustmentAccountId").val("0");
- var Addr = $(".txtAutoComplete_billtoaddressid option:selected").val();
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6")
- Addr = $(".txtAutoComplete_billfromaddressid option:selected").val();
- InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Addr);
- InvoiceItem.Instance().bindAdjustmentAccount(data.LobId, Addr);
- InvoiceItem.Instance().getGSTNo();
- var Address = $(".txtAutoComplete_billtoaddressid option:selected").val();
- if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7")
- Address = $(".txtAutoComplete_billfromaddressid option:selected").val();
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
- Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressByContactId(Address).then(function (response) {
- if (response.result != null) {
- if (response.result.GSTNO != "" && response.result.GSTNO != null)
- $(".txt_gstno").val(response.result.GSTNO);
- }
- });
- });
- if ((data.OrderId == 0 || data.OrderId == undefined) && (InvoiceItem.Instance().dcid != 0 && InvoiceItem.Instance().dcid != undefined)) {
- InvoiceItem.Instance().bindDefaultPaymentTerm(data.OrganizationId, data.LobId);
- }
- if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") && $("#chk_tcsapplied").val() != undefined) {
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- $(".number_tcsamount").prop("disabled", true);
- InvoiceItem.Instance().GetCustomerTurnOver();
- }
- InvoiceItem.Instance().GetAvailableWallets(0);
- InvoiceItem.Instance().loadOrderPendingItems();
- InvoiceItem.Instance().IsCustomerIndustrial(data.LobId, data.OrganizationId);
- }
- });
- });
- }
- bindSeries(lobid, branchid) {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getSeries($("#hf_FormInstalledAppId").val(), branchid, lobid).then(function (response) {
- if (response.result != null) {
- var seriesData = [];
- if (response.result.length > 0) {
- $(".txtSeriesAutoComplete_seriesid").empty();
- for (let s = 0; s < response.result.length; s++) {
- let Series = response.result[s];
- seriesData.push({ id: Series.SeriesId, text: Series.SeriesName, AddlData: Series.ManualNumbering });
- }
- $('.txtSeriesAutoComplete_seriesid').select2({
- data: seriesData,
- });
- $(".txtSeriesAutoComplete_seriesid").val(response.result[0].SeriesId).trigger("change");
- }
- else {
- Unibase.Platform.Series.Managers.SeriesManager.Instance().getActiveSeries(0, Number($("#hf_FormInstalledAppId").val())).then(function (response) {
- var data = response.result;
- if (data != null) {
- if (data.length != 0) {
- $(".txtSeriesAutoComplete_seriesid").empty();
- for (var s = 0; s < data.length; s++) {
- let Series = data[s];
- seriesData.push({ id: Series.SeriesId, text: Series.SeriesName, AddlData: Series.ManualNumbering });
- }
- $('.txtSeriesAutoComplete_seriesid').select2({
- data: seriesData,
- });
- $(".txtSeriesAutoComplete_seriesid").val(data[0].SeriesId).trigger("change");
- }
- }
- });
- }
- }
- else {
- Unibase.Platform.Series.Managers.SeriesManager.Instance().getActiveSeries(0, Number($("#hf_FormInstalledAppId").val())).then(function (response) {
- var data = response.result;
- if (data != null) {
- if (data.length != 0) {
- $(".txtSeriesAutoComplete_seriesid").empty();
- for (var s = 0; s < data.length; s++) {
- var Series = new Option(data[s].SeriesName, data[s].SeriesId.toString(), true);
- $(".txtSeriesAutoComplete_seriesid").append(Series);
- $(".txtSeriesAutoComplete_seriesid").val(data[s].SeriesId);
- }
- $(".txtSeriesAutoComplete_seriesid").val(data[0].SeriesId);
- }
- }
- });
- }
- });
- }
- bindAdjustmentAccount(lobid, branchid) {
- $('#hf_AdjustmentAccountId').val("0");
- $('#txt_AdjustmentAccountName').empty();
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
- Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLobLedgerSetting(lobid, branchid).then(function (response) {
- if (response.result != null && response.result != "") {
- $("#txt_AdjustmentAccountName").append(new Option(response.result.LedgerName, response.result.SettingValue1, true));
- $("#hf_AdjustmentAccountId").val(response.result.SettingValue1);
- $("#txt_AdjustmentAccountName").val(response.result.SettingValue1);
- }
- });
- });
- }
- bindDefaultPaymentTerm(organizationid, lobid) {
- $('.hfAutoCompleteId_paymenttermid').val(0);
- $('.txtAutoComplete_paymenttermid').empty();
- Bizgaze.Apps.Transact.Managers.PaymentTermManager.Instance().getPaymentTermByOrg(organizationid, lobid).then(function (response) {
- var paymentterm = response.result;
- if (paymentterm != null && paymentterm != "") {
- $('.hfAutoCompleteId_paymenttermid').val(paymentterm.PaymentTermId);
- $('.txtAutoComplete_paymenttermid').append(new Option(paymentterm.PaymentTermName, paymentterm.PaymentTermId, true));
- if (paymentterm.DueDays != null && paymentterm.DueDays > 0) {
- var from = $('.date_journaldate').val().toString().split("/");
- var f = new Date(Number(from[2]), Number(from[1]) - 1, Number(from[0]));
- var currentdate = f.setDate(f.getDate() + paymentterm.DueDays);
- $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(currentdate, ""));
- let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(currentdate), "");
- var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
- $('.hfdate_duedate').val(tdate);
- }
- }
- });
- }
- LoadContactDetails() {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorganization($(".hfAutoCompleteId_orgcontactid").val()).then(function (response) {
- if (response.result != null && response.result != "") {
- if (response.result.OrganizationTypeId == 1)
- InvoiceItem.Instance().IswalkinCustomer = false;
- else
- InvoiceItem.Instance().IswalkinCustomer = true;
- InvoiceItem.Instance().LoadSpocDetails($(".hfAutoCompleteId_orgcontactid").val());
- }
- else {
- InvoiceItem.Instance().IswalkinCustomer = false;
- InvoiceItem.Instance().LoadSpocDetails($(".hfAutoCompleteId_orgcontactid").val());
- }
- });
- }
- LoadSpocDetails(contactid) {
- if ($('.hdn_invoicetypeid').val() == "1" || $('.hdn_invoicetypeid').val() == "6" || $('.hdn_invoicetypeid').val() == "4") {
- $('.txtAutoComplete_billtoaddressid').empty();
- $('.txtAutoComplete_shiptoaddressid').empty();
- }
- else {
- $('.txtAutoComplete_billfromaddressid').empty();
- $('.txtAutoComplete_shipfromaddressid').empty();
- }
- if ($(".hdn_invoiceid").val() == "0") {
- $(".txtAutoComplete_LobId").empty();
- $(".hfAutoCompleteId_LobId").empty();
- }
- $(".txtAutoComplete_salespersonid").empty();
- $(".hfAutoCompleteId_salespersoid").empty();
- if (InvoiceItem.Instance().IswalkinCustomer == true) {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorganization(contactid).then(function (response) {
- if (response.result != null) {
- $(".hdn_organizationid").val(response.result.OrganizationId);
- $("#hfInv_OrganizationName").val(response.result.OrganizationName);
- if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") && $("#chk_tcsapplied").val() != undefined) {
- InvoiceItem.Instance().GetCustomerTurnOver();
- }
- $.when(InvoiceItem.Instance().loadAddressAutoCompletes(response.result.OrganizationId)).then(function () {
- InvoiceItem.Instance().BindAddressDetails(response.result.OrganizationId);
- InvoiceItem.Instance().GetAvailableWallets(0);
- });
- }
- });
- }
- else {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorgcontact(contactid).then(function (response) {
- var data = response.result;
- if (response.result != null && data.OrganizationId != 0) {
- $(".hdn_organizationid").val(response.result.OrganizationId);
- $("#hfInv_OrganizationName").val(data.OrganizationName);
- if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") && $("#chk_tcsapplied").val() != undefined) {
- InvoiceItem.Instance().GetCustomerTurnOver();
- }
- $.when(InvoiceItem.Instance().loadAddressAutoCompletes(response.result.OrganizationId)).then(function () {
- InvoiceItem.Instance().BindAddressDetails(response.result.OrganizationId);
- InvoiceItem.Instance().GetAvailableWallets(0);
- });
- }
- });
- }
- }
- GetJournalAlloc(invoiceId) {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getJournalAllocs(invoiceId).then(function (response) {
- if (response.result.length > 0)
- $(".txtAutoComplete_orgcontactid").prop("disabled", true);
- });
- }
- formatDate(date) {
- var datearray = date.split("/");
- var newdate = datearray[1] + '/' + datearray[0] + '/' + datearray[2];
- var d = new Date(newdate), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear();
- if (month.length < 2)
- month = '0' + month;
- if (month.length < 2)
- month = '0' + month;
- if (day.length < 2)
- day = '0' + day;
- return [year, month, day].join('-');
- }
- GetAvailableWallets(invoiceid) {
- var ContactId = $(".hdn_organizationid").val();
- var invoiceId = 0;
- if (invoiceid != 0 && $('#hfInv_IsRetun').val() != "1") {
- invoiceId = Number($(".hdn_invoiceid").val());
- }
- if (invoiceId != 0)
- InvoiceItem.Instance().GetJournalAlloc(invoiceId);
- var invoicedate = $('.date_journaldate').val();
- var invdate = InvoiceItem.Instance().formatDate(invoicedate);
- var lobId = $(".txtAutoComplete_lobid").val();
- if (lobId == null || lobId == undefined)
- lobId = 0;
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getJournalWallets(invdate, invoiceId, ContactId, Number($(".hdn_invoicetypeid").val()), lobId).then(function (response) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/controls/payments/wallet.component.js", function () {
- if (response.result != null) {
- Bizgaze.Apps.Transact.Controls.Wallet.Instance().loadInvoiceWallets(response.result);
- }
- });
- });
- }
- BindAddressDetails(orgid) {
- let branchid = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("branchid"));
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getbranche(branchid).then(function (responce) {
- if (responce.result != null) {
- if (responce.result.DefaultWarehouseId != 0)
- var ShipTo = new Option(responce.result.DefaultWarehouseName, responce.result.DefaultWarehouseId, true);
- else
- var ShipTo = new Option(responce.result.BranchName, responce.result.BranchId, true);
- var BillTo = new Option(responce.result.BranchName, responce.result.BranchId, true);
- if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7") {
- $(".txtAutoComplete_shiptoaddressid").append(ShipTo);
- $(".txtAutoComplete_billtoaddressid").append(BillTo);
- $(".txtAutoComplete_billtoaddressid").change(function () {
- InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid").val(), $(".txtAutoComplete_billtoaddressid").val());
- InvoiceItem.Instance().bindAdjustmentAccount($(".txtAutoComplete_lobid").val(), responce.result.BranchId);
- });
- }
- else {
- $(".txtAutoComplete_shipfromaddressid").append(ShipTo);
- $(".txtAutoComplete_billfromaddressid").append(BillTo);
- $(".txtAutoComplete_billfromaddressid").change(function () {
- InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid").val(), $(".txtAutoComplete_billfromaddressid").val());
- InvoiceItem.Instance().bindAdjustmentAccount($(".txtAutoComplete_lobid").val(), responce.result.BranchId);
- });
- }
- }
- });
- this.fileCacheHelper.loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
- Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressByContactId(orgid).then(function (response) {
- if (response.result != null && response.result != "") {
- var ShipTo = new Option(response.result.AddressName, response.result.ContactAddressId, true);
- var BillTo = new Option(response.result.AddressName, response.result.ContactAddressId, true);
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "4") {
- $(".txtAutoComplete_shiptoaddressid").append(ShipTo);
- $(".txtAutoComplete_billtoaddressid").append(BillTo);
- $(".txtAutoComplete_billtoaddressid").change(function () {
- $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () {
- InvoiceItem.Instance().BindLoB();
- });
- });
- InvoiceItem.Instance().getGSTNo();
- }
- else {
- $(".txtAutoComplete_shipfromaddressid").append(ShipTo);
- $(".txtAutoComplete_billfromaddressid").append(BillTo);
- $(".txtAutoComplete_billfromaddressid").change(function () {
- $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () {
- InvoiceItem.Instance().BindLoB();
- });
- });
- InvoiceItem.Instance().getGSTNo();
- }
- if (response.result.GSTNO != "" && response.result.GSTNO != null)
- $(".txt_gstno").val(response.result.GSTNO);
- $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () {
- InvoiceItem.Instance().BindLoB();
- });
- }
- else {
- MessageHelper.Instance().showError("Please assign billing address and shipping address", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- }
- });
- });
- }
- getGSTNo() {
- var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var gstno = $(".txt_gstno").val();
- if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0 && Number($(".hdn_invoiceid").val()) != 0) {
- gstno = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_gstno").Value;
- }
- $(".txt_gstno").parent().addClass("floating-label-form-group-with-value");
- if (gstno != null && gstno != "") {
- $(".txt_gstno").val(gstno);
- }
- else
- $(".txt_gstno").val("GSTIN not Assigned");
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "4") {
- $(".txtAutoComplete_billtoaddressid").change(function () {
- Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(Number($(".txtAutoComplete_billtoaddressid").val())).then(function (ress) {
- if (ress.result != null) {
- if (ress.result.GSTNO != "" && ress.result.GSTNO != null)
- $(".txt_gstno").val(ress.result.GSTNO);
- }
- });
- });
- }
- else {
- $(".txtAutoComplete_billfromaddressid").change(function () {
- Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(Number($(".txtAutoComplete_billfromaddressid").val())).then(function (ress) {
- if (ress.result != null) {
- if (ress.result.GSTNO != "" && ress.result.GSTNO != null)
- $(".txt_gstno").val(ress.result.GSTNO);
- }
- });
- });
- }
- }
- loadLobAndSp() {
- var AddressId = $(".txtAutoComplete_billfromaddressid option:selected").val();
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "4")
- AddressId = $(".txtAutoComplete_billtoaddressid option:selected").val();
- var lobParameters = [{ "ColumnName": "contactaddressid", "Value": AddressId, }];
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_lobid"), lobParameters);
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/orders/ordermanager.js", function () {
- var SpParameters = [{ "ColumnName": "contactaddressid", "Value": AddressId, }];
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_salespersonid"), null);
- });
- }
- BindLoB() {
- $(".txtAutoComplete_lobid").empty();
- $('#hf_AdjustmentAccountId').val("0");
- $('#txt_AdjustmentAccountName').empty();
- if ($(".hdn_invoiceid").val() == "0") {
- $(".InvoiceItems").find(".item-addedrow").remove();
- InvoiceItem.Instance().SplitedInvoiceItemList = new Array();
- InvoiceItem.Instance().itemIds = [0];
- InvoiceItem.Instance().dcItemIds = [0];
- $("#txt_Adjustment").val("0");
- $("#span_Adjustment").text("0");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- var AddressId = $(".txtAutoComplete_billfromaddressid option:selected").val();
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6")
- AddressId = $(".txtAutoComplete_billtoaddressid option:selected").val();
- this.fileCacheHelper.loadJsFile("apps/crm/lobs/managers/lobmanager.js", function () {
- if (AddressId == undefined) {
- AddressId = 0;
- }
- Bizgaze.Apps.CRM.Lobs.Managers.LobManager.Instance().getLobsByAddressId(Number(AddressId)).then(function (response) {
- if (response.message != '') {
- Unibase.Platform.Forms.Components.FormViewer.Instance().showError(response.message);
- }
- if (response.result != "" && response.result != null) {
- if (response.result.length == 1) {
- var LoB = new Option(response.result[0].LobName, response.result[0].LobId, true);
- $(".txtAutoComplete_lobid").append(LoB);
- $(".txtAutoComplete_lobid").val(response.result[0].LobId);
- InvoiceItem.Instance().BindSalesPerson(AddressId);
- InvoiceItem.Instance().bindDefaultPaymentTerm($(".hdn_organizationid").val(), response.result[0].LobId);
- var Addr = $(".txtAutoComplete_billtoaddressid option:selected").val();
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6")
- Addr = $(".txtAutoComplete_billfromaddressid option:selected").val();
- InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Addr);
- InvoiceItem.Instance().bindAdjustmentAccount(response.result[0].LobId, Addr);
- }
- }
- });
- });
- $(".txtAutoComplete_lobid").change(function () {
- InvoiceItem.Instance().bindDefaultPaymentTerm($(".hdn_organizationid").val(), $(".txtAutoComplete_lobid option:selected").val());
- var Address = $(".txtAutoComplete_billtoaddressid option:selected").val();
- var Billto = $(".txtAutoComplete_billfromaddressid option:selected").val();
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6") {
- Address = $(".txtAutoComplete_billfromaddressid option:selected").val();
- Billto = $(".txtAutoComplete_billtoaddressid option:selected").val();
- }
- InvoiceItem.Instance().BindSalesPerson(Billto);
- InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Address);
- InvoiceItem.Instance().bindAdjustmentAccount($(".txtAutoComplete_lobid option:selected").val(), Address);
- $(".InvoiceItems").find(".item-addedrow").remove();
- InvoiceItem.Instance().SplitedInvoiceItemList = new Array();
- InvoiceItem.Instance().itemIds = [0];
- InvoiceItem.Instance().dcItemIds = [0];
- $("#txt_Adjustment").val("0");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- InvoiceItem.Instance().GetAvailableWallets(0);
- });
- }
- BindSalesPerson(AddressId) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
- Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getManagerDetails(Number($(".txtAutoComplete_lobid option:selected").val()), AddressId).then(function (response) {
- if (response.result != null) {
- var SalesPerson = new Option(response.result.ManagerName, response.result.EmployeeId, true);
- $(".txtAutoComplete_salespersonid").empty();
- $(".txtAutoComplete_salespersonid").append(SalesPerson);
- $(".txtAutoComplete_salespersonid").val(response.result.EmployeeId);
- }
- else {
- $(".txtAutoComplete_salespersonid").empty();
- $(".txtAutoComplete_salespersonid").val(0);
- $(".txtAutoComplete_salespersonid").text("");
- }
- });
- });
- }
- LoadDueDays() {
- if (InvoiceItem.Instance().dcid != 0 && InvoiceItem.Instance().AutoDc == false && InvoiceItem.Instance().OrderSettingId != 2) {
- var invdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate($('.date_journaldate').val());
- if (InvoiceItem.Instance().DcDate != undefined) {
- var date = InvoiceItem.Instance().DcDate.toString();
- var dcdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
- if (invdate < dcdate) {
- var dctext = "DC";
- if ($('.hdn_invoicetypeid').val() == "2")
- dctext = "GRN";
- MessageHelper.Instance().showError("Invoice Date should not be less than " + dctext + " Date", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- }
- }
- }
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/paymentterms/paymenttermmanager.js", function () {
- Bizgaze.Apps.Transact.Managers.PaymentTermManager.Instance().getPaymentTerm(Number($('.hfAutoCompleteId_paymenttermid').val())).then(function (result) {
- if (result.result != null) {
- if (result.result.DueDays > 0) {
- if ($('.date_journaldate').val() == "") {
- let todaydate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
- $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), ""));
- $('.hfdate_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), ""));
- }
- else {
- var from = $('.date_journaldate').val().toString().split('/');
- var f = new Date(Number(from[2]), Number(from[1]) - 1, Number(from[0]));
- var currentdate = f.setDate(f.getDate() + result.result.DueDays);
- var currentdate1 = f.setDate(f.getDate() + result.result.DueDays + 1);
- $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(currentdate), ""));
- let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(currentdate), "");
- var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
- $('.hfdate_duedate').val(tdate);
- }
- }
- }
- });
- });
- }
- loadAddressAutoCompletes(organizationid) {
- var ToAddressParameters = [{ "ColumnName": "contactid", "Value": organizationid, }];
- let invoicetypeid = $(".hdn_invoicetypeid").val();
- if (invoicetypeid == "1" || invoicetypeid == "4" || invoicetypeid == "6") {
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billtoaddressid"), ToAddressParameters);
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shiptoaddressid"), ToAddressParameters);
- $(".txtAutoComplete_billtoaddressid").change(function () {
- if (Number($(".hdn_invoiceid").val()) == 0) {
- $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () {
- InvoiceItem.Instance().BindLoB();
- });
- }
- });
- }
- else {
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billfromaddressid"), ToAddressParameters);
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shipfromaddressid"), ToAddressParameters);
- $(".txtAutoComplete_billfromaddressid").change(function () {
- $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () {
- InvoiceItem.Instance().BindLoB();
- });
- });
- }
- var FromAddressParameters = [{ "ColumnName": "companyid", "Value": Number(Unibase.Platform.Membership.Infos.Identity.getSetting("companyid")) }];
- if (invoicetypeid == "1" || invoicetypeid == "4" || invoicetypeid == "6") {
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billfromaddressid"), FromAddressParameters);
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shipfromaddressid"), FromAddressParameters);
- }
- else {
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billtoaddressid"), FromAddressParameters);
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shiptoaddressid"), FromAddressParameters);
- }
- }
- loadControlSettings(controlsettingjson, formpropertyid) {
- var instance = InvoiceItem.Instance();
- $("#btnInvoiceItem").off().click(function () {
- let lobid = $(".hfAutoCompleteId_lobid").val();
- if (lobid == undefined || lobid == "" || lobid == "0") {
- MessageHelper.Instance().showError("Please Select LoB", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- else
- InvoiceItem.instance.addRow();
- });
- $("#btndiscountItem").off().click(function () {
- InvoiceItem.Instance().adddiscountrow(null, "", "", false);
- });
- instance.itemIds = new Array();
- instance.dcItemIds = new Array();
- instance.itemIds.push(0);
- instance.dcItemIds.push(0);
- instance.SplitedInvoiceItemList = new Array();
- instance.deleted_invoiceItems = new Array();
- instance.invItemTaxAdjustmentList = new Array();
- instance.AutoDc = false;
- instance.OrderSettingId = 0;
- instance.orderid = 0;
- instance.dcid = 0;
- instance.IswalkinCustomer = false;
- $('.inv_hdnfiels').empty();
- var d = "<div class='inv_hdnfiels'></div>";
- $(".section_CompanyDetails").prepend(d);
- var hiddenfileds = "<input type='hidden' id='hfInv_OrganizationName' value=''/>" +
- "<input type='hidden' id='hfInv_IsRetun' value='0'/>" +
- "<input type='hidden' id='hfInv_wallet' value='false' />";
- $('.inv_hdnfiels').append(hiddenfileds);
- $(".hdn_branchid").val(Unibase.Platform.Membership.Infos.Identity.getSetting("branchid"));
- var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
- if (obj.Key === "hf_" + InstalledAppId + "_orderid") {
- InvoiceItem.Instance().orderid = Number(Number(obj.Value));
- $(".hdn_orderid").val(Number(obj.Value));
- if (Number(obj.Value) != 0) {
- for (let ob of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
- if (ob.Key === "hf_" + InstalledAppId + "_branchid")
- $(".hdn_branchid").val(ob.Value);
- }
- }
- }
- if (obj.Key === "hf_" + InstalledAppId + "_dcid") {
- InvoiceItem.instance.dcid = Number(obj.Value);
- $(".hdn_dcid").val(Number(obj.Value));
- }
- if (obj.Key === "hf_" + InstalledAppId + "_claimid") {
- InvoiceItem.instance.ClaimId = Number(obj.Value);
- }
- if (obj.Key === "hf_" + InstalledAppId + "_dcdate") {
- InvoiceItem.instance.DcDate = obj.Value;
- }
- }
- if ((InvoiceItem.instance.dcid == 0 || InvoiceItem.instance.dcid == undefined) && (InvoiceItem.instance.dcid == 0 || InvoiceItem.instance.dcid == undefined)) {
- instance.AutoDc = true;
- }
- InvoiceItem.Instance().invoiceinit();
- $("#txt_taxAajustment").blur(function () {
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- $("#txt_assessableadjustment").blur(function () {
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- $(document).ready(function (e) {
- if (Number($("#hf_pk_value").val()) != 0 && $("#chk_tdsapplied").is(":checked")) {
- $(".divCustomProperties_tdstaxcodeid").removeClass('hidden');
- $(".divCustomProperties_tdstaxrate").removeClass('hidden');
- $(".divCustomProperties_tdsamount").removeClass('hidden');
- }
- else {
- $(".divCustomProperties_tdstaxcodeid").addClass('hidden');
- $(".divCustomProperties_tdstaxrate").addClass('hidden');
- $(".divCustomProperties_tdsamount").addClass('hidden');
- }
- $("#chk_tdsapplied").removeAttr("onclick");
- $("#chk_tdsapplied").change(function () {
- if ($(this).prop('checked') == false) {
- $(".txtAutoComplete_tdstaxcodeid").val(0);
- $(".txtAutoComplete_tdstaxcodeid").text("");
- $(".number_tdstaxrate").val(0);
- $(".divCustomProperties_tdstaxcodeid").addClass('hidden');
- $(".divCustomProperties_tdstaxrate").addClass('hidden');
- $(".divCustomProperties_tdsamount").addClass('hidden');
- $("#chk_tcsapplied").removeAttr("disabled");
- $("#hdnchk_tdsapplied").val("false");
- }
- else {
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- $('#chk_tcsapplied').prop('checked', false);
- $('#chk_tcsapplied').attr('disabled', "true");
- $(".divCustomProperties_tdstaxcodeid").removeClass('hidden');
- $(".divCustomProperties_tdstaxrate").removeClass('hidden');
- $(".divCustomProperties_tdsamount").removeClass('hidden');
- $("#chk_tcsapplied").attr("disabled");
- $("#hdnchk_tdsapplied").val("true");
- }
- InvoiceItem.Instance().update_total();
- });
- $(".txtAutoComplete_tdstaxcodeid").change(function () {
- $(".number_tdstaxrate").val(Number($(".txtAutoComplete_tdstaxcodeid").attr('data-addldata')));
- InvoiceItem.Instance().update_total();
- });
- });
- }
- loadPropertySettings(propertysettings, formpropertyid) {
- }
- bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
- }
- bindEditInvoiceDetails(invoiceid) {
- var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
- $("#" + VisibleContainerId).find(".btn_Save_Form").removeClass("hidden");
- if ($('.hdn_invoicetypeid').val() == "1" && $("#hf_AppSettingName").val() == "Create Return") {
- $('#hfInv_IsRetun').val(1);
- $('.hdn_invoicetypeid').val("3");
- $(".txtSeriesAutoComplete_seriesid").prop("disabled", false);
- $("#div_FormName").text("Create Sales Return");
- $(".txtAutoComplete_orgcontactid").prop("disabled", true);
- $(".hdn_journalno").val(0);
- }
- else if ($('.hdn_invoicetypeid').val() == "2" && $("#hf_AppSettingName").val() == "Create Return") {
- $('#hfInv_IsRetun').val(1);
- $('.hdn_invoicetypeid').val("4");
- $(".txtSeriesAutoComplete_seriesid").prop("disabled", false);
- $("#div_FormName").text("Create Purchase Return");
- $(".txtAutoComplete_orgcontactid").prop("disabled", true);
- $(".hdn_journalno").val(0);
- }
- let invoicetypeid = $('.hdn_invoicetypeid').val();
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/invoicemanager.js", function () {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(invoiceid).then(function (result) {
- var data = result.result;
- var companyId = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("companyid"));
- var Parameters = [];
- if ($(".hdn_invoicetypeid").val() != "6" && $(".hdn_invoicetypeid").val() != "7")
- Parameters = [{ "ColumnName": "companyid", "Value": companyId }];
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_orgcontactid"), Parameters);
- InvoiceItem.Instance().AutoDc = data.AutoDc;
- if (data.OrgContactId == 0) {
- InvoiceItem.Instance().IswalkinCustomer = true;
- $(".hfAutoCompleteId_orgcontactid").val(data.OrganizationId);
- var selectedCompany = new Option(data.OrganizationName, data.OrganizationId, true);
- }
- else {
- InvoiceItem.Instance().IswalkinCustomer = false;
- if (data.OrgContactName == null)
- data.OrgContactName = "";
- $(".hfAutoCompleteId_orgcontactid").val(data.OrgContactId);
- var selectedCompany = new Option(data.OrganizationName + " - " + data.OrgContactName, data.OrgContactId, true);
- }
- $(".txtAutoComplete_orgcontactid").empty();
- $(".txtAutoComplete_orgcontactid").append(selectedCompany);
- if ($(".section_Details").hasClass('hidden')) {
- $(".section_Details").removeClass('hidden');
- }
- if ($(".section_ItemDetails").hasClass('hidden')) {
- $(".section_ItemDetails").removeClass('hidden');
- }
- if ($(".section_Ebs").hasClass('hidden')) {
- $(".section_Ebs").removeClass('hidden');
- }
- if ($(".section_InvoiceAmount").hasClass('hidden')) {
- $(".section_InvoiceAmount").removeClass('hidden');
- }
- if ($(".section_Description").hasClass('hidden')) {
- $(".section_Description").removeClass('hidden');
- }
- if ($(".section_BillingAndShippingDetails").hasClass('hidden')) {
- $(".section_BillingAndShippingDetails").removeClass('hidden');
- }
- if ($(".section_Wallets").hasClass('hidden')) {
- $(".section_Wallets").removeClass("hidden");
- }
- if ($(".section_TCS").hasClass('hidden')) {
- $(".section_TCS").removeClass("hidden");
- }
- $("#btn_Save").removeClass('hidden');
- $(".txtAutoComplete_lobid").prop("disabled", true);
- $(".txtAutoComplete_orgcontactid").prop("disabled", true);
- if ($('#hfInv_IsRetun').val() == "1" && ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) {
- let todaydate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
- $('.date_journaldate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), ""));
- var tdate = moment(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), ""), "DD/MM/YYYY").format("YYYY/MM/DD");
- $('.hfdate_journaldate').val(tdate);
- $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), ""));
- $('.hfdate_duedate').val(tdate);
- InvoiceItem.Instance().LoadDueDays();
- }
- else {
- $('.date_journaldate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(data.InvoiceDate, ""));
- let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(data.InvoiceDate), "");
- var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
- $('.hfdate_journaldate').val(tdate);
- $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(data.DueDate, ""));
- var date1 = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(data.DueDate), "");
- tdate = moment(date1, "DD/MM/YYYY").format("YYYY/MM/DD");
- $('.hfdate_duedate').val(tdate);
- }
- $('.date_refdate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(data.RefDate, ""));
- date1 = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(data.RefDate), "");
- tdate = moment(date1, "DD/MM/YYYY").format("YYYY/MM/DD");
- $('.hfdate_refdate').val(tdate);
- $.when(Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().loadAddressAutoCompletes(data.OrganizationId)).then(function (response) {
- $(".txtAutoComplete_billfromaddressid").empty();
- $(".txtAutoComplete_billtoaddressid").empty();
- $(".txtAutoComplete_shiptoaddressid").empty();
- $(".txtAutoComplete_shipfromaddressid").empty();
- if ($('.hdn_invoicetypeid').val() == "1" || $('.hdn_invoicetypeid').val() == "4" || $('.hdn_invoicetypeid').val() == "6") {
- $(".hfAutoCompleteId_billfromaddressid").val(data.BillFromAddressId);
- $(".txtAutoComplete_billfromaddressid").append(new Option(data.BillFromAddressName, data.BillFromAddressId, true));
- $(".hfAutoCompleteId_billtoaddressid").val(data.BillToAddressId);
- $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillToAddressName, data.BillToAddressId, true));
- $(".hfAutoCompleteId_shiptoaddressid").val(data.ShipToAddressId);
- $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShipToAddressName, data.ShipToAddressId, true));
- $(".hfAutoCompleteId_shipfromaddressid").val(data.ShipFromAddressId);
- $(".txtAutoComplete_shipfromaddressid").append(new Option(data.ShipFromAddressName, data.ShipFromAddressId, true));
- }
- else {
- $(".hfAutoCompleteId_billfromaddressid").val(data.BillToAddressId);
- $(".txtAutoComplete_billfromaddressid").append(new Option(data.BillToAddressName, data.BillToAddressId, true));
- $(".hfAutoCompleteId_billtoaddressid").val(data.BillFromAddressId);
- $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillFromAddressName, data.BillFromAddressId, true));
- $(".hfAutoCompleteId_shiptoaddressid").val(data.ShipFromAddressId);
- $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShipFromAddressName, data.ShipFromAddressId, true));
- $(".hfAutoCompleteId_shipfromaddressid").val(data.ShipToAddressId);
- $(".txtAutoComplete_shipfromaddressid").append(new Option(data.ShipToAddressName, data.ShipToAddressId, true));
- }
- InvoiceItem.Instance().loadLobAndSp();
- InvoiceItem.Instance().getGSTNo();
- $('.txtAutoComplete_lobid').empty();
- $(".txtAutoComplete_lobid").append(new Option(data.LobName, data.LobId, true));
- $(".hfAutoCompleteId_lobid").val(data.LobId);
- $('.txtAutoComplete_salespersonid').empty();
- $('.txtAutoComplete_salespersonid').append(new Option(data.SalesPersonName, data.SalesPersonId, true));
- $('.hfAutoCompleteId_salespersonid').val(data.SalesPersonId);
- $('hdn_OrganizationId').val(data.OrganizationId);
- $("#hfInv_OrganizationName").val(data.OrganizationName);
- $('.txtAutoComplete_paymenttermid').empty();
- $('.hfAutoCompleteId_paymenttermid').val(data.PaymentTermId);
- $('.txtAutoComplete_paymenttermid').append(new Option(data.PaymentTermName, data.PaymentTermId, true));
- if (data.SeriesId != 0 && $('#hfInv_IsRetun').val() != "1") {
- $(".txtSeriesAutoComplete_seriesid").empty();
- $(".hfSeriesAutoCompleteId_seriesid").val(0);
- $(".txtSeriesAutoComplete_seriesid").append(new Option(data.SeriesName, data.SeriesId, true));
- $(".hfSeriesAutoCompleteId_seriesid").val(data.SeriesId);
- }
- else {
- $(".txtSeriesAutoComplete_seriesid").prop("disabled", false);
- if (data.SeriesId == 0 && data.InvoiceNo != null && data.InvoiceNo != "") {
- $(".isManualSeries_seriesid").prop("checked", true);
- $(".TextManualSeries").val(data.InvoiceNo);
- }
- else {
- var Addr = $(".txtAutoComplete_billtoaddressid option:selected").val();
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6")
- Addr = $(".txtAutoComplete_billfromaddressid option:selected").val();
- InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Addr);
- }
- }
- if (($('#hfInv_IsRetun').val() != "1") && ($('.hdn_invoicetypeid').val() == "4" || $('.hdn_invoicetypeid').val() == "7" || $('.hdn_invoicetypeid').val() == "6" || $('.hdn_invoicetypeid').val() == "3")) {
- $(".txtSeriesAutoComplete_seriesid").prop("disabled", true);
- }
- if (data.RefNo != "" && data.RefNo != null)
- $(".txt_refno").val(data.RefNo);
- $(".hdn_refinvoiceid").val(data.RefInvoiceId);
- if ($('#hfInv_IsRetun').val() == "1" && ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4"))
- $(".txt_refno").val(data.InvoiceNo);
- if (data.AdjustmentAccountId != 0) {
- $("#txt_AdjustmentAccountName").append(new Option(data.AdjustmentAccountName, data.AdjustmentAccountId, true));
- $("#txt_AdjustmentAccountName").val(data.AdjustmentAccountId);
- $("#hf_AdjustmentAccountId").val(data.AdjustmentAccountId);
- }
- if (data.AdjustmentAccountId == 0)
- $('#txt_AdjustmentAccountName').empty();
- if (data.AutoAdjustment == true) {
- $('#chk_AutoAdjustment').prop('checked', true);
- $('#txt_Adjustment').prop("disabled", true);
- $(".span_AdjustmentAccountName").removeClass('hidden');
- $("#txt_AdjustmentAccountName").addClass('required');
- }
- else {
- $('#chk_AutoAdjustment').prop('checked', false);
- $('#txt_Adjustment').prop("disabled", false);
- $("#txt_AdjustmentAccountName").removeClass('required');
- $(".span_AdjustmentAccountName").addClass('hidden');
- }
- $('#txt_Adjustment').val(data.Adjustment);
- if (data.Adjustment != 0) {
- $('.span_AdjustmentAccountName').removeClass('hidden');
- $("#txt_AdjustmentAccountName").addClass('required');
- }
- else {
- $('.span_AdjustmentAccountName').addClass('hidden');
- $("#txt_AdjustmentAccountName").removeClass('required');
- }
- if (data.InvoiceStatusId == 6) {
- $('#btnInvoiceItem').hide();
- }
- var Iswalkincustomer = false;
- var contactid = data.OrgContactId;
- if (data.OrgContactId == 0) {
- Iswalkincustomer = true;
- contactid = data.OrganizationId;
- }
- InvoiceItem.Instance().IsCustomerIndustrial(data.LobId, data.OrganizationId);
- $(".chk_excludefromcampaign").prop("checked", data.ExcludeFromCampaign);
- $("#hfId_istaxinclusive").val(data.IsTaxInclusive);
- InvoiceItem.Instance().isOfferChargeApplied = data.IsOfferChargeApplied;
- $(".dropdown_istaxinclusive").val(data.IsTaxInclusive.toString());
- $(".dropdown_paymentmethodid").val(data.PaymentMethodId);
- InvoiceItem.Instance().GetAvailableWallets(data.InvoiceId);
- InvoiceItem.Instance().loadOrderPendingItems();
- });
- $(".txtAutoComplete_orgcontactid").change(function () {
- InvoiceItem.Instance().LoadContactDetails();
- });
- if (data.GSTNO != "" && data.GSTNO != null)
- $(".txt_gstno").val(data.GSTNO);
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getCustomerTurnOver($(".hdn_organizationid").val(), $(".hdn_invoiceid").val(), InvoiceItem.Instance().formatDate($(".date_journaldate").val()), $(".hdn_invoicetypeid").val()).then(function (res) {
- if (res.result != null) {
- InvoiceItem.Instance().TurnOver = res.result.TurnOver;
- InvoiceItem.Instance().ContactTcsEnable = res.result.Enable;
- InvoiceItem.Instance().EnableTenantTcs = res.result.EnableTenantTcs;
- InvoiceItem.Instance().PanAvailable = res.result.PanAvailable;
- InvoiceItem.Instance().TaxRate = res.result.TaxRate;
- $(".hdn_tcstaxcodeaccountid").val(res.result.TCSTaxCodeAccountId);
- $(".hdn_tcstaxcodeid").val(res.result.TCSTaxCodeId);
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2") {
- if (InvoiceItem.Instance().ContactTcsEnable == true && InvoiceItem.Instance().EnableTenantTcs == true && data.TcsApplied == true) {
- $("#chk_tcsapplied").prop("checked", true);
- $("#hdnchk_tcsapplied").val("true");
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- $(".number_tcsamount").prop("disabled", true);
- }
- }
- }
- });
- $("chk_tcsapplies").prop("checked", data.TcsApplied);
- $(".hdn_tcstaxcodeid").val(data.TcsTaxCodeId);
- $(".hdn_tcstaxcodeaccountid").val(data.TcsTaxCodeAccountId);
- $(".number_tcstaxrate").val(data.TcsTaxRate);
- $(".number_tcstaxrate").prop("disabled", true);
- $(".txt_tcsadjustment").val(data.TcsAdjustment);
- $(".number_tcsamount").val(data.TcsAmount);
- $(".number_tcsamount").prop("disabled", true);
- $(".number_tdsamount").prop("disabled", true);
- $(".number_tdstaxrate").prop("disabled", true);
- InvoiceItem.Instance().ContactTcsEnable = data.TcsApplied;
- InvoiceItem.Instance().TaxRate = data.TcsTaxRate;
- if (data.TcsApplied == true) {
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- }
- else {
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- }
- $("#chk_tcsapplied").unbind();
- $("#chk_tcsapplied").change(function () {
- if ($('#chk_AutoAdjustment').prop("checked") == true) {
- $("#txt_Adjustment").val(0);
- $(".hdn_adjustment").val(0);
- }
- if ($(this).prop('checked') == true) {
- $(".divCustomProperties_tdstaxrate").addClass("hidden");
- $(".divCustomProperties_tdsamount").addClass("hidden");
- $(".divCustomProperties_tdstaxcodeid").addClass("hidden");
- $(".chk_tdsapplied").attr("disabled");
- $('#chk_tdsapplied').prop('checked', false);
- }
- else {
- $(".chk_tdsapplied").removeAttr("disabled");
- }
- $(".div_tcsadjustment").addClass("floating-label-form-group-with-value");
- if ($(this).prop('checked') == true && InvoiceItem.Instance().EnableTenantTcs == false && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) {
- MessageHelper.Instance().showError("Please Submit TCS Declaration", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- $("#hdnchk_tcsapplied").val("false");
- $('#chk_tcsapplied').prop('checked', false);
- }
- else {
- if ($(this).prop('checked') == true && $(".hdn_invoicetypeid").val() == "1") {
- bootbox.confirm("Confirm if sale value is > 50,00,000 for this customer.In this current Financial Year.", function (result) {
- if (result) {
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- else {
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- $('#chk_tcsapplied').prop('checked', false);
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- });
- }
- else if ($(this).prop('checked') == true) {
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- $("#chk_tdsapplied").removeAttr("disabled");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- else if ($(this).prop('checked') == false) {
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- $(".number_tcstaxrate").val(data.TcsTaxRate);
- $(".number_tcstaxrate").prop("disabled", true);
- $(".txt_tcsadjustment").val(data.TcsAdjustment);
- $(".number_tcsamount").val(data.TcsAmount);
- $(".number_tcsamount").prop("disabled", true);
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- }
- });
- if ($("#chk_tdsapplied").prop('checked') == false) {
- $(".divCustomProperties_tdstaxrate").addClass("hidden");
- $(".divCustomProperties_tdsamount").addClass("hidden");
- $(".divCustomProperties_tdstaxcodeid").addClass("hidden");
- }
- else
- $("#chk_tcsapplied").attr("disabled");
- $(".txt_tcsadjustment").unbind();
- $(".txt_tcsadjustment").blur(function () {
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- });
- });
- }
- loadOrderPendingItems() {
- var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- let instance = this;
- let invoiceid = $(".hdn_invoiceid").val();
- var orderid = $(".hdn_orderid").val();
- var Dcid = $(".hdn_dcid").val();
- var fromOrder = false;
- var items = [];
- var Invoiceitem = [];
- $(".item-addedrow").remove();
- var url = "";
- if (Dcid != 0 && Dcid != undefined && orderid == 0) {
- fromOrder = false;
- url = "apis/v4/bizgaze/transact/Dc/getpendingdcitemsforinvoice/dcid/" + Dcid;
- }
- if (Dcid == 0 || Dcid == undefined || InvoiceItem.Instance().OrderSettingId == 2) {
- if (orderid != "0" && orderid != undefined) {
- fromOrder = true;
- url = "apis/v4/bizgaze/transact/Orders/getpendingitemsforinvoice/orderid/" + orderid + "/ismergeorder/false";
- }
- }
- else if (Dcid != 0 && Dcid != undefined) {
- fromOrder = false;
- url = "apis/v4/bizgaze/transact/Dc/getpendingdcitemsforinvoice/dcid/" + Dcid;
- }
- if (invoiceid != 0 && invoiceid != undefined && invoiceid != "null") {
- fromOrder = false;
- if ($('#hfInv_IsRetun').val() == "1") {
- if ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")
- url = "apis/v4/bizgaze/transact/invoices/getinvoiceitemsbyinvoiceid/invoiceid/" + invoiceid + "/isreturn/true/itemid/0";
- }
- else
- url = "apis/v4/bizgaze/transact/invoices/getinvoiceitemsbyinvoiceid/invoiceid/" + invoiceid + "/isreturn/false/itemid/0";
- }
- if (url != "") {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceItems(url).then(function (response) {
- var oldTaxId = 0;
- var totalQty = 0;
- if (response.result != null && response.result.length > 0)
- instance.ShowOrHideSaveBtn(false);
- for (var i = 0; i < response.result.length; i++) {
- var item = response.result[i];
- var invoiceItemId = 0;
- totalQty += item.Quantity;
- if (invoiceid != "0" && invoiceid != undefined && invoiceid != "null") {
- invoiceItemId = item.InvoiceItemId;
- item.IsOfferChargeApplied = InvoiceItem.Instance().isOfferChargeApplied;
- }
- InvoiceItem.Instance().isOfferChargeApplied = true;
- $(".hdn_isofferchargeapplied").val('true');
- var refInvoiceItemId = 0;
- if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $("#hf_AppSettingName").val() == "Create Return")
- refInvoiceItemId = item.InvoiceItemId;
- if (i == 0)
- oldTaxId = item.TaxGroupId;
- if (oldTaxId != item.TaxGroupId && i != 0)
- $('#addDiscount').addClass('hidden');
- var maxQty = 0;
- if (item.OrderItemPendingQty > 0)
- maxQty = item.OrderItemPendingQty;
- var pendingQuantity = item.OrderItemPendingQty > 0 ? item.OrderItemPendingQty : 0;
- if (invoiceItemId != 0)
- maxQty = item.Quantity + pendingQuantity;
- if (item.DcItemId == undefined)
- item.DcItemId = 0;
- if (item.TaxAdjustment == undefined)
- item.TaxAdjustment = 0;
- if (item.AssesableAdjustment == undefined)
- item.AssesableAdjustment = 0;
- if (item.IsFoc == undefined)
- item.IsFoc = false;
- if (item.OfferItemId == undefined)
- item.OfferItemId = 0;
- if (item.DiscountPercent == undefined)
- item.DiscountPercent = 0;
- if (item.DiscountValue == undefined)
- item.DiscountValue = 0;
- if (item.IsSpecialPrice == undefined)
- item.IsSpecialPrice = false;
- if (item.MrpId == 0)
- item.EnableMRP = false;
- var itemRow = {
- orderItemId: item.OrderItemId,
- invoiceItemId: invoiceItemId,
- itemName: item.ItemName,
- itemId: item.ItemId,
- itemSKU: item.ItemSKU,
- unitName: item.UnitName,
- packSize: item.PackSize,
- packCount: item.PackCount,
- packs: item.Packs,
- quantity: item.Quantity,
- availPacks: item.AvailablePacks,
- availQty: item.AvailableQty,
- listPrice: 0,
- description: item.Description,
- taxGroupName: item.TaxGroupName,
- taxGroupId: item.TaxGroupId,
- isTaxInclusive: $("#hfId_istaxinclusive").val(),
- addlDiscountPercent: item.DiscountPercent,
- addlDiscountValue: item.DiscountAmount,
- creditNote: 0,
- priceListId: 0,
- batchId: 0,
- unitPrice: item.UnitPrice,
- invoiceallocations: null,
- exciseInvoiceItem: null,
- accountId: item.LedgerId,
- accountName: item.LedgerName,
- walletId: 0,
- Adjustment: 0,
- IsFoc: item.IsFoc,
- TariffNo: "",
- exciseAmount: item.ExciseAmount,
- discountName: "",
- discountId: 0,
- refNo: item.RefNo,
- DiscountGroupId: item.DiscountGroupId,
- DiscountGroupName: item.DiscountGroupName,
- ExchangeItem: item.ExchangeDC,
- maxQty: maxQty,
- RefInvoiceItemId: refInvoiceItemId,
- MrpId: item.MrpId,
- taxAdjustment: item.TaxAdjustment,
- assesableAdjustment: item.AssesableAdjustment,
- inventoryTypeId: item.InventoryTypeId,
- IsBoMItem: item.IsBoMItem,
- dcItemId: item.DcItemId,
- TotalRowAmount: 0,
- TotalDiscount: 0,
- BatchId: item.BatchId,
- OfferItemId: item.OfferItemId,
- AlternateUnitId: item.AlternateUnitId,
- DefaultSize: item.DefaultSize,
- ParentBOMItemId: item.ParentBOMItemId,
- IsSpecialPrice: item.IsSpecialPrice,
- IsMultipleUOMs: item.IsMultipleUOMs,
- MultipleUoms: item.MultipleUOMs,
- IsManualUOM: item.IsManualUOM,
- ConversionQuantity: item.ConversionQuantity,
- AlternateUnitName: item.AlternateUnitName,
- };
- var EnableMrp = item.EnableMRP;
- var EnableBatch = item.EnableBatch;
- if (item.IsFoc == true)
- Invoiceitem.push(itemRow);
- else if (item.DcItemId != 0 && EnableMrp != true && EnableBatch != true)
- Invoiceitem.push(itemRow);
- else if (item.InvoiceItemId == 0) {
- if (InvoiceItem.Instance().orderid != 0 && Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_ordertypeid").Value) == 2 && EnableMrp != true && EnableBatch != true)
- Invoiceitem.push(itemRow);
- }
- else if (item.InvoiceItemId == 0) {
- if (InvoiceItem.Instance().orderid != 0 && Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_ordertypeid").Value) == 1 && ((EnableMrp != true && EnableBatch != true) || Number(item.AvailableQty) <= 0))
- Invoiceitem.push(itemRow);
- }
- else if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && ((EnableMrp != true && EnableBatch != true)))
- Invoiceitem.push(itemRow);
- else if (($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3") && EnableMrp != true && EnableBatch != true)
- Invoiceitem.push(itemRow);
- else if ($(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7")
- Invoiceitem.push(itemRow);
- else {
- if (item.InventoryTypeId != 5 && item.InventoryTypeId != 6 && item.InventoryTypeId != 7) {
- var total = Number((itemRow.quantity * itemRow.unitPrice) + itemRow.exciseAmount + itemRow.Adjustment + itemRow.assesableAdjustment);
- var nonexcise = total - itemRow.exciseAmount;
- var disc = ((nonexcise * itemRow.addlDiscountPercent) / 100) + (itemRow.quantity * itemRow.addlDiscountValue);
- var Rowtotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(total - disc, 3);
- InvoiceItem.Instance().SplitedInvoiceItemList.push({
- orderItemId: item.OrderItemId,
- invoiceItemId: invoiceItemId,
- itemName: item.ItemName,
- itemId: item.ItemId,
- itemSKU: item.ItemSKU,
- unitName: item.UnitName,
- packSize: item.PackSize,
- packCount: item.PackCount,
- packs: item.Packs,
- quantity: item.Quantity,
- availPacks: item.AvailablePacks,
- availQty: item.AvailableQty,
- listPrice: 0,
- description: item.Description,
- taxGroupName: item.TaxGroupName,
- taxGroupId: item.TaxGroupId,
- isTaxInclusive: $("#hfId_istaxinclusive").val(),
- addlDiscountPercent: item.DiscountPercent,
- addlDiscountValue: item.DiscountAmount,
- creditNote: 0,
- priceListId: 0,
- batchId: 0,
- unitPrice: item.UnitPrice,
- invoiceallocations: null,
- exciseInvoiceItem: null,
- accountId: item.LedgerId,
- accountName: item.LedgerName,
- walletId: 0,
- Adjustment: 0,
- IsFoc: 0,
- TariffNo: "",
- exciseAmount: item.ExciseAmount,
- discountName: "",
- discountId: 0,
- refNo: item.RefNo,
- DiscountGroupId: item.DiscountGroupId,
- DiscountGroupName: item.DiscountGroupName,
- ExchangeItem: item.ExchangeDC,
- maxQty: maxQty,
- RefInvoiceItemId: refInvoiceItemId,
- MrpId: item.MrpId,
- taxAdjustment: item.TaxAdjustment,
- assesableAdjustment: item.AssesableAdjustment,
- inventoryTypeId: item.InventoryTypeId,
- IsBoMItem: item.IsBoMItem,
- dcItemId: item.DcItemId,
- TotalRowAmount: Rowtotal,
- TotalDiscount: disc,
- BatchId: item.BatchId,
- TotalAmount: Rowtotal,
- ParentBOMItemId: item.ParentBOMItemId
- });
- if (items.length != 0 && items.find(x => x.itemId == item.ItemId) != undefined) {
- var multipleExist = items.find(x => x.itemId == item.ItemId);
- multipleExist.quantity += itemRow.quantity;
- var RowTotal = 0;
- var rowtotal = Number((itemRow.quantity * itemRow.unitPrice) + itemRow.exciseAmount + itemRow.Adjustment + itemRow.assesableAdjustment);
- var nonexiceamount = rowtotal - itemRow.exciseAmount;
- var discount = ((nonexiceamount * itemRow.addlDiscountPercent) / 100) + (itemRow.quantity * itemRow.addlDiscountValue);
- discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3));
- RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3);
- multipleExist.TotalRowAmount = Number(multipleExist.TotalRowAmount) + Number(RowTotal);
- multipleExist.TotalDiscount = Number(multipleExist.TotalDiscount) + Number(discount);
- if (InvoiceItem.Instance().OrderSettingId == 1) {
- var Qty = Number(maxQty);
- multipleExist.maxQty = Qty + Number(multipleExist.maxQty);
- }
- else {
- var Qty = Number(item.Quantity);
- multipleExist.maxQty = Qty + Number(multipleExist.maxQty);
- }
- }
- else {
- var RowTotal = 0;
- var rowtotal = Number((itemRow.quantity * itemRow.unitPrice) + itemRow.exciseAmount + itemRow.Adjustment + itemRow.assesableAdjustment);
- var nonexiceamount = rowtotal - itemRow.exciseAmount;
- var discount = ((nonexiceamount * itemRow.addlDiscountPercent) / 100) + (itemRow.quantity * itemRow.addlDiscountValue);
- discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3));
- RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3);
- itemRow.TotalRowAmount = Number(itemRow.TotalRowAmount) + Number(RowTotal);
- itemRow.TotalDiscount = Number(discount);
- items.push(itemRow);
- }
- }
- else {
- Invoiceitem.push(itemRow);
- }
- }
- $.each(item.InvItemTaxAdjustments, function (e) {
- var data = $(this);
- var rowData = data[0];
- InvoiceItem.Instance().invItemTaxAdjustmentList.push(rowData);
- });
- }
- for (let j1 = 0; j1 < items.length; j1++) {
- let j = items[j1];
- var emptyRow = {
- orderItemId: j.orderItemId,
- invoiceItemId: 0,
- itemName: j.itemName,
- itemId: j.itemId,
- itemSKU: j.itemSKU,
- unitName: "",
- packSize: 0,
- packCount: 0,
- packs: 0,
- quantity: j.quantity,
- availPacks: 0,
- availQty: j.availQty,
- listPrice: 0,
- description: "",
- taxGroupName: j.taxGroupName,
- taxGroupId: j.taxGroupId,
- isTaxInclusive: $("#hf_istaxinclusive").val(),
- addlDiscountPercent: 0,
- addlDiscountValue: j.addlDiscountValue,
- creditNote: 0,
- priceListId: 0,
- batchId: 0,
- unitPrice: j.unitPrice,
- invoiceallocations: null,
- exciseInvoiceItem: null,
- accountId: j.accountId,
- accountName: j.accountName,
- walletId: 0,
- Adjustment: 0,
- IsFoc: j.IsFoc,
- TariffNo: "",
- exciseAmount: 0,
- discountName: "",
- discountId: 0,
- refNo: "",
- DiscountGroupId: 0,
- DiscountGroupName: '',
- RefInvoiceItemId: 0,
- MrpId: j.MrpId,
- taxAdjustment: 0,
- assesableAdjustment: 0,
- inventoryTypeId: 0,
- dcItemId: 0,
- TotalRowAmount: j.TotalRowAmount,
- BatchId: j.BatchId,
- maxQty: j.maxQty,
- TotalDiscount: j.TotalDiscount,
- ParentBOMItemId: j.ParentBOMItemId,
- IsSpecialPrice: j.IsSpecialPrice
- };
- if (j.dcItemId != 0)
- InvoiceItem.Instance().dcItemIds.push(j.dcItemId);
- InvoiceItem.Instance().addDataRow(emptyRow, true);
- if (items.length - 1 == j1) {
- if (invoiceid != 0)
- instance.GetDiscounts();
- instance.ShowOrHideSaveBtn(true);
- }
- }
- for (let k1 = 0; k1 < Invoiceitem.length; k1++) {
- let k = Invoiceitem[k1];
- if (k.dcItemId != 0)
- InvoiceItem.Instance().dcItemIds.push(k.dcItemId);
- InvoiceItem.Instance().addDataRow(k, false);
- if (Invoiceitem.length - 1 == k1) {
- if (invoiceid != 0)
- instance.GetDiscounts();
- instance.ShowOrHideSaveBtn(true);
- }
- }
- $("#totalinvoiceqty").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalQty, 2));
- });
- }
- }
- getwalletinvoiceditems() {
- var JournalAlloc = new Array();
- $("#tbl_WalletItems").find(".walletitem-addedrow").each(function () {
- JournalAlloc.push({
- journalAllocId: $(this).find(".journalAllocId").val(),
- RefAllocId: $(this).find(".refAllocId").val(),
- JournalId: $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_Invoiceid").val(),
- AdjustedAmount: Number($(this).find(".hfAdjustedAmount").val()),
- TotalAmount: Number($(this).find(".totalAmount").text()),
- IsWallet: true,
- CurrentAmount: Number($(this).find(".currentAmount").val()),
- });
- });
- return JournalAlloc;
- }
- ShowOrHideSaveBtn(IsShow) {
- let instance = this;
- if (!IsShow) {
- instance.navigationHelper.showLoading();
- $("#btnDynamicSave").prop("disabled", true);
- }
- else {
- instance.navigationHelper.hideLoading();
- $("#btnDynamicSave").prop("disabled", false);
- }
- }
- getInvoiceItems() {
- var invItemList = new Array();
- $(".InvoiceItems").find(".item-row").each(function () {
- if (!$(this).hasClass('SplitItem')) {
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- let ParentBOMItemId = $(this).find(".hf_ParentBOMItemId").val();
- if (ParentBOMItemId == null)
- ParentBOMItemId = 0;
- var invoicetermid = $(this).find(".invoiceTermId").val();
- var invoiceitemid = Number($(this).find(".selectedInvoiceItemId").val());
- var refInvoiceitemid = Number($(this).find(".refInvoiceItemId").val());
- var orderItemId = Number($(this).find(".orderItemId").val());
- var ItemId = Number($(this).find(".selectedItemId").val());
- var packs = 0;
- var prodprice = Number($(this).find(".prodPrice").val());
- var quantity = Number($(this).find(".prodQuantity").val());
- var prodpricelist = 0;
- var description = $(this).find(".prodDesc").val();
- var MrpId = Number($(this).find(".hfMrpId").val());
- var discountAmount = 0;
- var discountPercent = 0;
- var rowTotal = Number($(this).find(".prodTotalPrice").text());
- if (($(".hdn_invoicetypeid").val() == "2") && invoiceitemid != 0) {
- rowTotal = Number($(this).find(".hfRowTotalwithAdjustment").val());
- }
- var Quantity = Number($(this).find(".prodQuantity").val());
- var ConversionQuantity = Quantity;
- let SelectedUnitId = 0;
- let DefaultSize = 0;
- let AlternateSize = 0;
- if ($(this).find(".hf_IsMultipleUOM").val() == "true" && $(".hdn_invoicetypeid").val() == "1") {
- let ItemId = Number($(this).find(".selectedItemId").val());
- SelectedUnitId = Number($(this).find(".ddl_MultipleUOMs").val());
- if (SelectedUnitId != 0 && SelectedUnitId != 1) {
- var Uom = InvoiceItem.Instance().UOMs.find(x => x.ItemId == ItemId);
- var SelectedUOM = Uom.MultipleUOMs.find(x => x.SchemaDetailId == SelectedUnitId);
- DefaultSize = SelectedUOM.DefaultSize;
- AlternateSize = SelectedUOM.AlternateSize;
- ConversionQuantity = Number(Quantity) * (AlternateSize / DefaultSize);
- }
- }
- else if ($(this).find(".hf_IsManualUOM").val() == "true" && $(".hdn_invoicetypeid").val() == "1") {
- SelectedUnitId = Number($(this).find(".hf_AlternateUnitId").val());
- ConversionQuantity = Number($(this).find(".hf_ConversionQuantity").val());
- }
- if (($(this).find(".btnInvoice_DiscType option:selected").text().trim() == 'Val' || $(this).find(".btnInvoice_DiscType option:selected").text().trim() == 'Mul') && $(this).find('.inv_txtaddldiscount').val() != '' && $(this).find('.inv_txtaddldiscount').val() != undefined) {
- discountAmount = Number($(this).find('.inv_txtaddldiscount').val());
- }
- else if ($(this).find(".btnInvoice_DiscType option:selected").text().trim() == '%' && $(this).find('.inv_txtaddldiscount').val() != '' && $(this).find('.inv_txtaddldiscount').val() != undefined) {
- discountPercent = Number($(this).find('.inv_txtaddldiscount').val());
- }
- var TaxGroupId = Number($(this).find(".hfProdTax").val());
- let accountid = Number($(this).find(".txt_Account").val());
- let foc = ($(this).find(".hf_IsFoc").val() == 'true');
- invItemList.push({
- InvoiceItemId: invoiceitemid,
- OrderItemId: orderItemId,
- ItemId: ItemId,
- Packs: packs,
- TaxGroupId: TaxGroupId,
- Description: description,
- PriceListId: prodpricelist,
- UnitPrice: prodprice,
- DiscountAmount: discountAmount,
- DiscountPercent: discountPercent,
- IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()),
- AccountId: accountid,
- Adjustment: Number($(this).find(".hfRowTotalAdjustment").val()),
- TotalAmount: Number(rowTotal),
- Quantity: Number(Quantity),
- ExciseAmount: 0,
- RefNo: $(this).find(".refNo").val(),
- DiscountGroupId: Number($(this).find("#hfProdDiscountGroupId").val()),
- RefInvoiceItemId: Number(refInvoiceitemid),
- MrpId: Number(MrpId),
- DcItemId: Number($(this).find(".dcItemId").val()),
- BatchId: 0,
- IsFoc: foc,
- OfferItemId: ($(this).find(".hfOfferedItemId").val() == null || $(this).find(".hfOfferedItemId").val() == undefined) ? 0 : Number($(this).find(".hfOfferedItemId").val()),
- AlternateUnitId: SelectedUnitId,
- DefaultSize: DefaultSize,
- ParentBOMItemId: Number(ParentBOMItemId),
- ConversionQuantity: Number(ConversionQuantity)
- });
- }
- }
- });
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $('#hfInv_IsRetun').val() == "1") {
- InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId = 0;
- }
- invItemList.push({
- InvoiceItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId),
- OrderItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].orderItemId),
- ItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId),
- TaxGroupId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].taxGroupId),
- Description: InvoiceItem.Instance().SplitedInvoiceItemList[i].description,
- PriceListId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].priceListId),
- UnitPrice: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice),
- DiscountAmount: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountValue),
- DiscountPercent: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountPercent),
- IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()),
- AccountId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].accountId),
- Adjustment: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].Adjustment),
- TotalAmount: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].TotalAmount),
- Quantity: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity),
- ExciseAmount: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].exciseAmount),
- RefNo: InvoiceItem.Instance().SplitedInvoiceItemList[i].refNo,
- DiscountGroupId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].DiscountGroupId),
- RefInvoiceItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].RefInvoiceItemId),
- MrpId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].MrpId) == -1 ? 0 : Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].MrpId),
- DcItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].dcItemId),
- BatchId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].BatchId),
- IsFoc: false,
- OfferItemId: 0,
- });
- }
- $(".InvoiceItems").find(".discount-row").each(function () {
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- var rowname = "discount-row";
- var appliedOnWhole = false;
- var totalElement = $(this).find(".netdiscount-row-total");
- if (totalElement.length != 0) {
- appliedOnWhole = true;
- rowname = "netdiscount-row";
- }
- var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val();
- var ItemId = $(this).find(".hfSelectedChargeId").val();
- var chargeTypeId = $(this).find(".hdnChargeTypeId").val();
- var ledgerId = $(this).find(".hdnChargeLedgerId").val();
- var percent = $(this).find(".percentage").val();
- var value = $(this).find(".fixedvalue").val();
- var desc = $(this).find(".discountDesc").val();
- var totalamount = $(this).find("." + rowname + "-total").html();
- invItemList.push({
- InvoiceItemId: $(this).find(".selectedInvoiceItemId").val() == undefined ? 0 : Number($(this).find(".selectedInvoiceItemId").val()),
- OrderItemId: 0,
- ItemId: Number(ItemId),
- Packs: 0,
- TaxGroupId: Number($(this).find(".hfProdTax").val()),
- Description: $(this).find(".discountDesc").val(),
- PriceListId: 0,
- UnitPrice: 0,
- DiscountAmount: Number($(this).find(".fixedvalue").val()),
- DiscountPercent: Number($(this).find(".percentage").val()),
- IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()),
- AccountId: Number($(this).find(".hf_Account").val()),
- RowDiscount: Number(totalamount),
- SendToWallet: 0,
- Adjustment: 0,
- TotalAmount: 0,
- Quantity: 1,
- ExciseAmount: 0,
- RefNo: "",
- DiscountGroupId: 0,
- RefInvoiceItemId: 0,
- MrpId: 0,
- BatchId: 0,
- DcItemId: Number($(this).find(".dcItemId").val()),
- IsFoc: false,
- OfferItemId: 0,
- });
- }
- });
- $(".netdiscount-row").each(function () {
- var rowname = "";
- var appliedOnWhole = false;
- var totalElement = $(this).find(".netdiscount-row-total");
- if (totalElement.length != 0) {
- appliedOnWhole = true;
- rowname = "netdiscount-row";
- }
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val();
- var ItemId = $(this).find(".hfSelectedChargeId").val();
- var chargeTypeId = $(this).find(".hdnChargeTypeId").val();
- var ledgerId = $(this).find(".hdnChargeLedgerId").val();
- var percent = $(this).find(".percentage").val();
- var value = $(this).find(".fixedvalue").val();
- var desc = $(this).find(".discountDesc").val();
- var totalamount = $(this).find("." + rowname + "-total").html();
- invItemList.push({
- InvoiceItemId: $(this).find(".selectedInvoiceItemId").val() == undefined ? 0 : Number($(this).find(".selectedInvoiceItemId").val()),
- OrderItemId: 0,
- ItemId: Number(ItemId),
- Packs: 0,
- TaxGroupId: Number($(this).find(".hfProdTax").val()),
- Description: $(this).find(".discountDesc").val(),
- PriceListId: 0,
- UnitPrice: 0,
- DiscountAmount: Number($(this).find(".fixedvalue").val()),
- DiscountPercent: Number($(this).find(".percentage").val()),
- IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()),
- AccountId: Number($(this).find(".hf_Account").val()),
- RowDiscount: Number(totalamount),
- SendToWallet: 0,
- Adjustment: 0,
- TotalAmount: 0,
- Quantity: 1,
- ExciseAmount: 0,
- RefNo: "",
- DiscountGroupId: 0,
- RefInvoiceItemId: 0,
- MrpId: 0,
- BatchId: 0,
- DcItemId: Number($(this).find(".dcItemId").val()),
- IsFoc: false,
- OfferItemId: 0,
- });
- }
- });
- $(".expense-row").each(function () {
- var rowname = "";
- var appliedOnWhole = false;
- var totalElement = $(this).find(".expense-row-total");
- if (totalElement.length != 0) {
- appliedOnWhole = true;
- rowname = "expense-row";
- }
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val();
- var ItemId = $(this).find(".hfSelectedChargeId").val();
- var chargeTypeId = $(this).find(".hdnChargeTypeId").val();
- var ledgerId = $(this).find(".hdnChargeLedgerId").val();
- var percent = $(this).find(".percentage").val();
- var value = $(this).find(".fixedvalue").val();
- var desc = $(this).find(".discountDesc").val();
- var totalamount = $(this).find("." + rowname + "-total").html();
- if (Number($(this).find(".expfixedvalue").val()) != 0 || Number($(this).find(".exppercentage").val()) != 0) {
- invItemList.push({
- InvoiceItemId: $(this).find(".selectedInvoiceItemId").val() == undefined ? 0 : Number($(this).find(".selectedInvoiceItemId").val()),
- OrderItemId: 0,
- ItemId: Number(ItemId),
- Packs: 0,
- TaxGroupId: Number($(this).find(".hfProdTax").val()),
- Description: $(this).find(".expenseDesc").val(),
- PriceListId: 0,
- UnitPrice: 0,
- DiscountAmount: -Number($(this).find(".expfixedvalue").val()),
- DiscountPercent: -Number($(this).find(".exppercentage").val()),
- IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()),
- AccountId: Number($(this).find(".hf_Account").val()),
- RowDiscount: -Number(totalamount),
- SendToWallet: 0,
- Adjustment: 0,
- TotalAmount: 0,
- Quantity: 1,
- ExciseAmount: 0,
- RefNo: "",
- DiscountGroupId: 0,
- RefInvoiceItemId: 0,
- MrpId: 0,
- BatchId: 0,
- DcItemId: Number($(this).find(".dcItemId").val()),
- IsFoc: false,
- OfferItemId: 0,
- });
- }
- }
- });
- return invItemList;
- }
- getCharges() {
- var ChargeList = new Array();
- var chargeIndex = 0;
- InvoiceItem.Instance().update_discount_total();
- InvoiceItem.Instance().update_expense_total();
- $(".discount-row,.netdiscount-row").each(function () {
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- var rowname = "discount-row";
- var appliedOnWhole = false;
- var totalElement = $(this).find(".netdiscount-row-total");
- if (totalElement.length != 0) {
- appliedOnWhole = true;
- rowname = "netdiscount-row";
- }
- if ($(this).find(".hfSelectedChargeId").val() != "" && $(this).find(".hfSelectedChargeId").val() != "0") {
- var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val();
- chargeIndex += 1;
- var ChargeId = $(this).find(".hfSelectedChargeId").val();
- var chargeTypeId = $(this).find(".hdnChargeTypeId").val();
- var ledgerId = $(this).find(".hf_Account").val();
- var percent = $(this).find(".percentage").val();
- var value = $(this).find(".fixedvalue").val();
- var desc = $(this).find(".discountDesc").val();
- var totalamount = $(this).find("." + rowname + "-total").html();
- ChargeList.push({
- InvoiceChargeId: Number(invoicechargeid),
- ChargeId: Number(ChargeId),
- ChargeTypeId: Number(chargeTypeId),
- ChargeIndex: chargeIndex,
- Percentage: Number(percent),
- FixedAmount: Number(value),
- ApplyWhole: appliedOnWhole,
- Description: desc,
- TotalAmount: Number(totalamount),
- LedgerId: Number(ledgerId),
- TaxGroupId: Number($(this).find(".hfProdTax").val())
- });
- }
- }
- });
- $(".expense-row").each(function () {
- if ($(this).find(".selectedItemId").val() != undefined) {
- if ($(this).find(".hfSelectedChargeId").val() != "" && $(this).find(".hfSelectedChargeId").val() != "0") {
- var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val();
- let ChargeId = $(this).find(".hfSelectedChargeId").val();
- var chargeTypeId = $(this).find(".hdnChargeTypeId").val();
- var percent = $(this).find(".exppercentage").val();
- var value = $(this).find(".expfixedvalue").val();
- var desc = $(this).find(".expenseDesc").val();
- var totalamount = $(this).find(".expense-row-total").html();
- var ledgerId = $(this).find(".hf_Account").val();
- if (Number(value) != 0 || Number(percent)) {
- ChargeList.push({
- InvoiceChargeId: Number(invoicechargeid),
- ChargeId: Number(ChargeId),
- ChargeTypeId: Number(chargeTypeId),
- Percentage: Number(percent),
- FixedAmount: Number(value),
- ApplyWhole: true,
- Description: desc,
- TotalAmount: Number(totalamount),
- LedgerId: Number(ledgerId),
- TaxGroupId: Number($(this).find(".hfProdTax").val())
- });
- }
- }
- }
- });
- return ChargeList;
- }
- getobj() {
- var item = Number($(".selectedItemId").val());
- var inventorytypeid = 0;
- var AdjustmentAccountId = 0;
- var isqtyavail = true;
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () {
- Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItem(item).then(function (response) {
- inventorytypeid = response.result.InventoryTypeId;
- $(".InvoiceItems").find(".remove_item").remove();
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- if ($("#chk_tcsapplied").prop("checked") == true && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && InvoiceItem.Instance().EnableTenantTcs == false) {
- MessageHelper.Instance().showError("Please Submit TCS Declaration", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- $(".InvoiceItems").append("<div class='item-row added-row InvoiceitemRow-0'></div>");
- return false;
- }
- var CompanyName = $(".txtAutoComplete_orgcontactid").text();
- if (CompanyName == "") {
- $(".hfAutoCompleteId_orgcontactid").val(0);
- }
- var Adjustment = $('#txt_Adjustment').val();
- if ($('#chk_AutoAdjustment').is(':checked')) {
- if ($('#hf_AdjustmentAccountId').val() == 0) {
- MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- InvoiceItem.Instance().TotalAdjustment();
- Adjustment = $('#txt_Adjustment').val();
- AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val());
- }
- });
- });
- if ($('#chk_AutoAdjustment').is(':checked')) {
- if ($('#hf_AdjustmentAccountId').val() == 0) {
- MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- else
- AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val());
- }
- let isemptyrow = false;
- let rownotexist = true;
- let itemarray = [];
- let emptysplitrow = false;
- let itemname = "";
- var IsUnitPriceZero = false;
- $(".InvoiceItems").find(".item-addedrow").each(function () {
- rownotexist = false;
- if (!$(this).hasClass('SplitItem')) {
- if ($(this).find(".selectedItemId").val() == undefined || $(this).find(".selectedItemId").val() == 0) {
- isemptyrow = true;
- }
- if ($(this).find(".hfProdTax").val() == "0" || $(this).find(".hf_Account").val() == "0") {
- itemarray.push($(this));
- }
- if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && (InvoiceItem.Instance().AutoDc == true || InvoiceItem.Instance().OrderSettingId == 2)) {
- inventorytypeid = Number($(this).find("#inventorytypeid").val());
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- if ((Number($(this).find('.prodQuantity').val()) > Number($(this).find('.prodAvail').text())) && $(".hdn_invoiceid").val() == "0" && inventorytypeid != 2) {
- isqtyavail = false;
- }
- else {
- let Qty = Number($(this).find('.prodQuantity').val());
- let AvQty = Number($(this).find('.prodAvail').text()) + Number($(this).find('.Qty').val());
- if (Qty > AvQty && inventorytypeid != 2)
- isqtyavail = false;
- }
- }
- }
- }
- else {
- if (InvoiceItem.Instance().SplitedInvoiceItemList.find(x => x.itemId == Number($(this).find(".selectedItemId").val()))) {
- }
- else {
- emptysplitrow = true;
- itemname = $(this).find(".prodName").text();
- }
- }
- var UnitPrice = Number($(this).find(".prodPrice").val());
- if (UnitPrice == 0 && $(this).find(".hf_IsBOM").val() == "false" && $(this).find(".hf_IsFoc").val() == "false") {
- IsUnitPriceZero = true;
- }
- });
- if (!isqtyavail) {
- MessageHelper.Instance().showError("Please check available quantity", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- if (isemptyrow) {
- MessageHelper.Instance().showError("Please Select Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- if (rownotexist) {
- MessageHelper.Instance().showError("Please Add Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- if (emptysplitrow) {
- MessageHelper.Instance().showError("Please Select Mrp/Batch for the Item: " + itemname, $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- let couponitemrow = false;
- $(".addednetdiscount-row").each(function () {
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- if (($(this).find(".percentage").val() == "0" || $(this).find(".percentage").val() == "") && ($(this).find(".fixedvalue").val() == 0 || $(this).find(".fixedvalue").val() == ""))
- isemptyrow = true;
- }
- if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined)
- couponitemrow = true;
- });
- if (isemptyrow) {
- MessageHelper.Instance().showError("Please enter percentage or value for coupon item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- if (IsUnitPriceZero) {
- MessageHelper.Instance().showError("Item UnitPrice should not be zero.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- if (couponitemrow) {
- MessageHelper.Instance().showError("Please Select Coupon Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- var wallets = InvoiceItem.Instance().getwalletinvoiceditems();
- var invItems = InvoiceItem.Instance().getInvoiceItems();
- if (invItems.length == 0) {
- MessageHelper.Instance().showError("You Should Add atleast One Item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- else {
- var qtyresult = invItems.find(x => x.AccountId == 0) ? true : false;
- if (qtyresult == true) {
- for (var i = 0; i < itemarray.length; i++) {
- itemarray[i].find(".div_MoreDetails").removeClass("hidden");
- }
- MessageHelper.Instance().showError("Account Not Configured for the item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- var qty = invItems.find(x => x.Quantity == 0) ? true : false;
- if (qty == true) {
- MessageHelper.Instance().showError("Item quantity should not be zero.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- var TaxGroup = invItems.find(x => x.TaxGroupId == 0) ? true : false;
- if (TaxGroup == true) {
- for (var i = 0; i < itemarray.length; i++) {
- itemarray[i].find(".div_MoreDetails").removeClass("hidden");
- }
- MessageHelper.Instance().showError("TaxGroup Not Configured for the item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- }
- var billingAddressId = $(".hfAutoCompleteId_billtoaddressid").val();
- if (billingAddressId == null)
- billingAddressId = $("#hfId_billtoaddressid").val();
- var invoiceid = $(".hdn_invoiceid").val();
- let refInvoiceId = 0;
- if ($(".hdn_refinvoiceid").val() != undefined && Number($(".hdn_refinvoiceid").val()) != 0)
- refInvoiceId = Number($(".hdn_refinvoiceid").val());
- if (invoiceid == undefined)
- invoiceid = 0;
- if (($(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "3") && $("#hf_AppSettingName").val() == "Create Return") {
- invoiceid = 0;
- if (refInvoiceId == 0) {
- refInvoiceId = Number($(".hdn_invoiceid").val());
- $(".hdn_refinvoiceid").val($(".hdn_invoiceid").val());
- }
- $(".hdn_invoiceid").val("0");
- $(".hdn_journalno").val("0");
- }
- let orgcontactid = $(".txtAutoComplete_orgcontactid").val();
- var dcid = InvoiceItem.Instance().dcid;
- if (invoiceid == 0 && ($(".hdn_invoicetypeid").val() == '3' || $(".hdn_invoicetypeid").val() == '4' || $(".hdn_invoicetypeid").val() == '7' || $(".hdn_invoicetypeid").val() == '6')) {
- dcid = 0;
- }
- var orderid = InvoiceItem.Instance().orderid;
- if (orderid == undefined || orderid == 0) {
- orderid = 0;
- }
- var ClaimId = InvoiceItem.Instance().ClaimId;
- if (ClaimId == undefined || ClaimId == 0) {
- ClaimId = 0;
- }
- else
- orderid = ClaimId;
- var branchid = 0;
- $(".txt_RefNo").val() == "null" ? $(".txt_RefNo").val("") : $(".txt_refno").val();
- var description = $(".divCustomProperties_systemnotes").find("textarea").val();
- if ($('.txt_tcsadjustment').val() == "")
- $('.txt_tcsadjustment').val(0);
- if (Number($(".nettotal").html()) < 0) {
- MessageHelper.Instance().showError("Invoice value should not be less than 0", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- var InvoiceObject = {
- TotalAmount: Number($(".nettotal").html()),
- InvoiceItems: invItems,
- InvoiceCharges: InvoiceItem.Instance().getCharges(),
- AutoAdjustment: Boolean($('#chk_AutoAdjustment').is(':checked')),
- AutoDc: InvoiceItem.Instance().AutoDc,
- InvItemTaxAdjustments: InvoiceItem.Instance().invItemTaxAdjustmentList,
- JournalAlloc: wallets,
- AdjustmentAccountId: Number($("#txt_AdjustmentAccountName").val()),
- InvoiceId: Number(invoiceid),
- RefInvoiceId: Number(refInvoiceId),
- OrgContactId: Number(orgcontactid),
- DeletedInvoiceId: InvoiceItem.Instance().deleted_invoiceItems,
- IsOfferChargeApplied: InvoiceItem.Instance().isOfferChargeApplied,
- };
- return InvoiceObject;
- }
- saveInvoice() {
- $(".InvoiceItems").find(".remove_item").remove();
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- var inventorytypeid = 0;
- var AdjustmentAccountId = 0;
- var item = Number($(".selectedItemId").val());
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () {
- Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItem(item).then(function (response) {
- inventorytypeid = response.result.InventoryTypeId;
- if ($("#chk_tcsapplied").prop("checked") == true && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && InvoiceItem.Instance().EnableTenantTcs == false) {
- MessageHelper.Instance().showError("Please Submit TCS Declaration", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- $(".InvoiceItems").append("<div class='item-row added-row InvoiceitemRow-0'></div>");
- return false;
- }
- var CompanyName = $(".txtAutoComplete_orgcontactid").text();
- if (CompanyName == "") {
- $(".hfAutoCompleteId_orgcontactid").val(0);
- }
- if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && (InvoiceItem.Instance().AutoDc == true || InvoiceItem.Instance().OrderSettingId == 2)) {
- var isqtyavail = true;
- $(".InvoiceItems").find(".item-addedrow").each(function () {
- if (!$(this).hasClass('SplitItem')) {
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- if (Number($(this).find('.prodQuantity').val()) > Number($(this).find('.prodAvail').text()) && inventorytypeid != 2) {
- isqtyavail = false;
- }
- }
- }
- });
- if (!isqtyavail) {
- MessageHelper.Instance().showError("Please check available quantity", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- }
- });
- });
- var Adjustment = $('#txt_Adjustment').val();
- var AdjustmentAccountId = 0;
- if ($('#chk_AutoAdjustment').is(':checked')) {
- if ($('#hf_AdjustmentAccountId').val() == 0) {
- MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- InvoiceItem.Instance().TotalAdjustment();
- Adjustment = $('#txt_Adjustment').val();
- AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val());
- }
- if (Number($('#txt_Adjustment').val()) != 0) {
- if ($('#hf_AdjustmentAccountId').val() == 0) {
- MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- else
- AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val());
- }
- let isemptyrow = false;
- let rownotexist = true;
- let itemarray = [];
- let emptysplitrow = false;
- let itemname = "";
- $(".InvoiceItems").find(".item-addedrow").each(function () {
- rownotexist = false;
- if (!$(this).hasClass('SplitItem')) {
- if ($(this).find(".selectedItemId").val() == undefined || $(this).find(".selectedItemId").val() == 0) {
- isemptyrow = true;
- }
- if ($(this).find(".hfProdTax").val() == "0" || $(this).find(".hf_Account").val() == "0") {
- itemarray.push($(this));
- }
- }
- else {
- if (InvoiceItem.Instance().SplitedInvoiceItemList.find(x => x.itemId == Number($(this).find(".selectedItemId").val()))) {
- }
- else {
- emptysplitrow = true;
- itemname = $(this).find(".prodName").text();
- }
- }
- });
- if (isemptyrow) {
- MessageHelper.Instance().showError("Please Select Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- if (rownotexist) {
- MessageHelper.Instance().showError("Please Add Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- if (emptysplitrow) {
- MessageHelper.Instance().showError("Please Select Mrp/Batch for the Item: " + itemname, $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- let couponitemrow = false;
- $(".addednetdiscount-row").each(function () {
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- if (($(this).find(".percentage").val() == "0" || $(this).find(".percentage").val() == "") && ($(this).find(".fixedvalue").val() == 0 || $(this).find(".fixedvalue").val() == ""))
- isemptyrow = true;
- }
- if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined)
- couponitemrow = true;
- });
- if (isemptyrow) {
- MessageHelper.Instance().showError("Please enter percentage or value for coupon item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- if (couponitemrow) {
- MessageHelper.Instance().showError("Please Select Coupon Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- var wallets = InvoiceItem.Instance().getwalletinvoiceditems();
- var invItems = InvoiceItem.Instance().getInvoiceItems();
- if (invItems.length == 0) {
- MessageHelper.Instance().showError("You Should Add atleast One Item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- else {
- var qtyresult = invItems.find(x => x.AccountId == 0) ? true : false;
- if (qtyresult == true) {
- for (var i = 0; i < itemarray.length; i++) {
- itemarray[i].find(".div_MoreDetails").removeClass("hidden");
- }
- MessageHelper.Instance().showError("Account Not Configured for the item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- var qty = invItems.find(x => x.Quantity == 0) ? true : false;
- if (qty == true) {
- MessageHelper.Instance().showError("Item quantity should not be zero.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- var TaxGroup = invItems.find(x => x.TaxGroupId == 0) ? true : false;
- if (TaxGroup == true) {
- for (var i = 0; i < itemarray.length; i++) {
- itemarray[i].find(".div_MoreDetails").removeClass("hidden");
- }
- MessageHelper.Instance().showError("TaxGroup Not Configured for the item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- }
- var PaymentTermName = $(".txtAutoComplete_paymentiermid").text();
- var billingAddressId = $(".hfAutoCompleteId_billtoaddressid").val();
- if (billingAddressId == null)
- billingAddressId = $("#hfId_billtoaddressid").val();
- var invoiceid = $(".hdn_invoiceid").val();
- let refInvoiceId = 0;
- if (invoiceid == undefined)
- invoiceid = 0;
- if (($(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "3") && $("#hf_AppSettingName").val() == "Create Return") {
- invoiceid = 0;
- refInvoiceId = Number($(".hdn_invoiceid").val());
- $(".hdn_refinvoiceid").val($(".hdn_invoiceid").val());
- $(".hdn_invoiceid").val("0");
- $(".hdn_journalno").val("0");
- }
- let orgcontactid = $(".txtAutoComplete_orgcontactid").val();
- var dcid = InvoiceItem.Instance().dcid;
- if (invoiceid == 0 && ($(".hdn_invoicetypeid").val() == '3' || $(".hdn_invoicetypeid").val() == '4' || $(".hdn_invoicetypeid").val() == '7' || $(".hdn_invoicetypeid").val() == '6')) {
- dcid = 0;
- }
- var orderid = InvoiceItem.Instance().orderid;
- if (orderid == undefined || orderid == 0) {
- orderid = 0;
- }
- var ClaimId = InvoiceItem.Instance().ClaimId;
- if (ClaimId == undefined || ClaimId == 0) {
- ClaimId = 0;
- }
- else
- orderid = ClaimId;
- var branchid = 0;
- if ((ClaimId != 0 || orderid != 0) && InvoiceItem.Instance().dcid == 0)
- for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
- if (obj.Key === "hf_" + $("#hfLayout_InstalledPageId").val() + "_branchid")
- branchid = InvoiceItem.Instance().orderid = Number(obj.Value);
- }
- else
- branchid = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("branchid"));
- $(".txt_RefNo").val() == "null" ? $(".txt_RefNo").val("") : $(".txt_refno").val();
- var description = $(".divCustomProperties_systemnotes").find("textarea").val();
- if ($('.txt_tcsadjustment').val() == "")
- $('.txt_tcsadjustment').val(0);
- var InvoiceObject = {
- PaymentTermName: PaymentTermName,
- BranchId: branchid,
- TotalAmount: Number($(".nettotal").html()),
- InvoiceItems: invItems,
- InvoiceCharges: InvoiceItem.Instance().getCharges(),
- AutoAdjustment: Boolean($('#chk_AutoAdjustment').is(':checked')),
- AutoDc: InvoiceItem.Instance().AutoDc,
- InvItemTaxAdjustments: InvoiceItem.Instance().invItemTaxAdjustmentList,
- JournalAlloc: wallets,
- AdjustmentAccountId: Number($("#txt_AdjustmentAccountName").val()),
- InvoiceId: Number(invoiceid),
- RefInvoiceId: Number(refInvoiceId),
- OrgContactid: orgcontactid,
- DeletedInvoiceId: InvoiceItem.Instance().deleted_invoiceItems,
- IsOfferChargeApplied: InvoiceItem.Instance().isOfferChargeApplied,
- };
- return InvoiceObject;
- }
- addRow() {
- let isemptyrow = false;
- $(".InvoiceItems").find(".item-addedrow").each(function () {
- if (!$(this).hasClass('SplitItem')) {
- if ($(this).find(".selectedItemId").val() == undefined || $(this).find(".selectedItemId").val() == 0) {
- isemptyrow = true;
- }
- }
- });
- if (isemptyrow) {
- MessageHelper.Instance().showError("Please Select Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- var emptyRow = {
- orderItemId: 0,
- invoiceItemId: 0,
- itemName: "",
- itemId: 0,
- itemSKU: "",
- unitName: "",
- packSize: 0,
- packCount: 0,
- packs: 0,
- quantity: 0,
- availPacks: 0,
- availQty: 0,
- listPrice: 0,
- description: "",
- taxGroupName: "",
- taxGroupId: 0,
- isTaxInclusive: $("#hf_istaxinclusive").val(),
- addlDiscountPercent: 0,
- addlDiscountValue: 0,
- creditNote: 0,
- priceListId: 0,
- batchId: 0,
- unitPrice: 0,
- invoiceallocations: null,
- exciseInvoiceItem: null,
- accountId: 0,
- accountName: "",
- walletId: 0,
- Adjustment: 0,
- IsFoc: false,
- TariffNo: "",
- exciseAmount: 0,
- discountName: "",
- discountId: 0,
- refNo: "",
- DiscountGroupId: 0,
- DiscountGroupName: '',
- RefInvoiceItemId: 0,
- MrpId: 0,
- taxAdjustment: 0,
- assesableAdjustment: 0,
- inventoryTypeId: 0,
- dcItemId: 0,
- TotalRowAmount: 0,
- maxQty: 0,
- OfferItemId: 0
- };
- InvoiceItem.instance.addDataRow(emptyRow, false);
- }
- addDataRow(row, IsSplitItem) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/compact/components/details/details.js", function () {
- });
- this.rowIndex = $(".InvoiceItems").find(".item-addedrow").length + 1;
- var bg = "";
- if (row.packSize == 0)
- row.packSize = 1;
- if (row.packCount == 0)
- row.packCount = 1;
- if (row.quantity == 0)
- row.quantity = row.packCount * row.packs * row.packSize;
- var price = row.unitPrice;
- if (row.unitPrice == 0)
- price = row.listPrice;
- var currenttaxgroupid = 0;
- if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $('#hfInv_IsRetun').val() == "1") {
- row.invoiceallocations = null;
- row.invoiceItemId = 0;
- }
- if ($('#hfInv_IsRetun').val() == "1")
- row.invoiceItemId = 0;
- var zeroBilled = "";
- if (price == 0)
- zeroBilled = "bg-danger";
- var zeroQtyText = "";
- var zeroQtyDiv = "bg-light";
- let invoiceid = $(".hdn_invoiceid").val();
- if (invoiceid == "0") {
- if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && row.itemId != 0 && row.IsFoc == false) {
- if (row.availQty == 0) {
- row.quantity = 0;
- zeroQtyText = "text-danger";
- zeroQtyDiv = "bg-danger";
- }
- else if (row.availQty < row.quantity) {
- row.quantity = row.availQty;
- }
- }
- }
- var readonlyQty = "";
- var ManageInvoice = 2;
- var AutoDc = false;
- var ManageInvoiceTax = 2;
- var readonlyPrice = "";
- var readonlyDisc = "";
- var readonlyTax = "";
- if (ManageInvoice == 1 && AutoDc == false) {
- readonlyQty = "readonly";
- readonlyPrice = "readonly";
- readonlyDisc = "readonly";
- readonlyTax = "disabled";
- }
- if ($('.hdn_invoicetypeid').val() == "1" && ManageInvoiceTax == 1 && AutoDc == false) {
- readonlyTax = "readonly";
- }
- if (row.inventoryTypeId == "2") {
- readonlyQty = "";
- readonlyPrice = "";
- }
- var activeDiscVal = "";
- var activeDiscPercent = "";
- var activeDiscMul = "";
- var activeDiscText = "";
- var discValue = 0;
- if (row.addlDiscountPercent > 0) {
- discValue = row.addlDiscountPercent;
- activeDiscPercent = "active";
- activeDiscText = "%";
- }
- else if (row.addlDiscountValue > 0 && row.DiscountGroupId > 0) {
- discValue = row.addlDiscountValue;
- activeDiscMul = "active";
- activeDiscText = "Mul";
- }
- else {
- discValue = row.addlDiscountValue;
- activeDiscVal = "active";
- activeDiscText = "Val";
- }
- var itemNameClass = "floating-label-form-group";
- if (row.invoiceItemId != 0)
- itemNameClass = "";
- var mt = "";
- if (row.invoiceItemId != 0) {
- mt = "mt-5";
- }
- if (row.orderItemId != 0) {
- mt = "mt-10";
- }
- let AlternateUnitId = row.AlternateUnitId;
- let DefaultSize = row.DefaultSize;
- if (AlternateUnitId == undefined) {
- AlternateUnitId = 0;
- }
- if (row.ParentBOMItemId == null)
- row.ParentBOMItemId = 0;
- if (row.inventoryTypeId != 5 && row.inventoryTypeId != 6 && row.inventoryTypeId != 7) {
- var IsBom = "";
- if (row.IsBoMItem == true && row.IsBoMItem != undefined) {
- IsBom = "hidden";
- }
- var isbomitem = false;
- if (row.ParentBOMItemId != 0)
- isbomitem = true;
- var html = '<div id="div_itemAddedRow_' + this.rowIndex + '" class="item-row item-addedrow ' + bg + '">' +
- '<div class="row mx-0 justify-content-between align-items-end ' + IsBom + ' divItemRow_' + row.itemId + ' ">' +
- '<div class="col-lg-4 col-md-6 my-15 position-relative"> <div class="position-absolute r-0 z-index-1 sales-special-offers"><a class="btn_offer hidden" > <span class="btn btn-outline-primary btn-xs font-10 line-height-12 mb-1 count" > offer </span></a> <a class="btn_specialPrice hidden"><span class="btn btn-outline-blue btn-xs font-10 line-height-12 mb-1 count">SP</span></a></div>' +
- '<div class=" item-name min-padding" style="margin-left:20px;">' +
- '<lable for="lbl_itemname" class="d-md-none">Item Name</lable>' +
- '<input type="hidden" class="rowIndex" value="' + this.rowIndex + '" />' +
- '<input type="hidden" class="orderItemId" value="' + row.orderItemId + '" />' +
- '<input type="hidden" class="dcItemId" value="' + row.dcItemId + '" />' +
- '<input type="hidden" class="selectedInvoiceItemId" value="' + row.invoiceItemId + '" />' +
- '<input type="hidden" class="refInvoiceItemId" value="' + row.RefInvoiceItemId + '" />' +
- '<input type="hidden" class="selectedItemId" id="hf_txtitem_' + this.rowIndex + '" value="' + row.itemId + '" />' +
- '<input type="hidden" id="selectedItemId" value="' + row.itemId + '" />' +
- '<input type="hidden" id="inventorytypeid" value="' + row.itemId + '" />' +
- '<input type="hidden" class="selectedItemName" value="' + row.itemname + '" />' +
- '<input type="hidden" class="hfMrpId" value="' + row.MrpId + '" />' +
- '<input type="hidden" class="offerapplied" value="0" />' +
- '<input type="hidden" class="refNo" value="' + row.refNo + '"/>' +
- '<input type="hidden" class="description" value="' + row.description + '"/>' +
- '<input type="hidden" class="IsExchangeItem" value="' + row.ExchangeItem + '" />' +
- '<input type="hidden" class="maxQty" value="' + row.maxQty + '" />' +
- '<input type="hidden" class="Qty" value="' + row.quantity + '" />' +
- '<input type="hidden" class="hfAccountId" value="' + row.accountId + '"/>' +
- '<input type="hidden" class="hfItemTaxAdjsutmentVal" value="' + row.taxAdjustment + '" />' +
- '<input type="hidden" class="hfItemAssesableAdjustmentVal" value="' + row.assesableAdjustment + '" />' +
- '<input type="hidden" class="hfoldItemId" value="' + row.itemId + '"/>' +
- '<input type="hidden" class="hf_IsFoc" value="' + row.IsFoc + '"/>' +
- '<input type="hidden" class="hf_UnitPrice" value="' + price + '"/>' +
- '<input type="hidden" class="hf_AlternateUnitId" value="' + AlternateUnitId + '"/>' +
- '<input type="hidden" class="hf_AlternateUnitName" value="' + row.AlternateUnitName + '"/>' +
- '<input type="hidden" class="hf_UnitName" value="' + row.unitName + '"/>' +
- '<input type="hidden" class="hf_DefaultSize" value="' + DefaultSize + '"/>' +
- '<input type="hidden" class="hf_IsBOM" value="' + isbomitem + '"/>' +
- '<input type="hidden" class="hf_ParentBOMItemId" value="' + row.ParentBOMItemId + '"/>' +
- '<input type="hidden" class="hf_IsMultipleUOM" value="' + row.IsMultipleUOMs + '"/>' +
- '<input type="hidden" class="hf_IsManualUOM" value="' + row.IsManualUOM + '"/>' +
- '<input type="hidden" class="hf_ConversionQuantity" value="' + row.ConversionQuantity + '"/>' +
- '<input type="hidden" class="hf_IsSpecialPrice" value="' + row.IsSpecialPrice + '"/>' +
- '<input type="hidden" class="hf_AddtionalDiscount" value="0"/>';
- if (row.IsFoc == true) {
- html += '<input type="hidden" class="hfOfferedItemId" value="' + row.OfferItemId + '"/>';
- }
- html += '<div class="item-name-wrap">' +
- '<a class="no-border bg-white delete" href = "javascript:;" title = "Remove row" style = "" > <i class="fa fa-trash-o fa-lg mt-15 mr-2" style="margin-left:-25px;color:red"></i></a>';
- if (row.invoiceItemId != 0) {
- var itemName = row.itemSKU + ' - ' + row.itemName;
- if (row.ExchangeItem)
- itemName = '(Exchange) ' + row.itemSKU + ' - ' + row.itemName;
- html += '<a class="default prodName-link mt-10 ItemName" href="javascript:;">' + itemName + '</a>';
- }
- else {
- var itemName = "";
- if (row.ExchangeItem)
- itemName = '(Exchange) ' + row.itemName;
- else if (row.itemName != "" && row.itemSKU != "") {
- itemName = row.itemSKU + '-' + row.itemName;
- html += '<a class="default prodName-link mt-10 ItemName" href="javascript:;">' + itemName + '</a>';
- }
- else if (row.itemName != "") {
- itemName = row.itemName;
- html += '<a class="default prodName-link mt-10 ItemName" href="javascript:;">' + itemName + '</a>';
- }
- else {
- html += '<select class="form-control prodName" value="" id="txt_item_' + this.rowIndex + '" placeholder=" Select the item to Invoice" style="width:100%;" id="txtItem"></select>';
- }
- }
- html += '</div>' +
- '</div></div>' +
- '<div class="col-lg-2 col-md-6 pr-0 my-15">' +
- '<div class="floating-label-form-group text-center border-left-0">' +
- '<lable for="lbl_qty" class="d-md-none">Qty</lable>' +
- '<input type="text" class="prodQuantity text-center ' + zeroQtyText + ' form-control" placeholder="0.00" inputmode="numeric" value="' + row.quantity + '" ' + readonlyQty + ' />' +
- '</div>' +
- '</div>' +
- '<div class="col-lg-2 col-md-4 div_UnitPrice my-15">' +
- '<div class="floating-label-form-group min-padding text-center pl-15 border-left-0 "><lable for="lbl_unitprice" class="d-md-none">Unit Price</lable>';
- var readonly = "";
- html += '<input type="text" class="prodPrice text-center form-control" placeholder="0.00" inputmode="numeric" value="' + price + '" ' + readonlyPrice + ' />';
- html += '</div></div>' +
- '<div class="col-lg-2 col-md-4 div_SplitInvoiceItem my-15 hidden"><div class="mt-20 text-center"><a href="javascript:;" class="mr-10"><span id="spn_InvoiceItem_' + this.rowIndex + '" class="spn_InvoiceItem" style="text-decoration:underline;">Select</span></a></div></div>' +
- '<div class="col-lg-2 col-md-4 my-15 div_Discount"> ' +
- '<div class="floating-label-form-group text-center">' +
- '<lable for="lbl_disc" class="d-md-none">Disc.</lable>' +
- '<input type="hidden" id="hfProdDiscountGroupId" value="' + row.DiscountGroupId + '" />' +
- '<input type="hidden" id="hfProdDiscountGroupName" value="' + row.DiscountGroupName + '" />' +
- '<input type="hidden" id="hfProdDiscountList" value="" />' +
- '<input type="hidden" id="hfProdDiscountApplyTypes" value="" />' +
- '<div class="input-group">' +
- '<input type="text" id="inv_txtdiscount" placeholder="0.00" class="form-control inv_txtaddldiscount" inputmode="numeric" value="' + discValue + '" ' + readonlyDisc + '>' +
- '<div class="input-group-btn">' +
- '<select class="btnInvoice_DiscType btn_inv_DiscType mt-10 border-blue"><option value="Val">Val</option><option value="%">%</option></select>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '<div class="col-lg-2 col-md-4 my-15">' +
- '<input type="hidden" class="hfDiscountedAmount" value="0" />' +
- '<input type="hidden" class="hfRowTotalAdjustment" value="' + row.Adjustment + '" />' +
- '<input type="hidden" class="hfAssesableAdjustment" value="" />' +
- '<input type="hidden" class="hfTaxAdjustment" value="" />';
- if (($(".hdn_invoicetypeid").val() == "2") && invoiceid != 0) {
- html += '<a href="javascript:;" class=Adjustmentrow><input type="text" class="hfRowTotalwithAdjustment form-control txtRowTotalwithAdjustment text-right" value="0" style="color:#5ba8fb;cursor:pointer" disabled/></a>';
- html += '<a href="javascript:;" class="hidden" onclick="javascript: InvoiceItem.Instance().editInvItemTaxAllocs(' + row.invoiceItemId + ',' + row.taxGroupId + ',' + row.itemId + ',' + row.orderItemId + ')"><input type="text" style="color:#5ba8fb;text-decoration:underline;cursor:pointer" class="hfRowTotal form-control txtRowTotal text-right" value="0" /></a>';
- }
- else {
- html += '<p class="pull-right mt-10 text-center"><lable for="lbl_disc" class="d-md-none mr-1">Total:</lable><strong><input type="hidden" class="hfRowTotal" value="0" /><span class="prodTotalPrice">0.00</span></strong></p>';
- }
- html += '</div>' +
- '</div>' +
- '<div class="row"> <span class="col-sm-4"> <p class="ml-35 text-warning ItemConversion"> </p> </span>' +
- '<span class="col-sm-2 text-center SelectedUOMName pl-50"> </span>' +
- '<span class="col-sm-6 text-right UOMCalc"> </span></div>' +
- '<div class="hidden div_MoreDetails clear mt-5 bg-light">' +
- '<div class="row align-items-center mx-5 pt-10">' +
- '<div class="col-lg-2 col-md-4 my-15">' +
- '<div class="floating-label-form-group Desc">' +
- '<label for="from_lbl_Description" id="lbl_Description">Description</label>' +
- '<input type="text" id="txt_Description" data-isdynamic="false" class="form-control floating-label-control prodDesc" data-placeholder="Enter Description" placeholder="Description" data-label="Description"/>' +
- '</div>' +
- '</div>' +
- '<div class="col-lg-2 col-md-4 my-15 hidden" id="div_MultipleUOMs">' +
- '<div class="floating-label-form-group-with-value">' +
- '<label for="from_lbl_UOM" id="lbl_Output">UOM</label>' +
- '<div class="input-group">' +
- '<select class="form-control type-control value-control dropdown_MultipleUOMs ddl_MultipleUOMs" placeholder = "Select UOM" data - placeholder="Select UOM" data-label="UOM" data-isparent="false"></select>' +
- '</div></div>' +
- '</div>' +
- '<div class="col-lg-2 col-md-4 my-15">' +
- '<div class="floating-label-form-group-with-value">' +
- '<label for="from_lbl_Output" id="lbl_Output">Tax Group<span class="text-danger">*</span></label>' +
- '<div class="input-group">';
- if (row.taxGroupId != 0) {
- html += '<select type="text" data-isdynamic="false" class="form-control text-control ui-autocomplete prodTax ' + readonlyTax + '" value="' + row.taxGroupName + '" data-label="Output" id="txt_prodTax_' + this.rowIndex + '" data-placeholder="Output @ 18%" placeholder="Output" style="width:100%;"></select>' +
- '<input type="hidden" id="hfProdTaxPercent_' + this.rowIndex + '" class="hfProdTaxPercent" value="0" />' +
- '<input type="hidden" id="hfProdTax_' + this.rowIndex + '" class="hfProdTax hidden" value="' + row.taxGroupId + '"/>' +
- '<input type="hidden" class="txtProdTax hidden" value="' + row.taxGroupName + '"/>';
- }
- else {
- html += '<select type="text" data-isdynamic="false" class="form-control text-control select2-hidden-accessible prodTax ' + readonlyTax + '" id="txt_prodTax_' + this.rowIndex + '" data-label="Output" data-placeholder="Output @ 18%" placeholder="Output" style="width:100%;" id="prodTax"></select>' +
- '<input type="hidden" id="hfProdTaxPercent_' + this.rowIndex + '" class="hfProdTaxPercent" value="0" />' +
- '<input type="hidden" id="hfProdTax_' + this.rowIndex + '" class="hfProdTax hidden" value="0"/>' +
- '<input type="hidden" class="txtProdTax hidden" value=""/>';
- }
- html += '</div>' +
- '</div>' +
- '</div>' +
- '<div class="col-lg-3 col-md-4 my-15">' +
- '<div class="floating-label-form-group-with-value">' +
- '<label for="from_lbl_Account" id="lbl_Account">Account<span class="text-danger">*</span></label>';
- if (row.accountId != 0) {
- html += '<select data-isdynamic="false" class="form-control txt_Account ' + readonlyTax + '" data-placeholder="Account Number" placeholder="Account" data-label="Account" value="' + row.accountName + '" id="txt_Account_' + this.rowIndex + '" style="width:100%;" data-required="true"></select>' +
- '<input type="hidden" id="hf_Account_' + this.rowIndex + '" class="hf_Account" value="' + row.accountId + '" />' +
- '<input type="hidden" id="txt_AccountName_' + this.rowIndex + '" class="txt_AccountName" value="' + row.accountName + '"/>';
- }
- else {
- html += '<select data-isdynamic="false" class="form-control text-control select2-hidden-accessible txt_Account ' + readonlyTax + '" data-placeholder="Account Number" placeholder="Account" id="txt_Account_' + this.rowIndex + '" data-label="Account" style="width:100%;"></select>' +
- '<input type="hidden" id="hf_Account_' + this.rowIndex + '" class="hf_Account" value="0" />' +
- '<input type="hidden" id="txt_AccountName_' + this.rowIndex + '" class="txt_AccountName" value=""/>';
- }
- html += '</div>' +
- '</div>' +
- '<div class="col-lg-3 col-auto align-seld-end ml-auto text-right">' +
- '<label for="from_lbl_Avalilability" id="lbl_Avalilability" class="text-dark mb-0 font-weight-bold mr-10">Availability :</label>' +
- '<span class="prodAvail">' + row.availQty + '</span>' +
- '</div>' +
- '</div>' +
- '<div class="row ml-5 mr-5">' +
- '<div class="col-md-2"> </div>' +
- '</div>' +
- '<div class="row">' +
- '<div class="col-md-12">' +
- '<div class="col-md-3 form-group div_Mrp hidden">' +
- '<div class="floating-label-form-group floating-label focus">' +
- '<input type="hidden" class="hf_PriceList" value="' + row.priceListId + '" />' +
- '<label for="from_lbl_MRP" id="lbl_MRP">MRP</label>' +
- '<input type="text" data-isdynamic="false" class="form-control floating-label-control txt_MRP" data-placeholder="53" placeholder="MRP" data-label="MRP" />' +
- '</div>' +
- '</div>' +
- '</div>' +
- '<div class="orderitemlist"></div>' +
- '</div><div class="accountRow"></div>';
- $(".item-row:last").after(html);
- var element = $(".item-addedrow:last");
- if (IsSplitItem == true) {
- element.addClass('SplitItem');
- }
- InvoiceItem.Instance().loadTaxGroupAutoComplete(element);
- if (row.IsMultipleUOMs && $(".hdn_invoicetypeid").val() == "1") {
- let MultipleUOMs = row.MultipleUoms;
- let html = '<option value="0"> -- Select -- </option>';
- for (var i = 0; i < MultipleUOMs.length; i++) {
- html += '<option value="' + MultipleUOMs[i].SchemaDetailId + '">' + MultipleUOMs[i].AlternateUnitName + ' ( ' + MultipleUOMs[i].DefaultSize + ' ' + MultipleUOMs[i].DefaultUnitName + ' ) </option>';
- }
- element.find(".ddl_MultipleUOMs").html(html);
- element.find("#div_MultipleUOMs").removeClass("hidden");
- InvoiceItem.Instance().UOMs.push({
- ItemId: row.itemId,
- MultipleUOMs: MultipleUOMs
- });
- let SelectedUOM = Number(element.find(".hf_AlternateUnitId").val());
- let DefaultSize = Number(element.find(".hf_DefaultSize").val());
- if (SelectedUOM != 0) {
- element.find(".ddl_MultipleUOMs").val(SelectedUOM);
- let Qty = Number(element.find(".prodQuantity").val());
- let NewQty = Qty / DefaultSize;
- element.find(".prodQuantity").val(NewQty);
- }
- }
- var txtTaxGroup = element.find(".prodTax");
- var hfProdTax = element.find(".hfProdTax");
- var hfAccount = element.find(".hf_Account");
- var txtAccount = element.find(".txt_Account");
- hfAccount.val(row.accountId);
- hfProdTax.val(row.taxGroupId);
- txtTaxGroup.append(new Option(row.taxGroupName, row.taxGroupId, true));
- txtAccount.append(new Option(row.accountName, row.accountId, true));
- InvoiceItem.instance.itemsAutoComplete(element);
- InvoiceItem.instance.itemChange(element, element.find(".prodName").val(), element.find(".selectedItemId"));
- $('.inv_txtaddldiscount').keypress(function (event) {
- if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
- if (element.find(".selectedItemId").val() == "0") {
- Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Please Select Item");
- element.find('.inv_txtaddldiscount').val(0);
- }
- }
- else {
- event.preventDefault();
- }
- }).on('paste', function (event) {
- var numberRegex = /^\s*[+-]?(\d+|\d*\.\d+|\d+\.\d*)([Ee][+-]?\d+)?\s*$/;
- let val = event.originalEvent["clipboardData"].getData('text');
- if (!numberRegex.test(val)) {
- event.preventDefault();
- return false;
- }
- });
- $('.prodQuantity').keypress(function (event) {
- if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
- if (element.find(".selectedItemId").val() == "0") {
- Unibase.Platform.Forms.Components.FormViewer.Instance().showError(" Please Select Item");
- element.find(".prodQuantity").val(0);
- }
- }
- else {
- event.preventDefault();
- }
- }).on('paste', function (event) {
- var numberRegex = /^\s*[+-]?(\d+|\d*\.\d+|\d+\.\d*)([Ee][+-]?\d+)?\s*$/;
- let val = event.originalEvent["clipboardData"].getData('text');
- if (!numberRegex.test(val)) {
- event.preventDefault();
- return false;
- }
- });
- $('.prodPrice').keypress(function (event) {
- if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
- if (element.find(".selectedItemId").val() == "0") {
- Unibase.Platform.Forms.Components.FormViewer.Instance().showError(" Please Select Item");
- element.find('.prodPrice').val(0);
- }
- }
- else {
- event.preventDefault();
- }
- }).on('paste', function (event) {
- var numberRegex = /^\s*[+-]?(\d+|\d*\.\d+|\d+\.\d*)([Ee][+-]?\d+)?\s*$/;
- let val = event.originalEvent["clipboardData"].getData('text');
- if (!numberRegex.test(val)) {
- event.preventDefault();
- return false;
- }
- });
- element.find(".btnInvoice_DiscType option[value='" + activeDiscText + "']").prop("selected", true);
- element.find(".prodPrice,.prodQuantity,.inv_txtaddldiscount").focusin(function () {
- if (element.find($(".prodName")).val() != null || element.find($(".ItemName")).val() != null) {
- $(".div_MoreDetails").addClass("hidden");
- if (!element.parents(".item-row").hasClass('SplitItem'))
- element.find(".div_MoreDetails").removeClass("hidden");
- }
- });
- element.find(".prodName").focusin(function () {
- $(".divMoreDetails").addClass("hidden");
- });
- if (row.description != null && row.description != '' && row.description != 'null') {
- element.find('#txt_Description').val(row.description);
- element.find('#txt_Description').parent(".Desc").addClass("floating-label-form-group-with-value");
- }
- InvoiceItem.Instance().bind(element, row.inventoryTypeId);
- element.find("#inv_txtdiscount").change(function () {
- if (!element.hasClass('SplitItem')) {
- if (element.find(".btnInvoice_DiscType").val() == "%") {
- if (Number(element.find("#inv_txtdiscount").val()) > 100) {
- element.find("#inv_txtdiscount").val("100");
- }
- }
- }
- });
- if (row.TotalRowAmount != 0) {
- if ($(".hdn_invoicetypeid").val() == "2") {
- element.find(".hfRowTotalwithAdjustment").val();
- element.find(".hfRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number(row.TotalRowAmount), 2));
- if (element.hasClass('SplitItem'))
- element.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(row.TotalRowAmount, 2));
- }
- else {
- element.find('.prodTotalPrice').text('');
- element.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(row.TotalRowAmount, 2));
- }
- }
- if (row.TotalDiscount != 0 && row.TotalDiscount != undefined)
- element.find('#inv_txtdiscount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(row.TotalDiscount, 2));
- if (row.invoiceItemId != "0" && ($(".hdn_invoicetypeid").val() == "2")) {
- var x = element.find('.hfRowTotalwithAdjustment');
- element.find('.AdjustmentRow').click(function () {
- InvoiceItem.Instance().editInvItemTaxAllocs(row.invoiceItemId, row.taxGroupId, row.itemId, row.orderItemId, element);
- });
- }
- if (row.IsFoc == true) {
- element.find('.delete').addClass('hidden');
- element.find('.prodQuantity').prop('readonly', 'readonly');
- element.find('.prodPrice').prop('readonly', 'readonly');
- element.find("#inv_txtdiscount").prop('readonly', 'readonly');
- element.find(".btnInvoice_DiscType").prop('disabled', true);
- element.find('.prodQuantity').css('cursor', 'not-allowed');
- element.find('.prodPrice').css('cursor', 'not-allowed');
- element.find("#inv_txtdiscount").css('cursor', 'not-allowed');
- }
- }
- else {
- var element = $(".discount-addedrow:last");
- if (row.inventoryTypeId == 5) {
- element = $(".netdiscount-addedrow:last");
- InvoiceItem.Instance().adddiscountrow(row, row.itemName, row.itemId, true);
- }
- if (row.inventoryTypeId == 6) {
- InvoiceItem.Instance().adddiscountrow(row, row.itemName, row.itemId, false);
- }
- if (row.inventoryTypeId == 7) {
- InvoiceItem.Instance().addExpenseRow(row, row.itemName, row.itemId, true);
- }
- }
- }
- loadTaxGroupAutoComplete(element) {
- var txtTaxGroup = element.find(".prodTax");
- var hfProdTax = element.find(".hfProdTax");
- var hfAccount = element.find(".hf_Account");
- var txtAccount = element.find(".txt_Account");
- var accid = element.find(".hf_Account").val();
- var taxgrpid = element.find(".hfProdTax").val();
- var taxgrptext = element.find(".txtProdTax").val();
- var acctext = element.find(".txt_AccountName").val();
- var applytype = "Sales";
- AutoCompleteHelper.getHelper().Create("#txt_prodTax_" + this.rowIndex, hfProdTax, _appsettings.server_url() + "/apis/v4/bizgaze/transact/tax/taxgroupautocomplete", function (result) {
- if (hfProdTax.val() != '')
- InvoiceItem.Instance().update_tax(element, hfProdTax.val());
- });
- var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/ledgerautocomplete';
- AutoCompleteHelper.getHelper().Create("#txt_Account_" + this.rowIndex, hfAccount, url, function (response) {
- });
- }
- update_total() {
- var totalAmount = 0;
- var totalDiscountAmount = 0;
- var totalNonDiscountedAmount = 0;
- var totalTaxAmount = 0;
- var totalTaxAdjustment = 0;
- var totalAsseableAdjustment = 0;
- var totalQty = 0;
- var totalDiscountPercent = 0;
- var totalDiscountValue = 0;
- var totalAddlDiscountPercent = 0;
- var totalAddlDiscountValue = 0;
- var totalExpensePercent = 0;
- var totalExpenseValue = 0;
- var addexpenserow_total = 0;
- $('.expense-row-total').each(function (i) {
- var expense_row_total = Number($(this).html());
- addexpenserow_total += expense_row_total;
- });
- var ConsumedWalletValue = 0;
- var totalTaxPercent = 0;
- var totalTaxValue = 0;
- var totalCreditNote = 0;
- var adddiscountrow_total = 0;
- var netadddiscountrow_total = ConsumedWalletValue;
- $('.discount-row-total').each(function (i) {
- var discount_row_total = Number($(this).html());
- adddiscountrow_total += discount_row_total;
- });
- $('.netdiscount-row-total').each(function (i) {
- var discount_row_total = Number($(this).html());
- netadddiscountrow_total += discount_row_total;
- });
- var itemdiscount_total = 0;
- var totalLineAmount_total = 0;
- $('.hfRowTotal').each(function (i) {
- var element = $(this).parents(".item-row");
- if (!element.hasClass('SplitItem')) {
- var totalLineAmount = Number($(this).val());
- if (!isNaN(totalLineAmount))
- totalLineAmount_total += Number(totalLineAmount);
- var discountPercent = 0;
- var discountValue = 0;
- var quantity = Number(element.find(".prodQuantity").val());
- var unitPrice = Number(element.find(".prodPrice").val());
- var exciseAmount = Number(element.find(".exciseAmount").val());
- if (isNaN(exciseAmount))
- exciseAmount = 0;
- var nonexciseAmount = totalLineAmount - exciseAmount;
- if (element.find(".btnInvoice_DiscType option:selected").text().trim() == 'Val' && element.find('.inv_txtaddldiscount').val() != '' && element.find('.inv_txtaddldiscount').val() != undefined) {
- discountValue = Number(element.find('.inv_txtaddldiscount').val());
- }
- else if (element.find(".btnInvoice_DiscType option:selected").text().trim() == '%' && element.find('.inv_txtaddldiscount').val() != '' && element.find('.inv_txtaddldiscount').val() != undefined) {
- discountPercent = Number(element.find('.inv_txtaddldiscount').val());
- }
- else if (element.find(".btnInvoice_DiscType option:selected").text().trim() == 'Mul') {
- if (element.find('#hfProdDiscountList').val() != '' || element.find('#hfProdDiscountApplyTypes').val() != '') {
- var discountsArray = element.find('#hfProdDiscountList').val().toString().split(',');
- var applyTypes = element.find('#hfProdDiscountApplyTypes').val().toString().split(',');
- var price = Number(unitPrice) * Number(quantity);
- var currentAmount = Number(unitPrice) * Number(quantity);
- $.each(discountsArray, function (j) {
- var percent = discountsArray[j];
- var applyType = applyTypes[j];
- var discount = 0;
- if (applyType == 'NET' || applyType == '1') {
- discount = Number(price) * Number(percent) / 100;
- currentAmount -= Number(discount);
- }
- else {
- discount = Number(currentAmount) * Number(percent) / 100;
- currentAmount -= Number(discount);
- }
- discountValue += Number(discount);
- });
- element.find('.inv_txtaddldiscount').val(discountValue);
- }
- else {
- discountValue = Number(element.find('.inv_txtaddldiscount').val());
- }
- }
- if (!isNaN(discountPercent))
- totalDiscountPercent += Number(discountPercent);
- if (!isNaN(discountValue))
- totalAddlDiscountValue += Number(discountValue);
- var discountAmount = 0;
- discountAmount = (Number(nonexciseAmount) * Number(discountPercent) / 100)
- + (Number(quantity) * Number(discountValue));
- if ($(".hdn_invoicetypeid").val() == "1" && (element.find(".hf_IsManualUOM").val() == "true" || element.find(".hf_IsMultipleUOM").val() == "true")) {
- let ConversionQuantity = Number(element.find(".hf_ConversionQuantity").val());
- if (ConversionQuantity > 0)
- discountAmount = (Number(nonexciseAmount) * Number(discountPercent) / 100)
- + (Number(ConversionQuantity) * Number(discountValue));
- }
- discountAmount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discountAmount, 2));
- itemdiscount_total += discountAmount;
- var discountedAmount = Number(totalLineAmount) - Number(discountAmount);
- totalDiscountAmount += Number(discountAmount);
- element.find(".hfDiscountedAmount").val(discountAmount);
- let invoiceid = $(".hdn_invoiceid").val();
- if (invoiceid == undefined || invoiceid == "null")
- invoiceid = 0;
- if (($(".hdn_invoicetypeid").val() == "2") && invoiceid != 0) {
- element.find(".txtRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalLineAmount - discountAmount, 2));
- element.find(".prodTotalPrice").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalLineAmount - discountAmount, 2).toString());
- }
- else
- element.find(".prodTotalPrice").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalLineAmount - discountAmount, 2).toString());
- }
- });
- if (InvoiceItem.Instance().SplitedInvoiceItemList.length > 0) {
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- var totalline_Amount = Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity * InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice);
- var discountAmount = 0;
- var nonexciseAmount = totalline_Amount - Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].exciseAmount);
- discountAmount = (Number(nonexciseAmount) * Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountPercent) / 100)
- + (Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity) * Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountValue));
- discountAmount = Number(discountAmount);
- totalLineAmount_total += Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity * InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice);
- itemdiscount_total += discountAmount;
- totalDiscountAmount += discountAmount;
- }
- }
- var overalldiscountpercent = 0;
- if (adddiscountrow_total != 0) {
- overalldiscountpercent = (100 * Number(adddiscountrow_total)) / Number(totalLineAmount_total);
- overalldiscountpercent = Number(overalldiscountpercent);
- $("#hfOverallDiscountPercent").val(overalldiscountpercent);
- }
- var taxAmounts = [];
- $('.hfRowTotal').each(function (i) {
- var element = $(this).parents(".item-row");
- if (!element.hasClass('SplitItem')) {
- var totalLineAmount = Number($(this).val());
- var quantity = element.find(".prodQuantity").val();
- var UnitPrice = element.find(".prodPrice").val();
- var Discount = element.find("#inv_txtdiscount").val();
- var DiscountType = element.find(".btn_inv_DiscType").val();
- discountAmount = Number(element.find(".hfDiscountedAmount").val()) + (Number(totalLineAmount) * Number(overalldiscountpercent) / 100);
- var assesableAmount = totalLineAmount - discountAmount;
- assesableAmount = Number(assesableAmount);
- if (element.find(".hf_IsMultipleUOM").val() == "true" && $(".hdn_invoicetypeid").val() == "1") {
- let ItemId = Number(element.find(".selectedItemId").val());
- let SelectedUnitId = Number(element.find(".hf_AlternateUnitId").val());
- if (SelectedUnitId == 0 || SelectedUnitId == 1) {
- SelectedUnitId = Number(element.find(".ddl_MultipleUOMs").val());
- }
- if (SelectedUnitId != 0 && SelectedUnitId != 1) {
- let Uom = InvoiceItem.Instance().UOMs.find(x => x.ItemId == ItemId);
- let SelectedUOM = Uom.MultipleUOMs.find(x => x.SchemaDetailId == SelectedUnitId);
- let DefaultSize = SelectedUOM.DefaultSize;
- let AlternateSize = SelectedUOM.AlternateSize;
- quantity = Number(element.find(".prodQuantity").val()) * (AlternateSize / DefaultSize);
- totalLineAmount = Number(assesableAmount) * (AlternateSize / DefaultSize);
- element.find(".prodTotalPrice").text(totalLineAmount);
- element.find(".hfRowTotalwithAdjustment").val(totalLineAmount);
- let Conversion = SelectedUOM.DefaultSize + " " + SelectedUOM.DefaultUnitName + " = " + SelectedUOM.AlternateSize + " " + SelectedUOM.AlternateUnitName;
- element.find(".ItemConversion").text(Conversion);
- element.find(".SelectedUOMName").text('(' + SelectedUOM.DefaultUnitName + ')');
- let UOMCalc = UnitPrice + ' X ' + quantity + ' ( ' + SelectedUOM.AlternateUnitName + ' )';
- if (Discount > 0) {
- if (DiscountType == 'Val') {
- UOMCalc = '(' + UnitPrice + ' - ' + Discount + ')' + ' X ' + quantity + ' ( ' + SelectedUOM.DefaultUnitName + ' )';
- }
- else if (DiscountType == '%') {
- UOMCalc = '(' + UnitPrice + ' - ' + Discount + '%)' + ' X ' + quantity + ' ( ' + SelectedUOM.DefaultUnitName + ' )';
- }
- }
- element.find(".UOMCalc").text(UOMCalc);
- }
- else {
- element.find(".ItemConversion").text("");
- element.find(".UOMCalc").text("");
- element.find(".SelectedUOMName").text("");
- }
- }
- if (element.find(".hf_IsManualUOM").val() == "true" && $(".hdn_invoicetypeid").val() == "1") {
- let ItemId = Number(element.find(".selectedItemId").val());
- let SelectedUnitId = Number(element.find(".hf_AlternateUnitId").val());
- let ConversionQuantity = Number(element.find(".hf_ConversionQuantity").val());
- let AlternateUnitName = element.find(".hf_AlternateUnitName").val();
- let ItemUnitName = element.find(".hf_UnitName").val();
- totalLineAmount = Number(ConversionQuantity) * Number(UnitPrice);
- discountAmount = Number(element.find(".hfDiscountedAmount").val()) + (Number(totalLineAmount) * Number(overalldiscountpercent) / 100);
- var assesableAmount = totalLineAmount - discountAmount;
- assesableAmount = Number(assesableAmount);
- totalLineAmount = assesableAmount;
- if (SelectedUnitId != 0 && SelectedUnitId != 1) {
- element.find(".prodTotalPrice").text(totalLineAmount);
- element.find(".hfRowTotalwithAdjustment").val(totalLineAmount);
- element.find(".SelectedUOMName").text('(' + ItemUnitName + ')');
- let UOMCalc = UnitPrice + ' X ' + ConversionQuantity + ' ( ' + AlternateUnitName + ' )';
- if (Discount > 0) {
- if (DiscountType == 'Val') {
- UOMCalc = '(' + UnitPrice + ' - ' + Discount + ')' + ' X ' + ConversionQuantity + ' ( ' + AlternateUnitName + ' )';
- }
- else if (DiscountType == '%') {
- UOMCalc = '(' + UnitPrice + ' - ' + Discount + '%)' + ' X ' + ConversionQuantity + ' ( ' + AlternateUnitName + ' )';
- }
- }
- element.find(".UOMCalc").text(UOMCalc);
- }
- else {
- element.find(".ItemConversion").text("");
- element.find(".UOMCalc").text("");
- element.find(".SelectedUOMName").text("");
- }
- }
- if (!isNaN(totalLineAmount))
- totalNonDiscountedAmount += Number(totalLineAmount);
- discountAmount = Number(element.find(".hfDiscountedAmount").val()) + (Number(totalLineAmount) * Number(overalldiscountpercent) / 100);
- var assesableAmount = totalLineAmount - discountAmount;
- var taxPercents = element.find(".hfProdTaxPercent").val();
- if (taxPercents != undefined)
- var taxpercentarray = taxPercents.toString().split(',');
- var taxValue = 0;
- var assesableAdjustment = Number(element.find('.hfItemAssesableAdjustmentVal').val());
- var taxAdjustment = Number(element.find('.hfItemTaxAdjsutmentVal').val());
- if (!isNaN(taxAdjustment))
- totalTaxAdjustment += Number(taxAdjustment);
- if (!isNaN(assesableAdjustment))
- totalAsseableAdjustment += Number(assesableAdjustment);
- var cumlTax = 0;
- var cumtaxtotal = 0;
- if ($(".dropdown_istaxinclusive").val() == "true") {
- for (var i = 0; i < taxpercentarray.length; i++) {
- var taxPercentModel1 = taxpercentarray[i];
- var taxPercentM1 = taxPercentModel1.split(":");
- if (!isNaN(Number(taxPercentM1[1])))
- cumlTax += Number(taxPercentM1[1]);
- }
- var currentAmt = Number((Number(assesableAmount) * 100) / (100 + Number(cumlTax)));
- cumtaxtotal = (Number(assesableAmount) - Number(currentAmt));
- }
- if (taxpercentarray != undefined) {
- for (var i = 0; i < taxpercentarray.length; i++) {
- var taxPercentModel = taxpercentarray[i];
- var taxPercentM = taxPercentModel.split(":");
- var ledgerid = taxPercentM[0];
- var taxPercent = Number(taxPercentM[1]);
- let taxAmt = 0;
- if ($(".dropdown_istaxinclusive").val() == "true") {
- taxAmt = Number((taxPercent * cumtaxtotal) / cumlTax);
- }
- else {
- var tax = (Number(assesableAmount) * Number(taxPercent) / 100);
- taxAmt = Number(tax);
- }
- var ledgerexists = false;
- $.map(taxAmounts, function (e, i) {
- if (e.LedgerId == ledgerid) {
- ledgerexists = true;
- taxAmounts[i].TaxAmount = Number(taxAmounts[i].TaxAmount) + Number(taxAmt);
- }
- });
- if (!ledgerexists) {
- taxAmounts.push({
- LedgerId: ledgerid,
- TaxAmount: taxAmt,
- });
- }
- }
- }
- totalAmount += Number(totalLineAmount);
- totalQty += Number(quantity);
- }
- });
- if (InvoiceItem.Instance().SplitedInvoiceItemList.length > 0) {
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- var TotalLineAmount = Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity * InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice);
- var quantiy = Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity);
- if (!isNaN(TotalLineAmount))
- totalNonDiscountedAmount += Number(TotalLineAmount);
- var discountAmount = (quantiy * Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountValue)) + ((Number(TotalLineAmount) * Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountPercent)) / 100) + (Number(TotalLineAmount) * Number(overalldiscountpercent) / 100);
- ;
- var assesableAmount = TotalLineAmount - discountAmount;
- assesableAmount = Number(assesableAmount);
- var taxPercents = '';
- var instance = this;
- if (InvoiceItem.Instance().SplitedInvoiceItemList[i].TaxPercent == undefined || InvoiceItem.Instance().SplitedInvoiceItemList[i].TaxPercent == 0) {
- var element = "";
- $(".SplitItem").each(function () {
- if ($(this).find(".selectedItemId").val() == InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId) {
- element = $(this);
- taxPercents = element.find('.hfProdTaxPercent').val();
- }
- });
- }
- else
- taxPercents = InvoiceItem.Instance().SplitedInvoiceItemList[i].TaxPercent;
- if (taxPercents != undefined && taxPercents != '')
- var taxpercentarray = taxPercents.split(',');
- var assesableAdjustment = InvoiceItem.Instance().SplitedInvoiceItemList[i].assesableAdjustment;
- var taxAdjustment = InvoiceItem.Instance().SplitedInvoiceItemList[i].taxAdjustment;
- if (!isNaN(taxAdjustment))
- totalTaxAdjustment += Number(taxAdjustment);
- if (!isNaN(assesableAdjustment))
- totalAsseableAdjustment += Number(assesableAdjustment);
- var cumlTax = 0;
- var cumtaxtotal = 0;
- if ($(".dropdown_istaxinclusive").val() == "true") {
- for (var j = 0; j < taxpercentarray.length; j++) {
- var taxPercentModel1 = taxpercentarray[j];
- var taxPercentM1 = taxPercentModel1.split(":");
- if (!isNaN(taxPercentM1[1]))
- cumlTax += Number(taxPercentM1[1]);
- }
- var currentAmt = Number((Number(assesableAmount) * 100) / (100 + Number(cumlTax)));
- cumtaxtotal = (Number(assesableAmount) - Number(currentAmt));
- }
- if (taxpercentarray != undefined) {
- for (var k = 0; k < taxpercentarray.length; k++) {
- if (taxpercentarray[k] != '' && taxpercentarray[k] != null) {
- var taxPercentModel = taxpercentarray[k];
- var taxPercentM = taxPercentModel.split(":");
- var ledgerid = taxPercentM[0];
- var taxPercent = taxPercentM[1];
- var taxAmt = 0;
- if ($(".dropdown_istaxinclusive").val() == "true") {
- taxAmt = Number((taxPercent * cumtaxtotal) / cumlTax);
- }
- else {
- var tax = (Number(assesableAmount) * Number(taxPercent) / 100);
- taxAmt = Number(tax);
- }
- var ledgerexists = false;
- $.map(taxAmounts, function (e, m) {
- if (e.LedgerId == ledgerid) {
- ledgerexists = true;
- taxAmounts[m].TaxAmount = Number(taxAmounts[m].TaxAmount) + Number(taxAmt);
- }
- });
- if (!ledgerexists) {
- taxAmounts.push({
- LedgerId: ledgerid,
- TaxAmount: taxAmt,
- });
- }
- }
- }
- }
- totalAmount += Number(TotalLineAmount);
- totalQty += Number(quantiy);
- }
- }
- var taxAmount = 0;
- var taxAdjustment = 0;
- for (var i = 0; i < taxAmounts.length; i++) {
- if (!isNaN(taxAmounts[i].TaxAmount)) {
- var taxamt = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(taxAmounts[i].TaxAmount, 2);
- taxAmount += Number(taxamt);
- }
- }
- if (!isNaN(totalTaxAdjustment))
- totalTaxAdjustment = totalTaxAdjustment;
- if (!isNaN(totalAsseableAdjustment)) {
- totalAsseableAdjustment = totalAsseableAdjustment;
- }
- else {
- totalAsseableAdjustment = 0;
- }
- if (!isNaN(totalAsseableAdjustment))
- totalAmount += Number(totalAsseableAdjustment);
- totalTaxAmount = Number(taxAmount) + Number(totalTaxAdjustment);
- totalDiscountAmount += adddiscountrow_total;
- var totaltax = totalTaxAmount;
- var grosstotal = totalAmount;
- var creditnotes = 0;
- var assessableadjustment = 0;
- if (!isNaN(Number($("#txt_assessableadjustment").val())))
- assessableadjustment = Number($("#txt_assessableadjustment").val());
- var subtotal = grosstotal - totalDiscountAmount + assessableadjustment;
- let itemCount = $("#" + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId()).find(".InvoiceItems .item-addedrow .selectedItemId[value!='0']").length;
- $("#" + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId()).find("#Item_Count").text(itemCount);
- var overalldiscount = 0;
- var taxadjustment = 0;
- if (!isNaN(Number($('#txt_taxadjustment').val()))) {
- taxadjustment = Number($('#txt_taxadjustment').val());
- }
- totaltax = Number(totaltax) + Number(taxadjustment);
- totaltax = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totaltax, 2);
- $('#totalTax').html(totaltax);
- $('.hdn_taxamount').val(totaltax);
- $('#grosstotal').html(grosstotal);
- $('#totalItemDiscount').html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(itemdiscount_total, 2));
- $('#totalDiscount').html(totalDiscountAmount);
- $("#totalinvoiceqty").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalQty, 2));
- var expense = 0;
- if (!isNaN(Number($('#txtOverallExpenseAmount').val()))) {
- expense = Number($('#txtOverallExpenseAmount').val());
- $("#totalexpense").text(expense);
- }
- var adjustment = 0;
- var nettotal = Number(subtotal) + Number(addexpenserow_total) - Number(overalldiscount) - Number(netadddiscountrow_total) + Number(adjustment);
- if ($(".dropdown_istaxinclusive").val() == "false")
- nettotal += Number(totaltax);
- if ($(".dropdown_istaxinclusive").val() == "true") {
- subtotal = Number(subtotal) - Number(totalTaxAmount);
- }
- subtotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(subtotal, 2);
- $('#subtotal').html(subtotal);
- $('.hdn_assessableamount').val(subtotal);
- $('.hdn_assessableamount').val($('#subtotal').text());
- if ($("#hf_AdjustmentAccountId").val() != undefined) {
- $(".hdn_adjustmentaccountId").val($("#hf_AdjustmentAccountId").val());
- }
- if ($("#chk_tcsapplied").val() != undefined) {
- if ($("#chk_tcsapplied").prop("checked")) {
- let tcstax = 0;
- let tcsrate = 0;
- tcsrate = InvoiceItem.Instance().TaxRate;
- if (tcsrate != 0) {
- tcstax = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number(subtotal) + Number(totalTaxAmount)) * (tcsrate / 100), 2);
- $('.number_tcsamount').val(tcstax);
- nettotal += Number(tcstax);
- $('#lbltcsrate').text("TCS " + tcsrate + " %");
- var tcsadjustment = 0;
- if (!isNaN(Number($('.txt_tcsadjustment').val()))) {
- tcsadjustment = Number($('.txt_tcsadjustment').val());
- }
- $(".number_tcstaxrate").val(tcsrate);
- $('.number_tcsamount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number(tcstax) + tcsadjustment), 2));
- nettotal += tcsadjustment;
- }
- }
- else {
- $('.txt_tcsadjustment').val(0);
- $('.number_tcsamount').val(0);
- }
- }
- if ($("#chk_tdsapplied").val() != undefined) {
- if ($("#chk_tdsapplied").prop("checked")) {
- let taxcodeid = $(".txtAutoComplete_tdstaxcodeid").val();
- let tdsrate = $(".number_tdstaxrate").val();
- let tdstax = 0;
- if (tdsrate != 0) {
- tdstax = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number(subtotal) * (Number(tdsrate) / 100), 2);
- $('.number_tdsamount').val(tdstax);
- }
- nettotal -= Number(tdstax);
- }
- else {
- $('.txt_tdsadjustment').val(0);
- $('.number_tdsamount').val(0);
- }
- }
- $('.nettotal').html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(nettotal, 2));
- }
- loadItemAutoComplete(element) {
- let userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
- let sessionid = userinfo.sessionId;
- let postData = null;
- element.find(".prodName").select2({
- placeholder: "Select",
- tags: false,
- allowClear: true,
- theme: "default select2ErrorClass",
- data: [],
- ajax: {
- url: function (request) {
- let reqUrl = _appsettings.server_url() + '/apis/v4/bizgaze/transact/items/getitemsdcitemsandinvoiceitems';
- return reqUrl;
- },
- type: "POST",
- contentType: 'application/json',
- dataType: 'json',
- data: function (params) {
- let Term = params.term;
- sessionid = sessionid.replace('#', '');
- postData = {
- LobId: Number($(".hfAutoCompleteId_lobid").val()),
- ItemIds: InvoiceItem.instance.itemIds,
- term: Term,
- };
- return JSON.stringify(postData);
- },
- beforeSend: function (xhr) {
- if (userinfo !== undefined && userinfo !== null) {
- xhr.setRequestHeader("Authorization", "Basic " + userinfo.sessionId);
- xhr.setRequestHeader('geoposition', userinfo.latd + ':' + userinfo.lgId);
- }
- },
- processResults: function (data) {
- return {
- results: jQuery.map(JSON.parse(data.result), function (item) {
- return {
- id: item.Value,
- text: item.SelectText,
- addlInfo: item.addlData
- };
- })
- };
- },
- },
- });
- }
- itemChange(element, id, hdnAutoId) {
- id = element.find(".prodName option:selected").val();
- element.find(".prodName").change(function () {
- if (id == null || id == 0) {
- id = element.find(".prodName option:selected").val();
- }
- id = element.find(".prodName option:selected").val();
- if (id != 0) {
- var hdnItemId = id;
- element.find(".selectedItemId").val(id);
- if (id.search(':') == -1)
- hdnItemId = id;
- else
- hdnItemId = id.split(':')[1];
- if (element.find(".hfoldItemId").val() != hdnItemId) {
- if (element.find(".orderItemId").val() == "0" && hdnItemId != "") {
- if (element.find(".hfoldItemId").val() != "0" && element.find(".hfoldItemId").val() != undefined && element.find(".hfoldItemId").val() != "") {
- let index = InvoiceItem.Instance().itemIds.indexOf(Number(element.find(".hfoldItemId").val()), 0);
- if (index > -1) {
- InvoiceItem.Instance().itemIds.splice(index, 1);
- }
- }
- InvoiceItem.Instance().itemIds.push(Number(hdnItemId));
- }
- var x = [];
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == element.find(".hfoldItemId").val()) {
- x.push(i);
- }
- }
- for (var i = x.length - 1; i >= 0; i--) {
- InvoiceItem.Instance().SplitedInvoiceItemList.splice(x[i], 1);
- }
- $('.item-row').each(function () {
- if ($(this).find('.hfOfferedItemId').val() == element.find(".hfoldItemId").val())
- $(this).remove();
- });
- element.find(".hfoldItemId").val(hdnItemId);
- element.find(".div_UnitPrice").removeClass('hidden');
- element.find(".div_SplitInvoiceItem").addClass("hidden");
- element.find(".prodQuantity").val(0);
- element.find(".prodPrice").val(0);
- element.find(".prodQuantity").prop('disabled', false);
- element.find('.prodQuantity').css('cursor', 'default');
- element.find('.prodPrice').css('cursor', 'default');
- element.find("#inv_txtdiscount").css('cursor', 'default');
- element.find('#inv_txtdiscount').prop('disabled', false);
- element.find('#inv_txtdiscount').val(0);
- element.find('.btn_inv_DiscType').removeClass('hidden');
- element.find(".btn_inv_DiscType").prop('disabled', false);
- element.find(".prodTax").empty();
- element.find(".txt_Account").empty();
- if (element.hasClass('SplitItem')) {
- element.find(".spn_InvoiceItem").unbind("click", null);
- }
- element.find(".hfRowTotalwithAdjustment").val("0");
- element.find('.prodTotalPrice').text('0');
- $("#txt_Adjustment").val("0");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- element.removeClass('SplitItem');
- element.find(".hfMrpId").val(0);
- }
- if ($(hdnAutoId).val().toString().search(':') == -1)
- element.find(".hfoldItemId").val($(hdnAutoId).val());
- else
- element.find(".hfoldItemId").val($(hdnAutoId).val().toString().split(':')[1]);
- var hdnSelectedItemIdVal = 0;
- hdnSelectedItemIdVal = id;
- if (id != 0) {
- id = id;
- var hdnOrderItemIdVal = 0;
- var hdnDcItemIdVal = 0;
- var ids = $(hdnAutoId).val();
- if (ids.toString().search(':') == -1) {
- hdnSelectedItemIdVal = Number($(hdnAutoId).val());
- }
- else {
- var selectedVal = hdnAutoId;
- if (!InvoiceItem.Instance().AutoDc) {
- hdnOrderItemIdVal = Number($(selectedVal).val().toString().split(':')[0]);
- if (InvoiceItem.Instance().orderid != 0 && InvoiceItem.Instance().OrderSettingId == 2)
- hdnOrderItemIdVal = Number($(selectedVal).val().toString().split(':')[0]);
- else {
- hdnDcItemIdVal = Number($(selectedVal).val().toString().split(':')[0]);
- element.find(".dcItemId").val(hdnDcItemIdVal);
- let dcindex = InvoiceItem.Instance().dcItemIds.indexOf(hdnDcItemIdVal, 0);
- if (dcindex == -1)
- InvoiceItem.Instance().dcItemIds.push(hdnDcItemIdVal);
- }
- }
- hdnSelectedItemIdVal = Number($(selectedVal).val().toString().split(':')[1]);
- }
- var item = element.find(".prodName").text();
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemById(hdnSelectedItemIdVal).then(function (response) {
- var inventarytype = response.result.InventoryTypeId;
- if (inventarytype == 5 || inventarytype == 6) {
- InvoiceItem.Instance().addDiscountRow(element, item, id);
- var elementfordisc = $(".discount-row:last");
- InvoiceItem.Instance().loadItemRowDetails(elementfordisc, 0, hdnDcItemIdVal, hdnSelectedItemIdVal);
- }
- else if (inventarytype == 7) {
- InvoiceItem.Instance().addExpenseRow(element, item, id, true);
- var elementforexp = $(".expense-row:last");
- InvoiceItem.Instance().loadItemRowDetails(elementforexp, 0, hdnDcItemIdVal, hdnSelectedItemIdVal);
- }
- else {
- var itemid = 0;
- if (hdnSelectedItemIdVal == undefined) {
- InvoiceItem.Instance().loadItemRowDetails(element, 0, hdnDcItemIdVal, hdnSelectedItemIdVal);
- }
- else {
- InvoiceItem.Instance().loadItemRowDetails(element, hdnOrderItemIdVal, hdnDcItemIdVal, hdnSelectedItemIdVal);
- }
- }
- });
- }
- }
- });
- }
- itemsAutoComplete(element) {
- var txtAutoSearchCtrl = element.find(".prodName");
- var hdnOrderItemId = element.find(".orderItemId");
- var hdnDcItemId = element.find(".dcItemId");
- var hdnSelectedItemId = element.find(".selectedItemId");
- let lobid = $(".hfAutoCompleteId_lobid").val();
- if ((hdnSelectedItemId).val() != 0 && (hdnSelectedItemId).val() != "") {
- this.itemIds.push(Number((hdnSelectedItemId).val()));
- element.find(".hfoldItemId").val((hdnSelectedItemId).val());
- }
- let hdnAutoId = hdnSelectedItemId;
- let orderid = InvoiceItem.Instance().orderid;
- let dcid = InvoiceItem.Instance().dcid;
- let invoiceid = $(".hdn_invoiceid").val();
- if (invoiceid == undefined || invoiceid == "null")
- invoiceid = 0;
- var url = "";
- var id = 0;
- if ((orderid == 0) && (InvoiceItem.Instance().AutoDc) && InvoiceItem.Instance().OrderSettingId == 0 && ($('#hfInv_IsRetun').val() != "1" && ($(".hdn_refinvoiceid").val() == undefined || $(".hdn_refinvoiceid").val() == 0))) {
- InvoiceItem.instance.loadItemAutoComplete(element);
- }
- else {
- if ((orderid == 0) && (dcid != 0 && InvoiceItem.Instance().AutoDc == false))
- url = _appsettings.server_url() + "/apis/v4/bizgaze/transact/invoices/autodcitemforinvoicewithoutorder/dcid/" + dcid + "/itemids/" + InvoiceItem.Instance().itemIds;
- else if (InvoiceItem.Instance().OrderSettingId == 1)
- url = _appsettings.server_url() + "/apis/v4/bizgaze/transact/invoices/autodcitemforinvoice/dcid/" + dcid + "/itemids/" + InvoiceItem.Instance().dcItemIds;
- else
- url = _appsettings.server_url() + "/apis/v4/bizgaze/transact/invoices/autopendingorderitemforinvoice/orderid/" + orderid + "/itemids/" + InvoiceItem.Instance().itemIds;
- if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && ($('#hfInv_IsRetun').val() == "1" || ($(".hdn_refinvoiceid").val() != undefined && $(".hdn_refinvoiceid").val() != 0))) {
- var refinvoiceid = 0;
- if ($('#hfInv_IsRetun').val() == "1") {
- refinvoiceid = Number(invoiceid);
- $(".hdn_refinvoiceid").val(refinvoiceid);
- }
- if ($(".hdn_refinvoiceid").val() != undefined && $(".hdn_refinvoiceid").val() != 0)
- refinvoiceid = Number($(".hdn_refinvoiceid").val());
- url = _appsettings.server_url() + "/apis/v4/bizgaze/transact/invoices/autopendingreturnitemforinvoice/invoiceid/" + refinvoiceid + "/itemids/" + InvoiceItem.Instance().itemIds;
- }
- AutoCompleteHelper.getHelper().Create(txtAutoSearchCtrl, hdnAutoId, url, function (result) {
- InvoiceItem.instance.itemChange(element, result.id, hdnAutoId);
- });
- }
- InvoiceItem.Instance().loadItemRowDetails(element, hdnOrderItemId.val(), hdnDcItemId.val(), $(hdnSelectedItemId).val());
- }
- addDiscountRow(element, txtAutoSearchCtrl, hdnAutoId) {
- InvoiceItem.Instance().RemoveItem(element);
- InvoiceItem.Instance().adddiscountrow(null, txtAutoSearchCtrl, hdnAutoId, false);
- }
- adddiscountrow(row, txtAutoSearchCtrl, hdnAutoId, applyOnNet) {
- let isemptyrow = false;
- $(".addednetdiscount-row").each(function () {
- if ($(this).find(".txtDiscountName").val() == undefined || $(this).find(".txtDiscountName").val() == null) {
- isemptyrow = true;
- }
- });
- if (isemptyrow) {
- MessageHelper.Instance().showError("Please Select Coupon Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- var discountid = 0;
- var discountname = '';
- var description = '';
- var ledgerId = 0;
- var rowname = "discount-row";
- var percent = 0.0;
- var value = 0.0;
- var invoicechargeid = 0;
- var appliedWhole = false;
- var inventorytypeid = 6;
- var readonly = "";
- if (applyOnNet) {
- rowname = "netdiscount-row";
- appliedWhole = true;
- inventorytypeid = 5;
- }
- if ($("#hfDirectInvoice").val() == "0")
- invoicechargeid = 0;
- var html = '<div class="' + rowname + ' added' + rowname + ' row mb-2 mx-0" ' + readonly + '>' +
- '<div class="discount-name col-sm-4">' +
- '<div class="floating-label-form-group min-padding" style="margin-left:20px;border-bottom:0px"><input type="hidden" class="selectedInvoiceChargeId" value="' + invoicechargeid + '" />';
- if (row != null) {
- if (row.addlDiscountPercent != "") {
- percent = row.addlDiscountPercent;
- }
- if (row.addlDiscountValue != "") {
- value = row.addlDiscountValue;
- }
- if (row.description != "" && row.description != null) {
- description = row.description;
- }
- html += '<input type="hidden" class="rowIndex" value="' + this.rowIndex + '" />' +
- '<input type="hidden" class="orderItemId" value="' + row.orderItemId + '" />' +
- '<input type="hidden" class="dcItemId" value="' + row.dcItemId + '" />' +
- '<input type="hidden" class="selectedInvoiceItemId" value="' + row.invoiceItemId + '" />' +
- '<input type="hidden" class="refInvoiceItemId" value="' + row.RefInvoiceItemId + '" />' +
- '<input type="hidden" class="selectedItemId" value="' + row.itemId + '" />' +
- '<input type="hidden" class="inventorytypeid" value="' + row.itemId + '" />' +
- '<input type="hidden" class="selectedItemName" value="' + row.itemname + '" />' +
- '<input type="hidden" class="hfMrpId" value="' + row.MrpId + '" />' +
- '<input type="hidden" class="offerapplied" value="0" />' +
- '<input type="hidden" class="refNo" value="' + row.refNo + '" />' +
- '<input type="hidden" class="description" value="' + row.description + '" />' +
- '<input type="hidden" class="IsExchangeItem" value="' + row.ExchangeItem + '" />' +
- '<input type="hidden" class="maxQty" value="' + row.maxQty + '" />' +
- '<input type="hidden" class="hf_Account" value="' + row.accountId + '" />' +
- '<input type="hidden" class="hfItemTaxAdjsutmentVal" value="' + row.taxAdjustment + '" />' +
- '<input type="hidden" class="hfProdTax" value="' + row.taxGroupId + '" />' +
- '<input type="hidden" class="hfItemAssesableAdjustmentVal" value="' + row.assesableAdjustment + '" />' +
- '<input type="hidden" class="prodPrice text-center form-control" placeholder="0.00" value="0" />';
- }
- else {
- html += '<input type="hidden" class="rowIndex" value="' + this.rowIndex + '" />' +
- '<input type="hidden" class="orderItemId" value="0" />' +
- '<input type="hidden" class="dcItemId" value="0" />' +
- '<input type="hidden" class="selectedInvoiceItemId" value="0" />' +
- '<input type="hidden" class="selectedItemName" value="" />' +
- '<input type="hidden" class="refInvoiceItemId" value="0" />' +
- '<input type="hidden" class="selectedItemId" value="0" />' +
- '<input type="hidden" class="inventorytypeid" value="0" />' +
- '<input type="hidden" class="hfMrpId" value="0" />' +
- '<input type="hidden" class="offerapplied" value="0" />' +
- '<input type="hidden" class="refNo" value="0" />' +
- '<input type="hidden" class="description" value="0" />' +
- '<input type="hidden" class="IsExchangeItem" value="0" />' +
- '<input type="hidden" class="maxQty" value="0" />' +
- '<input type="hidden" class="hf_Account" value="0" />' +
- '<input type="hidden" class="hfItemTaxAdjsutmentVal" value="0" />' +
- '<input type="hidden" class="hfProdTax" value="0" />' +
- '<input type="hidden" class="hfItemAssesableAdjustmentVal" value="0" />' +
- '<input type="hidden" class="prodPrice text-center form-control" placeholder="0.00" value="0" />';
- }
- html += '<div class="input-group">' +
- '<input type="hidden" class="hdnChargeTypeId" value="2" />' +
- '<input type="hidden" class="hdnChargeLedgerId" value="' + ledgerId + '" />' +
- '<a class="input-group-addon no-border bg-white delete" href="javascript:;" title="Remove row"><i class="fa fa-trash-o fa-lg mt-15 mr-2" style="margin-left:-25px;color:red"></i></a>';
- if (rowname == "netdiscount-row") {
- html += '<select type="text" class="txtDiscountName ui-autocomplete form-control text-control readonly' + readonly + '" placeholder=" Discount name" value="' + discountname + '" style="width:100%;"></select>';
- }
- else {
- html += '<select type="text" class="txtDiscountName ui-autocomplete form-control readonly" placeholder=" Discount name" value="' + discountname + '" style="width:100%;"></select>';
- }
- html += '<input type="hidden" class="hfSelectedChargeId" value="' + discountid + '" />' +
- '</div>' +
- '</div></div>' +
- '<div class="col-sm-4">' +
- '<div class="floating-label-form-group min-padding"><input type="text" class="discountDesc form-control" placeholder="Description" value="' + description + '" /></div></div>' +
- '<div class="col-sm-1">' +
- '<div class="floating-label-form-group min-padding"><input type="text" class="percentage text-center form-control" placeholder="%" value="' + percent + '" /></div></div>' +
- '<div class="col-sm-1">' +
- '<div class="floating-label-form-group min-padding"><input type="text" class="fixedvalue text-center form-control" placeholder="0.00" value="' + value + '" /></div></div>' +
- '<div class="col-sm-2 mt-10"><p class="pull-right"><span class="' + rowname + '-total control-label mt-5">0</span></p></div>' +
- '</div>';
- $("." + rowname + ":last").after(html);
- var element = $("." + rowname + ":last");
- InvoiceItem.Instance().bind(element, inventorytypeid);
- if (inventorytypeid == 5)
- InvoiceItem.Instance().GetOnInvoiceDiscountItem(element);
- var txtChargeCode = element.find(".txtDiscountName");
- var hfSelectedChargeId = element.find(".hfSelectedChargeId");
- $(hfSelectedChargeId).val(hdnAutoId);
- if (hdnAutoId != 0) {
- var selecteditem = new Option(txtAutoSearchCtrl, hdnAutoId, true);
- txtChargeCode.append(selecteditem);
- }
- if (rowname == "netdiscount-row" || rowname == "discount-row") {
- var id = 0;
- if (row != null) {
- var selecteditem = new Option(row.itemName, row.itemId, true);
- txtChargeCode.append(selecteditem);
- }
- let typeid = "7";
- if (rowname == "discount-row") {
- typeid = "5,6";
- }
- var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/items/itemautocompletebyinventorytype/inventorytypeid/' + Number(inventorytypeid) + '/lobid/' + $(".hfAutoCompleteId_lobid").val() + '/invoicetypeid/' + $('.hdn_invoicetypeid').val();
- AutoCompleteHelper.getHelper().Create(txtChargeCode, hfSelectedChargeId, url, function (result) {
- if (id != result.id) {
- id = result.id;
- var elementfordisc = $(".netdiscount-row:last");
- var hdnOrderItemIdVal = $(hfSelectedChargeId).val().toString().split(':')[0];
- var hdnSelectedItemIdVal = $(hfSelectedChargeId).val().toString().split(':')[1];
- if (result.addlData != undefined && result.addlData != null) {
- var defaultpercent = Number(result.addlData.split(':')[0]);
- var defaultvalue = Number(result.addlData.split(':')[1]);
- element.find('.percentage').val(defaultpercent);
- element.find('.fixedvalue').val(defaultvalue);
- }
- InvoiceItem.Instance().loadItemRowDetails(element, 0, 0, hdnOrderItemIdVal);
- }
- });
- }
- $('.percentage').keypress(function (event) {
- if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
- }
- else {
- event.preventDefault();
- }
- }).on('paste', function (event) {
- event.preventDefault();
- });
- $('.fixedvalue').keypress(function (event) {
- if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
- }
- else {
- event.preventDefault();
- }
- }).on('paste', function (event) {
- event.preventDefault();
- });
- }
- addExpenseRow(row, txtAutoSearchCtrl, hdnAutoId, applyOnNet) {
- let isemptyrow = false;
- $(".addedexpense-row").each(function () {
- if ($(this).find(".txtExpenseName").val() == undefined || $(this).find(".txtExpenseName").val() == null) {
- isemptyrow = true;
- }
- });
- if (isemptyrow) {
- MessageHelper.Instance().showError("Please Select Expense Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- var discountid = 0;
- var discountname = '';
- var description = '';
- var ledgerId = 0;
- var rowname = "expense-row";
- var percent = 0.0;
- var value = 0.0;
- var invoicechargeid = 0;
- var appliedWhole = true;
- var inventorytypeid = 7;
- if ($("#hfDirectInvoice").val() == "0")
- invoicechargeid = 0;
- var html = '<div class="' + rowname + ' added' + rowname + ' row mb-2" >' +
- '<div class="expense-name col-sm-4">' +
- '<div class="floating-label-form-group min-padding" style="margin-left:20px;border-bottom:0px"><input type="hidden" class="selectedInvoiceChargeId" value="' + invoicechargeid + '" />';
- if (row != null) {
- if (row.addlDiscountPercent != "") {
- percent = -row.addlDiscountPercent;
- }
- if (row.addlDiscountValue != "") {
- value = -row.addlDiscountValue;
- }
- if (row.description != "") {
- description = row.description;
- }
- html += '<input type="hidden" class="rowIndex" value="' + this.rowIndex + '" />' +
- '<input type="hidden" class="orderItemId" value="' + row.orderItemId + '" />' +
- '<input type="hidden" class="dcItemId" value="' + row.dcItemId + '" />' +
- '<input type="hidden" class="selectedInvoiceItemId" value="' + row.invoiceItemId + '" />' +
- '<input type="hidden" class="refInvoiceItemId" value="' + row.RefInvoiceItemId + '" />' +
- '<input type="hidden" class="selectedItemId" value="' + row.itemId + '" />' +
- '<input type="hidden" class="inventorytypeid" value="' + row.itemId + '" />' +
- '<input type="hidden" class="selectedItemName" value="' + row.itemname + '" />' +
- '<input type="hidden" class="hfMrpId" value="' + row.MrpId + '" />' +
- '<input type="hidden" class="offerapplied" value="0" />' +
- '<input type="hidden" class="refNo" value="' + row.refNo + '" />' +
- '<input type="hidden" class="description" value="' + row.description + '" />' +
- '<input type="hidden" class="IsExchangeItem" value="' + row.ExchangeItem + '" />' +
- '<input type="hidden" class="maxQty" value="' + row.maxQty + '" />' +
- '<input type="hidden" class="hf_Account" value="' + row.accountId + '" />' +
- '<input type="hidden" class="hfItemTaxAdjsutmentVal" value="' + row.taxAdjustment + '" />' +
- '<input type="hidden" class="hfProdTax" value="' + row.taxGroupId + '" />' +
- '<input type="hidden" class="hfItemAssesableAdjustmentVal" value="' + row.assesableAdjustment + '" />' +
- '<input type="hidden" class="prodPrice text-center form-control" placeholder="0.00" value="0" />';
- }
- else {
- html += '<input type="hidden" class="rowIndex" value="' + this.rowIndex + '" />' +
- '<input type="hidden" class="orderItemId" value="0" />' +
- '<input type="hidden" class="dcItemId" value="0" />' +
- '<input type="hidden" class="selectedInvoiceItemId" value="0" />' +
- '<input type="hidden" class="selectedItemName" value="" />' +
- '<input type="hidden" class="refInvoiceItemId" value="0" />' +
- '<input type="hidden" class="selectedItemId" value="0" />' +
- '<input type="hidden" class="inventorytypeid" value="0" />' +
- '<input type="hidden" class="hfMrpId" value="0" />' +
- '<input type="hidden" class="offerapplied" value="0" />' +
- '<input type="hidden" class="refNo" value="0" />' +
- '<input type="hidden" class="description" value="0" />' +
- '<input type="hidden" class="IsExchangeItem" value="0" />' +
- '<input type="hidden" class="maxQty" value="0" />' +
- '<input type="hidden" class="hf_Account" value="0" />' +
- '<input type="hidden" class="hfItemTaxAdjsutmentVal" value="0" />' +
- '<input type="hidden" class="hfProdTax" value="0" />' +
- '<input type="hidden" class="hfItemAssesableAdjustmentVal" value="0" />' +
- '<input type="hidden" class="prodPrice text-center form-control" placeholder="0.00" value="0" />';
- }
- html += '<div class="input-group">' +
- '<input type="hidden" class="hdnChargeTypeId" value="1" />' +
- '<input type="hidden" class="hdnChargeLedgerId" value="' + ledgerId + '" />' +
- '<a class="input-group-addon no-border bg-white delete" href="javascript:;" title="Remove row"><i class="fa fa-trash-o fa-lg mt-15 mr-2" style="margin-left:-25px;color:red"></i></a>';
- html += '<select type="text" class="txtExpenseName ui-autocomplete form-control readonly" placeholder=" Expense name" value="' + discountname + '" style="width:100%;"></select>';
- html += '<input type="hidden" class="hfSelectedChargeId" value="' + discountid + '" />' +
- '</div>' +
- '</div></div>' +
- '<div class="col-sm-4">' +
- '<div class="floating-label-form-group min-padding"><input type="text" class="expenseDesc form-control" placeholder="Description" value="' + description + '" /></div></div>' +
- '<div class="col-sm-1">' +
- '<div class="floating-label-form-group min-padding"><input type="text" class="exppercentage text-center form-control" placeholder="%" value="' + percent + '" /></div></div>' +
- '<div class="col-sm-1">' +
- '<div class="floating-label-form-group min-padding"><input type="text" class="expfixedvalue text-center form-control" placeholder="0.00" value="' + value + '" /></div></div>' +
- '<div class="col-sm-2 mt-10"><p class="pull-right"><span class="' + rowname + '-total control-label mt-5">0</span></p></div>' +
- '</div>';
- $("." + rowname + ":last").after(html);
- var element = $("." + rowname + ":last");
- InvoiceItem.Instance().bind(element, inventorytypeid);
- var txtChargeCode = element.find(".txtExpenseName");
- var hfSelectedChargeId = element.find(".hfSelectedChargeId");
- $(hfSelectedChargeId).val(hdnAutoId);
- if (hdnAutoId != 0) {
- var selecteditem = new Option(txtAutoSearchCtrl, hdnAutoId, true);
- txtChargeCode.append(selecteditem);
- }
- if (rowname == "expense-row") {
- var id = 0;
- if (row != null) {
- var selecteditem = new Option(row.itemName, row.itemId, true);
- txtChargeCode.append(selecteditem);
- }
- let typeid = "7";
- var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/items/itemautocompletebyinventorytype/inventorytypeid/' + Number(inventorytypeid) + '/lobid/' + $(".hfAutoCompleteId_lobid").val() + '/invoicetypeid/' + $('.hdn_invoicetypeid').val();
- AutoCompleteHelper.getHelper().Create(txtChargeCode, hfSelectedChargeId, url, function (result) {
- if (id != result.id) {
- id = result.id;
- var elementfordisc = $(".expense-row:last");
- var hdnOrderItemIdVal = $(hfSelectedChargeId).val().toString().split(':')[0];
- var hdnSelectedItemIdVal = $(hfSelectedChargeId).val().toString().split(':')[1];
- InvoiceItem.Instance().loadItemRowDetails(element, 0, 0, hdnOrderItemIdVal);
- }
- });
- }
- $('.exppercentage').keypress(function (event) {
- if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
- }
- else {
- event.preventDefault();
- }
- }).on('paste', function (event) {
- event.preventDefault();
- });
- $('.expfixedvalue').keypress(function (event) {
- if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
- }
- else {
- event.preventDefault();
- }
- }).on('paste', function (event) {
- event.preventDefault();
- });
- }
- loadItemRowDetails(element, orderItemId, dcItemId, itemId) {
- var instance = this;
- if (orderItemId == '' || ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4"))
- orderItemId = 0;
- if (dcItemId == '' || ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) {
- dcItemId = 0;
- }
- if ((orderItemId != 0 && orderItemId != undefined) || (itemId != 0 && itemId != undefined) || (dcItemId != 0 && dcItemId != undefined)) {
- let lobId = $(".hfAutoCompleteId_lobid").val();
- let billingAddressId = $('.txtAutoComplete_billtoaddressid').val();
- if (billingAddressId == "0" || billingAddressId == "" || billingAddressId == null) {
- MessageHelper.Instance().showError("Please select bill to address", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- var portalId = 0;
- var ShipfromAddressId = 0;
- let invoiceid = $(".hdn_invoiceid").val();
- if (invoiceid == undefined)
- invoiceid = 0;
- ShipfromAddressId = Number($(".txtAutoComplete_shipfromaddressid").val());
- var ShiptoAddressId = Number($(".txtAutoComplete_shiptoaddressid").val());
- portalId = Number($(".txtAutoComplete_billfromaddressid").val());
- var MrpId = element.find(".hfMrpId").val();
- if (MrpId == undefined)
- MrpId = 0;
- var isconfirm = false;
- var invoicemode = "1";
- var invoiceType = $('.hdn_invoicetypeid').val();
- if (itemId == undefined)
- itemId = 0;
- var contactId = $(".hdn_organizationid").val();
- if (contactId == 0)
- contactId = $(".hfAutoCompleteId_orgcontactid").val();
- var invoiceapplytype = 1;
- if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7") {
- invoiceapplytype = 2;
- }
- let ApplyDate = new Date($('.hfdate_journaldate').val().toString());
- var refinvoiceid = 0;
- if ($(".hdn_refinvoiceid").val() != undefined && $(".hdn_refinvoiceid").val() != 0)
- refinvoiceid = Number($(".hdn_refinvoiceid").val());
- var post = {
- OrderItemId: Number(orderItemId),
- DcItemId: Number(dcItemId),
- ItemId: Number(itemId),
- BillingAddressId: Number(billingAddressId),
- BillFromAddressId: portalId,
- DefaultPriceListId: 0,
- InvoiceType: Number(invoiceType),
- MrpId: Number(MrpId),
- InvoiceMode: Number(invoicemode),
- isCform: Boolean(isconfirm),
- LobId: Number(lobId),
- contactId: Number(contactId),
- InvoiceApplyType: invoiceapplytype,
- ShipFromAddressId: ShipfromAddressId,
- ShipToAddressId: ShiptoAddressId,
- AutoDC: InvoiceItem.instance.AutoDc,
- InvoiceDate: ApplyDate,
- RefInvoiceId: refinvoiceid
- };
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemDetails(post).then(function (response) {
- var itemdata = response.result;
- element.find(".selectedItemId").val(itemdata.ItemId);
- if (itemdata.orderItemId == 0)
- element.find(".orderItemId").val(orderItemId);
- else
- element.find(".orderItemId").val(itemdata.OrderItemId);
- itemId = itemdata.ItemId;
- element.find(".spnProdName").text(itemdata.ItemName);
- element.find(".selectedItemName").text(itemdata.ItemName + ' - ' + itemdata.ItemSKU);
- element.find("#inventorytypeid").val(itemdata.InventoryTypeId);
- var prodPrice = element.find(".prodPrice");
- var prodQty = element.find(".prodQuantity");
- var priceListId = element.find(".hfPriceList");
- var isSplitItem = false;
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == itemdata.ItemId) {
- isSplitItem = true;
- }
- }
- if (itemdata.AccountId != 0 && (element.find(".selectedInvoiceItemId").val() == "0" || (itemdata.InventoryTypeId == 5)) && !isSplitItem) {
- var selectedAccount = new Option(itemdata.AccountName, itemdata.AccountId, true);
- element.find(".txt_Account").empty();
- element.find(".txt_Account").append(selectedAccount);
- element.find(".hf_Account").val(itemdata.AccountId);
- element.find(".txt_AccountName").val(itemdata.AccountName);
- }
- if (itemdata.TaxGroupId != 0 && (element.find(".selectedInvoiceItemId").val() == "0" || (itemdata.InventoryTypeId == 5)) && !isSplitItem) {
- var txtTaxGroup = element.find(".prodTax");
- var hfTaxGroupId = element.find(".hfProdTax");
- txtTaxGroup.empty();
- var selectedTaxgrp = new Option(itemdata.TaxGroupName, itemdata.TaxGroupId, true);
- txtTaxGroup.append(selectedTaxgrp);
- element.find(".txtProdTax").val(itemdata.TaxGroupName);
- hfTaxGroupId.val(itemdata.TaxGroupId);
- InvoiceItem.Instance().update_tax(element, itemdata.TaxGroupId);
- }
- if (element.find(".selectedInvoiceItemId").val() == "0" && !isSplitItem) {
- prodPrice.val(itemdata.UnitPrice);
- element.find(".hf_UnitPrice").val(itemdata.UnitPrice);
- priceListId.val(itemdata.PriceListId);
- if (itemdata.AddlDisountValue > 0) {
- element.find(".btnInvoice_DiscType option[value='Val']").prop("selected", true);
- element.find('.inv_txtaddldiscount').val(itemdata.AddlDisountValue);
- }
- else if (itemdata.AddlDiscountPercent > 0) {
- element.find(".btnInvoice_DiscType option[value='%']").prop("selected", true);
- element.find('.inv_txtaddldiscount').val(itemdata.AddlDiscountPercent);
- }
- }
- if ($(".hdn_invoiceid").val() != "0") {
- element.find(".prodAvail").text(itemdata.AvailableQty);
- element.find(".hfAvail").val(itemdata.AvailableQty);
- }
- else {
- element.find(".prodAvail").text(itemdata.AvailableQty);
- element.find(".hfAvail").val(itemdata.AvailableQty);
- }
- var dcid = InvoiceItem.Instance().dcid;
- if (dcid == undefined)
- dcid = 0;
- if ((itemdata.EnableMrp == true || itemdata.EnableBatchNo == true || itemdata.EnableSerialNo == true) && ((Number(element.find('.prodAvail').text()) > 0) || $(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || dcid != 0) && $(".hdn_invoicetypeid").val() != "6" && $(".hdn_invoicetypeid").val() != "7" && element.find('.hf_IsFoc').val() == "false") {
- element.find(".div_UnitPrice").addClass('hidden');
- element.find(".div_SplitInvoiceItem").removeClass("hidden");
- element.find(".prodQuantity").prop('disabled', true);
- element.find(".prodQuantity").css('cursor', "not-allowed");
- element.find("#inv_txtdiscount").prop('disabled', true);
- element.find("#inv_txtdiscount").css('cursor', "not-allowed");
- element.find('.btn_inv_DiscType').addClass('hidden');
- element.find(".btn_inv_DiscType").prop('disabled', true);
- element.find(".prodTax").removeClass("required");
- element.find(".txt_Account").removeClass("required");
- element.addClass('SplitItem');
- var ItemExist = false;
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == itemdata.ItemId) {
- ItemExist = true;
- if (InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId == 0)
- InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice = itemdata.UnitPrice;
- }
- }
- var type = '';
- if (itemdata.EnableBatchNo == true) {
- if (ItemExist == true)
- element.find(".spn_InvoiceItem").text("View BatchNo");
- else
- element.find(".spn_InvoiceItem").text("Select BatchNo");
- type = "BatchNo";
- }
- else if (itemdata.EnableMrp == true) {
- if (ItemExist == true)
- element.find(".spn_InvoiceItem").text("View MRP");
- else
- element.find(".spn_InvoiceItem").text("Select MRP");
- type = "MRP";
- }
- else {
- if (ItemExist == true)
- element.find(".spn_InvoiceItem").text("View SerialNo");
- else
- element.find(".spn_InvoiceItem").text("Select SerialNo");
- type = 'SerialNo';
- }
- let d = InvoiceItem.instance.AutoDc;
- if (d == false && dcItemId != 0 && element.find(".selectedInvoiceItemId").val() == "0") {
- var Isitemadded = false;
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (InvoiceItem.Instance().SplitedInvoiceItemList[i].dcItemId == dcItemId) {
- Isitemadded = true;
- }
- }
- if (Isitemadded == false) {
- var IsSpitItem = false;
- var RowTotal = 0;
- var Discount = 0;
- var Qty = 0;
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == itemdata.ItemId) {
- IsSpitItem = true;
- }
- }
- InvoiceItem.Instance().SplitedInvoiceItemList.push({
- orderItemId: itemdata.OrderItemId,
- invoiceItemId: 0,
- itemName: itemdata.ItemName,
- itemId: itemdata.ItemId,
- itemSKU: itemdata.ItemSKU,
- unitName: itemdata.UnitName,
- packSize: itemdata.PackSize,
- packCount: itemdata.PackCount,
- packs: itemdata.Packs,
- quantity: itemdata.Quantity,
- availPacks: itemdata.AvailablePacks,
- availQty: itemdata.AvailableQty,
- listPrice: 0,
- description: itemdata.Description,
- taxGroupName: itemdata.TaxGroupName,
- taxGroupId: itemdata.TaxGroupId,
- isTaxInclusive: $(".dropdown_istaxinclusive").val(),
- addlDiscountPercent: itemdata.AddlDiscountPercent == undefined ? 0 : itemdata.AddlDiscountPercent,
- addlDiscountValue: itemdata.AddlDisountValue,
- creditNote: 0,
- priceListId: 0,
- batchId: 0,
- unitPrice: itemdata.UnitPrice,
- invoiceallocations: null,
- exciseInvoiceItem: null,
- accountId: itemdata.AccountId,
- accountName: itemdata.AccountName,
- walletId: 0,
- Adjustment: 0,
- IsFoc: false,
- TariffNo: "",
- exciseAmount: 0,
- discountName: "",
- discountId: 0,
- refNo: itemdata.RefNo,
- DiscountGroupId: 0,
- DiscountGroupName: "",
- ExchangeItem: false,
- maxQty: itemdata.Quantity,
- RefInvoiceItemId: 0,
- MrpId: itemdata.MrpId,
- taxAdjustment: 0,
- assesableAdjustment: 0,
- inventoryTypeId: itemdata.InventoryTypeId,
- IsBoMItem: false,
- dcItemId: dcItemId,
- TotalRowAmount: 0,
- TotalDiscount: 0,
- TotalAmount: 0,
- BatchId: itemdata.BatchId,
- });
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == itemdata.ItemId) {
- Qty += InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity;
- var rowtotal = Number((InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity * InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice) + InvoiceItem.Instance().SplitedInvoiceItemList[i].exciseAmount + itemdata.Adjustment);
- var nonexiceamount = rowtotal - InvoiceItem.Instance().SplitedInvoiceItemList[i].exciseAmount;
- var discount = ((nonexiceamount * itemdata.AddlDiscountPercent) / 100) + (itemdata.Quantity * itemdata.AddlDisountValue);
- InvoiceItem.Instance().SplitedInvoiceItemList[i].TotalAmount = rowtotal,
- InvoiceItem.Instance().SplitedInvoiceItemList[i].TotalDiscount = discount,
- Discount += discount;
- RowTotal += rowtotal;
- }
- }
- $('.item-row').each(function () {
- if ($(this).find('.selectedItemId').val() == itemdata.ItemId) {
- if ($(".hdn_invoicetypeid").val() == "2") {
- $(this).find(".txtRowTotalwithAdjustment").val();
- $(this).find(".txtRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number(RowTotal), 3));
- }
- else {
- element.find('.prodTotalPrice').text('');
- element.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(RowTotal, 3));
- }
- $(this).find('.prodQuantity').val();
- $(this).find('.prodQuantity').val(Qty);
- $(this).find('#inv_txtdiscount').val();
- $(this).find('#inv_txtdiscount').val(Discount);
- }
- });
- }
- }
- if (orderItemId != 0 && invoiceid == 0) {
- element.find('.prodQuantity').val(itemdata.Quantity);
- }
- element.find(".spn_InvoiceItem").unbind().click(function () {
- InvoiceItem.Instance().createSplitItem(element, itemdata.ItemName + ' - ' + itemdata.ItemSKU, type);
- });
- }
- else if (element.find(".selectedInvoiceItemId").val() == "0" && $('.hdn_invoicetypeid').val() != '3' && $('.hdn_invoicetypeid').val() != '4' && (dcItemId != 0 || (orderItemId != 0 && InvoiceItem.Instance().OrderSettingId == 2))) {
- prodPrice.val(itemdata.UnitPrice);
- prodQty.val(itemdata.Quantity);
- priceListId.val(itemdata.PriceListId);
- element.find('.maxQty').val(itemdata.Quantity);
- }
- if (element.find(".selectedInvoiceItemId").val() == "0" && ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) {
- prodQty.val(itemdata.Quantity);
- }
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2") {
- if ((itemdata.IsOfferAvailable == true || itemdata.IsFocAvailable == true) && element.find('.hf_IsFoc').val() != "true") {
- element.find('.btn_offer').removeClass('hidden');
- element.find('.btn_offer').click(function () {
- InvoiceItem.Instance().loadItemOffers(itemdata.ItemId, itemdata.ItemName, invoiceapplytype, contactId, element);
- });
- }
- else
- element.find('.btn_offer').addClass('hidden');
- if (itemdata.IsSpecialPrice == true)
- element.find('.btn_specialPrice').removeClass('hidden');
- }
- if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $("#hf_AppSettingName").val() == "Create Return") {
- element.find(".prodTax").empty();
- element.find(".txt_Account").empty();
- if (itemdata.TaxGroupId != 0) {
- element.find(".txtProdTax").val(itemdata.TaxGroupName);
- element.find(".hfProdTax").val(itemdata.TaxGroupId);
- }
- if (itemdata.AccountId != 0) {
- element.find(".hf_Account").val(itemdata.AccountId);
- element.find(".txt_AccountName").val(itemdata.AccountName);
- }
- }
- if (!element.hasClass('SplitItem')) {
- if ($(".hdn_invoiceid").val() != "0" && $(".hdn_invoiceid").val() != undefined) {
- var taxgrpid = element.find(".hfProdTax").val();
- InvoiceItem.Instance().update_tax(element, taxgrpid);
- }
- }
- if (!element.hasClass('SplitItem') && (element.find(".selectedInvoiceItemId").val() == "0" || element.find(".selectedInvoiceItemId").val() == "undefined")) {
- var txtTaxGroup = element.find(".prodTax");
- var hfTaxGroupId = element.find(".hfProdTax");
- if (itemdata.TaxGroupId != 0) {
- txtTaxGroup.empty();
- var selectedTaxgrp = new Option(itemdata.TaxGroupName, itemdata.TaxGroupId, true);
- txtTaxGroup.append(selectedTaxgrp);
- element.find(".txtProdTax").val(itemdata.TaxGroupName);
- hfTaxGroupId.val(itemdata.TaxGroupId);
- InvoiceItem.Instance().update_tax(element, itemdata.TaxGroupId);
- }
- if (itemdata.AccountId != 0) {
- var selectedAccount = new Option(itemdata.AccountName, itemdata.AccountId, true);
- element.find(".txt_Account").empty();
- element.find(".txt_Account").append(selectedAccount);
- element.find(".hf_Account").val(itemdata.AccountId);
- element.find(".txt_AccountName").val(itemdata.AccountName);
- }
- }
- var unit = element.find(".unit");
- unit.text(itemdata.UnitName);
- var sku = element.find(".prodSKU");
- sku.text(itemdata.ItemSKU);
- var packSize = element.find(".packSize");
- if (itemdata.PackSize == "0")
- packSize.val("1");
- else
- packSize.val(itemdata.PackSize);
- if (itemdata.PackCount == "0")
- element.find(".packCount").val("1");
- else
- element.find(".packCount").val(itemdata.PackCount);
- var rowTotal = 0;
- var rowTotalwithAdjustment = 0;
- if (element.find('.prodPrice').val() != undefined && element.find('.prodQuantity').val() != undefined) {
- rowTotal = element.find('.prodPrice').val().replace("$", "") * element.find('.prodQuantity').val();
- rowTotalwithAdjustment = element.find('.prodPrice').val().replace("$", "") * element.find('.prodQuantity').val();
- }
- if (itemdata.InventoryTypeId == 2) {
- element.find('.prodQuantity').removeAttr('readonly');
- }
- var asbAdjAmt = element.find('.hfItemAssesableAdjustmentVal').val();
- if (!isNaN(asbAdjAmt))
- rowTotalwithAdjustment += Number(asbAdjAmt);
- rowTotalwithAdjustment = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowTotalwithAdjustment, 2);
- if (isNaN(rowTotal)) {
- if (!element.hasClass('SplitItem')) {
- element.find('.prodTotalPrice').html("N/A");
- element.find('.hfRowTotal').val("0");
- element.find('.hfRowTotalwithAdjustment').val("0");
- }
- }
- else {
- if (!element.hasClass('SplitItem')) {
- element.find('.hfRowTotal').val(rowTotal);
- element.find('.hfRowTotalwithAdjustment').val(rowTotalwithAdjustment);
- element.find('.prodTotalPrice').html(rowTotal);
- }
- }
- if (itemdata.AvailableQty <= 0)
- element.find(".prodAvail").addClass('text-danger');
- else
- element.find(".prodAvail").removeClass('text-danger');
- if (!element.hasClass('SplitItem')) {
- InvoiceItem.Instance().update_row_total(element, false);
- }
- InvoiceItem.Instance().loadPriceLists(element, itemId, itemdata.EnableMrp);
- if (itemdata.EnableMrp != true && itemdata.EnableBatchNo != true && itemdata.EnableSerialNo != true) {
- element.find('.hfRowTotalwithAdjustment').css("text-decoration", "underline");
- element.find('.hfRowTotalwithAdjustment').attr("disabled", false);
- element.find('.Adjustmentrow').click(function () {
- if ($(".hdn_invoicetypeid").val() == "2" && element.find('.selectedInvoiceItemId').val() != "0") {
- InvoiceItem.Instance().editInvItemTaxAllocs(element.find('.selectedInvoiceItemId').val(), element.find('.hfProdTax').val(), element.find('.selectedItemId').val(), element.find('.orderItemId').val(), element);
- }
- });
- }
- else {
- element.find('.hfRowTotalwithAdjustment').css("text-decoration", "");
- element.find('.hfRowTotalwithAdjustment').attr("disabled", true);
- }
- if (IsSpitItem == true) {
- element.remove();
- }
- if (itemdata.IsMultilpeUOMs && $(".hdn_invoicetypeid").val() == "1") {
- element.find(".hf_IsMultipleUOM").val(itemdata.IsMultilpeUOMs);
- let MultipleUOMs = itemdata.MultipleUoms;
- let html = '<option value="0"> -- Select -- </option>';
- for (var i = 0; i < MultipleUOMs.length; i++) {
- html += '<option value="' + MultipleUOMs[i].SchemaDetailId + '">' + MultipleUOMs[i].AlternateUnitName + ' ( ' + MultipleUOMs[i].DefaultSize + ' ' + MultipleUOMs[i].DefaultUnitName + ' ) </option>';
- }
- element.find(".ddl_MultipleUOMs").html(html);
- element.find("#div_MultipleUOMs").removeClass("hidden");
- instance.UOMs.push({
- ItemId: itemId,
- MultipleUOMs: MultipleUOMs
- });
- let SelectedUOM = Number(element.find(".hf_AlternateUnitId").val());
- let DefaultSize = Number(element.find(".hf_DefaultSize").val());
- if (SelectedUOM != 0) {
- element.find(".ddl_MultipleUOMs").val(SelectedUOM);
- let Qty = element.find(".prodQuantity").val();
- let NewQty = Qty / DefaultSize;
- element.find(".prodQuantity").val(NewQty);
- }
- }
- else {
- element.find("#div_MultipleUOMs").addClass("hidden");
- }
- if (itemdata.InventoryTypeId == 1)
- InvoiceItem.Instance().GetDiscounts();
- }, function (response) {
- MessageHelper.Instance().showError(JSON.stringify(response.responseJSON.Message), $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- });
- }
- }
- loadItemOffers(ItemId, ItemName, InvoiceApplyType, OrganizationId, element) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/components/invoices/itemofferselection.js", function () {
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(0, "", Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection.Instance(), function () {
- Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection.Instance().LoadOfferItems(OrganizationId, ItemId, ItemName, InvoiceApplyType, element, "Invoice");
- }, Unibase.Platform.Helpers.Size.Large);
- });
- }
- update_tax(element, taxGroupId) {
- var hfTaxValue = element.find(".hfProdTaxValue");
- var hfTaxPercent = element.find(".hfProdTaxPercent");
- var hfProdTax = element.find(".hfProdTax");
- var percentage = 0;
- if (taxGroupId == "0" || taxGroupId == "" || taxGroupId == undefined)
- return percentage;
- let branchid = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("branchid"));
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().gettaxpercentages(taxGroupId, branchid).then(function (response) {
- var percentstring = "";
- if (response.result.length > 0) {
- var percentages = response.result;
- for (var i = 0; i < percentages.length; i++) {
- percentstring += percentages[i].LedgerId + ":" + percentages[i].Percentage + ",";
- }
- hfTaxPercent.val(percentstring);
- }
- hfTaxValue.val("0");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }, function (response) {
- MessageHelper.Instance().showError(JSON.stringify(response.responseJSON.Message), $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- });
- }
- createSplitItem(element, ItemName, type) {
- let obj = [];
- obj.push({
- type: type,
- element: element,
- });
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/controls/invoices/splititem.js", function () {
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(obj, "", Bizgaze.Apps.Transact.Controls.Invoices.SplitItem.Instance(), null, Unibase.Platform.Helpers.Size.Large);
- });
- }
- loadPriceLists(element, itemId, IsEnableMrp) {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getLatestMrpByItemId(itemId).then(function (response) {
- if (response.result != null) {
- element.find(".hf_PriceList").val(response.result.PriceListId);
- if (response.result.MrpId != 0 && IsEnableMrp) {
- element.find(".txt_MRP").val(response.result.Mrp);
- element.find(".hfMrpId").val(response.result.MrpId);
- }
- }
- }, function (response) {
- MessageHelper.Instance().showError(JSON.stringify(response.responseJSON.Message), $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- });
- }
- RemoveItem(element) {
- var _this = element.find(".delete");
- var invoiceitemid = _this.parents('.item-row').find(".selectedInvoiceItemId").val();
- if (invoiceitemid == "0") {
- $(element).find(".prodTax").removeClass("required");
- $(element).find(".txt_Account").removeClass("required");
- $(element).addClass("hidden remove_item");
- $(element).find(".selectedItemId").val(0);
- }
- else {
- _this.parents('.item-row').remove();
- InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- bind(element, inventoryTypeId) {
- if (inventoryTypeId != 5 && inventoryTypeId != 6 && inventoryTypeId != 7) {
- element.find(".delete").on('click', function () {
- var _this = $(this);
- var invoiceitemid = _this.parents('.item-row').find(".selectedInvoiceItemId").val();
- if (_this.parents('.item-row').hasClass('SplitItem')) {
- bootbox.confirm("You are about to delete the invoice items. Are you sure?", function (result) {
- if (result == true) {
- var orderid = _this.parents('.item-row').find('.orderItemId').val();
- if ((orderid == 0 || orderid == "0" || orderid == undefined) && _this.parents('.item-row').find('.selectedItemId').val() != 0) {
- let index = InvoiceItem.Instance().itemIds.indexOf(_this.parents('.item-row').find('.selectedItemId').val(), 0);
- if (index == -1)
- index = InvoiceItem.Instance().itemIds.indexOf(Number(_this.parents('.item-row').find('.selectedItemId').val()), 0);
- if (index > -1) {
- InvoiceItem.Instance().itemIds.splice(index, 1);
- }
- }
- else if (orderid != 0) {
- let index = InvoiceItem.Instance().itemIds.indexOf(_this.parents('.item-row').find('.selectedItemId').val(), 0);
- if (index == -1)
- index = InvoiceItem.Instance().itemIds.indexOf(Number(_this.parents('.item-row').find('.selectedItemId').val()), 0);
- if (index > -1) {
- InvoiceItem.Instance().itemIds.splice(index, 1);
- }
- var itemlength = InvoiceItem.Instance().SplitedInvoiceItemList.find(x => x.itemId == Number(_this.parents('.item-row').find('.selectedItemId').val()));
- if (itemlength == undefined) {
- if (_this.parents('.item-row').find('.selectedInvoiceItemId').val() != 0) {
- InvoiceItem.Instance().deleted_invoiceItems.push(Number(_this.parents('.item-row').find('.selectedInvoiceItemId').val()));
- }
- }
- }
- var x = [];
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == _this.parents('.item-row').find('.selectedItemId').val()) {
- x.push(i);
- var index = InvoiceItem.Instance().dcItemIds.indexOf(InvoiceItem.Instance().SplitedInvoiceItemList[i].dcItemId);
- if (index == -1)
- index = InvoiceItem.Instance().dcItemIds.indexOf(Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].dcItemId));
- if (index > -1) {
- InvoiceItem.Instance().dcItemIds.splice(index, 1);
- }
- if (InvoiceItem.Instance().dcItemIds.length == 0)
- InvoiceItem.Instance().dcItemIds = [0];
- if (InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId != 0) {
- InvoiceItem.Instance().deleted_invoiceItems.push(Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId));
- }
- }
- }
- $('.item-row').each(function () {
- if ($(this).find('.hfOfferedItemId').val() == _this.parents('.item-row').find('.selectedItemId').val() && $(this).find('.hf_IsFoc').val() == "true") {
- if ($(this).find('.selectedInvoiceItemId').val() != 0)
- InvoiceItem.Instance().deleted_invoiceItems.push(Number($(this).find('.selectedInvoiceItemId').val()));
- $(this).remove();
- }
- });
- for (var i = x.length - 1; i >= 0; i--) {
- InvoiceItem.Instance().SplitedInvoiceItemList.splice(x[i], 1);
- }
- _this.parents('.item-row').remove();
- $("#txt_Adjustment").val("0");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- InvoiceItem.Instance().GetDiscounts();
- }
- });
- }
- else if (invoiceitemid != 0) {
- bootbox.confirm("You are about to delete the invoice items. Are you sure?", function (result) {
- if (result) {
- var invoiceitemid = _this.parents('.item-row').find(".selectedInvoiceItemId").val();
- InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
- var orderitemid = _this.parents('.item-row').find('.orderItemId').val();
- var dcitemid = _this.parents('.item-row').find('.dcItemId').val();
- if (_this.parents('.item-row').find('.selectedItemId').val() != 0) {
- let index = InvoiceItem.Instance().itemIds.indexOf(_this.parents('.item-row').find('.selectedItemId').val(), 0);
- if (index == -1)
- index = InvoiceItem.Instance().itemIds.indexOf(Number(_this.parents('.item-row').find('.selectedItemId').val()), 0);
- if (index > -1) {
- InvoiceItem.Instance().itemIds.splice(index, 1);
- }
- if (orderitemid != 0 && dcitemid != 0) {
- let dcindex = InvoiceItem.Instance().dcItemIds.indexOf(_this.parents('.item-row').find('.dcItemId').val(), 0);
- if (dcindex == -1)
- dcindex = InvoiceItem.Instance().dcItemIds.indexOf(Number(_this.parents('.item-row').find('.dcItemId').val()), 0);
- InvoiceItem.Instance().dcItemIds.splice(dcindex, 1);
- if (InvoiceItem.Instance().dcItemIds.length == 0)
- InvoiceItem.Instance().dcItemIds.push(0);
- }
- }
- $('.item-row').each(function () {
- if ($(this).find('.hfOfferedItemId').val() == _this.parents('.item-row').find('.selectedItemId').val() && $(this).find('.hf_IsFoc').val() == "true")
- $(this).remove();
- });
- _this.parents('.item-row').remove();
- $("#txt_Adjustment").val("0");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- InvoiceItem.Instance().GetDiscounts();
- }
- });
- }
- else {
- bootbox.confirm("You are about to delete the invoice item. Are you sure?", function (result) {
- if (result) {
- var dcitemid = _this.parents('.item-row').find('.dcItemId').val();
- if (_this.parents('.item-row').find('.selectedItemId').val() != 0) {
- let index = InvoiceItem.Instance().itemIds.indexOf(_this.parents('.item-row').find('.selectedItemId').val(), 0);
- if (index == -1)
- index = InvoiceItem.Instance().itemIds.indexOf(Number(_this.parents('.item-row').find('.selectedItemId').val()), 0);
- if (index > -1) {
- InvoiceItem.Instance().itemIds.splice(index, 1);
- if (dcitemid != 0) {
- let dcindex = InvoiceItem.Instance().dcItemIds.indexOf(Number(_this.parents('.item-row').find('.dcItemId').val()), 0);
- InvoiceItem.Instance().dcItemIds.splice(dcindex, 1);
- if (InvoiceItem.Instance().dcItemIds.length == 0)
- InvoiceItem.Instance().dcItemIds.push(0);
- }
- }
- }
- var x = [];
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == _this.parents('.item-row').find('.selectedItemId').val()) {
- x.push(i);
- }
- }
- for (var i = x.length - 1; i >= 0; i--) {
- InvoiceItem.Instance().SplitedInvoiceItemList.splice(x[i], 1);
- }
- $('.item-row').each(function () {
- if ($(this).find('.hfOfferedItemId').val() == _this.parents('.item-row').find('.selectedItemId').val() && $(this).find('.hf_IsFoc').val() == "true")
- $(this).remove();
- });
- _this.parents('.item-row').remove();
- $("#txt_Adjustment").val("0");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- InvoiceItem.Instance().GetDiscounts();
- }
- });
- }
- });
- element.find(".prodPrice,.prodQuantity,.exciseAmount").blur(function () {
- InvoiceItem.Instance().update_price(element);
- });
- element.find(".prodQuantity").change(function () {
- InvoiceItem.Instance().CheckOfferForItem($(this));
- });
- element.find(".prodTax").blur(function () {
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- element.find(".prodPrice").blur(function () {
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- InvoiceItem.Instance().GetDiscounts();
- });
- element.find(".prodQuantity").blur(function () {
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- InvoiceItem.Instance().GetDiscounts();
- });
- element.find('.ddl_MultipleUOMs').change(function () {
- InvoiceItem.Instance().update_row_total(element, true);
- });
- element.find(".inv_txtaddldiscount").blur(function () {
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- InvoiceItem.Instance().GetDiscounts();
- });
- element.find(".inv_txtaddldiscount").blur(InvoiceItem.Instance().update_discount_total);
- element.find(".btnOrder_DiscType").text('Val');
- element.find(".btnInvoice_DiscType").change(function () {
- if (element.find(".btnInvoice_DiscType option:selected").text().trim() == 'Val') {
- element.find('#hfProdDiscountGroupId').val(0);
- element.find('#hfProdDiscountGroupName').val('');
- element.find('.inv_txtaddldiscount').prop('disabled', false);
- }
- else if (element.find(".btnInvoice_DiscType option:selected").text().trim() == '%') {
- element.find('#hfProdDiscountGroupId').val(0);
- element.find('#hfProdDiscountGroupName').val('');
- element.find('.inv_txtaddldiscount').prop('disabled', false);
- if (Number(element.find("#inv_txtdiscount").val()) > 100) {
- element.find("#inv_txtdiscount").val("100");
- }
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- InvoiceItem.Instance().GetDiscounts();
- });
- }
- else {
- if (inventoryTypeId == 6) {
- element.find(".delete").on('click', function () {
- var dis = $(".fixedvalue").val();
- var _this = $(this);
- var selectedinvoiceitemid = element.find(".selectedInvoiceItemId").val();
- if (selectedinvoiceitemid != 0) {
- bootbox.confirm("You are about to delete the discount item. Are you sure?", function (result) {
- if (result) {
- var rowIndex = element.find(".rowIndex").val();
- var invoiceitemid = _this.parents('.discount-row').find(".selectedInvoiceItemId").val();
- _this.parents('.discount-row').remove();
- InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- }
- else {
- _this.parents('.discount-row').remove();
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- }
- else if (inventoryTypeId == 5) {
- element.find(".delete").on('click', function () {
- var dis = $(".fixedvalue").val();
- var _this = $(this);
- var selectedinvoiceitemid = element.find(".selectedInvoiceItemId").val();
- if (selectedinvoiceitemid != 0) {
- bootbox.confirm("You are about to delete the coupon item. Are you sure?", function (result) {
- if (result) {
- var rowIndex = element.find(".rowIndex").val();
- var invoiceitemid = _this.parents('.netdiscount-row').find(".selectedInvoiceItemId").val();
- _this.parents('.netdiscount-row').remove();
- InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- }
- else {
- if (_this.parents('.OnInvoiceOfferItem').length != 0) {
- InvoiceItem.Instance().isOfferChargeApplied = false;
- $(".hdn_isofferchargeapplied").val('false');
- }
- _this.parents('.netdiscount-row').remove();
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- }
- else if (inventoryTypeId == 7) {
- element.find(".delete").on('click', function () {
- var dis = $(".expfixedvalue").val();
- var _this = $(this);
- var selectedinvoiceitemid = element.find(".selectedInvoiceItemId").val();
- if (selectedinvoiceitemid != 0) {
- bootbox.confirm("You are about to delete the coupon item. Are you sure?", function (result) {
- if (result) {
- var rowIndex = element.find(".rowIndex").val();
- var invoiceitemid = _this.parents('.expense-row').find(".selectedInvoiceItemId").val();
- _this.parents('.expense-row').remove();
- InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- }
- else {
- _this.parents('.expense-row').remove();
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- }
- $(".percentage").on('blur', function () {
- InvoiceItem.Instance().update_discount_total();
- });
- $(".fixedvalue").on('blur', function () {
- InvoiceItem.Instance().update_discount_total();
- });
- $(".expfixedvalue").on('blur', function () {
- InvoiceItem.Instance().update_expense_total();
- });
- $(".exppercentage").on('blur', function () {
- InvoiceItem.Instance().update_expense_total();
- });
- InvoiceItem.Instance().update_discount_total();
- InvoiceItem.Instance().update_expense_total();
- }
- }
- update_price(element) {
- InvoiceItem.Instance().update_row_total(element, true);
- }
- update_row_total(element, checkavailability) {
- var row = element;
- var item = Number(row.find('.selectedItemId').val());
- var inventorytypeid = 0;
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () {
- Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItem(item).then(function (response) {
- inventorytypeid = response.result.InventoryTypeId;
- if (item == 0) {
- row.find(".prodQuantity").val(0);
- row.find(".prodPrice").val(0);
- MessageHelper.Instance().showError("Please Select Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- if (checkavailability == true) {
- let BranchId = 0;
- var SettingName = "";
- if ($(".hdn_invoicetypeid").val() == "1") {
- SettingName = "Bizgaze_Extension_Transact_Orders_Setting_Sales_CheckAvailability";
- BranchId = Number($(".txtAutoComplete_billfromaddressid option:selected").val());
- }
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/orders/ordermanager.js", function () {
- let LobId = Number($(".txtAutoComplete_lobid option:selected").val());
- Bizgaze.Apps.Transact.Managers.OrderManager.Instance().getOrderSettingsByLob(SettingName, LobId, BranchId).then(function (res) {
- let IsCheckAvailability_Lob = res.result.SettingValue;
- if (IsCheckAvailability_Lob == "Yes" || res.result == "") {
- if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && (InvoiceItem.Instance().OrderSettingId == 2 || InvoiceItem.Instance().AutoDc == true)) {
- if ($(".hdn_invoiceid").val() == "0") {
- if (Number(row.find('.prodQuantity').val()) > Number(row.find('.prodAvail').text()) && inventorytypeid != 2) {
- MessageHelper.Instance().showError("Check available quantity", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- if (Number(row.find('.prodAvail').text()) > 0)
- row.find('.prodQuantity').val(row.find('.prodAvail').text());
- else {
- row.find('.prodQuantity').val("0");
- }
- }
- }
- else {
- let Qty = Number(row.find('.prodQuantity').val());
- let AvQty = Number(row.find('.prodAvail').text()) + Number(row.find('.Qty').val());
- if (Qty > AvQty && inventorytypeid != 2) {
- MessageHelper.Instance().showError("Check available quantity", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- row.find('.prodQuantity').val(row.find('.Qty').val());
- }
- }
- }
- if (row.find('.orderItemId').val() != 0 && !row.hasClass('.SplitItem')) {
- if (Number(row.find('.prodQuantity').val()) > Number(row.find('.maxQty').val())) {
- row.find('.prodQuantity').val(Number(row.find('.maxQty').val()));
- InvoiceItem.Instance().update_row_total(element, checkavailability);
- InvoiceItem.Instance().GetDiscounts();
- }
- }
- }
- });
- });
- }
- var rowTotal = 0;
- var rowTotalwithAdjustment = 0;
- if (row.find('.prodPrice').val() != undefined && row.find('.prodQuantity').val() != undefined) {
- rowTotal = row.find('.prodPrice').val().replace("$", "") * (Number(row.find('.prodQuantity').val()));
- rowTotalwithAdjustment = row.find('.prodPrice').val().replace("$", "") * (Number(row.find('.prodQuantity').val()));
- }
- rowTotal += Number(row.find('.hfRowTotalAdjustment').val());
- rowTotalwithAdjustment += Number(row.find('.hfRowTotalAdjustment').val());
- var exciseAmount = element.find(".exciseAmount").val();
- if (exciseAmount != undefined) {
- rowTotal += Number(exciseAmount);
- rowTotalwithAdjustment += Number(exciseAmount);
- }
- var asbAdjAmt = 0;
- asbAdjAmt = row.find('.hfItemAssesableAdjustmentVal').val();
- if (!isNaN(asbAdjAmt))
- rowTotalwithAdjustment += Number(asbAdjAmt);
- rowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowTotal, 2);
- rowTotalwithAdjustment = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowTotalwithAdjustment, 2);
- if (isNaN(rowTotal)) {
- element.find('.prodTotalPrice').html("N/A");
- element.find('.hfRowTotal').val("0");
- element.find('.hfRowTotalwithAdjustment').val("0");
- }
- else {
- element.find('.hfRowTotal').val(rowTotal);
- element.find('.hfRowTotalwithAdjustment').val(rowTotalwithAdjustment);
- element.find('.prodTotalPrice').html(rowTotal);
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- InvoiceItem.Instance().update_discount_total();
- });
- });
- }
- CheckOfferForItem(control) {
- var element = control.parents('.item-row');
- if (element.find('.orderItemId').val() == 0) {
- if ($(".hdn_invoicetypeid").val() == "1") {
- if (Number(element.find('.prodQuantity').val()) <= Number(element.find('.prodAvail').text())) {
- InvoiceItem.Instance().GetPlanItems(element.find('.selectedItemId').val(), element.find('.prodQuantity').val(), element);
- }
- }
- else if ($(".hdn_invoicetypeid").val() == "2") {
- InvoiceItem.Instance().GetPlanItems(element.find('.selectedItemId').val(), element.find('.prodQuantity').val(), element);
- }
- }
- }
- GetPlanItems(ItemId, Quantity, element) {
- var contactId = $(".hdn_organizationid").val();
- if (contactId == 0)
- contactId = $(".hfAutoCompleteId_orgcontactid").val();
- var invoiceapplytype = 1;
- var RowTotal = Number(element.find('.prodTotalPrice').text());
- if ($(".hdn_invoicetypeid").val() == "2") {
- invoiceapplytype = 2;
- RowTotal = Number(element.find(".txtRowTotalwithAdjustment").val());
- }
- $('.item-row').each(function () {
- if ($(this).find('.hfOfferedItemId').val() == ItemId) {
- if ($(this).find('.selectedInvoiceItemId').val() != "0")
- InvoiceItem.Instance().deleted_invoiceItems.push(Number($(this).find('.selectedInvoiceItemId').val()));
- $(this).remove();
- }
- });
- let ApplyDate = moment($('.hfdate_journaldate').val().toString(), "YYYY/MM/DD").format("YYYY-MM-DD");
- Bizgaze.Apps.Transact.Managers.OfferManager.Instance().getoffers(ItemId, Number(contactId), Quantity, invoiceapplytype, RowTotal, ApplyDate).then(function (result) {
- var response = result.result;
- if (response.length > 0) {
- for (var j = 0; j < response.length; j++) {
- if (element.hasClass('SplitItem')) {
- var RowTotal = 0;
- var rowDiscount = 0;
- for (var k = 0; k < InvoiceItem.Instance().SplitedInvoiceItemList.length; k++) {
- if (InvoiceItem.Instance().SplitedInvoiceItemList[k].itemId == ItemId) {
- var discValue = 0;
- var discPercent = 0;
- var Itemrow = InvoiceItem.Instance().SplitedInvoiceItemList[k];
- if (response[j].PayoutValue > 0) {
- discValue = response[j].PayoutValue;
- Itemrow.addlDiscountValue = discValue;
- Itemrow.addlDiscountPercent = 0;
- }
- else if (response[j].PayoutPercent > 0) {
- discPercent = response[j].PayoutPercent;
- Itemrow.addlDiscountPercent = discPercent;
- Itemrow.addlDiscountValue = 0;
- }
- var TotalLineAmount = (Number(Itemrow.quantity) * Number(Itemrow.unitPrice)) + Number(Itemrow.exciseAmount) + Number(Itemrow.Adjustment) + Number(Itemrow.assesableAdjustment);
- var NonExciseAmount = TotalLineAmount - Number(Itemrow.exciseAmount);
- var DiscountAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(NonExciseAmount * (Number(Itemrow.addlDiscountPercent) / 100) + (Number(Itemrow.quantity) * Number(Itemrow.addlDiscountValue)), 2);
- Itemrow.DiscountedAmount = DiscountAmount;
- Itemrow.TotalAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((TotalLineAmount - Number(DiscountAmount)), 3);
- RowTotal += Number(Itemrow.TotalAmount);
- rowDiscount += Number(DiscountAmount);
- }
- }
- if ($(".hdn_invoicetypeid").val() == "2") {
- element.find(".txtRowTotalwithAdjustment").val();
- element.find(".txtRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(RowTotal, 3));
- element.find('#inv_txtdiscount').val();
- element.find('#inv_txtdiscount').val(rowDiscount);
- }
- else {
- element.find('.prodTotalPrice').text('');
- element.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(RowTotal, 3));
- element.find('#inv_txtdiscount').val();
- element.find('#inv_txtdiscount').val(rowDiscount);
- }
- }
- else {
- var discValue = 0;
- var discPercent = 0;
- if (response[j].PayoutValue > 0) {
- discValue = response[j].PayoutValue;
- element.find(".btnInvoice_DiscType option[value='Val']").prop("selected", true);
- element.find('.inv_txtaddldiscount').val(discValue);
- }
- else if (response[j].PayoutPercent > 0) {
- discPercent = response[j].PayoutPercent;
- element.find(".btnInvoice_DiscType option[value='%']").prop("selected", true);
- element.find('.inv_txtaddldiscount').val(discPercent);
- }
- }
- if (response[j].ItemVolumePayouts.length > 0) {
- var OfferItems = response[j].ItemVolumePayouts;
- for (var i = 0; i < OfferItems.length; i++) {
- var emptyRow = {
- orderItemId: 0,
- invoiceItemId: 0,
- itemName: OfferItems[i].ItemName,
- itemId: OfferItems[i].ItemId,
- itemSKU: "",
- unitName: "",
- packSize: 0,
- packCount: 0,
- packs: 0,
- quantity: OfferItems[i].Quantity,
- availPacks: 0,
- availQty: 0,
- listPrice: 0,
- description: OfferItems[i].Description,
- taxGroupName: "",
- taxGroupId: 0,
- isTaxInclusive: $("#hfIsTaxInclusive").val(),
- addlDiscountPercent: OfferItems[i].Discount,
- addlDiscountValue: 0,
- creditNote: 0,
- priceListId: 0,
- batchId: 0,
- unitPrice: 0,
- invoiceallocations: null,
- exciseInvoiceItem: null,
- accountId: 0,
- accountName: "",
- walletId: 0,
- Adjustment: 0,
- TariffNo: "",
- exciseAmount: 0,
- discountName: "",
- discountId: 0,
- refNo: "",
- DiscountGroupId: 0,
- DiscountGroupName: '',
- RefInvoiceItemId: 0,
- MrpId: 0,
- taxAdjustment: 0,
- assesableAdjustment: 0,
- inventoryTypeId: 0,
- dcItemId: 0,
- TotalRowAmount: 0,
- maxQty: 0,
- OfferItemId: ItemId,
- IsFoc: true,
- };
- InvoiceItem.Instance().addDataRow(emptyRow, false);
- }
- }
- }
- }
- });
- }
- TotalAdjustment() {
- if ($('#chk_AutoAdjustment').is(':checked')) {
- var total = $('.nettotal').text();
- var splitTotal = total.split('.');
- var AdjustmentValue = 0;
- var splitedAdjestment = 0;
- $("#txt_Adjustment").val(0);
- $(".hdn_adjustment").val(0);
- if (!isNaN(Number($('#txt_Adjustment').val()))) {
- AdjustmentValue = Number($('#txt_Adjustment').val());
- }
- if (Number(splitTotal[1]) > 0) {
- if (Number(splitTotal[1]) >= 50) {
- splitedAdjestment = (100 - Number(splitTotal[1])) / 100;
- AdjustmentValue += splitedAdjestment;
- $('#txt_Adjustment').val(Number(AdjustmentValue).toFixed(2)).blur();
- $(".hdn_adjustment").val($('#txt_Adjustment').val());
- $("#span_Adjustment").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(AdjustmentValue, 2));
- $('.nettotal').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number(total) + AdjustmentValue), 2));
- }
- else {
- splitedAdjestment = Number(splitTotal[1]) / 100;
- AdjustmentValue -= splitedAdjestment;
- $('#txt_Adjustment').val(Number(AdjustmentValue).toFixed(2));
- $(".hdn_adjustment").val($('#txt_Adjustment').val());
- $("#span_Adjustment").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(AdjustmentValue, 2));
- $('.nettotal').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number(total) + AdjustmentValue), 2));
- }
- }
- }
- else {
- $("#span_Adjustment").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($('#txt_Adjustment').val()), 2));
- $('.nettotal').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number($('.nettotal').text()) + Number($('#txt_Adjustment').val())), 2));
- }
- }
- update_discount_total() {
- var item_total = Number($("#grosstotal").html()) - Number($("#totalItemDiscount").html());
- var nettotal = Number($("#totalTax").text()) + Number(item_total);
- var sub_dis_total = 0;
- var prev_dis_total = 0;
- $(".discount-row,.netdiscount-row").each(function () {
- if ($(this).find(".percentage").val() != undefined) {
- var ele = $(this);
- var tt = prev_dis_total;
- if (!isNaN(tt))
- sub_dis_total += Number(tt);
- var percent = ele.find(".percentage").val();
- var value = ele.find(".fixedvalue").val();
- var adjustment = 0;
- if (percent == "")
- percent = 0;
- if (value == "")
- value = 0;
- var totaldiscount = 0;
- var totalElement = $(this).find(".netdiscount-row-total");
- if (totalElement.length != 0) {
- totaldiscount = (Number(percent) * Number(nettotal - sub_dis_total) / 100) + Number(value) + Number(adjustment);
- }
- else
- totaldiscount = (Number(percent) * Number(item_total - sub_dis_total) / 100) + Number(value) + Number(adjustment);
- ele.find(".discount-row-total").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totaldiscount, 2));
- ele.find(".netdiscount-row-total").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totaldiscount, 2));
- prev_dis_total = totaldiscount;
- }
- });
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- update_expense_total() {
- var item_total = Number($("#grosstotal").html()) - Number($("#totalItemDiscount").html());
- var nettotal = Number($("#totalTax").text()) + Number(item_total);
- var sub_dis_total = 0;
- var prev_dis_total = 0;
- $(".expense-row").each(function () {
- if ($(this).find(".exppercentage").val() != undefined) {
- var ele = $(this);
- var tt = prev_dis_total;
- if (!isNaN(tt))
- sub_dis_total += Number(tt);
- var percent = ele.find(".exppercentage").val();
- var value = ele.find(".expfixedvalue").val();
- var adjustment = 0;
- if (percent == "")
- percent = 0;
- if (value == "")
- value = 0;
- var totalexpense = (Number(percent) * Number(nettotal - sub_dis_total) / 100) + Number(value) + Number(adjustment);
- ele.find(".expense-row-total").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalexpense, 2));
- prev_dis_total = totalexpense;
- }
- });
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- RefreshItemRowDetaisl(element) {
- if (element.filter('.SplInvoiceItemRow').length > 0) {
- Bizgaze.Apps.Transact.Controls.Invoices.SplitItem.Instance().update_Discount(element);
- var row = InvoiceItem.Instance().SplitedInvoiceItemList.find(x => x.invoiceItemId == element.find(".hf_selectedInvoiceItemId").val());
- if (row != undefined) {
- row.assesableAdjustment = element.find('.hf_ItemAssesableAdjustmentVal').val();
- row.TotalAmount = element.find(".hf_RowTotal").val();
- }
- Bizgaze.Apps.Transact.Controls.Invoices.SplitItem.Instance().updateQuantity();
- InvoiceItem.Instance().update_total();
- }
- else {
- InvoiceItem.Instance().update_total();
- }
- }
- editInvItemTaxAllocs(invoiceItemId, taxGroupId, itemId, orderItemId, element) {
- var prvs = InvoiceItem.Instance().invItemTaxAdjustmentList;
- var obj = {
- invoiceItemId: invoiceItemId,
- taxGroupId: taxGroupId,
- itemId: itemId,
- orderItemId: orderItemId,
- element: element,
- };
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/components/invoices/invoiceitemtaxalloc.js", function () {
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(obj, "", Bizgaze.Apps.Transact.Components.Invoices.InvoiceItemTaxAloc.Instance(), null, Unibase.Platform.Helpers.Size.Large);
- });
- InvoiceItem.Instance().invItemTaxAdjustmentList = prvs;
- }
- GetCustomerTurnOver() {
- $(".txt_tcsadjustment").val("0");
- $("#chk_tcsapplied").unbind();
- $(".number_tcsamount").prop("disabled", true);
- $(".div_tcsadjustment").addClass("floating-label-form-group-with-value");
- $("#chk_tcsapplied").change(function () {
- if ($(this).prop('checked') == true && InvoiceItem.Instance().EnableTenantTcs == false && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) {
- MessageHelper.Instance().showError("Please Submit TCS Declaration", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- $("#hdnchk_tcsapplied").val("false");
- $('#chk_tcsapplied').prop('checked', false);
- }
- else {
- if ($('#chk_AutoAdjustment').prop("checked") == true) {
- $("#txt_Adjustment").val(0);
- $(".hdn_adjustment").val(0);
- }
- if ($(this).prop('checked') == true && $(".hdn_invoicetypeid").val() == "1") {
- bootbox.confirm("Confirm if sale value is > 50,00,000 for this customer.In this current Financial Year.", function (result) {
- if (result) {
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- else {
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- $('#chk_tcsapplied').prop('checked', false);
- $("#hdnchk_tcsapplied").val("false");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- });
- }
- else if ($(this).prop('checked') == true) {
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- else {
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- }
- });
- $(".txt_tcsadjustment").unbind();
- $(".txt_tcsadjustment").blur(function () {
- if ($('#chk_AutoAdjustment').prop("checked") == true) {
- $("#txt_Adjustment").val(0);
- $(".hdn_adjustment").val(0);
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- });
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- $("#chk_tcsapplied").prop("checked", false);
- $("#chk_tcsapplied").prop("disabled", false);
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getCustomerTurnOver($(".hdn_organizationid").val(), $(".hdn_invoiceid").val(), InvoiceItem.Instance().formatDate($(".date_journaldate").val()), $(".hdn_invoicetypeid").val()).then(function (response) {
- if (response.result != null) {
- $(".number_tcstaxrate").val(response.result.TaxRate);
- if (response.result.TCSTaxCodeId != 0) {
- $(".hdn_tcstaxcodeid").val(response.result.TCSTaxCodeId);
- $(".hdn_tcstaxcodeaccountid").val(response.result.TCSTaxCodeAccountId);
- $(".number_tcstaxrate").prop("disabled", true);
- }
- InvoiceItem.Instance().TurnOver = response.result.TurnOver;
- InvoiceItem.Instance().ContactTcsEnable = response.result.Enable;
- InvoiceItem.Instance().EnableTenantTcs = response.result.EnableTenantTcs;
- InvoiceItem.Instance().PanAvailable = response.result.PanAvailable;
- InvoiceItem.Instance().TaxRate = response.result.TaxRate;
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2") {
- if (InvoiceItem.Instance().ContactTcsEnable == true && InvoiceItem.Instance().EnableTenantTcs == true) {
- $("#chk_tcsapplied").prop("checked", true);
- $("#hdnchk_tcsapplied").val("true");
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- $(".number_tcsamount").prop("disabled", true);
- }
- else if (InvoiceItem.Instance().TurnOver > 5000000 && $(".hdn_invoicetypeid").val() == "1") {
- $("#chk_tcsapplied").prop("checked", true);
- $("#chk_tcsapplied").prop("disabled", "disabled");
- $("#hdnchk_tcsapplied").val("true");
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- $(".number_tcsamount").prop("disabled", true);
- }
- }
- else if ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") {
- $("#chk_tcsapplied").prop("checked", false);
- $("#hdnchk_tcsapplied").val("false");
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- }
- if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $('#hfInv_RefInvoiceId').val() == 0 && $("#hf_AppSettingName").val() == "Create Return") {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(($(".hdn_invoicetypeid").val())).then(function (res) {
- if (res.result != null && res.result != "") {
- InvoiceItem.Instance().TaxRate = res.result.TcsTaxRate;
- $(".number_tcstaxrate").val(res.result.TcsTaxRate);
- $(".hdn_tcstaxcodeid").val(response.result.TcsTaxCodeId);
- if (res.result.TcsTaxCodeId != 0) {
- $(".number_tcstaxrate").prop("disabled", true);
- }
- $(".number_tcsamount").prop("disabled", true);
- }
- });
- }
- }
- });
- }
- bindContactName() {
- Unibase.Platform.Forms.Managers.TagManager.Instance().GetTagItemsByUserId(Unibase.Platform.Membership.Infos.Identity.getCurrentUser().userId).then(function (response) {
- if (response.result.length == 1) {
- InvoiceItem.instance.fileCacheHelper.loadJsFile("apps/crm/lobs/managers/lobmanager.js", function () {
- Bizgaze.Apps.CRM.Lobs.Managers.LobManager.Instance().getLobByTagGroupId(response.result[0].TagGroupId).then(function (res) {
- let LobId = res.result.LobId;
- Bizgaze.Apps.CRM.Lobs.Managers.LobManager.Instance().getLobByLobId(LobId).then(function (result) {
- if (result.result != null) {
- if (result.result.DefaultContactId != 0) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
- Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getOrgContact(result.result.DefaultContactId).then(function (response) {
- if (response.result != null) {
- if (response.result.OrgContactName == null)
- response.result.OrgContactName = "";
- var _Name = new Option(response.result.OrgContactName, response.result.OrgContactId.toString(), false, false);
- $(".txtAutoComplete_orgcontactid").append(_Name).trigger("change");
- $(".hfAutoCompleteId_orgcontactid").val(response.result.OrgContactId);
- InvoiceItem.Instance().LoadContactDetails();
- }
- });
- });
- }
- }
- });
- });
- });
- }
- });
- }
- GetDiscounts() {
- if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3")) {
- let contactid = Number($(".hdn_organizationid").val());
- let invoicedate = moment($('.date_journaldate').val().toString(), "DD/MM/YYYY").format("YYYY-MM-DD");
- if ($(".hdn_invoicetypeid").val() == "3")
- invoicedate = moment($('.date_refdate').val().toString(), "DD/MM/YYYY").format("YYYY-MM-DD");
- var ItemList = [];
- $(".InvoiceItems").find(".item-row").each(function () {
- if (!$(this).hasClass('SplitItem')) {
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0 && Number($(this).find('.prodTotalPrice').text()) > 0) {
- var Quantity = Number($(this).find(".prodQuantity").val());
- let ItemId = Number($(this).find(".selectedItemId").val());
- ItemList.push({
- ItemId: ItemId,
- Quantity: Number(Quantity),
- ContactId: contactid,
- InvoiceDate: invoicedate
- });
- }
- }
- });
- for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
- ItemList.push({
- ItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId),
- Quantity: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity),
- ContactId: contactid,
- InvoiceDate: invoicedate
- });
- }
- Bizgaze.Apps.Transact.Managers.OfferManager.Instance().getdiscounts(ItemList).then(function (response) {
- var data = response.result;
- var InvItemId = 0;
- var discription = "";
- if ($(".netdiscount-row[style='pointer-events:none']").length == 0 && $(".hdn_invoicetypeid").val() == "3") {
- InvoiceItem.Instance().isOfferChargeApplied = false;
- if (data != null)
- data.PayoutValue == 0;
- }
- $('.netdiscount-row').each(function () {
- var invoiceitemid = $(this).find(".selectedInvoiceItemId").val();
- if ((data != null && (data.PayoutValue > 0 || InvoiceItem.Instance().isOfferChargeApplied) && $(this).find('.selectedItemId').val() != undefined && Number($(this).find('.selectedItemId').val()) != 0 && data.ItemId == Number($(this).find('.selectedItemId').val())) || (InvoiceItem.Instance().isOfferChargeApplied && invoiceitemid != undefined && invoiceitemid != 0 && data.ItemId == Number($(this).find('.selectedItemId').val()))) {
- $(this).remove();
- if (invoiceitemid != undefined || invoiceitemid != 0) {
- InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
- InvItemId = Number(invoiceitemid);
- discription = $(this).find('.discountDesc').val().toString();
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- });
- if (data != null && data.PayoutValue == 0) {
- if ($(".netdiscount-row[style='pointer-events:none']").length > 0) {
- var invoiceitemid = $(".netdiscount-row[style='pointer-events:none']").find(".selectedInvoiceItemId").val();
- $(".netdiscount-row[style='pointer-events:none']").remove();
- if (invoiceitemid != undefined || invoiceitemid != 0) {
- InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
- InvItemId = Number(invoiceitemid);
- $(".hdn_isofferchargeapplied").val('false');
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- }
- if ((data != null && data.PayoutValue > 0)) {
- if ($(".netdiscount-row[style='pointer-events:none']").length > 0) {
- var itemid = $(".netdiscount-row[style='pointer-events:none']").find(".selectedItemId").val();
- if (data.ItemId != itemid) {
- var invoiceitemid = $(".netdiscount-row[style='pointer-events:none']").find(".selectedInvoiceItemId").val();
- $(".netdiscount-row[style='pointer-events:none']").remove();
- if (invoiceitemid != undefined || invoiceitemid != 0) {
- InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
- InvItemId = Number(invoiceitemid);
- }
- InvoiceItem.Instance().update_total();
- InvoiceItem.Instance().TotalAdjustment();
- }
- }
- let Index = Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().deleted_invoiceItems.findIndex(x => x == InvItemId);
- if (Index != -1) {
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().deleted_invoiceItems.splice(Index, 1);
- }
- var itemRow = {
- orderItemId: 0,
- invoiceItemId: InvItemId,
- itemName: data.ItemName,
- itemId: data.ItemId,
- itemSKU: '',
- unitName: "",
- packSize: 0,
- packCount: 0,
- packs: 0,
- quantity: 0,
- availPacks: 0,
- availQty: 0,
- listPrice: 0,
- description: discription,
- taxGroupName: "",
- taxGroupId: 0,
- isTaxInclusive: $("#hf_istaxinclusive").val(),
- addlDiscountPercent: 0,
- addlDiscountValue: data.PayoutValue,
- creditNote: 0,
- priceListId: 0,
- batchId: 0,
- unitPrice: 0,
- invoiceallocations: null,
- exciseInvoiceItem: null,
- accountId: 0,
- accountName: "",
- walletId: 0,
- Adjustment: 0,
- IsFoc: false,
- TariffNo: "",
- exciseAmount: 0,
- discountName: "",
- discountId: 0,
- refNo: "",
- DiscountGroupId: 0,
- DiscountGroupName: '',
- RefInvoiceItemId: 0,
- MrpId: 0,
- taxAdjustment: 0,
- assesableAdjustment: 0,
- inventoryTypeId: 5,
- dcItemId: 0,
- TotalRowAmount: 0,
- maxQty: 0,
- OfferItemId: 0
- };
- InvoiceItem.instance.addDataRow(itemRow, false);
- }
- });
- }
- }
- GetOnInvoiceDiscountItem(element) {
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3") {
- var itemid = element.find('.selectedItemId').val();
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemById(Number(itemid)).then(function (response) {
- var data = response.result;
- let invoiceid = $(".hdn_invoiceid").val();
- if (invoiceid == undefined || invoiceid == "null")
- invoiceid = 0;
- if (data != null && !data.Sellable && !data.Purchasable)
- element.attr("style", "pointer-events:none");
- if (invoiceid == "0")
- element.addClass("OnInvoiceOfferItem");
- });
- }
- }
- IsCustomerIndustrial(LobId, OrganizationId) {
- var url1 = "apis/v4/bizgaze/transact/invoice/checkisenablesalespipeline/invoicetype/" + $(".hdn_invoicetypeid").val() + "/lobid/" + LobId + "/organizationid/" + OrganizationId;
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getIsEnableSalesPipeline(url1).then(function (response) {
- if (response.result == false) {
- $(".section_Ebs").addClass("hidden");
- }
- else {
- $(".section_Ebs").removeClass("hidden");
- }
- });
- }
- loadChangeTaxGroupAutoComplete() {
- var hfTaxgroup = $("#hdn_changetaxgroup");
- AutoCompleteHelper.getHelper().Create("#change_taxgroup", hfTaxgroup, _appsettings.server_url() + "/apis/v4/bizgaze/transact/tax/taxgroupautocomplete", function (result) {
- });
- }
- ShowOrHideEInvoiceButton() {
- let instance = Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance();
- var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var invoiceid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_invoiceid").Value);
- instance.fileCacheHelper.loadJsFiles(["apps/transact/managers/einvoice/einvoicemanager.js"], function () {
- Bizgaze.Apps.Transact.Managers.EInvoiceManager.Instance().geteinvoicebyinvoiceid(invoiceid).then(function (res) {
- if (res.result != null) {
- if (res.result.EInvoiceStatusId == 2 || res.result.AckNo == null)
- $(".DetailSetting_" + installedAppId + "_e-Invoice").removeClass("hidden");
- else
- $(".DetailSetting_" + installedAppId + "_e-Invoice").addClass("hidden");
- }
- });
- });
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new InvoiceItem();
- }
- return this.instance;
- }
- }
- Controls.InvoiceItem = InvoiceItem;
- })(Controls = Transact.Controls || (Transact.Controls = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
-
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Controls;
- (function (Controls) {
- class CustomerCreditHealth extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.ContainerId = "";
- this.PopUpContainerId = "";
- }
- init(formpropertyid, prop, callback) {
- var instance = this;
- instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
- instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
- }
- loadControl(containerid, prop) {
- let instance = this;
- instance.ContainerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
- let html = instance.getCustomerCreditHealth_html();
- $("#" + containerid).html(html);
- }
- getCustomerCreditHealth_html() {
- var html = '<div class="row"><div class=" col-sm-4" id="div_CreditLimit"><div class="card card-sm shadow-hover " id="kpi_card" style="height:auto;">' +
- '<div class="card-body" ><span class="d-block font-15 font-weight-500 text-dark">' +
- 'Credit Limit </span><div class="mt-10"><span class="h4 mb-10 block"><span id="span_CreditLimit" class="display-5 font-weight-400 text-dark">0</span></span></div></div></div></div>' +
- '<div class=" col-sm-4" id="div_AvailLimit"><div class="card card-sm shadow-hover " id="kpi_card" style="height:auto;"><div class="card-body">' +
- ' <span style=" text-transform: capitalize; " class="d-block font-15 font-weight-500 text-dark"> Avail Limit </span><div class="mt-10"><span class="h4 mb-10 block"><span id="span_AvailLimit" class="display-5 font-weight-400 text-dark">0</span>' +
- '</span></div></div></div></div><div class=" col-sm-4" id="div_OverDue"><div class="card card-sm shadow-hover " id="kpi_card" style="height:auto;"><div class="card-body">' +
- '<span class="d-block font-15 font-weight-500 text-dark"> Over Due </span><div class="mt-10">' +
- '<span class="h4 mb-10 block text-underline"><a id="lnk_OverDue"><span id="span_OverDue" class="display-5 font-weight-400 text-dark">0</span></a></span></div></div></div></div>' +
- '</div ><div class="row"><div class=" col-sm-4" id="div_Due"><div class="card card-sm shadow-hover " id="kpi_card" style="height:auto;"><div class="card-body"><span class="d-block font-15 font-weight-500 text-dark">' +
- 'Due</span><div class="mt-10"><span class="h4 mb-10 block text-underline"><a id="lnk_Due"><span id="span_Due" class="display-5 font-weight-400 text-dark">0</span></a>' +
- ' </span></div></div></div></div><div class=" col-sm-4" id="div_Credits"><div class="card card-sm shadow-hover " id="kpi_card" style="height:auto;"><div class="card-body">' +
- '<span class="d-block font-15 font-weight-500 text-dark"> Credits </span><div class="mt-10">' +
- ' <span class="h4 mb-10 block text-underline"><a id="lnk_Credits"><span id="span_Credits" class="display-5 font-weight-400 text-dark">0</span></a></span>' +
- ' </div></div></div></div><div class=" col-sm-4" id="div_Clearance"><div class="card card-sm shadow-hover " id="kpi_card" style="height:auto;">' +
- ' <div class="card-body"><span class="d-block font-15 font-weight-500 text-dark"> Clearance</span>' +
- ' <div class="mt-10"><span class="h4 mb-10 block text-underline"><a id="lnk_Clearance"><span id="span_Clearance" class="display-5 font-weight-400 text-dark">0</span></a></span>' +
- ' </div></div></div></div></div>';
- return html;
- }
- loadControlSettings(controlsettingjson, formpropertyid) {
- return null;
- }
- loadPropertySettings(propertysettings, formpropertyid) {
- return null;
- }
- bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
- return null;
- }
- getCreditHealth(OrgContactId, OrganizationId, Type) {
- var instance = this;
- instance.ContainerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
- let ContactId = Number(OrganizationId == 0 ? OrgContactId : OrganizationId);
- if (ContactId == 0) {
- return;
- }
- instance.bindKPIEvents(ContactId, Type);
- instance.getCCH_KPIDetails(OrgContactId, OrganizationId, Type);
- }
- bindKPIEvents(ContactId, Type) {
- let instance = this;
- let TypeName = "Sales";
- if (Type.toLowerCase().indexOf("purchase") != -1) {
- TypeName = "Purchase";
- }
- instance.fileCacheHelper.loadJsFile("apps/transact/controls/orders/credithealth.js", function () {
- $("#" + instance.ContainerId).find("#div_Due").unbind().click(function () {
- Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_Due_CCH_" + TypeName + "Orders").then(function (res) {
- if (res.result != null && res.result != "") {
- var filter = [];
- filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 });
- Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_Due_CCH_" + TypeName + "Orders", null, filter, null);
- }
- else {
- instance.getKPIPopUp("Due", "div_Due");
- instance.getInvoiceDetails(ContactId, "Due");
- }
- });
- });
- $("#" + instance.ContainerId).find('#div_OverDue').unbind().click(function () {
- Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_OverDue_CCH_" + TypeName + "Orders").then(function (res) {
- if (res.result != null && res.result != "") {
- var filter = [];
- filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 });
- Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_OverDue_CCH_" + TypeName + "Orders", null, filter, null);
- }
- else {
- instance.getKPIPopUp("Over Due", "div_Due");
- instance.getInvoiceDetails(ContactId, "OverDue");
- }
- });
- });
- $("#" + instance.ContainerId).find("#div_Credits").unbind().click(function () {
- Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_Credits_CCH_" + TypeName + "Orders").then(function (res) {
- if (res.result != null && res.result != "") {
- var filter = [];
- filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 });
- Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_Credits_CCH_" + TypeName + "Orders", null, filter, null);
- }
- else {
- instance.getKPIPopUp("Credits", "div_Credit");
- instance.getCreditNotesDetails(ContactId);
- }
- });
- });
- $("#" + instance.ContainerId).find("#div_Clearance").unbind().click(function () {
- Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_Clearance_CCH_Orders").then(function (res) {
- if (res.result != null && res.result != "") {
- var filter = [];
- filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 });
- Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_Clearance_CCH_Orders", null, filter, null);
- }
- else {
- instance.getKPIPopUp("Clearance", "div_Clearance");
- instance.getPaymentDetails(ContactId);
- }
- });
- });
- });
- }
- getKPIPopUp(WidgetTitle, CurrentDiv) {
- let instance = this;
- instance.PopUpContainerId = '_modal_bizgaze_popup_' + moment().unix();
- instance.navigationHelper.popup(0, instance.PopUpContainerId, Bizgaze.Apps.Transact.Orders.CreditHealth.Instance(), null, Unibase.Platform.Helpers.Size.ExtraLarge);
- $("#" + instance.PopUpContainerId).find("." + CurrentDiv).removeClass("hidden");
- $("#" + instance.PopUpContainerId).find(".title_widget").text(WidgetTitle);
- $("#" + instance.PopUpContainerId).find("#widget_list_container").empty();
- }
- noData() {
- let instance = this;
- $("#" + instance.PopUpContainerId).find(".header_list").html('<div class="alert alert-info">There is no Data</div>');
- $("#" + instance.PopUpContainerId).find(".span_Listsearch_count").text("0");
- $("#" + instance.PopUpContainerId).find(".header_list").removeClass("d-none");
- }
- getKPIData(ReportName, OrganizationId, ResultColName, elem) {
- let instance = this;
- let resultData = 0;
- let ReportUniqueId = "Bizgaze_Platform_Analytics_Reports_" + ReportName;
- let _numberHelper = Unibase.Core.Helpers.NumberHelper.Instance();
- Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId(ReportUniqueId).then(function (res) {
- if (res.result != null && res.result != "") {
- var postData = {
- "ReportId": res.result.ReportId,
- "page": 1,
- "pageSize": 20,
- "Filter": [],
- "FilterId": 0,
- "InputParameters": [
- {
- "Key": "organizationid",
- "Value": OrganizationId.toString(),
- "ExpOp": 1
- }
- ],
- "SearchTerm": null,
- "DateFilter": null,
- "DisplayModeTypeId": 1,
- "FromDate": "",
- "ToDate": "",
- "IsPortletWidget": false,
- "IsShowAll": false,
- "SortColumn": ""
- };
- Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportInfo(postData).then(function (report_res) {
- if (report_res.result != null) {
- if (report_res.result.ReportJsonData.Result.Data != null && report_res.result.ReportJsonData.Result.Data != "") {
- let val = JSON.parse(report_res.result.ReportJsonData.Result.Data);
- resultData = _numberHelper.roundNumber(val[0][ResultColName], 2);
- $("#" + instance.ContainerId).find("#" + elem).text(resultData);
- }
- }
- });
- }
- });
- }
- getCCH_KPIDetails(OrgContactId, OrganizationId, Type) {
- let instance = this;
- let TypeName = "Sales";
- let CreditLimit = 0;
- let AvailLimit = 0;
- let OverDue = 0;
- let Due = 0;
- let Credits = 0;
- let ClearanceAmount = 0;
- Bizgaze.Apps.Transact.Managers.OrderManager.Instance().getCustomerCreditHealth(OrgContactId, OrganizationId).then(function (response) {
- let data = response.result;
- let _numberHelper = Unibase.Core.Helpers.NumberHelper.Instance();
- if (data != "" && data != null) {
- CreditLimit = _numberHelper.roundNumber(data.CreditLimit, 2);
- AvailLimit = _numberHelper.roundNumber(data.AvailLimit, 2);
- OverDue = _numberHelper.roundNumber(data.OverDue, 2);
- Due = _numberHelper.roundNumber(data.OutStandingAmount, 2);
- Credits = _numberHelper.roundNumber(data.Credits, 2);
- ClearanceAmount = _numberHelper.roundNumber(data.ClearanceAmount, 2);
- $("#" + instance.ContainerId).find("#span_CreditLimit").text(CreditLimit);
- $("#" + instance.ContainerId).find("#span_AvailLimit").text(AvailLimit);
- $("#" + instance.ContainerId).find("#span_OverDue").text(OverDue);
- $("#" + instance.ContainerId).find("#span_Due").text(Due);
- $("#" + instance.ContainerId).find("#span_Credits").text(Credits);
- $("#" + instance.ContainerId).find("#span_Clearance").text(ClearanceAmount);
- }
- if (Type.toLowerCase().indexOf("purchase") != -1) {
- TypeName = "Purchase";
- }
- instance.getKPIData("CreditLimit_CCH_OrdersKPIWidget", OrganizationId, "creditlimit", "span_CreditLimit");
- instance.getKPIData("AvailLimit_CCH_OrdersKPIWidget", OrganizationId, "availlimit", "span_AvailLimit");
- instance.getKPIData("OverDue_CCH_" + TypeName + "OrdersKPIWidget", OrganizationId, "overdue", "span_OverDue");
- instance.getKPIData("DueAmount_CCH_" + TypeName + "OrdersKPIWidget", OrganizationId, "outstandingamount", "span_Due");
- instance.getKPIData("Credits_CCH_" + TypeName + "OrdersKPIWidget", OrganizationId, "credits", "span_Credits");
- instance.getKPIData("ClearanceAmount_CCH_OrdersKPIWidget", OrganizationId, "clearanceamount", "span_Clearance");
- });
- }
- getInvoiceDetails(ContactId, DueorOverDue) {
- let instance = this;
- let IsOverDue = false;
- if (DueorOverDue == "OverDue") {
- IsOverDue = true;
- }
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getPendingSalesInvoicesByContactId(ContactId, IsOverDue).then(function (response) {
- var PendingInvoices = response.result;
- if (PendingInvoices == "") {
- instance.noData();
- }
- else {
- var CurrentDate = new Date(), IsExpired = false, html = '';
- $("#" + instance.PopUpContainerId).find("#widget_list_container").html('<li class="list-group-item list-Report-Due hidden"></li>');
- for (var i = 0; i < PendingInvoices.length; i++) {
- var InvoiceItem = PendingInvoices[i];
- var Amount = InvoiceItem.TotalAmount;
- var DueDate = new Date(InvoiceItem.DueDate);
- var PaidAmount = Number(InvoiceItem.PaidAmount);
- var DueAmount = Number(InvoiceItem.TotalAmount) - Number(InvoiceItem.PaidAmount);
- if (DueDate < CurrentDate) {
- IsExpired = true;
- }
- html += '<li class="list-group-item data-list-item d-none d-sm-block"><div class="row px-2 text-dark d-flex align-items-center"><div class="col-sm-2 pl-0 pr-0"><span><span class="list-item-main-title">' + InvoiceItem.InvoiceNo + '</span> (' + InvoiceItem.LobShortCode + ')</span><br /><span>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate(InvoiceItem.InvoiceDate) + '</span><br></div><div class="col-sm-2 pl-0 pr-0"><span>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(InvoiceItem.RefDate, 'DD MMM YYYY') + '</span><br><span>' + InvoiceItem.RefNo + '</span></div><div class="col-sm-2 pl-0 pr-0"><span>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(DueDate, 'DD MMM YYYY') + '</span><br /><span>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().daysFromNow(InvoiceItem.InvoiceDate) + ' Days ago</span></div><div class="col-sm-2 pl-0 pr-0 text-right">' + Amount + '</div><div class="col-sm-2 text-right pl-0 pr-0">' + PaidAmount + '</div><div class="col-sm-2 pl-0 pr-0 text-right">' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(DueAmount, 2) + '</div></div></li><li class="data-list-item d-block d-sm-none p-1"><div class="card m-0 p-2 text-dark"><div><span class="list-item-main-title">' + InvoiceItem.InvoiceNo + '</span> (' + InvoiceItem.LobShortCode + ')</div><div>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate(InvoiceItem.InvoiceDate) + '</div><ul class="d-flex justify-content-between align-items-center"><li>Due Date/</li><li>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(DueDate, 'DD MMM YYYY') + '</li></ul><ul class="d-flex justify-content-between align-items-center"><li>Days</li><li>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().daysFromNow(InvoiceItem.InvoiceDate) + ' Days ago</li></ul><ul class="d-flex justify-content-between align-items-center"><li>Total</li><li>' + Amount + '</li></ul><ul class="d-flex justify-content-between align-items-center"><li>Paid</li><li>' + PaidAmount + '</li></ul><ul class="d-flex justify-content-between align-items-center"><li>Due</li><li>' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(DueAmount, 2) + '</li></ul></div></li>';
- }
- $("#" + instance.PopUpContainerId).find(".span_Listsearch_count").text(PendingInvoices.length);
- if (DueorOverDue == "Due" || (DueorOverDue == "OverDue" && IsExpired == true)) {
- $("#" + instance.PopUpContainerId).find(".list-Report-Due:last").after(html);
- }
- else {
- instance.noData();
- }
- }
- });
- }
- getPaymentDetails(ContactId) {
- let instance = this;
- Bizgaze.Apps.Transact.Managers.PaymentManager.Instance().getAllPendingPayments(ContactId).then(function (response) {
- var PendingPayments = response.result;
- if (PendingPayments == "") {
- instance.noData();
- }
- else {
- $("#" + instance.PopUpContainerId).find("#widget_list_container").html('<li class="list-group-item list-Report-Clearance hidden"></li>');
- var html = '';
- for (var i = 0; i < PendingPayments.length; i++) {
- var PaymentItem = PendingPayments[i];
- var CreatedDate = new Date(PaymentItem.CreatedDate);
- var currdate = new Date();
- var diff = new Date(currdate - CreatedDate);
- var days = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(diff / 1000 / 60 / 60 / 24, 2);
- html += '<li class="list-group-item d-none d-sm-block"><div class="row "><div class="col-sm-4 pl-2 pr-0"><span ><span class="list-item-main-title">' + PaymentItem.PaymentNo + '</span> (' + PaymentItem.RefNo + ')</span><br/><span>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate(PaymentItem.PaymentDate) + '</span></div><div class="col-sm-2 pl-0 pr-0"><span>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(PaymentItem.CreatedDate, 'DD MMM YYYY') + '</span><br><span>' + PaymentItem.ContactName + '</span></div><div class="col-sm-2 ">' + days + '</div><div class="col-sm-2 text-right">' + PaymentItem.TotalAmount + '</div><div class="col-sm-2 text-right"> ' + PaymentItem.StageName + '</div></div></li><li class="data-list-item d-block d-sm-none p-1"><div class="card p-2 text-dark m-0"><ul class="d-flex justify-content-between align-items-center"><li><div><span class="list-item-main-title">' + PaymentItem.PaymentNo + '</span> (' + PaymentItem.RefNo + ')</div></li><li>' + PaymentItem.StageName + '</li></ul><ul class="d-flex justify-content-between align-items-center"><li>Days ago</li><li>' + days + '</li></ul><ul class="d-flex justify-content-between align-items-center"><li>Total</li><li>' + PaymentItem.TotalAmount + '</li></ul></div></li>';
- }
- $("#" + instance.PopUpContainerId).find(".list-Report-Clearance:last").after(html);
- $("#" + instance.PopUpContainerId).find(".span_Listsearch_count").text(PendingPayments.length);
- }
- });
- }
- getCreditNotesDetails(ContactId) {
- var instance = this;
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getCreditNotesByContactId(ContactId).then(function (response) {
- var CreditNotes = response.result;
- if (CreditNotes.length != 0) {
- $("#" + instance.PopUpContainerId).find("#widget_list_container").html('<li class="list-group-item list-Report-Credits hidden"></li>');
- var html = '';
- for (var i = 0; i < CreditNotes.length; i++) {
- var CreditNoteItem = CreditNotes[i];
- var ConsumedAmount = CreditNoteItem.PaidAmount;
- var TotalAmount = CreditNoteItem.TotalAmount;
- var RemainingCredit = Number(CreditNoteItem.TotalAmount) - Number(CreditNoteItem.PaidAmount);
- var html = '<li class="list-group-item text-dark"><div class="d-none d-sm-block"><div class="row"><div class="col-sm-4"><span class="list-item-main-title">' + CreditNoteItem.InvoiceNo + '</span> <span>(' + CreditNoteItem.LobShortCode + ')</span> </br><span>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(CreditNoteItem.InvoiceDate, 'DD MMM YYYY') + '</span></div><div class="col-sm-2"><span>' + CreditNoteItem.RefNo + '</span><br /><span>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(CreditNoteItem.RefDate, 'DD MMM YYYY') + '</span></div><div class="col-sm-2 text-right">' + TotalAmount + '</div><div class="col-sm-2 text-right">' + ConsumedAmount + '</div><div class="col-sm-2 text-right">' + RemainingCredit + '</div></div></div><div class="d-block d-sm-none"><div class="card p-2 m-0"><div><span class="list-item-main-title">' + CreditNoteItem.InvoiceNo + '</span> <span>(' + CreditNoteItem.LobShortCode + ')</span> </br><span>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(CreditNoteItem.InvoiceDate, 'DD MMM YYYY') + '</span></div><ul class="d-flex justify-content-between align-items-center"> <li>Total</li><li>' + TotalAmount + '</li></ul><ul class="d-flex justify-content-between align-items-center"> <li>Consumed </li><li>' + ConsumedAmount + '</li></ul><ul class="d-flex justify-content-between align-items-center"> <li>Remaining</li><li>' + RemainingCredit + '</li></ul></div></div></li>';
- $("#" + instance.PopUpContainerId).find(".list-Report-Credits:last").after(html);
- }
- }
- $("#" + instance.PopUpContainerId).find(".span_Listsearch_count").text(CreditNotes.length);
- if (CreditNotes.length == 0 || CreditNotes == "") {
- $("#" + instance.PopUpContainerId).find(".header_list").removeClass("d-md-block").addClass("d-none");
- }
- instance.getAdvancePayments(ContactId, CreditNotes.length);
- });
- }
- getAdvancePayments(ContactId, CreditsCount) {
- let instance = this;
- Bizgaze.Apps.Transact.Managers.PaymentManager.Instance().getAdvancePaymentsByOrgId(ContactId).then(function (response) {
- var AdvancePayments = response.result;
- $("#" + instance.PopUpContainerId).find("#widget_list_container").append('<div class="card card-advancePayments m-0 py-2 px-3"><div class="d-flex justify-content-between align-items-center"><div class="biz-highlight-bg-color font-16 font-weight-600" href="javascript:;"><i class="fa fa-angle-down d-none"></i><i class="fa fa-angle-right"></i><span class="ml-10 title_widget">Advance Payments</span></div><div class="d-flex align-items-center card-action-wrap"><span class="pull-right badge badge-light badge-pill badge-outline mr-10 advacepayment_Listsearch_count"></span></div></div></div><li class="list-group-item list-Report-Payments hidden"></li>');
- if (AdvancePayments != "") {
- var advancepaymentcount = AdvancePayments.length;
- $(".advacepayment_Listsearch_count").html(advancepaymentcount);
- if (AdvancePayments.length == 0 && CreditsCount == 0) {
- instance.noData();
- $(".card-advancePayments").addClass("d-none");
- }
- for (var i = 0; i < AdvancePayments.length; i++) {
- var AdvancePaymentItem = AdvancePayments[i];
- var ConsumedAmount = AdvancePaymentItem.AdjustedAmount;
- var TotalAmount = AdvancePaymentItem.TotalAmount;
- var RemainingCredit = Number(AdvancePaymentItem.TotalAmount) - Number(AdvancePaymentItem.AdjustedAmount);
- var ExpTextColor = "text-info";
- var html = '<li class="list-group-item"><div class="panel wrapper-xs panel-success text-dark d-none d-sm-block"><div class="row"><div class="col-sm-4"><a class="list-group-anchor"><span class="list-item-main-title ' + ExpTextColor + '">' + AdvancePaymentItem.PaymentNo + '</span></a><br><span> ' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(AdvancePaymentItem.PaymentDate, 'DD MMM YYYY') + '</span></div><div class="col-sm-2 b-r ">' + Unibase.Platform.Helpers.DateTimeHelper.Instance().daysFromNow(AdvancePaymentItem.PaymentDate) + ' days ago</div><div class="col-sm-2 b-r text-right">' + TotalAmount + '</div><div class="col-sm-2 b-r text-right">' + ConsumedAmount + '</div><div class="col-sm-2 b-r text-right">' + RemainingCredit + '</div></div></div><div class="panel wrapper-xs panel-success text-dark d-block d-sm-none"><div class="card p-2 m-0"><div><span class="list-item-main-title">' + AdvancePaymentItem.PaymentNo + '</span></br><span>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(AdvancePaymentItem.PaymentDate, 'DD MMM YYYY') + '</span></div><ul class="d-flex justify-content-between align-items-center"> <li>Total</li><li>' + TotalAmount + '</li></ul><ul class="d-flex justify-content-between align-items-center"> <li>Consumed </li><li>' + ConsumedAmount + '</li></ul><ul class="d-flex justify-content-between align-items-center"> <li>Remaining</li><li>' + RemainingCredit + '</li></ul></div></div></li>';
- $("#" + instance.PopUpContainerId).find(".list-Report-Payments:last").after(html);
- }
- $("#" + instance.PopUpContainerId).find(".span_Listsearch_count").text(CreditsCount + AdvancePayments.length);
- }
- else {
- instance.noData();
- }
- });
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new CustomerCreditHealth();
- }
- return this.instance;
- }
- }
- Controls.CustomerCreditHealth = CustomerCreditHealth;
- })(Controls = Transact.Controls || (Transact.Controls = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
|