1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895 |
- 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 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").append('<option disabled="disabled" value="0" selected="selected" style="display:none;">Filter</option>');
- $("#ItemLoadType").val(0);
- 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;
- }
- showPrintErrorModal() {
- bootbox.alert("Please configure print template");
- }
- 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;
- }
- 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_row_total(element, true);
- }
- else {
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().GetPlanItems(element.find(".selectedItemId").val(), Qty, element);
- Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_row_total(element, true);
- }
- }
- 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_row_total(element, true);
- }
- }
- 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.CurrencyId != 0) {
- $(".hdn_currencyid").val(data.CurrencyId);
- $(".hdn_conversionrate").val(data.ConversionRate);
- }
- 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.CurrencyId != 0) {
- $(".hdn_currencyid").val(response.result.CurrencyId);
- $(".hdn_conversionrate").val(response.result.ConversionRate);
- }
- 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 (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4"))
- maxQty = item.Quantity;
- }
- 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;
- }
- let expenseitemrow = false;
- $(".addedexpense-row").each(function () {
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- if (($(this).find(".exppercentage").val() == "0" || $(this).find(".exppercentage").val() == "") && ($(this).find(".expfixedvalue").val() == 0 || $(this).find(".expfixedvalue").val() == ""))
- isemptyrow = true;
- }
- if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined)
- expenseitemrow = true;
- });
- if (isemptyrow) {
- MessageHelper.Instance().showError("Please enter percentage or value for Expense 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;
- }
- if (expenseitemrow) {
- MessageHelper.Instance().showError("Please Select Expense 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;
- }
- let expenseitemrow = false;
- $(".addedexpense-row").each(function () {
- if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
- if (($(this).find(".exppercentage").val() == "0" || $(this).find(".exppercentage").val() == "") && ($(this).find(".expfixedvalue").val() == 0 || $(this).find(".expfixedvalue").val() == ""))
- isemptyrow = true;
- }
- if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined)
- expenseitemrow = true;
- });
- if (isemptyrow) {
- MessageHelper.Instance().showError("Please enter percentage or value for Expense Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- return false;
- }
- if (expenseitemrow) {
- MessageHelper.Instance().showError("Please Select Expense 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';
- const selectId = `#txt_Account_${this.rowIndex}`;
- AutoCompleteHelper.getHelper().Create(selectId, hfAccount, url, function (response) {
- $(selectId).off('select2:open').on('select2:open', (e) => {
- const dropdownEl = $($(e.currentTarget).data('select2').$dropdown);
- dropdownEl.addClass('select2-account-container');
- });
- });
- }
- 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 = moment($('.date_journaldate').val().toString(), "DD/MM/YYYY").format("YYYY-MM-DD");
- 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")) {
- if (!element.hasClass('SplitItem'))
- 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 && $('#hfInv_IsRetun').val() != "1") {
- 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();
- InvoiceItem.Instance().update_expense_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) {
- 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].toString().replace(/,/g, ''), 2);
- if (resultData != null && resultData != undefined) {
- resultData = resultData.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
- }
- $("#" + instance.ContainerId).find("#" + elem).text(resultData);
- }
- }
- if (resultData == 0) {
- $("#" + instance.ContainerId).find("#" + elem).text("0.00");
- }
- });
- }
- });
- }
- 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 = {}));
|